コード例 #1
0
        /// <summary>
        /// To Import indicator classification from mapped indicator classification
        /// </summary>
        /// <param name="ICInfo">Instance of IndicatorClassificationInfo</param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="NidInTrgDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns>new indicator classification nid</returns>
        public int ImportICFrmMappedIC(IndicatorClassificationInfo ICInfo, int NidInSourceDB, int NidInTrgDB, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int RetVal = -1;

            try
            {
                // Set RetVal to NidInTrgDB
                RetVal = NidInTrgDB;


                if (RetVal > 0)
                {
                    // if source item is global
                    if (ICInfo.IsGlobal)
                    {
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateIC(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode,
                                                                                                             ICInfo.Name, ICInfo.GID, ICInfo.IsGlobal, ICInfo.Parent.Nid, ICInfo.ClassificationInfo, ICInfo.Type, RetVal));
                    }

                    //update/insert icon
                    DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.IndicatorClassification, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(RetVal);
        }
コード例 #2
0
 /// <summary>
 ///To add indicator classification into collection
 /// </summary>
 /// <param name="icInfo">object of IndicatorClassificationInfo</param>
 private void AddIndicatorIntoCollection(IndicatorClassificationInfo icInfo)
 {
     if (!this.IndicatorClassificationCollection.ContainsKey(icInfo.GID))
     {
         this.IndicatorClassificationCollection.Add(icInfo.GID, icInfo);
     }
 }
コード例 #3
0
ファイル: SourceBuilder.cs プロジェクト: dovanduy/sdrcdevinfo
        /// <summary>
        /// Update Sources
        /// </summary>
        /// <param name="sourceName"></param>
        /// <param name="sourceNid"></param>
        /// <returns></returns>
        public bool UpdateSources(string sourceName, int nid, int parentNid, string ISBN, string nature)
        {
            bool RetVal = false;
            int  SourceParentNid;

            if (this.CheckSourceExists(sourceName) <= 0)
            {
                IndicatorClassificationInfo ICInfo = new IndicatorClassificationInfo();
                ICInfo.Parent = new IndicatorClassificationInfo();

                ICInfo.Parent.Name = GetSourceParentFrmSourceName(sourceName);
                ICInfo.Name        = sourceName;
                ICInfo.Type        = ICType.Source;
                ICInfo.ISBN        = ISBN;
                ICInfo.Nature      = nature;

                //-- Update Publisher
                this.UpdateSources(ICInfo.Parent, parentNid);

                SourceParentNid = this.CheckPublisherExistsInDB(sourceName);
                if (SourceParentNid == -1)
                {
                    //-- Update Source
                    this.UpdateSources(ICInfo, nid);
                }
                RetVal = true;
            }
            else
            {
                //-- Update Publisher
                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Source.Update.UpdateSource(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, sourceName, nid, ISBN, nature));
            }
            return(RetVal);
        }
コード例 #4
0
ファイル: SourceBuilder.cs プロジェクト: dovanduy/sdrcdevinfo
        /// <summary>
        /// Update Sources
        /// </summary>
        /// <param name="sourceName"></param>
        /// <param name="sourceNid"></param>
        /// <returns></returns>
        public bool UpdateSources(string sourceName, int nid, int parentNid)
        {
            bool RetVal = false;
            int  SourceParentNid;

            if (this.CheckSourceExists(sourceName) <= 0)
            {
                IndicatorClassificationInfo ICInfo = new IndicatorClassificationInfo();
                ICInfo.Parent = new IndicatorClassificationInfo();

                ICInfo.Parent.Name = GetSourceParentFrmSourceName(sourceName);
                ICInfo.Name        = sourceName;
                ICInfo.Type        = ICType.Source;

                //-- Update Publisher
                this.UpdateSources(ICInfo.Parent, parentNid);

                SourceParentNid = this.CheckPublisherExistsInDB(sourceName);
                if (SourceParentNid == -1)
                {
                    //-- Update Source
                    this.UpdateSources(ICInfo, nid);
                }
                RetVal = true;
            }
            return(RetVal);
        }
コード例 #5
0
        /// <summary>
        /// Check existance of indicator classification  record into database if false then create indicator record
        /// </summary>
        /// <param name="indicatorClassificationInfo">object of IndicatorClassificationInfo</param>
        /// <returns>Nid</returns>
        public int CheckNCreateIndicatorClassification(IndicatorClassificationInfo icInfo)
        {
            int RetVal = 0;

            try
            {
                // check indicator classification exists or not
                RetVal = this.CheckIndicatorClassificationExists(icInfo);

                // if indicator classification does not exist then create it.
                if (RetVal <= 0)
                {
                    // insert indicator
                    if (this.InsertIntoDatabase(icInfo))
                    {
                        RetVal = this.GetNidByName(icInfo.Name, icInfo.Parent.Nid, icInfo.Type);
                    }
                }

                // add indicator classification information into collection
                icInfo.Nid = RetVal;
                this.AddIndicatorIntoCollection(icInfo);
            }
            catch (Exception)
            {
                RetVal = 0;
            }

            return(RetVal);
        }
コード例 #6
0
 public IndicatorClassificationInfo(string name, ICType type, bool isGlobal, int parentNid)
 {
     this._Parent     = new IndicatorClassificationInfo();
     this._Name       = name;
     this._Type       = type;
     this._IsGlobal   = isGlobal;
     this._Parent.Nid = parentNid;
 }
コード例 #7
0
 public IndicatorClassificationInfo(string name, ICType type, bool isGlobal, int parentNid)
 {
     this._Parent = new IndicatorClassificationInfo();
     this._Name = name;
     this._Type = type;
     this._IsGlobal = isGlobal;
     this._Parent.Nid = parentNid;
 }
コード例 #8
0
        /// <summary>
        /// Insert IndicatorClassification record into database
        /// </summary>
        /// <param name="indicatorClassificationInfo">object of IndicatorInfo</param>
        /// <returns>Ture/False. Return true after successful insertion otherwise false</returns>
        public bool InsertIntoDatabase(IndicatorClassificationInfo indicatorClassificationInfo)
        {
            bool   RetVal              = false;
            string ICName              = indicatorClassificationInfo.Name;
            string ICGId               = Guid.NewGuid().ToString();
            string LanguageCode        = string.Empty;
            string DefaultLanguageCode = string.Empty;
            string ICNameForDatabase   = string.Empty;
            int    ICOrder             = 0;

            try
            {
                DefaultLanguageCode = this.DBQueries.LanguageCode;

                //replace GID only if given gid is not empty or null.
                if (!string.IsNullOrEmpty(indicatorClassificationInfo.GID))
                {
                    ICGId = indicatorClassificationInfo.GID;
                }

                // get max IC order
                try
                {
                    ICOrder = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(this.DBQueries.IndicatorClassification.GetMaxICOrder(indicatorClassificationInfo.Parent.Nid)));
                }
                catch (Exception)
                {
                }

                ICOrder += 1;


                foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                {
                    LanguageCode = languageRow[Language.LanguageCode].ToString();
                    if (LanguageCode == DefaultLanguageCode.Replace("_", String.Empty))
                    {
                        ICNameForDatabase = ICName;
                    }
                    else
                    {
                        ICNameForDatabase = Constants.PrefixForNewValue + ICName;
                    }
                    this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Insert.InsertIC(this.DBQueries.DataPrefix, "_" + LanguageCode, ICNameForDatabase, ICGId,
                                                                                                         indicatorClassificationInfo.IsGlobal, indicatorClassificationInfo.Parent.Nid, indicatorClassificationInfo.ClassificationInfo, indicatorClassificationInfo.Type, ICOrder));
                }

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

            return(RetVal);
        }
