/// <summary> /// Initiates a single form publishing process /// </summary> private void DoPublish() { UserPublishGuid = Guid.NewGuid(); txtOrganizationKey.Enabled = false; txtStatus.Clear(); txtURL.Clear(); TimeSpan tClose = new TimeSpan(0, 23, 59, 59); btnPublishForm.Enabled = true; progressBar.Visible = true; stopwatch = new Stopwatch(); stopwatch.Start(); EWEManagerService.PublishRequest Request = new Epi.EWEManagerService.PublishRequest(); EWEManagerService.SurveyInfoDTO SurveyInfoDTO = new EWEManagerService.SurveyInfoDTO(); Request.SurveyInfo = SurveyInfoDTO; Request.SurveyInfo.DBConnectionString = RemoveUserName(this.mediater.Project.CollectedDataConnectionString); if (this.mediater.Project.CollectedData.GetDbDriver().ConnectionDescription.ToString().Contains("Microsoft SQL Server:")) { Request.SurveyInfo.IsSqlProject = true; } Request.SurveyInfo.OrganizationKey = new Guid(txtOrganizationKey.Text.ToString()); Request.SurveyInfo.UserPublishKey = UserPublishGuid; Request.SurveyInfo.XML = template; Request.SurveyInfo.IsDraftMode = true; Request.SurveyInfo.SurveyType = 2; Request.SurveyInfo.SurveyName = this.mediater.Project.Name; Request.SurveyInfo.ViewId = this.mediater.ProjectExplorer.CurrentView.Id; Request.SurveyInfo.OwnerId = LoginInfo.UserID; Request.SurveyInfo.StartDate = DateTime.Now; Configuration config = Configuration.GetNewInstance(); try { if (config.Settings.Republish_IsRepbulishable) { Request.SurveyInfo.IsDraftMode = true; } else { Request.SurveyInfo.IsDraftMode = false; } } catch (Exception ex) { Request.SurveyInfo.IsDraftMode = false; } try { Epi.EWEManagerService.PublishResponse Result = new Epi.EWEManagerService.PublishResponse(); lock (syncLock) { this.Cursor = Cursors.WaitCursor; publishWorker = new BackgroundWorker(); publishWorker.WorkerSupportsCancellation = true; publishWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(worker_DoWork); publishWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_WorkerCompleted); object[] args = new object[2]; args[0] = Request; args[1] = Result; publishWorker.RunWorkerAsync(args); } if (publishWorker.WorkerSupportsCancellation) { publishWorker.CancelAsync(); } } catch (Exception ex) { txtStatusSummary.AppendText("An error occurred while trying to publish the survey."); txtStatus.AppendText(ex.ToString()); btnDetails.Visible = true; this.progressBar.Visible = false; this.Cursor = Cursors.Default; } }
/// <summary> /// Initiates a single form publishing process /// </summary> private void DoPublish() { UserPublishGuid = Guid.NewGuid(); txtOrganizationKey.Enabled = false; // btnPrevious.Enabled = false; txtStatus.Clear(); txtURL.Clear(); // this.tabPublishWebForm.SelectedTab = this.tabPublishWebForm.TabPages[2]; TimeSpan tClose = new TimeSpan(0, 23, 59, 59); btnPublishForm.Enabled = true; progressBar.Visible = true; stopwatch = new Stopwatch(); stopwatch.Start(); EWEManagerService.PublishRequest Request = new Epi.EWEManagerService.PublishRequest(); EWEManagerService.SurveyInfoDTO SurveyInfoDTO = new EWEManagerService.SurveyInfoDTO(); Request.SurveyInfo = SurveyInfoDTO; //Request.SurveyInfo.ClosingDate = dtpSurveyClosingDate.Value.Date + t; //if (string.IsNullOrEmpty(ClosingTimecomboBox.Text)) // { // Request.SurveyInfo.ClosingDate = dtpSurveyClosingDate.Value.Date + GetTimeFormat(tClose.ToString()); // } //else { // // Request.SurveyInfo.ClosingDate = dtpSurveyClosingDate.Value.Date + GetTimeFormat(ClosingTimecomboBox.Text); // Request.SurveyInfo.ClosingDate = GetdateTimeFormat(dtpSurveyClosingDate.Value.Date, ClosingTimecomboBox.Text); // } Request.SurveyInfo.DBConnectionString = RemoveUserName(this.mediater.Project.CollectedDataConnectionString); if (this.mediater.Project.CollectedData.GetDbDriver().ConnectionDescription.ToString().Contains("Microsoft SQL Server:")) { Request.SurveyInfo.IsSqlProject = true; } Request.SurveyInfo.OrganizationKey = new Guid(txtOrganizationKey.Text.ToString()); Request.SurveyInfo.UserPublishKey = UserPublishGuid; Request.SurveyInfo.XML = template; Request.SurveyInfo.IsDraftMode = true; Request.SurveyInfo.SurveyType = 2; Request.SurveyInfo.SurveyName = this.mediater.Project.Name; Request.SurveyInfo.ViewId = this.mediater.ProjectExplorer.CurrentView.Id; Request.SurveyInfo.OwnerId = LoginInfo.UserID; Request.SurveyInfo.StartDate = DateTime.Now; //Request.SurveyInfo.SurveyType = (rdbSingleResponse.Checked) ? 1 : 2; //if (txtOrganization.Text.Equals("Your Organization Name (optional)", StringComparison.OrdinalIgnoreCase)) //{ // Request.SurveyInfo.OrganizationName = null; //} //else //{ // Request.SurveyInfo.OrganizationName = txtOrganization.Text; //} //if (txtSurveyID.Text.Equals("Your Survey ID (optional)", StringComparison.OrdinalIgnoreCase)) //{ // Request.SurveyInfo.SurveyNumber = null; //} //else //{ // Request.SurveyInfo.SurveyNumber = txtSurveyID.Text; //} Configuration config = Configuration.GetNewInstance(); try { if (config.Settings.Republish_IsRepbulishable) { Request.SurveyInfo.IsDraftMode = true; } else { Request.SurveyInfo.IsDraftMode = false; } } catch (Exception ex) { Request.SurveyInfo.IsDraftMode = false; } try { Epi.EWEManagerService.PublishResponse Result = new Epi.EWEManagerService.PublishResponse(); lock (syncLock) { this.Cursor = Cursors.WaitCursor; publishWorker = new BackgroundWorker(); publishWorker.WorkerSupportsCancellation = true; publishWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(worker_DoWork); publishWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_WorkerCompleted); object[] args = new object[2]; args[0] = Request; args[1] = Result; publishWorker.RunWorkerAsync(args); } if (publishWorker.WorkerSupportsCancellation) { publishWorker.CancelAsync(); } } catch (Exception ex) { txtStatusSummary.AppendText("An error occurred while trying to publish the survey."); txtStatus.AppendText(ex.ToString()); btnDetails.Visible = true; this.progressBar.Visible = false; this.Cursor = Cursors.Default; } }