/// <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);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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);
        }