コード例 #9
0
        private void Get_ICChain(string parentICGID, ICType icICType, SDMXObjectModel.Structure.CategoryType CatTypeCode)
        {
            string Name         = string.Empty;
            string GID          = string.Empty;
            string LanguageCode = this._LanguageCode;
            int    NID          = 0;
            bool   ISGlobal     = false;

            // Read each child IC for current IC
            foreach (SDMXObjectModel.Structure.CategoryType SubCateType in CatTypeCode.Items)
            {
                GID      = SubCateType.id;
                Name     = string.Empty;
                ISGlobal = false;

                foreach (TextType IndTextType in SubCateType.Name)
                {
                    if (IndTextType.lang.Trim('_') == this._LanguageCode)
                    {
                        Name = IndTextType.Value;
                        break;
                    }
                }

                foreach (AnnotationType AnnType in SubCateType.Annotations)
                {
                    if (AnnType.AnnotationTitle == SDMXConstants.Annotations.IsGlobal)
                    {
                        foreach (TextType AnnTextType in AnnType.AnnotationText)
                        {
                            ISGlobal = Convert.ToBoolean(AnnTextType.Value);
                            break;
                        }
                    }
                }

                if (!this.ICDetails.ContainsKey(GID))
                {
                    IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                    TableInfoObj.GID        = GID;
                    TableInfoObj.Name       = Name;
                    TableInfoObj.Type       = icICType;
                    TableInfoObj.Parent     = new IndicatorClassificationInfo();
                    TableInfoObj.Parent.GID = parentICGID;
                    this.ICDetails.Add(GID, TableInfoObj);
                }

                this.Get_ICChain(GID, icICType, SubCateType);
            }
        }
コード例 #10
0
        /// <summary>
        /// To check existance of Indicator classification first into collection then into database
        /// </summary>
        /// <param name="icInfo">object of IndicatorClassificationInfo</param>
        /// <returns>Nid</returns>
        private int CheckIndicatorClassificationExists(IndicatorClassificationInfo icInfo)
        {
            int RetVal = 0;

            //Step 1: check source exists in source collection
            RetVal = this.CheckIndicatorClassificationInCollection(icInfo.GID);

            //Step 2: check indicator exists in database.
            if (RetVal <= 0)
            {
                RetVal = this.GetIndicatorClassificationNid(icInfo.GID, icInfo.Name, icInfo.Parent.Nid, icInfo.Type);
            }

            return(RetVal);
        }
コード例 #11
0
ファイル: SourceBuilder.cs プロジェクト: dovanduy/sdrcdevinfo
        private bool UpdateSources(IndicatorClassificationInfo icInfo, int parentNid)
        {
            bool RetVal = false;

            try
            {
                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Source.Update.UpdateSource(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, icInfo.Name, parentNid, icInfo.ISBN, icInfo.Nature));

                RetVal = true;
            }
            catch (Exception)
            {
            }
            return(RetVal);
        }
コード例 #12
0
        /// <summary>
        /// Imports records from source database to target database/template
        /// </summary>
        /// <param name="selectedNids"></param>
        /// <param name="allSelected">Set true to import all records</param>
        public override void ImportValues(List<string> selectedNids, bool allSelected)
        {
            int ProgressBarValue = 0;
            IndicatorClassificationInfo SrcClassification;
            DataRow Row;

            foreach (string Nid in selectedNids)
            {
                try
                {
                    //get ic from source table
                    Row = this.SourceTable.Select(IndicatorClassifications.ICNId + "=" + Nid)[0];
                    SrcClassification = new IndicatorClassificationInfo();
                    SrcClassification.Name = DICommon.RemoveQuotes(Row[IndicatorClassifications.ICName].ToString());
                    SrcClassification.GID = Row[IndicatorClassifications.ICGId].ToString();
                    SrcClassification.IsGlobal = Convert.ToBoolean(Row[IndicatorClassifications.ICGlobal]);
                    SrcClassification.Nid = Convert.ToInt32(Row[IndicatorClassifications.ICNId]);
                    if (!Information.IsDBNull(Row[IndicatorClassifications.ICInfo]))
                    {
                        SrcClassification.ClassificationInfo = DICommon.RemoveQuotes(Row[IndicatorClassifications.ICInfo].ToString());
                    }

                    SrcClassification.Parent = new IndicatorClassificationInfo();
                    SrcClassification.Parent.Nid = Convert.ToInt32(Row[IndicatorClassifications.ICParent_NId]);
                    SrcClassification.Type = this._IndicatorClassificationType;

                    //import into target database
                    Utility.CreateClassificationChainFromExtDB(
                        SrcClassification.Nid,
                        SrcClassification.Parent.Nid,
                        SrcClassification.GID,
                        SrcClassification.Name,
                        SrcClassification.Type,
                        SrcClassification.ClassificationInfo,
                        SrcClassification.IsGlobal,
                        this.SourceDBQueries, this.SourceDBConnection, this._TargetDBQueries, this._TargetDBConnection);

                }
                catch (Exception ex)
                {
                    ExceptionFacade.ThrowException(ex);
                }
                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }
        }
コード例 #13
0
        /// <summary>
        /// Insert IndicatorClassification record into database
        /// </summary>
        /// <param name="indicatorClassificationInfo">object of IndicatorInfo</param>
        /// <returns>Ture/False. Return true after successful insertion otherwise false</returns>
        public bool InsertIntoDatabase(IndicatorClassificationInfo indicatorClassificationInfo)
        {
            bool RetVal = false;
            string ICName = indicatorClassificationInfo.Name;
            string ICGId = Guid.NewGuid().ToString();
            string LanguageCode = string.Empty;
            string DefaultLanguageCode = string.Empty;
            string ICNameForDatabase = string.Empty;
            int ICOrder = 0;

            try
            {
                DefaultLanguageCode = this.DBQueries.LanguageCode;

                //replace GID only if given gid is not empty or null.
                if (!string.IsNullOrEmpty(indicatorClassificationInfo.GID))
                {
                    ICGId = indicatorClassificationInfo.GID;
                }

                // get max IC order
                try
                {
                    ICOrder = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(this.DBQueries.IndicatorClassification.GetMaxICOrder(indicatorClassificationInfo.Parent.Nid)));
                }
                catch (Exception)
                {
                }

                ICOrder += 1;

                foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows)
                {

                    LanguageCode = languageRow[Language.LanguageCode].ToString();
                    if (LanguageCode == DefaultLanguageCode.Replace("_", String.Empty))
                    {
                        ICNameForDatabase = ICName;
                    }
                    else
                    {
                        ICNameForDatabase = Constants.PrefixForNewValue + ICName;

                    }
                    this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Insert.InsertIC(this.DBQueries.DataPrefix, "_" + LanguageCode, ICNameForDatabase, ICGId,
                        indicatorClassificationInfo.IsGlobal, indicatorClassificationInfo.Parent.Nid, indicatorClassificationInfo.ClassificationInfo, indicatorClassificationInfo.Type, ICOrder));
                }

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

            return RetVal;
        }
