/// <summary> /// 加载窗体 /// </summary> public override void FormOnLoad() { this.isUserClick = false; this.DTModule = this.GetModuleScope(this.PermissionItemScopeCode); // 公开的就没必要显示了 // BaseBusinessLogic.SetFilter(this.DTModule, BaseModuleEntity.FieldIsPublic, "0"); // 只有有效的才可以显示出来 BaseBusinessLogic.SetFilter(this.DTModule, BaseModuleEntity.FieldEnabled, "1"); this.DTModule.DefaultView.Sort = BaseModuleEntity.FieldSortCode; // 查找 ParentId 字段的值是否在 ID字段 里 // BaseInterfaceLogic.CheckTreeParentId(this.DTModule, BaseModuleEntity.FieldId, BaseModuleEntity.FieldParentId); this.ModuleIds = DotNetService.Instance.PermissionService.GetUserScopeModuleIds(UserInfo, this.ucUser.SelectedId, "Resource.AccessPermission"); // 获得用户的操作权限主键数组 this.PermissionItemIds = DotNetService.Instance.PermissionService.GetUserPermissionItemIds(UserInfo, this.ucUser.SelectedId); // 设置鼠标默认状态,原来的光标状态 this.BindData(true); // 有效性过滤,这个千万不能过滤的,这个过滤了,有效就设置不回来了 // BUBaseBusinessLogic.SetFilter(this.DSModule.Tables[BaseModuleEntity.TableName], BaseModuleEntity.FieldEnabled, "1"); // this.DSModule.Tables[BaseModuleEntity.TableName].AcceptChanges(); //this.tvModule.ExpandAll(); this.isUserClick = true; }
/// <summary> /// 从数据行读取 /// </summary> /// <param name="dataRow">数据行</param> public BaseContactDetailsEntity GetFrom(DataRow dataRow) { this.GetFromExpand(dataRow); this.Id = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldId]); this.ContactId = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldContactId]); this.Category = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldCategory]); this.ReceiverId = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldReceiverId]); this.ReceiverRealName = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldReceiverRealName]); this.IsNew = BaseBusinessLogic.ConvertToInt(dataRow[BaseContactDetailsEntity.FieldIsNew]); this.NewComment = BaseBusinessLogic.ConvertToInt(dataRow[BaseContactDetailsEntity.FieldNewComment]); this.LastViewIP = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldLastViewIP]); this.LastViewDate = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldLastViewDate]); this.Enabled = BaseBusinessLogic.ConvertToInt(dataRow[BaseContactDetailsEntity.FieldEnabled]); this.DeletionStateCode = BaseBusinessLogic.ConvertToInt(dataRow[BaseContactDetailsEntity.FieldDeletionStateCode]); this.SortCode = BaseBusinessLogic.ConvertToInt(dataRow[BaseContactDetailsEntity.FieldSortCode]); this.Description = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldDescription]); this.CreateOn = BaseBusinessLogic.ConvertToDateTime(dataRow[BaseContactDetailsEntity.FieldCreateOn]); this.CreateUserId = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldCreateUserId]); this.CreateBy = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldCreateBy]); this.ModifiedOn = BaseBusinessLogic.ConvertToDateTime(dataRow[BaseContactDetailsEntity.FieldModifiedOn]); this.ModifiedUserId = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldModifiedUserId]); this.ModifiedBy = BaseBusinessLogic.ConvertToString(dataRow[BaseContactDetailsEntity.FieldModifiedBy]); return(this); }
/// <summary> /// 选择用户 /// </summary> /// <param name="close">关闭窗体</param> private void SelectMulti(bool close = true) { if (BaseInterfaceLogic.CheckInputSelectAnyOne(this.grdUser, "colSelected")) { this.SelectedIds = this.GetSelectedIds(); this.SelectedFullName = BaseBusinessLogic.ObjectsToList(this.GetSelectedFullNames()); if (!close) { if (this.OnSelected != null) { // 进行委托处理 if (this.OnSelected(this.SelectedIds)) { this.RemoveUser(this.SelectedIds); this.SelectedIds = null; } // 清除选中的数据 return; } } this.DialogResult = DialogResult.OK; this.Close(); } }
private void CheckZtoElecInfo() { ZtoElecUserInfoEntity elecUserInfoEntity = BillPrintHelper.GetElecUserInfoEntity(); if (elecUserInfoEntity != null) { if (_list == null || _list.Count == 0) { MessageUtil.ShowWarning("请认真填写好发件人和收件人的姓名、电话、省市区、地址"); return; } var list = ZtoElecBillHelper.BindElecBillByCustomerId(_list, elecUserInfoEntity); if (list != null && list.Any()) { txtBillCode.Text = list.First().BillCode; txtBigPen.Text = list.First().BigPen; _list.First().BillCode = txtBillCode.Text; _list.First().BigPen = txtBigPen.Text; var printBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); // 表示更新 if (!string.IsNullOrEmpty(PrintBillId)) { list.First().Id = BaseBusinessLogic.ConvertToDecimal(PrintBillId); printBillManager.Update(list.First()); MessageUtil.ShowTips("获取成功,已更新本地"); } else { // 新增 printBillManager.Add(list.First(), true); MessageUtil.ShowTips("获取成功,已保存本地"); } } else { MessageUtil.ShowError("全部获取电子面单单号失败"); } } else { // 在默认发件人那边修改个人的商家ID信息 // 获取系统是否有默认发件人,如果有救修改,如果没有就新增 ZtoUserManager userManager = new ZtoUserManager(BillPrintHelper.DbHelper); var userList = userManager.GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1)); if (!userList.Any()) { XtraMessageBox.Show("系统未绑定默认发件人和商家ID,请进行绑定", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); FrmAddSendMan addSendMan = new FrmAddSendMan(); addSendMan.ShowDialog(); addSendMan.Dispose(); } else { XtraMessageBox.Show("默认发件人未绑定商家ID,请进行绑定", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); FrmAddSendMan frmSendMan = new FrmAddSendMan { Id = userList.First().Id.ToString() }; frmSendMan.ShowDialog(); frmSendMan.Dispose(); } } }
public string[] GetPermissionIdsByUser(string userId) { string tableName = BaseUserRoleEntity.TableName; if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode)) { tableName = BaseSystemInfo.SystemCode + "UserRole"; } string sqlQuery = // 用户的操作权限 " SELECT " + BasePermissionEntity.FieldPermissionItemId + " FROM " + this.CurrentTableName + " WHERE (" + BasePermissionEntity.FieldResourceCategory + " = '" + BaseUserEntity.TableName + "') " + " AND (" + BasePermissionEntity.FieldEnabled + " = 1) " + " AND (" + BasePermissionEntity.FieldResourceId + " = '" + userId + "')" + " UNION " // 角色的操作权限 + " SELECT " + BasePermissionEntity.FieldPermissionItemId + " FROM " + this.CurrentTableName + " WHERE " + "(" + BasePermissionEntity.FieldResourceCategory + " = '" + BaseRoleEntity.TableName + "') " + " AND (" + BasePermissionEntity.FieldEnabled + " = 1) " + " AND (" + BasePermissionEntity.FieldResourceId + " IN ( " + " SELECT " + BaseUserRoleEntity.FieldRoleId + " FROM " + tableName + " WHERE " + BaseUserRoleEntity.FieldUserId + " = '" + userId + "' " + " AND " + BaseUserRoleEntity.FieldEnabled + " = 1" + " UNION " + " SELECT " + BaseUserEntity.FieldRoleId + " FROM " + BaseUserEntity.TableName + " WHERE " + BaseUserEntity.FieldId + " = '" + userId + "'" + ")) "; DataTable dataTable = DbHelper.Fill(sqlQuery); string[] permissionItemIds = BaseBusinessLogic.FieldToArray(dataTable, BasePermissionEntity.FieldPermissionItemId); // 按部门获取权限项 if (BaseSystemInfo.UseOrganizePermission) { sqlQuery = string.Empty; BaseUserEntity userEntity = new BaseUserManager(this.DbHelper).GetEntity(userId); sqlQuery = " SELECT " + BasePermissionEntity.FieldPermissionItemId + " FROM " + this.CurrentTableName + " WHERE (" + this.CurrentTableName + ".ResourceCategory = '" + BaseOrganizeEntity.TableName + "') " + " AND (ResourceId = '" + userEntity.CompanyId + "' OR " + " ResourceId = '" + userEntity.DepartmentId + "' OR " + " ResourceId = '" + userEntity.SubCompanyId + "' OR" + " ResourceId = '" + userEntity.WorkgroupId + "') " + " AND (Enabled = 1) " + " AND (DeletionStateCode = 0)"; dataTable = DbHelper.Fill(sqlQuery); string[] permissionItemIdsByOrganize = BaseBusinessLogic.FieldToArray(dataTable, BasePermissionEntity.FieldPermissionItemId); permissionItemIds = StringUtil.Concat(permissionItemIds, permissionItemIdsByOrganize); } return(permissionItemIds); }
/// <summary> /// 更新访问当前访问状态 /// </summary> /// <param name="userId">用户主键</param> /// <param name="createOpenId">是否每次都产生新的OpenId</param> /// <returns>OpenId</returns> private string UpdateVisitDate(string userId, bool createOpenId = false) { string returnValue = string.Empty; #if (DEBUG) int milliStart = Environment.TickCount; #endif string sqlQuery = string.Empty; // 是否更新访问日期信息 if (BaseSystemInfo.UpdateVisit) { // 第一次登录时间 sqlQuery = " UPDATE " + BaseUserEntity.TableName + " SET " + BaseUserEntity.FieldFirstVisit + " = " + DbHelper.GetDBNow(); switch (DbHelper.CurrentDbType) { case CurrentDbType.Access: sqlQuery = sqlQuery + " WHERE (" + BaseUserEntity.FieldId + " = " + userId + ") AND " + BaseUserEntity.FieldFirstVisit + " IS NULL"; break; default: sqlQuery = sqlQuery + " WHERE (" + BaseUserEntity.FieldId + " = '" + userId + "') AND " + BaseUserEntity.FieldFirstVisit + " IS NULL"; break; } DbHelper.ExecuteNonQuery(sqlQuery); // 最后一次登录时间 sqlQuery = " UPDATE " + BaseUserEntity.TableName + " SET " + BaseUserEntity.FieldPreviousVisit + " = " + BaseUserEntity.FieldLastVisit + " , " + BaseUserEntity.FieldUserOnLine + " = 1 , " + BaseUserEntity.FieldLastVisit + " = " + DbHelper.GetDBNow() + " , " + BaseUserEntity.FieldLogOnCount + " = " + BaseUserEntity.FieldLogOnCount + " + 1 "; switch (DbHelper.CurrentDbType) { case CurrentDbType.Access: sqlQuery += " WHERE (" + BaseUserEntity.FieldId + " = " + userId + ")"; break; default: sqlQuery += " WHERE (" + BaseUserEntity.FieldId + " = '" + userId + "')"; break; } DbHelper.ExecuteNonQuery(sqlQuery); } // 实现单点登录功能,每次都更换Guid if (createOpenId) { returnValue = BaseBusinessLogic.NewGuid(); sqlQuery = " UPDATE " + BaseUserEntity.TableName + " SET " + BaseUserEntity.FieldOpenId + " = '" + returnValue + "'"; switch (DbHelper.CurrentDbType) { case CurrentDbType.Access: sqlQuery += " WHERE (" + BaseUserEntity.FieldId + " = " + userId + ")"; break; default: sqlQuery += " WHERE (" + BaseUserEntity.FieldId + " = '" + userId + "')"; break; } // sqlQuery += " AND " + BaseUserEntity.FieldOpenId + " IS NULL "; DbHelper.ExecuteNonQuery(sqlQuery); } // 写入调试信息 #if (DEBUG) int milliEnd = Environment.TickCount; Trace.WriteLine(DateTime.Now.ToString(BaseSystemInfo.TimeFormat) + " Ticks: " + TimeSpan.FromMilliseconds(milliEnd - milliStart).ToString() + " " + " BaseUserManager.UpdateVisitDate(" + userId + ")"); #endif return(returnValue); }
/// <summary> /// 从数据行读取 /// </summary> /// <param name="dr">数据行</param> protected override BaseEntity GetFrom(IDataRow dr) { GetFromExpand(dr); if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldSendPhone)) { SendPhone = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldSendPhone]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldReceiveMan)) { ReceiveMan = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldReceiveMan]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldCreateUserName)) { CreateUserName = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldCreateUserName]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldModifiedSite)) { ModifiedSite = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldModifiedSite]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldModifiedUserName)) { ModifiedUserName = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldModifiedUserName]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldCreateOn)) { CreateOn = BaseBusinessLogic.ConvertToNullableDateTime(dr[ZtoPrintCancelEntity.FieldCreateOn]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldOrderNumber)) { OrderNumber = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldOrderNumber]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldBillCode)) { BillCode = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldBillCode]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldSendMan)) { SendMan = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldSendMan]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldRemark)) { Remark = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldRemark]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldModifiedOn)) { ModifiedOn = BaseBusinessLogic.ConvertToNullableDateTime(dr[ZtoPrintCancelEntity.FieldModifiedOn]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldCreateSite)) { CreateSite = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldCreateSite]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldReceiveAddress)) { ReceiveAddress = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldReceiveAddress]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldId)) { Id = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldId]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldReceivePhone)) { ReceivePhone = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldReceivePhone]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldSendAddress)) { SendAddress = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldSendAddress]); } if (dr.ContainsColumn(ZtoPrintCancelEntity.FieldSendProvince)) { SendProvince = BaseBusinessLogic.ConvertToString(dr[ZtoPrintCancelEntity.FieldSendProvince]); } return(this); }
public static void CachePreheatingSpelling(bool flushDb = false) { // 组织机构数据缓存预热实现 BaseOrganizeManager organizeManager = new Business.BaseOrganizeManager(); // 减少数据库连接、减少内存站用、一边度取、一边设置缓存,只读取需要的数据 organizeManager.SelectFields = BaseOrganizeEntity.FieldId + ", " + BaseOrganizeEntity.FieldCode + ", " + BaseOrganizeEntity.FieldFullName + " , " + BaseOrganizeEntity.FieldSimpleSpelling + " , " + BaseOrganizeEntity.FieldCostCenterId + " , " + BaseOrganizeEntity.FieldProvinceId + " , " + BaseOrganizeEntity.FieldCompanyId + " , " + BaseOrganizeEntity.FieldCityId + " , " + BaseOrganizeEntity.FieldParentId + " , " + BaseOrganizeEntity.FieldSendAir + " , " + BaseOrganizeEntity.FieldEnabled + " , " + BaseOrganizeEntity.FieldDeletionStateCode + " , " + BaseOrganizeEntity.FieldSortCode; // 读取有效的,没有被删除的网点数据 // List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>(); // parameters.Add(new KeyValuePair<string, object>(BaseOrganizeEntity.FieldEnabled, 1)); // parameters.Add(new KeyValuePair<string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0)); // 2016-02-19 宋彪 PooledRedisHelper.GetClient() 改为 PooledRedisHelper.GetSpellingClient() using (var redisClient = PooledRedisHelper.GetSpellingClient()) { if (flushDb) { redisClient.FlushDb(); } double score = 0; using (IDataReader dataReader = organizeManager.ExecuteReader(0, BaseOrganizeEntity.FieldFullName)) { while (dataReader.Read()) { score++; // 读取到的数据直接强制设置到缓存里 BaseOrganizeEntity entity = new BaseOrganizeEntity(); entity.Id = dataReader[BaseOrganizeEntity.FieldId].ToString(); entity.Code = dataReader[BaseOrganizeEntity.FieldCode].ToString(); entity.FullName = dataReader[BaseOrganizeEntity.FieldFullName].ToString(); entity.SimpleSpelling = dataReader[BaseOrganizeEntity.FieldSimpleSpelling].ToString().ToLower(); entity.CostCenterId = dataReader[BaseOrganizeEntity.FieldCostCenterId].ToString(); entity.ProvinceId = dataReader[BaseOrganizeEntity.FieldProvinceId].ToString(); entity.CompanyId = dataReader[BaseOrganizeEntity.FieldCompanyId].ToString(); entity.CityId = dataReader[BaseOrganizeEntity.FieldCityId].ToString(); entity.ParentId = dataReader[BaseOrganizeEntity.FieldParentId].ToString(); entity.SendAir = BaseBusinessLogic.ConvertToInt(dataReader[BaseOrganizeEntity.FieldSendAir]); entity.Enabled = BaseBusinessLogic.ConvertToInt(dataReader[BaseOrganizeEntity.FieldEnabled]); entity.DeletionStateCode = BaseBusinessLogic.ConvertToInt(dataReader[BaseOrganizeEntity.FieldDeletionStateCode]); entity.SortCode = BaseBusinessLogic.ConvertToInt(dataReader[BaseOrganizeEntity.FieldSortCode]); if (!flushDb) { score = entity.SortCode.Value; } CachePreheatingSpelling(redisClient, entity, score); if (flushDb) { // 2016-02-02 吉日嘎拉 设置一下排序属性 new Business.BaseManager(BaseOrganizeEntity.TableName).SetProperty(entity.Id, new KeyValuePair <string, object>(BaseOrganizeEntity.FieldSortCode, score)); } } } } }
/// <summary> /// 获得用户有访问权限的模块 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <returns>数据表</returns> public DataTable GetModuleDTByUser(BaseUserInfo userInfo, string userId) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif DataTable dataTable = new DataTable(BaseModuleEntity.TableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); string tableName = BaseModuleEntity.TableName; if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode)) { tableName = BaseSystemInfo.SystemCode + "Module"; } BaseModuleManager moduleManager = new BaseModuleManager(dbHelper, userInfo, tableName); if (userInfo.IsAdministrator) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseModuleEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseModuleEntity.FieldDeletionStateCode, 0)); // 有效的,未被删除的显示出来 dataTable = moduleManager.GetDataTable(parameters, BaseModuleEntity.FieldSortCode); } else { dataTable = moduleManager.GetDataTableByUser(userId); } // 若不是员工,有些菜单可以去掉的功能,加在这里 if (string.IsNullOrEmpty(userInfo.StaffId)) { BaseBusinessLogic.Delete(dataTable, BaseModuleEntity.FieldCode, "FrmStaffAddressEdit"); dataTable.AcceptChanges(); } dataTable.TableName = BaseModuleEntity.TableName; BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_GetModuleDTByUser, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(dataTable); }
/// <summary> /// 从数据行读取 /// </summary> /// <param name="dr">数据行</param> protected override BaseEntity GetFrom(IDataRow dr) { GetFromExpand(dr); if (dr.ContainsColumn(ZtoPrintBillEntity.FieldId)) { Id = BaseBusinessLogic.ConvertToDecimal(dr[ZtoPrintBillEntity.FieldId]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendPostcode)) { SendPostcode = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendPostcode]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceiveMan)) { ReceiveMan = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceiveMan]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceiveProvince)) { ReceiveProvince = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceiveProvince]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldCreateUserName)) { CreateUserName = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldCreateUserName]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldModifiedSite)) { ModifiedSite = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldModifiedSite]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldModifiedUserName)) { ModifiedUserName = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldModifiedUserName]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldPaymentType)) { PaymentType = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldPaymentType]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldLength)) { Length = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldLength]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendMan)) { SendMan = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendMan]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldModifiedOn)) { ModifiedOn = BaseBusinessLogic.ConvertToNullableDateTime(dr[ZtoPrintBillEntity.FieldModifiedOn]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceiveAddress)) { ReceiveAddress = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceiveAddress]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceivePostcode)) { ReceivePostcode = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceivePostcode]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceivePhone)) { ReceivePhone = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceivePhone]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendDepartment)) { SendDepartment = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendDepartment]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendDate)) { SendDate = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendDate]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendProvince)) { SendProvince = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendProvince]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldTranFee)) { TranFee = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldTranFee]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendDeparture)) { SendDeparture = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendDeparture]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendPhone)) { SendPhone = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendPhone]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendCity)) { SendCity = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendCity]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldGoodsName)) { GoodsName = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldGoodsName]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldWeight)) { Weight = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldWeight]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldHeight)) { Height = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldHeight]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceiveCounty)) { ReceiveCounty = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceiveCounty]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceiveDestination)) { ReceiveDestination = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceiveDestination]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendCompany)) { SendCompany = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendCompany]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldCreateOn)) { CreateOn = BaseBusinessLogic.ConvertToDateTime(dr[ZtoPrintBillEntity.FieldCreateOn]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldBillCode)) { BillCode = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldBillCode]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldTotalNumber)) { TotalNumber = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldTotalNumber]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldRemark)) { Remark = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldRemark]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldCreateSite)) { CreateSite = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldCreateSite]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendSite)) { SendSite = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendSite]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldWidth)) { Width = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldWidth]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceiveCity)) { ReceiveCity = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceiveCity]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendAddress)) { SendAddress = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendAddress]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldSendCounty)) { SendCounty = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldSendCounty]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldReceiveCompany)) { ReceiveCompany = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldReceiveCompany]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldBigPen)) { BigPen = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldBigPen]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldOrderNumber)) { OrderNumber = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldOrderNumber]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldExpressId)) { ExpressId = BaseBusinessLogic.ConvertToString(dr[ZtoPrintBillEntity.FieldExpressId]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldToPayMent)) { TOPAYMENT = BaseBusinessLogic.ConvertToDecimal(dr[ZtoPrintBillEntity.FieldToPayMent]); } if (dr.ContainsColumn(ZtoPrintBillEntity.FieldGoodsPayMent)) { GOODS_PAYMENT = BaseBusinessLogic.ConvertToDecimal(dr[ZtoPrintBillEntity.FieldGoodsPayMent]); } return(this); }
/// <summary> /// 导入Excel数据到本地数据库 /// </summary> public bool Import() { if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim())) { XtraMessageBox.Show(@"请选择录单模板", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); btnOpenExcel_Click(this, null); return(false); } if (!File.Exists(txtFileFullPath.Text)) { XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); btnOpenExcel_Click(this, null); return(false); } if (!splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.ShowWaitForm(); } Application.DoEvents(); splashScreenManagerImportExcel.SetWaitFormCaption("请稍后"); splashScreenManagerImportExcel.SetWaitFormDescription("开始导入Excel数据..."); try { int crossRow = int.Parse(cmbPrintNumber.Text) - 1; if (crossRow < 0) { crossRow = 1; } DataTable chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text.Trim(), 38, 0, crossRow); if (chooseDt != null && chooseDt.Rows.Count > 0) { var list = new List <ZtoUserEntity>(); int temp = 0; foreach (DataRow dr in chooseDt.Rows) { ++temp; splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count)); var userEntity = new ZtoUserEntity { Realname = BaseBusinessLogic.ConvertToString(dr[8]) }; if (ValidateUtil.IsMobile(BaseBusinessLogic.ConvertToString(dr[9]))) { userEntity.Mobile = BaseBusinessLogic.ConvertToString(dr[9]); } else { userEntity.TelePhone = BaseBusinessLogic.ConvertToString(dr[9]); } var tempProvince = BaseBusinessLogic.ConvertToString(dr[10]); // 收件人地址(有可能用户不填写收件省市区) userEntity.Address = BaseBusinessLogic.ConvertToString(dr[13]); if (tempProvince != null) { userEntity.Province = tempProvince.Trim(); } var tempCity = BaseBusinessLogic.ConvertToString(dr[11]); if (tempCity != null) { userEntity.City = tempCity.Trim(); } var tempCounty = BaseBusinessLogic.ConvertToString(dr[12]); if (tempCounty != null) { userEntity.County = tempCounty.Trim(); } if (string.IsNullOrEmpty(userEntity.Province) && string.IsNullOrEmpty(userEntity.City) && string.IsNullOrEmpty(userEntity.County)) { if (!string.IsNullOrEmpty(userEntity.Address)) { var result = BaiduMapHelper.GetProvCityDistFromBaiduMap(userEntity.Address); if (result != null) { userEntity.Province = result.Result.AddressComponent.Province; userEntity.City = result.Result.AddressComponent.City; userEntity.County = result.Result.AddressComponent.District; } } } userEntity.Company = BaseBusinessLogic.ConvertToString(dr[31]); userEntity.Postcode = BaseBusinessLogic.ConvertToString(dr[32]); userEntity.Issendorreceive = "0"; if (string.IsNullOrEmpty(userEntity.Postcode)) { if (!string.IsNullOrEmpty(userEntity.City) && !string.IsNullOrEmpty(userEntity.County)) { userEntity.Postcode = NetworkHelper.GetPostCodeByAddress(userEntity.City, userEntity.County); } } if (!string.IsNullOrEmpty(userEntity.Province)) { var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.Province)).FirstOrDefault(); if (areaEntity != null) { userEntity.ProvinceId = areaEntity.Id; } } if (!string.IsNullOrEmpty(userEntity.City)) { var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.City)).FirstOrDefault(); if (areaEntity != null) { userEntity.CityId = areaEntity.Id; } } if (!string.IsNullOrEmpty(userEntity.County)) { var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.County)).FirstOrDefault(); if (areaEntity != null) { userEntity.CountyId = areaEntity.Id; } } userEntity.CreateOn = DateTime.Now; list.Add(userEntity); } using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, BillPrintHelper.BillPrintConnectionString)) { try { dbHelper.BeginTransaction(); var manager = new ZtoUserManager(dbHelper); foreach (ZtoUserEntity ztoUserEntity in list) { manager.Add(ztoUserEntity, true); } dbHelper.CommitTransaction(); GridDataBind(); } catch (Exception ex) { dbHelper.RollbackTransaction(); ProcessException(ex); } } if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.CloseWaitForm(); } Close(); } else { XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } catch (Exception ex) { ProcessException(ex); return(false); } finally { if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.CloseWaitForm(); } } return(true); }
/// <summary> /// 获取用户的管理网点 /// </summary> /// <param name="result">数据权限主键</param> /// <returns>管理网点数组</returns> public string[] GetUserCompanyIds(string userId, string permissionId) { string[] result = null; // 用户有权限的省?获取省的网点? // 用户有权限的市?市的网点? // 用户有权限的县?县的网点? // 用户有权限的街道?街道的网点? List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, permissionId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldDeletionStateCode, 0)); string tableName = this.UserInfo.SystemCode + "PermissionScope"; BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(this.DbHelper, this.UserInfo, tableName); string[] areaIds = permissionScopeManager.GetProperties(parameters, BasePermissionScopeEntity.FieldTargetId); // 按区域分割省、市、县、街道 string[] province = null; string[] city = null; string[] district = null; string[] street = null; SplitArea(areaIds, out province, out city, out district, out street); string[] areaCompanyIds = null; if (areaIds != null && areaIds.Length > 0) { string commandText = " SELECT " + BaseOrganizeEntity.FieldId + " FROM " + BaseOrganizeEntity.TableName + " WHERE " + BaseOrganizeEntity.FieldEnabled + " = 1 " + " AND " + BaseOrganizeEntity.FieldDeletionStateCode + " = 0 " + " AND ("; if (province != null && province.Length > 0) { commandText += BaseOrganizeEntity.FieldProvinceId + " IN (" + BaseBusinessLogic.ObjectsToList(province, "'") + ")"; } if (city != null && city.Length > 0) { if (province != null && province.Length > 0) { commandText += " OR "; } commandText += BaseOrganizeEntity.FieldCityId + " IN (" + BaseBusinessLogic.ObjectsToList(city, "'") + ")"; } if (district != null && district.Length > 0) { if ((province != null && province.Length > 0) || (city != null && city.Length > 0)) { commandText += " OR "; } commandText += BaseOrganizeEntity.FieldDistrictId + " IN (" + BaseBusinessLogic.ObjectsToList(district, "'") + ")"; } if (street != null && street.Length > 0) { if ((province != null && province.Length > 0) || (city != null && city.Length > 0) || (district != null && district.Length > 0)) { commandText += " OR "; } commandText += BaseOrganizeEntity.FieldStreetId + " IN (" + BaseBusinessLogic.ObjectsToList(areaIds, "'") + ")"; } commandText += ")"; BaseOrganizeManager organizeManager = new BaseOrganizeManager(); DataTable dt = organizeManager.Fill(commandText); areaCompanyIds = BaseBusinessLogic.FieldToArray(dt, BaseOrganizeEntity.FieldId); } // 用户直接有权限的网点 parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, permissionId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizeEntity.TableName)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldDeletionStateCode, 0)); string[] companyIds = permissionScopeManager.GetProperties(parameters, BasePermissionScopeEntity.FieldTargetId); result = StringUtil.Concat(companyIds, areaCompanyIds); return(result); }
/// <summary> /// 从数据行读取 /// </summary> /// <param name="dr">数据行</param> protected override BaseEntity GetFrom(IDataRow dr) { Id = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldId]); UserFrom = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldUserFrom]); Code = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldCode]); UserName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldUserName]); NickName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldNickName]); RealName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldRealName]); QuickQuery = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldQuickQuery]); SimpleSpelling = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldSimpleSpelling]); SecurityLevel = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldSecurityLevel]); WorkCategory = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldWorkCategory]); CompanyId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldCompanyId]); // 2015-12-29 吉日嘎拉 防止程序出错,没有这个字段也可以正常运行 if (dr.ContainsColumn(BaseUserEntity.FieldCompanyCode)) { CompanyCode = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldCompanyCode]); } CompanyName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldCompanyName]); SubCompanyId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldSubCompanyId]); SubCompanyName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldSubCompanyName]); DepartmentId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldDepartmentId]); DepartmentName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldDepartmentName]); SubDepartmentId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldSubDepartmentId]); SubDepartmentName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldSubDepartmentName]); WorkgroupId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldWorkgroupId]); WorkgroupName = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldWorkgroupName]); IDCard = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldIDCard]); Gender = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldGender]); Birthday = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldBirthday]); Duty = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldDuty]); Title = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldTitle]); Province = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldProvince]); City = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldCity]); District = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldDistrict]); HomeAddress = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldHomeAddress]); Score = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldScore]); IsAdministrator = BaseBusinessLogic.ConvertToBoolean(dr[BaseUserEntity.FieldIsAdministrator]); Lang = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldLang]); Theme = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldTheme]); Signature = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldSignature]); IsStaff = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldIsStaff]); IsCheckBalance = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldIsCheckBalance]); AuditStatus = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldAuditStatus]); ManagerId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldManagerId]); ManagerAuditStatus = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldManagerAuditStatus]); ManagerAuditDate = BaseBusinessLogic.ConvertToNullableDateTime(dr[BaseUserEntity.FieldManagerAuditDate]); IsVisible = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldIsVisible]); DeletionStateCode = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldDeletionStateCode]); Enabled = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldEnabled]); SortCode = BaseBusinessLogic.ConvertToInt(dr[BaseUserEntity.FieldSortCode]); Description = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldDescription]); CreateOn = BaseBusinessLogic.ConvertToNullableDateTime(dr[BaseUserEntity.FieldCreateOn]); CreateUserId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldCreateUserId]); CreateBy = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldCreateBy]); ModifiedOn = BaseBusinessLogic.ConvertToNullableDateTime(dr[BaseUserEntity.FieldModifiedOn]); ModifiedUserId = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldModifiedUserId]); ModifiedBy = BaseBusinessLogic.ConvertToString(dr[BaseUserEntity.FieldModifiedBy]); // 获取扩展属性 GetFromExpand(dr); return(this); }
/// <summary> /// 检索数据 /// </summary> /// <param name="userId">用户Id</param> /// <param name="categoryCode">单据类别</param> /// <param name="searchValue">关键字</param> /// <param name="enabled">是否有效</param> /// <param name="deletionStateCode">是否删除</param> /// <returns></returns> public DataTable SearchBill(string userId, string categoryId, string categorybillFullName, string searchValue, bool?enabled, bool?deletionStateCode) { int delete = 0; if (deletionStateCode != null) { delete = (bool)deletionStateCode ? 1 : 0; } string sqlQuery = string.Empty; sqlQuery = " SELECT " + BaseWorkFlowBillTemplateEntity.FieldId + " ," + BaseWorkFlowBillTemplateEntity.FieldCategoryCode + " ," + BaseWorkFlowBillTemplateEntity.FieldTitle + " ," + BaseWorkFlowBillTemplateEntity.FieldCode + " ," + BaseWorkFlowBillTemplateEntity.FieldIntroduction + " ," + BaseWorkFlowBillTemplateEntity.FieldAuditStatus + " ," + BaseWorkFlowBillTemplateEntity.FieldModifiedUserId + " ," + BaseWorkFlowBillTemplateEntity.FieldModifiedBy + " ," + BaseWorkFlowBillTemplateEntity.FieldModifiedOn + " ," + BaseWorkFlowBillTemplateEntity.FieldCreateOn + " ," + BaseWorkFlowBillTemplateEntity.FieldSortCode + " FROM " + this.CurrentTableName + " WHERE " + BaseWorkFlowBillTemplateEntity.FieldDeletionStateCode + " = " + delete; if (enabled != null) { int isEnabled = (bool)enabled ? 1 : 0; sqlQuery += " AND " + BaseWorkFlowBillTemplateEntity.FieldEnabled + " = " + isEnabled; } if (!String.IsNullOrEmpty(userId)) { sqlQuery += " AND " + BaseWorkFlowBillTemplateEntity.FieldCreateUserId + " = " + userId; } if (!string.IsNullOrEmpty(categoryId)) { BaseWorkFlowBillTemplateManager templateManager = new BaseWorkFlowBillTemplateManager(this.DbHelper, this.UserInfo); DataTable dataTable = templateManager.Search(string.Empty, categoryId, string.Empty, null, false); string categoryIds = BaseBusinessLogic.FieldToList(dataTable, BaseWorkFlowBillTemplateEntity.FieldId); if (!string.IsNullOrEmpty(categoryIds)) { sqlQuery += " AND (" + BaseWorkFlowBillTemplateEntity.FieldCategoryCode + " IN (" + categoryIds + ")) "; } } if (!String.IsNullOrEmpty(categorybillFullName)) { sqlQuery += " AND " + BaseWorkFlowBillTemplateEntity.FieldCategoryCode + " = '" + categorybillFullName + "'"; } List <IDbDataParameter> dbParameters = new List <IDbDataParameter>(); searchValue = searchValue.Trim(); if (!String.IsNullOrEmpty(searchValue)) { sqlQuery += " AND (" + BaseWorkFlowBillTemplateEntity.FieldTitle + " LIKE " + DbHelper.GetParameter(BaseWorkFlowBillTemplateEntity.FieldTitle); sqlQuery += " OR " + BaseWorkFlowBillTemplateEntity.FieldCode + " LIKE " + DbHelper.GetParameter(BaseWorkFlowBillTemplateEntity.FieldCode); sqlQuery += " OR " + BaseWorkFlowBillTemplateEntity.FieldCategoryCode + " LIKE " + DbHelper.GetParameter(BaseWorkFlowBillTemplateEntity.FieldCategoryCode); sqlQuery += " OR " + BaseWorkFlowBillTemplateEntity.FieldModifiedBy + " LIKE " + DbHelper.GetParameter(BaseWorkFlowBillTemplateEntity.FieldModifiedBy); sqlQuery += " OR " + BaseWorkFlowBillTemplateEntity.FieldIntroduction + " LIKE " + DbHelper.GetParameter(BaseWorkFlowBillTemplateEntity.FieldIntroduction) + ")"; if (searchValue.IndexOf("%") < 0) { searchValue = "%" + searchValue + "%"; } dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowBillTemplateEntity.FieldTitle, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowBillTemplateEntity.FieldCode, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowBillTemplateEntity.FieldCategoryCode, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowBillTemplateEntity.FieldModifiedBy, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowBillTemplateEntity.FieldIntroduction, searchValue)); } sqlQuery += " ORDER BY " + BaseWorkFlowBillTemplateEntity.FieldSortCode + " DESC "; return(DbHelper.Fill(sqlQuery, dbParameters.ToArray())); }
public BaseWorkFlowActivityEntity GetNextWorkFlowActivity(BaseWorkFlowCurrentEntity workFlowCurrentEntity) { BaseWorkFlowActivityEntity workFlowActivityEntity = null; DataTable dataTable = null; // 工作流主键 string workFlowId = workFlowCurrentEntity.WorkFlowId.ToString(); // 1. 从工作流审核步骤里选取审核步骤 BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldWorkFlowId, workFlowId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0)); dataTable = workFlowStepManager.GetDataTable(parameters, BaseWorkFlowStepEntity.FieldSortCode); if (dataTable.Rows.Count > 0) { dataTable.Columns.Remove(BaseWorkFlowStepEntity.FieldId); dataTable.Columns[BaseWorkFlowStepEntity.FieldActivityId].ColumnName = BaseWorkFlowStepEntity.FieldId; } else { // 2. 从工作流审核模板里选取审核步骤 下一步是多少?按工作流进行查找审核步骤 BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0)); dataTable = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode); } // 审核步骤主键 string activityId = string.Empty; if (workFlowCurrentEntity.ActivityId != null) { activityId = workFlowCurrentEntity.ActivityId.ToString(); } if (dataTable.Rows.Count == 0) { return(workFlowActivityEntity); } string nextActivityId = string.Empty; if (!string.IsNullOrEmpty(activityId)) { nextActivityId = BaseSortLogic.GetNextId(dataTable, activityId.ToString()); } else { nextActivityId = dataTable.Rows[0][BaseWorkFlowActivityEntity.FieldId].ToString(); } if (!string.IsNullOrEmpty(nextActivityId)) { // workFlowActivityEntity = workFlowActivityManager.GetEntity(nextActivityId); DataRow dataRow = BaseBusinessLogic.GetDataRow(dataTable, nextActivityId); workFlowActivityEntity = new BaseWorkFlowActivityEntity(dataRow); } return(workFlowActivityEntity); }
/// <summary> /// 导入Excel数据到本地数据库 /// </summary> public bool Import() { if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim())) { XtraMessageBox.Show(@"请选择录单模板", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); btnOpenExcel_Click(this, null); return(false); } if (!File.Exists(txtFileFullPath.Text)) { XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); btnOpenExcel_Click(this, null); return(false); } var startDateTime = DateTime.Now; StartDt = startDateTime; if (!splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.ShowWaitForm(); } Application.DoEvents(); splashScreenManagerImportExcel.SetWaitFormCaption("请稍后"); splashScreenManagerImportExcel.SetWaitFormDescription("开始导入Excel数据..."); try { DataTable chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text.Trim(), 38, 0, 3); if (chooseDt != null && chooseDt.Rows.Count > 0) { var list = new List <ZtoPrintBillEntity>(); int temp = 0; var defaultUserList = new ZtoUserManager(BillPrintHelper.DbHelper).GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1)); ZtoUserEntity defaultUserEntity = null; if (defaultUserList.Any()) { defaultUserEntity = defaultUserList.First(); } foreach (DataRow dr in chooseDt.Rows) { ++temp; splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count)); ZtoPrintBillEntity entity = new ZtoPrintBillEntity(); if (ckTodaySend.Checked) { entity.SendDate = DateTime.Now.ToString(BaseSystemInfo.DateFormat); } if (ckUserDefaultSendMan.Checked) { if (defaultUserEntity != null) { entity.SendMan = defaultUserEntity.Realname; entity.SendPhone = defaultUserEntity.Mobile + " " + defaultUserEntity.TelePhone; entity.SendProvince = defaultUserEntity.Province; entity.SendCity = defaultUserEntity.City; entity.SendCounty = defaultUserEntity.County; entity.SendAddress = defaultUserEntity.Address; entity.SendSite = ""; entity.SendDeparture = entity.SendProvince; entity.SendCompany = defaultUserEntity.Company; entity.SendDepartment = defaultUserEntity.Department; entity.SendPostcode = defaultUserEntity.Postcode; } } else { if (this.Tag != null) { var sendUserEntity = this.Tag as ZtoUserEntity; // 表示选择了一个发件人的信息,这样也不用读取Excel里面的发件人了 if (sendUserEntity != null) { entity.SendMan = sendUserEntity.Realname; entity.SendPhone = sendUserEntity.Mobile + " " + sendUserEntity.TelePhone; entity.SendProvince = sendUserEntity.Province; entity.SendCity = sendUserEntity.City; entity.SendCounty = sendUserEntity.County; entity.SendAddress = sendUserEntity.Address; entity.SendSite = ""; entity.SendDeparture = sendUserEntity.Province; entity.SendCompany = sendUserEntity.Company; entity.SendDepartment = sendUserEntity.Department; entity.SendPostcode = sendUserEntity.Postcode; } } else { entity.SendMan = BaseBusinessLogic.ConvertToString(dr[2]); entity.SendPhone = BaseBusinessLogic.ConvertToString(dr[3]); entity.SendProvince = BaseBusinessLogic.ConvertToString(dr[4]); entity.SendCity = BaseBusinessLogic.ConvertToString(dr[5]); entity.SendCounty = BaseBusinessLogic.ConvertToString(dr[6]); entity.SendAddress = BaseBusinessLogic.ConvertToString(dr[7]); entity.SendSite = ""; entity.SendDeparture = BaseBusinessLogic.ConvertToString(dr[26]); if (string.IsNullOrEmpty(entity.SendDeparture)) { entity.SendDeparture = entity.SendProvince; } entity.SendCompany = BaseBusinessLogic.ConvertToString(dr[27]); entity.SendDepartment = BaseBusinessLogic.ConvertToString(dr[28]); entity.SendPostcode = BaseBusinessLogic.ConvertToString(dr[29]); } } entity.ReceiveMan = BaseBusinessLogic.ConvertToString(dr[8]); entity.ReceivePhone = BaseBusinessLogic.ConvertToString(dr[9]); entity.ReceiveProvince = BaseBusinessLogic.ConvertToString(dr[10]); entity.ReceiveCity = BaseBusinessLogic.ConvertToString(dr[11]); entity.ReceiveCounty = BaseBusinessLogic.ConvertToString(dr[12]); entity.ReceiveAddress = BaseBusinessLogic.ConvertToString(dr[13]); entity.ReceiveDestination = BaseBusinessLogic.ConvertToString(dr[30]); if (string.IsNullOrEmpty(entity.ReceiveDestination)) { entity.ReceiveDestination = entity.ReceiveProvince; } entity.ReceiveCompany = BaseBusinessLogic.ConvertToString(dr[31]); entity.ReceivePostcode = BaseBusinessLogic.ConvertToString(dr[32]); entity.GoodsName = BaseBusinessLogic.ConvertToString(dr[14]); entity.Weight = BaseBusinessLogic.ConvertToString(dr[15]); entity.TranFee = BaseBusinessLogic.ConvertToString(dr[16]); entity.GOODS_PAYMENT = BaseBusinessLogic.ConvertToDecimal(dr[17]); entity.TOPAYMENT = BaseBusinessLogic.ConvertToDecimal(dr[18]); entity.Length = BaseBusinessLogic.ConvertToString(dr[33]); entity.Width = BaseBusinessLogic.ConvertToString(dr[34]); entity.Height = BaseBusinessLogic.ConvertToString(dr[35]); entity.TotalNumber = BaseBusinessLogic.ConvertToString(dr[36]); entity.OrderNumber = BaseBusinessLogic.ConvertToString(dr[37]); entity.Remark = BaseBusinessLogic.ConvertToString(dr[22]); entity.CreateUserName = ""; entity.CreateSite = ""; entity.CreateOn = DateTime.Now; entity.PaymentType = "现金"; // 如果Excel里面没有填写订单号系统自动生成一个订单号,这样提取电子面单单号就不用怕了,2016-1-23 14:07:12 if (string.IsNullOrEmpty(entity.OrderNumber)) { // 导入自动生成订单号(电子面单)79170-南昌昌南 18779176845 这个qq提供的思路,2016-1-20 20:08:50 entity.OrderNumber = Guid.NewGuid().ToString("N").ToLower(); } if (!ckGetServerPrintMark.Checked) { entity.BigPen = string.Format("{0} {1} {2}", entity.ReceiveProvince, entity.ReceiveCity, entity.ReceiveCounty); } else { entity.BigPen = ""; } list.Add(entity); } if (!ckGetServerPrintMark.Checked) { var manager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); foreach (ZtoPrintBillEntity ztoPrintBillEntity in list) { manager.Add(ztoPrintBillEntity, true); } if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.CloseWaitForm(); } GridDataBind(); var ts = DateTime.Now - startDateTime; lblTime.Text = string.Format("耗时:{0}时{1}分{2}秒{3}毫秒", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); Close(); } else { splashScreenManagerImportExcel.SetWaitFormDescription("正在联网获取大头笔信息,请稍后......"); // 开线程去读取大头笔的 CheckBillCode(list); } } else { XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } catch (Exception ex) { ProcessException(ex); return(false); } finally { if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible) { splashScreenManagerImportExcel.CloseWaitForm(); } } return(true); }
/// <summary> /// 获得某个用户的所有权限列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userId">用户主键</param> /// <returns>数据表</returns> public DataTable GetPermissionDTByUser(BaseUserInfo userInfo, string userId) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif DataTable dataTable = new DataTable(BasePermissionItemEntity.TableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); string tableName = BasePermissionItemEntity.TableName; if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode)) { tableName = BaseSystemInfo.SystemCode + "PermissionItem"; } // 是否超级管理员 BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); BasePermissionItemManager permissionItemManager = new BasePermissionItemManager(dbHelper, userInfo, tableName); if (userManager.IsAdministrator(userId)) { dataTable = permissionItemManager.GetDataTable(); } else { tableName = BasePermissionEntity.TableName; if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode)) { tableName = BaseSystemInfo.SystemCode + "Permission"; } BasePermissionManager permissionManager = new BasePermissionManager(dbHelper, userInfo, tableName); string[] ids = permissionManager.GetPermissionIdsByUser(userId); // 若是以前赋予的权限,后来有些权限设置为无效了,那就不应该再获取哪些无效的权限才对。 // bug修正:没有赋值DataTable,导致返回值空 dataTable = permissionItemManager.GetDataTable( new KeyValuePair <string, object>(BasePermissionItemEntity.FieldId, ids) , new KeyValuePair <string, object>(BasePermissionItemEntity.FieldEnabled, 1) , new KeyValuePair <string, object>(BasePermissionItemEntity.FieldDeletionStateCode, 0)); } dataTable.TableName = tableName; BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_GetPermissionDTByUser, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(dataTable); }
/// <summary> /// 批量打删除标志 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <returns>影响行数</returns> public int SetDeleted(BaseUserInfo userInfo, string[] ids) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo); for (int i = 0; i < ids.Length; i++) { // 设置部门为删除状态 returnValue += organizeManager.SetDeleted(ids[i]); // 相应的用户也需要处理 BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, null)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyName, null)); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, ids[i]), parameters); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyId, null)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyName, null)); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyId, ids[i]), parameters); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, null)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentName, null)); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, ids[i]), parameters); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, null)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupName, null)); userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, ids[i]), parameters); // 相应的员工也需要处理 BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo); staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldCompanyId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldCompanyId, null)); staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldSubCompanyId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldSubCompanyId, null)); staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldDepartmentId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldDepartmentId, null)); staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldWorkgroupId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldWorkgroupId, null)); } BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.OrganizeService_SetDeleted, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 获得所有主键数组 /// </summary> /// <returns>主键数组</returns> private string[] GetIds() { return(BaseBusinessLogic.FieldToArray(this.DTUser, BaseUserEntity.FieldId)); }
/// <summary> /// 获取子节点列表 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="tableName">目标表明</param> /// <param name="fieldId">主键字段</param> /// <param name="id">值</param> /// <param name="fieldParentId">父亲节点字段</param> /// <param name="order">排序</param> /// <returns>主键数组</returns> public static string[] GetChildrensId(IDbHelper dbHelper, string tableName, string fieldId, string id, string fieldParentId, string order) { return(BaseBusinessLogic.FieldToArray(GetChildrens(dbHelper, tableName, fieldId, id, fieldParentId, order, true), BaseBusinessLogic.FieldId)); }
/// <summary> /// 检查是否是步骤流 /// </summary> /// <param name="userInfo">用户信息</param> /// <param name="currentFlowIds">主键组</param> /// <param name="returnStatusCode">返回代码</param> /// <param name="returnStatusMessage">返回信息</param> /// <returns></returns> public bool CheckIsAutoWorkFlow(BaseUserInfo userInfo, string[] currentFlowIds, out string returnStatusCode, out string returnStatusMessage) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif returnStatusCode = string.Empty; returnStatusMessage = string.Empty; bool returnValue = false; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType)) { try { // 打开数据库 dbHelper.Open(WorkFlowDbConnection); BaseWorkFlowCurrentManager workFlowCurrentManager = new BaseWorkFlowCurrentManager(dbHelper, userInfo); string processId = string.Empty; for (int i = 0; i < currentFlowIds.Length; i++) { BaseWorkFlowCurrentEntity workFlowCurrentEntity = workFlowCurrentManager.GetEntity(currentFlowIds[i]); if ((workFlowCurrentEntity != null) && (!string.IsNullOrEmpty(workFlowCurrentEntity.Id))) { if (workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.StartAudit.ToString()) || workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditPass.ToString()) || workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.WaitForAudit.ToString()) || workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditReject.ToString())) { // 不为空的话是步骤流 if (workFlowCurrentEntity.WorkFlowId != null) { returnValue = true; } else { // 判断是否是批量审核,只有自由流才限制批量审批 if (i > 0) { returnStatusMessage = "你选中的记录里包含自由审批流程所以不能批量审批。"; } return(false); } } else { returnStatusMessage = "你选中的记录里包含状态不明确的记录。"; return(false); } } else { returnStatusMessage = "你选中的记录里可能已被删除。"; return(false); } } BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 获取父子节点列表 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="tableName">目标表明</param> /// <param name="fieldCode">编码字段</param> /// <param name="code">编码</param> /// <param name="order">排序</param> /// <returns>主键数组</returns> public static string[] GetParentChildrensIdByCode(IDbHelper dbHelper, string tableName, string fieldCode, string code, string order) { return(BaseBusinessLogic.FieldToArray(GetParentChildrensByCode(dbHelper, tableName, fieldCode, code, order, true), BaseBusinessLogic.FieldId)); }
/// <summary> /// 获取等审核信息 /// </summary> /// <param name="userId">用户主键</param> /// <param name="categoryCode">分类代码</param> /// <param name="searchValue">查询字符串</param> /// <param name="showAuditReject">显示退回的</param> /// <returns>数据表</returns> public DataTable GetWaitForAudit(string userId = null, string categoryCode = null, string categorybillFullName = null, string searchValue = null, bool showAuditReject = true) { if (string.IsNullOrEmpty(userId)) { userId = this.UserInfo.Id; } string sqlQuery = " SELECT * " + " FROM " + BaseWorkFlowCurrentEntity.TableName // 未被删除的,有效的数据,还没能审核结束的 + " WHERE (" + BaseWorkFlowCurrentEntity.FieldDeletionStateCode + " = 0) " // Enabled 0 表示,审核还没结束 + " AND (" + BaseWorkFlowCurrentEntity.FieldEnabled + " = 0) "; if (!showAuditReject) { sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldAuditStatus + " != 'AuditReject') "; } if (!string.IsNullOrEmpty(userId)) { // 待审核的工作流(指向用户的) switch (BaseSystemInfo.UserCenterDbType) { case DbTypes.Access: sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldToUserId + "= '" + userId + "' "; break; default: sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldToUserId + "=" + userId + " "; break; } //(指向角色的) BaseUserManager userManager = new BaseUserManager(this.UserInfo); string[] roleIds = userManager.GetAllRoleIds(userId); if (roleIds != null && roleIds.Length > 0) { sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToRoleId + " IN (" + StringUtil.ArrayToList(roleIds) + ")"; } //(指向部门的) string[] organizeIds = userManager.GetAllOrganizeIds(userId); if (organizeIds != null && organizeIds.Length > 0) { sqlQuery += " OR (" + BaseWorkFlowCurrentEntity.FieldToUserId + " IS NULL AND + " + BaseWorkFlowCurrentEntity.FieldToDepartmentId + " IN (" + StringUtil.ArrayToList(organizeIds) + "))"; } sqlQuery += " ) "; } if (!string.IsNullOrEmpty(categoryCode)) { BaseWorkFlowBillTemplateManager templateManager = new BaseWorkFlowBillTemplateManager(this.DbHelper, this.UserInfo); DataTable dataTable = templateManager.Search(string.Empty, categoryCode, string.Empty, null, false); string categoryCodes = BaseBusinessLogic.FieldToList(dataTable, BaseWorkFlowBillTemplateEntity.FieldCode); if (!string.IsNullOrEmpty(categoryCodes)) { sqlQuery += " AND (BaseWorkFlowCurrent.CategoryCode IN (" + categoryCodes + ")) "; } } if (!string.IsNullOrEmpty(categorybillFullName)) { sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.TableName + "." + BaseWorkFlowCurrentEntity.FieldCategoryFullName + " ='" + categorybillFullName + "') "; } List <IDbDataParameter> dbParameters = new List <IDbDataParameter>(); if (!String.IsNullOrEmpty(searchValue)) { searchValue = searchValue.Trim(); sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldObjectFullName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldObjectFullName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditUserRealName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditUserRealName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditIdea + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditIdea); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditStatusName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditStatusName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToDepartmentName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldToDepartmentName); sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToUserRealName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldToUserRealName) + ")"; if (searchValue.IndexOf("%") < 0) { searchValue = "%" + searchValue + "%"; } dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldObjectFullName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditUserRealName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditIdea, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditStatusName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldToDepartmentName, searchValue)); dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldToUserRealName, searchValue)); } // 排序字段 sqlQuery += " ORDER BY " + BaseWorkFlowCurrentEntity.FieldSendDate; return(DbHelper.Fill(sqlQuery, dbParameters.ToArray())); }
/// <summary> /// 从Excel文件导入(角色) /// </summary> /// <param name="filePath"></param> /// <returns></returns> private bool DoImport(string filePath) { bool returnValue = false; // 鼠标忙碌状态 this.Cursor = Cursors.WaitCursor; try { //将Excel表转换为DataTable string error = ""; DataTable dataTable = new DataTable(); AsposeExcelTools.ExcelFileToDataTable(filePath, out dataTable, out error); //检查Excell转为DataTable是否成功 if (error != "") { MessageBox.Show(error, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } //是否有记录 if (dataTable.Rows.Count > 0) { //将第一行数据给数据列置名称,以便于识别和调用数据。 int columnsCount = 0; for (columnsCount = 0; columnsCount < dataTable.Columns.Count; columnsCount++) { dataTable.Columns[columnsCount].ColumnName = dataTable.Rows[0][columnsCount].ToString().Trim(); } //循环处理每行数据 int rowsCount = 0; int errorCount = 0; BaseRoleEntity tempentity; string statusCode = string.Empty; string statusMessage = string.Empty; DataTable dt = DotNetService.Instance.RoleService.GetDataTable(UserInfo); for (rowsCount = 1; rowsCount < dataTable.Rows.Count; rowsCount++) { //角色名称不允许导入重复项 bool exists = BaseBusinessLogic.Exists(dt, BaseRoleEntity.FieldRealName, dataTable.Rows[rowsCount][BaseRoleEntity.FieldRealName].ToString()); if (!exists) { //清空实体 tempentity = new BaseRoleEntity(); //给实体赋值 tempentity.RealName = dataTable.Rows[rowsCount][BaseRoleEntity.FieldRealName].ToString(); tempentity.Code = dataTable.Rows[rowsCount][BaseRoleEntity.FieldCode].ToString(); tempentity.Description = dataTable.Rows[rowsCount][BaseRoleEntity.FieldDescription].ToString(); tempentity.Enabled = int.Parse(dataTable.Rows[rowsCount][BaseRoleEntity.FieldEnabled].ToString()); tempentity.CategoryCode = dataTable.Rows[rowsCount][BaseRoleEntity.FieldCategoryCode].ToString(); tempentity.AllowDelete = 1; tempentity.AllowEdit = 1; tempentity.DeletionStateCode = 0; tempentity.IsVisible = 1; DotNetService.Instance.RoleService.Add(UserInfo, tempentity, out statusCode, out statusMessage); } else { errorCount++; } } this.Changed = true; returnValue = true; MessageBox.Show("共有" + (dataTable.Rows.Count - 1) + "条记录," + (dataTable.Rows.Count - 1 - errorCount).ToString() + "条记录被成功导入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { this.ProcessException(ex); } finally { // 设置鼠标默认状态 this.Cursor = Cursors.Default; } return(returnValue); }
/// <summary> /// 获取下一步是谁审核的功能 /// </summary> /// <param name="workFlowCurrentEntity">当前审核情况</param> /// <returns>下一步审核</returns> public BaseWorkFlowStepEntity GetNextWorkFlowStep(BaseWorkFlowCurrentEntity workFlowCurrentEntity) { BaseWorkFlowStepEntity workFlowStepEntity = null; DataTable dt = null; string nextActivityId = string.Empty; // 1. 从工作流审核步骤里选取审核步骤 BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo); // 若是会签 bool allPersons = false; if (!string.IsNullOrEmpty(workFlowCurrentEntity.ActivityType) && workFlowCurrentEntity.ActivityType.Equals("AllPersons")) { if (!string.IsNullOrEmpty(workFlowCurrentEntity.ToUserId) && workFlowCurrentEntity.ToUserId.IndexOf(",") >= 0) { // 这里是识别是会签 allPersons = true; List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldProcessId, workFlowCurrentEntity.ProcessId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldActivityId, workFlowCurrentEntity.ActivityId)); workFlowStepEntity = BaseEntity.Create <BaseWorkFlowStepEntity>(workFlowStepManager.GetDataTable(parameters)); // 这里是替换已经审核的人员 workFlowCurrentEntity.ToUserId = workFlowCurrentEntity.ToUserId.Replace(this.UserInfo.Id, "").Trim(','); workFlowStepEntity.AuditUserId = workFlowCurrentEntity.ToUserId; workFlowStepEntity.AuditUserRealName = new BaseUserManager().GetUsersName(workFlowCurrentEntity.ToUserId); } } // 若不是会签 if (!allPersons) { // 工作流主键 string workFlowId = workFlowCurrentEntity.ProcessId.ToString(); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldProcessId, workFlowId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0)); dt = workFlowStepManager.GetDataTable(parameters, BaseWorkFlowStepEntity.FieldSortCode); if (dt.Rows.Count > 0) { dt.Columns.Remove(BaseWorkFlowStepEntity.FieldId); dt.Columns[BaseWorkFlowStepEntity.FieldActivityId].ColumnName = BaseWorkFlowStepEntity.FieldId; } else { // 2. 从工作流审核模板里选取审核步骤 下一步是多少?按工作流进行查找审核步骤 BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldProcessId, workFlowId)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0)); dt = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode); } // 审核步骤主键 string activityId = string.Empty; if (workFlowCurrentEntity.ActivityId != null) { activityId = workFlowCurrentEntity.ActivityId.ToString(); } if (dt.Rows.Count == 0) { return(workFlowStepEntity); } if (!string.IsNullOrEmpty(activityId)) { nextActivityId = BaseSortLogic.GetNextId(dt, activityId.ToString()); } else { nextActivityId = dt.Rows[0][BaseWorkFlowActivityEntity.FieldId].ToString(); } } if (!string.IsNullOrEmpty(nextActivityId) && dt != null) { // workFlowActivityEntity = workFlowActivityManager.GetObject(nextActivityId); DataRow dr = BaseBusinessLogic.GetDataRow(dt, nextActivityId); workFlowStepEntity = BaseEntity.Create <BaseWorkFlowStepEntity>(dr); workFlowStepEntity.ActivityId = int.Parse(nextActivityId); } return(workFlowStepEntity); }
/// <summary> /// 按角色获取用户列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="roleId">角色主键</param> /// <returns>数据表</returns> public DataTable GetUserDTByRole(BaseUserInfo userInfo, string roleId) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif DataTable dataTable = new DataTable(BaseUserEntity.TableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); string sqlQuery = " SELECT " + BaseUserEntity.TableName + "." + BaseUserEntity.FieldId + "," + BaseUserEntity.TableName + "." + BaseUserEntity.FieldRealName + "," + BaseUserEntity.TableName + "." + BaseUserEntity.FieldUserOnLine + " FROM " + BaseUserEntity.TableName; sqlQuery += " WHERE (" + BaseUserEntity.TableName + "." + BaseUserEntity.FieldDeletionStateCode + " = 0 " + " AND " + BaseUserEntity.TableName + "." + BaseUserEntity.FieldEnabled + " = 1 " + " AND " + BaseUserEntity.TableName + "." + BaseUserEntity.FieldIsVisible + " = 1 ) "; if (!String.IsNullOrEmpty(roleId)) { // 从用户默认橘色 sqlQuery += " AND (" + BaseUserEntity.TableName + "." + BaseUserEntity.FieldRoleId + " = '" + roleId + "') "; // 从兼职表读取用户 sqlQuery += " OR " + BaseUserEntity.FieldId + " IN (" + " SELECT " + BaseUserRoleEntity.FieldUserId + " FROM " + BaseUserRoleEntity.TableName + " WHERE " + BaseUserRoleEntity.TableName + "." + BaseUserRoleEntity.FieldDeletionStateCode + " = 0 " + " AND " + BaseUserRoleEntity.TableName + "." + BaseUserRoleEntity.FieldEnabled + " = 1 " + " AND " + BaseUserRoleEntity.TableName + "." + BaseUserRoleEntity.FieldRoleId + " = '" + roleId + "') "; } sqlQuery += " ORDER BY " + BaseUserEntity.TableName + "." + BaseUserEntity.FieldSortCode; dataTable = userManager.Fill(sqlQuery); dataTable.TableName = BaseUserEntity.TableName; BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_GetUserDTByDepartment, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(dataTable); }
/// <summary> /// 添加实体 /// </summary> /// <param name="baseMessageEntity">实体</param> public string AddEntity(BaseMessageEntity baseMessageEntity) { string sequence = string.Empty; this.Identity = false; if (baseMessageEntity.SortCode == null || baseMessageEntity.SortCode == 0) { BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); baseMessageEntity.SortCode = int.Parse(sequence); } if (baseMessageEntity.Id != null) { sequence = baseMessageEntity.Id.ToString(); } SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, BaseMessageEntity.FieldId); if (!this.Identity) { if (string.IsNullOrEmpty(baseMessageEntity.Id)) { sequence = BaseBusinessLogic.NewGuid(); baseMessageEntity.Id = sequence; } sqlBuilder.SetValue(BaseMessageEntity.FieldId, baseMessageEntity.Id); } else { if (!this.ReturnId && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2)) { if (DbHelper.CurrentDbType == DbTypes.Oracle) { sqlBuilder.SetFormula(BaseMessageEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DbHelper.CurrentDbType == DbTypes.DB2) { sqlBuilder.SetFormula(BaseMessageEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2)) { if (string.IsNullOrEmpty(baseMessageEntity.Id)) { if (string.IsNullOrEmpty(sequence)) { BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity); sequence = sequenceManager.GetSequence(this.CurrentTableName); } baseMessageEntity.Id = sequence; } sqlBuilder.SetValue(BaseMessageEntity.FieldId, baseMessageEntity.Id); } } } this.SetEntity(sqlBuilder, baseMessageEntity); if (UserInfo != null) { sqlBuilder.SetValue(BaseMessageEntity.FieldCreateUserId, UserInfo.Id); sqlBuilder.SetValue(BaseMessageEntity.FieldCreateBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseMessageEntity.FieldCreateOn); if (UserInfo != null) { sqlBuilder.SetValue(BaseMessageEntity.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(BaseMessageEntity.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseMessageEntity.FieldModifiedOn); if (this.Identity && (DbHelper.CurrentDbType == DbTypes.SqlServer || DbHelper.CurrentDbType == DbTypes.Access)) { sequence = sqlBuilder.EndInsert().ToString(); } else { sqlBuilder.EndInsert(); } return(sequence); }
/// <summary> /// 获取内部组织机构 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetInnerOrganizeDT(BaseUserInfo userInfo) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif // 是否需要获取用户状态 bool getOnLine = false; lock (locker) { using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo); if (MessageService.LaseInnerOrganizeCheck == DateTime.MinValue) { getOnLine = true; } else { // 2008.01.23 JiRiGaLa 修正错误 TimeSpan timeSpan = DateTime.Now - MessageService.LaseInnerOrganizeCheck; if ((timeSpan.Minutes * 60 + timeSpan.Seconds) >= BaseSystemInfo.OnLineCheck * 100) { getOnLine = true; } } if (OnLineStateDT == null || getOnLine) { string commandText = " SELECT * " + " FROM " + BaseOrganizeEntity.TableName + " WHERE " + BaseOrganizeEntity.FieldDeletionStateCode + " = 0 " + " AND " + BaseOrganizeEntity.FieldIsInnerOrganize + " = 1 " + " AND " + BaseOrganizeEntity.FieldEnabled + " = 1 " + " ORDER BY " + BaseOrganizeEntity.FieldSortCode; InnerOrganizeDT = organizeManager.Fill(commandText); InnerOrganizeDT.TableName = BaseOrganizeEntity.TableName; MessageService.LaseInnerOrganizeCheck = DateTime.Now; } // BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } } // 写入调试信息 #if (DEBUG) if (getOnLine) { BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); } #endif return(InnerOrganizeDT); }
/// <summary> /// 保存本地 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveBill_Click(object sender, EventArgs e) { //构建实体 ZtoPrintBillEntity printBillEntity = BuildPrintEntity(); //if (!string.IsNullOrEmpty(PrintBillId)) //{ // printBillEntity = new ZtoPrintBillManager(BillPrintHelper.DbHelper).GetObject(PrintBillId); //} //printBillEntity.SendMan = txtSendMan.Text; //printBillEntity.SendPhone = txtSendPhone.Text; //printBillEntity.SendCompany = txtSendCompany.Text; //printBillEntity.SendAddress = txtSendAddress.Text; //printBillEntity.SendDate = string.IsNullOrEmpty(txtSendDate.Text) ? DateTime.Now.ToString(BaseSystemInfo.DateFormat) : txtSendDate.Text; //if (!string.IsNullOrEmpty(dgvSendArea.Text)) //{ // var sendAreaArray = dgvSendArea.Text.Split('-'); // printBillEntity.SendProvince = sendAreaArray[0]; // printBillEntity.SendCity = sendAreaArray[1]; // printBillEntity.SendCounty = sendAreaArray[2]; //} //printBillEntity.ReceiveMan = txtReceiveMan.Text; //printBillEntity.ReceivePhone = txtReceivePhone.Text; //printBillEntity.ReceiveCompany = txtReceiveCompany.Text; //printBillEntity.ReceiveAddress = txtReceiveAddress.Text; //if (!string.IsNullOrEmpty(dgvReceiveArea.Text)) //{ // var receiveAreaArray = dgvReceiveArea.Text.Split('-'); // printBillEntity.ReceiveProvince = receiveAreaArray[0]; // printBillEntity.ReceiveCity = receiveAreaArray[1]; // printBillEntity.ReceiveCounty = receiveAreaArray[2]; //} //printBillEntity.GoodsName = cmbGoodsName.Text; //printBillEntity.Weight = txtGoodsWeight.Text; //printBillEntity.GOODS_PAYMENT = string.IsNullOrEmpty(txtGoodsPayment.Text) ? 0 : decimal.Parse(txtGoodsPayment.Text); //printBillEntity.TOPAYMENT = string.IsNullOrEmpty(txtToPayMent.Text) ? 0 : decimal.Parse(txtToPayMent.Text); //printBillEntity.Remark = txtRemark.Text; //printBillEntity.BigPen = txtBigPen.Text; var ztoPrintBillManager = new ZtoPrintBillManager(BillPrintHelper.DbHelper); // 表示更新 if (!string.IsNullOrEmpty(PrintBillId)) { printBillEntity.Id = BaseBusinessLogic.ConvertToDecimal(PrintBillId); ztoPrintBillManager.Update(printBillEntity); XtraMessageBox.Show("更新成功", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _list.Clear(); var saveCount = int.Parse(cmbPrintNumber.Text); if (saveCount == 0) { cmbPrintNumber.Text = "1"; saveCount = 1; } // 这里要有订单号可以输入,不能系统生成,这样不科学,2016年6月15日22:33:11,杨恒连 // 如果他大于1条的话,后面的订单号要系统生成了 // 最好检查这个订单号有么有重复使用,重复使用就不好了,这样获取到用过的单号是要罚款的 if (!string.IsNullOrEmpty(txtOrderNumber.Text)) { saveCount = saveCount - 1; printBillEntity.OrderNumber = txtOrderNumber.Text; ztoPrintBillManager.Add(printBillEntity, true); _list.Add(printBillEntity); } for (int i = 0; i < saveCount; i++) { printBillEntity.OrderNumber = Guid.NewGuid().ToString("N").ToLower(); ztoPrintBillManager.Add(printBillEntity, true); _list.Add(printBillEntity); } XtraMessageBox.Show(string.Format("新增成功{0}条记录", cmbPrintNumber.Text), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 获取在线用户列表 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetOnLineState(BaseUserInfo userInfo) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 是否需要获取用户状态 bool getOnLine = false; // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif lock (locker) { using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 设置为在线状态 userManager.OnLine(userInfo.Id); if (MessageService.LaseOnLineStateCheck == DateTime.MinValue) { getOnLine = true; } else { // 2008.01.23 JiRiGaLa 修正错误 TimeSpan timeSpan = DateTime.Now - MessageService.LaseOnLineStateCheck; if ((timeSpan.Minutes * 60 + timeSpan.Seconds) >= BaseSystemInfo.OnLineCheck) { getOnLine = true; } } if (OnLineStateDT == null || getOnLine) { // 检查用户在线状态(服务器专用) userManager.CheckOnLine(); // 获取在线状态列表 OnLineStateDT = userManager.GetOnLineStateDT(); OnLineStateDT.TableName = BaseUserEntity.TableName; MessageService.LaseOnLineStateCheck = DateTime.Now; } // BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } } // 写入调试信息 #if (DEBUG) if (getOnLine) { BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); } #endif return(OnLineStateDT); }