protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (Request.QueryString["id"] != null) { Id = int.Parse(Request.QueryString["id"]); } if (Request.QueryString["ProcessId"] != null) { ProcessId = long.Parse(Request.QueryString["ProcessId"]); } //查询并加载数据 if (Id != null) { using (BizDataContext context = new BizDataContext()) { SysProcessProxy ProcessProxyData = context.FindById <SysProcessProxy>(Id); this.scOwner.SetValue(ProcessProxyData.OwnerId); this.scOwner.Text = context.FindById <T_User>(ProcessProxyData.OwnerId).User_Name; this.scProxy.SetValue(ProcessProxyData.ProxyId); this.scProxy.Text = context.FindById <T_User>(ProcessProxyData.ProxyId).User_Name; this.dtcStartTime.SetValue(ProcessProxyData.StartTime); this.dtcEndTime.SetValue(ProcessProxyData.EndTime); } } if (HttpContext.Current.Request.UrlReferrer != null) { this.btnCancel.PostBackUrl = HttpContext.Current.Request.UrlReferrer.ToString(); ViewState["UrlReferrer"] = HttpContext.Current.Request.UrlReferrer; } } }
public string GetPageUrl(BizDataContext db, SysEntity entity, SysPage page) { string str = string.Empty; if ((page != null) && page.ModuleId.HasValue) { page.OwnerModule = db.FindById <SysModule>(new object[] { page.ModuleId }); if (page.OwnerModule != null) { page.OwnerModule.EntityCategory = db.FindById <SysEntityCategory>(new object[] { page.OwnerModule.CategoryId }); if (page.OwnerModule.EntityCategory != null) { str = string.Format("~/{0}_{1}/{2}", page.OwnerModule.EntityCategory.CategoryName, page.OwnerModule.ModuleName, page.PageName); } } return(str); } if (entity != null) { entity.OwnerModule = db.FindById <SysModule>(new object[] { entity.ModuleId }); if (entity.OwnerModule == null) { return(str); } entity.OwnerModule.EntityCategory = db.FindById <SysEntityCategory>(new object[] { entity.OwnerModule.CategoryId }); if (entity.OwnerModule.EntityCategory != null) { str = string.Format("~/{0}_{1}/{2}", entity.OwnerModule.EntityCategory.CategoryName, entity.OwnerModule.ModuleName, page.PageName); } } return(str); }
/// <summary> /// 加载数据 /// </summary> void LoadData() { this.TracerBackground = System.Configuration.ConfigurationManager.AppSettings[ConstKey.ProcessDetailBackground]; if (string.IsNullOrEmpty(this.TracerBackground)) { this.TracerBackground = "E8E8E8"; } string id = Request.QueryString["id"]; if (!string.IsNullOrEmpty(id)) { int piid = int.Parse(id); using (BizDataContext context = new BizDataContext()) { this.PICache = new ProcessInstanceCacheFactory(context); this.PI = PICache.GetProcessInstanceCache(piid); var data = this.PI; lblProcessName.Text = data.Process.ProcessName; var startUser = context.FindById <T_User>(data.StartUserId); var startDept = context.FindById <T_Department>(data.StartDeptId); if (startUser != null) { lblStartUser.Text = startUser.User_Name; } if (startDept != null) { lblStartDept.Text = startDept.Department_Name; } if (data.StartTime.HasValue) { lblStartTime.Text = data.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } if (data.EndTime.HasValue) { lblEndTime.Text = data.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } lblStatus.Text = GetStatusName(data.InstanceStatus); this.ProcessInstanceId = data.ProcessInstanceId; int objectId = data.ObjectId; string entityName = data.Process.ProcessEntity.EntityName; string displayValue = (new OrgManager(context)).GetDisplayValue(entityName, objectId); lblObject.Text = displayValue; } } }
/// <summary> /// 绑定第三层Repeater,这个是SysApproveActivityData(已经审核的)和SysWorkItem(未参与审核的) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rpApproveGroup_ItemDataBound(object sender, RepeaterItemEventArgs e) { Repeater rpApproveActivity = e.Item.FindControl("rpApproveActivity") as Repeater; SysWorkItemApproveGroup group = e.Item.DataItem.GetPropertyValue("Group") as SysWorkItemApproveGroup; using (BizDataContext context = new BizDataContext()) { var result = context.Where <SysApproveActivityData>(p => p.ApproveGroupId == group.ApproveGroupId) .Select(p => new { p.ApproveTime, p.WorkItemId, User_Name = context.FindById <T_User>(p.ApproveUserId).User_Name, ApproveResult = p.ApproveResult, ApproveComment = p.ApproveComment, AddingUser = p.IsAdded == true ? "[加签]" : "", ProxyUser = p.IsProxy == true ? "[代理]" : "", }).ToList().Select(p => new UserApproveComment() { WorkItemId = p.WorkItemId, User_Name = p.User_Name, ApproveComment = p.ApproveComment, AddingUser = p.AddingUser, ProxyUser = p.ProxyUser, ApproveResult = GetCheckState(p.ApproveResult), ApproveDate = string.Format("{0:MM/dd HH:mm}", p.ApproveTime), }).ToList(); var idList = result.Select(p => p.WorkItemId); var otherList = group.WorkItems.Where(p => !idList.Contains(p.WorkItemId)); int?state = null; foreach (var other in otherList) { result.Add(new UserApproveComment() { WorkItemId = other.WorkItemId, User_Name = context.FindById <T_User>(other.OwnerId).User_Name, ApproveComment = other.Status == (int)WorkItemStatus.CancelledBySystem ? "未参与审核" : GetCheckState(state), AddingUser = string.Empty, ProxyUser = string.Empty, ApproveResult = other.Status == (int)WorkItemStatus.CancelledBySystem ? "未参与审核" : GetCheckState(state), }); } rpApproveActivity.DataSource = result; rpApproveActivity.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { //加载数据 if (!string.IsNullOrEmpty(Request.QueryString["id"])) { long ProcessId = long.Parse(Request.QueryString["id"]); using (BizDataContext context = new BizDataContext()) { SysProcess process = context.FindById <SysProcess>(ProcessId); if (process != null) { this.lblProcessName.Text = process.ProcessName; this.lblProcessDescription.Text = process.ProcessDescription; this.lblStatus.Text = EnumHelper.GetDescription(typeof(ProcessState), process.ProcessStatus.Value); this.gcProcessProxy.DataSource = context.Where <SysProcessProxy>(p => p.ProcessId == ProcessId).ToList(); this.gcProcessProxy.DataBind(); } } this.btnAdd.PostBackUrl = "~/SystemManagement/ProcessProxyAdd.aspx?ProcessId=" + Request.QueryString["id"]; } } }
public T_WorkItemBase GetWorkItemBase(int id) { using (BizDataContext context = new BizDataContext(true)) { return(context.FindById <T_WorkItemBase>(new object[] { id })); } }
public bool ChangeWorkItemState(int id, T_WorkItemBaseStateEnum state, out string errorMsg) { bool flag; errorMsg = string.Empty; try { using (BizDataContext context = new BizDataContext(true)) { T_WorkItemBase base2 = context.FindById <T_WorkItemBase>(new object[] { id }); if ((base2 != null) && (base2.WorkItemBase_Id > 0)) { base2.State = new int?((int)state); context.UpdatePartial <T_WorkItemBase>(base2, p => new { State = p.State }); return(true); } errorMsg = "未获取到T_WorkItemBase实体"; flag = false; } } catch (Exception exception) { errorMsg = exception.Message; flag = false; } return(flag); }
public static int GetUserIdFromToken(string token, BizDataContext db = null) { SysUserToken token2; if (string.IsNullOrWhiteSpace(token)) { throw new SsoException("令牌为空", SsoException.NullToken); } if (db == null) { using (db = new BizDataContext()) { token2 = db.FindById <SysUserToken>(token); token2.ExpireTime = DateTime.Now.AddHours(2.0); db.UpdatePartial(token2, p => new { p.ExpireTime }); } } else { token2 = db.FindById <SysUserToken>(token); token2.ExpireTime = DateTime.Now.AddHours(2.0); db.UpdatePartial(token2, p => new { p.ExpireTime }); } if (token2 == null) { throw new SsoException("令牌无效", SsoException.InvalidToken); } if (token2.ExpireTime < DateTime.Now) { throw new SsoException("令牌已过期", SsoException.ExpiredToken); } return(token2.UserId); }
private string GetStartUserName(BizDataContext context, string wiId) { try { int id = wiId.ToInt(); var wi = context.FindById <SysWorkItem>(id); var ai = context.FindById <SysActivityInstance>(wi.ActivityInstanceId); var pi = context.FindById <SysProcessInstance>(ai.ProcessInstanceId); var user = context.FindById <T_User>(pi.StartUserId); return(user.User_Name); } catch { return(null); } }
/// <summary> /// 删除流程参与人 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { try { long?id = (sender as LinkButton).CommandArgument.ToLongNullable(); using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { SysProcessParticipant p = db.FindById <SysProcessParticipant>(id); if (p != null) { //同步删除关联的活动参与人 var apList = db.Where <SysActivityParticipant>(x => x.ParticipantId == id); foreach (var ap in apList) { db.Delete(ap); } db.Delete(p); } } ts.Complete(); } BindGrid(); } catch (Exception ex) { this.AjaxAlert(ex); } }
private WfActivityEntityInstance GetApproveEntityData(BizDataContext context, SysApproveActivityData p) { WfActivityEntityInstance entity = new WfActivityEntityInstance() { ActivityEntityInstanceId = p.DataId, }; var dic = new Dictionary <string, WfActivityFieldData>(); var list = context.Where <SysApproveActivityData>(i => i.ApproveGroupId == p.ApproveGroupId).OrderBy(i => i.ApproveTime).ToList(); for (int i = 0; i < list.Count(); i++) { p = list.ElementAt(i); var user = context.FindById <T_User>(p.ApproveUserId); if (user != null) { dic[(1 + 3 * i).ToString()] = new WfActivityFieldData() { DisplayText = "审核人", Value = user.User_Name }; } dic[(2 + 3 * i).ToString()] = new WfActivityFieldData() { DisplayText = "审核时间", Value = Convert.ToString(p.ApproveTime) }; dic[(3 + 3 * i).ToString()] = new WfActivityFieldData() { DisplayText = "审核意见", Value = p.ApproveComment }; } entity.ActivityEntityInstanceData = dic; return(entity); }
public ViewQueryBase(BizDataContext context, IUserIdentity currentUser) { this.enumDict = new Dictionary <string, Dictionary <int, string> >(); this.boolDict = new Dictionary <string, Dictionary <bool, string> >(); this.DataHelper = context; this.CurrentUser = currentUser; this.CurrentDepartment = context.FindById <T_Department>(new object[] { currentUser.Department_ID }); this.ViewQueryExs = new List <ViewQueryEx>(); this.ViewFieldFormatDict = new Dictionary <string, string>(); }
public Task <SysUser> FindByIdAsync(long userId) { SysUser user; using (BizDataContext context = new BizDataContext(true)) { user = context.FindById <SysUser>(new object[] { userId }); } return(Task.FromResult <SysUser>(user)); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { //保存文本 string OriginalTitleText = this.hcTemplate.Value; //翻译成模板文本 string TemplateTitleText = Server.HtmlDecode(OriginalTitleText); AllNodes.ToList().ForEach(p => { TemplateTitleText = TemplateTitleText.Replace(p.Value, p.Key); }); //保存文本 string OriginalContentText = this.hcTemplate.Text; //翻译成模板文本 string TemplateContentText = Server.HtmlDecode(OriginalContentText); AllNodes.ToList().ForEach(p => { TemplateContentText = TemplateContentText.Replace(p.Value, p.Key); }); using (BizDataContext context = new BizDataContext()) { SysProcessRemindTemplate model; if (TemplateId == null) { model = new SysProcessRemindTemplate(); model.TemplateId = context.GetNextIdentity(); model.State = 1; } else { model = context.FindById <SysProcessRemindTemplate>(TemplateId.Value); } model.TemplateName = this.tcTemplateName.Text; model.TemplateType = this.ccTemplateType.SelectedValue.ToInt(); model.ProcessEntityId = this.ccProcessEntityId.SelectedValue.ToLong(); model.ActivityEntityId = this.ccActivityEntityId.SelectedValue.ToLong(); model.UseTimeType = this.ccUseTimeType.SelectedValue.ToInt(); model.ResultType = this.ccResultType.SelectedValue.ToInt(); model.OriginalTitleText = OriginalTitleText; model.OriginalContentText = OriginalContentText; model.TemplateContentText = TemplateContentText; model.TemplateTitleText = TemplateTitleText; if (TemplateId == null) { context.Insert(model); } else { context.Update(model); } } Response.Redirect("~/SystemManagement/ProcessTemplateQuery.aspx"); }
private string GetUserName(BizDataContext context, int?id) { string result = null; if (id != null) { var user = context.FindById <T_User>(id); if (user != null) { result = user.User_Name; } } return(result); }
/// <summary> /// 禁用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbtnDisable_Click(object sender, EventArgs e) { string id = (sender as LinkButton).CommandArgument; if (!string.IsNullOrEmpty(id)) { using (BizDataContext context = new BizDataContext()) { var model = context.FindById <SysProcessRemindTemplate>(id.ToLong()); model.State = 2; context.Update(model); BindGrid(); } } }
protected void btnAdd_Click(object sender, EventArgs e) { try { var id = this.ccWorkItemType.SelectedValue.ToIntNullable(); if (id != null) { using (BizDataContext context = new BizDataContext()) { var wi = context.FindById <Drision.Framework.OrgLibrary.InternalEntities.T_WorkItemType>(id); if (wi != null) { if (wi.CreatePageType == (int)WorkItemCreatePageType.DirectUrl) { if (!string.IsNullOrEmpty(wi.CreatePageUserDefinePage)) { Response.Redirect(wi.CreatePageUserDefinePage); } } else if (wi.CreatePageType == (int)WorkItemCreatePageType.MetaPage) { if (!string.IsNullOrEmpty(wi.EntityName) && !string.IsNullOrEmpty(wi.CreatePageName)) { var entity = this.EntityCache.SysEntity.FirstOrDefault <SysEntity>(p => p.EntityName == wi.EntityName); var page = this.EntityCache.SysPage.FirstOrDefault <SysPage>(p => p.PageName == wi.CreatePageName); if (entity != null && page != null) { string url = (this.Master as Site).GetPageUrl(entity, page); url = string.Format("{0}?typeid={1}", url, id); Response.Redirect(url); } } } else { throw new Exception("暂时不支持插件方式的新增页面路径"); } } } } } catch (Exception ex) { this.AjaxAlert(ex); } }
/// <summary> /// 发布 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnPublish_Click(object sender, EventArgs e) { try { SysForm form = this.DataHelper.FindById <SysForm>(this.FormId); if (form != null) { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { //更新表单状态 form.State = (int)FormState.StartUsed; form.UpdateTime = DateTime.Now; form.UpdateUserId = this.LoginUserID; db.UpdatePartial(form, p => new { p.State, p.UpdateUserId, p.UpdateTime }); //发布数据库 SysEntity entity = this.EntityCache.FindById <SysEntity>(this.EntityId); if (entity == null) //新增加的实体 { entity = db.FindById <SysEntity>(this.EntityId); if (entity == null) { throw new Exception("表单关联实体不存在"); } entity.Fields = db.Where <SysField>(p => p.EntityId == entity.EntityId); FormEntityPublishHelper publish = new FormEntityPublishHelper(entity, db); publish.Publish(); } } ts.Complete(); } } else { throw new Exception("表单不存在"); } this.AjaxAlertAndRedirect("发布成功", "FormQuery.aspx"); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
/// <summary> /// 绑定时将用户主键转为用户名称(前台调用) /// </summary> /// <param name="UserID"></param> /// <returns></returns> public string GetUserName(object UserID) { string User_Name = UserID == null ? "" : UserID.ToString(); if (UserID != null) { using (BizDataContext context = new BizDataContext()) { int id = int.Parse(UserID.ToString()); T_User User = context.FindById <T_User>(id); if (User != null) { User_Name = User.User_Name; } } } return(User_Name); }
public virtual void OnWorkItemCompleted(int wiBaseId, int wiId, string Id) { if (WebConfigAppSettings.UseSSOModel) { using (BizDataContext context = new BizDataContext(WebConfigAppSettings.HomeBizDBConnString, true)) { int num; if (int.TryParse(Id, out num)) { T_WorkItemBase base2 = context.FindById <T_WorkItemBase>(new object[] { num }); if (base2 != null) { base2.State = 1; context.Update(base2); } } } } }
public SysPathRule GetRule(int id) { using (BizDataContext context = new BizDataContext(true)) { SysPathRule rule = context.FindById <SysPathRule>(new object[] { id }); List <SysPathRuleItem> list = context.Where <SysPathRuleItem>(p => p.PathRuleId == id); foreach (SysPathRuleItem item in list) { if (item.ItemType == PathRuleMasterType.Role) { rule.Roles.Add(item.ObjectId); } else { rule.Users.Add(item.ObjectId); } } return(rule); } }
/// <summary> /// 初始化数据 /// </summary> /// <param name="context"></param> private void InitData(BizDataContext context) { if (TemplateId != null) { var RemindTemplate = context.FindById <SysProcessRemindTemplate>(TemplateId.Value); this.tcTemplateName.SetValue(RemindTemplate.TemplateName); this.ccProcessEntityId.SetValue(RemindTemplate.ProcessEntityId); this.ccActivityEntityId.SetValue(RemindTemplate.ActivityEntityId); this.ccTemplateType.SetValue(RemindTemplate.TemplateType); this.ccUseTimeType.SetValue(RemindTemplate.UseTimeType); this.ccResultType.SetValue(RemindTemplate.ResultType == null ? (int)ProcessTemplateResultType.Pass : RemindTemplate.ResultType.Value); //将两个字段赋到前台 this.hcTemplate.Value = RemindTemplate.OriginalTitleText; this.hcTemplate.Text = RemindTemplate.OriginalContentText; } else { this.tcTemplateName.SetValue("模板名称"); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { using (BizDataContext context = new BizDataContext()) { SysProcessProxy ProcessProxyData; if (Id == null) { ProcessProxyData = new SysProcessProxy() { ProcessProxyId = context.GetNextIdentity_Int(), ProcessId = ProcessId, OwnerId = Convert.ToInt32(this.scOwner.GetValue()), ProxyId = Convert.ToInt32(this.scProxy.GetValue()), StartTime = Convert.ToDateTime(this.dtcStartTime.GetValue()), EndTime = Convert.ToDateTime(this.dtcEndTime.GetValue()), CreateTime = DateTime.Now, Status = (int)ProxyStatus.Enable, }; context.Insert(ProcessProxyData); } else { ProcessProxyData = context.FindById <SysProcessProxy>(Id); ProcessProxyData.OwnerId = Convert.ToInt32(this.scOwner.GetValue()); ProcessProxyData.ProxyId = Convert.ToInt32(this.scProxy.GetValue()); ProcessProxyData.StartTime = Convert.ToDateTime(this.dtcStartTime.GetValue()); ProcessProxyData.EndTime = Convert.ToDateTime(this.dtcEndTime.GetValue()); context.Update(ProcessProxyData); } } Response.Redirect(ViewState["UrlReferrer"].ToString()); } catch (ApplicationException ex) { this.AjaxAlert(ex.Message); } }
protected void btnRead_Click(object sender, EventArgs e) { try { string idStr = (sender as LinkButton).CommandArgument; int id = Convert.ToInt32(idStr); using (BizDataContext context = new BizDataContext()) { var remind = context.FindById <SysRemind>(id); if (remind != null) { remind.State = (int)RemindStausEnum.Completed; context.Update(remind); BindRemind(); } } } catch (ApplicationException ex) { this.AjaxAlert(ex.Message); } }
/// <summary> /// 绑定角色ID号 /// </summary> private void BingDataToRoleId(string roleId) { //如果传入ID号有误,则变成下拉菜单来处理 bool nextSetp = true; using (BizDataContext Context = new BizDataContext()) { if (!string.IsNullOrEmpty(roleId)) { this.RoleId = Convert.ToInt32(roleId); var role = Context.FindById <T_Role>(RoleId); if (null != role) { this.lblRoleName.Text = role.Role_Name; this.lblRoleName.Visible = true; this.ddlRoleList.Visible = false; nextSetp = false; BingDataToDataList(); } } if (nextSetp) { var roleList = Context.Set <T_Role>().ToList(); this.ddlRoleList.DataSource = roleList; this.ddlRoleList.DataValueField = "Role_ID"; this.ddlRoleList.DataTextField = "Role_Name"; this.ddlRoleList.DataBind(); this.RoleId = Convert.ToInt32(this.ddlRoleList.SelectedValue); this.ddlRoleList.Visible = true; this.lblRoleName.Visible = false; } } }
private void BingDataToRoleId(string roleId) { //如果传入ID号有误,则变成下拉菜单来处理 bool nextSetp = true; if (!string.IsNullOrEmpty(roleId)) { this.RoleId = Convert.ToInt32(roleId); using (BizDataContext context = new BizDataContext()) { var query = context.FindById <T_Role>(this.RoleId); if (query != null) { lblRoleName.Text += query.Role_Name; this.ddlRoleList.Visible = false; nextSetp = false; } } } if (nextSetp) { using (BizDataContext Context = new BizDataContext()) { var roleList = Context.FetchAll <T_Role>(); this.ddlRoleList.DataSource = roleList; this.ddlRoleList.DataValueField = "Role_ID"; this.ddlRoleList.DataTextField = "Role_Name"; this.ddlRoleList.DataBind(); this.RoleId = Convert.ToInt32(this.ddlRoleList.SelectedValue); this.ddlRoleList.Visible = true; } } }
/// <summary> /// 清除流程 /// </summary> /// <param name="processId"></param> public string Delete(long processId) { try { using (BizDataContext context = new BizDataContext()) { SendToClient("正在删除旧流程定义...", 10); SysProcess process = context.FindById <SysProcess>(processId); if (process != null) { //禁用外键 DisableConstraint(); //删除流程 context.Delete(process); //删除活动 context.Where <SysActivity>(p => p.ProcessId == processId).ToList().ForEach(p => { //删除活动 context.Delete(p); //删除活动操作 context.Where <SysActivityOperation>(i => i.ActivityId == p.ActivityId).ToList().ForEach(i => { //删除活动操作 context.Delete(i); //删除活动操作步骤 context.Where <SysActivityStep>(q => q.OperationId == i.OperationId).ToList().ForEach(q => context.Delete(q)); }); //删除活动提醒 context.Where <SysActivityRemind>(i => i.ActivityId == p.ActivityId).ToList().ForEach(i => { //删除活动提醒 context.Delete(i); //删除活动提醒参与人 context.Where <SysActivityRemindParticipant>(q => q.RemindId == i.RemindId).ToList().ForEach(q => context.Delete(q)); }); //删除活动参与人 context.Where <SysActivityParticipant>(i => i.ActivityId == p.ActivityId).ToList().ForEach(i => context.Delete(i)); //删除表达式 context.Where <SysExpression>(i => i.ActivityId == p.ActivityId).ToList().ForEach(i => context.Delete(i)); }); //删除流程参与人 context.Where <SysProcessParticipant>(p => p.ProcessId == processId).ToList().ForEach(p => context.Delete(p)); //删除流程提醒 context.Where <SysProcessRemind>(p => p.ProcessId == processId).ToList().ForEach(p => { //删除流程提醒 context.Delete(p); //删除流程提醒参与人 context.Where <SysProcessRemindParticipant>(q => q.RemindId == p.RemindId).ToList().ForEach(q => context.Delete(q)); }); //删除连接线 context.Where <SysTransition>(p => p.ProcessId == processId).ToList().ForEach(p => context.Delete(p)); //启用外键 EnableConstraint(); return(null); } return(null); } } catch (Exception ex) { return(ex.Message); } }
public static List <SelectControlData> GetData(DataType DataType, Type t, object parameter, int currentUseID) { List <SelectControlData> list = new List <SelectControlData>(); List <NameValues> userList = new List <NameValues>(); using (BizDataContext context = new BizDataContext(true)) { if (DataType == DataType.All) { List <T_User> list3 = context.Set <T_User>().ToList <T_User>(); userList = (from user in context.Set <T_User>() join dep in context.Set <T_Department>() on user.Department_ID equals(int?) dep.Department_ID where (user.State == 0) && (dep.State == 0) orderby user.User_Name select new NameValues { Id = user.User_ID, Name = user.User_Name, DepID = user.Department_ID.ToInt(), DepName = dep.Department_Name, ParentDepID = dep.Parent_ID }).ToList <NameValues>(); } if (DataType == DataType.CurrentDep) { T_User currentUserModel = context.FindById <T_User>(new object[] { currentUseID }); if ((currentUserModel != null) && (currentUserModel.User_ID > 0)) { userList = (from dep in context.Set <T_Department>() join user in context.Set <T_User>() on dep.Department_ID equals user.Department_ID where (((dep.Department_ID == currentUserModel.Department_ID) && (user.State == 0)) && (dep.State == 0)) && (user.Department_ID != null) orderby user.User_Name select new NameValues { Id = user.User_ID, Name = user.User_Name, DepID = user.Department_ID.ToInt(), DepName = dep.Department_Name, ParentDepID = dep.Parent_ID }).ToList <NameValues>(); } } if (DataType == DataType.SubDep) { T_User t_user = context.FindById <T_User>(new object[] { currentUseID }); if ((t_user != null) && (t_user.User_ID > 0)) { T_Department currentDepModel = context.FindById <T_Department>(new object[] { t_user.Department_ID }); if ((currentDepModel != null) && (currentDepModel.Department_ID > 0)) { userList = (from dep in context.Set <T_Department>() join user in context.Set <T_User>() on dep.Department_ID equals user.Department_ID into user where dep.SystemLevelCode.StartsWith(currentDepModel.SystemLevelCode) select new NameValues { Id = t_user.User_ID, Name = t_user.User_Name, DepID = t_user.Department_ID.ToInt(), DepName = dep.Department_Name, ParentDepID = dep.Parent_ID }).ToList <NameValues>(); } } } if (DataType == DataType.Custom) { try { userList = ((ICustomSelectUser)Activator.CreateInstance(t)).GetCustomData(parameter); } catch (Exception exception) { AppLogHelper.Error(exception); } } } List <SelectControlData> depList = new List <SelectControlData>(); if ((userList != null) && (userList.Count > 0)) { depList = (from p in userList select new SelectControlData { id = p.DepID, name = p.DepName, pId = p.ParentDepID, open = true, userlist = new List <NameValues>(), icon = "/Content/metro/images/selectuser_icon.png" }).ToList <SelectControlData>().Distinct <SelectControlData>(new List_DepId()).ToList <SelectControlData>(); GetSelectControlData(userList, depList); } return(depList); }
/// <summary> /// 选中现有字段并添加为表单字段 /// </summary> /// <param name="sectionId"></param> /// <param name="parameter"></param> /// <returns></returns> private string SelectField(long sectionId, string parameter) { StringBuilder sb = new StringBuilder(); SysFormFieldSection section = this.DataHelper.FindById <SysFormFieldSection>(sectionId); if (section != null) { JavaScriptSerializer js = new JavaScriptSerializer(); object[] fieldList = js.DeserializeObject(parameter) as object[]; if (fieldList == null) { throw new Exception("回调参数不正确"); } var source = fieldList.Select(p => p as Dictionary <string, object>) .Select(p => new { FieldId = p["FieldId"].ToLong(), RelationId = p["RelationId"].ToStringNullable().ToLongNullable(), }); int maxOrder = this.DataHelper.Set <SysFormField>().Where(p => p.FormSectionId == sectionId).Max(p => p.DisplayOrder ?? 0); using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { foreach (var p in source) { SysField field = this.EntityCache.FindById <SysField>(p.FieldId); if (field == null) { field = db.FindById <SysField>(p.FieldId); } if (field != null) { SysFormField ff = new SysFormField() { FormFieldId = db.GetNextIdentity(), FormSectionId = sectionId, FormId = section.FormId, FieldId = p.FieldId, RelationId = p.RelationId, DisplayOrder = ++maxOrder, EntityId = field.EntityId, DataType = field.DataType, IsNullable = true, CreateUserId = this.LoginUserID, CreateTime = DateTime.Now, }; db.Insert(ff); sb.AppendFormat("<div id=\"{0}\" class=\"field unselected\" onclick=\"Select(this);\">{1}</div>", ff.FormFieldId, field.DisplayText); } else { throw new Exception("找不到关联字段"); } } } ts.Complete(); } } else { throw new Exception("找不到表单段落"); } return(sb.ToString()); }
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); } }