public void InvalidateCachingAllNodes( ) { DataList.Clear(); foreach (TreeConfigNode configNode in ConfigList.Values) { try { if (configNode.InnerData != null && configNode.ParentNode != null) { DataView view = DataCachingProvider.TryToGetDataView(configNode.InnerData.TableName, false); BusinessObjectController Controller = BusinessControllerFactory.GetBusinessController(configNode.InnerData.TableName); //DataSet ds=Controller.GetAllObjects(); //if ( ds!=null&&ds.Tables.Count>0 ) //{ foreach (DataRow dr in view.Table.Rows) { BusinessObject obj = Controller.GetObjectFromDataRow(dr); if (obj != null) { ABCTreeListNode node = new ABCTreeListNode(null, configNode.InnerData.Name, obj); node.Manager = this; node.CachingNode(); } } // } } } catch (Exception ex) { } } }
public void Invalidate(DataTable table, String strObjectName) { InvalidateCachingAllNodes(); RootData = new ABCTreeListNode(null, null, null); RootData.Manager = this; if (RootConfig.ChildrenNodes.ContainsKey(strObjectName)) { String strTableName = RootConfig.ChildrenNodes[strObjectName].InnerData.TableName; BusinessObjectController Controller = BusinessControllerFactory.GetBusinessController(strTableName); foreach (DataRow dr in table.Rows) { BusinessObject objChild = Controller.GetObjectFromDataRow(dr); if (objChild != null) { ABCTreeListNode node = new ABCTreeListNode(RootData, strObjectName, objChild); node.CachingNode(); } } } ExpandDataAll(); TreeList.InnerTreeList.DataSource = RootData; TreeList.InnerTreeList.RefreshDataSource(); }
public void Append(DataSet ds) { if (ds == null || ds.Tables.Count <= 0) { return; } foreach (DataRow row in ds.Tables[0].Rows) { BusinessObject objItemInfo = (BusinessObject)Controller.GetObjectFromDataRow(row); if (objItemInfo != null) { this.Add((T)objItemInfo); BackupInnerList.Add((T)objItemInfo.Clone()); } } this.ResetBindings(); }
public void RefreshCachingNodes(TreeConfigNode configNode) { try { if (configNode.InnerData != null && configNode.ParentNode != null) { Dictionary <Guid, ABCTreeListNode> innerList = null; if (this.DataList.TryGetValue(configNode.InnerData.Name, out innerList) == false) { innerList = new Dictionary <Guid, ABCTreeListNode>(); this.DataList.Add(configNode.InnerData.Name, innerList); } DataView view = DataCachingProvider.TryToGetDataView(configNode.InnerData.TableName, false); BusinessObjectController Controller = BusinessControllerFactory.GetBusinessController(configNode.InnerData.TableName); String strPK = DataStructureProvider.GetPrimaryKeyColumn(configNode.InnerData.TableName); foreach (DataRow dr in view.Table.Rows) { BusinessObject obj = Controller.GetObjectFromDataRow(dr); if (obj != null) { Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, strPK)); if (innerList.ContainsKey(iID) == false) { ABCTreeListNode node = new ABCTreeListNode(null, configNode.InnerData.Name, obj); node.Manager = this; node.CachingNode(); } else { innerList[iID].InnerData = obj; } } } } } catch (Exception ex) { } }
public static void RefreshLookupTable(String strTableName) { bool isUpdate = false; lock ( LookupTables ) { LoadLookupTable(strTableName); if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colUpdateTime) && LastUpdateTimes.ContainsKey(strTableName)) { #region Has 'UpdateTime' DateTime lastTimeInDB = TimeProvider.GetTableLastUpdateTime(strTableName); DataTable lookupTable = LookupTables[strTableName]; DateTime lastTimeInApp = LastUpdateTimes[strTableName]; if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colABCStatus)) { #region Has 'ABCStatus' if (lastTimeInDB > lastTimeInApp) { #region Refresh Modified Items String strQuery = String.Format(@"SELECT * FROM {0} WHERE ABCStatus ='Alive' AND {1}", strTableName, TimeProvider.GenCompareDateTime(ABCCommon.ABCConstString.colUpdateTime, ">", lastTimeInApp)); DataSet ds = DataQueryProvider.CompanyDatabaseHelper.RunQuery(strQuery); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { BusinessObjectController controller = BusinessControllerFactory.GetBusinessController(strTableName); String strPK = DataStructureProvider.GetPrimaryKeyColumn(strTableName); foreach (DataRow row in ds.Tables[0].Rows) { #region Row BusinessObject obj = (BusinessObject)controller.GetObjectFromDataRow(row); Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, strPK)); DataRow[] rows = lookupTable.Select(String.Format("{0}='{1}'", strPK, iID)); if (rows.Length == 0) // new { lookupTable.ImportRow(row); } else { DataRow dr = rows[0]; int index = lookupTable.Rows.IndexOf(dr); if (DataStructureProvider.IsExistABCStatus(obj.AATableName) && ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colABCStatus).ToString().Equals(ABCCommon.ABCConstString.ABCStatusDeleted)) //delete { lookupTable.Rows.RemoveAt(index); } else //update { object[] lstArr = new object[row.ItemArray.Length]; row.ItemArray.CopyTo(lstArr, 0); lookupTable.Rows[index].ItemArray = lstArr; } } #endregion } isUpdate = true; } #endregion } #endregion } else { #region Without 'ABCStatus' if (lastTimeInDB > lastTimeInApp || TimeProvider.GetRecordCountOfTable(strTableName) != lookupTable.Rows.Count) { DataSet ds = BusinessControllerFactory.GetBusinessController(strTableName).GetDataSetAllObjects(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { lookupTable.Rows.Clear(); foreach (DataRow dr in ds.Tables[0].Rows) { lookupTable.ImportRow(dr); } isUpdate = true; } } #endregion } LastUpdateTimes[strTableName] = lastTimeInDB; #endregion } else { #region Without 'UpdateTime' DataTable lookupTable = LookupTables[strTableName]; if (TimeProvider.GetRecordCountOfTable(strTableName) != lookupTable.Rows.Count) { DataSet ds = BusinessControllerFactory.GetBusinessController(strTableName).GetDataSetAllObjects(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { lookupTable.Rows.Clear(); foreach (DataRow dr in ds.Tables[0].Rows) { lookupTable.ImportRow(dr); } isUpdate = true; } } #endregion } } if (isUpdate && RefreshTableMethods.ContainsKey(strTableName)) { foreach (MethodInfo method in RefreshTableMethods[strTableName]) { method.Invoke(null, new object[] {}); } } }