public GetAllCategoriesResult GetAllCategories() { var service = new DOMAService(); service.Url = WebServiceUrl; var request = new GetAllCategoriesRequest { Username = Username, Password = Password }; var response = service.GetAllCategories(request); var result = new GetAllCategoriesResult { ErrorMessage = response.ErrorMessage, Success = response.Success, }; if (response.Success) { result.Categories = new List <Category>(); foreach (var category in response.Categories) { result.Categories.Add(TranslateCategory(category)); } } return(result); }
private void FillCategories( TreeViewItem baseItem, GetAllCategoriesResult baseCategory, GetAllCategoriesResult[] allCategories) { allCategories.Where(item => item.ParentId == baseCategory.Id).ForEach(item => { var newItem = new TreeViewItem { Header = item.Name, Uid = item.Id.ToString(), IsExpanded = true }; baseItem.Items.Add(newItem); FillCategories(newItem, item, allCategories); }); }
private void Connect() { mapPublisher.Password = password.Text; mapPublisher.Username = username.Text; mapPublisher.WebServiceUrl = webServiceURL.Text; allMaps.Clear(); ConnectResult connectResult; GetAllMapsResult getAllMapsResult = null; GetAllCategoriesResult getAllCategoriesResult = null; try { Cursor = Cursors.WaitCursor; connectResult = mapPublisher.Connect(); Cursor = Cursors.Default; if (connectResult.Success) { Cursor = Cursors.WaitCursor; SaveConnectionSettings(); PopulateUsernameComboBox(); getAllMapsResult = GetAllMaps(); getAllCategoriesResult = mapPublisher.GetAllCategories(); } } catch (Exception ex) { connectResult = new ConnectResult { Success = false, ErrorMessage = ex.Message, Version = null }; } Cursor = Cursors.Default; map.DataSource = allMaps; var success = true; if (!connectResult.Success) { MessageBox.Show(connectResult.ErrorMessage, Strings.Error_MapPublishCommunication, MessageBoxButtons.OK, MessageBoxIcon.Error); success = false; } if (getAllMapsResult != null && !getAllMapsResult.Success) { MessageBox.Show(getAllMapsResult.ErrorMessage, Strings.Error_MapPublishCommunication, MessageBoxButtons.OK, MessageBoxIcon.Error); success = false; } if (getAllCategoriesResult != null && !getAllCategoriesResult.Success) { MessageBox.Show(getAllCategoriesResult.ErrorMessage, Strings.Error_MapPublishCommunication, MessageBoxButtons.OK, MessageBoxIcon.Error); success = false; } if (getAllCategoriesResult != null) { category.DataSource = getAllCategoriesResult.Categories; } SetControlEnabledState(success); if (map.Items.Count > 0) { map.SelectedIndex = 0; } }