Ejemplo n.º 1
0
        /// <summary>
        /// Creates attributes for the root element
        /// </summary>
        /// <param name="xmlDataPackage">The Xml Data Package document</param>
        /// <param name="root">The root element of the document</param>
        protected void CreateRootAttributes(XmlDocument xmlDataPackage, XmlElement root)
        {
            #region Input Validation
            if (xmlDataPackage == null)
            {
                throw new ArgumentNullException("xmlDataPackage");
            }
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }
            #endregion // Input Validation

            Epi.ApplicationIdentity appId = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);

            // Append timestamp in UTC so that people sending packages across time zones don't need to worry about what zone it was packaged in.
            DateTime dt = DateTime.UtcNow;
            string   dateDisplayValue = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:s}", dt);

            XmlAttribute version = xmlDataPackage.CreateAttribute("Version"); // The version of Epi Info 7 that was used to create it
            XmlAttribute created = xmlDataPackage.CreateAttribute("Created"); // The date/time the package creation started
            XmlAttribute pakName = xmlDataPackage.CreateAttribute("Name");    // The name of the package (should mirror the file name but without a filename-based timestamp)
            XmlAttribute guidStr = xmlDataPackage.CreateAttribute("Id");      // Unique ID value for the package; may be useful to avoid importing the same package twice depending on how system designers have set up their import mechanisms

            version.Value = appId.Version;
            created.Value = dateDisplayValue;
            pakName.Value = PackageName;
            guidStr.Value = System.Guid.NewGuid().ToString();

            root.Attributes.Append(version);
            root.Attributes.Append(created);
            root.Attributes.Append(pakName);
            root.Attributes.Append(guidStr);
        }
        public DashboardProperties(DashboardHelper dashboardHelper)
        {
            #region Input Validation
            if (dashboardHelper == null) { throw new ArgumentNullException("dashboardHelper"); }
            #endregion // Input Validation

            InitializeComponent();
            this.DashboardHelper = dashboardHelper;

            if (DashboardHelper.IsUsingEpiProject)
            {
                txtProjectPath.Text = dashboardHelper.View.Project.FilePath;

                if (System.IO.File.Exists(txtProjectPath.Text))
                {
                    cmbFormName.Items.Clear();
                    Project project = new Project(txtProjectPath.Text);
                    foreach (View view in project.Views)
                    {
                        cmbFormName.Items.Add(view.Name);
                    }
                }

                cmbFormName.Text = dashboardHelper.View.Name;
            }
            else
            {
                if (!string.IsNullOrEmpty(dashboardHelper.CustomQuery))
                {
                    SqlQuery = DashboardHelper.CustomQuery;
                }
            }

            tblockRows.Text = dashboardHelper.DataSet.Tables[0].Rows.Count.ToString() + " unfiltered rows";
            tblockColumns.Text = dashboardHelper.DataSet.Tables[0].Columns.Count.ToString() + " columns";
            tblockCacheDateTime.Text = "Data last cached at " + dashboardHelper.LastCacheTime.ToShortDateString() + " " + dashboardHelper.LastCacheTime.ToShortTimeString();
            tblockCacheTimeElapsed.Text = "Took " + dashboardHelper.TimeToCache + " to locally cache data";

            Epi.ApplicationIdentity appId = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);
            tblockCurrentEpiVersion.Text = "Epi Info " + appId.Version;

            lbxRelatedDataSources.Items.Clear();
            if (dashboardHelper.ConnectionsForRelate.Count > 0)
            {
                // Related Data
                foreach (RelatedConnection rConn in dashboardHelper.ConnectionsForRelate)
                {
                    lbxRelatedDataSources.Items.Add(rConn.db.ConnectionString);
                }
            }
        }
        public ChoroplethProperties(EpiDashboard.Mapping.StandaloneMapControl mapControl, ESRI.ArcGIS.Client.Map myMap)
        {
            InitializeComponent();
            this.mapControl = mapControl;
            this.myMap = myMap;
            ////this.DashboardHelper = dashboardHelper;

            //if (DashboardHelper.IsUsingEpiProject)
            //{
            //    //txtProjectPath.Text = dashboardHelper.View.Project.FilePath;

            //    if (System.IO.File.Exists(txtProjectPath.Text))
            //    {
            //        cmbFormName.Items.Clear();
            //        Project project = new Project(txtProjectPath.Text);
            //        foreach (View view in project.Views)
            //        {
            //            cmbFormName.Items.Add(view.Name);
            //        }
            //    }

            //    //cmbFormName.Text = dashboardHelper.View.Name;
            //}
            //else
            //{
            //    //if (!string.IsNullOrEmpty(dashboardHelper.CustomQuery))
            //    //{
            //    //    SqlQuery = DashboardHelper.CustomQuery;
            //    //}
            //}

            //tblockRows.Text = dashboardHelper.DataSet.Tables[0].Rows.Count.ToString() + " unfiltered rows";
            //tblockColumns.Text = dashboardHelper.DataSet.Tables[0].Columns.Count.ToString() + " columns";
            //tblockCacheDateTime.Text = "Data last cached at " + dashboardHelper.LastCacheTime.ToShortDateString() + " " + dashboardHelper.LastCacheTime.ToShortTimeString();
            //tblockCacheTimeElapsed.Text = "Took " + dashboardHelper.TimeToCache + " to locally cache data";

            Epi.ApplicationIdentity appId = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);
            tblockCurrentEpiVersion.Text = "Epi Info " + appId.Version;

            //lbxRelatedDataSources.Items.Clear();
            //if (dashboardHelper.ConnectionsForRelate.Count > 0)
            //{
            //    // Related Data
            //    foreach (RelatedConnection rConn in dashboardHelper.ConnectionsForRelate)
            //    {
            //        lbxRelatedDataSources.Items.Add(rConn.db.ConnectionString);
            //    }
            //}
        }
