public void UpdateListView(KeyWorldsEntityInList keyWorldEntity, OperationType optType) { switch (optType) { case OperationType.Add: if (lstKeyWorldsInList.Count > 0) { KeyWorldsEntityInList last = lstKeyWorldsInList.Last(); if (last.Background == Brushes.LightGray) { keyWorldEntity.Background = Brushes.Transparent; } else { keyWorldEntity.Background = Brushes.LightGray; } } else { keyWorldEntity.Background = Brushes.Transparent; } lstKeyWorldsInList.Add(keyWorldEntity); break; case OperationType.Modify: KeyWorldsEntityInList keyworld = lstKeyWorldsInList.Where(p => p.KeyWorldID == keyWorldEntity.KeyWorldID).First(); keyworld.BookmarkLevelColor = keyWorldEntity.BookmarkLevelColor; break; case OperationType.Delete: lstKeyWorldsInList.Remove(keyWorldEntity); break; } PopupPanel.IsOpen = false; }
private void DeleteKeyworld() { Service510011Client client = null; try { KeyWorldsEntityInList keyWorld = lvKeyWorldsObject.SelectedItem as KeyWorldsEntityInList; WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S5100RequestCode.DeleteKeyWorld; webRequest.Session = CurrentApp.Session; webRequest.ListData.Add(keyWorld.KeyWorldID); client = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001")); WebReturn webReturn = client.DoOperation(webRequest); CurrentApp.MonitorHelper.AddWebReturn(webReturn); client.Close(); if (!webReturn.Result) { if (webReturn.Code != Defines.RET_FAIL) { ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message))); return; } else { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } } CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("OPR1", "Success")); UpdateListView(keyWorld, OperationType.Delete); } catch (Exception ex) { ShowException(ex.Message); } finally { if (client != null) { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } } }
void BasicOpt_Click(object sender, RoutedEventArgs e) { var btn = e.Source as Button; if (btn != null) { var optItem = btn.DataContext as OperationInfo; if (optItem == null) { return; } switch (optItem.ID) { case S5100Const.OPT_KeyWorldAdd: UC_KeyWorldEdit ucKeyWorldEdit = new UC_KeyWorldEdit(); ucKeyWorldEdit.CurrentApp = CurrentApp; ucKeyWorldEdit.iAddOrModify = OperationType.Add; ucKeyWorldEdit.ParentPage = this; PopupPanel.Content = ucKeyWorldEdit; PopupPanel.Title = CurrentApp.GetLanguageInfo("5102004", "Add a new key world"); PopupPanel.IsOpen = true; break; case S5100Const.OPT_KeyWroldModify: ucKeyWorldEdit = new UC_KeyWorldEdit(); ucKeyWorldEdit.CurrentApp = CurrentApp; ucKeyWorldEdit.iAddOrModify = OperationType.Modify; KeyWorldsEntityInList item = lvKeyWorldsObject.SelectedItem as KeyWorldsEntityInList; ucKeyWorldEdit.keyWorldInModify = item; ucKeyWorldEdit.ParentPage = this; PopupPanel.Content = ucKeyWorldEdit; PopupPanel.Title = CurrentApp.GetLanguageInfo("5102011", "Change the label level of keywords"); PopupPanel.IsOpen = true; break; case S5100Const.OPT_KeyWorldDelete: string strConfirm = CurrentApp.GetLanguageInfo("5102013", "Confirm"); string strPopupMsg = CurrentApp.GetLanguageInfo("5102010", "Are you sure you delete this item?"); MessageBoxResult result = MessageBox.Show(strPopupMsg, strConfirm, MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { DeleteKeyworld(); } break; } } }
private void GetAllKeyWorlds() { Service510011Client client = null; try { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S5100RequestCode.GetAllKeyWorlds; webRequest.Session = CurrentApp.Session; client = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001")); WebReturn webReturn = client.DoOperation(webRequest); CurrentApp.MonitorHelper.AddWebReturn(webReturn); client.Close(); if (!webReturn.Result) { if (webReturn.Code != Defines.RET_FAIL) { ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message))); return; } else { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } } List <string> lstRecords = webReturn.ListData; OperationReturn optReturn = null; KeyWorldsEntity keyWrold = null; KeyWorldsEntityInList keyWroldInList = null; for (int i = 0; i < lstRecords.Count; i++) { optReturn = XMLHelper.DeserializeObject <KeyWorldsEntity>(lstRecords[i]); if (optReturn.Result) { keyWrold = optReturn.Data as KeyWorldsEntity; keyWroldInList = new KeyWorldsEntityInList(); keyWroldInList.BookmarkLevelColor = keyWrold.BookmarkLevelcolor; keyWroldInList.BookmarkLevelID = keyWrold.BookmarkLevelID; keyWroldInList.KeyWorldContent = keyWrold.KeyWorldContent; keyWroldInList.KeyWorldID = keyWrold.KeyWorldID; keyWroldInList.LevelName = keyWrold.LevelName; lstKeyWorldsInList.Add(keyWroldInList); if (i % 2 == 1) { keyWroldInList.Background = Brushes.LightGray; } else { keyWroldInList.Background = Brushes.Transparent; } } } } catch (Exception ex) { ShowException(ex.Message); } finally { if (client != null) { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } } }
private void ModifyKeyWorld() { Service510011Client client = null; try { KeyWorldsEntityInList keyworld = new KeyWorldsEntityInList(); BookmarkLevelEntity level = (cmbLevels.SelectedItem as ComboBoxItem).DataContext as BookmarkLevelEntity; keyworld.KeyWorldID = keyWorldInModify.KeyWorldID; keyworld.KeyWorldContent = txtName.Text; keyworld.BookmarkLevelID = level.BookmarkLevelID; keyworld.BookmarkLevelColor = level.BookmarkLevelColor; WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S5100RequestCode.ModifyKeyWorld; webRequest.Session = CurrentApp.Session; webRequest.ListData.Add(keyworld.KeyWorldID); webRequest.ListData.Add(level.BookmarkLevelID); client = new Service510011Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service51001")); WebReturn webReturn = client.DoOperation(webRequest); CurrentApp.MonitorHelper.AddWebReturn(webReturn); client.Close(); string msg = string.Format("{0}{1}{2}", CurrentApp.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO5102002")), txtName.Text); msg += Utils.FormatOptLogString(string.Format("5102012")) + keyWorldInModify.LevelName + " -- " + level.BookmarkLevelName; if (!webReturn.Result) { CurrentApp.WriteOperationLog("5102002", ConstValue.OPT_RESULT_FAIL, msg); if (webReturn.Code != Defines.RET_FAIL) { if (webReturn.Code == (int)S5100WcfErrorCode.UploadKeyWorldXmlFailed) { string strMsg = CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), "Upload file failed, may be right enough, please complete control of license to the '{0}' folder Everyone"); strMsg = string.Format(strMsg, webReturn.Message); ShowException(strMsg); } else { ShowException(CurrentApp.GetLanguageInfo(((int)webReturn.Code).ToString(), string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message))); } } else { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (webReturn.Code > (int)S5100WcfErrorCode.GenerateKeyWorldXmlException) { ParentPage.UpdateListView(keyworld, OperationType.Modify); } } else { CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("OPR1", "Success")); CurrentApp.WriteOperationLog("5102002", ConstValue.OPT_RESULT_SUCCESS, msg); ParentPage.UpdateListView(keyworld, OperationType.Modify); } } catch (Exception ex) { ShowException(ex.Message); } finally { if (client != null) { if (client.State == System.ServiceModel.CommunicationState.Opened) { client.Close(); } } } }