예제 #1
0
    /// <summary>
    /// Generate all codelists
    /// </summary>
    /// <param name="ObjDIConnection"></param>
    /// <param name="dataFolderName"></param>
    private string GenerateAllCodelists(DIConnection ObjDIConnection, string dataFolderName, string selectedDataTypes, string areaOrderBy, string quickSelectionType)
    {
        string RetVal = "false";
        string LanguageBasedOutputFolder = string.Empty;
        SDMXMLGenerator SDMXMLFileGenerator = null;
        ArrayList XmlDataList = new ArrayList();
        AreaQuickSelectionType QuickSelectionType = AreaQuickSelectionType.Immediate;

        foreach (string XmlDataType in Global.SplitString(selectedDataTypes, Constants.Delimiters.Comma))
        {
            XmlDataList.Add(XmlDataType);
        }

        try
        {
            SDMXMLFileGenerator = new SDMXMLGenerator(ObjDIConnection.ConnectionStringParameters.GetConnectionString(), Convert.ToInt32(ObjDIConnection.ConnectionStringParameters.ServerType));

            LanguageBasedOutputFolder = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + dataFolderName + "\\" + Constants.FolderName.DataFiles);

            if (XmlDataList.Contains(Constants.FolderName.Codelists.Area))
            {
                //-- Generate Area
                switch (areaOrderBy)
                {
                    case "AreaName":
                        SDMXMLFileGenerator.SortByAreaName = true;
                        break;
                    case "AreaId":
                        SDMXMLFileGenerator.SortByAreaName = false;
                        break;
                    default:
                        break;
                }

                SDMXMLFileGenerator.AreaLevel = "_";
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.DI7Area, LanguageBasedOutputFolder, Constants.FolderName.Codelists.Area, true);

                //-- Generate Area level
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.Arealevel, LanguageBasedOutputFolder, Constants.FolderName.Codelists.Area, true);
            }

            if (XmlDataList.Contains("quicksearch"))
            {
                switch (quickSelectionType)
                {
                    case "All":
                        QuickSelectionType = AreaQuickSelectionType.All;
                        break;
                    case "Immediate":
                        QuickSelectionType = AreaQuickSelectionType.Immediate;
                        break;
                    case "None":
                        QuickSelectionType = AreaQuickSelectionType.None;
                        break;
                    default:
                        break;
                }

                SDMXMLFileGenerator.SelectedAreaQuickSelectionType = QuickSelectionType;

                //-- Generate Area search
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.AreaSearch, LanguageBasedOutputFolder, Constants.FolderName.Codelists.Area, true);

                //-- Generate Quick search
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.QuickSearch, LanguageBasedOutputFolder, Constants.FolderName.Codelists.Area, true);
            }

            if (XmlDataList.Contains(Constants.FolderName.Codelists.Footnotes))
            {
                //-- Generate Footnotes
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.Footnotes, LanguageBasedOutputFolder, Constants.FolderName.Codelists.Footnotes, true);
            }

            if (XmlDataList.Contains(Constants.FolderName.Codelists.IC))
            {
                //-- Generate ic xml files e.g avl_ic_types.xml,sc.xml,sc_l1.xml,sc_l1_icNId.xml and for other ictypes etc.
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.IC, LanguageBasedOutputFolder, Constants.FolderName.Codelists.IC, true);
            }

            if (XmlDataList.Contains(Constants.FolderName.Codelists.IC_IUS))
            {
                //-- Generate ic-ius files iu_ICNId.xml
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.ic_ius, LanguageBasedOutputFolder, Constants.FolderName.Codelists.IC_IUS, true);
            }

            if (XmlDataList.Contains(Constants.FolderName.Codelists.IUS))
            {
                //-- Generate IUS codelist e.g. _iu_.xml, ius_IndicatorNID_UnitNID.xml and IUSSearch xml files
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.ius, LanguageBasedOutputFolder, Constants.FolderName.Codelists.IUS, true);
            }

            if (XmlDataList.Contains(Constants.FolderName.Codelists.Metadata))
            {
                //-- Generate Metadata
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.Metadata, LanguageBasedOutputFolder, Constants.FolderName.Codelists.Metadata, true);
            }

            if (XmlDataList.Contains(Constants.FolderName.Codelists.TP))
            {
                //-- Generate Time Period
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.tp, LanguageBasedOutputFolder, Constants.FolderName.Codelists.TP, true);
            }

            RetVal = "true";
        }
        catch (Exception ex)
        {
            if (Directory.Exists(LanguageBasedOutputFolder))
            {
                //Global.DeleteDirectory(LanguageBasedOutputFolder);
            }

            //Global.WriteErrorsInLog(ex.StackTrace + "--" + ex.Message);
            Global.CreateExceptionString(ex, null);
        }

        return RetVal;
    }