Ejemplo n.º 4
0
        public StatCalcMenu()
        {
            InitializeComponent();
            Epi.ApplicationIdentity appId = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);
            this.tsslLocale.Text  = Thread.CurrentThread.CurrentUICulture.Name;
            this.tsslVersion.Text = appId.Version;

            #region Translation

            txtPopulationSurvey.Text   = StatCalcSharedStrings.STATCALC_POPULATION_SURVEY;
            txtCohortorCross.Text      = StatCalcSharedStrings.STATCALC_COHORT_CROSS;
            unmatchedCaseControl.Text  = StatCalcSharedStrings.STATCALC_UNMATCHED_CASE;
            txtChiSquare.Text          = StatCalcSharedStrings.STATCALC_CHI_SQUARE;
            txtTables22N.Text          = StatCalcSharedStrings.STATCALC_TABLES_22N;
            txtPoisson.Text            = StatCalcSharedStrings.STATCALC_POISSON_RARE;
            txtPopulationBinomial.Text = StatCalcSharedStrings.STATCALC_POPULATION_BINOMIAL;
            txtMatchedPairCase.Text    = StatCalcSharedStrings.STATCALC_MATCHED_PAIR_CASE;
            txtLanguage.Text           = StatCalcSharedStrings.STATCALC_LANGUAGE;
            txtVersion.Text            = StatCalcSharedStrings.STATCALC_VERSION;
            #endregion Translation
        }
