Exemplo n.º 1
0
        /// <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;
            }
        }
Exemplo n.º 2
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[0];

            btnPublishForm.Enabled = false;

            progressBar.Visible = true;

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

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

               // Epi.Web.Enter.Common.Message.PublishRequest Request = new Epi.Web.Enter.Common.Message.PublishRequest();
            var Request = new Epi.EWEManagerService.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;
            DataTable table;
            View RootView = this.mediater.Project.Metadata.GetParentView(this.mediater.ProjectExplorer.CurrentView.Id);
            if (RootView == null)
                {
                table = this.mediater.Project.Metadata.GetPublishedViewKeys(this.mediater.ProjectExplorer.CurrentView.Id);
                }
            else
                {
                table = this.mediater.Project.Metadata.GetPublishedViewKeys(RootView.Id);
                }

            DataRow ViewRow = table.Rows[0];

            this.currentSurveyInfoDTO.SurveyId = ViewRow.ItemArray[3].ToString();

            this.currentSurveyInfoDTO.OwnerId = LoginInfo.UserID;
            this.currentSurveyInfoDTO.StartDate = DateTime.Now;
            this.currentSurveyInfoDTO.SurveyName = this.mediater.Project.Name;
            this.currentSurveyInfoDTO.DBConnectionString = RemoveUserName(this.mediater.Project.CollectedDataConnectionString);
            if (this.mediater.Project.CollectedData.GetDbDriver().ConnectionDescription.ToString().Contains("Microsoft SQL Server:"))
                {
                this.currentSurveyInfoDTO.IsSqlProject = true;
                }
              Request.SurveyInfo  = this.currentSurveyInfoDTO;

            try
            {
            EWEManagerService.EWEManagerServiceV2Client client = Epi.Core.ServiceClient.EWEServiceClient.GetClient();
              //  Epi.Web.Enter.Common.Message.PublishResponse Result = client.RePublishSurvey(Request);
                //Epi.Web.Enter.Common.Message.PublishResponse Result = client.RePublishSurvey(Request);
               var 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;
                    Importantlabel3.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;
                    Importantlabel3.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;
                    Importantlabel3.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;
        }
Exemplo n.º 3
0
        /// <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;
            }
        }