|
I would use Context.Refresh(RefreshMode.StoreWins, obj) as my "Plan B".
My "Plan A" would be keeping changes outside of Context until they are ready to be committed, and then apply and commit them in an atomic operation. This requires more work as you need to track the state of newly added entities, but I think it is worth it, because the approach is cleaner overall.
|
|
|
|
|
Transaction. I've not worked with them with Entity Framework myself, but that seems like what you want.
|
|
|
|
|
Hi experts,
there is a PropertyGrid in my application. It shows properties of an object. Some of these properties can hold values that are illegal to business logic. Those values show a warning symbol by using a custom TypeEditor. Mentioned properties are marked by an attribute.
Some of the properties are even linked. Business logic decides whether or not a combination of linked properties is illegal.
To this point all is fine.
Now the PropertyGrid has to show properties of multiple objects and the warning symbols don't work any longer.
This method should tell whether a property can, depending on its value, warn by setting the symbol
public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
{
if (
context.PropertyDescriptor.PropertyType.IsEnum
&& Enum.IsDefined(context.PropertyDescriptor.PropertyType, "Invalid")
)
return(true);
foreach(Attribute attribute in context.PropertyDescriptor.Attributes)
if(attribute is WarnableAttribute)
return(true);
return (false);
}
The marked line fails for multiple objects.context.PropertyDescriptor is a PropertyGridInternal.MergePropertyDescriptor , which is not accessible due to access levels.
How could I test for an icon to be painted?
Edit: It's working now thanks to ITypeDescriptorContext containing an object called instance , which is an Array when selecting multiple objects.
Knowing that, it's possible to check for attributes with some reflection.
Ciao,
luker
modified on Friday, June 17, 2011 3:19 AM
|
|
|
|
|
Environment – VS2010, Window 7;iis7.0
We have created a Web service (EDI_Translate) and we are consuming this webservice in C# console application. This console application calls the web service in a loop continuously in different thread. The web server handles the request sequentially (like first in first out) but we want web server to handle the request parallely to boost the performance. What should be done in webservice code or web server in order to handle the request paralley by webservice code .
Ramesh Kumar Singh
Software Engineer
Ness Technologies
India
|
|
|
|
|
Without knowing anything at all about what the webservice actually does or how it does it how do you expect anyone to accurately answer this?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Calling the service in a loop sounds pretty serial to me. I suspect that the client is making requests in that form, and the server is not serialising them. Web services are (I think) intrinsically parallel. Try starting two clients and see if they interleave.
|
|
|
|
|
Hello everyone this is my first post so be gentle.
I've implemented a solution to download file,
the problem is that specific pdf files can't be downloaded with lots of bytes per package therefore I want to decrease the number of packages but in order to reduce the waiting time until download completion I want to download the file in sections which means to download parts of the file simultaneously when I implemented it I got an exception "Stream does'nt support multiple IO accesses" probably I'm doing something wrong can someone tell me what should I correct or how should I do it?
for (int i = 0; i < numberOfParts; i++)
{
httpRequest.AddRange("splittedDownload",Convert.ToInt32(i * size / 5),Convert.ToInt32((i+1) * size / 5-1));
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
streams.Add(new MyStream(httpResponse.GetResponseStream(),i+1));
IAsyncResult result = streams[i].Input.BeginRead(buffer, 0, paketSize, AsyncDownload, streams[i]);
}
Thanks.
|
|
|
|
|
You can't read a network stream with random access because the data you are trying to access doesn't exist yet. I don't think HTTP supports downloading files in sections, but I'm not sure about that – it supports starting a download from a particular point (that's how browsers can resume a download so you might be able to fire multiple requests for parts of a file.
Chances are though that the waiting time is to do with your connection speed and not this.
|
|
|
|
|
Thank you for the reply,
I've used AddRange in order to start downloading from specific place I think this is the method in order to do it please correct me if I'm wrong but the first request goes well but when I tried to start the second Async operation I get the exception.
I checked the pdf issue and I can see that I can download rar files in packets of 1024 bytes (I didn't check it with bigger packets) but pdf files are recieved corrupted if I download more than 2 bytes every time so it effects the download speed (the same file with 1024 bytes is downloaded in 26 seconds now with 2 bytes it grows to 37 seconds and this is small file,about 2.5 MB) so I think this is the right solution, can you please tell me what is may be wrong in my code in my last correspondence?
Thank you very much.
|
|
|
|
|
The number of bytes you read at a time should not affect the output. You are doing something wrong in your reading code if that is the case (perhaps writing the buffer size, not the actual number of bytes read, at each step). It should be something like
byte[] buf = new byte[buf_size];
int read;
while(0 < read = stream.Read(buf, buf_size)){
outStream.Write(buf, 0, read);
}
A common mistake is to write buf_size bytes to the output, not read bytes.
2.5MB in 26 seconds is roughly 800kbps, that is quite plausible for a transfer from the public internet.
|
|
|
|
|
Thanks, that was the problem
now I can download the 2.5MB file in about 13 seconds
anyway I would like to know what I did wrong with the download in parts (just to learn for the next time) but its not that urgent anymore.
Thank you very much
|
|
|
|
|
Hello Everybody,
I am drawing text, rectangle and Line. In which have i am tring to zoom Text but i m confused how to zoom text as per as zoom level.
Eg : Rectangle r = new Rectangle (x,y,width * zoomlevel,height * zoomlevel);
How to Zoom Text for ZoomLevel.
Thanks
If you can think then I Can.
|
|
|
|
|
You need to create a scaled version of the text's font.
|
|
|
|
|
The easiest way to do this is very simple: apply a Scaling factor to the graphics object you are drawing on. Create a Panel, and two buttons, then handle the appropriate events:
float sx = 1.0F;
float sy = 1.0F;
Font font = new Font("Verdana", 10.0F);
private void panel1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.ScaleTransform(sx, sy);
g.DrawRectangle(Pens.Blue, new Rectangle(50,50,150, 150));
g.DrawLine(Pens.Red, 0,0, 200,200);
g.DrawString("Hello there this is text", font, Brushes.Green, new Point(20,20));
}
private void butZoomIn_Click(object sender, EventArgs e)
{
sx *= 2;
sy *= 2;
panel1.Invalidate();
}
private void butZoomOut_Click(object sender, EventArgs e)
{
sx /= 2;
sy /= 2;
panel1.Invalidate();
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Oh, good call, I forgot about that.
|
|
|
|
|
Good Day all
i have a SQL Job and i want to change the times in the job programmatically from C#. The application that will change the Job Settings will be accessing the job remotely.
Is is possible ?
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Just curious, same question you asked here[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Yes you are right, this is because i want to see different types of View from different type of People. its not like i posted the same question in the same website.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Vuyiswa Maseko wrote: its not like i posted the same question in the same website.
Yes, I agree.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
You mean when it is scheduled to run?
Are you writing a SQL management tool? If not I don't see the point.
The point of having a scheduled job is to schedule it because it isn't dynamic (relatively speaking). And there are other ways to deal with dynamic problems.
I am rather certain you can create jobs via some API though. That would include setting the times. I would google for it.
|
|
|
|
|
Hi all,
i want to develop one addin for MS Word. document created under my addin can not open without my addin(i.e. if user don't have my addin, default screen to download addin will open....after install user can view the document). is it possible with Word addin? how?
Thanks,
Ankur
!- F - R - I - E - N - D - S -!
|
|
|
|
|
I would start by defining a new file extension for documents created with my add-in. When Windows encounters an unknown file type, it asks the user to identify an application to use for opening it, or offers to search the Web for a suitable application. Your download site will have to publish its ability to provide a suitable program for opening that type of file, and I have no idea how that is done, but I'm sure you can find that information using Google.
Will Rogers never met me.
|
|
|
|
|
Dear sir
Myself Pardeep working in the private sector. I am beginer in the C# environment. I got a task to stich(join) two images with removing overlap area one of the image. First i am tried a lot for loading two images in c#. I did't get any desirable help. please help me.I am waiting for your feedback.
Thank you.
|
|
|
|
|
I guess you need to start with the Image [^] Class.
The best things in life are not things.
|
|
|
|
|
- Load the two images with Image.Load
- Calculate or take as user input the overlap amount/direction
- Create a new Bitmap* for the combined image, taking into account the overlap when calculating the size
- Get the graphics object for the new bitmap (Graphics.FromImage, iirc)
- Draw the first two images into the combined bitmap with Graphics.DrawImage
*: unless you're combining metafiles or another vector format, but 'image' usually implies raster.
|
|
|
|