예제 #1
0
        private static List <string> GetExistingExDatabaseTableNameAndStructure(List <string> exChangeDbTableList, Dictionary <string, List <PdmEntityColumnClrDto> > dictExchangeTableColumnDto)
        {
            using (SqlConnection conn = new SqlConnection(PLM_ExChangeDatabase_ConnectionString))
            {
                conn.Open();

                string QueryExchangeTable = string.Format(@" select distinct Left(  sysobj .Name , 50 ) AS [ExChangeTableName] from sysObjects  as sysobj 
            inner join dbo.sysColumns  as sysColumn on sysColumn.ID =  sysobj .ID
            where   sysobj .name like '{0}%' and sysColumn.Name in ( '{1}', '{2}' ,'{3}' ,'{4}' ,'{5}')",
                                                          PLMConstantString.EX_PLM_Import_Prefix,
                                                          PLMConstantString.ExchangeRowDataERPFlagColumn,
                                                          PLMConstantString.ExchangeRowDataPLMFlagColumn,
                                                          PLMConstantString.ExchangeRowDataERPExportDateTimeColumn,
                                                          PLMConstantString.ExchangeRowDataPLMImportDateTimeColumn,
                                                          PLMConstantString.ExchangeRowDataPLMPrimayKeyColumn

                                                          );

                CLROutput.Output("QueryExchangeTable=" + QueryExchangeTable);

                exChangeDbTableList = DataAcessHelper.GetDataTableQueryResult(conn, QueryExchangeTable).AsEnumerable().Select(o => (o["ExChangeTableName"] as string).Trim().ToLowerInvariant()).ToList();



                foreach (string exchangeTable in exChangeDbTableList)
                {
                    List <PdmEntityColumnClrDto> exEntituyColumn = PLMSEntityClrBL.GetExchangeDatabaseTableColumnDto(conn, exchangeTable);
                    dictExchangeTableColumnDto.Add(exchangeTable, exEntituyColumn);
                }
            }
            return(exChangeDbTableList);
        }
예제 #2
0
        //TODO list--------
        public static void GenerateUserDefinTableScript()
        {
            List <int> userDefineEntityIds = null;

            using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
            {
                conn.Open();

                int       userDefineEntityType  = (int)EmEntityType.UserDefineTable;
                string    qeuryUserDefineEntity = @" SELECT EntityID FROM pdmentity WHERE EntityType =  " + userDefineEntityType;
                DataTable resultTabel           = DataAcessHelper.GetDataTableQueryResult(conn, qeuryUserDefineEntity);
                userDefineEntityIds = resultTabel.GetDistinctOneColumnValueIds("EntityID").ToList();
            }


            // List<PdmEntityClrUserDefineDto> listPdmEntityClrDto = null;

            List <PdmClrEntitySimpleStructureDto> listPdmEntityClrDto = PLMSEntityClrBL.GetEntityAndColumnStrcutureInfoList(userDefineEntityIds);

            using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
            {
                conn.Open();



                string aEntiValueScript = string.Empty;
                foreach (PdmClrEntitySimpleStructureDto aEntityDTO in listPdmEntityClrDto)
                {
                    //  int entityId = aEntityDTO.EntityId;
                    //  string entityCode = ;
                    aEntityDTO.EntityCode = DataTableUtility.FilterSQLDBInvalidChar(aEntityDTO.EntityCode);

                    GenetateEntityDTOQuery(aEntityDTO, conn);

                    string deleteOldEntityTable = @"delete  [pdmDWTabGridScriptSetting] where EntityID=" + aEntityDTO.EntityId;


                    // string sqlSelect = aEntityDTO.SQLSelect;
                    string IntoUseDefineTablName = " insert   into " + aEntityDTO.DWUserDefineTableName + aEntityDTO.SQLSelect;


                    // save to dbms

                    string     deleteAndInsert = deleteOldEntityTable + System.Environment.NewLine + @" insert into " + PLMConstantString.PLM_DW_TabGridScripContainerTable + " ( EntityID,EntityName,InserIntoSQLScript,DWTableName,RootLevelSelectSQLScript)    values (@EntityID,@EntityName,@queryResult,@DWTableName,@SQLRootLevelSelect)";
                    SqlCommand cmd             = new  SqlCommand(deleteAndInsert, conn);
                    cmd.Parameters.Add(new SqlParameter("@EntityID", aEntityDTO.EntityId));
                    cmd.Parameters.Add(new SqlParameter("@EntityName", DataTableUtility.FilterSQLDBInvalidChar(aEntityDTO.EntityCode)));
                    cmd.Parameters.Add(new SqlParameter("@queryResult", IntoUseDefineTablName));
                    cmd.Parameters.Add(new SqlParameter("@DWTableName", aEntityDTO.DWUserDefineTableName));
                    cmd.Parameters.Add(new SqlParameter("@SQLRootLevelSelect", aEntityDTO.SQLSelect));
                    CLROutput.OutputDebug("aEntityDTO.entityCode" + aEntityDTO.EntityCode);
                    CLROutput.OutputDebug("aEntityDTO.SQLSelect" + aEntityDTO.SQLSelect);

                    cmd.ExecuteNonQuery();
                } // end of for eahc entity
            }
        }
