コード例 #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>
 /// Creates Icon tables for all available language
 /// </summary>
 /// <param name="dbConnection"></param>
 /// <param name="dbQueries"></param>
 /// <param name="forOnlineDB"></param>
 public static void CreateIconsTblsForAllLngs(DIConnection dbConnection, DIQueries dbQueries, bool forOnlineDB)
 {
     if (DIIcons.IsIconsTblExists(dbQueries.TablesName.Icons, dbConnection) == false)
     {
         try
         {
             //-- create Icon table
             dbConnection.ExecuteNonQuery(DIIcons.CreateIconsTbl(dbQueries.TablesName.Icons, forOnlineDB));
         }
         catch (Exception ex)
         {
             throw new ApplicationException(ex.Message);
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Imports metadata from the source database into current database
        /// </summary>
        /// <param name="srcConnection"></param>
        /// <param name="srcQueries"></param>
        /// <param name="srcElementNid"></param>
        /// <param name="trgElementNid"></param>
        /// <param name="categoryType"></param>
        /// <param name="metadataType"></param>
        /// <param name="iconType"></param>
        public void ImportMetadata(DIConnection srcConnection, DIQueries srcQueries, int srcElementNid, int trgElementNid, MetadataElementType categoryType, MetaDataType metadataType, IconElementType iconType)
        {
            string    SrcCategoryGID   = string.Empty;
            string    MetadataText     = string.Empty;
            int       TrgCategoryNid   = 0;
            DataTable TrgCategoryTable = null;
            Dictionary <String, String> OldIconNIdnNewIconNId = new Dictionary <string, string>();

            try
            {
                // Get target Category table
                TrgCategoryTable = this.DBConnection.ExecuteDataTable(this.DBQueries.Metadata_Category.GetMetadataCategories(FilterFieldType.Type, DIQueries.MetadataElementTypeText[categoryType]));

                // update metadata icon in DICon table
                OldIconNIdnNewIconNId = DIIcons.ImportElement(srcElementNid, trgElementNid, iconType, srcQueries, srcConnection, this.DBQueries, this.DBConnection);



                //get source metadata reports
                foreach (DataRow SrcRow in srcConnection.ExecuteDataTable(srcQueries.MetadataReport.GetMetadataReportsByTargetNid(srcElementNid.ToString(), categoryType)).Rows)
                {
                    SrcCategoryGID = Convert.ToString(SrcRow[Metadata_Category.CategoryGId]);

                    // check source category GID exists in current database
                    // Import metadta report only if category exists in current database
                    foreach (DataRow TrgCategoryRow in TrgCategoryTable.Select(Metadata_Category.CategoryGId + "='" + DIQueries.RemoveQuotesForSqlQuery(SrcCategoryGID) + "' "))
                    {
                        MetadataText = Convert.ToString(SrcRow[MetadataReport.Metadata]);

                        // Update IconNids in metadata if exists
                        foreach (string OldIconName in OldIconNIdnNewIconNId.Keys)
                        {
                            MetadataText = MetadataText.Replace(OldIconName, OldIconNIdnNewIconNId[OldIconName].ToString());
                        }

                        TrgCategoryNid = Convert.ToInt32(TrgCategoryRow[Metadata_Category.CategoryNId]);
                        this.InsertORUpdateMetadataInfo(metadataType, TrgCategoryNid.ToString(), trgElementNid, MetadataText);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.ExceptionFacade.ThrowException(ex);
            }
        }
コード例 #4
0
ファイル: MapBuilder.cs プロジェクト: dovanduy/sdrcdevinfo
        /// <summary>
        /// Clear all map and their dependencies & relationship from database
        /// </summary>
        public void ClearMap()
        {
            DevInfo.Lib.DI_LibDAL.Queries.Area.Delete AreaDelete = new DevInfo.Lib.DI_LibDAL.Queries.Area.Delete(new DITables(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode));

            //-- Clear all associated metadata icons
            DIIcons.ClearIcon(this.DBConnection, this.DBQueries.DataPrefix, IconElementType.MetadataArea);

            //-- Clear all record from Area_Map_Metadata table (languages based tables)
            this.ClearAreaMapMetadata();

            //-- Clear all associated record from Area_Map table
            this.DBConnection.ExecuteNonQuery(AreaDelete.ClearAreaMap());

            //-- Clear all records from Area_Feature_Type table
            this.DBConnection.ExecuteNonQuery(AreaDelete.ClearAreaFeatureType());

            //-- Clear layer record from Area_Map_Layer master table
            this.DBConnection.ExecuteNonQuery(AreaDelete.ClearAreaMapLayer());
        }
コード例 #5
0
ファイル: MapBuilder.cs プロジェクト: dovanduy/sdrcdevinfo
        /// <summary>
        /// Delete Map layer and all associated dependencies & relationships
        /// </summary>
        /// <param name="layerNId"></param>
        public void DeleteMap(string layerNIds)
        {
            DevInfo.Lib.DI_LibDAL.Queries.Area.Delete AreaDelete = new DevInfo.Lib.DI_LibDAL.Queries.Area.Delete(new DITables(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode));

            //-- Delete all associated metadata icons
            DIIcons.DeleteIcon(this.DBConnection, this.DBQueries.DataPrefix, layerNIds, IconElementType.MetadataArea);

            //-- Delete all associated record from Metdata table (languages based tables)
            this.DeleteAreaMapMetaData(layerNIds);

            //-- Delete all associated record from AreaMap table
            this.DBConnection.ExecuteNonQuery(AreaDelete.DeleteAreaMap(layerNIds.ToString()));

            // TODO Area feature type - Not to be implemented now as there is no interface to enter records into Area_Feature_Type table
            // When a record is deleted in AreaMap table, get Area_Map.Feature_Type_NId
            // If Area_Map.Feature_Type_NId not associated to any other layer then delete record in Area_Feature_Type.Feature_Type_NId (language based table)

            //-- Delete layer record from AreaMapLayer master table
            this.DBConnection.ExecuteNonQuery(AreaDelete.DeleteAreaMapLayer(layerNIds.ToString()));
        }
コード例 #6
0
        /// <summary>
        /// Dictionary containing old IconNId as key and new IconNId as value.
        /// This information shall be utilised to update metadata xml being inserted / updated
        /// </summary>
        /// <param name="NidInSourceDB"></param>
        /// <param name="NidInTargetDB"></param>
        /// <param name="elementType"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="SourceDBConnection"></param>
        /// <param name="targetQurey"></param>
        /// <param name="TargetDBConnection"></param>
        /// <returns>
        /// </returns>
        /// <remarks></remarks>
        public static Dictionary <string, string> ImportElement(int NidInSourceDB, int NidInTargetDB, IconElementType elementType, DIQueries sourceQurey, DIConnection sourceDBConnection, DIQueries targetQurey, DIConnection targetDBConnection)
        {
            Dictionary <string, string> RetVal = new Dictionary <string, string>();

            string    ElementValue = DIIcons.Elements[elementType];
            string    SqlQuery     = string.Empty;
            DataTable IconsDatatable;
            string    OldIconNId = string.Empty;
            string    NewIconNId = string.Empty;

            try {
                if ((sourceDBConnection != null))
                {
                    if (DIIcons.IsIconsTblExists(sourceQurey.TablesName.Icons, sourceDBConnection))
                    {
                        //-- In Target Database: delete records from UT_Icon table if Icon is already associated with given Element Type
                        SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Icon.Delete.DeleteIcon(targetQurey.DataPrefix, ElementValue, NidInTargetDB.ToString());
                        targetDBConnection.ExecuteNonQuery(SqlQuery);


                        //-- In Source Database: check Icon is associated with the given Element type in UT_ICon table
                        SqlQuery       = sourceQurey.Icon.GetIcon(NidInSourceDB.ToString(), ElementValue);
                        IconsDatatable = sourceDBConnection.ExecuteDataTable(SqlQuery);

                        //-- If associated, then copy it it from Source database into target database
                        foreach (DataRow Row in IconsDatatable.Rows)
                        {
                            //-- Insert Icon and get new IconNId
                            NewIconNId = DIIcons.InsertIcon(targetDBConnection, targetQurey, (byte[])(Row["Element_Icon"]), Row["Icon_Type"].ToString(), Convert.ToInt32(Row["Icon_Dim_W"]), Convert.ToInt32(Row["Icon_Dim_H"]), ElementValue, Convert.ToString(NidInTargetDB)).ToString();

                            //-- Add Item to Dictionary with New IconNId as Key and Old IconNId as Value
                            RetVal.Add(IMG_PREFIX + Row["Icon_NId"].ToString() + ".", IMG_PREFIX + NewIconNId + ".");
                        }
                    }
                }
            }
            catch (Exception ex) {
                throw new ApplicationException(ex.Message);
            }
            return(RetVal);
        }
コード例 #7
0
        /// <summary>
        /// To import indicator information from mapped indicator
        /// </summary>
        /// <param name="indicatorInfo"></param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="NidInTrgDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns></returns>
        public int ImportIndicatorFrmMappedIndicator(IndicatorInfo indicatorInfo, int NidInSourceDB, int NidInTrgDB, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int       RetVal       = -1;
            string    metadataInfo = string.Empty;
            string    SqlString    = string.Empty;
            DataRow   Row;
            DataTable TempTable;
            Dictionary <String, String> OldIconNId_NewIconNId = new Dictionary <string, string>();
            MetaDataBuilder             MetaDataBuilderObj;
            IndicatorInfo TrgIndicatorInfo;

            try
            {
                // set RetVal to targetNID
                RetVal = NidInTrgDB;

                if (RetVal > 0)
                {
                    TrgIndicatorInfo = this.GetIndicatorInfo(FilterFieldType.NId, RetVal.ToString(), FieldSelection.Light);

                    // dont import if trg indicator is global but source indicator is local
                    if (TrgIndicatorInfo.Global & indicatorInfo.Global == false)
                    {
                        // dont import if trg indicator is global but source indicator is local
                    }
                    else
                    {
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Indicator.Update.UpdateByNid(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, indicatorInfo.Name, indicatorInfo.GID, indicatorInfo.Global, indicatorInfo.Info, RetVal));
                    }
                }


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

                OldIconNId_NewIconNId = DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.MetadataIndicator, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection);

                // get metadata info.
                metadataInfo = indicatorInfo.Info;

                // Update IconNids in xml if exists
                foreach (string OldIconName in OldIconNId_NewIconNId.Keys)
                {
                    metadataInfo = metadataInfo.Replace(OldIconName, OldIconNId_NewIconNId[OldIconName].ToString());
                }

                metadataInfo = DICommon.CheckNConvertMetadataXml(metadataInfo);
                // Update Metadata
                this.DBConnection.ExecuteNonQuery(DALQueries.Indicator.Update.UpdateIndicatorInfo(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, DICommon.RemoveQuotes(metadataInfo), FilterFieldType.GId, indicatorInfo.GID));


                // -- insert records in xslt tables

                SqlString = sourceQurey.Xslt.GetXSLT(NidInSourceDB.ToString(), MetadataElementType.Indicator);
                TempTable = sourceDBConnection.ExecuteDataTable(SqlString);


                if (TempTable.Rows.Count > 0)
                {
                    Row = TempTable.Rows[0];
                    MetaDataBuilderObj = new MetaDataBuilder(this.DBConnection, this.DBQueries);
                    MetaDataBuilderObj.ImportTransformInfo(Row[XSLT.XSLTText].ToString(), Row[XSLT.XSLTFile].ToString(), RetVal.ToString(), MetadataElementType.Indicator);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(RetVal);
        }
コード例 #8
0
        /// <summary>
        /// To import indicator into template or database
        /// </summary>
        /// <param name="indicatorInfo"></param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns></returns>
        public int ImportIndicator(IndicatorInfo sourceIndicatorInfo, int NidInSourceDB, DIQueries sourceQurey, DIConnection sourceDBConnection, bool importIndicatorInfoAlso)
        {
            int       RetVal       = -1;
            string    metadataInfo = string.Empty;
            string    SqlString    = string.Empty;
            DataRow   Row;
            DataTable TempTable;
            //Dictionary<String, String> OldIconNId_NewIconNId = new Dictionary<string, string>();
            //MetaDataBuilder MetaDataBuilderObj;
            DI7MetaDataBuilder MetadataBuilderObj = null;
            IndicatorInfo      TrgIndicatorInfo;

            try
            {
                //check Indicator already exists in database or not

                RetVal = this.GetIndicatorNid(sourceIndicatorInfo.GID, sourceIndicatorInfo.Name);

                if (RetVal > 0)
                {
                    TrgIndicatorInfo = this.GetIndicatorInfo(FilterFieldType.NId, RetVal.ToString(), FieldSelection.Heavy);

                    // dont import if trg indicator is global but source indicator is local
                    if (TrgIndicatorInfo.Global & sourceIndicatorInfo.Global == false)
                    {
                        // dont import if trg indicator is global but source indicator is local
                    }
                    else
                    {
                        sourceIndicatorInfo.Info = DICommon.CheckNConvertMetadataXml(sourceIndicatorInfo.Info);
                        //update the gid,name and global on the basis of nid
                        this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Indicator.Update.UpdateByNid(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, sourceIndicatorInfo.Name, sourceIndicatorInfo.GID, sourceIndicatorInfo.Global, sourceIndicatorInfo.Info, RetVal, sourceIndicatorInfo.HighIsGood));
                    }
                }
                else if (importIndicatorInfoAlso)
                {
                    if (this.InsertIntoDatabase(sourceIndicatorInfo))
                    {
                        //get nid
                        RetVal = Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery("SELECT @@IDENTITY"));
                    }
                }

                if (RetVal > 0)
                {
                    //update/insert icon
                    DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.Indicator, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection);


                    // import metadata
                    MetadataBuilderObj = new DI7MetaDataBuilder(this.DBConnection, this.DBQueries);
                    MetadataBuilderObj.ImportMetadata(sourceDBConnection, sourceQurey, NidInSourceDB, RetVal, MetadataElementType.Indicator, MetaDataType.Indicator, IconElementType.MetadataIndicator);

                    //////// -- insert records in xslt tables
                    //////SqlString = sourceQurey.Xslt.GetXSLT(NidInSourceDB.ToString(), MetadataElementType.Indicator);
                    //////TempTable = sourceDBConnection.ExecuteDataTable(SqlString);


                    //////if (TempTable.Rows.Count > 0)
                    //////{
                    //////    Row = TempTable.Rows[0];
                    //////    MetaDataBuilderObj = new MetaDataBuilder(this.DBConnection, this.DBQueries);
                    //////    MetaDataBuilderObj.ImportTransformInfo(Row[XSLT.XSLTText].ToString(), Row[XSLT.XSLTFile].ToString(), RetVal.ToString(), MetadataElementType.Indicator);
                    //////}
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(RetVal);
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: SourceBuilder.cs プロジェクト: dovanduy/sdrcdevinfo
        /// <summary>
        /// To import source into template or database
        /// </summary>
        /// <param name="sourceInfo"></param>
        /// <param name="NidInSourceDB"></param>
        /// <param name="sourceQurey"></param>
        /// <param name="sourceDBConnection"></param>
        /// <returns></returns>
        public int ImportSource(SourceInfo sourceInfo, int NidInSourceDB, DIQueries sourceQurey, DIConnection sourceDBConnection)
        {
            int       RetVal       = -1;
            string    MetadataInfo = string.Empty;
            string    SqlString    = string.Empty;
            string    Publisher    = string.Empty;
            int       ParentNid    = -1;
            DataRow   Row;
            DataTable TempTable;
            Dictionary <String, String> OldIconNId_NewIconNId = new Dictionary <string, string>();
            DI7MetaDataBuilder          SourceMetadataBuilder = null;

            try
            {
                //check source already exists in database or not
                RetVal = this.GetSourceNid(sourceInfo.Name);

                if (RetVal > 0)
                {
                    // if source indicator is global
                    if (sourceInfo.Global)
                    {
                        // do nothing
                    }
                }
                else
                {
                    RetVal = this.CheckNCreateSource(sourceInfo.Name, sourceInfo.ISBN, sourceInfo.Nature);
                }

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

                // import metadata reports from source database into current database
                SourceMetadataBuilder = new DI7MetaDataBuilder(this.DBConnection, this.DBQueries);
                SourceMetadataBuilder.ImportMetadata(sourceDBConnection, sourceQurey, NidInSourceDB, RetVal, MetadataElementType.Source, MetaDataType.Source, IconElementType.MetadataSource);

                //OldIconNId_NewIconNId = DIIcons.ImportElement(NidInSourceDB, RetVal, IconElementType.MetadataSource, sourceQurey, sourceDBConnection, this.DBQueries, this.DBConnection);

                //// get metadata info.
                //MetadataInfo = sourceInfo.Info;

                //// Update IconNids in xml if exists
                //foreach (string OldIconName in OldIconNId_NewIconNId.Keys)
                //{
                //    MetadataInfo = MetadataInfo.Replace(OldIconName, OldIconNId_NewIconNId[OldIconName].ToString());
                //}
                //MetadataInfo = DICommon.CheckNConvertMetadataXml(MetadataInfo);
                //// Update Metadata
                //this.DBConnection.ExecuteNonQuery(DALQueries.IndicatorClassification.Update.UpdateICInfo(this.DBQueries.DataPrefix, this.DBQueries.LanguageCode, DICommon.RemoveQuotes(MetadataInfo), ICType.Source, RetVal));

                //// -- insert records in xslt tables
                //SqlString = sourceQurey.Xslt.GetXSLT(NidInSourceDB.ToString(), MetadataElementType.Source);
                //TempTable = sourceDBConnection.ExecuteDataTable(SqlString);


                //if (TempTable.Rows.Count > 0)
                //{
                //    Row = TempTable.Rows[0];
                //    MetaDataBuilderObj = new MetaDataBuilder(this.DBConnection, this.DBQueries);
                //    MetaDataBuilderObj.ImportTransformInfo(Row[XSLT.XSLTText].ToString(), Row[XSLT.XSLTFile].ToString(), RetVal.ToString(), MetadataElementType.Source);
                //}
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(RetVal);
        }