public static bool CheckGroupName(long l_gid, string str_gname) { try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.Count > 0) { ICollection values = groupCache.Values; foreach (GroupInfo groupInfo in values) { if (groupInfo.group_name.Equals(str_gname)) { bool result; if (groupInfo.id == l_gid) { result = true; return(result); } result = false; return(result); } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); bool result = false; return(result); } return(true); }
public static List <GroupInfo> GetPartGroup(int i_selectflag) { List <GroupInfo> list = new List <GroupInfo>(); try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.Count > 0) { ICollection values = groupCache.Values; foreach (GroupInfo groupInfo in values) { if (i_selectflag == 2) { GroupInfo item = new GroupInfo(groupInfo); list.Add(item); } else { if (groupInfo.SelectedFlag == i_selectflag) { GroupInfo item2 = new GroupInfo(groupInfo); list.Add(item2); } } } } list.Sort((GroupInfo x, GroupInfo y) => x.group_name.CompareTo(y.group_name)); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } return(list); }
public SMTPSetting() { try { SMTPSetting sMTPSetting = DBCache.GetSMTPSetting(); if (sMTPSetting != null) { this.smtp_enable = sMTPSetting.Status; this.smtp_server = sMTPSetting.ServerIP; this.smtp_port = sMTPSetting.Port; this.smtp_from = sMTPSetting.Sender; this.smtp_to = sMTPSetting.Receiver; this.smtp_event = sMTPSetting.EVENT; this.smtp_auth = sMTPSetting.AuthenticationFlag; this.smtp_account = sMTPSetting.AccountName; this.smtp_pwd = sMTPSetting.AccountPwd; } else { this.smtp_enable = 0; this.smtp_server = ""; this.smtp_port = 25; this.smtp_from = ""; this.smtp_to = ""; this.smtp_event = ""; this.smtp_auth = 0; this.smtp_account = ""; this.smtp_pwd = ""; } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
public static ArrayList getAllZone() { List <ZoneInfo> list = new List <ZoneInfo>(); try { Hashtable zoneCache = DBCache.GetZoneCache(); if (zoneCache != null && zoneCache.Count > 0) { ICollection values = zoneCache.Values; foreach (ZoneInfo item in values) { list.Add(item); } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get all zone error : " + ex.Message + "\n" + ex.StackTrace); } list.Sort((ZoneInfo x, ZoneInfo y) => x.z_name.CompareTo(y.z_name)); ArrayList arrayList = new ArrayList(); foreach (ZoneInfo current in list) { arrayList.Add(current); } return(arrayList); }
public static bool IsLocalIP(string str_ip) { try { NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); NetworkInterface[] array = allNetworkInterfaces; for (int i = 0; i < array.Length; i++) { NetworkInterface networkInterface = array[i]; IPInterfaceProperties iPProperties = networkInterface.GetIPProperties(); UnicastIPAddressInformationCollection unicastAddresses = iPProperties.UnicastAddresses; foreach (UnicastIPAddressInformation current in unicastAddresses) { if (str_ip.Equals(current.Address.ToString())) { return(true); } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile(ex.Message); } return(false); }
public void Info(string message) { if (this.open) { try { bool flag = false; try { Monitor.Enter(this, ref flag); string str = DateTime.Now.ToString("HH:mm:ss"); File.AppendAllText(this.path + DateTime.Now.ToString("yyyy-MM-dd") + ".log", str + " '" + message + "'\r\n", Encoding.Default); } finally { if (flag) { Monitor.Exit(this); } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } } }
public static bool CheckColor(long l_id, int i_color) { try { Hashtable zoneCache = DBCache.GetZoneCache(); if (zoneCache != null && zoneCache.Count > 0) { ICollection values = zoneCache.Values; foreach (ZoneInfo zoneInfo in values) { long zoneID = zoneInfo.ZoneID; string zoneColor = zoneInfo.ZoneColor; if (zoneColor.Equals(string.Concat(i_color))) { bool result; if (zoneID == l_id) { result = true; return(result); } result = false; return(result); } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } return(true); }
private static IntPtr RegisterForDeviceNotifications(IntPtr parent) { IntPtr intPtr = IntPtr.Zero; BroadcastDeviceInterface broadcastDeviceInterface = default(BroadcastDeviceInterface); broadcastDeviceInterface.dbcc_size = Marshal.SizeOf(broadcastDeviceInterface); broadcastDeviceInterface.BroadcastDeviceType = BroadcastDeviceType.DBT_DEVTYP_DEVICEINTERFACE; broadcastDeviceInterface.dbcc_classguid = RawInput.AllUsbDeviceInterfaceHid; IntPtr intPtr2 = IntPtr.Zero; try { intPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BroadcastDeviceInterface))); Marshal.StructureToPtr(broadcastDeviceInterface, intPtr2, false); intPtr = Win32.RegisterDeviceNotification(parent, intPtr2, DeviceNotification.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile(ex.Message + "\r\n" + ex.StackTrace); } finally { Marshal.FreeHGlobal(intPtr2); } if (intPtr == IntPtr.Zero) { DebugCenter.GetInstance().appendToFile("Registration for device notifications Failed. Error: " + Marshal.GetLastWin32Error().ToString()); } return(intPtr); }
private static long GetMySqlPacketLength(string connectString) { long result = 0L; try { MySqlConnection mySqlConnection = new MySqlConnection(connectString); mySqlConnection.Open(); MySqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlCommand.CommandText = "SHOW VARIABLES LIKE 'max_allowed_packet'"; DbDataReader dbDataReader = mySqlCommand.ExecuteReader(); if (dbDataReader.Read()) { result = (long)Convert.ToInt32(dbDataReader.GetValue(1)); } dbDataReader.Close(); mySqlCommand.Dispose(); mySqlConnection.Close(); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("getMySQLPath: " + ex.Message); result = 0L; } return(result); }
public void showRpt(int selpage, int needinit) { if (selpage == 1) { if (needinit == 1) { this.thermGenRptPara1.pageInit(this); } this.thermGenRptPara1.Visible = true; this.thermRptShow1.Visible = false; this.thermGenRptPara1.resettime(); this.m_inAnalysisFlg = 1; return; } if (selpage == 2) { Program.IdleTimer_Pause(4); this.thermGenRptPara1.Visible = false; this.thermRptShow1.Visible = true; this.thermRptShow1.pageInit(this, this.thermGenRptPara1); DebugCenter.GetInstance().appendToFile("ThermalAnalysis Finish."); this.m_inAnalysisFlg = 4; return; } if (selpage == 4) { this.thermGenRptPara1.Visible = false; this.thermRptShow1.Visible = true; Program.IdleTimer_Run(4); this.m_inAnalysisFlg = 4; } }
public PresentValue GetPresentValue(System.Collections.Generic.List <ValueMessage> values, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, OutletMapping> > outletIdMapper, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, BankMapping> > bankIdMapper, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, SensorMapping> > sensorIdMapper, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, LineMapping> > lineIdMapper) { if (values == null || values.Count < 1) { return(new PresentValue()); } if (this.presentValue == null) { this.presentValue = new PresentValue(); } foreach (ValueMessage current in values) { try { this.setDeviceTable(current.CreateTime, current.DeviceValue, current.DeviceID); this.setSensorTable(current.CreateTime, current.SensorValue, current.DeviceID, current.SensorNums, current.DeviceMac, sensorIdMapper); this.setOutletTable(current.CreateTime, current.OutletValue, current.DeviceID, current.PortNums, current.DeviceMac, outletIdMapper); this.setBankTable(current.CreateTime, current.BankValue, current.DeviceID, current.BankNums, current.DeviceMac, bankIdMapper); this.setLineTable(current.CreateTime, current.LineValue, current.DeviceID, current.LineNums, current.DeviceMac, lineIdMapper); } catch (System.Exception ex) { DebugCenter.GetInstance().appendToFile("Skip device: " + current.DeviceMac + ", " + ex.Message); } } return(this.presentValue); }
public static void InsertBankPower(int i_bankid, double f_power, DateTime dt_inserttime, DBConn conn) { try { long num = Convert.ToInt64(f_power * 10000.0); if (DBUrl.SERVERMODE) { string item = string.Concat(new object[] { "insert into bank_auto_info", dt_inserttime.ToString("yyyyMMdd"), " (bank_id,power,insert_time ) values(", i_bankid, ",", num, ",#", dt_inserttime.ToString("yyyy-MM-dd HH:mm:ss"), "#)" }); WorkQueue <string> .getInstance().WorkSequential = true; WorkQueue <string> .getInstance().EnqueueItem(item); } else { if (DBUrl.DB_CURRENT_TYPE.Equals("MYSQL")) { string item2 = string.Concat(new object[] { "insert into bank_auto_info", dt_inserttime.ToString("yyyyMMdd"), " (bank_id,power,insert_time ) values(", i_bankid, ",", num, ",#", dt_inserttime.ToString("yyyy-MM-dd HH:mm:ss"), "#)" }); WorkQueue <string> .getInstance().WorkSequential = true; WorkQueue <string> .getInstance().EnqueueItem(item2); } else { List <string> list = new List <string>(); list.Add(string.Concat(i_bankid)); list.Add(dt_inserttime.ToString("yyyy-MM-dd HH:mm:ss")); list.Add("bank_auto_info"); list.Add(string.Concat(num)); PDDataProcess.GetInstance().PutItem(list); } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
public int Update() { if (this.id < 1) { return(-1); } if (this.device_id < 1) { return(-1); } DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; string commandText = "update line_info set max_voltage=?,min_voltage=?,max_power=?,min_power=?,max_current=?,min_current=? where id=" + this.id; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@max_voltage", this.max_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_voltage", this.min_voltage, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_power", this.max_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_power", this.min_power, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@max_current", this.max_current, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@min_current", this.min_current, dbCommand)); int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); DBCacheStatus.Device = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Device" }); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(-1); }
public static long DeleteLogByRecords(int records) { long result = 0L; string commandText = "select min(log.id) from (select top " + records + " id from logrecords order by id desc ) as log"; string arg = "delete from logrecords where id < "; DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getLogConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; if (DBUrl.SERVERMODE) { commandText = "select min(logg.id) from (select id from logrecords order by id desc LIMIT " + records + " OFFSET 0 ) as logg"; } dbCommand.CommandText = commandText; object obj = dbCommand.ExecuteScalar(); if (obj != null && obj != DBNull.Value) { int num = 0; try { num = Convert.ToInt32(obj); } catch { } dbCommand.CommandText = arg + num; result = (long)dbCommand.ExecuteNonQuery(); } dbCommand.Dispose(); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(result); }
public int UpdateLineThreshold(DBConn conn) { if (this.id < 1) { return(-1); } if (this.device_id < 1) { return(-1); } DbCommand dbCommand = null; try { if (conn.con != null) { dbCommand = DBConn.GetCommandObject(conn.con); dbCommand.Connection = conn.con; dbCommand.CommandType = CommandType.Text; string text = "update line_info set "; text = text + "max_voltage=" + CultureTransfer.ToString(this.max_voltage); text = text + ",min_voltage=" + CultureTransfer.ToString(this.min_voltage); text = text + ",max_power=" + CultureTransfer.ToString(this.max_power); text = text + ",min_power=" + CultureTransfer.ToString(this.min_power); text = text + ",max_current=" + CultureTransfer.ToString(this.max_current); text = text + ",min_current=" + CultureTransfer.ToString(this.min_current); text = text + " where id= " + this.id; dbCommand.CommandText = text; int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); dbCommand.Dispose(); return(result); } } catch (Exception ex) { try { dbCommand.Dispose(); } catch { } DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } } return(-1); }
public static bool SetEventInfo(DataTable eventlist) { bool result = false; DBConn dBConn = null; DbCommand dbCommand = new OleDbCommand(); try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); foreach (DataRow dataRow in eventlist.Rows) { dbCommand.CommandType = CommandType.Text; dbCommand.CommandText = string.Concat(new object[] { "update event_info set logflag = ", Convert.ToInt16(dataRow["logflag"]), ", mailflag = ", Convert.ToInt16(dataRow["mailflag"]), " where eventid = '", Convert.ToString(dataRow["eventid"]), "' " }); dbCommand.ExecuteNonQuery(); } dbCommand.Dispose(); DBCacheStatus.Event = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Event" }); return(true); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(result); }
public string[] directoryListDetailed(string directory) { try { this.ftpRequest = (FtpWebRequest)WebRequest.Create(string.Concat(new object[] { "ftp://", this.host, ":", this.port, "/", directory })); this.ftpRequest.Credentials = new NetworkCredential(this.user, this.pass); this.ftpRequest.UseBinary = true; this.ftpRequest.UsePassive = true; this.ftpRequest.KeepAlive = true; this.ftpRequest.Method = "LIST"; this.ftpResponse = (FtpWebResponse)this.ftpRequest.GetResponse(); this.ftpStream = this.ftpResponse.GetResponseStream(); StreamReader streamReader = new StreamReader(this.ftpStream); string text = null; try { while (streamReader.Peek() != -1) { text = text + streamReader.ReadLine() + "|"; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } streamReader.Close(); this.ftpStream.Close(); this.ftpResponse.Close(); this.ftpRequest = null; try { return(text.Split("|".ToCharArray())); } catch (Exception ex2) { Console.WriteLine(ex2.ToString()); } } catch (Exception ex3) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex3.Message + "\n" + ex3.StackTrace); Console.WriteLine(ex3.ToString()); } return(new string[] { "" }); }
public int CloseDBConnection() { if (this.DBTYPE == 1) { return(1); } if (this.con != null) { int i = 0; while (i < 600) { if (this.con.State == ConnectionState.Closed) { goto IL_38; } if (this.con.State == ConnectionState.Open) { goto Block_4; } IL_8B: DebugCenter.GetInstance().appendToFile("Close DBConnection exception : " + this.con.State); i++; Thread.Sleep(50); continue; Block_4: try { try { IL_38: this.con.Close(); } catch { } try { this.con.Dispose(); } catch { } this.con = null; return(1); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("Close DBConnection exception : " + ex.Message + "\n" + ex.StackTrace); break; } goto IL_8B; } return(-1); } return(1); }
public void showRpt(int selpage, int needinit) { switch (selpage) { case 1: if (needinit == 1) { this.genRptPara1.pageInit_1(this); } else { this.genRptPara1.pageInit_2(0); } this.genRptPara1.Visible = true; this.EgenRptShow1.Visible = false; this.genRptPara1.resettime(); this.m_inAnalysisFlg = 1; return; case 2: Program.IdleTimer_Pause(2); this.genRptPara1.pageInit_2(1); this.genRptPara1.Visible = true; this.EgenRptShow1.Visible = false; if (this.m_inAnalysisFlg == 2) { return; } this.m_pParaClass = new EGenRptParaClass(); this.m_pParaClass.pageInit(this.genRptPara1); this.m_inAnalysisFlg = 2; this.m_oldAnalysisFlg = 2; System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(this.prepare_dataProc), this.m_pParaClass); this.dTimer.Enabled = true; return; case 3: this.genRptPara1.Visible = false; this.EgenRptShow1.Visible = true; this.EgenRptShow1.pageInit(this, this.m_pParaClass, this.m_retDataSet); DebugCenter.GetInstance().appendToFile("PowerAnalysis Finish."); Program.IdleTimer_Run(2); this.m_inAnalysisFlg = 4; return; case 4: this.genRptPara1.Visible = false; this.EgenRptShow1.Visible = true; this.m_inAnalysisFlg = 4; return; default: return; } }
public int UpdatePortThreshold(DBConn conn) { if (this.id < 1) { return(-1); } if (this.device_id < 1) { return(-1); } DbCommand dbCommand = new OleDbCommand(); try { if (conn.con != null) { dbCommand = DBConn.GetCommandObject(conn.con); dbCommand.CommandType = CommandType.Text; string text = "update port_info set port_nm=?,port_confirmation=?,port_ondelay_time=?,port_offdelay_time=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=?,shutdown_method=?,mac=? where id=" + this.id; text = "update port_info set "; text = text + "port_nm='" + this.port_nm + "'"; text = text + ",port_confirmation=" + CultureTransfer.ToString(this.port_confirmation); text = text + ",port_ondelay_time=" + CultureTransfer.ToString(this.port_ondelay_time); text = text + ",port_offdelay_time=" + CultureTransfer.ToString(this.port_offdelay_time); text = text + ",max_voltage=" + CultureTransfer.ToString(this.max_voltage); text = text + ",min_voltage=" + CultureTransfer.ToString(this.min_voltage); text = text + ",max_power_diss=" + CultureTransfer.ToString(this.max_power_diss); text = text + ",min_power_diss=" + CultureTransfer.ToString(this.min_power_diss); text = text + ",max_power=" + CultureTransfer.ToString(this.max_power); text = text + ",min_power=" + CultureTransfer.ToString(this.min_power); text = text + ",max_current=" + CultureTransfer.ToString(this.max_current); text = text + ",min_current=" + CultureTransfer.ToString(this.min_current); text = text + ",shutdown_method=" + CultureTransfer.ToString(this.shutdown_method); text = text + ",mac='" + this.port_mac + "'"; text = text + " where id= " + this.id; dbCommand.CommandText = text; int result = dbCommand.ExecuteNonQuery(); dbCommand.Parameters.Clear(); dbCommand.Dispose(); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); try { dbCommand.Dispose(); } catch { } } return(-1); }
public static int InsertRackEffect(string str_sql, DateTime dt_inserttime) { if (DBUrl.SERVERMODE) { WorkQueue <string> .getInstance_rackeffect().WorkSequential = true; WorkQueue <string> .getInstance_rackeffect().EnqueueItem(str_sql); return(1); } if (DBUrl.DB_CURRENT_TYPE.ToUpper().Equals("MYSQL")) { WorkQueue <string> .getInstance_rackeffect().WorkSequential = true; WorkQueue <string> .getInstance_rackeffect().EnqueueItem(str_sql); return(1); } DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getThermalConnection(); if (dBConn != null && dBConn.con != null) { dbCommand = dBConn.con.CreateCommand(); } dbCommand.CommandText = str_sql.Replace("'", "#"); dbCommand.ExecuteNonQuery(); dbCommand.Dispose(); dBConn.Close(); return(1); } catch (Exception ex) { try { dbCommand.Dispose(); } catch { } try { dBConn.Close(); } catch { } DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Generate RackEffect Error : " + ex.Message + "\n" + ex.StackTrace); } return(-1); }
private void baseListen() { bool flag = true; while (this.isListening) { byte[] array = new byte[63488]; System.Net.EndPoint endPoint = null; try { endPoint = new System.Net.IPEndPoint(this.ipAddress, this.port); this.serverSocket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp); this.serverSocket.Bind(endPoint); if (flag) { DebugCenter.GetInstance().clearStatusCode(DebugCenter.ST_TrapPortNA, true); flag = false; } this.serverSocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, System.Net.Sockets.SocketOptionName.ReceiveTimeout, 0); int num = this.serverSocket.ReceiveFrom(array, System.Net.Sockets.SocketFlags.None, ref endPoint); if (num > 0 && this.isListening) { string[] separator = new string[] { ":" }; string[] array2 = endPoint.ToString().Split(separator, System.StringSplitOptions.None); SocketMessager socketMessager = new SocketMessager(); socketMessager.Target = array2[0]; socketMessager.Port = System.Convert.ToInt32(array2[1]); socketMessager.DataLenth = num; socketMessager.DataBytes = array; System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(this.waitCallback), socketMessager); } } catch (System.Exception) { try { System.Threading.Thread.Sleep(100); } catch (System.Exception) { } } finally { if (this.serverSocket != null) { this.serverSocket.Close(); } } } }
public EnqueueEventArgs(object item) { try { this.Item = (T)((object)item); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); throw new InvalidCastException("object to T failed"); } }
public static int InsertBillReport(string str_title, string str_writer, DateTime dt_time, string str_path) { int result = -1; DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); if (DBUrl.SERVERMODE) { string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?Title,?Writer,?ReportTime,?ReportPath)"; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("?Title", str_title, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?Writer", str_writer, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("?ReportPath", str_path, dbCommand)); } else { string commandText = "insert into reportbill(Title,Writer,ReportTime,ReportPath) values(?,?,?,?)"; dbCommand.CommandText = commandText; dbCommand.Parameters.Add(DBTools.GetParameter("@Title", str_title, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@Writer", str_writer, dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ReportTime", dt_time.ToString("yyyy-MM-dd HH:mm:ss"), dbCommand)); dbCommand.Parameters.Add(DBTools.GetParameter("@ReportPath", str_path, dbCommand)); } result = dbCommand.ExecuteNonQuery(); return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { if (dbCommand != null) { dbCommand.Dispose(); } if (dBConn.con != null) { dBConn.Close(); } } return(result); }
public void QueueWork(object sender, WorkQueue <Dictionary <string, Dictionary <string, Dictionary <string, string> > > > .EnqueueEventArgs e) { if (this.con == null || this.con.State != ConnectionState.Open) { if (this.con != null) { try { this.con.Close(); } catch (Exception) { } } try { if (DBUrl.SERVERMODE) { this.con = this.getConnection(); } else { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBUrl.DEFAULT_HOST_PATH + ";Jet OLEDB:Database Password="******"DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } } try { Dictionary <string, Dictionary <string, Dictionary <string, string> > > item = e.Item; foreach (KeyValuePair <string, Dictionary <string, Dictionary <string, string> > > current in item) { string key = current.Key; Dictionary <string, Dictionary <string, string> > value = current.Value; InSnergyGateway.RefreshGateWay(key, value, this.con); if (GateWayRefreshQueue.CBWork != null) { GateWayRefreshQueue.CBWork(key); } } } catch (Exception ex2) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex2.Message + "\n" + ex2.StackTrace); } }
public bool Start() { DebugCenter.GetInstance().appendToFile("Start DBCache Event Processor " + this._threadName + " thread"); Interlocked.Exchange(ref this._stopping, 0); this._stoppedEvent.Reset(); this._abortEvent.Reset(); DBCacheStatus._dbSyncEvent.Reset(); this._waitHandles[0] = this._abortEvent; this._waitHandles[1] = DBCacheStatus._dbSyncEvent; this._procThread = new Thread(new ParameterizedThreadStart(this.WorkThread)); this._procThread.Name = this._threadName; this._procThread.Start(); return(true); }
public PortInfo(int l_did, int i_portnum) { try { Hashtable devicePortMap = DBCache.GetDevicePortMap(); Hashtable portCache = DBCache.GetPortCache(); if (devicePortMap != null && devicePortMap.Count > 0 && portCache != null && portCache.Count > 0 && devicePortMap.ContainsKey(l_did)) { List <int> list = (List <int>)devicePortMap[l_did]; if (list != null) { foreach (int current in list) { PortInfo portInfo = (PortInfo)portCache[current]; if (portInfo != null && portInfo.PortNum == i_portnum) { this.id = portInfo.ID; this.device_id = portInfo.DeviceID; this.port_num = portInfo.PortNum; this.port_nm = portInfo.PortName; this.max_voltage = portInfo.Max_voltage; this.min_voltage = portInfo.Min_voltage; this.max_power_diss = portInfo.Max_power_diss; this.min_power_diss = portInfo.Min_power_diss; this.max_power = portInfo.Max_power; this.min_power = portInfo.Min_power; this.max_current = portInfo.Max_current; this.min_current = portInfo.Min_current; this.port_confirmation = portInfo.OutletConfirmation; this.port_ondelay_time = portInfo.OutletOnDelayTime; this.port_offdelay_time = portInfo.OutletOffDelayTime; this.shutdown_method = portInfo.OutletShutdownMethod; try { this.port_mac = portInfo.OutletMAC; } catch { this.port_mac = ""; } } } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
public RawInput(IntPtr parentHandle) { try { base.AssignHandle(parentHandle); RawInput._rawinputDriver = new RawInputDriver(parentHandle); RawInput._rawinputDriver.EnumerateDevices(); this._devNotifyHandle = RawInput.RegisterForDeviceNotifications(parentHandle); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile(ex.Message + "\r\n" + ex.StackTrace); } }
private void createDirection() { try { if (!Directory.Exists(this.path)) { Directory.CreateDirectory(this.path); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
public static int UpdateGroupStatus(int i_selectflag, string str_groups) { int result = -1; DBConn dBConn = null; DbCommand dbCommand = null; try { dBConn = DBConnPool.getConnection(); if (dBConn.con != null) { dbCommand = DBConn.GetCommandObject(dBConn.con); dbCommand.CommandType = CommandType.Text; string commandText = string.Concat(new object[] { "update data_group set isselect = ", i_selectflag, " where id in (", str_groups, " )" }); dbCommand.CommandText = commandText; result = dbCommand.ExecuteNonQuery(); DBCacheStatus.Group = true; DBCacheStatus.DBSyncEventSet(true, new string[] { "DBSyncEventName_Service_Group" }); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } finally { try { dbCommand.Dispose(); } catch { } if (dBConn != null) { dBConn.close(); } } return(result); }