public static GECompanyUnitsInfo GetCompanyUnit(String strRealTableName, Guid realCompanyUnitID) { if (DataStructureProvider.IsExistedTable(strRealTableName)) { BusinessObject obj = BusinessControllerFactory.GetBusinessController(strRealTableName).GetObjectByID(realCompanyUnitID); return(GetCompanyUnit(obj)); } return(null); }
public static void SynchronizeTablePermission( ) { GEPermissionTablesController permissionCtrl = new GEPermissionTablesController(); String strQuery = String.Format(@"DELETE FROM GEPermissionTables WHERE FK_GEPermissionID NOT IN (SELECT GEPermissionID FROM GEPermissions)"); BusinessObjectController.RunQuery(strQuery); foreach (GEPermissionsInfo permission in new GEPermissionsController().GetListAllObjects()) { #region Table Dictionary <String, GEPermissionTablesInfo> lstTables = new Dictionary <string, GEPermissionTablesInfo>(); foreach (GEPermissionTablesInfo tableInfo in permissionCtrl.GetListByForeignKey("FK_GEPermissionID", permission.GEPermissionID).Cast <GEPermissionTablesInfo>().ToList()) { if (lstTables.ContainsKey(tableInfo.TableName) == false) { if (DataStructureProvider.IsExistedTable(tableInfo.TableName)) { lstTables.Add(tableInfo.TableName, tableInfo); } else { permissionCtrl.DeleteObject(tableInfo); } } } foreach (String strTableName in DataStructureProvider.DataTablesList.Keys) { if (lstTables.ContainsKey(strTableName) == false) { GEPermissionTablesInfo tableInfo = new GEPermissionTablesInfo(); tableInfo.FK_STTableConfigID = DataConfigProvider.TableConfigList[strTableName].ConfigID; tableInfo.TableName = strTableName; tableInfo.FK_GEPermissionID = permission.GEPermissionID; tableInfo.AllowView = true; tableInfo.AllowNew = true; tableInfo.AllowEdit = true; tableInfo.AllowDelete = true; permissionCtrl.CreateObject(tableInfo); lstTables.Add(tableInfo.TableName, tableInfo); } } #endregion } }
public static double GetCredit(Guid partnerID, CreditConfigType configType) { double amt = 0; foreach (CRCreditConfigsInfo config in GetCreditConfigs(configType)) { String strFKPartnerIDCol = config.PartnerIDField; if (String.IsNullOrWhiteSpace(strFKPartnerIDCol)) { strFKPartnerIDCol = "FK_MAPartnerID"; } String strQuery = QueryGenerator.GenSelect(config.TableName, String.Format("SUM({0})", config.AmtFCField), true); strQuery = QueryGenerator.AddCondition(strQuery, config.ConditionString); if (DataStructureProvider.IsTableColumn(config.TableName, strFKPartnerIDCol)) { strQuery = QueryGenerator.AddEqualCondition(strQuery, strFKPartnerIDCol, partnerID); } else { if (DataStructureProvider.IsExistedTable(config.ParentTableName)) { if (DataStructureProvider.IsTableColumn(config.ParentTableName, strFKPartnerIDCol)) { String strFK = DataStructureProvider.GetForeignKeyOfTableName(config.TableName, config.ParentTableName); String strQuery2 = QueryGenerator.GenSelect(config.ParentTableName, DataStructureProvider.GetPrimaryKeyColumn(config.ParentTableName), true); strQuery2 = QueryGenerator.AddEqualCondition(strQuery2, strFKPartnerIDCol, partnerID); strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} IN ({1})", strFK, strQuery2)); } } } object obj = BusinessObjectController.GetData(strQuery); if (obj != null && obj != DBNull.Value) { amt += Convert.ToDouble(obj); } } return(amt); }
public static BusinessObject GetCachedBusinessObject(String strTableName, Guid iID) { if (String.IsNullOrWhiteSpace(strTableName)) { return(null); } if (!DataStructureProvider.IsExistedTable(strTableName)) { return(null); } DataView view = TryToGetDataView(strTableName, false); DataRow[] rows = view.Table.Select(String.Format("{0} = '{1}'", DataStructureProvider.GetPrimaryKeyColumn(strTableName), iID)); if (rows.Length <= 0) { return(null); } return(BusinessControllerFactory.GetBusinessController(strTableName).GetObjectFromDataRow(rows[0])); }
public static AccrossStructInfo GetAccrossStructInfo(String strTableName, Guid iFieldValue, String strFieldString, String strIDTableName) { if (String.IsNullOrWhiteSpace(strFieldString)) { return(null); } String[] strArr = strFieldString.Split(':'); if (DataStructureProvider.IsForeignKey(strTableName, strArr[0]) == false && strArr[0] != "ID") { return(null); } AccrossStructInfo result = new AccrossStructInfo(); if (strArr[0] == "ID" && !String.IsNullOrWhiteSpace(strIDTableName)) { result.TableName = strIDTableName; } else { result.TableName = DataStructureProvider.GetTableNameOfForeignKey(strTableName, strArr[0]); } result.TableID = iFieldValue; result.FieldName = String.Empty; if (!DataStructureProvider.IsExistedTable(result.TableName)) { return(null); } BusinessObject objTable = GetCachedBusinessObject(result.TableName, result.TableID); if (objTable == null) { return(null); } for (int i = 1; i < strArr.Length; i++) { result.FieldName = strArr[i]; if (result.FieldName == "ID" && DataStructureProvider.IsTableColumn(result.TableName, "TableName")) { object objTemp = ABCBusinessEntities.ABCDynamicInvoker.GetValue(objTable, "TableName"); if (objTemp == null) { break; } result.TableName = objTemp.ToString(); objTemp = ABCBusinessEntities.ABCDynamicInvoker.GetValue(objTable, result.FieldName); if (objTemp == null) { break; } result.TableID = ABCHelper.DataConverter.ConvertToGuid(objTemp); } else { if (DataStructureProvider.IsForeignKey(result.TableName, result.FieldName) == false) { break; } result.TableName = DataStructureProvider.GetTableNameOfForeignKey(result.TableName, result.FieldName); object objValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(objTable, result.FieldName); if (objValue == null) { break; } result.TableID = ABCHelper.DataConverter.ConvertToGuid(objValue); objTable = GetCachedBusinessObject(result.TableName, result.TableID); if (objTable == null) { break; } } result.FieldName = String.Empty; } if (DataStructureProvider.IsForeignKey(result.TableName, result.FieldName) || result.FieldName == String.Empty) { if (DataStructureProvider.IsForeignKey(result.TableName, result.FieldName)) { result.TableName = DataStructureProvider.GetTableNameOfForeignKey(result.TableName, result.FieldName); } result.FieldName = DataStructureProvider.GetDisplayColumn(result.TableName); } if (String.IsNullOrWhiteSpace(result.FieldName)) { result.FieldName = DataStructureProvider.GetDisplayColumn(result.TableName); } if (String.IsNullOrWhiteSpace(result.FieldName)) { result.FieldName = DataStructureProvider.GetPrimaryKeyColumn(result.TableName); } return(result); }
public static List <CRCreditConfigsInfo> GetCreditConfigs(CreditConfigType type) { List <CRCreditConfigsInfo> lstConfigs = new CRCreditConfigsController().GetListAllObjects().Cast <CRCreditConfigsInfo>().ToList(); lstConfigs = lstConfigs.Where(t => !String.IsNullOrWhiteSpace(t.TableName) && DataStructureProvider.IsExistedTable(t.TableName) && !String.IsNullOrWhiteSpace(t.PartnerIDField) && (!String.IsNullOrWhiteSpace(t.AmtField) || !String.IsNullOrWhiteSpace(t.AmtFCField))).ToList(); if ((type & CreditConfigType.Increase) == CreditConfigType.Increase) { lstConfigs = lstConfigs.Where(t => t.IsIncrease).ToList(); } if ((type & CreditConfigType.Decrease) == CreditConfigType.Decrease) { lstConfigs = lstConfigs.Where(t => t.IsDecrease).ToList(); } if ((type & CreditConfigType.Purchase) == CreditConfigType.Purchase) { lstConfigs = lstConfigs.Where(t => t.IsPurchase).ToList(); } if ((type & CreditConfigType.Sale) == CreditConfigType.Sale) { lstConfigs = lstConfigs.Where(t => t.IsSale).ToList(); } return(lstConfigs); }
public static void CreateNewNotifyFromComment(String strTableName, Guid iID) { if (DataStructureProvider.IsExistedTable(strTableName) == false) { return; } String strIDCol = DataStructureProvider.GetPrimaryKeyColumn(strTableName); #region Get Users List <String> lstUsers = new List <string>(); DataSet ds = BusinessObjectController.RunQuery(String.Format(@"SELECT CreateUser FROM GEComments WHERE TableName ='{0}' AND ID = '{1}' GROUP BY CreateUser", strTableName, iID)); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { if (lstUsers.Contains(dr[0].ToString()) == false) { lstUsers.Add(dr[0].ToString()); } } } ds = BusinessObjectController.RunQuery(String.Format(@"SELECT TagString FROM GEComments WHERE TableName ='{0}' AND ID = '{1}' AND TagString IS NOT NULL AND TagString NOT LIKE '' GROUP BY TagString", strTableName, iID)); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { if (dr[0] != null && dr[0] != DBNull.Value && String.IsNullOrWhiteSpace(dr[0].ToString()) == false) { string[] arr = { "::" }; arr = dr[0].ToString().Split(arr, StringSplitOptions.None); for (int i = 0; i < arr.Length; i++) { if (lstUsers.Contains(arr[i]) == false) { lstUsers.Add(arr[i]); } } } } } if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colCreateUser)) { ds = BusinessObjectController.RunQuery(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}'", ABCCommon.ABCConstString.colCreateUser, strTableName, strIDCol, iID)); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { object objCreateUser = ds.Tables[0].Rows[0][0]; if (objCreateUser != null && objCreateUser != DBNull.Value && lstUsers.Contains(objCreateUser.ToString()) == false) { lstUsers.Add(objCreateUser.ToString()); } } } if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colUpdateUser)) { ds = BusinessObjectController.RunQuery(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}'", ABCCommon.ABCConstString.colUpdateUser, strTableName, strIDCol, iID)); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { object objUpdateUser = ds.Tables[0].Rows[0][0]; if (objUpdateUser != null && objUpdateUser != DBNull.Value && lstUsers.Contains(objUpdateUser.ToString()) == false) { lstUsers.Add(objUpdateUser.ToString()); } } } #endregion String strTitle = DataConfigProvider.GetTableCaption(strTableName); String strDisplayCol = DataStructureProvider.GetDisplayColumn(strTableName); object obj = BusinessObjectController.GetData(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}' ", strDisplayCol, strTableName, strIDCol, iID)); if (obj != null && obj != DBNull.Value) { strTitle = strTitle + " : " + obj.ToString(); } foreach (String strUser in lstUsers) { if (strUser != ABCUserProvider.CurrentUserName) { CreateNewNotify(strUser, strTitle, "", strTableName, iID, ""); } } }