예제 #3
0
        // Big size
        private static DataTable GetSizeRotateTableWithSizerunId(int sizerunValueId)
        {
            var sizeEntity = PdmCacheManager.DictCodeKeyPdmEntityBlCache[EmEntityCode.SizeRunDetail.ToString()];

            string connectionInfo = PLMSEntityClrBL.GetConnectionInfoWithCode(sizeEntity.DataSourceFrom);

            string querySizeRotate = @" select SizeRunRotateID ,SizeOrder  ,SizeName  from tblSizeRunRotate where SizeRunId = @sizeRunId order by SizeOrder ";

            // need to filter
            using (SqlConnection conn = new SqlConnection(connectionInfo))
            {
                //SqlContext.
                conn.Open();
                SqlCommand   cmdSize = new SqlCommand(querySizeRotate, conn);
                SqlParameter paraSizeRunrunIdValueId = new SqlParameter("@sizeRunId", sizerunValueId);
                cmdSize.Parameters.Add(paraSizeRunrunIdValueId);
                DataTable sizeRotateTable = DataAcessHelper.GetDataTableQueryResult(cmdSize);
                return(sizeRotateTable);
            }
        }
예제 #4
0
        public static void TestExchangeDBConnection()
        {
            //step1: Get all Ex-change Tables from ex-Chang Dababae
            List <string> exChangeDbTableList = null;
            Dictionary <string, List <PdmEntityColumnClrDto> > dictExchangeTableColumnDto = new Dictionary <string, List <PdmEntityColumnClrDto> >();

            exChangeDbTableList = GetExistingExDatabaseTableNameAndStructure(exChangeDbTableList, dictExchangeTableColumnDto);

            //Step2: insert new Ex-change table
            AddNewExchangeTableToPLMSUserDefineEntity(exChangeDbTableList, dictExchangeTableColumnDto);

            // step2-2 update strcutre


            // Get all Refresh Userdefinetable from PLMS

            string queryllEntityImport = @"  select  EntityID from pdmEntity where IsImport =1 and EntityID > 3000 ";

            List <PdmEntityClrDto> plmImportEntityDtoList = null;

            using (SqlConnection conn = new SqlConnection(PLMSDWStoredProcedures.PLM_APP_ConnectionString))
            {
                List <int> enityIds = DataAcessHelper.GetDataTableQueryResult(conn, queryllEntityImport).AsEnumerable().Select(o => (int)o["EntityID"]).ToList();;

                plmImportEntityDtoList = PLMSEntityClrBL.GetEntityAndColumnStrcutureInfoList(enityIds, conn);
            }



            //Step3 Transfer NewRecord FromERP To PLM
            TransferNewRecordFromERPToPLM(plmImportEntityDtoList);

            ////Step4; upadte modfied fileds
            UpdateModifyRecordFromERPToPLM(plmImportEntityDtoList);

            //ste5: Delete--toDO

            //Step 6: update FK relation Ship
            UpdateForeignKeyRelationFromERPToPLM(plmImportEntityDtoList);
        }
        public static DataTable RetrieveDataTableReferenceSimpleDcutValue(IEnumerable <string> referenceIds, List <PdmBlockSubItemClrDto> subItemList, bool isShowLookUpItem = true)
        {
            Dictionary <int, int> dictSuibtemIdControType = new Dictionary <int, int>();

            foreach (var blockSubitem in subItemList)
            {
                dictSuibtemIdControType.Add(blockSubitem.SubItemId, blockSubitem.ControlType);
            }

            Dictionary <int, Dictionary <int, object> > toReturn = new Dictionary <int, Dictionary <int, object> >();

            //if (referenceIds == null || referenceIds.Count() == 0)
            //    return simpleDcuTable;

            var subitemIds = subItemList.Select(o => o.SubItemId).ToList();

            if (subitemIds.Count == 0)
            {
                return(new DataTable());
            }

            string referenceInClause = DataAcessHelper.GenerateColumnInClauseWithAndCondition(referenceIds, GridColumnConstantName.ProductReferenceID, true);

            if (referenceIds.Count() == 1 && referenceIds.ElementAt(0) == "-2")
            {
                referenceInClause = string.Empty;
            }


            string subitemIdInclause = DataAcessHelper.GenerateColumnInClauseWithAndCondition(subitemIds, GridColumnConstantName.SubItemID, false);

            StringBuilder aQuery = new StringBuilder();

            //   aQuery.Append( string" SELECT ProductReferenceID,BlockID, GridID,  RowID,  RowValueGUID ,Sort,");

            aQuery.Append(" SELECT " +
                          GridColumnConstantName.ProductReferenceID + ", " +
                          GridColumnConstantName.SubItemID + ", " +
                          GridColumnConstantName.ValueText
                          );

            string queryString = aQuery.ToString() + " from pdmSearchSimpleDcuValue where " + subitemIdInclause + referenceInClause;



            DataTable dtSimpleValue;

            var allSubitemeEntityIds = subItemList.Where(o => o.EntityId.HasValue).Select(o => o.EntityId.Value).ToList();
            Dictionary <int, Dictionary <object, string> > dictKeyEntityDictKeyIdDisplayString = PLMSEntityClrBL.GetDictEntityDictDisplayString(allSubitemeEntityIds);



            using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
            {
                conn.Open();
                DataAcessHelper.ExecuteReadUnCommmited(conn);

                dtSimpleValue = DataAcessHelper.GetDataTableQueryResult(conn, queryString);
                // dictKeyEntityDictKeyIdDisplayString = PLMSEntityClrBL.GetDictEntityDictDisplayString(allSubitemeEntityIds, conn);

                DataAcessHelper.ExecuteReadCommmited(conn);
            }

            var subItemQuery = from row in dtSimpleValue.AsDataRowEnumerable()
                               group row by new
            {
                ProductReferenceID = (int)row[GridColumnConstantName.ProductReferenceID]
            } into grp
            orderby grp.Key.ProductReferenceID
                select new
            {
                Key = grp.Key.ProductReferenceID,

                SubitemIDAndValueList = grp.Select(r => new { id = (int)r[GridColumnConstantName.SubItemID], value = r[GridColumnConstantName.ValueText] }),
            };

            DataTable roReturnDcuTable = CreateDataTableStrcutureFromBlockSubitem(subItemList);

            foreach (var o in subItemQuery)
            {
                //Dictionary<int, object> dictSubitemValue = new Dictionary<int, object>();

                DataRow dataRow = roReturnDcuTable.NewRow();
                dataRow[GridColumnConstantName.ProductReferenceID] = o.Key;
                foreach (var subitem in o.SubitemIDAndValueList)
                {
                    object value = ControlTypeValueConverter.ConvertValueToObject(subitem.value, dictSuibtemIdControType[subitem.id]);


                    if (value == null)
                    {
                        dataRow[subitem.id.ToString()] = DBNull.Value;
                    }
                    else
                    {
                        //  CLROutput.Output("convervalue=" + value);
                        dataRow[subitem.id.ToString()] = value;

                        //  CLROutput.Output("dataRow[subitem.id.ToString()]" + dataRow[subitem.id.ToString()]);
                    }
                }

                roReturnDcuTable.Rows.Add(dataRow);
            }

            if (isShowLookUpItem)
            {
                List <PdmBlockSubItemClrDto> dDLSubitemDtoList = subItemList.Where(o => o.ControlType == (int)EmControlType.DDL && o.EntityId.HasValue).ToList();

                foreach (var dictDDLSubitemDto in dDLSubitemDtoList)
                {
                    int    entityId        = dictDDLSubitemDto.EntityId.Value;
                    string stringSubItemId = dictDDLSubitemDto.SubItemId.ToString();
                    if (dictKeyEntityDictKeyIdDisplayString.ContainsKey(entityId))
                    {
                        Dictionary <object, string> lookUpItem = dictKeyEntityDictKeyIdDisplayString[entityId];
                        foreach (DataRow row in roReturnDcuTable.Rows)
                        {
                            int?lookupid = ControlTypeValueConverter.ConvertValueToInt(row[stringSubItemId]);
                            if (lookupid.HasValue)
                            {
                                int idvalue = lookupid.Value;
                                if (lookUpItem.ContainsKey(idvalue))
                                {
                                    row[stringSubItemId] = lookUpItem[idvalue];;

                                    CLROutput.OutputDebug("entityID_idvalue+dislayvalue=" + entityId.ToString() + "_" + idvalue.ToString() + "_" + "_" + lookUpItem[idvalue]);
                                }
                            }
                        }
                    }
                }
            }


            return(roReturnDcuTable);
        }        // key1: blockId, key2:referecne, value