예제 #2
0
        /// <summary>
        /// Generate all xml files of mdb database
        /// </summary>
        /// <param name="dataFolderName"></param>
        /// <param name="areaOrderBy"></param>
        /// <param name="quickSelectionType"></param>
        /// <returns></returns>
        public bool GenerateDefaultXmlFiles(string dataFolderName, string areaOrderBy, string quickSelectionType)
        {
            bool RetVal = false;
            string LanguageBasedOutputFolder = string.Empty;
            SDMXMLGenerator SDMXMLFileGenerator = null;
            AreaQuickSelectionType QuickSelectionType = AreaQuickSelectionType.Immediate;
            int ProgressCount = 8;

            try
            {
                //-- raise event to display progress form
                this.RaiseDisplayProgressFormEvent();

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, string.Empty, false);

                SDMXMLFileGenerator = new SDMXMLGenerator(this.DBConnection.ConnectionStringParameters.GetConnectionString(), Convert.ToInt32(this.DBConnection.ConnectionStringParameters.ServerType));

                LanguageBasedOutputFolder = Path.Combine(this.OutputFolderPath, dataFolderName);

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "Area", false);

                #region "-- Generate Area -- "

                switch (areaOrderBy)
                {
                    case "AreaName":
                        SDMXMLFileGenerator.SortByAreaName = true;
                        break;
                    case "AreaId":
                        SDMXMLFileGenerator.SortByAreaName = false;
                        break;
                    default:
                        break;
                }

                SDMXMLFileGenerator.AreaLevel = "_";
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.DI7Area, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.Area, true);

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "Area level", false);

                //-- Generate Area level
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.Arealevel, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.Area, true);
                #endregion

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "Quick Search", false);

                #region "-- Quick Search -- "

                switch (quickSelectionType)
                {
                    case "All":
                        QuickSelectionType = AreaQuickSelectionType.All;
                        break;
                    case "Immediate":
                        QuickSelectionType = AreaQuickSelectionType.Immediate;
                        break;
                    case "None":
                        QuickSelectionType = AreaQuickSelectionType.None;
                        break;
                    default:
                        break;
                }

                SDMXMLFileGenerator.SelectedAreaQuickSelectionType = QuickSelectionType;

                //-- Generate Area search
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.AreaSearch, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.Area, true);

                //-- Generate Quick search
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.QuickSearch, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.Area, true);

                #endregion

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "Footnote", false);

                //-- Generate Footnotes
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.Footnotes, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.Footnotes, true);

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "IC", false);

                //-- Generate ic xml files e.g avl_ic_types.xml,sc.xml,sc_l1.xml,sc_l1_icNId.xml and for other ictypes etc.
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.IC, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.IC, true);

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "IC and IUS", false);

                //-- Generate ic-ius files iu_ICNId.xml
               SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.ic_ius, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.IC_IUS, true);

               // increment progress bar value
               this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "IUS", false);

                //-- Generate IUS codelist e.g. _iu_.xml, ius_IndicatorNID_UnitNID.xml and IUSSearch xml files
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.ius, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.IUS, true);

                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "Metadata", false);

                //-- Generate Metadata
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.Metadata, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.Metadata, true)
            ;
                // increment progress bar value
                this.RaiseProgressChangedEvent(ProgressCount++, string.Empty, "Timeperiod", false);

                //-- Generate Time Period
                SDMXMLFileGenerator.GenerateXmlCodeList(XMLCodeListType.tp, LanguageBasedOutputFolder, QDSConstants.FolderName.Codelists.TP, true);

                RetVal = true;
            }
            catch (Exception)
            {
                throw;
            }

            return RetVal;
        }