コード例 #14
0
        /// <summary>
        /// To Import indicator classification into database or template
        /// </summary>
        /// <param name="ICInfo">Instance of IndicatorClassificationInfo</param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns>new indicator classification nid</returns>
        public int ImportIndicatorClassification(ICType icType, string icName, string icGId, string parentICGId, bool isGlobal)
        {
            int RetVal = -1;
            bool ISTrgICGlobal = false;
            DataTable TempTable;
            IndicatorClassificationInfo ICInfo = new IndicatorClassificationInfo(icName, icType, isGlobal, 0);
            ICInfo.GID = icGId;
            string LangCode = this.DBQueries.LanguageCode;

            try
            {
                ICInfo.Parent = new IndicatorClassificationInfo();
                if (parentICGId == "-1")
                {
                    ICInfo.Parent.Nid = -1;
                }
                else
                {
                    ICInfo.Parent.GID = parentICGId;
                    ICInfo.Parent.Nid = this.GetNidByGID(parentICGId, icType);
                }
                //check item is already exist in database or not
                RetVal = this.GetIndicatorClassificationNid(ICInfo.GID, ICInfo.Name, ICInfo.Parent.Nid, ICInfo.Type);

                if (RetVal > 0)
                {
                    if (!this.DBQueries.LanguageCode.StartsWith("_"))
                    {
                        LangCode = "_" + LangCode;
                    }

                    // check target ic is global
                    TempTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, RetVal.ToString(), FieldSelection.Light));
                    if (TempTable.Rows.Count > 0)
                    {
                        ISTrgICGlobal = Convert.ToBoolean(TempTable.Rows[0][IndicatorClassifications.ICGlobal]);
                    }

                    // if target item is  not global
                    if (!ISTrgICGlobal)
                    {
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateIC(this.DBQueries.DataPrefix, LangCode,
                           ICInfo.Name, ICInfo.GID, ICInfo.IsGlobal, ICInfo.Parent.Nid, ICInfo.ClassificationInfo, ICInfo.Type, RetVal));
                    }

                }
                else
                {
                    if (this.InsertIntoDatabase(ICInfo))
                    {
                        //get nid
                        RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY"));
                    }
                }

                // update UT_CF_FLOWCHART table
                if (ICInfo.Type == ICType.CF)
                {
                    //--
                }

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return RetVal;
        }
コード例 #15
0
        /// <summary>
        /// To Import indicator classification into database or template
        /// </summary>
        /// <param name="ICInfo">Instance of IndicatorClassificationInfo</param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns>new indicator classification nid</returns>
        public int ImportIndicatorClassification(IndicatorClassificationInfo ICInfo, int NidInSourceDB, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int RetVal = -1;
            bool ISTrgICGlobal = false;
            DataTable TempTable;

            try
            {
                //check item is already exist in database or not
                RetVal = this.GetIndicatorClassificationNid(ICInfo.GID, ICInfo.Name, ICInfo.Parent.Nid, ICInfo.Type);

                if (RetVal > 0)
                {
                    // check target ic is global
                    TempTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, RetVal.ToString(), FieldSelection.Light));
                    if (TempTable.Rows.Count > 0)
                    {
                        ISTrgICGlobal = Convert.ToBoolean(TempTable.Rows[0][IndicatorClassifications.ICGlobal]);
                    }

                    // if target item is  not global
                    if (!ISTrgICGlobal)
                    {
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateIC(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode,
                           ICInfo.Name, ICInfo.GID, ICInfo.IsGlobal, ICInfo.Parent.Nid, ICInfo.ClassificationInfo, ICInfo.Type, RetVal));
                    }

                }
                else
                {
                    if (this.InsertIntoDatabase(ICInfo))
                    {
                        //get nid
                        RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY"));
                    }
                }

                // update UT_CF_FLOWCHART table
                if (ICInfo.Type == ICType.CF)
                {
                    string NewXMLText = "<?xml version=\"1.0\"?><!--AddFlow.net diagram--><AddFlow Nodes=\"1\" Links=\"0\"><Version>1.5.2.0</Version></AddFlow>";

                    DataTable SrcCFTable = null;
                    DataTable TrgCFTable = null;

                    try
                    {
                        // get node where URL ==NidInSourceDB
                        SrcCFTable = sourceDBConnection.ExecuteDataTable(sourceQurey.IndicatorClassification.GetCFFlowCharts());
                        if (SrcCFTable.Rows.Count > 0)
                        {
                            string SrcXMLString = string.Empty;
                            string TrgXMLString = string.Empty;

                            // get xml from src database
                            SrcXMLString = Convert.ToString(SrcCFTable.Rows[0][CFFlowChart.CF_FlowChart]);

                            XmlDocument SrcXmlDoc = new XmlDocument();
                            SrcXmlDoc.LoadXml(SrcXMLString);
                            SrcXmlDoc.PreserveWhitespace = true;

                            //update Nid in src node
                            XmlNodeList SrcNodeList = SrcXmlDoc.SelectNodes("/AddFlow/Node[./Url='" + NidInSourceDB + "']");
                            SrcNodeList.Item(0).LastChild.InnerText = RetVal.ToString();

                            // get target CF table
                            XmlDocument TrgXmlDoc = new XmlDocument();
                            TrgXmlDoc.PreserveWhitespace = true;
                            TrgCFTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetCFFlowCharts());

                            if (TrgCFTable.Rows.Count > 0)
                            {
                                //update
                                TrgXMLString = Convert.ToString(TrgCFTable.Rows[0][CFFlowChart.CF_FlowChart]);
                                if (string.IsNullOrEmpty(TrgXMLString))
                                {
                                    TrgXMLString = NewXMLText;
                                }
                                TrgXmlDoc.LoadXml(TrgXMLString);

                                XmlNodeList TrgNodeList = TrgXmlDoc.SelectNodes("/AddFlow/Node[./Url='" + RetVal + "']");

                                if (TrgNodeList != null & TrgNodeList.Count > 0)
                                {
                                    TrgXmlDoc.SelectNodes("/AddFlow").Item(0).RemoveChild(TrgNodeList.Item(0));
                                }

                                XmlNode SrcImpNode = SrcXmlDoc.SelectSingleNode("/AddFlow/Node[./Url='" + RetVal + "']");

                                //NewNode

                                XmlNode NewNode = TrgXmlDoc.ImportNode(SrcImpNode, true);

                                TrgXmlDoc.SelectNodes("/AddFlow").Item(0).AppendChild(NewNode);
                                TrgXMLString = DICommon.IndentXMLString(TrgXmlDoc.InnerXml);

                                TrgXMLString = DICommon.RemoveQuotes(TrgXMLString);

                                //TrgXmlDoc.Save("c:\\testtest.xml");
                                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.IndicatorClassification.Update.UpateCFFlowChart(this.DBQueries.TablesName.CFFlowChart, TrgXMLString));
                            }

                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                //update/insert icon
                DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.IndicatorClassification, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection);

            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return RetVal;
        }
