|
I had already debugged and there was nothing wrong with the result being returned at that stage of the method.
It turns out the problem was, I copied a list of names from the web, and pasted them into the comboBox. Evidently it didnt put them in as separate strings even though it showed each one on a new line. When I went back and entered the names manually it worked perfectly.
Thanks to everyone for your assistance
|
|
|
|
|
I am just getting started on building a workflow engine. I know I can build tasks in DLLs using the Workflow Foundation or to trigger a stand-alone executable but I am looking to add in the ability to write the task code in a scripting language similar to JavaScript, TypeScript, or LUA. I know this is a broad question but I don't really know where to start. Is it even possible? If it is, would this be a major endeavor or something relatively simple?
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
There's a proud history of hosting languages inside C# applications. One you'll often find mentioned is IronPython.NET. There's an example showing how to host it here[^]. Hopefully that will get you started.
This space for rent
|
|
|
|
|
Thanks for the link. I visited the website and noticed that there has not been an update to IronPython.NET since 2014. Should I be concerned?
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
You have a ton of options for scripting languages. If the choice of scripting language is not driven by the anticipated skills of the future users then I would suggest using C# for scripting. One of the most prominent solutions is CS-Script[^]. With Roslyn there's a relatively new solution, potentially even better (I haven't used it yet): roslyn scripting - Google Search[^]
Foothill wrote: would this be a major endeavor or something relatively simple? Somewhere inbetween unless you decide to create your own DSL, which will make it a major endeavor but could potentially be the best solution if one of your goals is to make it as user-accessible as possible.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thanks for the links. I've heard of Roslyn but I never looked into it before. I like the idea of being able to write a C# workflow in text, store it anywhere (file, database), and execute it when needed.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
Roslyn is awesome. I really like it.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Jint[^] is a JavaScript interpreter written in C#.
If you don't mind importing native DLLs, PythonNET[^] is quite cool.
Roslyn has been mentioned already, and the official repo is on Github[^] (Beware, the build process can be quite finicky at times, failing for no obvious reason)
NLua[^] allows .NET applications to leverage the Lua language (currently Lua 5.2).
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Jint looks interesting. I will have to follow it.
Brisingr Aerowing wrote: Beware, the build process can be quite finicky at times, failing for no obvious reason
Interestingly enough, I used to work with MS System Center Orchestrator and one thing I really liked about it was that you could write actual C# code to be used anywhere in a Runbook. I don't know why I didn't think of it before because it was using Compiler Services the whole time. It too would throw some cryptic errors when I forgot to put the end quote on a string literal or a parameter was empty.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
The errors from Roslyn are pretty much always to the point and actually tell you what went wrong.
I don't use Jint, so I can't say what it's like.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I've been looking at about a dozen flavors of scripting strategies for C# including those mentioned here (but, not Lua, Python, or IronPython). There's lots of open-source projects going on that offer scripting from light to heavy.
Defining what the facilities you need now, and in the future, seems to me the most criteria for choice of package. And, one can use T4, or .NET's compiler-services to generate code, or objects, on-the-fly, compile, run, instantiate the objects, etc.
One interesting script language for C# I have been exploring is Jing Lu's ReoScript; he used that in the ReoGrid project that he presented in an article here (just look it up); Jing made the choice to move ReoGrid from open- to closed-source some time ago, but his last open-source version is still up here. AFAIK ReoScript is still available as open-source: [^].
«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
|
|
|
|
|
There seems to be a lot of competing scripting implementations for .Net. I do happen to be gravitating to Roslyn as you can write normal C#/VB code outside of a library and execute it inside the CLR. The idea of writing all your workflows in text and placing them in any storage medium, granting the workflows a level of independence from the program which executes them, affords system architects a level of flexibility that is hard to ignore.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
Is there any plugin or provision for End user can build a query and generate a Chart.
Example: My application have a list of master items, i can select master item and make a project. Consider i have 20 master items in which 5 projects are In Progress, 5 are Completed projects and 10 items Not started a Project yet. Based on this i want to draw a pie chart or a bar chart.
|
|
|
|
|
Where does the data come from and how is it managed? And when you say 'plugin', plugin for what? Please put some proper detail in your question.
|
|
|
|
|
Plugin for accepting the data returned by query and to generate a chart.
Data i have a plan to display tables or views which enduser can query
Thanks,
Gopichand N
|
|
|
|
|
|
Am sorry for asking the question here. Initially i don't find where to ask the question then i came here and posted. If possible can you move it to my questions.
Thanks,
Gopichand N
|
|
|
|
|
Sorry no, I do not have the power to move it. However, that is not the issue, it is the fact that we have no idea what your problem is.
|
|
|
|
|
I'm stil beginner in c#. and i have made a small program. here is Main Program :
class Program
{
public static void Main()
{
while (true)
{
Console.WriteLine("Welcome");
Console.WriteLine("1 to go to Data class");
Console.WriteLine("type q to exit");
string input = Console.ReadLine();
if (input == "1")
{
}
else if (input == "q")
{
break;
}
else
{
Console.WriteLine("invalid option");
}
}
}
}
And this One is the Data Class.
class Data
{
public Data()
{
while (true)
{
Console.WriteLine("Choose Option : ");
Console.WriteLine("Press 1 to add and Press 2 To Go to Main Program");
int entry = int.Parse(Console.ReadLine());
if (entry == 1)
{
Console.WriteLine("Enter any number ");
int input = int.Parse(Console.ReadLine());
int result = input += 3;
Console.WriteLine("result");
Console.WriteLine(result);
}
else if (entry == 2)
{
}
else
{
Console.WriteLine("Invalid OPtion");
}
break;
}
}
}
And I want to do is . When the user type 2 in data class. then the program should go to main program, but unfortunately I dont know how to do that. Anyone Help please
|
|
|
|
|
Basically, don't.
Look at your code for the Data constructor (I'll rip out some of it top make it clearer):
while (true)
{
...
if (entry == 1)
{
...
}
else if (entry == 2)
{
}
else
{
...
}
break;
} Which means that regardless of what path you take though the if, you will always exit your loop at the end of the first iteration. So why is the loop there at all?
But there are more fundamental things: why are you getting the values inside the class constructor at all? That "locks" the class to always only work from the Console, you can't create an instance from data he entered last time if you save it. That's bad design - there is no good reasond for the Data class to have any idea where the data comes from. In fact is much, much better from an OOPs standpoint if the class has no idea where data comes from!
But your Data class is not a "real" class - it's just code you will call from your main method by a silly mechanism.
Classes aren't there to act as "super containers" for blocks of procedural code - they are supposed to be there to contain the data and it's related methods so each instance can work on it's own data.
For example, a simple class:
public class User
{
private string name;
private string hairColour;
private DateTime dateOfBirth;
public User(string name, string hairColour, int year, int month, int day)
{
this.name = name;
this.hairColour = hairColour;
dateOfBirth = new DateTime(year, month, day);
}
public int GetAge()
{
DateTime start = dateOfBirth;
DateTime end = DateTime.Now.Date;
int days = end.Day - start.Day;
if (days < 0)
{
end = end.AddMonths(-1);
days += DateTime.DaysInMonth(end.Year, end.Month);
}
int months = end.Month - start.Month;
if (months < 0)
{
end = end.AddYears(-1);
months += 12;
}
int years = end.Year - start.Year;
return years;
}
public string GetDetails()
{
return string.Format("{0} ({1}) is now {2}", name, hairColour, GetAge());
}
}
You create users thus:
User mike = new User("Mike Smith", "Blonde", 1990, 11, 14);
User joe = new User("Joe Ninety", "Mousey", 1983, 2, 1); And the class then handles all the work itself:
User mike = new User("Mike Smith", "Blonde", 1990, 11, 14);
User joe = new User("Joe Ninety", "Mousey", 1983, 2, 1);
Console.WriteLine(mike.GetDetails());
Console.WriteLine(joe.GetDetails());
And it will print:
Mike Smith (Blonde) is now 25
Joe Ninety (Mousey) is now 33
The User class is independent of the input and output mechanism, it just handles users and their data.
Do you see the difference between that and what you are trying to do?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I have a treat for you
public static class AgeCalculationExtension
{
public static int CalculateCurrentAge(this DateTime birthday)
{
return CalculateAgeAsOf(birthday, DateTime.Today);
}
public static int CalculateAgeAsOf(this DateTime birthday, DateTime appointedDate)
{
if (appointedDate < birthday)
throw new ArgumentOutOfRangeException(nameof(appointedDate));
int age = appointedDate.Year - birthday.Year;
if (birthday > appointedDate.AddYears(-age))
age--;
return age;
}
}
edit: Added input validation.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
modified 27-Apr-16 7:48am.
|
|
|
|
|
Ooh goody. Here's an input for it:
DateTime dateTime = new DateTime(1968, 2, 29);
int age = dateTime.CalculateAgeAsOf(new DateTime(1964, 2, 29)); Apparently, that person is -4.
This space for rent
|
|
|
|
|
Totally correct answer.
You have the birthday in 1968, and are asking age as of 1964.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
While it's syntactically correct, it's also logically bogus. It's why public inputs should always be checked.
This space for rent
|
|
|
|
|
I agree - and added it.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|