Ejemplo n.º 5
0
        public DashboardProperties(DashboardHelper dashboardHelper)
        {
            #region Input Validation
            if (dashboardHelper == null)
            {
                throw new ArgumentNullException("dashboardHelper");
            }
            #endregion // Input Validation

            InitializeComponent();
            this.DashboardHelper = dashboardHelper;

            DataContext = this;

            if (DashboardHelper.IsUsingEpiProject)
            {
                txtProjectPath.Text = dashboardHelper.View.Project.FilePath;

                if (System.IO.File.Exists(txtProjectPath.Text))
                {
                    cmbFormName.Items.Clear();
                    Project project = new Project(txtProjectPath.Text);
                    foreach (View view in project.Views)
                    {
                        cmbFormName.Items.Add(view.Name);
                    }
                }

                cmbFormName.Text = dashboardHelper.View.Name;

                panelDataSourceProject.Visibility = System.Windows.Visibility.Visible;
                panelDataSourceOther.Visibility   = System.Windows.Visibility.Collapsed;
                panelDataSourceSql.Visibility     = System.Windows.Visibility.Collapsed;
                panelAdvancedSQLQuery.Visibility  = System.Windows.Visibility.Collapsed;
            }
            else
            {
                if (dashboardHelper.Database.ToString().Contains("SqlDatabase"))
                {
                    txtSQLConnectionString.Text = DashboardHelper.Database.ConnectionString;

                    Epi.Data.IDbDriver database   = Epi.Data.DBReadExecute.GetDataDriver(txtSQLConnectionString.Text);
                    List <string>      tableNames = database.GetTableNames();
                    cmbSqlTable.Items.Clear();
                    cmbSqlTable.Items.Add("");

                    foreach (string tableName in tableNames)
                    {
                        cmbSqlTable.Items.Add(tableName);
                    }

                    cmbSqlTable.SelectedItem = DashboardHelper.TableName;

                    if (!String.IsNullOrEmpty(dashboardHelper.CustomQuery))
                    {
                        CustomQuery = DashboardHelper.CustomQuery;
                    }

                    panelDataSourceProject.Visibility = System.Windows.Visibility.Collapsed;
                    panelDataSourceOther.Visibility   = System.Windows.Visibility.Collapsed;
                    panelDataSourceSql.Visibility     = System.Windows.Visibility.Visible;
                    panelAdvancedSQLQuery.Visibility  = System.Windows.Visibility.Visible;
                }
                else
                {
                    txtStandalonePath.Text = DashboardHelper.Database.DataSource;

                    Epi.Data.IDbDriver database   = Epi.Data.DBReadExecute.GetDataDriver(txtStandalonePath.Text);
                    List <string>      tableNames = database.GetTableNames();
                    cmbStandaloneFormName.Items.Clear();
                    cmbStandaloneFormName.Items.Add("");
                    foreach (string tableName in tableNames)
                    {
                        cmbStandaloneFormName.Items.Add(tableName);
                    }

                    cmbStandaloneFormName.SelectedItem = DashboardHelper.TableName;

                    if (!String.IsNullOrEmpty(dashboardHelper.CustomQuery))
                    {
                        CustomQuery = DashboardHelper.CustomQuery;
                    }

                    panelDataSourceProject.Visibility = System.Windows.Visibility.Collapsed;
                    panelDataSourceOther.Visibility   = System.Windows.Visibility.Visible;
                    panelDataSourceSql.Visibility     = System.Windows.Visibility.Collapsed;
                    panelAdvancedSQLQuery.Visibility  = System.Windows.Visibility.Visible;
                }
            }

            tblockRows.Text             = dashboardHelper.DataSet.Tables[0].Rows.Count.ToString() + DashboardSharedStrings.GADGET_INFO_UNFILTERED_ROWS;
            tblockColumns.Text          = dashboardHelper.DataSet.Tables[0].Columns.Count.ToString() + DashboardSharedStrings.CANVAS_COLUMNS;
            tblockCacheDateTime.Text    = DashboardSharedStrings.CANVAS_DATA_LAST_CACHED + dashboardHelper.LastCacheTime.ToShortDateString() + " " + dashboardHelper.LastCacheTime.ToShortTimeString();
            tblockCacheTimeElapsed.Text = DashboardSharedStrings.CANVAS_INFO_TOOK + dashboardHelper.TimeToCache + DashboardSharedStrings.CANVAS_INFO_LOCALLY_CACHE_DATA;

            Epi.ApplicationIdentity appId = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);
            tblockCurrentEpiVersion.Text = "Epi Info " + appId.Version;

            lbxRelatedDataSources.Items.Clear();
            if (dashboardHelper.ConnectionsForRelate.Count > 0)
            {
                // Related Data
                foreach (RelatedConnection rConn in dashboardHelper.ConnectionsForRelate)
                {
                    lbxRelatedDataSources.Items.Add(rConn.db.ConnectionString);
                }
            }


            #region Translation

            lblConfigExpandedTitle.Content = DashboardSharedStrings.CMENU_PROPERTIES;
            tbtnDataSource.Title           = DashboardSharedStrings.GADGET_DATA_SOURCE;
            tbtnDataSource.Description     = DashboardSharedStrings.CANVASPROPERTIES_TABDESC_DATASOURCE;
            tbtnHTML.Title       = DashboardSharedStrings.GADGET_TABBUTTON_DISPLAY;
            tbtnHTML.Description = DashboardSharedStrings.CANVASPROPERTIES_DESC_HTMLOUTPUT;
            //tbtnCharts.Title = DashboardSharedStrings.GADGET_TAB_COLORS_STYLES;
            //tbtnCharts.Description = DashboardSharedStrings.CANVASPROPERTIES_DESC_CHARTS;
            tbtnInfo.Title       = DashboardSharedStrings.CANVASPROPERTIES_TITLE_INFORMATION;
            tbtnInfo.Description = DashboardSharedStrings.CANVASPROPERTIES_DESC_INFORMATION;

            //Data Source Panel
            tblockPanelDataSource.Content = DashboardSharedStrings.GADGET_DATA_SOURCE;
            tblockEpiInfoPro.Content      = DashboardSharedStrings.CANVAS_EPIINFOPRO;
            btnBrowse.Content             = DashboardSharedStrings.BUTTON_BROWSE;
            tblockForm.Content            = DashboardSharedStrings.CANVAS_FORM;
            lblRelatedDataSources.Content = DashboardSharedStrings.RALATED_DATASOURCE;

            //Display Panel
            tblockHTMLOutput.Content        = DashboardSharedStrings.GADGET_PANELHEADER_DISPLAY;
            tblockHTMLSetting.Content       = DashboardSharedStrings.CANVAS_HTMLOUTPUT_SETTINGS;
            txtTitle.Text                   = DashboardSharedStrings.CANVAS_TITLE;
            txtSummary.Text                 = DashboardSharedStrings.CANVAS_SUMMARY;
            txtConclusion.Text              = DashboardSharedStrings.CANVAS_CONCLUSION;
            checkboxGadgetHeadings.Content  = DashboardSharedStrings.CANVAS_GADGET_HEADING;
            checkboxGadgetSettings.Content  = DashboardSharedStrings.CANVAS_GADGET_SETTINGS;
            checkboxCanvasSummary.Content   = DashboardSharedStrings.CANVAS_CANVAS_SUMMARY;
            checkboxAlternateColors.Content = DashboardSharedStrings.CANVAS_ALTERNATING_COLORS;
            checkboxTopToBottom.Content     = DashboardSharedStrings.CANVAS_DISPLAY_TOPTO_BOTTOM;
            tblockChartSetting.Content      = DashboardSharedStrings.CANVAS_CHART_SETTINGS;
            lbldefaultwidth.Content         = DashboardSharedStrings.CANVAS_DEFAULT_WIDTH;
            lbldefaultheight.Content        = DashboardSharedStrings.CANVAS_DEFAULT_HEIGHT;

            //Information Panel
            lblCanvasInformation.Content = DashboardSharedStrings.GADGET_CANVAS_INFO;

            #endregion // Translation
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dashboardHelper">The dashboard helper to attach</param>
        public PropertiesControl(DashboardHelper dashboardHelper, DashboardControl dashboardControl)
        {
            InitializeComponent();

            this.dashboardHelper  = dashboardHelper;
            this.dashboardControl = dashboardControl;

            imgClose.MouseEnter += new MouseEventHandler(imgClose_MouseEnter);
            imgClose.MouseLeave += new MouseEventHandler(imgClose_MouseLeave);
            imgClose.MouseDown  += new MouseButtonEventHandler(imgClose_MouseDown);

            ConfigGrid.MaxWidth = 500;

            pnlError.Visibility   = System.Windows.Visibility.Collapsed;
            pnlWarning.Visibility = System.Windows.Visibility.Collapsed;
            pnlSave.Visibility    = System.Windows.Visibility.Collapsed;

            cmbTableName.Items.Clear();
            // Data Source Properties
            if (dashboardHelper.IsUsingEpiProject)
            {
                txtProjectPath.Visibility       = System.Windows.Visibility.Visible;
                tblockProjectPath.Visibility    = System.Windows.Visibility.Visible;
                btnProjectPathBrowse.Visibility = System.Windows.Visibility.Visible;

                tblockTableName.Visibility = System.Windows.Visibility.Visible;
                cmbTableName.Visibility    = System.Windows.Visibility.Visible;

                txtDataSource.Visibility          = System.Windows.Visibility.Collapsed;
                tblockConnectionString.Visibility = System.Windows.Visibility.Collapsed;

                txtSQLQuery.Visibility    = System.Windows.Visibility.Collapsed;
                tblockSQLQuery.Visibility = System.Windows.Visibility.Collapsed;

                txtProjectPath.Text = dashboardHelper.View.Project.FilePath;

                if (System.IO.File.Exists(txtProjectPath.Text))
                {
                    Project project = new Project(txtProjectPath.Text);
                    foreach (View view in project.Views)
                    {
                        cmbTableName.Items.Add(view.Name);
                    }
                }

                cmbTableName.Text = dashboardHelper.View.Name;
            }
            else
            {
                grdDataSource.Visibility = System.Windows.Visibility.Collapsed;

                txtProjectPath.Visibility       = System.Windows.Visibility.Collapsed;
                tblockProjectPath.Visibility    = System.Windows.Visibility.Collapsed;
                btnProjectPathBrowse.Visibility = System.Windows.Visibility.Collapsed;

                tblockTableName.Visibility = System.Windows.Visibility.Collapsed;
                cmbTableName.Visibility    = System.Windows.Visibility.Collapsed;

                txtDataSource.Visibility          = System.Windows.Visibility.Visible;
                tblockConnectionString.Visibility = System.Windows.Visibility.Visible;

                if (!string.IsNullOrEmpty(dashboardHelper.CustomQuery))
                {
                    grdDataSource.Visibility = System.Windows.Visibility.Visible;

                    txtDataSource.Visibility          = System.Windows.Visibility.Collapsed;
                    tblockConnectionString.Visibility = System.Windows.Visibility.Collapsed;

                    txtSQLQuery.Visibility    = System.Windows.Visibility.Visible;
                    tblockSQLQuery.Visibility = System.Windows.Visibility.Visible;
                    txtSQLQuery.Text          = dashboardHelper.CustomQuery;
                }
                else
                {
                    txtSQLQuery.Visibility    = System.Windows.Visibility.Collapsed;
                    tblockSQLQuery.Visibility = System.Windows.Visibility.Collapsed;
                    txtSQLQuery.Text          = string.Empty;
                }
                //txtDataSource.Text = dashboardHelper.Database.ConnectionString;
            }

            if (dashboardHelper.ConnectionsForRelate.Count > 0)
            {
                grdRelatedDataSources.Visibility = System.Windows.Visibility.Visible;
                // Related Data
                foreach (RelatedConnection rConn in dashboardHelper.ConnectionsForRelate)
                {
                    RowDefinition rowDefHeader = new RowDefinition();
                    grdRelatedDataSourceList.RowDefinitions.Add(rowDefHeader);

                    //Image imgRemove = new Image();
                    //imgRemove.Source = imgClose.Source;
                    //imgRemove.Width = 16;
                    //imgRemove.Height = 16;
                    //Grid.SetRow(imgRemove, grdRelatedDataSourceList.RowDefinitions.Count - 1);
                    //Grid.SetColumn(imgRemove, 0);
                    //grdRelatedDataSourceList.Children.Add(imgRemove);

                    TextBlock tblockCount = new TextBlock();
                    tblockCount.Text     = grdRelatedDataSourceList.RowDefinitions.Count.ToString();
                    tblockCount.MaxWidth = 300;
                    Grid.SetRow(tblockCount, grdRelatedDataSourceList.RowDefinitions.Count - 1);
                    Grid.SetColumn(tblockCount, 0);
                    grdRelatedDataSourceList.Children.Add(tblockCount);

                    TextBlock tblockRelatedData = new TextBlock();
                    tblockRelatedData.Text     = rConn.db.ConnectionString;
                    tblockRelatedData.MaxWidth = 300;
                    Grid.SetRow(tblockRelatedData, grdRelatedDataSourceList.RowDefinitions.Count - 1);
                    Grid.SetColumn(tblockRelatedData, 2);
                    grdRelatedDataSourceList.Children.Add(tblockRelatedData);
                }
            }
            else
            {
                grdRelatedDataSources.Visibility = System.Windows.Visibility.Collapsed;
            }

            // HTML Output Properties
            txtTitle.Text      = dashboardControl.CustomOutputHeading;
            txtSummary.Text    = dashboardControl.CustomOutputSummaryText;
            txtConclusion.Text = dashboardControl.CustomOutputConclusionText;
            checkboxGadgetHeadings.IsChecked  = dashboardControl.ShowGadgetHeadingsInOutput;
            checkboxGadgetSettings.IsChecked  = dashboardControl.ShowGadgetSettingsInOutput;
            checkboxAlternateColors.IsChecked = dashboardControl.UseAlternatingColorsInOutput;
            checkboxCanvasSummary.IsChecked   = dashboardControl.ShowCanvasSummaryInfoInOutput;

            // Misc info
            tblockRows.Text             = dashboardHelper.DataSet.Tables[0].Rows.Count.ToString() + " unfiltered rows";
            tblockColumns.Text          = dashboardHelper.DataSet.Tables[0].Columns.Count.ToString() + " columns";
            tblockCacheDateTime.Text    = "Data last cached at " + dashboardHelper.LastCacheTime.ToShortDateString() + " " + dashboardHelper.LastCacheTime.ToShortTimeString();
            tblockCacheTimeElapsed.Text = "Took " + dashboardHelper.TimeToCache + " to locally cache data";

            Epi.ApplicationIdentity appId = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);
            tblockCurrentEpiVersion.Text = "Epi Info " + appId.Version;

            cmbTableName.SelectionChanged += new SelectionChangedEventHandler(cmbTableName_SelectionChanged);
            txtProjectPath.TextChanged    += new TextChangedEventHandler(txtProjectPath_TextChanged);
        }
