/// <summary> /// 删除 /// </summary> /// <param name="serser"></param> /// <param name="e"></param> protected void lbtnDel_Click(object sender, EventArgs e) { using (BizDataContext context = new BizDataContext()) { int id = int.Parse((sender as LinkButton).CommandArgument); SysProcessProxy ProcessProxyData = context.FirstOrDefault <SysProcessProxy>(p => p.ProcessProxyId == id); context.Delete(ProcessProxyData); } Response.Redirect(Request.Url.ToString()); }
public Task <SysUser> FindByNameAsync(string userName) { SysUser user; if (string.IsNullOrWhiteSpace(userName)) { user = null; } else { using (BizDataContext context = new BizDataContext(true)) { user = context.FirstOrDefault <SysUser>(p => p.LoginName == userName); } } return(Task.FromResult <SysUser>(user)); }
/// <summary> /// 判断是否含有权限 /// </summary> /// <param name="roleId">角色ID号</param> /// <param name="entityId">实体ID号</param> /// <param name="operationEnum">操作方式</param> /// <returns></returns> public static bool TryCanOperation(int roleId, int entityId, EntityOperationEnum operationEnum) { using (BizDataContext context = new BizDataContext(GlobalObject.ConnString)) { var query = context.FirstOrDefault <SysDataPrivilege>(x => x.RoleId == roleId && x.EntityId == entityId && x.OperationId == (int)operationEnum); if (query == null) { return(false); } else if (query.PrivelegeLevel != (int)EntityPrivilegeEnum.NoPermission) { return(true); } } return(false); }
public static T_User GetUser(string loginName) { T_User user = null; if (!string.IsNullOrWhiteSpace(loginName)) { using (BizDataContext context = new BizDataContext(true)) { user = context.FirstOrDefault <T_User>(t => t.LoginName == loginName); if (user != null) { user.T_Roles = GetRoleList(context, user.User_ID); } } } return(user); }
protected void cbcForgetpwd_CallBack(object sender, CallBackEventArgs e) { try { string UserCode = Convert.ToString(e.Context["UserCode"]); string Email = Convert.ToString(e.Context["Email"]); if (string.IsNullOrWhiteSpace(UserCode) || string.IsNullOrWhiteSpace(Email)) { e.Result = "请输入用户名和邮箱!"; } else { using (BizDataContext context = new BizDataContext()) { var user = context.FirstOrDefault <T_User>(p => p.User_Code == UserCode && p.User_EMail == Email); if (user == null) { e.Result = "输入的用户名和邮箱不匹配!"; } else if (user.User_Status == (int)Enum.EffectiveFlagEnum.No) { e.Result = "此用户已经被禁用!"; } else { string NewPwd = new Random().Next(100000, 1000000).ToString(); user.User_Password = this.Md5(NewPwd); context.Update(user); //调用邮件接口 (new Drision.Framework.Manager.EmailManager(this.DataHelper)).SendEmail(user.User_EMail, string.Empty, "密码帮助", string.Format("新密码为:{0},请重新登录!", NewPwd)); e.Result = "已将新密码发到您的邮箱!"; } } } } catch (Exception ex) { e.Result = ex.Message; } }
/// <summary> /// 发布工作流 /// </summary> /// <param name="data"></param> /// <returns></returns> public string PublishWorkFlow(WfWorkflowData data, long?oldProcessId) { try { using (BizDataContext context = new BizDataContext()) { //先把对应的已启用的流程状态改为已升级 var oldProcess = context.FirstOrDefault <SysProcess>(p => p.ProcessType == data.Process.ProcessType && p.ProcessStatus == (int)ProcessState.StartUsed); if (oldProcess != null) { oldProcess.ProcessStatus = (int)ProcessState.Updated; context.UpdatePartial(oldProcess, p => new { p.ProcessStatus }); } return(InternalSaveWorkFlow(context, data, oldProcessId)); } } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// 发布 /// </summary> public void Publish() { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { //TO DO 验证流程的完整性 //将对应的已启用的流程的状态改为已升级 SysProcess oldProcess = db.FirstOrDefault <SysProcess>(p => p.ProcessType == _process.ProcessType && p.ProcessStatus == (int)ProcessState.StartUsed); if (oldProcess != null) { oldProcess.ProcessStatus = (int)ProcessState.Updated; db.UpdatePartial(oldProcess, p => new { p.ProcessStatus }); } //将当前流程版本,状态改为已启用 _process.ProcessStatus = (int)ProcessState.StartUsed; db.UpdatePartial(_process, p => new { p.ProcessStatus }); } ts.Complete(); } }
/// <summary> /// 活动实体的内容 /// </summary> /// <param name="process"></param> /// <param name="activityInstance"></param> /// <param name="data"></param> private void LoadActivityEntityData(BizDataContext context, SysProcess process, WfActivityInstance activityInstance, WfWorkflowInstanceData data) { //实体名 string entityName = process.ActivityEntity.EntityName; var es = IEntitySchemaHelper.Get(entityName); //主键名 string keyFieldName = es.KeyName;// process.ActivityEntity.GetKeyFieldName(); //字段列表 var fieldList = process.ActivityEntity.Fields.ToList(); //签核流程 bool isApprove = process.ProcessCategory == (int)ProcessCategory.Approve; if (isApprove) { SysApproveActivityData ad = context.FirstOrDefault <SysApproveActivityData>(p => p.ActivityInstanceId == activityInstance.ActivityInstanceId); if (ad != null) { WfActivityEntityInstance entity = GetApproveEntityData(context, ad); activityInstance.ActivityEntityInstance = entity; } } else { //标哥说普通流程活动实例ID和活动实体ID是一样的…… int id = activityInstance.ActivityInstanceId; dynamic entityData = (new OrgManager(context)).GetEntity(entityName, id); if (entityData != null) { Type entityType = entityData.GetType(); WfActivityEntityInstance entity = new WfActivityEntityInstance() { ActivityEntityInstanceId = id, }; //属性的键值对 entity.ActivityEntityInstanceData = entityType.GetProperties() .Where(i => i.Name != keyFieldName && !IgnoreList.Contains(i.Name)) .ToDictionary(i => i.Name, i => { var pValue = new WfActivityFieldData(); try { pValue.Value = Convert.ToString(i.GetValue(entityData, null)); } catch { } return(pValue); }); //加上DisplayText foreach (var i in entity.ActivityEntityInstanceData) { var field = fieldList.FirstOrDefault(q => q.FieldName.Contains(i.Key)); if (field != null) { i.Value.DisplayText = field.DisplayText; } else { i.Value.DisplayText = i.Key; } } activityInstance.ActivityEntityInstance = entity; } } }
protected void btnNextStep_Click(object sender, EventArgs e) { try { string entityType = this.ddlEntityType.SelectedValue; string displayText = this.txtSysEntity.Text.Trim(); string entityName = "T_" + displayText.ToPingYin(); string formName = this.txtFormName.Text.Trim(); string formTitle = this.txtFormTitle.Text.Trim(); string formDecription = this.txtFormDescription.Text.Trim(); if (string.IsNullOrEmpty(formName)) { throw new Exception("表单名称不能为空"); } using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { switch (entityType) { case "0": case "1": if (this.EntityId == null) { throw new Exception("关联实体不能为空"); } break; case "2": if (string.IsNullOrEmpty(displayText)) { throw new Exception("关联实体不能为空"); } if (string.IsNullOrEmpty(entityName)) { throw new Exception("关联实体表名不能为空"); } SysEntity tempEntity = db.FirstOrDefault <SysEntity>(p => p.EntityName == entityName || p.DisplayText == displayText); if (tempEntity != null) { throw new Exception("当前新增的关联实体名称已存在"); } tempEntity = new SysEntity() { EntityId = db.GetNextIdentity(), EntityName = entityName, DisplayText = displayText, Description = displayText, IsFormEntity = true, CreateTime = DateTime.Now, }; db.Insert(tempEntity); this.EntityId = tempEntity.EntityId; //默认加一个主键字段 SysField tempField = new SysField() { FieldId = db.GetNextIdentity(), EntityId = tempEntity.EntityId, FieldName = displayText.ToPingYin() + "_Id", DisplayText = displayText + "ID", Description = displayText + "ID", DataType = (int)DataTypeEnum.pkey, IsFormField = true, //2013-9-24 zhumin }; db.Insert(tempField); break; default: break; } if (this.FormId != null) { SysForm form = db.FindById <SysForm>(this.FormId); if (form != null) { form.FormName = formName; form.EntityId = this.EntityId; form.UpdateTime = DateTime.Now; form.UpdateUserId = this.LoginUserID; form.FormTitle = formTitle; form.FormDescription = formDecription; db.UpdatePartial(form, p => new { p.FormName, p.FormTitle, p.FormDescription, p.EntityId, p.UpdateTime, p.UpdateUserId }); } else { throw new Exception("表单不存在"); } } else { SysForm form = new SysForm() { FormId = db.GetNextIdentity(), FormName = formName, FormTitle = formTitle, FormDescription = formDecription, EntityId = this.EntityId, CreateTime = DateTime.Now, CreateUserId = this.LoginUserID, OwnerId = this.LoginUserID, State = (int)FormState.New, }; db.Insert(form); this.FormId = form.FormId; } } ts.Complete(); } Response.Redirect(string.Format("FormDesigner_SecondStep.aspx?id={0}", this.FormId)); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
protected void buttonLogin_Click(object sender, EventArgs e) { try { //if (!RegValidate.ValidateFromRegistryKey()) //{ // Drision.Framework.Common.MessageBox.AlertAndGo(this, "此产品未经注册或已经过期", "Error.aspx"); // return; //} Session["T_Function"] = null; //清一下菜单缓存 Session["ModuleId"] = 1; Session["FunctionId"] = 1; string originalPwd = this.txtPwd.Text.Trim(); string pwd = this.Md5(originalPwd); string account = this.txtLogin.Text.Trim(); using (BizDataContext db = new BizDataContext()) { var user = db.FirstOrDefault <T_User>(p => p.User_Code == account && (p.User_Password == pwd || p.User_Password == originalPwd)); if (user == null) { this.AjaxAlert("用户名或密码错误!"); } else if (user.User_Status == (int)Enum.EffectiveFlagEnum.No) { this.AjaxAlert("此用户已经被禁用!"); } else { LoginUser = user; if (this.loginRemind.Checked) { UserToCookie(user); } else { Response.Cookies["UserCode"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["User_Password"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["isChecked"].Expires = DateTime.Now.AddDays(-1); } //跳转 string returnUrl = Request.QueryString[WebConfigConstKey.returnUrlKey]; if (!string.IsNullOrEmpty(returnUrl)) { Response.Redirect(returnUrl); } else { Response.Redirect(AppSettings.HomePageUrl); } } } } catch (Exception ex) { this.AjaxAlert(ex); } }