|
I have a good prototype to draw some fancy mathematical models in Windows Form application.
now I want to wrap this drawing logic into a chart control.
how difficult is it for this conversion?
try to get some ideas from you gurus here. plan to do this conversion in this year end break.
diligent hands rule....
|
|
|
|
|
Not too difficult: create a UserControl and start adding your logic code to that. If you code already draws on a form, it should work pretty much unchanged on a UC (remember that a Form is derived from Control and so shares a lot of properties and methods).
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
thanks for your confirmation! I will convert it by myself.
diligent hands rule....
|
|
|
|
|
You're welcome!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I had this code working in VB.net, and I tried switching it to C# as follows. did anyone ever do this before?
(how do I "type" objMyform? What would be the equivalent of "dim")
objMyForm = Server.CreateObject("CutePDF.Document"); 'Create form object
int nReturn;
objMyForm.initialize("FS21-001-39268470-03111634") ; 'Initialize object by serial number of the license
int familyID = session("FamilyID");
FM Family = new Family();
FM.GetByID(familyID);
Camper CP = new Camper();
int CamperID;
GetCamper(CamperID );
'Open an encrypted PDF form file from an URL with password 'cutepdf'
if objMyForm.openFile("/../Forms/Parentalconsent.pdf") == false then
errorMessage = objMyForm.GetLastError();
end if
'Set some value into fields
nReturn = objMyForm.setField("chkAgudah", CP.att_camp ==1? "on":"off");
nReturn = objMyForm.setField("chkBnos", CP.att_camp ==2? "on":"off");
nReturn = objMyForm.setField("chkCCM", CP.att_camp =31? "on":"off");
nReturn = objMyForm.setField("chknu", CP.att_camp ==4? "on:"off");
|
|
|
|
|
Quote: (how do I "type" objMyform? What would be the equivalent of "dim")
objMyForm = Server.CreateObject("CutePDF.Document"); 'Create form object
int nReturn;
The Dim statement in VB is simple:
Dim variableName As variableType = ... In C#, it's even simpler:
variableType variableName = ...
If you don't know both languages, then use an online converter: Code Converter C# to VB and VB to C# – Telerik[^] is the one I use.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Cute PDF SDJ support request: [^].
The form indicates questions re evaluation version may be accepted.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Hello everyone
i am using Thread and inside it there is for loop
it starts fast for first 30 times then it becomes slow and after 500 times it become much slower any idea why this happen?
modified 26-Dec-22 6:17am.
|
|
|
|
|
Without your code (and probably your data)?
We have no idea why this happens - there are just too many different things you could be doing! There is nowhere near enough information here for us to begin to help you - we have no idea what you are trying to do, or where you are starting from.
Start here: Asking questions is a skill[^] and think about what you need to know, and what you need to tell us in order to get help.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
you are right sorry for that
and i finally got what was the problem i am using inside loop linq and when i use function inside where it took too much time
|
|
|
|
|
It's OK, at least you tried to ask a "proper question" - it's not the worst question we've ever had, just look two threads down ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
of course, we have no idea how you are using Linq, but:
"inside loop linq:" keep possibility of multiple enumerations in mind: [^]
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Probably creating a memory leak.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I have an IEnumerable<employee> that I need to update some fields based on the user's security permissions. If a user is in the Admin or HR roles, the CanEdit and CanDelete properties should be set to true. If the user is not Admin or HR, but is their own record, CanEdit should be true. I have come up with two options, and wanted to know which would be considered the better method (or a different way) for speed, readability, and maintainability.
Method 1 first checks if the user is Admin or HR, then loops through the entire collection and updates the values. If the user is not Admin/HR, then it checks each record to see if it is the users and updates. Currently, a user can only have one record, so I quit once I update the matching employee record.
if(_userManager.User.IsInRole("Admin") || _userManager.User.IsInRole("HR"))
{
foreach(var employeeRecord in employeeList)
{
employeeRecord.CanEdit = employeeRecord.CanDelete = true;
}
return employeeList;
}
foreach(var employeeRecord in employeeList)
{
if(employeeRecord.WorkEmail.Equals(_userManager.User.Identity.Name, StringComparison.OrdinalIgnoreCase))
{
employeeRecord.CanEdit = true;
return employeeList;
}
}
return employeeList; Method 2 stores a boolean if the user is an Admin/HR, and just sets that as the permission, then checks if the current employeeRecord belongs to the user and sets the permission.
bool hasEditDeletePermission = _userManager.User.IsInRole("Admin") || _userManager.User.IsInRole("HR");
foreach(var employeeRecord in employeeList)
{
employeeRecord.CanEdit = employeeRecord.CanDelete = hasEditDeletePermission;
if(_userManager.User.Identity.Name.Equals(employeeRecord.WorkEmail, StringComparison.OrdinalIgnoreCase))
{
employeeRecord.CanEdit = true;
}
}
return employeeList; Method 2 seems shorter and easier to understand, but Method 1 can be faster when the user isn't Admin or HR, which would happen more often. There's also the issue that Method 1 leaves the CanEdit/CanDelete values to whatever they were originally supplied as (currently defaults to false), where as Method 2 will always override any preexisting values which might cause unexpected behavior if other rules are added elsewhere.
Any recommendations on which you would rather use, or even suggestions on better ways to code this would be appreciated.
|
|
|
|
|
If the user was limited to certain records in the first place, that particular process should have been "data driven" with a proper query. Instead, you've got "generic" process that attempts to apply some logic to "every record" from who knows where.
The "data driver" could be data records, references or simply keys. Another design decision.
What you're dealing with is affectionately known as "tramp data".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Could you explain a bit more what you mean by 'data driven with a proper query'? Almost every tutorial/example I've found only seems to be basic "Can Access/Can Not Access", but my needs are more granular. I'm currently using CQRS to have my Controller send an EmployeeQuery request. I've added a pipeline to the request handler which has my security logic and updates the results from the query as I need to apply information not just to the records themselves, but also potentially individual properties of the record. I didn't want to mix my security logic in with my query as I thought that could get hard to expand in the future. Here's an example of the current rules/permissions:
- Admin : Full Create, Read, Update, (Soft/Hard) Delete.
- HR : Full Create, Read, Update, Soft Delete.
- Manager : Full Read (of specific columns), Update of their own record (excluding some columns).
- User : Full Read (of specific columns different than Manager), Update of their own record (excluding some columns).
I'm using EFCore and LINQ for the query and I had first thought about trying to have the security logic in the pipeline 'build' the IQueryable that will get executed by the query handler, but I haven't found a good resource on how to do that, so I am updating the results of the handled query before sending it back to the Controller.
|
|
|
|
|
Context is important. You make references to IEnumerable when operations like "create", update and delete (of a give user's record) typically don't involve "updating sets"; they involve a single record or object graph.
"Browsing" implies sets, and is generally only limited in a broad sense (one may or may not access this particular "view").
When talking about "roles", this is not something that starts at query time; it starts as soon as the user has logged in and identified themselves. The app should be aware of parts to limit based on roles; which includes forms, reports, menu items, and sensitive data (which may involve limiting tables, records, columns, ranges, etc. based on need).
The "back end" accesses "views" of the data based on roles; and applies "need to know" filters before it even tackles the user's request. Still a pipeline, but with some extra "role filters" in between components; which includes the interactive / online / real-time parts.
So, you need to maintain and interface with a user's "role object" from start to finish. And the data that is finally handed off to that actual "insert" or update (that last "grain") is then free of any "role checking".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
as Gary says (imho), you should not be retrieving all records, and then using Linq: you EF query should pull only the records that need updating, and, then, write those updated records back to the data store.
IEnumerable: keep an eye out for multiple enumerations: [^]
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Have an object - user details that stores the info on the current user and a list of permissions. This should be populated when the user logs on.
Each page checks the user object for permissions and set 1 or more flags that control the state of the form controls and the content of any lists for the form.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
|
perhaps the OP thinks this is a psychic hotline ?
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
He will meet a tall, dark stranger and should avoid elevators and shellfish until Tuesday ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Well, first you've gotta wait for the keyboard to do it's magic (press any key). Then when the log-in screen appears out from behind the screen saver, you've gotta stand up. Now move your head as close to perpendicular to the lit screen and, looking down onto it's surface, identify where the spots of spagetti sauce are most concentrated. Notice that the most crusty of these clusters of dinner spatter might be well congealed and therefore hard to wipe off with cold water (test run a "scrape" using a fingernail). Get a cloth rag then, soaked with HOT water, and lightly, from this high advantage point above the frame of the monitor, in a bak-and-forth manner, rub the sauce from the darker backlit spots until they have been removed. After, dry with a paper towel. And you're good to go.
|
|
|
|
|
When I started reading that, I assumed it was going to end with "tell them 'I am too damn stupid to own a computer'"
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|