コード例 #1
0
        /// <summary>
        /// Initiates a single form publishing process
        /// </summary>
        private void DoRePublish()
        {
            txtSurveyName.Enabled = false;
            txtSurveyID.Enabled = false;
            txtOrganization.Enabled = false;
            txtDepartment.Enabled = false;
            txtIntroductionText.Enabled = false;
            txtExitText.Enabled = false;
            dtpSurveyClosingDate.Enabled = false;
            txtOrganizationKey.Enabled = false;
            btnPrevious.Enabled = false;
            txtStatus.Clear();
            txtURL.Clear();
            this.tabPublishWebForm.SelectedTab = this.tabPublishWebForm.TabPages[2];

            btnPublishForm.Enabled = false;

            progressBar.Visible = true;

            //stopwatch = new Stopwatch();
            //stopwatch.Start();

            //SurveyManagerService.ManagerServiceClient client = new SurveyManagerService.ManagerServiceClient();

            Epi.Web.Common.Message.PublishRequest Request = new Epi.Web.Common.Message.PublishRequest();
            Request.Action = "Update";

            //this.currentSurveyInfoDTO.ClosingDate =  dtpSurveyClosingDate.Value.Date + GetTimeFormat(ClosingTimecomboBox.Text);

            this.currentSurveyInfoDTO.ClosingDate = GetdateTimeFormat(dtpSurveyClosingDate.Value.Date, ClosingTimecomboBox.Text);

            //this.currentSurveyInfoDTO.StartDate = StartDateDatePicker.Value.Date + GetTimeFormat(StartTimecomboBox.Text);
            this.currentSurveyInfoDTO.StartDate = GetdateTimeFormat(StartDateDatePicker.Value.Date, StartTimecomboBox.Text);
            this.currentSurveyInfoDTO.DepartmentName = txtDepartment.Text;

            //this.currentSurveyInfoDTO.DepartmentName = txtDepartment.Text;
            this.currentSurveyInfoDTO.IntroductionText = txtIntroductionText.Text;
            this.currentSurveyInfoDTO.ExitText = txtExitText.Text;
            if (txtOrganization.Text.Equals("Your Organization Name (optional)", StringComparison.OrdinalIgnoreCase))
            {
                this.currentSurveyInfoDTO.OrganizationName = null;
            }
            else
            {
                this.currentSurveyInfoDTO.OrganizationName = txtOrganization.Text;
            }

            if (txtSurveyID.Text.Equals("Your Survey ID (optional)", StringComparison.OrdinalIgnoreCase))
            {
                this.currentSurveyInfoDTO.SurveyNumber = null;
            }
            else
            {
                this.currentSurveyInfoDTO.SurveyNumber = txtSurveyID.Text;
            }

            this.currentSurveyInfoDTO.SurveyName = txtSurveyName.Text;

            this.currentSurveyInfoDTO.OrganizationKey = new Guid(txtOrganizationKey.Text.ToString());
            //this.currentSurveyInfoDTO.UserPublishKey = UserPublishGuid;
            if (!this.IsMetaDataOnly)
            {
                this.currentSurveyInfoDTO.XML = this.template;
            }
            this.currentSurveyInfoDTO.SurveyType = (rdbSingleResponse.Checked) ? 1 : 2;

            Request.SurveyInfo = this.currentSurveyInfoDTO;

            try
            {
                SurveyManagerService.ManagerServiceClient client = MakeView.Utils.ServiceClient.GetClient();
                Epi.Web.Common.Message.PublishResponse Result = client.RePublishSurvey(Request);

                panel2.Visible = true;
                panel3.Visible = true;

                if (Result.PublishInfo.IsPulished)
                {
                    panel3.Visible = true;

                    txtURL.Text = Result.PublishInfo.URL;
                    lblSuccessNotice.Visible = true;
                    lblSuccessNotice2.Visible = true;
                    lblSuccessNotice.Text = "Your survey has been published!  Please copy and paste the following URL and Keys to be used later.";
                    lblSuccessNotice.BackColor = Color.FromArgb(230, 255, 191);
                    lblSuccessNotice2.Visible = true;
                    btnShowLog.Visible = true;
                    this.btnKeyCopy.Enabled = true;
                    this.btnCopyAllURLs.Enabled = true;
                    this.btnDataKeyCopy.Enabled = true;
                    this.btnGo.Enabled = true;
                    this.btnURLCopy.Enabled = true;
                    //txtURL.Text = Result.PublishInfo.URL;
                    txtSurveyKey.Text = this.currentSurveyInfoDTO.SurveyId;

                    txtDataKey.Text = this.currentSurveyInfoDTO.UserPublishKey.ToString();
                    //txtDataKey.Text = txtSurveyKey.Text;
                    txtStatusSummary.Text = SharedStrings.WEBFORM_SUCCESS;
                    // txtURL.Text = Result.PublishInfo.URL;

                    //txtURL.Text =;

                    //txtStatusSummary.Text = SharedStrings.WEBFORM_SUCCESS;
                    //txtStatusSummary.Text = "Your Form has been republished: " + Result.Message;

                    lblSuccessNotice.Visible = true;
                    lblSuccessNotice2.Visible = true;
                    lblSuccessNotice.Text = "Your survey has been published!  Please copy and paste the following URL and Keys to be used later.";
                    lblSuccessNotice.BackColor = Color.FromArgb(230, 255, 191);
                    lblSuccessNotice2.Visible = true;
                    btnPublishForm.Visible = true;
                    btnPublishForm.Enabled = false;
                    btnURLCopy.Enabled = true;
                    btnGo.Enabled = true;
                    btnKeyCopy.Enabled = true;
                    btnDataKeyCopy.Enabled = true;
                    btnShowLog.Enabled = true;
                    btnShowLog.Visible = true;
                    btnCopyAllURLs.Enabled = true;

                    string message = DateTime.Now + ": " + SharedStrings.WEBFORM_SUCCESS + ": " + txtURL.Text; ///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);
                }
                else
                {
                    txtStatusSummary.Text = Result.Message;
                    lblSuccessNotice.Text = "The survey failed to publish. Please check that the organization key is correct and try again.";
                    //panel2.Visible = true;
                    btnShowLog.Visible = false;
                    lblSuccessNotice.BackColor = Color.FromArgb(243, 217, 217);
                    panel3.Visible = true;
                    lblSuccessNotice2.Visible = false;
                    txtOrganizationKey.Enabled = true;
                    btnPublishForm.Enabled = true;
                }

                //this.progressBar.Visible = false;
                //this.btnPublish.Enabled = true;

            }
            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;
            }

            this.progressBar.Visible = false;
            //this.btnPublish.Enabled = true;
        }
