private void Init() { if (AlarmInfoItem == null) { return; } try { AlarmInfomationItem info = AlarmInfoItem; TxtName.Text = info.Name; AlarmMessageInfo message = info.Message; if (message != null) { TxtAlarmType.Text = message.AlarmType.ToString(); TxtModule.Text = message.ModuleID.ToString(); TxtMessage.Text = message.MessageID.ToString(); TxtStatus.Text = message.StatusID.ToString(); } for (int i = 0; i < mListAlarmLevelItems.Count; i++) { var item = mListAlarmLevelItems[i]; if (item.Level == AlarmInfoItem.Level) { ComboLevel.SelectedItem = item; } } } catch (Exception ex) { ShowException(ex.Message); } }
private void LoadAlarmMessageInfos() { try { mListAlarmMessageInfos.Clear(); WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.GetAlarmMessageList; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("0"); Service44101Client client = new Service44101Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service44101")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (webReturn.ListData == null) { ShowException(string.Format("Fail.\tListData is null")); return; } int count = webReturn.ListData.Count; OperationReturn optReturn; for (int i = 0; i < count; i++) { string strInfo = webReturn.ListData[i]; optReturn = XMLHelper.DeserializeObject <AlarmMessageInfo>(strInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } AlarmMessageInfo info = optReturn.Data as AlarmMessageInfo; if (info == null) { ShowException(string.Format("Fail.\tAlarmMessage is null")); return; } mListAlarmMessageInfos.Add(info); } CurrentApp.WriteLog("LoadAlarmMessage", string.Format("Load end.\t{0}", mListAlarmMessageInfos.Count)); } catch (Exception ex) { ShowException(ex.Message); } }
private OperationReturn GetAlarmMessageList(SessionInfo session, List <string> listParams) { OperationReturn optReturn = new OperationReturn(); optReturn.Result = true; optReturn.Code = 0; try { //ListParam //0 用户编号 if (listParams == null || listParams.Count < 1) { optReturn.Result = false; optReturn.Code = Defines.RET_PARAM_INVALID; optReturn.Message = string.Format("Request param is null or count invalid"); return(optReturn); } string strUserID = listParams[0]; string strSql; DataSet objDataSet; switch (session.DBType) { case 2: strSql = string.Format("SELECT * FROM T_25_006 ORDER BY C001"); optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql); if (!optReturn.Result) { return(optReturn); } objDataSet = optReturn.Data as DataSet; break; case 3: strSql = string.Format("SELECT * FROM T_25_006 ORDER BY C001"); optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql); if (!optReturn.Result) { return(optReturn); } objDataSet = optReturn.Data as DataSet; break; default: optReturn.Result = false; optReturn.Code = Defines.RET_PARAM_INVALID; optReturn.Message = string.Format("Database type not surpport.\t{0}", session.DBType); return(optReturn); } if (objDataSet == null) { optReturn.Result = false; optReturn.Code = Defines.RET_OBJECT_NULL; optReturn.Message = string.Format("DataSet is null"); return(optReturn); } List <string> listReturn = new List <string>(); for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++) { DataRow dr = objDataSet.Tables[0].Rows[i]; AlarmMessageInfo item = new AlarmMessageInfo(); item.SerialID = Convert.ToInt64(dr["C001"]); item.AlarmType = Convert.ToInt32((dr["C002"])); item.ModuleID = Convert.ToInt32(dr["C003"]); item.MessageID = Convert.ToInt32(dr["C004"]); item.StatusID = Convert.ToInt32(dr["C005"]); item.IsEnabled = dr["C006"].ToString() == "1"; item.Description = dr["C007"].ToString(); optReturn = XMLHelper.SeriallizeObject(item); if (!optReturn.Result) { return(optReturn); } listReturn.Add(optReturn.Data.ToString()); } optReturn.Data = listReturn; } catch (Exception ex) { optReturn.Result = false; optReturn.Code = Defines.RET_FAIL; optReturn.Message = ex.Message; return(optReturn); } return(optReturn); }
private void AddAlarmMessage() { try { AlarmMessageInfo alarmInfo = new AlarmMessageInfo(); if (string.IsNullOrEmpty(TxtName.Text)) { ShowException(CurrentApp.GetLanguageInfo("4415N003", string.Format("Name empty"))); return; } alarmInfo.Name = TxtName.Text; var typeItem = ComboType.SelectedItem as ComboItem; if (typeItem == null) { ShowException(CurrentApp.GetLanguageInfo("4415N004", string.Format("Type invalid"))); return; } alarmInfo.Type = typeItem.IntValue; alarmInfo.State = RadioStateEnable.IsChecked == true ? 0 : 2; if (TxtRank.Value == null) { ShowException(CurrentApp.GetLanguageInfo("4415N006", string.Format("Rank invalid"))); return; } int intValue = (int)TxtRank.Value; if (intValue < 0 || intValue > 10) { ShowException(CurrentApp.GetLanguageInfo("4415N006", string.Format("Rank invalid"))); return; } alarmInfo.Rank = intValue; alarmInfo.Color = TxtColor.SelectedColor.ToString(); alarmInfo.Icon = mAlarmIcon; if (TxtHoldTime.Value == null) { ShowException(CurrentApp.GetLanguageInfo("4415N007", string.Format("HoldTime invalid"))); return; } intValue = (int)TxtHoldTime.Value; if (intValue < 0) { ShowException(CurrentApp.GetLanguageInfo("4415N007", string.Format("HoldTime invalid"))); return; } alarmInfo.HoldTime = intValue; typeItem = ComboRelativeState.SelectedItem as ComboItem; if (typeItem == null) { alarmInfo.StateID = 0; } else { alarmInfo.StateID = typeItem.LongValue; } alarmInfo.Value = TxtValue.Text; alarmInfo.Content = TxtContent.Text; bool isFail = true; string strMsg = string.Empty; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveAlarmMessage; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("0"); webRequest.ListData.Add("1");//拷贝图标文件 webRequest.ListData.Add("1"); OperationReturn optReturn = XMLHelper.SeriallizeObject(alarmInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } webRequest.ListData.Add(optReturn.Data.ToString()); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { Service44101Client client = new Service44101Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service44101")); WebReturn webReturn = client.DoOperation(webRequest); if (!webReturn.Result) { strMsg = string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message); return; } if (webReturn.ListData == null) { strMsg = string.Format("Fail.ListData is null"); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { string str = webReturn.ListData[i]; CurrentApp.WriteLog("AddAlarmMessage", string.Format("{0}", str)); } isFail = false; } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); if (!isFail) { ShowInformation(CurrentApp.GetLanguageInfo("4415N008", string.Format("Add successful"))); if (PageParent != null) { PageParent.ReloadData(); } var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } } else { ShowException(strMsg); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }