public void GetOrgUsers() { Epi.Web.Common.Message.UserRequest Request = new Epi.Web.Common.Message.UserRequest(); try { SurveyManagerServiceV4.ManagerServiceV4Client client = ServiceClient.GetClientV4(); Request.Organization.OrganizationKey = this.EditOtextBox1.Text.ToString(); var Result = client.GetUserListByOrganization(Request); UserlistBox.Items.Clear(); if (Result.Message != null) { richTextBox1.AppendText(Result.Message.ToString()); } if (Result.User != null) { for (int i = 0; i < Result.User.Count; i++) { this.UserlistBox.Items.Add(Result.User[i].FirstName + " " + Result.User[i].LastName + "___" + Result.User[i].UserId); } this.UserlistBox.SelectedIndex = 0; } } catch (Exception ex) { richTextBox1.AppendText("Error occurred while getting Organization users. "); } }
private void PingButton_Click(object sender, RoutedEventArgs e) { this.PingResultTextBox.Text = ""; string pEndPointAddress = this.EndPointURLTextBox.Text; bool pIsAuthenticated = false; bool pIsWsHTTPBinding = true; if ((bool)this.YesRadioButton.IsChecked) { pIsAuthenticated = true; } if ((bool)this.wsHTTPRadioButton.IsChecked) { pIsWsHTTPBinding = true; } else { pIsWsHTTPBinding = false; } try { int ServiceVersion = ServiceClient.GetServiceVersion(); if (ServiceVersion == 1) { SurveyManagerServiceV4.ManagerServiceV4Client Client = ServiceClient.GetClientV4(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding); Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); var Result = Client.GetOrganization(Request); } else if (ServiceVersion == 2) { SurveyManagerServiceV2.ManagerServiceV2Client Client = ServiceClient.GetClientV2(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding); Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); var Result = Client.GetOrganization(Request); } else if (ServiceVersion == 3) { SurveyManagerServiceV3.ManagerServiceV3Client Client = ServiceClient.GetClientV3(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding); Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); var Result = Client.GetOrganization(Request); } else if (ServiceVersion == 4) { SurveyManagerServiceV4.ManagerServiceV4Client Client = ServiceClient.GetClientV4(pEndPointAddress, pIsAuthenticated, pIsWsHTTPBinding); Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); var Result = Client.GetOrganization(Request); } this.PingResultTextBox.Text = "Successfully Created Service Client"; this.PingResultTextBox.Text = "Successfully Created Service Client"; } catch (Exception ex) { this.PingResultTextBox.Text = "Failed to create Service Client:\n\n" + ex.Message; } }
private void Button_Click(object sender, RoutedEventArgs e) { Epi.Web.Common.Message.UserRequest Request = new Epi.Web.Common.Message.UserRequest(); SurveyManagerServiceV4.ManagerServiceV4Client Client = ServiceClient.GetClientV4(); Request.User.FirstName = FName.Text.ToString(); Request.User.LastName = LName.Text.ToString(); Request.User.EmailAddress = Email.Text.ToString(); Request.User.PhoneNumber = this.PhoneNum.Text.ToString(); Request.User.UserName = Email.Text.ToString().Split('@')[0]; Request.User.UGuid = Guid.NewGuid(); Request.User.PasswordHash = "NA"; Request.User.ResetPassword = false; if (IsActive.IsChecked != null) { Request.User.IsActive = IsActive.IsChecked.Value; } else { Request.User.IsActive = false; } Request.Organization.OrganizationKey = _OrganizationKey.ToString(); bool Result = false; if (string.IsNullOrEmpty(_UserName)) { Result = Client.SetUserInfo(Request); } else { var UserId = _UserName.Substring(_UserName.IndexOf("___") + 3); var OrgId = _OrganizationName.Substring(_OrganizationName.IndexOf("___") + 3); Request.User.Operation = Common.Constants.Constant.OperationMode.UpdateUserInfo; Request.User.UserId = int.Parse(UserId); Request.Organization.OrganizationId = int.Parse(OrgId); Result = Client.UpdateUserInfo(Request); } Message.Text = ""; if (Result) { //Message.Foreground = Brushes.Green; //Message.Text = "Successfully added a user"; Page_AddOrganization Page_AddUser = new Page_AddOrganization(_AdminKey.ToString(), _OrganizationName.ToString()); this.NavigationService.Navigate(Page_AddUser); } else { Message.Foreground = Brushes.Red; Message.Text = "Error occurred while trying to add a user"; } // Message.Text= (Result.Message.ToString()); }
//public Page_AddUser(Guid OrganizationKey, Guid AdminKey , string Organization ) //{ // _OrganizationKey = OrganizationKey; // _AdminKey = AdminKey; // _OrganizationName = Organization; // InitializeComponent(); // Cancel1.Visibility = Visibility.Hidden; // // TextBlock_OrganizationName = new TextBlock(); // TextBlock_OrganizationName.Text = Organization; //} public Page_AddUser(Guid OrganizationKey, Guid AdminKey, string Organization, string UserName, bool ShowCancel) { _OrganizationKey = OrganizationKey; _AdminKey = AdminKey; _OrganizationName = Organization; _UserName = UserName; InitializeComponent(); if (!ShowCancel) { Cancel1.Visibility = Visibility.Hidden; } else { Cancel1.Visibility = Visibility.Visible; } if (string.IsNullOrEmpty(UserName)) { this.AddEditUser.Content = "Add User"; } else { this.AddEditUser.Content = "Update User"; // Add select user info to the screen Epi.Web.Common.Message.UserRequest Request = new Epi.Web.Common.Message.UserRequest(); SurveyManagerServiceV4.ManagerServiceV4Client Client = ServiceClient.GetClientV4(); var UserId = UserName.Substring(UserName.IndexOf("___") + 3); var OrgId = Organization.Substring(Organization.IndexOf("___") + 3); Request.User.UserId = int.Parse(UserId); Request.Organization.OrganizationId = int.Parse(OrgId); var Result = Client.GetUserByUserId(Request); FName.Text = Result.User[0].FirstName; LName.Text = Result.User[0].LastName; Email.Text = Result.User[0].EmailAddress; this.PhoneNum.Text = Result.User[0].PhoneNumber; if (Result.User[0].IsActive) { IsActive.IsChecked = true; } else { IsActive.IsChecked = false; } } TextBlock_OrganizationName.Text = Organization; }
public void GetOrganizationNames() { richTextBox1.AppendText("Simo is here"); Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); richTextBox1.Document.Blocks.Clear(); try { if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString())) { int ServiceVersion = ServiceClient.GetServiceVersion(); if (ServiceVersion == 1) { Request.AdminSecurityKey = new Guid(passwordBox1.Password); SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient(); Epi.Web.Common.Message.OrganizationResponse Result = client.GetOrganizationNames(Request); OnamelistBox1.Items.Clear(); if (Result.Message != null) { richTextBox1.AppendText(Result.Message.ToString()); } if (Result.OrganizationList != null) { for (int i = 0; i < Result.OrganizationList.Count; i++) { this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization + "___" + Result.OrganizationList[i].OrganizationId); } this.OnamelistBox1.SelectedIndex = 0; } } else if (ServiceVersion == 2) { Request.AdminSecurityKey = new Guid(passwordBox1.Password); SurveyManagerServiceV2.ManagerServiceV2Client client = ServiceClient.GetClientV2(); Epi.Web.Common.Message.OrganizationResponse Result = client.GetOrganizationNames(Request); OnamelistBox1.Items.Clear(); if (Result.Message != null) { richTextBox1.AppendText(Result.Message.ToString()); } if (Result.OrganizationList != null) { for (int i = 0; i < Result.OrganizationList.Count; i++) { this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization); } this.OnamelistBox1.SelectedIndex = 0; } } else if (ServiceVersion == 3) { Request.AdminSecurityKey = new Guid(passwordBox1.Password); SurveyManagerServiceV3.ManagerServiceV3Client client = ServiceClient.GetClientV3(); Epi.Web.Common.Message.OrganizationResponse Result = client.GetOrganizationNames(Request); OnamelistBox1.Items.Clear(); if (Result.Message != null) { richTextBox1.AppendText(Result.Message.ToString()); } if (Result.OrganizationList != null) { for (int i = 0; i < Result.OrganizationList.Count; i++) { this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization); } this.OnamelistBox1.SelectedIndex = 0; } } else if (ServiceVersion == 4) { Request.AdminSecurityKey = new Guid(passwordBox1.Password); SurveyManagerServiceV4.ManagerServiceV4Client client = ServiceClient.GetClientV4(); Epi.Web.Common.Message.OrganizationResponse Result = client.GetOrganizationNames(Request); OnamelistBox1.Items.Clear(); if (Result.Message != null) { richTextBox1.AppendText(Result.Message.ToString()); } if (Result.OrganizationList != null) { for (int i = 0; i < Result.OrganizationList.Count; i++) { this.OnamelistBox1.Items.Add(Result.OrganizationList[i].Organization); } this.OnamelistBox1.SelectedIndex = 0; } if (this.OnamelistBox1.SelectedItem != null) { GetOrgUsers(); } } else { richTextBox1.AppendText("Error occurred while trying to get all organization names."); } } else { richTextBox1.AppendText("Admin key is required and Should be a Guid."); } } catch (Exception ex) { richTextBox1.AppendText("Error occurred while trying to get all organization names. "); } }
private void GetKey_Clik(object sender, RoutedEventArgs e) { //SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient(); //Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); this.ONameEditTextBox1.Clear(); this.checkBox1.IsChecked = false; richTextBox1.Document.Blocks.Clear(); try { if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString())) { if (OnamelistBox1.Items.Count > 0) { if (!string.IsNullOrEmpty(OnamelistBox1.SelectedItem.ToString())) { int ServiceVersion = ServiceClient.GetServiceVersion(); SurveyManagerServiceV4.ManagerServiceV4Client client = ServiceClient.GetClientV4(); Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); Request.Organization.Organization = this.OnamelistBox1.SelectedItem.ToString().Remove(OnamelistBox1.SelectedItem.ToString().IndexOf("___")); Request.AdminSecurityKey = new Guid(passwordBox1.Password); Epi.Web.Common.Message.OrganizationResponse Result = client.GetOrganization(Request); EditOtextBox1.Clear(); ONameEditTextBox1.Clear(); if (Result.Message != null) { richTextBox1.AppendText(Result.Message.ToString()); } if (Result.OrganizationList != null) { for (int i = 0; i < Result.OrganizationList.Count; i++) { // EditOtextBox1.Text = Cryptography.Decrypt(Result.OrganizationList[i].OrganizationKey.ToString()); EditOtextBox1.Text = Result.OrganizationList[i].OrganizationKey.ToString(); this.ONameEditTextBox1.Text = Result.OrganizationList[i].Organization; this.checkBox1.IsChecked = Result.OrganizationList[i].IsEnabled; } } } } else { richTextBox1.AppendText("Please selet a organization name."); } } else { richTextBox1.AppendText("Please selet a organization name. And admin key is required and Should be a Guid. "); } // } // else // { // richTextBox1.AppendText("Admin pass is required and Should be a Guid."); // } GetOrgUsers(); } catch (Exception ex) { richTextBox1.AppendText("Error occurred while trying to get new organization keys. "); } }
private void AddOrganization_Click(object sender, RoutedEventArgs e) { richTextBox1.Document.Blocks.Clear(); Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); richTextBox1.Foreground = Brushes.Red; try { if (!string.IsNullOrEmpty(passwordBox1.Password.ToString()) && IsGuid(passwordBox1.Password.ToString())) { if (!string.IsNullOrEmpty(OrganizationtextBox1.Text.ToString())) { if (!string.IsNullOrEmpty(GeneratedkeytextBox1.Text.ToString())) { Request.Organization.IsEnabled = true; Request.AdminSecurityKey = new Guid(passwordBox1.Password); Request.Organization.Organization = OrganizationtextBox1.Text; //Request.Organization.OrganizationKey = Cryptography.Encrypt(this.GeneratedkeytextBox1.Text); Request.Organization.OrganizationKey = this.GeneratedkeytextBox1.Text.ToString(); // Epi.Web.Common.Message.OrganizationResponse Result = client.SetOrganization(Request); var Organizationtext = OrganizationtextBox1.Text.ToString(); var Generatedkey = GeneratedkeytextBox1.Text.ToString(); richTextBox1.Document.Blocks.Clear(); OrganizationtextBox1.Clear(); GeneratedkeytextBox1.Clear(); int ServiceVersion = ServiceClient.GetServiceVersion(); if (ServiceVersion == 1) { SurveyManagerService.ManagerServiceClient Client = ServiceClient.GetClient(); Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request); if (Result.Message.ToString().Contains("Successfully")) { Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false); this.NavigationService.Navigate(Page_AddUser); richTextBox1.Foreground = Brushes.Green; richTextBox1.AppendText(Result.Message.ToString()); } else { richTextBox1.Foreground = Brushes.Red; richTextBox1.AppendText(Result.Message.ToString()); } } else if (ServiceVersion == 2) { SurveyManagerServiceV2.ManagerServiceV2Client Client = ServiceClient.GetClientV2(); Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request); if (Result.Message.ToString().Contains("Successfully")) { Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false); this.NavigationService.Navigate(Page_AddUser); richTextBox1.Foreground = Brushes.Green; richTextBox1.AppendText(Result.Message.ToString()); } else { richTextBox1.Foreground = Brushes.Red; richTextBox1.AppendText(Result.Message.ToString()); } } else if (ServiceVersion == 3) { SurveyManagerServiceV3.ManagerServiceV3Client Client = ServiceClient.GetClientV3(); Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request); if (Result.Message.ToString().Contains("Successfully")) { Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false); this.NavigationService.Navigate(Page_AddUser); richTextBox1.Foreground = Brushes.Green; richTextBox1.AppendText(Result.Message.ToString()); } else { richTextBox1.Foreground = Brushes.Red; richTextBox1.AppendText(Result.Message.ToString()); } } else if (ServiceVersion == 4) { SurveyManagerServiceV4.ManagerServiceV4Client Client = ServiceClient.GetClientV4(); Epi.Web.Common.Message.OrganizationResponse Result = Client.SetOrganization(Request); if (Result.Message.ToString().Contains("Successfully")) { Page_AddUser Page_AddUser = new Page_AddUser(new Guid(Generatedkey), new Guid(passwordBox1.Password), Organizationtext, "", false); this.NavigationService.Navigate(Page_AddUser); richTextBox1.Foreground = Brushes.Green; richTextBox1.AppendText(Result.Message.ToString()); } else { richTextBox1.Foreground = Brushes.Red; richTextBox1.AppendText(Result.Message.ToString()); } } } else { richTextBox1.AppendText("Please generate organization key."); } } else { richTextBox1.AppendText("Organization Name is required."); } } else { richTextBox1.AppendText("Admin key is required and Should be a Guid."); } } catch (Exception ex) { richTextBox1.AppendText("Error occurred while trying to add new organization key. Please try again. "); } }