Esempio n. 1
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;
        }
Esempio n. 2
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;
        }
Esempio n. 3
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);
        }