private void toolStripPublishToWebEnter_Click(object sender, EventArgs e) { DataTable table = mediator.Project.Metadata.GetPublishedViewKeys(this.projectExplorer.CurrentView.Id); DataRow ViewRow = table.Rows[0]; // this.OrganizationKey = this.projectExplorer.CurrentView.EWEOrganizationKey; this.EWEOrganizationKey = ViewRow.ItemArray[2].ToString(); if (string.IsNullOrEmpty(EWEOrganizationKey)) if (RepublishOrgKey != null) EWEOrganizationKey = RepublishOrgKey; Template template = new Template(this.mediator); string InvalidForPublishing = ListFieldsNotSupportedForWeb(); View view; if (projectExplorer.CurrentView != null) { view = projectExplorer.CurrentView; } else { view = projectExplorer.SelectedPage.view; } if (InvalidForPublishing.Length > 0) { SupportedFieldTypeDialog dialog = new SupportedFieldTypeDialog(InvalidForPublishing); dialog.ShowDialog(); } else { Configuration config = Configuration.GetNewInstance(); try { if (view.Project.CollectedData.TableExists(view.TableName) == false)//checking if no table is created in Epi7 { CreateViewDataTable(view); } if (ValidateUser() && !iscancel) // Validate User { if (config.Settings.Republish_IsRepbulishable == true) //IsRepbulishable { if (string.IsNullOrWhiteSpace(this.EWEOrganizationKey) && !string.IsNullOrWhiteSpace(view.EWEFormId))//valitate OrgId and FormId { Epi.Core.ServiceClient.EWEServiceClient.IsValidOrganizationKeyEnum IsValidOKey = Epi.Core.ServiceClient.EWEServiceClient.IsValidOrganizationKeyEnum.No; if (string.IsNullOrWhiteSpace(view.EWEFormId)) { IsValidOKey = Epi.Core.ServiceClient.EWEServiceClient.IsValidOrgKey(this.EWEOrganizationKey); } else { IsValidOKey = Epi.Core.ServiceClient.EWEServiceClient.IsValidOrgKey(this.EWEOrganizationKey, view.EWEFormId); } WebEnterPublishDialog dialog = null; WebEnterOptions wso = null; switch (IsValidOKey) { case Epi.Core.ServiceClient.EWEServiceClient.IsValidOrganizationKeyEnum.No: EWEOrgKey NewDialog = new EWEOrgKey(this.CurrentView.EWEFormId, false, "The organization key has been successfully submitted!", "The organization key is required for security purposes before you can republish this survey."); DialogResult result = NewDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { this.EWEOrganizationKey = NewDialog.OrganizationKey; if (!string.IsNullOrWhiteSpace(EWEOrganizationKey)) { SetFormInfo(); dialog = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); dialog.ShowDialog(); } } break; case Epi.Core.ServiceClient.EWEServiceClient.IsValidOrganizationKeyEnum.EndPointNotFound: WebEnterOptions dialog1 = new WebEnterOptions(); DialogResult result1 = dialog1.ShowDialog(); if (result1 == System.Windows.Forms.DialogResult.OK) { EWEOrgKey OrgKeyDialog = new EWEOrgKey(this.CurrentView.EWEFormId, false, "The organization key has been successfully submitted!", "The organization key is required for security purposes before you can republish this survey."); DialogResult result2 = OrgKeyDialog.ShowDialog(); if (result2 == System.Windows.Forms.DialogResult.OK) { this.EWEOrganizationKey = OrgKeyDialog.OrganizationKey; if (!string.IsNullOrWhiteSpace(EWEOrganizationKey)) { SetFormInfo(); dialog = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); dialog.ShowDialog(); } } } break; case Epi.Core.ServiceClient.EWEServiceClient.IsValidOrganizationKeyEnum.GeneralException: WebEnterOptions dialog2 = new WebEnterOptions(); DialogResult result3 = dialog2.ShowDialog(); if (result3 == System.Windows.Forms.DialogResult.OK) { EWEOrgKey OrgKeyDialog = new EWEOrgKey(this.CurrentView.EWEFormId, false, "The organization key has been successfully submitted!", "The organization key is required for security purposes before you can republish this survey."); DialogResult result4 = OrgKeyDialog.ShowDialog(); if (result4 == System.Windows.Forms.DialogResult.OK) { this.EWEOrganizationKey = OrgKeyDialog.OrganizationKey; if (!string.IsNullOrWhiteSpace(EWEOrganizationKey)) { SetFormInfo(); dialog = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); dialog.ShowDialog(); } } } break; case Epi.Core.ServiceClient.EWEServiceClient.IsValidOrganizationKeyEnum.Yes: SetFormInfo(); dialog = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); dialog.ShowDialog(); break; } } else //valitate OrgId and FormId { if (!string.IsNullOrEmpty(this.EWEOrganizationKey)) { WebEnterPublishDialog dialog = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); dialog.ShowDialog(); } else { try { var client = Epi.Core.ServiceClient.EWEServiceClient.GetClient(); EWEManagerService.OrganizationRequest Request = new Epi.EWEManagerService.OrganizationRequest(); //Epi.Web.Common.Message.OrganizationRequest Request = new Epi.Web.Common.Message.OrganizationRequest(); Request.Organization = new EWEManagerService.OrganizationDTO(); var TestService = client.GetOrganization(Request); WebEnterPublishDialog dialog = new WebEnterPublishDialog(null, this.mediator, template.CreateWebEnterTemplate()); DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { this.EWEOrganizationKey = dialog.GetOrgKey; } } catch (Exception ex) { WebEnterOptions dialog2 = new WebEnterOptions(); DialogResult result3 = dialog2.ShowDialog(); if (result3 == System.Windows.Forms.DialogResult.OK) { WebEnterPublishDialog dialog = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { this.EWEOrganizationKey = dialog.GetOrgKey; } } } } } } else // IsRepbulishable { try { SurveyManagerService.ManagerServiceV3Client client = Epi.Core.ServiceClient.ServiceClient.GetClient(); SurveyManagerService.OrganizationRequest Request = new SurveyManagerService.OrganizationRequest(); SurveyManagerService.OrganizationDTO orgDTO = new SurveyManagerService.OrganizationDTO(); Request.Organization = orgDTO; var TestService = client.GetOrganization(Request); WebEnterPublishDialog dialog = new WebEnterPublishDialog(null, this.mediator, template.CreateWebEnterTemplate()); DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { this.EWEOrganizationKey = dialog.GetOrgKey; } } catch (Exception ex) { if (config.Settings.Republish_IsRepbulishable == true) { WebSurveyOptions dialog2 = new WebSurveyOptions(); DialogResult result3 = dialog2.ShowDialog(); if (result3 == System.Windows.Forms.DialogResult.OK) { WebEnterPublishDialog dialog = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { this.EWEOrganizationKey = dialog.GetOrgKey; } } } else { WebEnterPublishDialog dialog = new WebEnterPublishDialog(null, this.mediator, template.CreateWebEnterTemplate()); dialog.ShowDialog(); } } } } /* else if(!iscancel)// Validate User { int ISWindowAuthMode = config.Settings.EWEServiceAuthMode; if (ISWindowAuthMode == 0) { if (LoginInfo.UserID == -1) { UserAuthentication dialog = new UserAuthentication(); DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { dialog.Close(); if (string.IsNullOrEmpty(this.EWEOrganizationKey)) { WebEnterPublishDialog dialog1 = new WebEnterPublishDialog(null, this.mediator, template.CreateWebEnterTemplate()); dialog1.ShowDialog(); } else { WebEnterPublishDialog dialog1 = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); dialog1.ShowDialog(); } } } else { if (string.IsNullOrEmpty(this.EWEOrganizationKey)) { WebEnterPublishDialog dialog1 = new WebEnterPublishDialog(null, this.mediator, template.CreateWebEnterTemplate()); dialog1.ShowDialog(); } else { WebEnterPublishDialog dialog1 = new WebEnterPublishDialog(this.EWEOrganizationKey, this.mediator, template.CreateWebEnterTemplate()); dialog1.ShowDialog(); } } } else { MessageBox.Show("You are not authorized to publish this form to Epi Web Enter system. Please contact system admin for more info."); } }*/ } catch (Exception ex)// not republishable { WebEnterPublishDialog dialog = new WebEnterPublishDialog(null, this.mediator, template.CreateWebEnterTemplate()); dialog.ShowDialog(); } } this.SetPublishMenuItems(view); }
private void UpdateFormMode(bool IsDraftMode) { try { Template template = new Template(this.mediator); var client = Epi.Core.ServiceClient.EWEServiceClient.GetClient(); DataTable table; View RootView = this.mediator.Project.Metadata.GetParentView(this.mediator.ProjectExplorer.CurrentView.Id); if (RootView == null) { table = this.mediator.Project.Metadata.GetPublishedViewKeys(this.mediator.ProjectExplorer.CurrentView.Id); } else { table = this.mediator.Project.Metadata.GetPublishedViewKeys(RootView.Id); } DataRow ViewRow = table.Rows[0]; string WebSurveyId = ViewRow.ItemArray[3].ToString(); string OrganizationKey = ViewRow.ItemArray[2].ToString(); Configuration config = Configuration.GetNewInstance(); Epi.EWEManagerService.SurveyInfoRequest Request = new Epi.EWEManagerService.SurveyInfoRequest(); Epi.EWEManagerService.SurveyInfoResponse Result = new Epi.EWEManagerService.SurveyInfoResponse(); Epi.EWEManagerService.SurveyInfoCriteria Criteria = new EWEManagerService.SurveyInfoCriteria(); // Request.Criteria.ClosingDate = this.CloseDate; Criteria.OrganizationKey = new Guid(OrganizationKey); //Criteria.UserPublishKey = new Guid(this.UserPublishKey); List<string> List = new List<string>(); List.Add(WebSurveyId); Criteria.SurveyIdList = List.ToArray(); Request.Criteria = Criteria; Epi.EWEManagerService.SurveyInfoDTO SurveyInfoDTO = new Epi.EWEManagerService.SurveyInfoDTO(); SurveyInfoDTO.StartDate = DateTime.Now; SurveyInfoDTO.SurveyId = new Guid(WebSurveyId).ToString(); SurveyInfoDTO.SurveyType = 2; SurveyInfoDTO.SurveyName = mediator.Project.Name; SurveyInfoDTO.OrganizationKey = new Guid(OrganizationKey); if (this.mediator.Project.CollectedData.GetDbDriver().ConnectionDescription.ToString().Contains("Microsoft SQL Server:")) { SurveyInfoDTO.IsSqlProject= true; }// Update IsSqlProject to true on change survey mode for Sql project. //SurveyInfoDTO.UserPublishKey = new Guid(this.UserPublishKey); SurveyInfoDTO.XML = template.CreateWebEnterTemplate(); Request.Criteria.SurveyType = 2; if (IsDraftMode) { Request.Action = "Update"; Request.Criteria.IsDraftMode = true; SurveyInfoDTO.IsDraftMode = true; } else { Request.Action = "UpdateMode"; Request.Criteria.IsDraftMode = false; SurveyInfoDTO.IsDraftMode = false; } List<Epi.EWEManagerService.SurveyInfoDTO> DTOList = new List<Epi.EWEManagerService.SurveyInfoDTO>(); DTOList.Add(SurveyInfoDTO); Request.SurveyInfoList = DTOList.ToArray(); Result = client.SetSurveyInfo(Request); if (Result != null && Result.SurveyInfoList.Count() > 0) { //this.UpdateStatus("Survey mode was successfully updated!"); if (IsDraftMode) { MessageBox.Show("Form mode was successfully changed to Staging.", "", MessageBoxButtons.OK); } else { MessageBox.Show("Form mode was successfully changed to Production.", "", MessageBoxButtons.OK); } } } catch (Exception ex) { //this.BeginInvoke(new FinishWithExceptionDelegate(FinishWithException), ex); } }
private void DoQuickPublish(Template template) { var client = Epi.Core.ServiceClient.EWEServiceClient.GetClient(); DataTable table; View RootView = this.mediator.Project.Metadata.GetParentView(this.mediator.ProjectExplorer.CurrentView.Id); if (RootView == null) { table = this.mediator.Project.Metadata.GetPublishedViewKeys(this.mediator.ProjectExplorer.CurrentView.Id); } else { table = this.mediator.Project.Metadata.GetPublishedViewKeys(RootView.Id); } DataRow ViewRow = table.Rows[0]; string WebSurveyId = ViewRow.ItemArray[3].ToString(); string OrganizationKey = ViewRow.ItemArray[2].ToString(); Configuration config = Configuration.GetNewInstance(); Epi.EWEManagerService.SurveyInfoRequest Request = new Epi.EWEManagerService.SurveyInfoRequest(); Epi.EWEManagerService.SurveyInfoResponse Result = new Epi.EWEManagerService.SurveyInfoResponse(); Epi.EWEManagerService.SurveyInfoCriteria Criteria = new EWEManagerService.SurveyInfoCriteria(); // Request.Criteria.ClosingDate = this.CloseDate; Criteria.OrganizationKey = new Guid(OrganizationKey); //Criteria.UserPublishKey = new Guid(this.UserPublishKey); List<string> List = new List<string>(); List.Add(WebSurveyId); Criteria.SurveyIdList = List.ToArray(); Request.Criteria = Criteria; Request.Action = "Update"; Epi.EWEManagerService.SurveyInfoDTO SurveyInfoDTO = new Epi.EWEManagerService.SurveyInfoDTO(); SurveyInfoDTO.StartDate = DateTime.Now; SurveyInfoDTO.SurveyId = new Guid(WebSurveyId).ToString(); SurveyInfoDTO.SurveyType = 2; SurveyInfoDTO.SurveyName = mediator.Project.Name; SurveyInfoDTO.OrganizationKey = new Guid(OrganizationKey); if (this.mediator.Project.CollectedData.GetDbDriver().ConnectionDescription.ToString().Contains("Microsoft SQL Server:")) { SurveyInfoDTO.IsSqlProject = true; }//changed IsSqlProject to true on quick publishing a SQL project //SurveyInfoDTO.UserPublishKey = new Guid(this.UserPublishKey); SurveyInfoDTO.XML = template.CreateWebEnterTemplate(); Request.Criteria.SurveyType = 2; Request.Criteria.IsDraftMode = true; //SurveyInfoDTO.IsDraftMode = this.IsDraftMode; List<Epi.EWEManagerService.SurveyInfoDTO> DTOList = new List<Epi.EWEManagerService.SurveyInfoDTO>(); DTOList.Add(SurveyInfoDTO); Request.SurveyInfoList = DTOList.ToArray(); Result = client.SetSurveyInfo(Request); if (Result != null && Result.SurveyInfoList.Count() > 0) { //this.UpdateStatus("Survey was successfully updated!"); MessageBox.Show("Form was successfully updated.", "", MessageBoxButtons.OK); } }