コード例 #2
0
        /// <summary>
        /// Initiates a single form publishing process
        /// </summary>
        private void DoPublish()
        {
            UserPublishGuid = Guid.NewGuid();
            txtSurveyName.Enabled = false;
            txtSurveyID.Enabled = false;
            txtOrganization.Enabled = false;
            txtDepartment.Enabled = false;
            txtIntroductionText.Enabled = false;
            txtExitText.Enabled = false;
            dtpSurveyClosingDate.Enabled = false;
            txtOrganizationKey.Enabled = false;
            btnPrevious.Enabled = false;
            txtStatus.Clear();
            txtURL.Clear();
            this.tabPublishWebForm.SelectedTab = this.tabPublishWebForm.TabPages[2];

            btnPublishForm.Enabled = true;
            progressBar.Visible = true;

            stopwatch = new Stopwatch();
            stopwatch.Start();

            Epi.Web.Common.Message.PublishRequest Request = new Epi.Web.Common.Message.PublishRequest();

            if (string.IsNullOrEmpty(ClosingTimecomboBox.Text))
            {
                Request.SurveyInfo.ClosingDate = dtpSurveyClosingDate.Value.Date + new TimeSpan(0, 23, 59, 0);
            }
            else
            {
                Request.SurveyInfo.ClosingDate = GetdateTimeFormat(dtpSurveyClosingDate.Value.Date, ClosingTimecomboBox.Text);
            }

            if (string.IsNullOrEmpty(StartTimecomboBox.Text))
            {
                Request.SurveyInfo.StartDate = StartDateDatePicker.Value.Date;
            }
            else
            {
                Request.SurveyInfo.StartDate = GetdateTimeFormat(StartDateDatePicker.Value.Date, StartTimecomboBox.Text);
            }

            Request.SurveyInfo.DepartmentName = txtDepartment.Text;
            Request.SurveyInfo.IntroductionText = txtIntroductionText.Text;
            Request.SurveyInfo.ExitText = txtExitText.Text;

            Request.SurveyInfo.SurveyName = txtSurveyName.Text;

            Request.SurveyInfo.OrganizationKey = new Guid(txtOrganizationKey.Text.ToString());
            Request.SurveyInfo.UserPublishKey = UserPublishGuid;
            Request.SurveyInfo.XML = template;
            Request.SurveyInfo.IsDraftMode = true;
            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.Web.Common.Message.PublishResponse Result = new Epi.Web.Common.Message.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;
            }
        }