private void AddOrganization_Click(object sender, RoutedEventArgs e)
        {
            MessagerichTextBox1.Document.Blocks.Clear();
            EWEManagerService.EWEManagerServiceClient        client  = ServiceClient.GetClient();
            Epi.Web.Enter.Common.Message.OrganizationRequest Request = new Epi.Web.Enter.Common.Message.OrganizationRequest();
            MessagerichTextBox1.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.Enter.Common.Message.OrganizationResponse Result = client.SetOrganization(Request);
                            MessagerichTextBox1.Document.Blocks.Clear();
                            OrganizationtextBox1.Clear();
                            GeneratedkeytextBox1.Clear();
                            if (Result.Message.ToString().Contains("Successfully"))
                            {
                                MessagerichTextBox1.Foreground = Brushes.Green;
                            }
                            MessagerichTextBox1.AppendText(Result.Message.ToString());
                        }
                        else
                        {
                            MessagerichTextBox1.AppendText("Please generate organization key.");
                        }
                    }
                    else
                    {
                        MessagerichTextBox1.AppendText("Organization Name is required.");
                    }
                }
                else
                {
                    MessagerichTextBox1.AppendText("Admin pass  is required and Should be a Guid.");
                }
            }
            catch (Exception ex)
            {
                MessagerichTextBox1.AppendText("Error occurred while trying to add new organization key. Please  try again. ");
            }
        }
Beispiel #2
0
        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. ");
            }
        }