|
I am doing this way and it works fine.
public static class StringHelpers
{
public static string BuildFormula(this string formulatemplate, string value1, string value2)
{
return string.Format(formulatemplate, value1, value2);
}
public static string BuildFormula(this string formulatemplate, string value1, string value2, string value3)
{
return string.Format(formulatemplate, value1, value2, value3);
}
}
Calling this way
---------------------
BrokerCountFormula = FormulaTemplate.BrokerCount.BuildFormula(
(StartPeriod + row.ToString()), (EndPeriod + row.ToString()));
|
|
|
|
|
I am doing this way and it works fine.
public static class StringHelpers
{
public static string BuildFormula(this string formulatemplate, string value1, string value2)
{
return string.Format(formulatemplate, value1, value2);
}
public static string BuildFormula(this string formulatemplate, string value1, string value2, string value3)
{
return string.Format(formulatemplate, value1, value2, value3);
}
}
Calling this way
---------------------
BrokerCountFormula = FormulaTemplate.BrokerCount.BuildFormula(
(StartPeriod + row.ToString()), (EndPeriod + row.ToString()));
|
|
|
|
|
Hi All,
As i am using below C# code in Asp.net web api(GET) to pull the records(8 lac records),i am facing an error i.e system.outofmemoryexception was thrown.Can anyone helpme out on this.Thank You.
public HttpResponseMessage GetLocation([FromBody] data data)
{
try
{
ds = objTransactionMgr.Getlocationdetails(data, ref objError);
if (ds.Tables[0].Rows.Count > 0)
{
var JsonList = ds.Tables[0].AsEnumerable().Select(dataRow => new get_location_details()
{
name = dataRow.Field<string>("name"),
order = dataRow.Field<string>("order"),
date = Convert.ToDateTime(dataRow.Field<datetime?>("date")),
location = dataRow.Field<string>("location"),
type = dataRow.Field<string>("type"),
id = dataRow.Field<string>("id"),
category = dataRow.Field<string>("category"),
seq = Convert.ToInt32(dataRow.Field<decimal?>("seq")),
address = dataRow.Field<string>("address"),
uom = dataRow.Field<string>("uom"),
volume = dataRow.Field<string>("volume"),
total = Convert.ToInt32(dataRow.Field<double?>("total")),
task_value = Convert.ToInt32(dataRow.Field<decimal?>("task_value"))
}).ToList();
return Request.CreateResponse(HttpStatusCode.OK, JsonList);
}
else
{
_messages.status = "Success";
_messages.message = "No rows to return";
return Request.CreateResponse(HttpStatusCode.OK, _messages);
}
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
}
}
|
|
|
|
|
Simple: don't load so much data.
Either reduce the amount of data your API is returning, or stream the results from the database[^] instead of trying to load them all into memory at once.
NB: If you go with the streaming option, you'll just be moving the error to the client, which won't be able to load the entire response from your API into memory.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard Thank you for your time.
As my client is looking for all the data at once and stream the results from database means what exactly
can u bit explain pls
|
|
|
|
|
Your Getlocationdetails method is currently loading everything into a DataSet . You would need to use a SqlDataReader instead, and write the records to the response as you read them.
Something like this:
public async Task<HttpResponseMessage> GetLocation([FromBody] data data)
{
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new PushStreamContent(async (outputStream, httpContext, transportContext) =>
{
using (var sw = new StreamWriter(stream))
using (var jsonWriter = new JsonTextWriter(sw))
using (SqlConnection connection = CreateConnection())
using (SqlCommand command = new SqlCommand("...", connection))
{
... ADD PARAMETERS HERE ...
await connection.OpenAsync();
using (var reader = await command.ExecuteReaderAsync())
{
if (!reader.HasRows)
{
var serializer = new JsonSerialize();
serializer.Serialize(writer, new { status = "Success", message = "No rows to return" });
return;
}
writer.WriteStartArray();
while (await reader.ReadAsync())
{
writer.WriteStartObject();
writer.WritePropertyName("name");
writer.WriteValue(reader["name"]);
writer.WritePropertyName("order");
writer.WriteValue(reader["order"]);
writer.WritePropertyName("date");
writer.WriteValue(reader["date"]);
...
writer.WriteEndObject();
}
writer.WriteEndArray();
}
}
})
};
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you sooo much for your time Richard i will try and get back to you.
|
|
|
|
|
I am trying to communicate with a EOS Rebel T7 on mac, but haven't had any luck.
I downloaded the latest version of the SDK, but could not test the Objective-C sample because I don't (can't yet) have Xcode on my computer.
I found this C# project to be instructive. Ultimately I was able to get the following C# code to compile without errors:
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using EOSDigital.API;
using EOSDigital.SDK;
namespace ConsoleExample
{
class Program
{
static CanonAPI APIHandler;
static Camera MainCamera;
static string ImageSaveDirectory;
static bool Error = false;
static ManualResetEvent WaitEvent = new ManualResetEvent(false);
static void Main(string[] args)
{
CanonSDK.InitializeVersion();
IntPtr camPtrList;
CanonSDK.EdsGetCameraList(out camPtrList);
int camCount;
CanonSDK.EdsGetChildCount(camPtrList, out camCount);
Console.WriteLine(camCount + " cameras found.");
}
}
}
However, I end up with camCount==0; "0 cameras found". I thought this might be because the EOS Utility (which opens automatically when plugging in the camera) is occupying the necessary resources, however I tried uninstalling EOS Utility and this did not help.
Can anyone provide a simple example that I can test (that doesn't require Xcode) in VS or VScode? Any help or advice would be much appreciated. Thank you!
PS: Figuring out how to compile in VS on mac was a struggle as I am unfamiliar with both, so I'm open to any suggestions for other IDEs/compilers/languages if it will make using EDSDK easier.
|
|
|
|
|
I'm unfamiliar with Canon EDSDK however I found this article[^] on this very site; the article has lots of high votes, but please don't expect it to make your job simpler...
Luc Pattyn [My Articles]
If you can't find it on YouTube try TikTok...
|
|
|
|
|
Hello,
First of all, I would like to inform you that I am not a software developer, I am dealing with it as a hobby.
I made a simple desktop application, there is a picturebox on the form, I want a website to be opened when I click on the picture, but it gives an error. I've been searching for a few days, there are similar issues but no answer.
Methods I have tried.
using System.Diagnostics;
private void pictureBox2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(@"https://www.website.com.tr/");
}
The error the codes give is "System.ComponentModel.Win32Exception: 'The system cannot find the file specified.' "
Error details.
System.ComponentModel.Win32Exception
HResult=0x80004005
İleti=Sistem belirtilen dosyayı bulamıyor.
Kaynak=System.Diagnostics.Process
StackTrace:
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at AcınımHepalama_001.Form1.pictureBox2_Click(Object sender, EventArgs e) in D:\ÖMÜR ÇALIŞMALAR\MU-uygulamarı\AcınımHepalama-001\Form1.cs:line 604
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
|
|
|
|
|
Try:
System.Diagnostics.Process.Start("explorer.exe", @"https://www.website.com.tr/");
"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!
|
|
|
|
|
thank you very much this code worked.
|
|
|
|
|
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!
|
|
|
|
|
|
Thanks for the reply, I'll look into the thread you mentioned.
|
|
|
|
|
You included expected results vs. actual results. You included actual exception.
Well done
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
i am just starting with c# and wondering if there is a way to read the contents of csv files stored in a particular folder on network and write it into an oracle table. Can someone give me an example so that i can try and test by myself.
|
|
|
|
|
|
To add to what Richard has said, there are several CSV reading packages - this one reads into a DataTable, so provided the columns match up with your database, they can be INSERTed with no other changes: A Fast CSV Reader[^]
"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!
|
|
|
|
|
The article I linked to also reads into a DataTable.
|
|
|
|
|
I have the following treeview class whose purpose is to draw an overlay on the icons in a node. Notice it overrides "OnDrawNode":
public delegate Image GetTreeIconOverlayMethod(TreeNode node);
public class OverlayTreeView : TreeView
{
bool drawOverlay;
int iconHeight;
int iconWidth;
public GetTreeIconOverlayMethod GetIconOverlay { get; set; }
public OverlayTreeView() { }
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
if (ImageList != null)
{
drawOverlay = true;
iconHeight = ImageList.ImageSize.Height;
iconWidth = ImageList.ImageSize.Width;
}
}
protected override void OnDrawNode(DrawTreeNodeEventArgs e)
{
base.OnDrawNode(e);
Image overlay = null;
if (drawOverlay)
if (GetIconOverlay != null)
if (!((e.Node.ImageIndex == -1) && (e.Node.ImageKey == null)))
overlay = GetIconOverlay(e.Node);
if (overlay != null)
{
int x = e.Node.Bounds.X + iconWidth - overlay.Width;
int y = e.Node.Bounds.Y + iconHeight - overlay.Height;
e.Graphics.DrawImage(overlay, x, y);
}
}
}
The overlay is not being drawn and it seems this is because the override is not being called at all. Any breakpoint put in this method does NOT gte triggered even though a breakpoint in OnHandleCreated is. It doesn't matter where I put the breakpoint within the method. (And yes... symbols are loaded).
I have no idea why this would occur...
|
|
|
|
|
The OnDrawNode method is used by the base class to raise the DrawNode event.
According to the documentation[^], that event is only raised if "the DrawMode property is set to a TreeViewDrawMode value other than Normal ."
It's therefore safe to assume that the OnDrawNode method won't be called if DrawMode is set to Normal .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
So what method would I override to add the overlay no matter what draw mode is being used? I can't find one, except perhaps OnPaint... but I would think Microsoft would have included a default drawnode method to use regardless of the draw method. Since the point of my class is to add the overlay, I wouldn't want a potential user of the class to have to specify a draw mode. (I know there are workarounds... but to me forcing us to use them doesn't make a whole lot of sense to me, especially considering the complexity of drawing a tree node).
|
|
|
|
|
There isn't one. The method is called in response to an unmanaged WM_ message, which will only be sent to the control if it's set to be owner-drawn.
Windows Forms controls are thin wrappers around native Windows controls. They can't add functionality that the native controls don't support.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|