コード例 #16
0
        /// <summary>
        /// To Import indicator classification from mapped indicator classification
        /// </summary>
        /// <param name="ICInfo">Instance of IndicatorClassificationInfo</param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="NidInTrgDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns>new indicator classification nid</returns>
        public int ImportICFrmMappedIC(IndicatorClassificationInfo ICInfo, int NidInSourceDB, int NidInTrgDB, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int RetVal = -1;

            try
            {
                // Set RetVal to NidInTrgDB
                RetVal = NidInTrgDB;

                if (RetVal > 0)
                {
                    // if source item is global
                    if (ICInfo.IsGlobal)
                    {
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateIC(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode,
                           ICInfo.Name, ICInfo.GID, ICInfo.IsGlobal, ICInfo.Parent.Nid, ICInfo.ClassificationInfo, ICInfo.Type, RetVal));
                    }

                    //update/insert icon
                    DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.IndicatorClassification, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return RetVal;
        }
コード例 #17
0
        /// <summary>
        /// Check existance of indicator classification  record into database if false then create indicator record 
        /// </summary>
        /// <param name="indicatorClassificationInfo">object of IndicatorClassificationInfo</param>
        /// <returns>Nid</returns>
        public int CheckNCreateIndicatorClassification(IndicatorClassificationInfo icInfo)
        {
            int RetVal = 0;

            try
            {
                // check indicator classification exists or not
                RetVal = this.CheckIndicatorClassificationExists(icInfo);

                // if indicator classification does not exist then create it.
                if (RetVal <= 0)
                {
                    // insert indicator
                    if (this.InsertIntoDatabase(icInfo))
                    {
                        RetVal = this.GetNidByName(icInfo.Name, icInfo.Parent.Nid, icInfo.Type);
                    }

                }

                // add indicator classification information into collection
                icInfo.Nid = RetVal;
                this.AddIndicatorIntoCollection(icInfo);
            }
            catch (Exception)
            {
                RetVal = 0;
            }

            return RetVal;
        }
コード例 #18
0
        private void ImportSector(DataRow row)
        {
            IndicatorClassificationInfo SrcClassification;

            try
            {
                //get ic from source table
                SrcClassification = new IndicatorClassificationInfo();
                SrcClassification.Name = DICommon.RemoveQuotes(row[IndicatorClassifications.ICName].ToString());
                SrcClassification.GID = row[IndicatorClassifications.ICGId].ToString();
                SrcClassification.IsGlobal = Convert.ToBoolean(row[IndicatorClassifications.ICGlobal]);
                SrcClassification.Nid = Convert.ToInt32(row[IndicatorClassifications.ICNId]);
                if (!Information.IsDBNull(row[IndicatorClassifications.ICInfo]))
                {
                    SrcClassification.ClassificationInfo = DICommon.RemoveQuotes(row[IndicatorClassifications.ICInfo].ToString());
                }

                SrcClassification.Parent = new IndicatorClassificationInfo();
                SrcClassification.Parent.Nid = Convert.ToInt32(row[IndicatorClassifications.ICParent_NId]);
                SrcClassification.Type = ICType.Sector;

                //import into target database
                Utility.CreateClassificationChainFromExtDB(
                    SrcClassification.Nid,
                    SrcClassification.Parent.Nid,
                    SrcClassification.GID,
                    SrcClassification.Name,
                    SrcClassification.Type,
                    SrcClassification.ClassificationInfo,
                    SrcClassification.IsGlobal,
                    this.SourceDBQueries, this.SourceDBConnection, this._TargetDBQueries, this._TargetDBConnection);

            }
            catch (Exception ex)
            {
                ExceptionFacade.ThrowException(ex);
            }
        }
コード例 #19
0
        /// <summary>
        /// Process Matched Indicator Classification
        /// </summary>
        public void ProcessMatchedIC()
        {
            IndicatorClassificationInfo SrcClassification;
            DataTable Table = null;

            DIConnection SourceDBConnection = null;
            DIQueries SourceDBQueries = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this.DBConnection.ExecuteDataTable(this.TemplateQueries.GetMatchedIC());

            //-- Step 2: Import Nids for each SourceFile
            foreach (DataRow Row in Table.Copy().Rows)
            {
                try
                {
                    SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]), String.Empty, MergetTemplateConstants.DBPassword);
                    SourceDBQueries = DataExchange.GetDBQueries(SourceDBConnection);

                    //get ic from source table
                    //Row = this.SourceTable.Select(IndicatorClassifications.ICNId + "=" + Nid)[0];
                    SrcClassification = new IndicatorClassificationInfo();
                    SrcClassification.Name = DICommon.RemoveQuotes(Row[IndicatorClassifications.ICName].ToString());
                    SrcClassification.GID = Row[IndicatorClassifications.ICGId].ToString();
                    SrcClassification.IsGlobal = Convert.ToBoolean(Row[IndicatorClassifications.ICGlobal]);
                    SrcClassification.Nid = Convert.ToInt32(Row[IndicatorClassifications.ICNId]);
                    if (!string.IsNullOrEmpty(Convert.ToString((Row[IndicatorClassifications.ICInfo]))))
                    {
                        SrcClassification.ClassificationInfo = DICommon.RemoveQuotes(Row[IndicatorClassifications.ICInfo].ToString());
                    }

                    SrcClassification.Parent = new IndicatorClassificationInfo();
                    SrcClassification.Parent.Nid = Convert.ToInt32(Row[IndicatorClassifications.ICParent_NId]);
                    SrcClassification.Type = (ICType)(Convert.ToInt32(DIQueries.ICTypeText.IndexOfValue("'" + Convert.ToString(Row[IndicatorClassifications.ICType]) + "'")));

                    //import into target database
                    this.CreateClassificationChainFromExtDB(
                        SrcClassification.Nid,
                        SrcClassification.Parent.Nid,
                        SrcClassification.GID,
                        SrcClassification.Name,
                        SrcClassification.Type,
                        SrcClassification.ClassificationInfo,
                        SrcClassification.IsGlobal,
                       SourceDBQueries, SourceDBConnection, this.DBQueries, this.DBConnection);

                }
                catch (Exception ex)
                {
                    ExceptionFacade.ThrowException(ex);
                }

            }
        }
コード例 #20
0
ファイル: ICSource.cs プロジェクト: SDRC-India/sdrcdevinfo
        public override void Import(string selectedNIds)
        {
            IndicatorClassificationInfo SrcClassification;
            string SrcFileName = string.Empty;
            DataTable Table = null;
            int ProgressCounter = 0;
            //IndicatorClassificationBuilder  ICBuilder = null;
            //Dictionary<string, DataRow> FileWithNids = new Dictionary<string, DataRow>();

            DIConnection SourceDBConnection = null;
            DIQueries SourceDBQueries = null;

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedNIds.Split(',').GetUpperBound(0) + 1);

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportICs( selectedNIds));

            ////-- Step 2:Initialise Indicator Builder with Target DBConnection
            //ICBuilder = new IndicatorClassificationBuilder(this.TargetDBConnection, this.TargetDBQueries);

            try
            {

                //-- Step 3: Import Nids for each SourceFile
                foreach (DataRow Row in Table.Copy().Rows)
                {
                    try
                    {
                        if (SrcFileName != Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]))
                        {
                            SrcFileName = Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]);

                            //-- Step 2:Initialise DBConnection
                            if (SourceDBConnection != null)
                            {
                                SourceDBConnection.Dispose();
                            }

                            SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, SrcFileName, String.Empty, MergetTemplateConstants.DBPassword);
                            SourceDBQueries = DataExchange.GetDBQueries(SourceDBConnection);
                        }

                        SrcClassification = new IndicatorClassificationInfo();
                        SrcClassification.Name = DICommon.RemoveQuotes(Row[IndicatorClassifications.ICName].ToString());
                        SrcClassification.GID = Row[IndicatorClassifications.ICGId].ToString();
                        SrcClassification.IsGlobal = Convert.ToBoolean(Row[IndicatorClassifications.ICGlobal]);
                        SrcClassification.Nid = Convert.ToInt32(Row[IndicatorClassifications.ICNId]);
                        if (!string.IsNullOrEmpty(Convert.ToString((Row[IndicatorClassifications.ICInfo]))))
                        {
                            SrcClassification.ClassificationInfo = DICommon.RemoveQuotes(Row[IndicatorClassifications.ICInfo].ToString());
                        }

                        SrcClassification.Parent = new IndicatorClassificationInfo();
                        SrcClassification.Parent.Nid = Convert.ToInt32(Row[IndicatorClassifications.ICParent_NId]);
                        SrcClassification.Type = this._CurrentICType;

                        //import into target database
                        this.CreateClassificationChainFromExtDB(
                            SrcClassification.Nid,
                            SrcClassification.Parent.Nid,
                            SrcClassification.GID,
                            SrcClassification.Name,
                            SrcClassification.Type,
                            SrcClassification.ClassificationInfo,
                            SrcClassification.IsGlobal,
                           SourceDBQueries, SourceDBConnection, this._TargetDBQueries, this._TargetDBConnection);

                        ProgressCounter += 1;
                        this.RaiseProgressBarIncrement(ProgressCounter);

                    }
                    catch (Exception ex)
                    {
                        ExceptionFacade.ThrowException(ex);
                    }
                    this._UnmatchedTable = this.GetUnmatchedTable();
                    this._AvailableTable = this.GetAvailableTable();

                }
            }
            catch (Exception ex)
            {
                ExceptionFacade.ThrowException(ex);
            }
            finally
            {
                if (SourceDBConnection != null)
                {
                    SourceDBConnection.Dispose();
                }
            }

            // Close ProgressBar
            this.RaiseProgressBarClose();
        }
