private void SetRegionMmt(ObjItem regionItem, List <string> listUserIDStates) { try { int count = listUserIDStates.Count; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SetRegionMmt; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(regionItem.ObjID.ToString()); webRequest.ListData.Add(count.ToString()); for (int i = 0; i < count; i++) { webRequest.ListData.Add(listUserIDStates[i]); } 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; } CurrentApp.WriteLog("SetRegionMmt", string.Format("End.\t{0}", regionItem.ObjID)); ShowInformation(CurrentApp.GetLanguageInfo("COMN003", string.Format("Save end"))); } catch (Exception ex) { ShowException(ex.Message); } }
private void LoadRegionSeatInfos() { try { mListRegionSeats.Clear(); if (RegionItem == null) { return; } long regionID = RegionItem.ObjID; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.GetRegionSeatList; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(regionID.ToString()); 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; } OperationReturn optReturn; for (int i = 0; i < webReturn.ListData.Count; i++) { string strInfo = webReturn.ListData[i]; optReturn = XMLHelper.DeserializeObject <RegionSeatInfo>(strInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } RegionSeatInfo info = optReturn.Data as RegionSeatInfo; if (info == null) { ShowException(string.Format("Fail.\tRegionSeatInfo is null")); return; } mListRegionSeats.Add(info); } CurrentApp.WriteLog("LoadRegionSeatInfo", string.Format("Load end.\t{0}", mListRegionSeats.Count)); } catch (Exception ex) { ShowException(ex.Message); } }
private void LoadRegionUserIDs() { try { mListRegionUserIDs.Clear(); if (RegionItem == null) { return; } WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.GetRegionUserList; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(RegionItem.ObjID.ToString()); 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; } for (int i = 0; i < webReturn.ListData.Count; i++) { string strID = webReturn.ListData[i]; long id; if (long.TryParse(strID, out id)) { mListRegionUserIDs.Add(id); } } CurrentApp.WriteLog("LoadRegionUserIDs", string.Format("Load end.\t{0}", mListRegionUserIDs.Count)); } catch (Exception ex) { ShowException(ex.Message); } }
private void SaveRegionSeats() { try { if (RegionInfo == null) { return; } List <RegionSeatInfo> listCheckedSeats = new List <RegionSeatInfo>(); for (int i = 0; i < mListCheckableSeatItems.Count; i++) { var item = mListCheckableSeatItems[i]; if (item.IsChecked) { var regionSeat = ListRegionSeats.FirstOrDefault(s => s.SeatID == item.SeatID); if (regionSeat == null) { regionSeat = new RegionSeatInfo(); regionSeat.RegionID = RegionInfo.ObjID; regionSeat.SeatID = item.SeatID; regionSeat.Creator = CurrentApp.Session.UserID; regionSeat.CreateTime = DateTime.Now.ToUniversalTime(); } regionSeat.Modifier = CurrentApp.Session.UserID; regionSeat.ModifyTime = DateTime.Now.ToUniversalTime(); listCheckedSeats.Add(regionSeat); } } int count = listCheckedSeats.Count; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveRegionSeatInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("1"); webRequest.ListData.Add(RegionInfo.ObjID.ToString()); webRequest.ListData.Add(count.ToString()); OperationReturn optReturn; for (int i = 0; i < count; i++) { optReturn = XMLHelper.SeriallizeObject(listCheckedSeats[i]); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } webRequest.ListData.Add(optReturn.Data.ToString()); } 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; } for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("SaveRegionSeats", string.Format("{0}", webReturn.ListData[i])); } CurrentApp.WriteLog("SaveRegionSeats", "Save end."); ShowInformation(string.Format("Save region seat end.")); if (PageParent != null) { PageParent.Reload(); } var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } } catch (Exception ex) { ShowException(ex.Message); } }
private void LoadRegionExtItems(ChildRegionItem childRegionItem, ObjItem regionItem) { try { long regionID = regionItem.ObjID; string strRegionName = regionItem.Name; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.GetRegionSeatList; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(regionID.ToString()); 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; } OperationReturn optReturn; for (int i = 0; i < webReturn.ListData.Count; i++) { string strInfo = webReturn.ListData[i]; optReturn = XMLHelper.DeserializeObject <RegionSeatInfo>(strInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } RegionSeatInfo info = optReturn.Data as RegionSeatInfo; if (info == null) { ShowException(string.Format("Fail.\tRegionSeatInfo is null")); return; } if (ListAllSeatInfos == null) { continue; } var seatInfo = ListAllSeatInfos.FirstOrDefault(s => s.ObjID == info.SeatID); if (seatInfo == null) { continue; } RegionExtensionItem extItem = new RegionExtensionItem(); extItem.SeatInfo = seatInfo; extItem.ChildRegionID = childRegionItem.RegionID; extItem.RegionID = regionID; extItem.SeatID = seatInfo.ObjID; extItem.SeatName = seatInfo.Name; extItem.Extension = seatInfo.Extension; childRegionItem.ListRegionExtItems.Add(extItem); mListAllRegionExtItems.Add(extItem); } CurrentApp.WriteLog("LoadRegionExtItems", string.Format("Load end.\t{0}\t{1}", strRegionName, childRegionItem.ListRegionExtItems.Count)); } catch (Exception ex) { ShowException(ex.Message); } }
private void ModifySeat() { try { if (SeatItem == null) { return; } long objID = SeatItem.ObjID; string strName = TxtName.Text; if (string.IsNullOrEmpty(strName)) { ShowException(CurrentApp.GetLanguageInfo("4413N004", string.Format("Name invalid"))); return; } string strExtension = TxtExtension.Text; if (string.IsNullOrEmpty(strExtension)) { ShowException(CurrentApp.GetLanguageInfo("4413N005", string.Format("Extension invalid"))); return; } bool isEnable = RadioStateEnable.IsChecked == true; if (TxtLevel.Value == null) { ShowException(CurrentApp.GetLanguageInfo("4413N006", string.Format("Level invalid"))); return; } int intLevel = (int)TxtLevel.Value; if (intLevel < 0 || intLevel >= 10) { ShowException(CurrentApp.GetLanguageInfo("4413N006", string.Format("Level invalid"))); return; } string strDescription = TxtDescription.Text; SeatInfo seatInfo = new SeatInfo(); seatInfo.ObjID = objID; seatInfo.Name = strName; seatInfo.Extension = strExtension; seatInfo.State = isEnable ? 1 : 0; seatInfo.Level = intLevel; seatInfo.Description = strDescription; seatInfo.Modifier = CurrentApp.Session.UserID; seatInfo.ModifyTime = DateTime.Now.ToUniversalTime(); #region 检查是否有重复的座位名 if (ListAllSeatInfo == null) { return; } var temp = ListAllSeatInfo.FirstOrDefault(s => s.Name.ToLower() == seatInfo.Name.ToLower()); if (temp != null && temp.ObjID != objID) { ShowException(CurrentApp.GetLanguageInfo("4413N009", string.Format("Same seat name!"))); return; } #endregion List <SeatInfo> listSeatInfos = new List <SeatInfo>(); listSeatInfos.Add(seatInfo); WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveSeatInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("0"); webRequest.ListData.Add("1"); OperationReturn optReturn = XMLHelper.SeriallizeObject(seatInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } webRequest.ListData.Add(optReturn.Data.ToString()); bool isSuccess = false; 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); 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; } for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("ModifySeat", string.Format("{0}", webReturn.ListData[i])); } isSuccess = true; } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); try { if (!isSuccess) { return; } ShowInformation(CurrentApp.GetLanguageInfo("4413N008", string.Format("Modify seat successful!"))); var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } if (PageParent != null) { PageParent.Reload(); } } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void AddSeat() { try { if (TxtCount.Value == null) { ShowException(CurrentApp.GetLanguageInfo("4413N003", string.Format("Count invalid"))); return; } int intCount = (int)TxtCount.Value; if (intCount <= 0 || intCount >= 10000) { ShowException(CurrentApp.GetLanguageInfo("4413N003", string.Format("Count invalid"))); return; } string strName = TxtName.Text; if (string.IsNullOrEmpty(strName)) { ShowException(CurrentApp.GetLanguageInfo("4413N004", string.Format("Name invalid"))); return; } string strExtension = TxtExtension.Text; if (string.IsNullOrEmpty(strExtension)) { ShowException(CurrentApp.GetLanguageInfo("4413N005", string.Format("Extension invalid"))); return; } bool isEnable = RadioStateEnable.IsChecked == true; if (TxtLevel.Value == null) { ShowException(CurrentApp.GetLanguageInfo("4413N006", string.Format("Level invalid"))); return; } int intLevel = (int)TxtLevel.Value; if (intLevel < 0 || intLevel >= 10) { ShowException(CurrentApp.GetLanguageInfo("4413N006", string.Format("Level invalid"))); return; } string strDescription = TxtDescription.Text; List <SeatInfo> listSeatInfos = new List <SeatInfo>(); if (intCount == 1) { SeatInfo seatInfo = new SeatInfo(); seatInfo.Name = strName; seatInfo.Extension = strExtension; seatInfo.State = isEnable ? 1 : 0; seatInfo.Level = intLevel; seatInfo.Description = strDescription; seatInfo.Creator = CurrentApp.Session.UserID; seatInfo.CreateTime = DateTime.Now.ToUniversalTime(); seatInfo.Modifier = CurrentApp.Session.UserID; seatInfo.ModifyTime = DateTime.Now.ToUniversalTime(); listSeatInfos.Add(seatInfo); } else { string strTemp = strName; string strPreName = string.Empty; int intLengthName = strTemp.Length; int intNumberName; while (!int.TryParse(strTemp, out intNumberName) && !string.IsNullOrEmpty(strTemp)) { string str = strTemp.Substring(0, 1); strPreName += str; strTemp = strTemp.Substring(1); intLengthName--; } strTemp = strExtension; string strPreExtension = string.Empty; int intLengthExtension = strTemp.Length; int intNumberExtension; while (!int.TryParse(strTemp, out intNumberExtension) && !string.IsNullOrEmpty(strTemp)) { string str = strTemp.Substring(0, 1); strPreExtension += str; strTemp = strTemp.Substring(1); intLengthExtension--; } for (int i = 0; i < intCount; i++) { string strNumber = (i + intNumberName).ToString(); strName = strPreName + strNumber.PadLeft(intLengthName, '0'); strNumber = (i + intNumberExtension).ToString(); strExtension = strPreExtension + strNumber.PadLeft(intLengthExtension, '0'); SeatInfo seatInfo = new SeatInfo(); seatInfo.Name = strName; seatInfo.Extension = strExtension; seatInfo.State = isEnable ? 1 : 0; seatInfo.Level = intLevel; seatInfo.Description = strDescription; seatInfo.Creator = CurrentApp.Session.UserID; seatInfo.CreateTime = DateTime.Now.ToUniversalTime(); seatInfo.Modifier = CurrentApp.Session.UserID; seatInfo.ModifyTime = DateTime.Now.ToUniversalTime(); listSeatInfos.Add(seatInfo); } } int count = listSeatInfos.Count; #region 检查是否有重复的座位名 if (ListAllSeatInfo == null) { return; } for (int i = 0; i < count; i++) { var info = listSeatInfos[i]; var temp = ListAllSeatInfo.FirstOrDefault(s => s.Name.ToLower() == info.Name.ToLower()); if (temp != null) { ShowException(CurrentApp.GetLanguageInfo("4413N009", string.Format("Same seat name!"))); return; } } #endregion WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveSeatInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("0"); webRequest.ListData.Add(count.ToString()); OperationReturn optReturn; for (int i = 0; i < count; i++) { optReturn = XMLHelper.SeriallizeObject(listSeatInfos[i]); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } webRequest.ListData.Add(optReturn.Data.ToString()); } bool isSuccess = false; 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); 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; } for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("AddSeat", string.Format("{0}", webReturn.ListData[i])); } isSuccess = true; } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); try { if (!isSuccess) { return; } ShowInformation(CurrentApp.GetLanguageInfo("4413N007", string.Format("Add seats successful!"))); var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } if (PageParent != null) { PageParent.Reload(); } } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void ModifyRegion() { try { RegionInfo regionInfo = RegionItem.Data as RegionInfo; if (regionInfo == null) { return; } if (string.IsNullOrEmpty(TxtRegionName.Text)) { ShowException(CurrentApp.GetLanguageInfo("4412N003", string.Format("Region name can not be empty."))); return; } regionInfo.Name = TxtRegionName.Text; var regionType = ComboRegionTypes.SelectedItem as RegionTypeItem; if (regionType == null) { ShowException(CurrentApp.GetLanguageInfo("4412N004", string.Format("Region type invalid."))); return; } regionInfo.Type = regionType.Value; regionInfo.State = RadioStateEnable.IsChecked == true ? 1 : 0; regionInfo.IsDefault = RadioDefaultYes.IsChecked == true; int intValue = 0; if (TxtRegionWidth.Value != null && TxtRegionWidth.Value > 0) { intValue = (int)TxtRegionWidth.Value; } regionInfo.Width = intValue; intValue = 0; if (TxtRegionHeight.Value != null && TxtRegionHeight.Value > 0) { intValue = (int)TxtRegionHeight.Value; } regionInfo.Height = intValue; bool isCopy = false; regionInfo.BgColor = TxtBgColor.SelectedColor.ToString(); if (!string.IsNullOrEmpty(mBgFileName)) { regionInfo.BgImage = mBgFileName; isCopy = true; } OperationReturn optReturn = XMLHelper.SeriallizeObject(regionInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } string strInfo = optReturn.Data.ToString(); bool isSuccess = false; string strMsg = string.Empty; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveRegionInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(regionInfo.ObjID.ToString()); webRequest.ListData.Add(strInfo); webRequest.ListData.Add(isCopy ? "1" : "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) { strMsg = string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message); return; } isSuccess = true; } catch (Exception ex) { strMsg = ex.Message; } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); try { if (isSuccess) { ShowInformation(CurrentApp.GetLanguageInfo("4412N006", string.Format("Modify region end"))); var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } if (PageParent != null) { var parentItem = RegionItem.Parent as ObjItem; if (parentItem != null) { parentItem.IsExpanded = true; PageParent.ReloadRegionInfo(parentItem); } } } else { ShowException(strMsg); } } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void LoadRegionInfos(ObjItem parent, long parentID) { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.GetRegionInfoList; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(parentID.ToString()); 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; int valid = 0; OperationReturn optReturn; for (int i = 0; i < count; i++) { string strInfo = webReturn.ListData[i]; optReturn = XMLHelper.DeserializeObject <RegionInfo>(strInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } RegionInfo info = optReturn.Data as RegionInfo; if (info == null) { ShowException(string.Format("Fail.\tRegionInfo is null")); return; } ObjItem item = new ObjItem(); item.Data = info; item.ObjType = S4410Consts.RESOURCE_REGION; item.ObjID = info.ObjID; item.Name = info.Name; string strDescription = info.Description; if (string.IsNullOrEmpty(strDescription)) { strDescription = item.Name; } item.Description = strDescription; item.Type = info.Type; item.Icon = GetItemIcon(item); item.CurrentApp = CurrentApp; if (mListUserRegionIDs.Contains(info.ObjID)) { mListRegionItems.Add(item); AddChild(parent, item); valid++; LoadRegionInfos(item, info.ObjID); } else { LoadRegionInfos(parent, info.ObjID); } } CurrentApp.WriteLog("LoadRegionInfos", string.Format("Load end.\t{0};Valid:{1}", count, valid)); } catch (Exception ex) { ShowException(ex.Message); } }
private void SaveAlarmUserInfos() { try { if (AlarmItem == null) { return; } long alarmID = AlarmItem.SerialID; List <ObjItem> listItems = new List <ObjItem>(); GetCheckItems(mRootUserItem, ref listItems); List <AlarmUserInfo> listUserInfos = new List <AlarmUserInfo>(); for (int i = 0; i < listItems.Count; i++) { var item = listItems[i]; var objID = item.ObjID; var objType = item.ObjType; var temp = mListAlarmUserInfos.FirstOrDefault(a => a.UserID == objID); if (temp == null) { temp = new AlarmUserInfo(); temp.AlarmID = alarmID; temp.UserID = objID; temp.UserType = objType; temp.Creator = CurrentApp.Session.UserID; temp.CreateTime = DateTime.Now.ToUniversalTime(); } temp.Modifier = CurrentApp.Session.UserID; temp.ModifyTime = DateTime.Now.ToUniversalTime(); listUserInfos.Add(temp); } int count = listUserInfos.Count; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveAlarmUser; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(alarmID.ToString()); webRequest.ListData.Add(count.ToString()); OperationReturn optReturn; for (int i = 0; i < count; i++) { var userInfo = listUserInfos[i]; optReturn = XMLHelper.SeriallizeObject(userInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } webRequest.ListData.Add(optReturn.Data.ToString()); } bool isFail = true; string strMsg = string.Empty; 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); client.Close(); if (!webReturn.Result) { strMsg = string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message); return; } if (webReturn.ListData == null) { strMsg = string.Format("Fail.\tListData is null"); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("SaveAlarmUserInfos", string.Format("{0}", webReturn.ListData[i])); } isFail = false; } catch (Exception ex) { strMsg = ex.Message; } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); if (isFail) { ShowException(strMsg); } else { ShowInformation(CurrentApp.GetLanguageInfo("4415N010", string.Format("Save Alarm User end."))); var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void SaveRegionMap() { try { if (mRegionInfo == null) { return; } List <RegionSeatInfo> listRegionSeats = new List <RegionSeatInfo>(); for (int i = 0; i < mListSeatItems.Count; i++) { var item = mListSeatItems[i]; var info = item.Info; if (info == null) { continue; } info.Modifier = CurrentApp.Session.UserID; info.ModifyTime = DateTime.Now.ToUniversalTime(); listRegionSeats.Add(info); } int count = listRegionSeats.Count; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveRegionSeatInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("0"); webRequest.ListData.Add(mRegionInfo.ObjID.ToString()); webRequest.ListData.Add(count.ToString()); OperationReturn optReturn; for (int i = 0; i < count; i++) { optReturn = XMLHelper.SeriallizeObject(listRegionSeats[i]); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } webRequest.ListData.Add(optReturn.Data.ToString()); } 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; } for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("SaveRegionMap", string.Format("{0}", webReturn.ListData[i])); } ShowInformation(CurrentApp.GetLanguageInfo("COMN003", string.Format("Save end"))); } catch (Exception ex) { ShowException(ex.Message); } }
private void DeleteSeat() { try { var items = LvSeatList.SelectedItems; string strMsg = string.Empty; List <SeatInfo> listSeatInfos = new List <SeatInfo>(); for (int i = 0; i < items.Count; i++) { var item = items[i] as ObjItem; if (item != null) { var seatInfo = item.Data as SeatInfo; if (seatInfo != null) { listSeatInfos.Add(seatInfo); } } } int count = listSeatInfos.Count; int tempCount = Math.Min(count, 5); for (int i = 0; i < tempCount; i++) { strMsg += string.Format("{0}\r\n", listSeatInfos[i].Name); } if (tempCount < count) { strMsg += string.Format("...\r\n"); } strMsg = string.Format("{0}\r\n{1}", CurrentApp.GetLanguageInfo("4413N001", "Confirm delete seats?"), strMsg); var result = MessageBox.Show(strMsg, CurrentApp.AppTitle, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } OperationReturn optReturn; WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveSeatInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("2");//删除 webRequest.ListData.Add(count.ToString()); for (int i = 0; i < count; i++) { optReturn = XMLHelper.SeriallizeObject(listSeatInfos[i]); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } webRequest.ListData.Add(optReturn.Data.ToString()); } bool isSuccessful = false; 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); 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.\t ListData is null")); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("DeleteSeat", string.Format("{0}", webReturn.ListData[i])); } isSuccessful = true; } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); try { if (isSuccessful) { ShowInformation(CurrentApp.GetLanguageInfo("4413N002", string.Format("Delete seat successful."))); Reload(); } } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void ModifyAgentState() { try { if (StateItem == null) { return; } var stateInfo = StateItem.Data as AgentStateInfo; if (stateInfo == null) { return; } string strName = TxtName.Text; if (string.IsNullOrEmpty(strName)) { ShowException(CurrentApp.GetLanguageInfo("4414N003", string.Format("Name can not be empty."))); return; } stateInfo.Name = strName; var typeItem = ComboStateTypes.SelectedItem as StateTypeItem; if (typeItem != null) { stateInfo.Type = typeItem.Value; } else { stateInfo.Type = S4410Consts.STATE_TYPE_UNKOWN; } string strValue = TxtValue.Text; int intValue; if (!int.TryParse(strValue, out intValue) || intValue < 0) { ShowException(CurrentApp.GetLanguageInfo("4414N004", string.Format("Value invalid"))); return; } stateInfo.Value = intValue; stateInfo.State = RadioStateEnable.IsChecked == true ? 1 : 0; stateInfo.Color = TxtColor.SelectedColor.ToString(); bool isCopy = false; if (!string.IsNullOrEmpty(mStateIcon)) { stateInfo.Icon = mStateIcon; isCopy = true; } //stateInfo.IsWorkTime = RadioIsWorkTimeYes.IsChecked == true; stateInfo.IsWorkTime = true; stateInfo.Description = TxtDescription.Text; stateInfo.Modifier = CurrentApp.Session.UserID; stateInfo.ModifyTime = DateTime.Now.ToUniversalTime(); OperationReturn optReturn; optReturn = XMLHelper.SeriallizeObject(stateInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } string strInfo = optReturn.Data.ToString(); bool isSuccess = false; string strMsg = string.Empty; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.SaveAgentStateInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("0"); webRequest.ListData.Add(isCopy ? "1" : "0"); webRequest.ListData.Add("1"); webRequest.ListData.Add(strInfo); Service44101Client client = new Service44101Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service44101")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { strMsg = string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message); return; } if (webReturn.ListData != null) { for (int i = 0; i < webReturn.ListData.Count; i++) { CurrentApp.WriteLog("DeleteAgentState", string.Format("{0}", webReturn.ListData[i])); } } isSuccess = true; } catch (Exception ex) { strMsg = ex.Message; } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); try { if (isSuccess) { ShowInformation(CurrentApp.GetLanguageInfo("4414N006", string.Format("Modify AgentState end"))); var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } if (PageParent != null) { PageParent.ReloadData(); } } else { ShowException(strMsg); } } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void DeleteRegion() { try { var item = GridTreeRegions.SelectedItem as ObjItem; if (item == null) { return; } var info = item.Data as RegionInfo; if (info == null) { return; } if (info.ObjID == S4410Consts.REGION_ROOT) { ShowException(CurrentApp.GetLanguageInfo("4412N001", string.Format("Root region can not be deleted."))); return; } var result = MessageBox.Show(string.Format("{0}\r\n\r\n{1}", CurrentApp.GetLanguageInfo("4412N002", "Confirm delete region?"), info.Name), CurrentApp.AppTitle, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } bool isSuccess = false; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S4410Codes.DeleteRegionInfo; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add(info.ObjID.ToString()); 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; } ShowInformation(string.Format("Delete region end")); isSuccess = true; } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); try { if (isSuccess) { var parentItem = item.Parent as ObjItem; if (parentItem != null) { parentItem.IsExpanded = true; ReloadRegionInfo(parentItem); } } } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }