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 async static void Start() { while (true) { var waittime = 24 * 60 * 60 * 1000; try { using (var db = new BizDataContext()) { var temp = db.Set <T_Configuration>().Where(p => p.Configuration_Key == CommonHelper.SERVERKEY).FirstOrDefault(); if (temp != null) { waittime = Int32.Parse(temp.Configuration_Value); } var servers = db.Set <T_HTZ_Server>().Where(p => p.State == v_common.YesState).Select(p => new v_server(p)); foreach (var item in servers) { await SaveData(item); } } } catch (Exception e) { } finally { Thread.Sleep(waittime); } } }
/// <summary> /// 提交流程 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnApply_Click(object sender, EventArgs e) { try { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { //保存表单实例得到FormInstanceId int fiId = this.formPreview.SaveFormInstance(db); //提交流程 string processName = (sender as LinkButton).CommandArgument; Drision.Framework.WorkflowEngineCore.EngineProxy proxy = new WorkflowEngineCore.EngineProxy(db); proxy.StartProcess(processName, this.LoginUserID, fiId); } ts.Complete(); } this.AjaxAlertAndRedirect("提交成功", "FormInstanceQuery.aspx"); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
/// <summary> /// 旧的提醒,已抛弃 /// </summary> private void BindRemind_Old() { using (BizDataContext context = new BizDataContext()) { var query = context.Set <SysRemind>().Where(item => item.State == (int)RemindStausEnum.New && item.OwnerId == this.LoginUserID).OrderByDescending(x => x.CreateTime); var result = query.Take(6).ToList(); var source = result.Select(item => new { item.RemindId, RemindName = GetString(item.RemindName, 35), item.RemindURL, OwnerUserName = GetUserName(context, item.OwnerId), item.CreateTime, item.DeadLine, }).ToList(); this.RemindCount = query.Count(); this.rRemind.DataSource = source.Select(item => new { item.RemindId, item.RemindName, RemindUrl = GetRemindUrl(item.RemindURL, item.RemindId), item.OwnerUserName, CreateTime = GetDate(item.CreateTime), item.DeadLine, }).ToList(); this.rRemind.DataBind(); } }
private void BindSchedule() { try { using (BizDataContext context = new BizDataContext()) { var source = context.Where <Drision.Framework.OrgLibrary.InternalEntities.T_WorkItemBase>(p => p.OwnerId == LoginUserID && p.State == (int)WorkItemStatus.Created).ToList() .Select(p => new ScheduleEvent() { StartTime = p.StartTime, EndTime = p.EndTime, EventId = p.WorkItemBase_Id, Title = p.Title, Url = p.CompletePageUrl, IsAllDay = p.IsAllDay ?? false, EventType = p.WorkItemTypeID == null ? ScheduleEventTypes.Blue : ScheduleEventTypes.Green, }); foreach (var p in source) { this.sc.ScheduleEvents.Add(p); } } } catch (Exception ex) { this.AjaxAlert(ex); } }
/// <summary> /// 驳回 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnReject_Click(object sender, EventArgs e) { try { bool isAddUser = this.ccIsAddUser.Checked; int? addUserId = this.scAddUserId.GetValue().ToStringNullable().ToIntNullable(); string approveComment = this.txtApproveComment.Text.Trim(); using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { //更新表单实例 this.formPreview.UpdateFormInstance(db); //完成工作项 EngineProxy proxy = new EngineProxy(db); proxy.CompleteApproveWorkItem(this.WorkItemId, ApproveResultEnum.Reject, approveComment, isAddUser, addUserId); } ts.Complete(); } Response.Redirect("FormInstanceQuery.aspx"); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
public FormEntityPublishHelper(SysEntity entity, BizDataContext db) { this._entity = entity; this._fieldList = entity.Fields.ToList(); this._db = db; this._dbType = db.DatabaseType; }
private void BindRemind() { using (BizDataContext context = new BizDataContext()) { var query = context.Set <SysRemind>().Where(p => p.State == (int)RemindStausEnum.New && p.OwnerId == LoginUserID).OrderByDescending(p => p.CreateTime); var result = query.Skip(this.PageIndex_Remind * this.PageSize_Remind).Take(this.PageSize_Remind).ToList(); var source = result.Select(p => new { p.RemindId, p.RemindName, p.RemindURL, CreateUserName = GetUserName(context, p.CreateUserId), p.CreateTime, p.DeadLine, RemindUrl = CreateUrl(p.RemindURL, p.RemindId), }).ToList(); gcRemind.DataSource = source; gcRemind.PagerSettings.DataCount = query.Count(); gcRemind.DataBind(); } }
private void BindWorkItem() { using (BizDataContext context = new BizDataContext()) { var wibList = context.Set <T_WorkItemBase>().Where(p => p.WorkItemTypeID == null && p.Entity_Trace_PlanID == null && p.OwnerId == LoginUserID && p.State == (int)WorkItemStatus.Created).OrderByDescending(p => p.CreateTime); var result = wibList.Skip(this.PageIndex_WorkItem * this.PageSize_WorkItem).Take(this.PageSize_WorkItem).ToList(); var source = from wi in result orderby wi.CreateTime descending select new { wi.Title, wi.CreateTime, wi.CompletePageUrl, wi.WorkItemId, wi.WorkItemBase_Id, User_Name = GetStartUserName(context, wi.WorkItemId), }; gcWorkItem.DataSource = source.ToList(); gcWorkItem.PagerSettings.DataCount = wibList.Count(); gcWorkItem.DataBind(); } }
/// <summary> /// 删除 /// </summary> /// <param name="selectedId"></param> private void Delete(long selectedId) { var section = this.DataHelper.FindById <SysFormFieldSection>(selectedId); if (section != null) { var fieldList = this.DataHelper.Where <SysFormField>(p => p.FormSectionId == selectedId); using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { foreach (var field in fieldList) { db.Delete(field); } db.Delete(section); } ts.Complete(); } } else { var field = this.DataHelper.FindById <SysFormField>(selectedId); if (field != null) { this.DataHelper.Delete(field); } } }
private void LoadDropDown() { try { using (BizDataContext context = new BizDataContext()) { var processList = context.Where <SysProcess>(p => p.ProcessStatus == (int)ProcessState.StartUsed && p.ProcessCategory != (int)ProcessCategory.FormApprove //2013-9-13 zhumin 排除表单流程 ); cbProcess.DataTextField = "ProcessName"; cbProcess.DataValueField = "ProcessType"; cbProcess.DataSource = processList; cbProcess.DataBind(); cbStartUser.DataTextField = "User_Name"; cbStartUser.DataValueField = "User_ID"; cbStartUser.DataSource = context.FetchAll <T_User>(); cbStartUser.DataBind(); cbStartUser.SetValue(this.LoginUserID.ToString()); } } catch (ApplicationException ex) { this.AjaxAlert(ex.Message); } }
public static string CreateUserToken(IUserIdentity user) { if (!IsSsoServer) { return(null); } var span = new TimeSpan(2, 0, 0); var str = DateTime.Now.Ticks.ToString("X16"); var str2 = Guid.NewGuid().ToString("N").ToUpper(); var str3 = rnd.Next(0x989680, 0x7ffffffe).ToString("X"); var str4 = str + str2 + str3; using (var scope = new TransactionScope(TransactionScopeOption.Suppress)) { using (var context = new BizDataContext()) { var token = new SysUserToken { TokenKey = str4, UserId = user.User_ID, ExpireTime = DateTime.Now.Add(span) }; context.Insert(token); } scope.Complete(); } user.SsoToken = str4; return(str4); }
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); }
/// <summary> /// 保存最新服务状态 /// </summary> /// <param name="servicestate">服务状态</param> /// <param name="serviceid">服务id</param> /// <param name="costTime">花费时间</param> /// <param name="serverAppType">链接服务监控时,是App还是web</param> /// <returns></returns> public async static Task SaveNewState(int servicestate, int serviceid, int?costTime = null, int?serverAppType = null) { using (var db = new BizDataContext()) { var entity = await db.Set <T_HTZ_ServiceState>().Where(p => p.State == v_common.YesState && p.ObjectId == serviceid && p.ServiceType == serverAppType).FirstOrDefaultAsync(); if (entity == null) { entity = new T_HTZ_ServiceState(); entity.CreateTime = DateTime.Now; entity.HTZ_ServiceState_Id = await db.GetNextIdentity_IntAsync(); entity.ServiceState = servicestate; entity.ServiceType = serverAppType;//链接服务监控时,是App还是web entity.State = v_common.YesState; entity.ObjectId = serviceid; entity.RequestCostTime = costTime; entity.UpdateTime = entity.CreateTime; await db.InsertAsync(entity); } else { entity.UpdateTime = DateTime.Now; entity.ServiceState = servicestate; entity.RequestCostTime = costTime; await db.UpdatePartialAsync(entity, p => new { p.UpdateTime, p.ServiceState, p.RequestCostTime }); } } }
/// <summary> /// 启用流程,只有“停用”状态的可以启用 /// </summary> public void StartProcess() { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { if (_process != null && _process.ProcessStatus == (int)ProcessState.Stoped) { int count = db.Set <SysProcess>().Count(p => p.ProcessType == _process.ProcessType && p.ProcessStatus == (int)ProcessState.StartUsed); if (count > 0) { throw new Exception("该流程已经存在已启用的版本,请先停用"); } _process.ProcessStatus = (int)ProcessState.StartUsed; db.UpdatePartial(_process, p => new { p.ProcessStatus }); } else { throw new Exception("流程不存在或当前流程状态不能启用"); } } ts.Complete(); } }
//string GetEntityName(long entityId,BizDataContext context) //{ // string res = string.Empty; // SysEntity se= context.FindById<SysEntity>(entityId); // if (se != null) // { // res = se.DisplayText; // } // return res; //} private void BindGrid() { using (BizDataContext context = new BizDataContext()) { var list = context.FetchAll <SysProcessRemindTemplate>(); var result = list.Select(p => new { p.TemplateId, p.TemplateName, p.TemplateType, p.UseTimeType, ProcessEntityName = this.EntityCache.FindById <SysEntity>(p.ProcessEntityId).EntityName, //GetEntityName(p.ProcessEntityId.Value,context), ActivityEntityName = this.EntityCache.FindById <SysEntity>(p.ActivityEntityId).EntityName, //GetEntityName(p.ActivityEntityId.Value,context), p.State }).ToList().Select(p => new { p.TemplateId, p.TemplateName, TemplateType = EnumHelper.GetDescription(typeof(TemplateType), p.TemplateType.Value), UseTimeType = EnumHelper.GetDescription(typeof(UseTimeType), p.UseTimeType.Value), p.ProcessEntityName, p.ActivityEntityName, State = p.State == 1 ? "启用" : "禁用", }).ToList(); this.gcProcessTemplateQuery.DataSource = result; this.gcProcessTemplateQuery.DataBind(); } }
/// <summary> /// 删除流程,只有“新增”状态的可以删除 /// </summary> public void DeleteProcess() { using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { if (_process != null && _process.ProcessStatus == (int)ProcessState.Created) { //删除流程 db.Delete(_process); //删除活动 db.Where <SysActivity>(p => p.ProcessId == _process.ProcessId).ToList().ForEach(p => { //删除活动 db.Delete(p); //删除活动参与人 db.Where <SysActivityParticipant>(i => i.ActivityId == p.ActivityId).ToList().ForEach(i => db.Delete(i)); }); //删除流程参与人 db.Where <SysProcessParticipant>(p => p.ProcessId == _process.ProcessId).ToList().ForEach(p => db.Delete(p)); //删除连接线 db.Where <SysTransition>(p => p.ProcessId == _process.ProcessId).ToList().ForEach(p => db.Delete(p)); } else { throw new Exception("流程不存在或当前流程状态不能删除"); } } ts.Complete(); } }
/// <summary> /// 查询所有提醒模板 /// </summary> /// <returns></returns> public IEnumerable <WfRemindTemplate> GetRemindTemplateList() { using (BizDataContext context = new BizDataContext()) { return(context.FetchAll <SysProcessRemindTemplate>().ConvertTo <WfRemindTemplate>()); } }
/// <summary> /// 驳回(指定下一活动) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnTrueReject_Click(object sender, EventArgs e) { try { string approveComment = this.txtApproveComment.Text.Trim(); long nextActivityId = (sender as LinkButton).CommandArgument.ToLong(); using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { using (BizDataContext db = new BizDataContext()) { //更新表单实例 this.formPreview.UpdateFormInstance(db); //完成工作项 EngineProxy proxy = new EngineProxy(db); proxy.RejectApproveWorkItem(this.WorkItemId, approveComment, nextActivityId); } ts.Complete(); } Response.Redirect("FormInstanceQuery.aspx"); } catch (Exception ex) { this.AjaxAlertAndEnableButton(ex); } }
/// <summary> /// 查询所有工作流 /// </summary> /// <returns></returns> public IEnumerable <WfProcess> GetWorkFlowList() { Drision.Framework.Entity.EntityCache cache = Drision.Framework.Entity.EntityCache.New(); using (BizDataContext context = new BizDataContext()) { var processList = context.Set <SysProcess>().Where(p => p.ProcessCategory != (int)ProcessCategory.FormApprove).ToList(); foreach (var p in processList) { p.ActivityEntity = cache.FindById <SysEntity>(p.ActivityEntityId); // context.FindById<SysEntity>(p.ActivityEntityId); p.ProcessEntity = cache.FindById <SysEntity>(p.EntityId); // context.FindById<SysEntity>(p.EntityId); } return(processList.Select(p => new { ActivityEntityName = p.ActivityEntity != null ? p.ActivityEntity.EntityName : "", EntityName = p.ProcessEntity != null ? p.ProcessEntity.EntityName : "", p.ProcessName, p.ProcessId, p.ProcessStatus, p.ProcessCategory, p.ProcessVersion, CanDelete = p.ProcessStatus == (int)ProcessState.Created, }).ConvertTo <WfProcess>()); } }
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> /// <param name="process"></param> public string SaveWorkFlow(WfWorkflowData data, long?oldProcessId) { using (BizDataContext context = new BizDataContext()) { return(InternalSaveWorkFlow(context, data, oldProcessId)); } }
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); }
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 static async Task SaveServerDisks(BizDataContext db, v_server server) { var dbdisks = await db.Set <T_HTZ_ServerHardDisk>().Where(p => p.State == v_common.YesState && p.HTZ_ServerId == server.id).ToListAsync(); foreach (var item in server.disks) { var disk = dbdisks.Where(p => p.HTZ_ServerHardDisk_Name == item.name && p.State == v_common.YesState).FirstOrDefault(); if (disk == null) { disk = new T_HTZ_ServerHardDisk(); disk.HTZ_ServerHardDisk_Name = item.name; disk.CreateTime = DateTime.Now; disk.UpdateTime = DateTime.Now; disk.TotalCapacity = (int)(item.Size / 1024 / 1024 / 1024); disk.UserCapacity = (int)(item.FreeSpace / 1024 / 1024 / 1024); disk.State = v_common.YesState; disk.UpdateTime = disk.CreateTime; disk.HTZ_ServerHardDisk_Id = await db.GetNextIdentity_IntAsync(); disk.HTZ_ServerId = server.id; await db.InsertAsync(disk); } else { disk.UpdateTime = DateTime.Now; disk.TotalCapacity = (int)(item.Size / 1024 / 1024 / 1024); disk.UserCapacity = (int)(item.FreeSpace / 1024 / 1024 / 1024); await db.UpdatePartialAsync(disk, p => new { p.UpdateTime, p.TotalCapacity, p.UserCapacity }); } } }
public static void SetDefaultValue(TagBuilder UserName, TagBuilder HidUserId, TagBuilder selectedIDHf, string selectValue) { string str = string.Empty; StringBuilder builder = new StringBuilder(100); if (!string.IsNullOrEmpty(selectValue)) { string[] strArray = selectValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); using (BizDataContext context = new BizDataContext(true)) { var source = (from u in context.FetchAll <T_User>() join suid in strArray on u.User_ID.ToString() equals suid select new { User_ID = u.User_ID, User_Name = u.User_Name }).ToList(); List <string> values = new List <string>(); if ((source != null) && (source.Count > 0)) { foreach (string str2 in strArray) { int id = str2.ToInt(); string item = source.FirstOrDefault(a => (a.User_ID == id)).User_Name; values.Add(item); builder.Append(str2 + "," + item + ";"); } str = string.Join(",", values); } } UserName.MergeAttribute("value", str); HidUserId.MergeAttribute("value", selectValue); selectedIDHf.MergeAttribute("value", builder.ToString().TrimEnd(new char[] { ';' })); } }
/// <summary> /// 查询 /// </summary> protected void btnQuery_Click(object sender, EventArgs e) { try { using (BizDataContext context = new BizDataContext()) { string name = this.tbT_ProcessName.Text.Trim(); var result = context.Where <SysProcess>(p => p.ProcessName.Contains(name) && p.ProcessCategory != (int)ProcessCategory.FormApprove && //2013-9-13 zhumin 排除表单流程 p.ProcessStatus == (int)ProcessState.StartUsed) .OrderBy(p => p.ProcessType); var source = result.Select(p => new { p.ProcessId, ProcessCategory = EnumHelper.GetDescription(typeof(ProcessCategory), p.ProcessCategory.Value), p.ProcessName, //context.FindById<SysEntity>(p.EntityId).EntityName, this.EntityCache.FindById <SysEntity>(p.EntityId).EntityName, //ActivityEntityName = context.FindById<SysEntity>(p.ActivityEntityId).EntityName, ActivityEntityName = this.EntityCache.FindById <SysEntity>(p.ActivityEntityId).EntityName, p.ProcessType, p.ProcessVersion, ProcessStatus = EnumHelper.GetDescription(typeof(ProcessState), p.ProcessStatus.Value), }); gcProcess.DataSource = source; gcProcess.DataBind(); } } catch (ApplicationException ex) { this.AjaxAlert(ex.Message); } }
protected void btnChangeSystemLevelCode_Click(object sender, EventArgs e) { using (BizDataContext context = new BizDataContext()) { StringBuilder sbSQL = new StringBuilder(); //将父部门字段值调整过来并先处理好顶级部门的层级码 sbSQL.AppendLine("update T_Department set SystemLevelCode = Convert(nvarchar(50),Department_ID)+'-' where Parent_ID is null"); context.ExecuteNonQuery(sbSQL.ToString()); var AllDepts = context.FetchAll <T_Department>(); var Depts = AllDepts.Where(p => !(p.Parent_ID == null)).ToList(); var DealedDepts = AllDepts.Where(p => p.Parent_ID == null).ToList(); while (Depts.Count > 0) { for (int i = Depts.Count - 1; i >= 0; i--) { var Child = Depts[i]; var FindParent = DealedDepts.FirstOrDefault(p => p.Department_ID == Child.Parent_ID); if (FindParent != null) { //当前未处理的这个是某个已处理的子部门,则处理当前这个,并把它从未处理中移走,加到已处理中。 Child.SystemLevelCode = FindParent.SystemLevelCode + Child.Department_ID + "-"; context.Update(Child); Depts.Remove(Child); DealedDepts.Add(Child); } } } } this.AjaxAlert("调整成功!"); }
/// <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); } }
public T_WorkItemBase GetWorkItemBase(int id) { using (BizDataContext context = new BizDataContext(true)) { return(context.FindById <T_WorkItemBase>(new object[] { id })); } }