コード例 #21
0
        /// <summary>
        /// Get_IC_IUS_List method..
        /// </summary>
        /// <param name="DSDStructure"></param>
        /// <returns></returns>
        private void Get_IC_IUS()
        {
            //  Dictionary<string, string> RetVal = new Dictionary<string, string>();
            // IndicatorClassificationBuilder ICBuilder = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries);
            string IUSGID = string.Empty;
            string ICGID  = string.Empty;

            //int ICNId = 0;
            //int IUSNId = 0;
            this.ICIUSDetails = new Dictionary <string, IndicatorClassificationInfo>();

            foreach (SDMXObjectModel.Structure.CategorisationType CodeListObj in this.DSDStructure.Structures.Categorisations)
            {
                if (CodeListObj.id.StartsWith("CTGZ_"))
                {
                    IUSGID = CodeListObj.id.Substring(5);
                    IUSGID = IUSGID.Substring(IUSGID.IndexOf("@") + 1);
                }

                foreach (SDMXObjectModel.Common.RefBaseType TargetObj in CodeListObj.Target.Items)
                {
                    ICGID = TargetObj.id;
                    break;
                }

                if (!this.ICIUSDetails.ContainsKey(IUSGID))
                {
                    IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                    if (this.ICDetails.ContainsKey(ICGID))
                    {
                        TableInfoObj = this.ICDetails[ICGID];
                    }
                    else
                    {
                        TableInfoObj.GID  = ICGID;
                        TableInfoObj.Name = ICGID;
                    }

                    this.ICIUSDetails.Add(IUSGID, TableInfoObj);
                }
                else
                {
                    if (this.ICDetails.ContainsKey(ICGID))
                    {
                        if (this.ICDetails[ICGID].Parent != null)
                        {
                            if (this.ICDetails[ICGID].Parent.GID != "-1" && !string.IsNullOrEmpty(this.ICDetails[ICGID].Parent.GID))
                            {
                                IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                                if (this.ICDetails.ContainsKey(ICGID))
                                {
                                    TableInfoObj = this.ICDetails[ICGID];
                                }
                                else
                                {
                                    TableInfoObj.GID  = ICGID;
                                    TableInfoObj.Name = ICGID;
                                }
                                this.ICIUSDetails[IUSGID] = TableInfoObj;
                            }
                        }
                    }
                }
            }

            //  return RetVal;
        }
コード例 #22
0
        /// <summary>
        /// Update Sources
        /// </summary>
        /// <param name="sourceName"></param>
        /// <param name="sourceNid"></param>
        /// <returns></returns>
        public bool UpdateSources(string sourceName, int nid, int parentNid)
        {
            bool RetVal = false;
            int SourceParentNid;
            if (this.CheckSourceExists(sourceName) <= 0)
            {
                IndicatorClassificationInfo ICInfo = new IndicatorClassificationInfo();
                ICInfo.Parent = new IndicatorClassificationInfo();

                ICInfo.Parent.Name = GetSourceParentFrmSourceName(sourceName);
                ICInfo.Name = sourceName;
                ICInfo.Type = ICType.Source;

                //-- Update Publisher
                this.UpdateSources(ICInfo.Parent, parentNid);

                SourceParentNid = this.CheckPublisherExistsInDB(sourceName);
                if (SourceParentNid == -1)
                {
                    //-- Update Source
                    this.UpdateSources(ICInfo, nid);

                }
                RetVal = true;
            }
            return RetVal;
        }
コード例 #23
0
ファイル: DSDHelper.cs プロジェクト: SDRC-India/sdrcdevinfo
        /// <summary>
        /// Get_IC_IUS_List method..
        /// </summary>
        /// <param name="DSDStructure"></param>
        /// <returns></returns>
        private void Get_IC_IUS()
        {
            //  Dictionary<string, string> RetVal = new Dictionary<string, string>();
            // IndicatorClassificationBuilder ICBuilder = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries);
            string IUSGID = string.Empty;
            string ICGID = string.Empty;
            //int ICNId = 0;
            //int IUSNId = 0;
            this.ICIUSDetails = new Dictionary<string, IndicatorClassificationInfo>();

            foreach (SDMXObjectModel.Structure.CategorisationType CodeListObj in this.DSDStructure.Structures.Categorisations)
            {
                if (CodeListObj.id.StartsWith("CTGZ_"))
                {
                    IUSGID = CodeListObj.id.Substring(5);
                    IUSGID = IUSGID.Substring(IUSGID.IndexOf("@") + 1);
                }

                foreach (SDMXObjectModel.Common.RefBaseType TargetObj in CodeListObj.Target.Items)
                {
                    ICGID = TargetObj.id;
                    break;
                }

                if (!this.ICIUSDetails.ContainsKey(IUSGID))
                {
                    IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                    if (this.ICDetails.ContainsKey(ICGID))
                    {
                        TableInfoObj = this.ICDetails[ICGID];
                    }
                    else
                    {
                        TableInfoObj.GID = ICGID;
                        TableInfoObj.Name = ICGID;
                    }

                    this.ICIUSDetails.Add(IUSGID, TableInfoObj);
                }
                else
                {
                    if (this.ICDetails.ContainsKey(ICGID))
                    {
                        if (this.ICDetails[ICGID].Parent != null)
                        {
                            if (this.ICDetails[ICGID].Parent.GID != "-1" && !string.IsNullOrEmpty(this.ICDetails[ICGID].Parent.GID))
                            {
                                IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                                if (this.ICDetails.ContainsKey(ICGID))
                                {
                                    TableInfoObj = this.ICDetails[ICGID];
                                }
                                else
                                {
                                    TableInfoObj.GID = ICGID;
                                    TableInfoObj.Name = ICGID;
                                }
                                this.ICIUSDetails[IUSGID] = TableInfoObj;
                            }
                        }
                    }
                }
            }

            //  return RetVal;
        }
