|
I don't use multiple threads. Invoke is needed for safe receiving data from COM port.
Actually there is no
IfNewDay variable. Switching of a DAY depends on timer. Its tick time (TT) is evaluated every time when new DAY starts. If there is no any MEASURE (coming temperature values from device) at 24h (stating of a new day) than TT = 24hours, else TT = 24h-(Time for MEASURE). When you start the programm TT=24h-(Current time).
All overlapping of MEASUREs as it seems to me take place within a DAY. Different SETs sometimes has MEASUREs of their own and equal (bug) MEASUREs.
|
|
|
|
|
Hi again,
I don't see where it is wrong, I might need to see more code.
However, there is one thing that I don't like at all:
Member 8075591 wrote: Active.CurrentS.CurrentM.Add(p);
each day has a current set, each set has a current measurement. However, as I understand it your system only needs one current measurement overall, so having a lot of them is just asking for trouble.
|
|
|
|
|
You are one handred percent right! And I'll think how to change my code to follow you advice!
But I wonder how such things can happen!? If you are interested also I can comment all places you will ask and send you all my code.
|
|
|
|
|
dear guys, i need help about this C# class code.
i think this class is used to force the program to read sqlconnection string from a file with xml extension.
i needed someone to translate this coding into vb.net so it's easier for me to understand it.
thanks before.
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
namespace Core.Classes
{
public class Configuration
{
public class ProgramClass
{
public string Id { get; set; }
public string Name { get; set; }
public string DefaultCurrency { get; set; }
}
public class ConnectionClass
{
public string Provider { get; set; }
public string String { get; set; }
}
public ConnectionClass Connection { get; set; }
public ProgramClass Program { get; set; }
protected XPathNavigator nav = null;
public Configuration()
{
this.Connection = new ConnectionClass();
this.Program = new ProgramClass();
}
public bool Open(ProviderCollection providers, string filename)
{
if (!File.Exists(filename))
{
return false;
}
try
{
XmlDocument doc = new XmlDocument();
doc.Load(filename);
this.nav = doc.CreateNavigator();
return true;
}
catch
{
return false;
}
}
public virtual bool Read()
{
try
{
this.nav = nav.SelectSingleNode("//connection");
this.Connection.Provider = this.nav.GetAttribute("provider", "");
this.Connection.String = this.nav.GetAttribute("connection_string", "");
this.nav = nav.SelectSingleNode("//program");
this.Program.Id = this.nav.GetAttribute("id", "");
this.Program.Name = this.nav.GetAttribute("name", "");
this.Program.DefaultCurrency = this.nav.GetAttribute("default_currency", "");
return true;
}
catch
{
return false;
}
}
}
}
modified 18-Nov-11 23:53pm.
|
|
|
|
|
Here
Public Class Configuration
Public Class ProgramClass
Public Property Id() As String
Get
Return m_Id
End Get
Set
m_Id = Value
End Set
End Property
Private m_Id As String
Public Property Name() As String
Get
Return m_Name
End Get
Set
m_Name = Value
End Set
End Property
Private m_Name As String
Public Property DefaultCurrency() As String
Get
Return m_DefaultCurrency
End Get
Set
m_DefaultCurrency = Value
End Set
End Property
Private m_DefaultCurrency As String
End Class
Public Class ConnectionClass
Public Property Provider() As String
Get
Return m_Provider
End Get
Set
m_Provider = Value
End Set
End Property
Private m_Provider As String
Public Property [String]() As String
Get
Return m_String
End Get
Set
m_String = Value
End Set
End Property
Private m_String As String
End Class
Public Property Connection() As ConnectionClass
Get
Return m_Connection
End Get
Set
m_Connection = Value
End Set
End Property
Private m_Connection As ConnectionClass
Public Property Program() As ProgramClass
Get
Return m_Program
End Get
Set
m_Program = Value
End Set
End Property
Private m_Program As ProgramClass
Protected nav As XPathNavigator = Nothing
Public Sub New()
Me.Connection = New ConnectionClass()
Me.Program = New ProgramClass()
End Sub
Public Function Open(providers As ProviderCollection, filename As String) As Boolean
If Not File.Exists(filename) Then
Return False
End If
Try
Dim doc As New XmlDocument()
doc.Load(filename)
Me.nav = doc.CreateNavigator()
Return True
Catch
Return False
End Try
End Function
Public Overridable Function Read() As Boolean
Try
Me.nav = nav.SelectSingleNode("//connection")
Me.Connection.Provider = Me.nav.GetAttribute("provider", "")
Me.Connection.[String] = Me.nav.GetAttribute("connection_string", "")
Me.nav = nav.SelectSingleNode("//program")
Me.Program.Id = Me.nav.GetAttribute("id", "")
Me.Program.Name = Me.nav.GetAttribute("name", "")
Me.Program.DefaultCurrency = Me.nav.GetAttribute("default_currency", "")
Return True
Catch
Return False
End Try
End Function
End Class
I just used developerfusion's converter application[^].
Next time you can go straight there.
Good luck.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
thank's a lot, but am i right about the function of this class?
|
|
|
|
|
It looks like it.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
okay thankyou then
|
|
|
|
|
Glad to help!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
The first thing to try in future is to use one of the online translation services - I use DeveloperFusion[^]
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
If you read my original answer, you will note I told him the same thing. In fact that is all I did
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Sorry! I saw a large wodge of VB and didn't read to the end...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
No need to be sorry! There is no harm in reinforcing issues like that. They should learn to start helping themselves
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I have the following method in a class library that creates a dropdown menu populated using linq to sql.
public DropDownList GetCategoryList()
{
ArticleDataDataContext dc = new ArticleDataDataContext();
DataBuddy db = new DataBuddy(dc.getAllCategories());
List<string> result = db.EnumerateISingleResultAsString();
DropDownList d = new DropDownList();
d.ID = "ddCatList";
d.ViewStateMode = ViewStateMode.Enabled;
foreach (string item in result)
{
d.Items.Add(new ListItem(item, item, true));
}
return d;
}
This works fine but I cannot figure out how to access the control on postback.
I have tried the following in a button click event handler but it doesn't work.
DropDownList dd = (DropDownList)this.FindControl("ddCatList");
|
|
|
|
|
You must take care of recreating the control on each post back.
Here's a good article/example:
Linky
All the best,
Dan
|
|
|
|
|
Thanks Dan, I've been pulling my hair out trying to figure that out. Worked perfectly.
|
|
|
|
|
You're welcome.
All the best,
Dan
|
|
|
|
|
Good evening to all
Currently i'm developing a Windows Service in order to automatically send me e-mails with my remote computer operating status.
I already checked MSDN documentation about this subject http://msdn.microsoft.com/en-us/library/ycy63t34.aspx and changed the code to use on my situation. But... i don't receive e-mails from it when the remote computer is normally turned off.
Someone could help me with this issue?
Best Regards.
|
|
|
|
|
Can you attach a debugger or at least write some log entries so you can debug what's occurring?
Mark Salsbery
|
|
|
|
|
Dear Mark,
I'm using Visual C# Express 2005 and i can't find the process debugger on my debug tab. But i can present you the code i'm using:
using System;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Win32;
using System.ComponentModel;
using System.Configuration.Install;
using System.Net.Mail;
namespace SimpleServiceCs
{
public class SimpleService : ServiceBase
{
static void Main(string[] args)
{
ServiceBase.Run(new SimpleService());
}
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("SimpleService", "Starting SimpleService");
new Thread(RunMessagePump).Start();
}
void RunMessagePump()
{
EventLog.WriteEntry("SimpleService.MessagePump", "Starting SimpleService Message Pump");
Application.Run(new HiddenForm());
}
protected override void OnStop()
{
Application.Exit();
}
}
public partial class HiddenForm : Form
{
public HiddenForm()
{
InitializeComponent();
}
private void HiddenForm_Load(object sender, EventArgs e)
{
SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
}
private void HiddenForm_FormClosing(object sender, FormClosingEventArgs e)
{
SystemEvents.SessionEnding -= new SessionEndingEventHandler(SystemEvents_SessionEnding);
}
private void SystemEvents_SessionEnding(object sender, EventArgs e)
{
EventLog.WriteEntry("System Logoff or System Shutdown");
SendEMail("Your System is being Logged Off or Shutdown!");
}
private void SendEmail(string Warning){
}
}
partial class HiddenForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.SuspendLayout();
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(0, 0);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "HiddenForm";
this.Text = "HiddenForm";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Load += new System.EventHandler(this.HiddenForm_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HiddenForm_FormClosing);
this.ResumeLayout(false);
}
}
[RunInstaller(true)]
public class SimpleInstaller : Installer
{
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
public SimpleInstaller()
{
processInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();
processInstaller.Account = ServiceAccount.LocalSystem;
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceInstaller.ServiceName = "Simple Service";
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
}
}
I'll be waiting for your feedback.
Best Regards.
|
|
|
|
|
You should still be able to debug it, but that's a topic for Visual Studio.
Do you get the log entry "System Logoff or System Shutdown"? If so, write some log entries in your email code to see if some function is failing.
Mark Salsbery
|
|
|
|
|
Dear Mark,
Testing my service with attached debugger and with a breakpoint at my SystemEvent Handler (private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)), when i try to logoff or shutdown my pc, that breakpoint is never reached, because the debugger is first disabled.
Best Regards.
|
|
|
|
|
It could be that the machine does not have an SMTP account configure on it. Before your try to get your service to send an e-mail, try sending an e-mail from the it yourself. After you do that, yo must make sure that your windows service is able to use that SMTP e-mail account.
|
|
|
|
|
Dear Silim
Thank you for your fast response. That was the first test i've done. The smtp mail account is working fine. Only at SystemEvents Handler (private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)) isn't working.
Best regards.
|
|
|
|
|