|
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
|
|
|
|
|
|
Richard Deeming wrote: There isn't one. See my answer below for a solution.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
modified 5-Nov-21 6:03am.
|
|
|
|
|
Works for me:
Override 'OnCreateControl and set the 'TreeViewDrawMode Property ... with either 'DrawMode == 'OwnerDrawText or 'OwnerDrawAll: 'OnDrawNode will be called.
protected override void OnCreateControl()
{{
if (DrawMode != TreeViewDrawMode.OwnerDrawText)
{
DrawMode = TreeViewDrawMode.OwnerDrawText;
}
base.OnCreateControl();
}
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Hi,
I need to do a "cron mechanism" that does not block the entire program. It has to be performed at the time set by the user
int time_stop;
Task.Delay(time_stop).Wait(); .
time_stop is provided by the user. But this approach is not entirely consistent with my assumptions. Can someone guide me.
Sorry, but I'm just learning to code
|
|
|
|
|
You either need to set up a Timer Class (System.Timers) | Microsoft Docs[^] or a BackgroundWorker Class (System.ComponentModel) | Microsoft Docs[^]
Either will do, but without one or the other, you will block the UI thread waiting for the timeout to elapse - which will make it look like the whole application is locked up!
Me? I'd use a background worker and use the Progress reporting mechanism to update the UI thread when necessary:
private void FrmMain_Shown(object sender, EventArgs epp)
{
BackgroundWorker work = new BackgroundWorker();
work.DoWork += Work_DoWork;
work.ProgressChanged += Work_ProgressChanged;
work.RunWorkerCompleted += Work_RunWorkerCompleted;
work.WorkerReportsProgress = true;
work.RunWorkerAsync("A parameter of any type you want to pass it");
}
private void Work_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
MyTextBox.Text = "Done.";
}
private void Work_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
MyTextBox.Text = ($"Progress: {e.ProgressPercentage} - {e.UserState as string}");
}
private void Work_DoWork(object sender, DoWorkEventArgs e)
{
if (sender is BackgroundWorker work)
{
for (int i = 0; i < 1000000; i++)
{
Thread.Sleep(1000);
work.ReportProgress(i / 10000, $"An object of any type you want to pass back to the main thread: {i}");
}
}
}
"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!
|
|
|
|
|
If I use a loop
while (1)
{
Thread.Sleep (1000);
work.ReportProgress (i / 10000, $ "An object of any type you want to pass back to the main thread: {i}");
}
will I suspend the program?
The program is to be executed e.g. every day at 7:00 am
|
|
|
|