Ejemplo n.º 7
0
        public virtual void WriteTo(string fileName)
        {
            ExportInfo.UserID          = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
            ExportInfo.ExportInitiated = DateTime.Now;

            var sw = new Stopwatch();

            sw.Start();

            MajorProgress = 0;

            Epi.ApplicationIdentity    appId       = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);
            System.Reflection.Assembly vhfAssembly = System.Reflection.Assembly.GetExecutingAssembly();

            DateTime    dt = DateTime.UtcNow;
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;
            string      dateDisplayValue = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:s}", dt);

            using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                XmlWriterSettings settings = new XmlWriterSettings()
                {
                    Async = false, Encoding = Encoding.Default, CheckCharacters = false, NewLineOnAttributes = false, Indent = true
                };

                using (XmlWriter writer = XmlWriter.Create(stream, settings))
                {
                    writer.WriteStartElement("DataPackage");
                    writer.WriteAttributeString("Version", appId.Version);
                    writer.WriteAttributeString("VhfVersion", vhfAssembly.GetName().Version.ToString());
                    writer.WriteAttributeString("CreatedUtc", dateDisplayValue);
                    writer.WriteAttributeString("CreatedDate", dt.ToString(invariantCulture.DateTimeFormat.ShortDatePattern));
                    writer.WriteAttributeString("Name", "sync");
                    writer.WriteAttributeString("Id", System.Guid.NewGuid().ToString());
                    writer.WriteAttributeString("SourceDbType", _database);
                    writer.WriteAttributeString("StartDate", StartDate.ToString(invariantCulture.DateTimeFormat.ShortDatePattern));
                    writer.WriteAttributeString("EndDate", EndDate.ToString(invariantCulture.DateTimeFormat.ShortDatePattern));

                    if (_region == RegionEnum.International)
                    {
                        writer.WriteAttributeString("Region", "International");
                    }
                    else
                    {
                        writer.WriteAttributeString("Region", "USA");
                    }

                    foreach (View form in Project.Views)
                    {
                        ExportInfo.RecordsPackaged.Add(form, 0);

                        if (!_includeContacts && form.Name.Equals(Core.Constants.CONTACT_FORM_NAME, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        WriteFormData(writer, form);
                        MajorProgress += _majorProgressIncrement;
                        OnMajorProgressChanged();
                        ExportInfo.FormsProcessed++;
                    }

                    WriteLinksData(writer);
                    MajorProgress += _majorProgressIncrement;
                    OnMajorProgressChanged();

                    if (_includeContacts)
                    {
                        WriteFollowUpsData(writer);
                        MajorProgress += _majorProgressIncrement;
                        OnMajorProgressChanged();
                    }

                    writer.WriteEndElement();
                }
            }

            OnMinorStatusChanged("All records written.");

            sw.Stop();
            Debug.Print(sw.Elapsed.TotalMilliseconds.ToString());

            ExportInfo.ExportCompleted = DateTime.Now;
            ExportInfo.TimeElapsed     = ExportInfo.ExportCompleted - ExportInfo.ExportInitiated;
            ExportInfo.Succeeded       = true;
        }