コード例 #24
0
ファイル: DSDHelper.cs プロジェクト: SDRC-India/sdrcdevinfo
        private void Get_ICChain(string parentICGID, ICType icICType, SDMXObjectModel.Structure.CategoryType CatTypeCode)
        {
            string Name = string.Empty;
            string GID = string.Empty;
            string LanguageCode = this._LanguageCode;
            int NID = 0;
            bool ISGlobal = false;

            // Read each child IC for current IC
            foreach (SDMXObjectModel.Structure.CategoryType SubCateType in CatTypeCode.Items)
            {
                GID = SubCateType.id;
                Name = string.Empty;
                ISGlobal = false;

                foreach (TextType IndTextType in SubCateType.Name)
                {
                    if (IndTextType.lang.Trim('_') == this._LanguageCode)
                    {
                        Name = IndTextType.Value;
                        break;
                    }
                }

                foreach (AnnotationType AnnType in SubCateType.Annotations)
                {
                    if (AnnType.AnnotationTitle == SDMXConstants.Annotations.IsGlobal)
                    {
                        foreach (TextType AnnTextType in AnnType.AnnotationText)
                        {
                            ISGlobal = Convert.ToBoolean(AnnTextType.Value);
                            break;
                        }
                    }
                }

                if (!this.ICDetails.ContainsKey(GID))
                {
                    IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                    TableInfoObj.GID = GID;
                    TableInfoObj.Name = Name;
                    TableInfoObj.Type = icICType;
                    TableInfoObj.Parent = new IndicatorClassificationInfo();
                    TableInfoObj.Parent.GID = parentICGID;
                    this.ICDetails.Add(GID, TableInfoObj);
                }

                this.Get_ICChain(GID, icICType, SubCateType);

            }
        }
