public static void SaveOperationLog(string OperationContent, string OperationKey, string OperationTitle, string OperationTableKey, string OperationTableName, string OperationMan = "", DateTime?LogoutTime = null, bool IsHide = false) { DateTime _LogoutTime = DateTime.MinValue; if (LogoutTime.HasValue) { _LogoutTime = Convert.ToDateTime(LogoutTime); } var context = HttpContext.Current; if (string.IsNullOrEmpty(OperationMan)) { OperationMan = WebUtil.GetUser(context).LoginName; } string IPAddress = GetHostAddress(); var log = new OperationLog(); log.OperationTime = DateTime.Now; log.OperationMan = OperationMan; log.OperationContent = OperationContent; log.OperationKey = OperationKey; log.LogoutTime = _LogoutTime; log.IPAddress = IPAddress; log.OperationTitle = OperationTitle; log.OperationTableKey = OperationTableKey; log.OperationTableName = OperationTableName; log.IsHide = IsHide; log.Save(); }
private void timer2_Elapsed_1(object sender, System.Timers.ElapsedEventArgs e) { try { LineBoxStatus hanglineboxstatus; LineBoxStatus lineboxstatus; if (OperateOpcAndSoft.plc != null) { //hanglineboxstatus = opert.SubLineStatus(); //if (hanglineboxstatus != null && hanglineboxstatus.status == 1) //{ // if (hanglineboxstatus.lineboxcode.ToString() != labblockbox.Text) // { // try // { // SortingFault.SaveFaultBoxStatus(hanglineboxstatus.lineboxcode,hanglineboxstatus.status); // OperationLog operationLog = OperationLog.NewOperationLog(); // operationLog.OPERATIONCODE = "挂烟"; // operationLog.OPERATIONNAME = hanglineboxstatus.lineboxcode.ToString(); // operationLog.Save(); // } // catch // { } // labblockbox.Text = hanglineboxstatus.lineboxcode.ToString(); // labblockbox.ForeColor = Color.Red; // labboxstatus.ForeColor = Color.Red; // labblockname.ForeColor = Color.Red; // if (SortingLineTaskDetail.GetSortingLineBoxCigNumber(hanglineboxstatus.lineboxcode) == 1) // { // labblockname.Text = SortingLineTaskDetail.GetSortingLineBoxCigName(hanglineboxstatus.lineboxcode); // } // else // { // labblockname.Text = "混仓品牌"; // } // if (hanglineboxstatus.status == 1) // { // labboxstatus.Text = "挂烟"; // } // Thread thread = new Thread(new ParameterizedThreadStart(PlayHangSound)); // thread.Start(hanglineboxstatus); // } //} lineboxstatus = opert.GetLineBoxException(); if (lineboxstatus != null) { if (lineboxstatus.lineboxcode.ToString() != labblockbox.Text) { try { SortingFault.SaveFaultBoxStatus(lineboxstatus.lineboxcode, lineboxstatus.status, lineboxstatus.putnum); OperationLog operationLog = OperationLog.NewOperationLog(); if (lineboxstatus.status == 8) { operationLog.OPERATIONCODE = "卡烟"; //发送当前已打出的条烟到数码管 //SendTaskPutNiLight(lineboxstatus.lineboxcode); //Thread thread = new Thread(new ParameterizedThreadStart(SendTaskPutNiLight)); //thread.Start(lineboxstatus.lineboxcode); } if (lineboxstatus.status == 4) { operationLog.OPERATIONCODE = "缺烟"; } if (lineboxstatus.status == 16) { operationLog.OPERATIONCODE = "挂烟"; } operationLog.OPERATIONNAME = lineboxstatus.lineboxcode.ToString(); operationLog.Save(); } catch { } labblockbox.Text = lineboxstatus.lineboxcode.ToString(); labblockbox.ForeColor = Color.Red; labboxstatus.ForeColor = Color.Red; labblockname.ForeColor = Color.Red; if (SortingLineTaskDetail.GetSortingLineBoxCigNumber(lineboxstatus.lineboxcode) == 1) { labblockname.Text = SortingLineTaskDetail.GetSortingLineBoxCigName(lineboxstatus.lineboxcode); } else { labblockname.Text = "混仓品牌"; } if (lineboxstatus.status == 4) { labboxstatus.Text = "缺烟"; } if (lineboxstatus.status == 8) { labboxstatus.Text = "卡烟"; } if (lineboxstatus.status == 16) { labboxstatus.Text = "挂烟"; } Thread thread1 = new Thread(new ParameterizedThreadStart(PlayBlockSound)); thread1.Start(lineboxstatus); //发送当前已打出的条烟到数码管 SendTaskPutNiLight(lineboxstatus.lineboxcode); } } //if (hanglineboxstatus == null && lineboxstatus == null) if (lineboxstatus == null && labboxstatus.Text != "正常") { SortingFault.SaveFaultBoxStatus(0, 0, 0); labboxstatus.Text = "正常"; labboxstatus.ForeColor = Color.Green; labblockbox.Text = "无"; labblockbox.ForeColor = Color.Green; labblockname.Text = "无"; labblockname.ForeColor = Color.Green; Nixielight ni = new Nixielight(); ni.SendNull(); } } else { try { OpcPlc opcPlc = new OpcPlc(); OperateOpcAndSoft.plc = opcPlc; } catch { } } } catch (Exception ex) { try { OperationLog operationLog = OperationLog.NewOperationLog(); operationLog.OPERATIONCODE = "出现异常"; operationLog.OPERATIONNAME = ex.Message; operationLog.Save(); } catch (Exception) { } } }
private void timer2_Elapsed_1(object sender, System.Timers.ElapsedEventArgs e) { try { LineBoxStatus hanglineboxstatus; LineBoxStatus lineboxstatus; //hanglineboxstatus = SortingFault.GetFaultLineBoxStatus(); //if (hanglineboxstatus != null && hanglineboxstatus.status == 1) //{ // if (hanglineboxstatus.lineboxcode.ToString() != labblockbox.Text) // { // try // { // OperationLog operationLog = OperationLog.NewOperationLog(); // operationLog.OPERATIONCODE = "挂烟"; // operationLog.OPERATIONNAME = hanglineboxstatus.lineboxcode.ToString(); // operationLog.Save(); // } // catch // { // } // labblockbox.Text = hanglineboxstatus.lineboxcode.ToString(); // labblockbox.ForeColor = Color.Red; // labboxstatus.ForeColor = Color.Red; // labblockname.ForeColor = Color.Red; // if (SortingLineTaskDetail.GetSortingLineBoxCigNumber(hanglineboxstatus.lineboxcode) == 1) // { // labblockname.Text = // SortingLineTaskDetail.GetSortingLineBoxCigName(hanglineboxstatus.lineboxcode); // } // else // { // labblockname.Text = "混仓品牌"; // } // if (hanglineboxstatus.status == 1) // { // labboxstatus.Text = "挂烟"; // } // Thread thread = new Thread(new ParameterizedThreadStart(PlayHangSound)); // thread.Start(hanglineboxstatus); // } //} lineboxstatus = SortingFault.GetFaultLineBoxStatus(); if (lineboxstatus != null && (lineboxstatus.status == 4 || lineboxstatus.status == 8 || lineboxstatus.status == 16)) { if (lineboxstatus.lineboxcode.ToString() != labblockbox.Text) { try { //OperationLog operationLog = OperationLog.NewOperationLog(); //if (lineboxstatus.status == 8) //{ // operationLog.OPERATIONCODE = "卡烟"; //} //if (lineboxstatus.status == 4) //{ // operationLog.OPERATIONCODE = "缺烟"; //} //if (lineboxstatus.status == 16) //{ // operationLog.OPERATIONCODE = "挂烟"; //} //operationLog.OPERATIONNAME = lineboxstatus.lineboxcode.ToString(); //operationLog.Save(); } catch { } labblockbox.Text = lineboxstatus.lineboxcode.ToString(); labblockbox.ForeColor = Color.Red; labboxstatus.ForeColor = Color.Red; labblockname.ForeColor = Color.Red; if (SortingLineTaskDetail.GetSortingLineBoxCigNumber(lineboxstatus.lineboxcode) == 1) { labblockname.Text = SortingLineTaskDetail.GetSortingLineBoxCigName(lineboxstatus.lineboxcode); } else { labblockname.Text = "混仓品牌"; } if (lineboxstatus.status == 4) { labboxstatus.Text = "缺烟"; labputnum.Text = lineboxstatus.putnum.ToString(); } if (lineboxstatus.status == 8) { labboxstatus.Text = "卡烟"; labputnum.Text = lineboxstatus.putnum.ToString(); } if (lineboxstatus.status == 16) { labboxstatus.Text = "挂烟"; labputnum.Text = lineboxstatus.putnum.ToString(); } Thread thread = new Thread(new ParameterizedThreadStart(PlayBlockSound)); thread.Start(lineboxstatus); } } if (lineboxstatus == null) { labboxstatus.Text = "正常"; labboxstatus.ForeColor = Color.Green; labblockbox.Text = "无"; labblockbox.ForeColor = Color.Green; labblockname.Text = "无"; labblockname.ForeColor = Color.Green; labputnum.Text = "0"; } } catch (Exception ex) { OperationLog operationLog = OperationLog.NewOperationLog(); operationLog.OPERATIONCODE = "出现异常"; operationLog.OPERATIONNAME = ex.Message.Substring(0, 250); operationLog.Save(); } }