|
I would have to know what the offset is that I'm looking for, then add that to the DateTime I'm using as my paramater
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
So you want the rows where the local value of the DateTimeOffset is after a particular DateTime value?
Seems a bit strange to me, but you should be able to do something like this:
int startYear = startDT.Year;
int startMonth = startDT.Month;
int startDay = startDT.Day;
int startHour = startDT.Hour;
int startMinute = startDT.Minute;
int startSecond = startDT.Second;
...
where t.Started >= EntityFunctions.CreateDateTimeOffset(
startYear, startMonth, startDay, startHour, startMinute, startSecond,
SqlFunctions.DatePart("tz", t.Started))
...
EntityFunctions is defined in System.Data.Entity.Core.Objects in the EntityFramework assembly;
SqlFunctions is defined in System.Data.Entity.SqlServer in the EntityFramework.SqlServer assembly.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Good evening everyone I'm looking on google but I do not find a solution that allows me to display the checkbox check in datagridview in a line specify. The display should not be vertical as the result in this image.
|
|
|
|
|
|
How can I implement NLP in c# program? Is there any logic for extracting single/multiple words from one or more sentences?
For more understandability, I included a paragraph(Doctor's Note) here.
The patient x is suffering from fever. He has no headache, cough or neck pain. But he has back pain.
Moreover patient x suffers Sleeplessness.
<big>My requirement is</big>,
I need to iterate symptoms such as <big>fever, back pain and sleeplessness</big>. And
do not take symptoms <big>headache, cough and back pain</big> .
|
|
|
|
|
|
There is no package yet that can guarantee correctness. Unless the doctors adhere to a specific syntax you'll run into weird phrases.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hey volks,
I would accomplish the following scenario:
I have a C# Application, it hast registered OS-Extension (*.fpf) and comes as ClickOnce.
Now i would have the ability to save variables into a "project-file" that is saved somewhere on the system and if i doubleclick the C# application starts and read the stuff of the project-file.
Any idea how to solve this is welcome...
Thanks in advance,
Matthias
|
|
|
|
|
Member 11045388 wrote: Now i would have the ability to save variables into a "project-file" that is saved somewhere on the system and if i doubleclick the C# application starts and read the stuff of the project-file. You register a new file type. See MSDN[^], or here[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
well, that is done so far, i registered a extension for my app and when i open the associated file (which contains strings (with line breaks) the application open correctly. What i don't know is how to use the text part inside the app now. When i use filestreamreader - how do i say how to use the lines of the file (the one that i double-clicked) ....
any Idea how to do this?
|
|
|
|
|
Unless you expect your file to be yuuge, you probably don't need a streamreader. File.ReadAllText would do, and that would return a string. Split it on characters #10 and #13 (CR LF) and you'll have an array of lines.
You'll have to "find" the appropriate entry by looking at those strings.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks - that is ok for me, all i need to know is how to use the file that i double-clicked. That is not clear to me ... the app start when i double-click on it, but how can i access the textfile (what is needed that the app knows it is opened by a textfile and parse the values). I read actual about
Environment.GetCommandLineArgs(); but unfortunately it seems to be empty 
|
|
|
|
|
I'd prefer to get the command-line arguments as passed into the main-method[^], but it should yield the same result.
It is an array of which the first item may be empty. If no arguments are supplied at all, then you probably did not register the correct command to launch the application. Did you include a "%1" in the command-line as registered to launch the application?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i found my error. The extension does not open with my exe file. Instead it opens with the ClickOnce Handler .... now i have to find out how to change this
When doing it right i get the filename and path that opens my app so i can continue from here i think.
Thanks for everybody!
|
|
|
|
|
Or let the system do it for you with File.ReadAllLines
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Lines! You're right!
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have an interface I need to implement. But one of the interface's members I cannot understand why the refactor in VS implement in a certain way.
Here is the interface. (Never mind the names for variables etc, I have changed them).
using System;
public interface IStuff
{
void SPB(string a, DateTime d, string c);
void P(decimal a, string r);
void EPB();
}
I have a class Stuff which implement the interface. Here is how VS implemented the interface for me.
using System;
namespace Namespace1
{
public class Stuff : IStuff
{
public void SPB(string a, DateTime d, string c)
{
}
public void IStuff.P(decimal a, string r)
{
}
void EPB()
{
}
}
}
What I don't understand is why the P() method in the interface is implemented in the class as:
public void IStuff.P(decimal a, string r)
{
}
Why not like this?
public void P(decimal a, string r)
{
}
Why is this so? How do I access the P() method in the class?
What is going on here?
|
|
|
|
|
Check the rest of your Stuff class - you already have some object called "P" so VS inserts an explicit implementation "IStuff.P" so that there is no confusion.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks Griff!
My original class was named "P" as well *lol* Therefore VS inserted the explicit implementation.
I renamed the class to something else and I got the correct interface implementation.
/Steffe
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Mc_Topaz wrote: public void IStuff.P(decimal a, string r)
void EPB()
When you changed the method names for your post, you also changed the access modifiers on your methods. The code you've posted won't compile.
You'd need to remove the public from P , and add it to EPB instead:
void IStuff.P(decimal a, string r) { ... }
public void EPB() { ... }
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Everything declared in an Interface, when you implement it in a class, must have the access modifier 'public. This "default" implementation syntax can be called implicit implementation.
The exception, which does confuse people, is the special case where you have a class that implements more than one Interface and identical names are used in each Interface, and you need to make it clear, for a duplicated name implementation, which Interface your implementation refers to.
So, when explicit implementation is used: no modifiers are allowed; and, the Interface name is followed by a dot, and the declaration.
The examples here should make this clear: [^].
If you are one of those curious persons who dares ask why you can't have access modifiers in Interfaces, and/or why you can't use other modifiers than 'public in your implementation of Interfaces; you may wish to read this thread: [^].
Suppose your class implements one Interface, and you make every implementation explicit:
public interface IStuff
{
void SPB(string a, DateTime d, string c);
void P(decimal a, string r);
void EPB();
string Name { set; get; }
}
public class Test : IStuff
{
void IStuff.SPB(string a, DateTime d, string c)
{
throw new NotImplementedException();
}
void IStuff.P(decimal a, string r)
{
throw new NotImplementedException();
}
void IStuff.EPB()
{
throw new NotImplementedException();
}
private string _name;
string IStuff.Name
{
get { return _name; }
set { _name = value; }
}
} When you create an instance of this class, none of its methods, and its one field, can be accessed from the instance: you'll have to cast the instance to the Interface:
var test = new Test();
(test as IStuff).name = "wtf ?";
«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
modified 18-Jan-17 2:48am.
|
|
|
|
|
Hi there everyone, new here and would like to get some feedback on my code.
I run a store procedure that I want to dump on a excel template.
It currently works, but just takes way too long. On sql management studio the query runs good, but just writing to the template is really slow.
Can anyone suggest a more efficient way to achieve the same result?
thanks in advance
here is part of my code:
sdate = StartDate.Value.ToString();
edate = EndDate.Value.ToString();
Excel.Application oXL;
Excel._Workbook oWB;
Excel._Worksheet aSheet;
try
{
//Start Excel and get Application object.
oXL = new Excel.Application();
oXL.Visible = true;
//open the excel template
oWB = oXL.Workbooks.Open("C:\\TEMP\\template.xlsm");
//oWB = (Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
//Call to service
//aSheet = (Excel._Worksheet)oWB.Worksheets.get_Item(1);
aSheet = (Excel._Worksheet)oWB.ActiveSheet;
//backgroundWorker1.ReportProgress(i++);
writedata_from_proc(aSheet, "dbo.CODE_RED_2017");
//backgroundWorker1.ReportProgress(i++);
//Make sure Excel is visible and give the user control
//of Microsoft Excel's lifetime.
//backgroundWorker1.ReportProgress(i++);
MessageBox.Show("Data extraction complete");
oXL.Visible = true;
oXL.UserControl = true;
//SaveExcel(oWB);
//clean up the COM objects to remove them from the memory
Marshal.FinalReleaseComObject(aSheet);
Marshal.FinalReleaseComObject(oWB);
Marshal.FinalReleaseComObject(oXL);
}
catch (Exception theException)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, theException.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, theException.Source);
MessageBox.Show(errorMessage, "Error");
}
}
|
|
|
|
|
It's slow because you're using Office Interop to create the Excel workbook. Office Interop is notoriously slow and there's no way you can speed this up.
To get it to go faster, you have to drop Excel and use the OpenXML SDK to create an Excel workbook file directly. It's much faster but the learning curve to use the SDK is kind of steep.
|
|
|
|
|
You can also export the data to a tab or comma separated text file - Excel is happy to use them
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|