|
As Pete says, the database location is probably relevant here - you should never store data in the app folder as it tends to work in development, but fail in production. The reason for that is that in production it's installed under "Program Files" (or its x86 equivelant) which is protected from changes by the system to help prevent virus activity.
Have a look here: Where should I store my data?[^] - it shows some better places, and how to access them.
In addition, it's a poor idea to just us an anonymous INSERT - you should list the columns in the order you are going to INSERT them as this means your code is more resilient to changes in your DB. Use:
INSERT INTO ENVIO (Raid, Nparte, Cantidad, Ventana, Lider, Fecha) VALUES (@RAID, @NPARTE, @CANTIDAD, @VENTANA, @LIDER, @FECHA) (Or similar) instead.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I have a rather complicated class describing an xml structure, I've been using the .net XmlSerializer and its has worked for almost all of my purposes except for one very important kink.
I have an element deep in my xml object where the rules are no more. The element has text and xml elements mingled in with the text. Like so.
<KnownElement>
Here is some text <c>This is important text</c> here is some more text <c>Yet more important text stuff</c> more text
</KnownElement>
I need to be able to know at the very least, where the text is and where the important text is (which can assume different tags by the way, so need to know which tags they assume too), in regards to each other.
This is as close as I've gotten to a solution.
public class KnownElement
{
[XmlAnyElement]
public XmlElement[] DocumentNodes { get; set; }
[XmlText]
public string[] Text { get; set; }
}
This allows me to retrieve the nodes for the important text as well as the text that isn't in a node, but inside the KnownElement. The only problem is I have no idea in which order they're all are in the grand scheme. The DocumentNodes property returns an ordered enumeration of the nodes (important text) inside KnownElement, and the Text property returns an array of strings of which are an ordered occurrence of text separated by nodes.
This is neat, but say I have only one node, and one text... I have no idea if the text came before or after the node.
Is there anyway to get the desired effect without me throwing up a xmlreader or something like that...? I would hate to iterate through the HUGE structure this little bit is found within.
|
|
|
|
|
"If thine eye ("c" in this case) offends thee, pluck it out!".
Do a "change all" on any
" <c>" and
"</c> " to some other harmless tag or token.
(These should have been "HTML escaped")
|
|
|
|
|
I have a Bat file that I can load outside of C# but wanted to have it inside of C# to be more secure(load it inside of the exe of C# code).
I can't wrap it out my head on how you would load a batch file inside from C#. Here is my code on how to load it outside of C#:
try
{
var newProcessInfo = new System.Diagnostics.ProcessStartInfo();
newProcessInfo.FileName = @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe";
newProcessInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
newProcessInfo.Verb = "runas";
newProcessInfo.Arguments = @"-executionpolicy unrestricted -Command "".\power\gwx\uninstallgwx.bat""";
System.Diagnostics.Process.Start(newProcessInfo);
MessageBox.Show("Windows 10 Updater uninstalled");
}
catch
{ }
|
|
|
|
|
Powershell is for powershell-scripts. Batch-files are executed on the console (cmd.exe), using the Proces class.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You cannot "load a batch file" and there is no such thing as "load it inside C#".
Your application would have to be written as an interpreter for a BAT file to be "more secure".
Old batch files have to be written to disk in order to be executed, thereby defeating your "security".
Powershell scripts can be executed inside your application, but you have to host the execution environment in your app. The script can come from a string resource inside your app.
Really, what are you securing? There's nothing in these scripts that should be that earth shattering as everything would be in clear text, including any passwords. Putting a password in a text file is just plain stupid.
|
|
|
|
|
Thank you! I just didn't want to have the files all packed away in a folder to make it easier for the user.
|
|
|
|
|
Last weak my teacher says that it's better to not use the C#6 code for ASP.NET MVC web applications like below but he didn't say why. Can you explain me why?
using static system.Math;
string text = $"hello, {yourName}! the square root of 5 is {Sqrt(5)}.";
|
|
|
|
|
That's his humble opinion, that's all.
There is no concrete reason for his statement.
|
|
|
|
|
As Dave said, that's your teacher's opinion. The only person who can explain why he holds that opinion is your teacher.
Personally, I dislike the using static syntax, and would never consider using it. I think a lot of the other C# 6 features make your code much cleaner and easier to read. The only time I'd avoid using them would be if I had to share the project with someone using Visual Studio 2013 or earlier.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Did your teacher mean they didn't like ALL the new features of C# 6, or that they didn't like the new extended semantics of the 'using statement ? uhhh ... how can we possibly know ?
Perhaps your teacher is concerned about this:
"Using static imports only accessible static members and nested types declared in the specified type. Inherited members are not imported." Or,this: "Using static makes extension methods declared in the specified type available for extension method lookup. However, the names of the extension methods are not imported into scope for unqualified reference in code" [^].
So, you might ask your teacher, gently, if they meant you should not do your assignments compiling with C#6, or just not to use the new features in C# 6.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
I get an error when trying to access a non-user mailbox (Process MailBox): "The SMTP address has no mailbox associated with it."
This is the code I use. This has been working since 2010; but stopped working last week.
static void Test()
{
string MailBoxAdd = "xxxx.xx@dom.com";
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl(MailBoxAdd, RedirectionUrlValidationCallback);
ItemView view = new ItemView(10);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived, ItemSchema.HasAttachments);
FolderId folder = new FolderId(WellKnownFolderName.Inbox, new Mailbox(MailBoxAdd));
FindItemsResults<Item> findResults = service.FindItems(folder, view);
}
Appreciate your help...
|
|
|
|
|
PLease do not post the same thing in multiple places: it duplicates work and that annoys people.
You have this posted in QA, so leave it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hello,
I want to implement a feature of floating window (similar to dropbox which floats when we open File editors like excel) using .net.
I want to trigger a popup window, only when windows explorer is in foreground.
How to do this?
|
|
|
|
|
Hello,
What I need is a table with two columns.
1 column gives an assignment such as "Baker" or "Miller".
column #2 is where a user can enter a name anytime, on the fly.
The logic will assign person X to the "Baker" or "Miller" role.
The issue here is that the Person class has many more attributes. And I'll need to make this so if someone is assigned the "Miller" role, then it can assign the "Miller" to the proper "environment" class. E.g. "Bob" is a "Miller" and should work in a "Bakery".
So far, I have a People class, a Jobs class, and an Environment class. I was thinking of having the Jobs class inherit the people class to use their functions, and the environment class inherit from the jobs class... But now I'm thinking this won't work at all and am a bit confused.
Any thoughts would be GREATLY appreciated.
|
|
|
|
|
Things will make more sense when you consider your object relationships in the context of composition (i.e. "has-a") versus inheritance ("is-a"), which is what you are doing.
You would use object references / "links" between people, jobs and environments in this case; versus sub-classing:
- Each person can be assigned one or more jobs (?)
- A job is performed in which environment(s)
Jobs and environments, however, could easily be sub-classed from other classes; e.g. Jobs - Engineering - Mechanical - etc.
|
|
|
|
|
Just to expound on what Gerry said, what you're talking about is a property relationship rather than a polymorphic one. You'll likely find you're best served by using a mapping class like so:
public class Person
{
public string Name { get; protected set; }
...
}
public class Role
{
string Title { get; protected set; }
...
}
public class RoleAssignment
{
public Person Person { get; protected set; }
public Role Role { get; protected set; }
}
public class Environment
{
public IEnumerable<RoleAssignment> Roles{ get; protected set; }
...
}
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
You use the word "table" here: are you talking about a DataTable, or DataTables in a DataSet ?
It is not clear to me if you need a database with three DataTables ... for Persons, for Work Roles, for Work Environments, or, if the "business rules" are so clear-cut that you can user fewer DataTables: for example, if a "Baker" always works in a "Bakery" do you have to have a separate DataTable of Bakeries.
If each "entity" (Person, Work-Role, Work Environment) has multiple instances, then, yes, you need multiple DataTables/Classes.
I suggest you make an outline of the functionality you need in the "final product," and, then, work backwards from that, and revise your question here to be clearer.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
Hello Bill,
Figured our the posting problem!
When I say table, I am speaking of a database table.
I have a pool of 20 people. And need to be able to assign those people to different jobs everyday.
Bakers always work in bakeries, etc. this is correct.
What is absolutely necessary is for my code to be able to read a file, determine if it's part of X environment, and assign it to the corresponding role.
Note that this is only one module of the programs functionality, and a person will have other attributes as well, to suit other said functions.
|
|
|
|
|
For anyone reading, found some logic that may help.
I could make a method that iterates through a text file list of people which will then make a new object for each person. This will allow the program to make the objects, and then I'll just need to assign said objects to the proper ENV
|
|
|
|
|
Partial Answer to my question has been determined. All code below.
Basically, I need to create a person class, and a job class. The person class will have a null value for their job. The job class will specify what the job is, and logic for assignment. The person will then be assigned a job with the same name as their job class instance. The 'hook' will find the person obj with a job type, and then run it as an argument on the job class object.
class Role
{
public string Baker { get; set; }
public string fireFighter { get; set; }
public string chief { get; set; }
public string myName;
public Role(string myName)
{
this.Baker = myName;
}
}
static void Main(string[] args)
{
const string f = "textfile1.txt";
List<string> lines = new List<string>();
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
lines.Add(line);
}
}
List<Role> whoIs = new List<Role>();
foreach (string s in lines)
{
Role temp = new Role(s);
whoIs.Add(temp);
Console.WriteLine(temp.Baker);
}
whoIs.ForEach(Console.WriteLine);
Console.ReadKey();
Role assignTarget = whoIs.Find(x => x.Baker == "Corey");
assignTarget.fireFighter = "BatMan";
Console.WriteLine("Corey is {0} ", assignTarget.fireFighter);
Console.ReadKey();
}
}
|
|
|
|
|
Hello 1 i need to know as i have made my sales system project on a simple windowform and a coding behind , i mean to say without any n tier or 2-3 tier layers, but now i wanna add (search information of items code) with the help of layers in a existing project ,when i have written all code inside project there occur some problem in a biz and Ui layer , it requires assembly refernce i m trying to build my biz and ui to give both their reference but it failed 1 and gives this similar kind of error ,on the other hand my dal layer is build successsfully. please guide me.
|
|
|
|
|
I'm sorry, but we can't.
Partly because your question is unreadable (please try to learn what punctuation is, how to use it, and what capitalization is for), partly because you don't give us even slightly enough information about what "some problem in a biz and Ui layer" means, and partly because it sounds like you are trying to bolt a three layer model onto an existing project without changing anything. That's not generally a good idea: it's difficult to separate the concerns in an existing project, normally it's a lot easier to sit down and rewrite it from scratch with a better model in mind.
So remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work from, and think about your question from that perspective.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
sorry my article is error
modified 28-Jun-16 6:34am.
|
|
|
|
|
Ummm.... what are you doing?
This is not the place to post articles and what you've posted cannot even be considered an article.
There's a menu bar near the top of this window with an item called "articles". Under that menu theres a green button called "Submit an article or tip". If you want to post an article that's the place to do it.
Oh, and if you want it to be published your article better have a much more in-depth discussion about what you're doing and why. An article is not a place for a bunch of unexplained code dumps.
|
|
|
|
|