コード例 #25
0
ファイル: DSDHelper.cs プロジェクト: SDRC-India/sdrcdevinfo
        /// <summary>
        /// Get_IC_Collection method.. 
        /// </summary>
        /// <param name="this._DSDStructure"></param>
        /// <returns></returns>
        private void Get_IC()
        {
            //'Dictionary<string, int> RetVal = new Dictionary<string, int>();
            // IndicatorClassificationBuilder BuilderObj = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries);
            //SourceBuilder SrcBuilderObj = new SourceBuilder(this.DBConnection, this.DBQueries);
            string Name = string.Empty;
            string GID = string.Empty;
            string LanguageCode = this._LanguageCode;
            int NID = 0;
            string ParentID = string.Empty;
            ICType icICType = ICType.Sector;
            //Dictionary<string, string> CParent = new Dictionary<string, string>();

            bool ISGlobal = false;

            this.ICDetails = new Dictionary<string, IndicatorClassificationInfo>();

            foreach (SDMXObjectModel.Structure.CategorySchemeType CodeListObj in this._DSDStructure.Structures.CategorySchemes)
            {
                icICType = (ICType)DIQueries.ICTypeText.Values.IndexOf("'" + CodeListObj.id.Substring(3) + "'");

                if (icICType != ICType.Source)
                {
                    foreach (SDMXObjectModel.Structure.CategoryType CatTypeCode in CodeListObj.Items)
                    {
                        GID = CatTypeCode.id;
                        Name = string.Empty;
                        ISGlobal = false;

                        foreach (TextType IndTextType in CatTypeCode.Name)
                        {
                            if (IndTextType.lang.Trim('_') == this._LanguageCode)
                            {
                                Name = IndTextType.Value;
                                break;
                            }
                        }

                        foreach (AnnotationType AnnType in CatTypeCode.Annotations)
                        {
                            if (AnnType.AnnotationTitle == SDMXConstants.Annotations.IsGlobal)
                            {
                                foreach (TextType AnnTextType in AnnType.AnnotationText)
                                {
                                    ISGlobal = Convert.ToBoolean(AnnTextType.Value);
                                    break;
                                }
                            }
                        }

                        ParentID = "-1";

                        if (!this.ICDetails.ContainsKey(GID))
                        {
                            IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                            TableInfoObj.GID = GID;
                            TableInfoObj.Name = Name;
                            TableInfoObj.Type = icICType;
                            TableInfoObj.Parent = new IndicatorClassificationInfo();
                            TableInfoObj.Parent.GID = ParentID;
                            this.ICDetails.Add(GID, TableInfoObj);
                        }
                        // Read each child IC for current IC
                        this.Get_ICChain(GID, icICType, CatTypeCode);
                    }
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// Get_IC_Collection method..
        /// </summary>
        /// <param name="this._DSDStructure"></param>
        /// <returns></returns>
        private void Get_IC()
        {
            //'Dictionary<string, int> RetVal = new Dictionary<string, int>();
            // IndicatorClassificationBuilder BuilderObj = new IndicatorClassificationBuilder(this.DBConnection, this.DBQueries);
            //SourceBuilder SrcBuilderObj = new SourceBuilder(this.DBConnection, this.DBQueries);
            string Name         = string.Empty;
            string GID          = string.Empty;
            string LanguageCode = this._LanguageCode;
            int    NID          = 0;
            string ParentID     = string.Empty;
            ICType icICType     = ICType.Sector;
            //Dictionary<string, string> CParent = new Dictionary<string, string>();

            bool ISGlobal = false;

            this.ICDetails = new Dictionary <string, IndicatorClassificationInfo>();

            foreach (SDMXObjectModel.Structure.CategorySchemeType CodeListObj in this._DSDStructure.Structures.CategorySchemes)
            {
                icICType = (ICType)DIQueries.ICTypeText.Values.IndexOf("'" + CodeListObj.id.Substring(3) + "'");

                if (icICType != ICType.Source)
                {
                    foreach (SDMXObjectModel.Structure.CategoryType CatTypeCode in CodeListObj.Items)
                    {
                        GID      = CatTypeCode.id;
                        Name     = string.Empty;
                        ISGlobal = false;

                        foreach (TextType IndTextType in CatTypeCode.Name)
                        {
                            if (IndTextType.lang.Trim('_') == this._LanguageCode)
                            {
                                Name = IndTextType.Value;
                                break;
                            }
                        }

                        foreach (AnnotationType AnnType in CatTypeCode.Annotations)
                        {
                            if (AnnType.AnnotationTitle == SDMXConstants.Annotations.IsGlobal)
                            {
                                foreach (TextType AnnTextType in AnnType.AnnotationText)
                                {
                                    ISGlobal = Convert.ToBoolean(AnnTextType.Value);
                                    break;
                                }
                            }
                        }

                        ParentID = "-1";

                        if (!this.ICDetails.ContainsKey(GID))
                        {
                            IndicatorClassificationInfo TableInfoObj = new IndicatorClassificationInfo();
                            TableInfoObj.GID        = GID;
                            TableInfoObj.Name       = Name;
                            TableInfoObj.Type       = icICType;
                            TableInfoObj.Parent     = new IndicatorClassificationInfo();
                            TableInfoObj.Parent.GID = ParentID;
                            this.ICDetails.Add(GID, TableInfoObj);
                        }
                        // Read each child IC for current IC
                        this.Get_ICChain(GID, icICType, CatTypeCode);
                    }
                }
            }
        }
コード例 #27
0
ファイル: ICSource.cs プロジェクト: SDRC-India/sdrcdevinfo
        private IndicatorClassificationInfo GetICInfo(DataRow row)
        {
            IndicatorClassificationInfo RetVal;

            try
            {
                //get unit from source table
                RetVal = new IndicatorClassificationInfo();
                RetVal.Name = DICommon.RemoveQuotes(row[IndicatorClassifications.ICName].ToString());
                RetVal.GID = row[IndicatorClassifications.ICGId].ToString();
                RetVal.IsGlobal = Convert.ToBoolean(row[IndicatorClassifications.ICGlobal]);
                RetVal.ClassificationInfo = DICommon.RemoveQuotes(Convert.ToString(row[IndicatorClassifications.ICInfo]));
                RetVal.Nid = Convert.ToInt32(row[IndicatorClassifications.ICNId]);
                RetVal.Parent = new IndicatorClassificationInfo();
                RetVal.Parent.Nid = Convert.ToInt32(row[IndicatorClassifications.ICParent_NId]);
            }
            catch (Exception ex)
            {
                RetVal = null;
                ExceptionFacade.ThrowException(ex);
            }
            return RetVal;
        }
コード例 #28
0
        /// <summary>
        /// To Import indicator classification into database or template
        /// </summary>
        /// <param name="ICInfo">Instance of IndicatorClassificationInfo</param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns>new indicator classification nid</returns>
        public int ImportIndicatorClassification(IndicatorClassificationInfo ICInfo, int NidInSourceDB, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int       RetVal        = -1;
            bool      ISTrgICGlobal = false;
            DataTable TempTable;

            try
            {
                //check item is already exist in database or not
                RetVal = this.GetIndicatorClassificationNid(ICInfo.GID, ICInfo.Name, ICInfo.Parent.Nid, ICInfo.Type);

                if (RetVal > 0)
                {
                    // check target ic is global
                    TempTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, RetVal.ToString(), FieldSelection.Light));
                    if (TempTable.Rows.Count > 0)
                    {
                        ISTrgICGlobal = Convert.ToBoolean(TempTable.Rows[0][IndicatorClassifications.ICGlobal]);
                    }

                    // if target item is  not global
                    if (!ISTrgICGlobal)
                    {
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateIC(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode,
                                                                                                             ICInfo.Name, ICInfo.GID, ICInfo.IsGlobal, ICInfo.Parent.Nid, ICInfo.ClassificationInfo, ICInfo.Type, RetVal));
                    }
                }
                else
                {
                    if (this.InsertIntoDatabase(ICInfo))
                    {
                        //get nid
                        RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY"));
                    }
                }

                // update UT_CF_FLOWCHART table
                if (ICInfo.Type == ICType.CF)
                {
                    string NewXMLText = "<?xml version=\"1.0\"?><!--AddFlow.net diagram--><AddFlow Nodes=\"1\" Links=\"0\"><Version>1.5.2.0</Version></AddFlow>";

                    DataTable SrcCFTable = null;
                    DataTable TrgCFTable = null;

                    try
                    {
                        // get node where URL ==NidInSourceDB
                        SrcCFTable = sourceDBConnection.ExecuteDataTable(sourceQurey.IndicatorClassification.GetCFFlowCharts());
                        if (SrcCFTable.Rows.Count > 0)
                        {
                            string SrcXMLString = string.Empty;
                            string TrgXMLString = string.Empty;

                            // get xml from src database
                            SrcXMLString = Convert.ToString(SrcCFTable.Rows[0][CFFlowChart.CF_FlowChart]);

                            XmlDocument SrcXmlDoc = new XmlDocument();
                            SrcXmlDoc.LoadXml(SrcXMLString);
                            SrcXmlDoc.PreserveWhitespace = true;

                            //update Nid in src node
                            XmlNodeList SrcNodeList = SrcXmlDoc.SelectNodes("/AddFlow/Node[./Url='" + NidInSourceDB + "']");
                            SrcNodeList.Item(0).LastChild.InnerText = RetVal.ToString();

                            // get target CF table
                            XmlDocument TrgXmlDoc = new XmlDocument();
                            TrgXmlDoc.PreserveWhitespace = true;
                            TrgCFTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetCFFlowCharts());

                            if (TrgCFTable.Rows.Count > 0)
                            {
                                //update
                                TrgXMLString = Convert.ToString(TrgCFTable.Rows[0][CFFlowChart.CF_FlowChart]);
                                if (string.IsNullOrEmpty(TrgXMLString))
                                {
                                    TrgXMLString = NewXMLText;
                                }
                                TrgXmlDoc.LoadXml(TrgXMLString);

                                XmlNodeList TrgNodeList = TrgXmlDoc.SelectNodes("/AddFlow/Node[./Url='" + RetVal + "']");

                                if (TrgNodeList != null & TrgNodeList.Count > 0)
                                {
                                    TrgXmlDoc.SelectNodes("/AddFlow").Item(0).RemoveChild(TrgNodeList.Item(0));
                                }

                                XmlNode SrcImpNode = SrcXmlDoc.SelectSingleNode("/AddFlow/Node[./Url='" + RetVal + "']");

                                //NewNode

                                XmlNode NewNode = TrgXmlDoc.ImportNode(SrcImpNode, true);

                                TrgXmlDoc.SelectNodes("/AddFlow").Item(0).AppendChild(NewNode);
                                TrgXMLString = DICommon.IndentXMLString(TrgXmlDoc.InnerXml);

                                TrgXMLString = DICommon.RemoveQuotes(TrgXMLString);



                                //TrgXmlDoc.Save("c:\\testtest.xml");
                                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.IndicatorClassification.Update.UpateCFFlowChart(this.DBQueries.TablesName.CFFlowChart, TrgXMLString));
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                //update/insert icon
                DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.IndicatorClassification, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(RetVal);
        }
コード例 #29
0
        private bool UpdateSources(IndicatorClassificationInfo icInfo, int parentNid)
        {
            bool RetVal = false;
            try
            {
                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Source.Update.UpdateSource(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, icInfo.Name, parentNid, icInfo.ISBN, icInfo.Nature));

                RetVal = true;
            }
            catch (Exception)
            {
            }
            return RetVal;
        }
コード例 #30
0
 /// <summary>
 ///To add indicator classification into collection 
 /// </summary>
 /// <param name="icInfo">object of IndicatorClassificationInfo</param>
 private void AddIndicatorIntoCollection(IndicatorClassificationInfo icInfo)
 {
     if (!this.IndicatorClassificationCollection.ContainsKey(icInfo.GID))
     {
         this.IndicatorClassificationCollection.Add(icInfo.GID, icInfo);
     }
 }
コード例 #31
0
ファイル: ICSource.cs プロジェクト: SDRC-India/sdrcdevinfo
        internal int CreateClassificationChainFromExtDB(int srcICNId, int srcParentNId, string srcICGid, string srcICName, ICType srcICType, string srcICInfo, bool isGlobal, DIQueries srcQueries, DIConnection srcDBConnection, DIQueries targetDBQueries, DIConnection targetDBConnection)
        {
            int RetVal;
            //int TrgParentNId;
            //string TrgParentName;
            int NewParentNId;
            DataTable TempTable;
            IndicatorClassificationInfo ICInfo;
            IndicatorClassificationBuilder ClassificationBuilder = new IndicatorClassificationBuilder(targetDBConnection, targetDBQueries);

            // -- STEP 1: If the Parent NID is -1 then create the Classification at the root
            if (srcParentNId == -1)
            {
                // -- Create the Classification

                // --------------------------------------------------------------
                // While importing the Classifications, if the NId of the Source Classification is _
                // the same as that of the one created, then the Duplicate check fails and a duplicate
                // classification getscreated. PASS -99 as the first parameter to the calling function
                // --------------------------------------------------------------
                ICInfo = new IndicatorClassificationInfo();
                ICInfo.Parent = new IndicatorClassificationInfo();
                ICInfo.Parent.Nid = srcParentNId;
                ICInfo.Nid = srcICNId;
                ICInfo.Name = srcICName;
                ICInfo.ClassificationInfo = srcICInfo;
                ICInfo.GID = srcICGid;
                ICInfo.IsGlobal = isGlobal;
                ICInfo.Type = srcICType;

                RetVal = ClassificationBuilder.ImportIndicatorClassification(ICInfo, srcICNId, srcQueries, srcDBConnection);

            }

            else
            {
                // -- STEP 2: If the Parent is not -1 then check for the existence of the Parent and then create the Classification
                // Classification can only be created if the parent exists
                // -- STEP 2.1: If the Parent Exists then create the Classification under that parent
                // -- STEP 2.2: If the Parent does not Exist then create the Parent first and then the Classification under that parent

                // -- STEP 2: Check the existence of the Parent in the Target Database
                // -- get the parent from the source database

                TempTable = srcDBConnection.ExecuteDataTable(srcQueries.IndicatorClassification.GetIC(FilterFieldType.NId, srcParentNId.ToString(), srcICType, FieldSelection.Heavy));
                {

                    // --------------------------------------------------------------
                    // While importing the Classifications, if the NId of the Source Classification is _
                    // the same as that of the one created, then the Duplicate check fails and a duplicate
                    // classification getscreated. PASS -99 as the first parameter to the calling function
                    // --------------------------------------------------------------
                    DataRow Row;
                    string ClassificationInfo = string.Empty;
                    Row = TempTable.Rows[0];
                    ClassificationInfo = Convert.ToString(Row[IndicatorClassifications.ICInfo]);

                    NewParentNId = CreateClassificationChainFromExtDB(
                       Convert.ToInt32(Row[IndicatorClassifications.ICNId]),
                       Convert.ToInt32(Row[IndicatorClassifications.ICParent_NId]),
                        Row[IndicatorClassifications.ICGId].ToString(),
                        Row[IndicatorClassifications.ICName].ToString(),
                        srcICType,
                        ClassificationInfo, Convert.ToBoolean(Row[IndicatorClassifications.ICGlobal]), srcQueries, srcDBConnection, targetDBQueries, targetDBConnection); ;
                }

                // -- Create the Child Now
                ICInfo = new IndicatorClassificationInfo();
                ICInfo.Parent = new IndicatorClassificationInfo();
                ICInfo.Parent.Nid = NewParentNId;       // set new parent nid
                ICInfo.Nid = srcICNId;
                ICInfo.Name = srcICName;
                ICInfo.ClassificationInfo = srcICInfo;
                ICInfo.GID = srcICGid;
                ICInfo.IsGlobal = isGlobal;
                ICInfo.Type = srcICType;

                RetVal = ClassificationBuilder.ImportIndicatorClassification(ICInfo, srcICNId, srcQueries, srcDBConnection);

            }

            //import ic and ius relationship into indicator_classification_IUS table
            ClassificationBuilder.ImportICAndIUSRelations(srcICNId, RetVal, ICInfo.Type, srcQueries, srcDBConnection);

            return RetVal;
        }
コード例 #32
0
        /// <summary>
        /// To check existance of Indicator classification first into collection then into database
        /// </summary>
        /// <param name="icInfo">object of IndicatorClassificationInfo</param>
        /// <returns>Nid</returns>
        private int CheckIndicatorClassificationExists(IndicatorClassificationInfo icInfo)
        {
            int RetVal = 0;

            //Step 1: check source exists in source collection
            RetVal = this.CheckIndicatorClassificationInCollection(icInfo.GID);

            //Step 2: check indicator exists in database.
            if (RetVal <= 0)
            {
                RetVal = this.GetIndicatorClassificationNid(icInfo.GID, icInfo.Name, icInfo.Parent.Nid, icInfo.Type);
            }

            return RetVal;
        }
コード例 #33
0
        /// <summary>
        /// Update Sources
        /// </summary>
        /// <param name="sourceName"></param>
        /// <param name="sourceNid"></param>
        /// <returns></returns>
        public bool UpdateSources(string sourceName, int nid, int parentNid,string ISBN,string nature)
        {
            bool RetVal = false;
            int SourceParentNid;

            if (this.CheckSourceExists(sourceName) <= 0)
            {
                IndicatorClassificationInfo ICInfo = new IndicatorClassificationInfo();
                ICInfo.Parent = new IndicatorClassificationInfo();

                ICInfo.Parent.Name = GetSourceParentFrmSourceName(sourceName);
                ICInfo.Name = sourceName;
                ICInfo.Type = ICType.Source;
                ICInfo.ISBN = ISBN;
                ICInfo.Nature = nature;

                //-- Update Publisher
                this.UpdateSources(ICInfo.Parent, parentNid);

                SourceParentNid = this.CheckPublisherExistsInDB(sourceName);
                if (SourceParentNid == -1)
                {
                    //-- Update Source
                    this.UpdateSources(ICInfo, nid);

                }
                RetVal = true;
            }
            else
            {
                //-- Update Publisher
                this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Source.Update.UpdateSource(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, sourceName, nid, ISBN, nature));
            }
            return RetVal;
        }
コード例 #34
0
        /// <summary>
        /// To Import indicator classification into database or template
        /// </summary>
        /// <param name="ICInfo">Instance of IndicatorClassificationInfo</param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns>new indicator classification nid</returns>
        public int ImportIndicatorClassification(ICType icType, string icName, string icGId, string parentICGId, bool isGlobal)
        {
            int       RetVal        = -1;
            bool      ISTrgICGlobal = false;
            DataTable TempTable;
            IndicatorClassificationInfo ICInfo = new IndicatorClassificationInfo(icName, icType, isGlobal, 0);

            ICInfo.GID = icGId;
            string LangCode = this.DBQueries.LanguageCode;

            try
            {
                ICInfo.Parent = new IndicatorClassificationInfo();
                if (parentICGId == "-1")
                {
                    ICInfo.Parent.Nid = -1;
                }
                else
                {
                    ICInfo.Parent.GID = parentICGId;
                    ICInfo.Parent.Nid = this.GetNidByGID(parentICGId, icType);
                }
                //check item is already exist in database or not
                RetVal = this.GetIndicatorClassificationNid(ICInfo.GID, ICInfo.Name, ICInfo.Parent.Nid, ICInfo.Type);

                if (RetVal > 0)
                {
                    if (!this.DBQueries.LanguageCode.StartsWith("_"))
                    {
                        LangCode = "_" + LangCode;
                    }

                    // check target ic is global
                    TempTable = this.DBConnection.ExecuteDataTable(this.DBQueries.IndicatorClassification.GetIC(FilterFieldType.NId, RetVal.ToString(), FieldSelection.Light));
                    if (TempTable.Rows.Count > 0)
                    {
                        ISTrgICGlobal = Convert.ToBoolean(TempTable.Rows[0][IndicatorClassifications.ICGlobal]);
                    }

                    // if target item is  not global
                    if (!ISTrgICGlobal)
                    {
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateIC(this.DBQueries.DataPrefix, LangCode,
                                                                                                             ICInfo.Name, ICInfo.GID, ICInfo.IsGlobal, ICInfo.Parent.Nid, ICInfo.ClassificationInfo, ICInfo.Type, RetVal));
                    }
                }
                else
                {
                    if (this.InsertIntoDatabase(ICInfo))
                    {
                        //get nid
                        RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY"));
                    }
                }

                // update UT_CF_FLOWCHART table
                if (ICInfo.Type == ICType.CF)
                {
                    //--
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(RetVal);
        }