예제 #6
0
        internal static void SetupDataTableDDLLookupValue(List <PdmGridMetaColumnClrDto> columnList, DataTable roReturnDcuTable)
        {
            var allSubitemeEntityIds = columnList.Where(o => o.EntityId.HasValue).Select(o => o.EntityId.Value).ToList();

            Dictionary <int, Dictionary <object, string> > dictKeyEntityDictKeyIdDisplayString = PLMSEntityClrBL.GetDictEntityDictDisplayString(allSubitemeEntityIds);


            var dDLColumnDtoList = columnList.Where(o => o.ColumnTypeId == (int)EmControlType.DDL).ToList();

            foreach (var aDdlColumnDto in dDLColumnDtoList)
            {
                int columnId = aDdlColumnDto.GridColumnId;
                if (aDdlColumnDto.ColumnTypeId == (int)EmControlType.DDL && aDdlColumnDto.EntityId.HasValue)
                {
                    int entityId = aDdlColumnDto.EntityId.Value;

                    if (dictKeyEntityDictKeyIdDisplayString.ContainsKey(entityId))
                    {
                        Dictionary <object, string> lookUpItem = dictKeyEntityDictKeyIdDisplayString[entityId];
                        foreach (DataRow row in roReturnDcuTable.Rows)
                        {
                            string stringColumnId = columnId.ToString();

                            //  CLROutput.Output("stringColumnId=" + stringColumnId);
                            SqlInt32 lookupid = Converter.ToDDLSqlInt32(row[stringColumnId]);
                            if (!lookupid.IsNull)
                            {
                                int idvalue = lookupid.Value;
                                if (lookUpItem.ContainsKey(idvalue))
                                {
                                    row[stringColumnId] = lookUpItem[idvalue];;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        internal static void SetDepdentMasterEntityColumn(PdmGridClrDto aPdmGridEntity, DataTable toReturnDcuTable)
        {
            //var dictSysDefineMasterEntityColumnIdEntityIds = aPdmGridEntity.MasterEntityColumn.Where(col => col.EntityId.HasValue && col.EntityId.Value < 3000).ToDictionary(col => col.GridColumnId, col => col.EntityId.Value);

            Dictionary <int, int> dictUserDefineMasterEntityColumnIdEntityIds = new Dictionary <int, int>();

            foreach (var column in aPdmGridEntity.MasterEntityColumn)
            {
                if (column.EntityId.HasValue)
                {
                    int entityId       = column.EntityId.Value;
                    int masterColumnId = column.GridColumnId;

                    PdmEntityBlClrDto aPdmEntityBlClrDto = PdmCacheManager.DictPdmEntityBlEntity[entityId];
                    if (aPdmEntityBlClrDto.EntityType == (int)EmEntityType.SystemDefineTable)
                    {
                        // int entityId = columnIdEntity.Value;

                        List <string> columnNames = new List <string>();
                        if (aPdmGridEntity.MasterEntityDepdentColumn.ContainsKey(masterColumnId))
                        {
                            columnNames = aPdmGridEntity.MasterEntityDepdentColumn[masterColumnId].Where(o => !string.IsNullOrEmpty(o.InternalCode)).Select(o => o.InternalCode).ToList();
                            DataTable aDtResult = PLMSEntityClrBL.GetMutipleSysDefineEntityRowValue(entityId, columnNames);
                            ProcessSystemDefineEntityColumn(aPdmGridEntity, toReturnDcuTable, aDtResult, masterColumnId);
                        }
                    }
                    else if (aPdmEntityBlClrDto.EntityType == (int)EmEntityType.UserDefineTable)
                    {
                        dictUserDefineMasterEntityColumnIdEntityIds.Add(masterColumnId, entityId);
                    }
                }
            }

            List <int> userDefineColumnIds = new List <int>();

            foreach (var columnIdEntity in dictUserDefineMasterEntityColumnIdEntityIds)
            {
                int masterColumnId = columnIdEntity.Key;
                int entityId       = columnIdEntity.Value;

                var pdmUserDefineEntity = PdmCacheManager.DictPdmEntityBlEntity[entityId];

                if (aPdmGridEntity.MasterEntityDepdentColumn.ContainsKey(masterColumnId))
                {
                    // if (aDtcolumn.UserDefineEntityColumnId.ToString() == dependentEntityColumn.InternalCode)
                    var columnids = aPdmGridEntity.MasterEntityDepdentColumn[masterColumnId]
                                    .Where(o => !string.IsNullOrEmpty(o.InternalCode))
                                    .Select(o => int.Parse(o.InternalCode.Trim()));

                    userDefineColumnIds.AddRange(columnids);
                }
            }
            if (userDefineColumnIds.Count > 0)
            {
                // Key: EntityId, vlaue
                Dictionary <int, List <SimpleUserDefineEntityRow> > result = PLMSEntityClrBL.GetDictEntityUserDefineRows(dictUserDefineMasterEntityColumnIdEntityIds.Values.ToList(), userDefineColumnIds);

                foreach (var columnIdEntity in dictUserDefineMasterEntityColumnIdEntityIds)
                {
                    int masterColumnId = columnIdEntity.Key;
                    int entityId       = columnIdEntity.Value;
                    if (result.ContainsKey(entityId))
                    {
                        List <SimpleUserDefineEntityRow> listRow = result[entityId];

                        CLROutput.OutputDebug("masterColumnId =" + masterColumnId);

                        ProcessUserDefineEntityColumn(aPdmGridEntity, toReturnDcuTable, listRow, masterColumnId);
                    }
                }
            }
        }
예제 #8
0
        private static void UpdateSystemDefineCache(PdmEntityBlClrDto entity)
        {
            int entityId = entity.EntityId;

            CLROutput.OutputDebug("UpdateSystemDefineCache start...  ConnectInfo:" + entity.ConnectInfo);

            // CLROutput.OutputDebug("UpdateSystemDefineCache start...");

            if (!string.IsNullOrEmpty(entity.ConnectInfo))
            {
                //try
                //{
                using (SqlConnection conn = new SqlConnection(entity.ConnectInfo))
                {
                    conn.Open();

                    string lastChange = PdmCacheEntityLookupItem.GetLastChangeCheckSum(conn, entity.SysTableName);

                    //  CLROutput.InsertException(conn, "entity.LastScanCheckSum: " + entity.LastScanCheckSum + "lastChange :" + lastChange);

                    CLROutput.OutputDebug("entity.LastScanCheckSum: " + entity.LastScanCheckSum + "lastChange :" + lastChange);

                    if (lastChange != entity.LastScanCheckSum)
                    {
                        if (DictEntityLookupCache.ContainsKey(entityId))
                        {
                            CLROutput.OutputDebug(" lastChange sysdefine before DictEntityLookupCache " + "__" + entity.EntityCode + "__" + entity.LastScanCheckSum, conn);
                            List <LookupItemDto>        newLookupitem = PdmCacheEntityLookupItem.GetOneSystemDefinTableLookupItems(conn, PLMSEntityClrBL.GetSysDefineQueryIDAndDisplay(entity));
                            Dictionary <object, string> result        = PdmCacheEntityLookupItem.ConvertLookItemToDictionaryItem(newLookupitem);

                            DictEntityLookupCache.Remove(entityId);
                            DictEntityLookupCache.Add(entityId, result);

                            entity.LastScanCheckSum = lastChange;
                            // CLROutput.InsertException(conn, " lastChange sysdefine  after" + "__" + entity.EntityCode + "__" + entity.LastScanCheckSum);
                        }
                    }
                }

                //}
                //catch (Exception ex)
                //{

                //    //using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
                //    //{
                //    //    conn.Open();
                //    //    CLROutput.InsertException(conn, " exception " + entity.EntityId  + "__" + entity.EntityCode   + ex.ToString());

                //    //}

                //}
            }
        }
예제 #9
0
        private static void UpdateUserDefineCache()
        {
            using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
            {
                conn.Open();

                string lastChange = PdmCacheEntityLookupItem.GetLastChangeCheckSum(conn, UserDefineEntityTableName);


                if (lastChange != string.Empty && lastChange != LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum)
                {
                    // CLROutput.InsertException(conn, " lastChange before userdefine " + LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum);

                    Dictionary <int, List <LookupItemDto> > dictUserDefineLookupItem = PLMSEntityClrBL.GetUserDefineEntityDisplayInfoList(UserDefineEntityList, conn);


                    foreach (int entityId in dictUserDefineLookupItem.Keys)
                    {
                        Dictionary <object, string> result = PdmCacheEntityLookupItem.ConvertLookItemToDictionaryItem(dictUserDefineLookupItem[entityId]);

                        // if(
                        DictEntityLookupCache.Remove(entityId);
                        DictEntityLookupCache.Add(entityId, result);
                    }



                    LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum = lastChange;

                    // CLROutput.InsertException(conn, " lastChange userdefine  after" + LastScanUserDefinePdmEntityBlClrDto.LastScanCheckSum);
                }
            }
        }
예제 #10
0
        public static Dictionary <int, List <LookupItemDto> > GetDictEntityLookItemDtoFromDataBase(List <int> entityIDs)
        {
            var discitnEntitIds = entityIDs.Distinct().ToList();
            Dictionary <int, List <LookupItemDto> > dictEntityDisplayInfoList = new Dictionary <int, List <LookupItemDto> >();

            List <PdmEntityBlClrDto> listPdmEntityDto = PdmCacheManager.DictPdmEntityBlEntity.Where(pair => entityIDs.Contains(pair.Key)).Select(pair => pair.Value).ToList();

            Dictionary <string, List <PdmEntityBlClrDto> > dictConnInfoSysDefineEntityList = new Dictionary <string, List <PdmEntityBlClrDto> >();
            List <PdmEntityBlClrDto> userDefineEntityList = new List <PdmEntityBlClrDto>();
            List <PdmEntityBlClrDto> enumEntityList       = new List <PdmEntityBlClrDto>();

            // need to classify entity type !!
            foreach (PdmEntityBlClrDto pdmEntityBlClrDto in listPdmEntityDto)
            {
                //tblCompanySetup=
                if (pdmEntityBlClrDto.EntityType == (int)EmEntityType.SystemDefineTable)
                {
                    // need to filter tblsketch ,tblskech could come fro mother applcation place
                    //if (pdmEntityBlClrDto.EntityCode == EmEntityCode.Sketch.ToString ())
                    //    continue;

                    string connectInfo = PLMSEntityClrBL.GetConnectionInfoWithCode(pdmEntityBlClrDto.DataSourceFrom);
                    //  CLROutput.OutputDebug(pdmEntityBlClrDto.EntityCode + "c?" + connectInfo);


                    pdmEntityBlClrDto.ConnectInfo = connectInfo;

                    //  CLROutput.OutputDebug("pdmEntityBlClrDto.ConnectInfo=" + pdmEntityBlClrDto.ConnectInfo);


                    if (dictConnInfoSysDefineEntityList.ContainsKey(connectInfo))
                    {
                        List <PdmEntityBlClrDto> listEntityDto = dictConnInfoSysDefineEntityList[connectInfo];
                        listEntityDto.Add(pdmEntityBlClrDto);
                    }
                    else // not include conenction info key: first time
                    {
                        List <PdmEntityBlClrDto> listEntityDto = new List <PdmEntityBlClrDto>();
                        dictConnInfoSysDefineEntityList.Add(connectInfo, listEntityDto);
                        listEntityDto.Add(pdmEntityBlClrDto);
                    }
                }
                else if (pdmEntityBlClrDto.EntityType == (int)EmEntityType.UserDefineTable)
                {
                    userDefineEntityList.Add(pdmEntityBlClrDto);
                }
                else if (pdmEntityBlClrDto.EntityType == (int)EmEntityType.PDMEnum)
                {
                    enumEntityList.Add(pdmEntityBlClrDto);
                }
            }


            //
            foreach (string connectInfo in dictConnInfoSysDefineEntityList.Keys)
            {
                using (SqlConnection conn = new SqlConnection(connectInfo))
                {
                    conn.Open();
                    List <PdmEntityBlClrDto> listEntityDto = dictConnInfoSysDefineEntityList[connectInfo];

                    GetSysDefineDictLookItem(conn, dictEntityDisplayInfoList, listEntityDto);
                }
            }

            using (SqlConnection conn = new SqlConnection(PLMConstantString.PLM_APP_ConnectionString))
            {
                conn.Open();
                PLMSEntityClrBL.GetEnumDictLookItemNew(conn, dictEntityDisplayInfoList, enumEntityList);
                PLMSEntityClrBL.GetUserDefineDictLookItem(conn, dictEntityDisplayInfoList, userDefineEntityList);
            }

            return(dictEntityDisplayInfoList);
        }
예제 #11
0
        private static Dictionary <int, List <LookupItemDto> > LoadSysDefineLookupItemFromDabaBase(List <PdmEntityBlClrDto> sysDefineEntityList, SqlConnection conn)
        {
            Dictionary <int, List <LookupItemDto> > toReturn = new Dictionary <int, List <LookupItemDto> >();

            Dictionary <string, string> dictTableNameAndQuery = new Dictionary <string, string>();

            foreach (var aPdmEntityDto in sysDefineEntityList)
            {
                string systemQueryTable = PLMSEntityClrBL.GetSysDefineQueryIDAndDisplay(aPdmEntityDto);

                //    CLROutput.OutputDebug("aPdmEntityDto.SysTableName systemQueryTable" + aPdmEntityDto.EntityId + "=" + systemQueryTable);


                if (string.IsNullOrEmpty(systemQueryTable))
                {
                    continue;
                }

                //    CLROutput.OutputDebug("aPdmEntityDto.SysTableName" + aPdmEntityDto.EntityId + "=" + aPdmEntityDto.EntityCode + aPdmEntityDto.SysTableName);

                if (!String.IsNullOrEmpty(aPdmEntityDto.SysTableName))
                {
                    if (!dictTableNameAndQuery.ContainsKey(aPdmEntityDto.SysTableName))
                    {
                        dictTableNameAndQuery.Add(aPdmEntityDto.SysTableName, systemQueryTable);
                    }
                }
            }


            foreach (string tablname in dictTableNameAndQuery.Keys)
            {
                string queryTAble = dictTableNameAndQuery[tablname];

                List <LookupItemDto> listDto = GetOneSystemDefinTableLookupItems(conn, queryTAble);
                foreach (PdmEntityBlClrDto SysEntityDto in sysDefineEntityList)
                {
                    string sysTableName = SysEntityDto.SysTableName;

                    //  CLROutput.SendDataTable(datatable);

                    if (sysTableName == tablname)
                    {
                        toReturn.Add(SysEntityDto.EntityId, listDto);

                        //  CLROutput.OutputDebug("before EntityCode " + SysEntityDto.EntityCode + " tableName="+ sysTableName + "=" + " lastScaltime=" );
                        //Important
                        //Important
                        string lastScaltime = GetLastChangeCheckSum(conn, tablname);

                        //F**k conn.ConnectionString will retur no password !!!!
                        //  SysEntityDto.ConnectInfo = conn.ConnectionString;

                        CLROutput.OutputDebug("SysEntityDto.ConnectInfo = conn.ConnectionString" + SysEntityDto.ConnectInfo);


                        SysEntityDto.LastScanCheckSum = lastScaltime;

                        CLROutput.OutputDebug(sysTableName + " lastScaltime :" + lastScaltime);
                    }
                }
            }


            return(toReturn);
        }