/// <summary> /// Parses XML from the web survey /// </summary> /// <param name="result">The parsed results in dictionary format</param> private Dictionary<string, Dictionary<string, WebFieldData>> ParseXML(SurveyManagerService.SurveyAnswerResponse pSurveyAnswer) { Dictionary<string, Dictionary<string, WebFieldData>> result = new Dictionary<string, Dictionary<string, WebFieldData>>(StringComparer.OrdinalIgnoreCase); // SetFilterProperties(DownLoadType); foreach (SurveyManagerService.SurveyAnswerDTO surveyAnswer in pSurveyAnswer.SurveyResponseList) { if (SurveyStatus == 0) { if ((surveyAnswer.IsDraftMode == IsDraftMode)) { AddSurveyAnswerResult(result, surveyAnswer); } } else { if ((surveyAnswer.IsDraftMode == IsDraftMode) && (surveyAnswer.Status == SurveyStatus)) { AddSurveyAnswerResult(result, surveyAnswer); } } } return result; }
private void AddSurveyAnswerResult(Dictionary<string, Dictionary<string, WebFieldData>> result, SurveyManagerService.SurveyAnswerDTO surveyAnswer) { result.Add(surveyAnswer.ResponseId, new Dictionary<string, WebFieldData>(StringComparer.OrdinalIgnoreCase)); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(surveyAnswer.XML); foreach (XmlNode docElement in doc.SelectNodes("//ResponseDetail")) { string fieldName = docElement.Attributes.GetNamedItem("QuestionName").Value; object fieldValue = FormatWebFieldData(fieldName, docElement.InnerText); WebFieldData wfData = new WebFieldData(); wfData.RecordGUID = surveyAnswer.ResponseId; wfData.FieldName = fieldName; wfData.FieldValue = fieldValue; wfData.Status = surveyAnswer.Status; if (result[surveyAnswer.ResponseId].Keys.Contains(wfData.FieldName) == false) { result[surveyAnswer.ResponseId].Add(wfData.FieldName, wfData); } } }
/// <summary> /// Initiates a full import on a single form /// </summary> private void DoImport(SurveyManagerService.SurveyAnswerRequest Request) { { try { stopwatch = new Stopwatch(); stopwatch.Start(); int recordCount = 0; // Result.SurveyResponseList.Count; // sourceView.GetRecordCount(); int gridRowCount = 0; // Grids not supported //foreach (GridField gridField in sourceView.Fields.GridFields) //{ // IDataReader reader = sourceProjectDataDriver.GetTableDataReader(gridField.TableName); // while (reader.Read()) // { // gridRowCount++; // } //} progressBar.Maximum = recordCount * (destinationView.Pages.Count + 1); progressBar.Maximum = progressBar.Maximum + gridRowCount; string importTypeDescription = "Records with matching ID fields will be updated and unmatched records will be appended."; //if (cmbImportType.SelectedIndex == 0) //{ // update = true; // append = true; //} //else if (cmbImportType.SelectedIndex == 1) //{ // update = true; // append = false; // importTypeDescription = "Records with matching ID fields will be updated. Unmatched records will be ignored."; //} //else //{ // update = false; // append = true; // importTypeDescription = "Records with no matching ID fields will be appended. Records with matching ID fields will be ignored."; //} update = false; append = true; importTypeDescription = "Records with no matching ID fields will be appended. Records with matching ID fields will be ignored."; // DownLoadType = cmbImportType.SelectedIndex; AddStatusMessage("Import initiated for form " + textProject.Text + ". " + importTypeDescription); btnCancel.Enabled = false; btnOK.Enabled = false; //cmbImportType.Enabled = false; textProject.Enabled = false; textData.Enabled = false; textOrganization.Enabled = false; if (importWorker.WorkerSupportsCancellation) { importWorker.CancelAsync(); } this.Cursor = Cursors.WaitCursor; importWorker = new BackgroundWorker(); importWorker.WorkerSupportsCancellation = true; importWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(worker_DoWork); importWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_WorkerCompleted); importWorker.RunWorkerAsync(Request); //} } catch (System.ServiceModel.CommunicationException ex) { this.BeginInvoke(new SetStatusDelegate(AddErrorStatusMessage), "Couldn't properly communicate with web service. Import halted."); if (stopwatch != null) { stopwatch.Stop(); } btnCancel.Enabled = true; btnOK.Enabled = true; //cmbImportType.Enabled = true; textProject.Enabled = true; textData.Enabled = true; textOrganization.Enabled = true; progressBar.Visible = false; importFinished = true; this.Cursor = Cursors.Default; } catch (Exception ex) { this.BeginInvoke(new SetStatusDelegate(AddErrorStatusMessage), "Import from web failed."); if (stopwatch != null) { stopwatch.Stop(); } btnCancel.Enabled = true; btnOK.Enabled = true; //cmbImportType.Enabled = true; textProject.Enabled = true; progressBar.Visible = false; importFinished = true; this.Cursor = Cursors.Default; } } }
//private void AfterPublish(Epi.Web.Common.Message.PublishResponse Result) private void AfterPublish(SurveyManagerService.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; 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; txtSurveyName.Enabled = true; txtSurveyID.Enabled = true; txtOrganization.Enabled = true; txtDepartment.Enabled = true; txtIntroductionText.Enabled = true; txtExitText.Enabled = true; dtpSurveyClosingDate.Enabled = true; txtOrganizationKey.Enabled = false; //txtOrganizationKey.Clear(); btnPrevious.Enabled = false; //btnNext.Enabled = false; panel3.Visible = true; panel2.Visible = true; if (this.isRepublishableConfig) { // save survey id to metadata //this.viewma.metad this.view.WebSurveyId = txtSurveyKey.Text; this.view.SaveToDb(); this.view.CheckCodeBefore = txtOrganizationKey.Text.ToString(); } } else { txtStatusSummary.Text = "The survey failed to publish. Please check that the organization key is correct and try again."; lblSuccessNotice.Text = "The survey failed to publish. Please check that the organization key is correct and try again."; lblSuccessNotice.BackColor = Color.FromArgb(243, 217, 217); panel2.Visible = false; panel3.Visible = true; btnPublishForm.Enabled = true; btnPublishForm.Visible = true; txtOrganizationKey.Enabled = true; btnPublishForm.Visible = true; btnShowLog.Visible = false; lblSuccessNotice2.Visible = false; } txtStatus.AppendText(Environment.NewLine); // panel2.Visible = false; panel3.Visible = true; }