Ejemplo n.º 8
0
        public static XmlNode Serialize(System.Xml.XmlDocument doc, ChoroplethLayerProvider provider, string dataKey, string shapeKey, string value, string legacyClassCountIndex, SolidColorBrush highColor, SolidColorBrush lowColor, SolidColorBrush missingColor, string uniqueXmlString, DashboardHelper dashboardHelper, XmlAttribute type, double opacity)
        {
            Epi.ApplicationIdentity appId = new Epi.ApplicationIdentity(typeof(Configuration).Assembly);

            try
            {
                string classTitles       = "<classTitles>" + Environment.NewLine;
                long   classTitleCount   = 0;
                string classTitleTagName = "";

                foreach (KeyValuePair <string, string> entry in provider.ListLegendText.Dict)
                {
                    classTitleTagName = entry.Key;
                    classTitles      += string.Format("<{1}>{0}</{1}>", entry.Value, classTitleTagName) + Environment.NewLine;
                    classTitleCount++;
                }

                classTitles += "</classTitles>" + Environment.NewLine;

                string customColors = "";

                if (provider.CustomColorsDictionary != null)
                {
                    customColors = "<customColors>" + Environment.NewLine;

                    foreach (KeyValuePair <string, Color> keyValuePair in provider.CustomColorsDictionary.Dict)
                    {
                        string customColor = "<" + keyValuePair.Key + ">";
                        string color       = keyValuePair.Value.R + "," + keyValuePair.Value.G + "," + keyValuePair.Value.B;
                        customColor  += color + "</" + keyValuePair.Key + ">" + Environment.NewLine;
                        customColors += customColor;
                    }

                    customColors += "</customColors>" + Environment.NewLine;
                }

                string useCustomColorsTag = "<useCustomColors>" + provider.UseCustomColors + "</useCustomColors>" + Environment.NewLine;
                string asQuintileTag      = "<partitionUsingQuantiles>" + provider.UseQuantiles + "</partitionUsingQuantiles>" + Environment.NewLine;
                string classRanges        = "";


                string resolution    = "<resolution>" + provider.ArcGIS_Map.Resolution.ToString() + "</resolution>" + Environment.NewLine;
                string centerPoint_X = "<centerPoint_X>" + provider.ArcGIS_Map.Extent.GetCenter().X.ToString() + "</centerPoint_X>" + Environment.NewLine;
                string centerPoint_Y = "<centerPoint_Y>" + provider.ArcGIS_Map.Extent.GetCenter().Y.ToString() + "</centerPoint_Y>" + Environment.NewLine;
                string spatialRef    = "<spatialRef>" + provider.ArcGIS_Map.Extent.SpatialReference.WKID.ToString() + "</spatialRef>" + Environment.NewLine;
                //string spatialRef = "<spatialRef>" + provider.ArcGIS_Map.SpatialReference.WKID.ToString() + "</spatialRef>" + Environment.NewLine;
                string envMinX = "<envMinX>" + provider.ArcGIS_Map.Extent.XMin + "</envMinX>" + Environment.NewLine;
                string envMinY = "<envMinY>" + provider.ArcGIS_Map.Extent.YMin + "</envMinY>" + Environment.NewLine;
                string envMaxX = "<envMaxX>" + provider.ArcGIS_Map.Extent.XMax + "</envMaxX>" + Environment.NewLine;
                string envMaxY = "<envMaxY>" + provider.ArcGIS_Map.Extent.YMax + "</envMaxY>" + Environment.NewLine;

                if (provider.UseQuantiles == false)
                {
                    if (provider.ClassRangesDictionary != null)
                    {
                        classRanges = "<classRanges>" + Environment.NewLine;

                        foreach (KeyValuePair <string, string> keyValuePair in provider.ClassRangesDictionary.RangeDictionary)
                        {
                            string rangeName  = "<" + keyValuePair.Key + ">";
                            string rangeValue = keyValuePair.Value;
                            rangeName   += rangeValue + "</" + keyValuePair.Key + ">" + Environment.NewLine;
                            classRanges += rangeName;
                        }

                        classRanges += "</classRanges>" + Environment.NewLine;
                    }
                }

                string xmlString = uniqueXmlString +
                                   "<highColor>" + highColor.Color.ToString() + "</highColor>" + Environment.NewLine +
                                   "<legTitle>" + provider.LegendText + "</legTitle>" + Environment.NewLine +
                                   "<showPolyLabels>" + provider.ShowPolyLabels + "</showPolyLabels>" + Environment.NewLine +
                                   classTitles +
                                   classRanges +
                                   useCustomColorsTag +
                                   resolution +
                                   centerPoint_X +
                                   centerPoint_Y +
                                   spatialRef +
                                   envMinX +
                                   envMinY +
                                   envMaxX +
                                   envMaxY +
                                   asQuintileTag +
                                   customColors +
                                   "<lowColor>" + lowColor.Color.ToString() + "</lowColor>" + Environment.NewLine +
                                   "<missingColor>" + missingColor.Color.ToString() + "</missingColor>" + Environment.NewLine +
                                   "<classes>" + legacyClassCountIndex + "</classes>" + Environment.NewLine +
                                   "<dataKey>" + dataKey + "</dataKey>" + Environment.NewLine +
                                   "<shapeKey>" + shapeKey + "</shapeKey>" + Environment.NewLine +
                                   "<value>" + value + "</value>" + Environment.NewLine +
                                   "<opacity>" + opacity + "</opacity>" + Environment.NewLine +
                                   "<versionTag>" + appId.Version.ToString() + "</versionTag>" + Environment.NewLine;

                doc.PreserveWhitespace = true;

                XmlElement element = doc.CreateElement("dataLayer");
                element.InnerXml = xmlString;
                element.AppendChild(dashboardHelper.Serialize(doc));

                element.Attributes.Append(type);

                return(element);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }