public static BaseOrganizeEntity GetObjectByName(BaseUserInfo userInfo, string fullName) { BaseOrganizeEntity result = null; string url = BaseSystemInfo.UserCenterHost + "/UserCenterV42/OrganizeService.ashx"; WebClient webClient = new WebClient(); NameValueCollection postValues = new NameValueCollection(); postValues.Add("system", BaseSystemInfo.SoftFullName); postValues.Add("systemCode", BaseSystemInfo.SystemCode); postValues.Add("securityKey", BaseSystemInfo.SecurityKey); postValues.Add("function", "GetObjectByName"); postValues.Add("userInfo", userInfo.Serialize()); postValues.Add("encrypted", true.ToString()); postValues.Add("fullName", SecretUtil.Encrypt(fullName)); // 向服务器发送POST数据 byte[] responseArray = webClient.UploadValues(url, postValues); string response = Encoding.UTF8.GetString(responseArray); if (!string.IsNullOrEmpty(response)) { result = JsonConvert.DeserializeObject <BaseOrganizeEntity>(response); } return(result); }
/// <summary> /// 保存实体修改记录 /// </summary> /// <param name="newEntity">修改前的实体对象</param> /// <param name="oldEntity">修改后的实体对象</param> /// <param name="tableName">表名称</param> public void UpdateEntityLog(BaseOrganizeEntity newEntity, BaseOrganizeEntity oldEntity, string tableName = null) { if (string.IsNullOrEmpty(tableName)) { tableName = this.CurrentTableName + "_LOG"; } BaseModifyRecordManager manager = new BaseModifyRecordManager(this.UserInfo, tableName); foreach (var property in typeof(BaseOrganizeEntity).GetProperties()) { var oldValue = Convert.ToString(property.GetValue(oldEntity, null)); var newValue = Convert.ToString(property.GetValue(newEntity, null)); var fieldDescription = property.GetCustomAttributes(typeof(FieldDescription), false).FirstOrDefault() as FieldDescription; //不记录创建人、修改人、没有修改的记录 if (!fieldDescription.NeedLog || oldValue == newValue) { continue; } var record = new BaseModifyRecordEntity(); record.TableCode = this.CurrentTableName.ToUpper(); record.TableDescription = FieldExtensions.ToDescription(typeof(BaseOrganizeEntity), "TableName"); record.ColumnCode = property.Name.ToUpper(); record.ColumnDescription = fieldDescription.Text; record.RecordKey = oldEntity.Id.ToString(); record.NewValue = newValue; record.OldValue = oldValue; record.IPAddress = Utilities.GetIPAddress(true); manager.Add(record, true, false); } }
/// <summary> /// 更新实体 /// </summary> /// <param name="entity">实体</param> public int UpdateObject(BaseOrganizeEntity entity) { int result = 0; SQLBuilder sqlBuilder = new SQLBuilder(DbHelper); sqlBuilder.BeginUpdate(this.CurrentTableName); this.SetObject(sqlBuilder, entity); if (UserInfo != null) { sqlBuilder.SetValue(BaseOrganizeEntity.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(BaseOrganizeEntity.FieldModifiedBy, UserInfo.RealName); } // 若有修改时间标示,那就按修改时间来,不是按最新的时间来 if (entity.ModifiedOn.HasValue) { sqlBuilder.SetValue(BaseOrganizeEntity.FieldModifiedOn, entity.ModifiedOn.Value); } else { sqlBuilder.SetDBNow(BaseOrganizeEntity.FieldModifiedOn); } sqlBuilder.SetWhere(BaseOrganizeEntity.FieldId, entity.Id); result = sqlBuilder.EndUpdate(); return(result); }
public static BaseOrganizeEntity GetObjectByNameByCache(BaseUserInfo userInfo, string fullName) { BaseOrganizeEntity result = null; string key = "OBN:" + fullName; string id = string.Empty; using (var redisClient = PooledRedisHelper.GetReadOnlyClient()) { id = redisClient.Get <string>(key); } if (!string.IsNullOrEmpty(id)) { key = "O:" + id; result = BaseOrganizeManager.GetCacheByKey(key); } // 远程通过接口获取数据 if (result == null) { result = GetObjectByName(userInfo, fullName); } return(result); }
/// <summary> /// 设置实体 /// </summary> /// <param name="organizeEntity">实体</param> partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseOrganizeEntity entity) { sqlBuilder.SetValue(BaseOrganizeEntity.FieldStatisticalName, entity.StatisticalName); sqlBuilder.SetValue(BaseOrganizeEntity.FieldWeightRatio, entity.WeightRatio); sqlBuilder.SetValue(BaseOrganizeEntity.FieldSendAir, entity.SendAir); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCalculateComeFee, entity.CalculateComeFee); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCalculateReceiveFee, entity.CalculateReceiveFee); sqlBuilder.SetValue(BaseOrganizeEntity.FieldBillBalanceSite, entity.BillBalanceSite); sqlBuilder.SetValue(BaseOrganizeEntity.FieldLevelTwoTransferCenter, entity.LevelTwoTransferCenter); sqlBuilder.SetValue(BaseOrganizeEntity.FieldProvinceSite, entity.ProvinceSite); sqlBuilder.SetValue(BaseOrganizeEntity.FieldBigArea, entity.BigArea); sqlBuilder.SetValue(BaseOrganizeEntity.FieldSendFee, entity.SendFee); sqlBuilder.SetValue(BaseOrganizeEntity.FieldLevelTwoTransferFee, entity.LevelTwoTransferFee); sqlBuilder.SetValue(BaseOrganizeEntity.FieldBillSubsidy, entity.BillSubsidy); sqlBuilder.SetValue(BaseOrganizeEntity.FieldMaster, entity.Master); sqlBuilder.SetValue(BaseOrganizeEntity.FieldMasterMobile, entity.MasterMobile); sqlBuilder.SetValue(BaseOrganizeEntity.FieldMasterQQ, entity.MasterQQ); sqlBuilder.SetValue(BaseOrganizeEntity.FieldManager, entity.Manager); sqlBuilder.SetValue(BaseOrganizeEntity.FieldManagerMobile, entity.ManagerMobile); sqlBuilder.SetValue(BaseOrganizeEntity.FieldManagerQQ, entity.ManagerQQ); sqlBuilder.SetValue(BaseOrganizeEntity.FieldEmergencyCall, entity.EmergencyCall); sqlBuilder.SetValue(BaseOrganizeEntity.FieldBusinessPhone, entity.BusinessPhone); }
public string Add(BaseOrganizeEntity organizeEntity, out string statusCode) { string returnValue = string.Empty; // 检查是否重复 List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldParentId, organizeEntity.ParentId)); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldFullName, organizeEntity.FullName)); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); //注意Access 的时候,类型不匹配,会出错故此将 ID 传入 if (BaseSystemInfo.UserCenterDbType == CurrentDbType.Access) { if (this.Exists(parameters, organizeEntity.Id)) { // 名称已重复 statusCode = StatusCode.ErrorNameExist.ToString(); } else { parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldCode, organizeEntity.Code)); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); if (organizeEntity.Code.Length > 0 && this.Exists(parameters)) { // 编号已重复 statusCode = StatusCode.ErrorCodeExist.ToString(); } else { returnValue = this.AddEntity(organizeEntity); // 运行成功 statusCode = StatusCode.OKAdd.ToString(); } } } else if (this.Exists(parameters)) { // 名称已重复 statusCode = StatusCode.ErrorNameExist.ToString(); } else { parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldCode, organizeEntity.Code)); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); if (organizeEntity.Code.Length > 0 && this.Exists(parameters)) { // 编号已重复 statusCode = StatusCode.ErrorCodeExist.ToString(); } else { returnValue = this.AddEntity(organizeEntity); // 运行成功 statusCode = StatusCode.OKAdd.ToString(); } } return(returnValue); }
public int Update(BaseOrganizeEntity organizeEntity, out string statusCode) { int returnValue = 0; // 检查是否已被其他人修改 //if (DbLogic.IsModifed(DbHelper, BaseOrganizeEntity.TableName, organizeEntity.Id, organizeEntity.ModifiedUserId, organizeEntity.ModifiedOn)) //{ // // 数据已经被修改 // statusCode = StatusCode.ErrorChanged.ToString(); //} //else //{ List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldParentId, organizeEntity.ParentId)); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldFullName, organizeEntity.FullName)); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); if (this.Exists(parameters, organizeEntity.Id)) { // 名称已重复 statusCode = StatusCode.ErrorNameExist.ToString(); } else { // 检查编号是否重复 parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldCode, organizeEntity.Code)); parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); if (organizeEntity.Code.Length > 0 && this.Exists(parameters, organizeEntity.Id)) { // 编号已重复 statusCode = StatusCode.ErrorCodeExist.ToString(); } else { // 1:更新部门的信息 returnValue = this.UpdateEntity(organizeEntity); // 2:组织机构修改时,用户表的公司,部门,工作组数据给同步更新。 BaseUserManager userManager = new BaseUserManager(this.DbHelper, this.UserInfo); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, organizeEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyName, organizeEntity.FullName)); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, organizeEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentName, organizeEntity.FullName)); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, organizeEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupName, organizeEntity.FullName)); // 03:组织机构修改时,文件夹同步更新 BaseFolderManager folderManager = new BaseFolderManager(this.DbHelper, this.UserInfo); folderManager.SetProperty(new KeyValuePair <string, object>(BaseFolderEntity.FieldFolderName, organizeEntity.FullName), new KeyValuePair <string, object>(BaseFolderEntity.FieldId, organizeEntity.Id)); if (returnValue == 1) { statusCode = StatusCode.OKUpdate.ToString(); } else { statusCode = StatusCode.ErrorDeleted.ToString(); } } } //} return(returnValue); }
/// <summary> /// 缓存预热,强制重新缓存 /// </summary> /// <returns>影响行数</returns> public static int CachePreheating() { int result = 0; // 把所有的组织机构都缓存起来的代码 BaseOrganizeManager manager = new BaseOrganizeManager(); using (IDataReader dataReader = manager.ExecuteReader()) { while (dataReader.Read()) { BaseOrganizeEntity entity = BaseEntity.Create <BaseOrganizeEntity>(dataReader, false); if (entity != null) { BaseOrganizeManager.SetCache(entity); string[] systemCodes = BaseSystemManager.GetSystemCodes(); for (int i = 0; i < systemCodes.Length; i++) { // 重置权限缓存数据 BaseOrganizePermissionManager.ResetPermissionByCache(systemCodes[i], entity.Id); } result++; System.Console.WriteLine(result.ToString() + " : " + entity.FullName); } } dataReader.Close(); } return(result); }
/// <summary> /// 某一个网点是否另外一个网点的父级 /// </summary> /// <param name="parentId">父级别主键</param> /// <param name="id">主键盘</param> /// <returns>是父亲节点</returns> public static bool IsParentByCache(string parentId, string id) { bool result = false; // 打开缓存、进行查找 using (var redisClient = PooledRedisHelper.GetReadOnlyClient()) { // 若已经在缓存里保存了,是上级网点、就不用计算了,提高判断的效率 string key = "IsParent:" + parentId + ":" + id; result = redisClient.Get <bool>(key); if (!result) { // 从缓存读取数据、提高读取的效率,这里需要防止死循环,有时候会有脏数据 BaseOrganizeEntity organizeEntity = BaseOrganizeManager.GetObjectByCache(redisClient, id); while (organizeEntity != null && !string.IsNullOrEmpty(organizeEntity.ParentId) && !id.Equals(organizeEntity.ParentId) ) { // 若已经找到了,就退出循环,提高效率 if (organizeEntity.ParentId.Equals(parentId)) { result = true; break; } organizeEntity = BaseOrganizeManager.GetObjectByCache(redisClient, organizeEntity.ParentId); } // 设置一个过期时间,提高效率,10分钟内不需要重复判断,把关系写入缓存数据库里,是否成立都写入缓存服务器里。 redisClient.Set <bool>(key, result, DateTime.Now.AddMinutes(10)); } } return(result); }
public static BaseOrganizeEntity GetObjectByCache(string id, bool fefreshCache = false) { BaseOrganizeEntity result = null; if (!string.IsNullOrEmpty(id)) { string cacheKey = "O:"; cacheKey = cacheKey + id; if (!fefreshCache) { result = GetCacheByKey(cacheKey); } if (result == null) { BaseOrganizeManager manager = new DotNet.Business.BaseOrganizeManager(); result = manager.GetObject(id); // 若是空的不用缓存,继续读取实体 if (result != null) { SetCache(result); } } } return(result); }
/// <summary> /// 更新组织机构 /// </summary> /// <param name="userInfo">用户</param> /// <param name="entity">实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>影响行数</returns> public int Update(BaseUserInfo userInfo, BaseOrganizeEntity entity, out string statusCode, out string statusMessage) { int result = 0; string returnCode = string.Empty; string returnMessage = string.Empty; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) => { // 2015-12-19 吉日嘎拉 网络不稳定,数据获取不完整时,异常时,会引起重大隐患 var manager = new BaseOrganizeManager(dbHelper, userInfo); // result = manager.Update(entity); if (manager.StatusCode.Equals(Status.OKUpdate.ToString())) { // var folderManager = new BaseFolderManager(dbHelper, userInfo); // result = folderManager.SetProperty(entity.Id.ToString(), new KeyValuePair<string, object>(BaseFolderEntity.FieldFolderName, entity.FullName)); } returnCode = manager.StatusCode; returnMessage = manager.StatusMessage; }); statusCode = returnCode; statusMessage = returnMessage; return(result); }
/// <summary> /// 从缓存获取获取实体 /// </summary> /// <param name="id">主键</param> /// <returns>实体</returns> public static BaseOrganizeEntity GetObjectByCache(IRedisClient redisClient, string id) { BaseOrganizeEntity result = null; if (!string.IsNullOrEmpty(id)) { //string cacheKey = "Organize"; string cacheKey = "O:"; cacheKey = cacheKey + id; result = GetCacheByKey(redisClient, cacheKey); if (result == null) { BaseOrganizeManager manager = new DotNet.Business.BaseOrganizeManager(); result = manager.GetObject(id); // 若是空的不用缓存,继续读取实体 if (result != null) { SetCache(result); } } } return(result); }
public static BaseOrganizeEntity GetObjectByNameByCache(string fullName) { BaseOrganizeEntity result = null; // string key = "OrganizeByName:" + fullName; string key = "OBN:" + fullName; string id = string.Empty; using (var redisClient = PooledRedisHelper.GetReadOnlyClient()) { id = redisClient.Get <string>(key); if (!string.IsNullOrWhiteSpace(id)) { result = GetObjectByCache(redisClient, id); } else { // 从数据库读取数据 BaseOrganizeManager organizeManager = new BaseOrganizeManager(); result = organizeManager.GetObjectByName(fullName); // 设置缓存 if (result != null) { SetCache(result); } } } return(result); }
/// <summary> /// 编辑之后,需要重新刷新缓存,否则其他读取数据的地方会乱了,或者不及时了 /// </summary> /// <param name="entity">实体</param> /// <returns>影响行数</returns> public int AfterUpdate(BaseOrganizeEntity entity) { int result = 0; // 用户的缓存需要更新 BaseOrganizeManager.SetCache(entity); return(result); }
public static BaseOrganizeEntity GetObjectByNameByCache(string fullName) { BaseOrganizeEntity result = null; string key = "OrganizeByName" + fullName; result = GetCache(key); return(result); }
/// <summary> /// 获取用户的通知列表 /// </summary> /// <param name="companyId">网点主键</param> /// <param name="parentId"></param> /// <param name="topLimit">获取前几个</param> /// <param name="containContents">是否包含内容</param> /// <returns>通知列表</returns> public List <BaseContactEntity> GetTopListByCompanyId(string companyId, string parentId, int topLimit, bool containContents = false) { List <BaseContactEntity> result = new List <BaseContactEntity>(); // 获取用户信息 string commandText = string.Empty; // 获取用户所在的单位的信息 BaseOrganizeEntity organizeEntity = BaseOrganizeManager.GetObjectByCache(companyId); if (organizeEntity != null) { // 2015-11-26 吉日嘎拉 需要过去数据,最近的30天的数据就可以了,太久了意义不大 commandText = " ( " + BaseContactEntity.FieldCreateOn + " > SYSDATE - 30) AND ((ParentId = '" + parentId + "' AND " + "Enabled = 1 AND DeletionStateCode = 0 AND IsOpen = 1 AND AuditStatus=2) OR (Enabled = 1 AND AuditStatus=2 AND DeletionStateCode = 0 AND Id IN ("; // 所在省 if (!string.IsNullOrEmpty(organizeEntity.ProvinceId)) { commandText += " (SELECT ContactId FROM BaseContactTarget WHERE Category = '0' AND ReceiverId = '" + organizeEntity.ProvinceId + "') "; } // 所在市 if (!string.IsNullOrEmpty(organizeEntity.CityId)) { commandText += " UNION (SELECT ContactId FROM BaseContactTarget WHERE Category = '1' AND ReceiverId = '" + organizeEntity.CityId + "') "; } // 所在县 if (!string.IsNullOrEmpty(organizeEntity.DistrictId)) { commandText += " UNION (SELECT ContactId FROM BaseContactTarget WHERE Category = '2' AND ReceiverId = '" + organizeEntity.DistrictId + "') "; } } // 发给所在单位的 if (!string.IsNullOrEmpty(companyId)) { commandText += " UNION (SELECT ContactId FROM BaseContactTarget WHERE Category = '3' AND ReceiverId = '" + companyId + "')))) "; } string order = BaseContactEntity.FieldPriority + "," + BaseContactEntity.FieldCreateOn + " DESC "; using (IDataReader dataReader = this.ExecuteReaderByWhere(commandText, null, topLimit, order)) { while (dataReader.Read()) { // 2015-11-18 吉日嘎拉 消息的内容不能有,否则会出错,缓存的内容也太大 BaseContactEntity contactEntity = BaseEntity.Create <BaseContactEntity>(dataReader, false); // 是否要内容 if (!containContents) { contactEntity.Contents = null; } result.Add(contactEntity); } } return(result); }
public DataTable GetFullNameDepartment(DataTable dt) { foreach (DataRow dr in dt.Rows) { BaseOrganizeEntity subCompanyNameEntity = this.GetObject(dr[BaseOrganizeEntity.FieldParentId].ToString()); dr[BaseOrganizeEntity.FieldFullName] = subCompanyNameEntity.FullName.ToString() + "--" + dr[BaseOrganizeEntity.FieldFullName].ToString(); BaseOrganizeEntity companyEntity = this.GetObject(subCompanyNameEntity.ParentId); dr[BaseOrganizeEntity.FieldFullName] = companyEntity.FullName.ToString() + "--" + dr[BaseOrganizeEntity.FieldFullName].ToString(); } return(dt); }
public DataTable GetFullNameDepartment(DataTable dataTable) { foreach (DataRow dr in dataTable.Rows) { BaseOrganizeEntity subCompanyNameEntity = DotNetService.Instance.OrganizeService.GetEntity(UserInfo, dr[BaseOrganizeEntity.FieldParentId].ToString()); dr[BaseOrganizeEntity.FieldFullName] = subCompanyNameEntity.FullName.ToString() + "--" + dr[BaseOrganizeEntity.FieldFullName].ToString(); BaseOrganizeEntity companyEntity = DotNetService.Instance.OrganizeService.GetEntity(UserInfo, subCompanyNameEntity.ParentId.ToString()); dr[BaseOrganizeEntity.FieldFullName] = companyEntity.FullName.ToString() + "--" + dr[BaseOrganizeEntity.FieldFullName].ToString(); } return(dataTable); }
/// <summary> /// 设置实体 /// </summary> /// <param name="entity">实体</param> private void SetObject(SQLBuilder sqlBuilder, BaseOrganizeEntity entity) { sqlBuilder.SetValue(BaseOrganizeEntity.FieldParentId, entity.ParentId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldParentName, entity.ParentName); sqlBuilder.SetValue(BaseOrganizeEntity.FieldLayer, entity.Layer); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCode, entity.Code); sqlBuilder.SetValue(BaseOrganizeEntity.FieldShortName, entity.ShortName); sqlBuilder.SetValue(BaseOrganizeEntity.FieldFullName, entity.FullName); sqlBuilder.SetValue(BaseOrganizeEntity.FieldStandardCode, entity.StandardCode); sqlBuilder.SetValue(BaseOrganizeEntity.FieldStandardName, entity.StandardName); sqlBuilder.SetValue(BaseOrganizeEntity.FieldQuickQuery, entity.QuickQuery); sqlBuilder.SetValue(BaseOrganizeEntity.FieldSimpleSpelling, entity.SimpleSpelling); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCategoryCode, entity.CategoryCode); sqlBuilder.SetValue(BaseOrganizeEntity.FieldOuterPhone, entity.OuterPhone); sqlBuilder.SetValue(BaseOrganizeEntity.FieldInnerPhone, entity.InnerPhone); sqlBuilder.SetValue(BaseOrganizeEntity.FieldFax, entity.Fax); sqlBuilder.SetValue(BaseOrganizeEntity.FieldPostalcode, entity.Postalcode); sqlBuilder.SetValue(BaseOrganizeEntity.FieldProvinceId, entity.ProvinceId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldProvince, entity.Province); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCityId, entity.CityId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCity, entity.City); sqlBuilder.SetValue(BaseOrganizeEntity.FieldDistrictId, entity.DistrictId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldDistrict, entity.District); sqlBuilder.SetValue(BaseOrganizeEntity.FieldStreetId, entity.StreetId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldStreet, entity.Street); sqlBuilder.SetValue(BaseOrganizeEntity.FieldAddress, entity.Address); sqlBuilder.SetValue(BaseOrganizeEntity.FieldWeb, entity.Web); sqlBuilder.SetValue(BaseOrganizeEntity.FieldIsInnerOrganize, entity.IsInnerOrganize); sqlBuilder.SetValue(BaseOrganizeEntity.FieldBank, entity.Bank); sqlBuilder.SetValue(BaseOrganizeEntity.FieldBankAccount, entity.BankAccount); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCompanyId, entity.CompanyId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCompanyCode, entity.CompanyCode); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCompanyName, entity.CompanyName); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCostCenter, entity.CostCenter); sqlBuilder.SetValue(BaseOrganizeEntity.FieldCostCenterId, entity.CostCenterId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldFinancialCenter, entity.FinancialCenter); sqlBuilder.SetValue(BaseOrganizeEntity.FieldFinancialCenterId, entity.FinancialCenterId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldManageId, entity.ManageId); sqlBuilder.SetValue(BaseOrganizeEntity.FieldManageName, entity.ManageName); sqlBuilder.SetValue(BaseOrganizeEntity.FieldArea, entity.Area); sqlBuilder.SetValue(BaseOrganizeEntity.FieldJoiningMethods, entity.JoiningMethods); sqlBuilder.SetValue(BaseOrganizeEntity.FieldIsCheckBalance, entity.IsCheckBalance); sqlBuilder.SetValue(BaseOrganizeEntity.FieldDeletionStateCode, entity.DeletionStateCode); sqlBuilder.SetValue(BaseOrganizeEntity.FieldEnabled, entity.Enabled); sqlBuilder.SetValue(BaseOrganizeEntity.FieldSortCode, entity.SortCode); sqlBuilder.SetValue(BaseOrganizeEntity.FieldDescription, entity.Description); SetObjectExpand(sqlBuilder, entity); }
public static BaseOrganizeEntity GetCacheByKey(IRedisClient redisClient, string key) { BaseOrganizeEntity result = null; if (!string.IsNullOrWhiteSpace(key)) { // 2016-01-08 吉日嘎拉 实现只读连接,读写分离 result = redisClient.Get <BaseOrganizeEntity>(key); } return(result); }
/// <summary> /// 添加之后,需要重新刷新缓存,否则其他读取数据的地方会乱了,或者不及时了 /// </summary> /// <param name="entity">实体</param> /// <returns>影响行数</returns> public int AfterAdd(BaseOrganizeEntity entity) { int result = 0; // 2016-01-28 更新用户缓存 // 2016-02-19 宋彪 PooledRedisHelper.GetClient() 改为 PooledRedisHelper.GetSpellingClient() using (var redisClient = PooledRedisHelper.GetSpellingClient()) { BaseOrganizeManager.CachePreheatingSpelling(redisClient, entity); } return(result); }
/// <summary> /// 按名称获取实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="fullName">名称</param> /// <returns>实体</returns> public BaseOrganizeEntity GetObjectByName(BaseUserInfo userInfo, string fullName) { BaseOrganizeEntity entity = null; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) => { var manager = new BaseOrganizeManager(dbHelper, userInfo); entity = manager.GetObjectByName(fullName); }); return(entity); }
public static string GetCodeByCache(string id) { string result = string.Empty; BaseOrganizeEntity entity = GetObjectByCache(id); if (entity != null) { result = entity.Code; } return(result); }
public static string GetIdByCodeByCache(string code) { string result = string.Empty; BaseOrganizeEntity entity = GetObjectByCodeByCache(code); if (entity != null) { result = entity.Id.ToString(); } return(result); }
private int UpdataAuditStatr(string id, string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity) { BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetObject(id); workFlowCurrentEntity.CategoryCode = categoryCode; workFlowCurrentEntity.CategoryFullName = categoryFullName; workFlowCurrentEntity.ObjectId = objectId; workFlowCurrentEntity.ObjectFullName = objectFullName; workFlowCurrentEntity.ProcessId = workFlowStepEntity.ProcessId; workFlowCurrentEntity.ActivityId = workFlowStepEntity.Id; workFlowCurrentEntity.ActivityType = workFlowStepEntity.ActivityType; workFlowCurrentEntity.SendDate = DateTime.Now; workFlowCurrentEntity.AuditDate = DateTime.Now; workFlowCurrentEntity.AuditStatus = AuditStatus.StartAudit.ToString(); workFlowCurrentEntity.AuditStatusName = AuditStatus.StartAudit.ToDescription(); // 是否提交给组织机构审批 workFlowCurrentEntity.ToDepartmentId = workFlowStepEntity.AuditDepartmentId; workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditDepartmentName; // 是否提交给角色审批 workFlowCurrentEntity.ToRoleId = workFlowStepEntity.AuditRoleId; workFlowCurrentEntity.ToRoleRealName = workFlowStepEntity.AuditRoleRealName; // 是否提交给用户审批 workFlowCurrentEntity.ToUserId = workFlowStepEntity.AuditUserId; workFlowCurrentEntity.ToUserRealName = workFlowStepEntity.AuditUserRealName; if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId)) { BaseUserManager userManager = new BaseUserManager(UserInfo); BaseUserEntity userEntity = userManager.GetObject(workFlowStepEntity.AuditUserId); workFlowCurrentEntity.ToUserRealName = userEntity.RealName; // 用户的部门信息需要处理 if (!string.IsNullOrEmpty(userEntity.DepartmentId)) { BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo); BaseOrganizeEntity entity = organizeManager.GetObject(userEntity.DepartmentId); workFlowCurrentEntity.ToDepartmentName = entity.FullName; } } // 当前审核人的信息写入当前工作流 workFlowCurrentEntity.AuditUserId = string.Empty; workFlowCurrentEntity.AuditUserCode = string.Empty; workFlowCurrentEntity.AuditUserRealName = string.Empty; workFlowCurrentEntity.AuditIdea = auditIdea; workFlowCurrentEntity.AuditDate = DateTime.Now; int result = this.UpdateObject(workFlowCurrentEntity); this.AddHistory(workFlowCurrentEntity); return(result); }
private int UpdataAuditStatr(string id, string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity) { BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(id); workFlowCurrentEntity.CategoryCode = categoryCode; workFlowCurrentEntity.CategoryFullName = categoryFullName; workFlowCurrentEntity.ObjectId = objectId; workFlowCurrentEntity.ObjectFullName = objectFullName; workFlowCurrentEntity.WorkFlowId = workFlowStepEntity.WorkFlowId; workFlowCurrentEntity.ActivityId = workFlowStepEntity.Id; workFlowCurrentEntity.SendDate = DateTime.Now; workFlowCurrentEntity.AuditDate = DateTime.Now; workFlowCurrentEntity.AuditStatus = AuditStatus.StartAudit.ToString(); workFlowCurrentEntity.AuditStatusName = AuditStatus.StartAudit.ToDescription(); // 是否提交给组织机构审批 if (!string.IsNullOrEmpty(workFlowStepEntity.AuditDepartmentId)) { workFlowCurrentEntity.ToDepartmentId = workFlowStepEntity.AuditDepartmentId; workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditDepartmentName; } // 是否提交给角色审批 if (!string.IsNullOrEmpty(workFlowStepEntity.AuditRoleId)) { workFlowCurrentEntity.ToDepartmentId = workFlowStepEntity.AuditRoleId; workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditRoleRealName; } // 是否提交给用户审批 if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId)) { BaseUserManager userManager = new BaseUserManager(UserInfo); BaseUserEntity userEntity = userManager.GetEntity(workFlowStepEntity.AuditUserId); workFlowCurrentEntity.ToUserId = workFlowStepEntity.AuditUserId; workFlowCurrentEntity.ToUserRealName = userEntity.RealName; // TODO 用户的部门信息需要处理 if (!string.IsNullOrEmpty(userEntity.DepartmentId)) { BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo); BaseOrganizeEntity organizeEntity = organizeManager.GetEntity(userEntity.DepartmentId); workFlowCurrentEntity.ToDepartmentId = userEntity.DepartmentId; workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName; } } // 当前审核人的信息写入当前工作流 // workFlowCurrentEntity.AuditUserId = this.UserInfo.Id; // workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code; // workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName; workFlowCurrentEntity.AuditIdea = auditIdea; workFlowCurrentEntity.AuditDate = DateTime.Now; return(this.UpdateEntity(workFlowCurrentEntity)); }
public string AddByDetail(string parentId, string code, string fullName, string category, string outerPhone, string innerPhone, string fax, bool enabled, out string statusCode) { BaseOrganizeEntity organizeEntity = new BaseOrganizeEntity(); organizeEntity.ParentId = parentId; organizeEntity.Code = code; organizeEntity.FullName = fullName; organizeEntity.Category = category; organizeEntity.OuterPhone = outerPhone; organizeEntity.InnerPhone = innerPhone; organizeEntity.Fax = fax; organizeEntity.Enabled = enabled ? 1 : 0; return(this.Add(organizeEntity, out statusCode)); }
public string AddByDetail(string parentId, string code, string fullName, string categoryCode, string outerPhone, string innerPhone, string fax, bool enabled) { BaseOrganizeEntity entity = new BaseOrganizeEntity(); entity.ParentId = parentId; entity.Code = code; entity.FullName = fullName; entity.CategoryCode = categoryCode; entity.OuterPhone = outerPhone; entity.InnerPhone = innerPhone; entity.Fax = fax; entity.Enabled = enabled ? 1 : 0; return(this.Add(entity)); }
public static string GetIdByNameByCache(string fullName) { string result = string.Empty; if (!string.IsNullOrEmpty(fullName)) { BaseOrganizeEntity entity = GetObjectByNameByCache(fullName); if (entity != null) { result = entity.Id; } } return(result); }
public static string GetNameByCodeByCache(string code) { string result = string.Empty; if (!string.IsNullOrEmpty(code)) { BaseOrganizeEntity entity = GetObjectByCodeByCache(code); if (entity != null) { result = entity.FullName; } } return(result); }