private void AfterPublish(Epi.Web.Common.Message.PublishResponse Result) { /* if (Result.PublishInfo.IsPulished) * { * txtURL.Text = Result.PublishInfo.URL; * txtSurveyKey.Text = txtURL.Text.Substring(txtURL.Text.LastIndexOf('/') + 1); * * txtDataKey.Text = UserPublishGuid.ToString(); * //txtDataKey.Text = txtSurveyKey.Text; * txtStatusSummary.Text = SharedStrings.WEBFORM_SUCCESS; * string message = DateTime.Now + ": " + SharedStrings.WEBFORM_SUCCESS + ": " + Result.PublishInfo.URL; * Logger.Log(message); * message = DateTime.Now + ": Survey Key= " + txtSurveyKey.Text; * Logger.Log(message); * message = DateTime.Now + ": Data Key= " + txtDataKey.Text; * Logger.Log(message); * * lblSuccessNotice.Visible = true; * lblSuccessNotice2.Visible = true; * btnPublishForm.Visible = false; * btnPublish.Enabled = true; //OK button * btnURLCopy.Enabled = true; * btnGo.Enabled = true; * btnKeyCopy.Enabled = true; * btnDataKeyCopy.Enabled = true; * btnShowLog.Enabled = true; * btnCopyAllURLs.Enabled = true; * * txtSurveyName.Enabled = true; * txtSurveyID.Enabled = true; * txtOrganization.Enabled = true; * txtDepartment.Enabled = true; * txtIntroductionText.Enabled = true; * txtExitText.Enabled = true; * dtpSurveyClosingDate.Enabled = true; * txtOrganizationKey.Enabled = true; * txtOrganizationKey.Clear(); * btnClear.Enabled = true; * * } * else * { * txtStatusSummary.Text = "The survey failed to publish. Check that the organization key is correct and try again."; * } * txtStatus.AppendText(Environment.NewLine); * * }*/ }
private void SubmitRequestButton_Click(object sender, RoutedEventArgs e) { ServiceResponseTextBox.Document.Blocks.Clear(); this.OpenURLButton.IsEnabled = false; // SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient(); Epi.Web.Common.Message.PublishRequest Request = new Epi.Web.Common.Message.PublishRequest(); if (this.datePicker1.SelectedDate == null) { TimeSpan t = new TimeSpan(10, 0, 0, 0); Request.SurveyInfo.ClosingDate = DateTime.Now + t; } else { Request.SurveyInfo.ClosingDate = (DateTime)this.datePicker1.SelectedDate; } Request.SurveyInfo.DepartmentName = this.DepartmentTextBox.Text; Request.SurveyInfo.IntroductionText = new TextRange(this.IntroductionTextBox.Document.ContentStart, this.IntroductionTextBox.Document.ContentEnd).Text; Request.SurveyInfo.ExitText = new TextRange(this.ExitTextTextBox.Document.ContentStart, this.ExitTextTextBox.Document.ContentEnd).Text; if ((bool)this.IsSingleResponseCheckBox.IsChecked) { Request.SurveyInfo.SurveyType = 1; } else { Request.SurveyInfo.SurveyType = 2; } Request.SurveyInfo.OrganizationName = this.OrganizationTextBox.Text; Request.SurveyInfo.SurveyName = this.SurveyNameTextBox.Text; Request.SurveyInfo.SurveyNumber = this.SurveyNumberTextBox.Text; Request.SurveyInfo.XML = new TextRange(this.TemplateXMLTextBox.Document.ContentStart, this.TemplateXMLTextBox.Document.ContentEnd).Text; //Checking the publish key guid is in correct format if (!IsGuid(txtPublishKey.Text)) { MessageBox.Show("Publish key is not in correct format"); return; } Request.SurveyInfo.UserPublishKey = new Guid(txtPublishKey.Text); //get the Organization key and assign it to SurveyInfoDTO object under PublishRequest string strOrganizationKey = passOrganizationKey.Password.ToString(); if (!IsGuid(strOrganizationKey)) { MessageBox.Show("Organization key is not in correct format"); return; } Guid gOrganizationkey = new Guid(strOrganizationKey); Request.SurveyInfo.OrganizationKey = gOrganizationkey; try { int ServiceVersion = ServiceClient.GetServiceVersion(); if (ServiceVersion == 1) { SurveyManagerService.ManagerServiceClient client = ServiceClient.GetClient(); Epi.Web.Common.Message.PublishResponse Result = client.PublishSurvey(Request); passOrganizationKey.Password = string.Empty; URL = Result.PublishInfo.URL; ServiceResponseTextBox.AppendText("is published: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.IsPulished.ToString()); ServiceResponseTextBox.AppendText("\nURL: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.URL); ServiceResponseTextBox.AppendText("\nStatus Text: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.StatusText); ServiceResponseTextBox.AppendText("\n User Publish Key: "); ServiceResponseTextBox.AppendText(UserPublishKey.ToString()); this.OpenURLButton.IsEnabled = Result.PublishInfo.IsPulished; } else if (ServiceVersion == 2) { SurveyManagerServiceV2.ManagerServiceV2Client client = ServiceClient.GetClientV2(); Epi.Web.Common.Message.PublishResponse Result = client.PublishSurvey(Request); passOrganizationKey.Password = string.Empty; URL = Result.PublishInfo.URL; ServiceResponseTextBox.AppendText("is published: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.IsPulished.ToString()); ServiceResponseTextBox.AppendText("\nURL: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.URL); ServiceResponseTextBox.AppendText("\nStatus Text: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.StatusText); ServiceResponseTextBox.AppendText("\n User Publish Key: "); ServiceResponseTextBox.AppendText(UserPublishKey.ToString()); this.OpenURLButton.IsEnabled = Result.PublishInfo.IsPulished; } else if (ServiceVersion == 3) { SurveyManagerServiceV3.ManagerServiceV3Client client = ServiceClient.GetClientV3(); Epi.Web.Common.Message.PublishResponse Result = client.PublishSurvey(Request); passOrganizationKey.Password = string.Empty; URL = Result.PublishInfo.URL; ServiceResponseTextBox.AppendText("is published: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.IsPulished.ToString()); ServiceResponseTextBox.AppendText("\nURL: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.URL); ServiceResponseTextBox.AppendText("\nStatus Text: "); ServiceResponseTextBox.AppendText(Result.PublishInfo.StatusText); ServiceResponseTextBox.AppendText("\n User Publish Key: "); ServiceResponseTextBox.AppendText(UserPublishKey.ToString()); this.OpenURLButton.IsEnabled = Result.PublishInfo.IsPulished; } } catch (FaultException<CustomFaultException> cfe) { ServiceResponseTextBox.AppendText("FaultException<CustomFaultException>:\n"); ServiceResponseTextBox.AppendText(cfe.ToString()); } catch (FaultException fe) { ServiceResponseTextBox.AppendText("FaultException:\n"); ServiceResponseTextBox.AppendText(fe.ToString()); } catch (CommunicationException ce) { ServiceResponseTextBox.AppendText("CommunicationException:\n"); ServiceResponseTextBox.AppendText(ce.ToString()); } catch (TimeoutException te) { ServiceResponseTextBox.AppendText("TimeoutException:\n"); ServiceResponseTextBox.AppendText(te.ToString()); } catch (Exception ex) { ServiceResponseTextBox.AppendText("Exception:\n"); ServiceResponseTextBox.AppendText(ex.ToString()); } }