private SettingsModel GetModel() { var model = new SettingsModel(); model.SchemeName = "SimpleWF"; using (var context = new DataModelDataContext()) { var lo = new DataLoadOptions(); lo.LoadWith <Employee>(c => c.StructDivision); lo.LoadWith <EmployeeRole>(c => c.Role); lo.LoadWith <Employee>(c => c.EmployeeRoles); context.LoadOptions = lo; var wfSheme = context.WorkflowSchemes.FirstOrDefault(c => c.Code == model.SchemeName); if (wfSheme != null) { model.WFSchema = wfSheme.Scheme; } model.Employees = context.Employees.ToList(); model.Roles = context.Roles.ToList(); model.StructDivision = context.StructDivisions.ToList(); } return(model); }
public bool IsInRole(Guid identityId, Guid roleId) { using (var context = new DataModelDataContext()) { return context.EmployeeRoles.Count(er => er.EmloyeeId == identityId && er.RoleId == roleId) > 0; } }
public IEnumerable<string> GetAllInRole(string roleId) { using (var context = new DataModelDataContext()) { return context.EmployeeRoles.Where(er => er.RoleId == new Guid(roleId)).Select(er=>er.EmloyeeId).ToList().Select(c=> c.ToString("N")); } }
public static void WriteTransitionHistory(Guid processId, string currentStateName, string executedStateName, string commandName, IEnumerable <Guid> identities) { var currentstate = WorkflowInit.Runtime.GetLocalizedStateName(processId, currentStateName); var nextState = WorkflowInit.Runtime.GetLocalizedStateName(processId, executedStateName); var command = WorkflowInit.Runtime.GetLocalizedCommandName(processId, commandName); using (var scope = new TransactionScope()) { using (var context = new DataModelDataContext()) { GetEmployeesString(identities, context); var historyItem = new DocumentTransitionHistory { Id = Guid.NewGuid(), AllowedToEmployeeNames = GetEmployeesString(identities, context), DestinationState = nextState, DocumentId = processId, InitialState = currentstate, Command = command }; context.DocumentTransitionHistories.InsertOnSubmit(historyItem); context.SubmitChanges(); } scope.Complete(); } }
public static bool CheckDocumentsAuthorIsBoss(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return context.Documents.Count(d => d.Id == processInstance.ProcessId && d.Employee1.IsHead) > 0; } }
public IEnumerable <Guid> GetAllInRole(Guid roleId) { using (var context = new DataModelDataContext()) { return(context.EmployeeRoles.Where(er => er.RoleId == roleId).Select(er => er.EmloyeeId).ToList()); } }
public IEnumerable<Guid> GetAllInRole(Guid roleId) { using (var context = new DataModelDataContext()) { return context.EmployeeRoles.Where(er => er.RoleId == roleId).Select(er=>er.EmloyeeId).ToList(); } }
public bool IsInRole(string identityId, string roleId) { using (var context = new DataModelDataContext()) { return(context.EmployeeRoles.Count(er => er.EmloyeeId == new Guid(identityId) && er.RoleId == new Guid(roleId)) > 0); } }
//根据id获取指定文档 public static Document Get(Guid id) { using (var context = new DataModelDataContext()) { return Get(id, context); } }
public static bool CheckDocumentHasController(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return context.Documents.Count(d => d.Id == processInstance.ProcessId && d.EmloyeeControlerId.HasValue) > 0; } }
public static bool CheckDocumentsAuthorIsBoss(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return(context.Documents.Count(d => d.Id == processInstance.ProcessId && d.Employee1.IsHead) > 0); } }
public static void WriteTransitionHistory(ProcessInstance processInstance, string parameter) { if (processInstance.IdentityIds == null) { return; } var currentstate = WorkflowInit.Runtime.GetLocalizedStateName(processInstance.ProcessId, processInstance.CurrentState); var nextState = WorkflowInit.Runtime.GetLocalizedStateName(processInstance.ProcessId, processInstance.ExecutedActivityState); var command = WorkflowInit.Runtime.GetLocalizedCommandName(processInstance.ProcessId, processInstance.CurrentCommand); using (var context = new DataModelDataContext()) { GetEmployeesString(processInstance.IdentityIds, context); var historyItem = new DocumentTransitionHistory { Id = Guid.NewGuid(), AllowedToEmployeeNames = GetEmployeesString(processInstance.IdentityIds, context), DestinationState = nextState, DocumentId = processInstance.ProcessId, InitialState = currentstate, Command = command }; context.DocumentTransitionHistories.InsertOnSubmit(historyItem); context.SubmitChanges(); } }
public static Document Get(Guid id) { using (var context = new DataModelDataContext()) { return(Get(id, context)); } }
public bool IsInRole(Guid identityId, Guid roleId) { using (var context = new DataModelDataContext()) { return(context.EmployeeRoles.Count(er => er.EmloyeeId == identityId && er.RoleId == roleId) > 0); } }
public static void CheckDocumentHasController(Guid processId, out bool conditionResult) { using (var context = new DataModelDataContext()) { conditionResult = context.Documents.Count(d => d.Id == processId && d.EmloyeeControlerId.HasValue) > 0; } }
public static void CheckDocumentsAuthorIsBoss(Guid processId, out bool conditionResult) { using (var context = new DataModelDataContext()) { conditionResult = context.Documents.Count(d => d.Id == processId && d.Employee.IsHead) > 0; } }
public static void CheckBigBossMustSight(Guid processId, out bool conditionResult) { using (var context = new DataModelDataContext()) { conditionResult = context.Documents.Count(d => d.Id == processId && d.Sum > 100) > 0; } }
public static void RecalcInbox() { using (var context = new DataModelDataContext()) { foreach (var d in WF.Sample.Business.Helpers.DocumentHelper.GetAll()) { Guid id = d.Id; try { if (_runtime.IsProcessExists(id)) { _runtime.UpdateSchemeIfObsolete(id); context.DropWorkflowInbox(id); FillInbox(id, context); context.SubmitChanges(); } } catch (Exception ex) { throw new Exception(string.Format("Unable to calculate the inbox for process Id = {0}", id), ex); } } } }
public ActionResult Edit(Guid?Id, DocumentModel model, string button) { using (var context = new DataModelDataContext()) { if (!ModelState.IsValid) { return(View(model)); } Document target = null; if (model.Id != Guid.Empty) { target = context.Documents.SingleOrDefault(d => d.Id == model.Id); if (target == null) { ModelState.AddModelError("", "Row not found!"); return(View(model)); } } else { target = new Document(); target.Id = Guid.NewGuid(); target.AuthorId = model.AuthorId; target.StateName = model.StateName; context.Documents.InsertOnSubmit(target); } target.Name = model.Name; target.EmloyeeControlerId = model.EmloyeeControlerId; target.Comment = model.Comment; target.Sum = model.Sum; try { context.SubmitChanges(); } catch (Exception ex) { var sb = new StringBuilder("Ошибка сохранения. " + ex.Message); if (ex.InnerException != null) { sb.AppendLine(ex.InnerException.Message); } ModelState.AddModelError("", sb.ToString()); return(View(model)); } if (button == "SaveAndExit") { return(RedirectToAction("Index")); } if (button != "Save") { ExecuteCommand(target.Id, button, model); } return(RedirectToAction("Edit", new { target.Id })); } return(View(model)); }
public static void WriteTransitionHistory(ProcessInstance processInstance, string parameter) { if (processInstance.IdentityIds == null) return; var currentstate = WorkflowInit.Runtime.GetLocalizedStateName(processInstance.ProcessId, processInstance.CurrentState); var nextState = WorkflowInit.Runtime.GetLocalizedStateName(processInstance.ProcessId, processInstance.ExecutedActivityState); var command = WorkflowInit.Runtime.GetLocalizedCommandName(processInstance.ProcessId, processInstance.CurrentCommand); using (var context = new DataModelDataContext()) { GetEmployeesString(processInstance.IdentityIds, context); var historyItem = new DocumentTransitionHistory { Id = Guid.NewGuid(), AllowedToEmployeeNames = GetEmployeesString(processInstance.IdentityIds, context), DestinationState = nextState, DocumentId = processInstance.ProcessId, InitialState = currentstate, Command = command }; context.DocumentTransitionHistories.InsertOnSubmit(historyItem); context.SubmitChanges(); } }
public static void CheckDocumentHasController(Guid processId, out bool conditionResult) { using (var context = new DataModelDataContext()) { conditionResult = context.Documents.Count(d => d.Id == processId && d.EmloyeeControlerId.HasValue) > 0; } }
public static bool CheckDocumentHasController(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return(context.Documents.Count(d => d.Id == processInstance.ProcessId && d.EmloyeeControlerId.HasValue) > 0); } }
public static void CheckDocumentsAuthorIsBoss(Guid processId, out bool conditionResult) { using (var context = new DataModelDataContext()) { conditionResult = context.Documents.Count(d => d.Id == processId && d.Employee.IsHead) > 0; } }
public static bool CheckBigBossMustSight(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return(context.Documents.Count(d => d.Id == processInstance.ProcessId && d.Sum > 100) > 0); } }
public static void CheckBigBossMustSight(Guid processId, out bool conditionResult) { using (var context = new DataModelDataContext()) { conditionResult = context.Documents.Count(d => d.Id == processId && d.Sum > 100) > 0; } }
public static bool CheckBigBossMustSight(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return context.Documents.Count(d => d.Id == processInstance.ProcessId && d.Sum > 100) > 0; } }
public IEnumerable <string> GetAllInRole(string roleId) { using (var context = new DataModelDataContext()) { return(context.EmployeeRoles.Where(er => er.RoleId == new Guid(roleId)).Select(er => er.EmloyeeId).ToList().Select(c => c.ToString("N"))); } }
private Guid CreateDocument(List <Employee> emps, Random r) { Guid id = Guid.NewGuid(); DateTime opStart = DateTime.Now; using (var context = new DataModelDataContext()) { var author = emps[r.Next(0, emps.Count)]; var controller = emps[r.Next(0, emps.Count)]; var doc = new Document(); doc.Id = id; doc.AuthorId = author.Id; doc.StateName = "Draft"; doc.Name = "AG_Doc " + doc.Number.ToString(); if (r.Next(0, 2) == 1) { doc.EmloyeeControlerId = controller.Id; } doc.Comment = string.Format("Auto-generated documnet. {0}.", DateTime.Now.ToShortTimeString()); doc.Sum = r.Next(1, 10000); context.Documents.InsertOnSubmit(doc); context.SubmitChanges(); } AddOperation(opStart, DateTime.Now, "CreatingDocument"); return(id); }
public bool IsInRole(string identityId, string roleId) { using (var context = new DataModelDataContext()) { return context.EmployeeRoles.Count(er => er.EmloyeeId == new Guid(identityId) && er.RoleId == new Guid(roleId)) > 0; } }
public static List<Employee> GetAll() { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); return context.Employees.OrderBy(c=>c.Name).ToList(); } }
/// <summary> /// 根据DocumentId获取所有DocumentTransitionHistory记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public static List<DocumentTransitionHistory> GetHistory(Guid id) { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); return context.DocumentTransitionHistories.Where(h=>h.DocumentId == id).OrderBy(h=>h.TransitionTimeForSort).ThenBy(h=>h.Order).ToList(); } }
/// <summary> /// 获取所有Document记录 /// </summary> /// <returns></returns> public static List<Document> GetAll() { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); return context.Documents.OrderBy(c => c.Number).ToList(); } }
public static List <Employee> GetAll() { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); return(context.Employees.OrderBy(c => c.Name).ToList()); } }
private bool CheckRole(ProcessInstance processInstance, string identityId, string parameter) { using (var context = new DataModelDataContext()) { return context.EmployeeRoles.Any( r => r.EmloyeeId == new Guid(identityId) && r.Role.Name == parameter); } }
private bool CheckRole(ProcessInstance processInstance, string identityId, string parameter) { using (var context = new DataModelDataContext()) { return(context.EmployeeRoles.Any( r => r.EmloyeeId == new Guid(identityId) && r.Role.Name == parameter)); } }
public static List <Document> GetAll() { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); return(context.Documents.ToList()); } }
public static List <DocumentTransitionHistory> GetHistory(Guid id) { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); return(context.DocumentTransitionHistories.Where(h => h.DocumentId == id).OrderBy(h => h.TransitionTimeForSort).ThenBy(h => h.Order).ToList()); } }
private IEnumerable <string> GetInRole(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return (context.EmployeeRoles.Where(r => r.Role.Name == parameter).ToList() .Select(r => r.EmloyeeId.ToString("N")).ToList()); } }
private IEnumerable<string> GetInRole(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { return context.EmployeeRoles.Where(r => r.Role.Name == parameter).ToList() .Select(r => r.EmloyeeId.ToString("N")).ToList(); } }
public string Get(Guid districtId, int announcementAppId) { using (var context = new DataModelDataContext(connectionString)) { var res = context.AnnouncementAssignments.FirstOrDefault( x => x.DistrictId == districtId && x.AnnouncementApplicationId == announcementAppId); return(res?.YoutubeId); } }
public ActionResult Clean() { using (var context = new DataModelDataContext()) { context.LoadTestingOperations.DeleteAllOnSubmit(context.LoadTestingOperations); context.SubmitChanges(); } return(Content("")); }
private IEnumerable<Guid> GetDocumentAuthor(Guid processId) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processId); if (document == null) return new List<Guid>{}; return new List<Guid> {document.AuthorId}; } }
private bool IsAuthorsBoss(ProcessInstance processInstance, string identityId, string parameter) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processInstance.ProcessId); if (document == null) return false; return context.vHeads.Count(h => h.Id == document.AuthorId && h.HeadId == new Guid(identityId)) > 0; } }
public static List <Document> Get(out int count, int page = 0, int pageSize = 128) { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); int actual = page * pageSize; var query = context.Documents.OrderByDescending(c => c.Number); count = query.Count(); return(query.Skip(actual).Take(pageSize).ToList()); } }
public static List<Document> Get(out int count, int page = 0, int pageSize = 128) { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); int actual = page * pageSize; var query = context.Documents.OrderByDescending(c => c.Number); count = query.Count(); return query.Skip(actual).Take(pageSize).ToList(); } }
public static string GetNameById(Guid id) { string res = "Unknown"; using (var context = new DataModelDataContext()) { var item = context.Employees.FirstOrDefault(c => c.Id == id); if (item != null) res = item.Name; } return res; }
private IEnumerable<Guid> GetDocumentController(Guid processId) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processId); if (document == null || !document.EmloyeeControlerId.HasValue) return new List<Guid> {}; return new List<Guid> {document.EmloyeeControlerId.Value}; } }
private IEnumerable<Guid> GetAuthorsBoss(Guid processId) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processId); if (document == null) return new List<Guid>{}; return context.vHeads.Where(h=>h.Id == document.AuthorId).Select(h=>h.HeadId).ToList(); } }
private static void PreExecuteAndFillInbox(ProcessStatusChangedEventArgs e) { var processId = e.ProcessId; using (var context = new DataModelDataContext()) { FillInbox(processId, context); context.SubmitChanges(); } }
public static List<Document> GetOutbox(Guid identityId, out int count, int page = 0, int pageSize = 128) { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); int actual = page * pageSize; var subQuery = context.DocumentTransitionHistories.Where(c => c.EmployeeId == identityId).Skip(actual).Take(pageSize); count = subQuery.Count(); return context.Documents.Where(c => subQuery.Where(i => i.DocumentId == c.Id).Count() > 0).ToList(); } }
public static List <Document> GetOutbox(Guid identityId, out int count, int page = 0, int pageSize = 128) { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); int actual = page * pageSize; var subQuery = context.DocumentTransitionHistories.Where(c => c.EmployeeId == identityId).Skip(actual).Take(pageSize); count = subQuery.Count(); return(context.Documents.Where(c => subQuery.Where(i => i.DocumentId == c.Id).Count() > 0).ToList()); } }
private bool IsDocumentController(Guid processId, Guid identityId) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processId); if (document == null) { return(false); } return(document.EmloyeeControlerId.HasValue && document.EmloyeeControlerId.Value == identityId); } }
public static List<Document> GetInbox(Guid identityId, out int count, int page = 0, int pageSize = 128) { using (var context = new DataModelDataContext()) { context.LoadOptions = GetDefaultDataLoadOptions(); int actual = page * pageSize; var subQuery = context.WorkflowInboxes.Where(c => c.IdentityId == identityId).Skip(actual).Take(pageSize); count = subQuery.Count(); return context.Documents.Where(c => subQuery.Where(i => i.ProcessId == c.Id).Count() > 0).OrderByDescending(c=>c.Number).ToList(); } }
private bool IsDocumentAuthor(Guid processId, Guid identityId) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processId); if (document == null) { return(false); } return(document.AuthorId == identityId); } }
private bool IsAuthorsBoss(Guid processId, Guid identityId) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processId); if (document == null) { return(false); } return(context.vHeads.Count(h => h.Id == document.AuthorId && h.HeadId == identityId) > 0); } }
public static void DeleteEmptyTransitionHistoryItems(Guid processId) { using (var context = new DataModelDataContext()) { var unusedHistories = context.DocumentTransitionHistories.Where( h => h.DocumentId == processId && !h.TransitionTime.HasValue); context.DocumentTransitionHistories.DeleteAllOnSubmit(unusedHistories); context.SubmitChanges(); } }
public static void DeleteEmptyPreHistory(Guid processId) { using (var context = new DataModelDataContext()) { var existingNotUsedItems = context.DocumentTransitionHistories.Where( dth => dth.DocumentId == processId && !dth.TransitionTime.HasValue).ToList(); context.DocumentTransitionHistories.DeleteAllOnSubmit(existingNotUsedItems); context.SubmitChanges(); } }
//删除文档 public static void Delete(Guid[] ids) { using (var context = new DataModelDataContext()) { var objs = (from item in context.Documents where ids.Contains(item.Id) select item).ToList(); foreach (Document item in objs) { context.Documents.DeleteOnSubmit(item); } context.SubmitChanges(); } }
public static void UpdateTransitionHistory(Guid processId, string currentStateName, string executedStateName, string commandName, Guid identityId, Guid impersonatedIdentityId, string comment) { var currentstate = WorkflowInit.Runtime.GetLocalizedStateName(processId, currentStateName); var nextState = WorkflowInit.Runtime.GetLocalizedStateName(processId, executedStateName); var command = WorkflowInit.Runtime.GetLocalizedCommandName(processId, commandName); using (var scope = new TransactionScope()) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processId); if (document == null) return; document.State = nextState; var historyItem = context.DocumentTransitionHistories.FirstOrDefault( h => h.DocumentId == processId && !h.TransitionTime.HasValue && h.InitialState == currentstate && h.DestinationState == nextState); if (historyItem == null) { historyItem = new DocumentTransitionHistory { Id = Guid.NewGuid(), AllowedToEmployeeNames = string.Empty, DestinationState = nextState, DocumentId = processId, InitialState = currentstate }; context.DocumentTransitionHistories.InsertOnSubmit(historyItem); } historyItem.Command = command; historyItem.TransitionTime = DateTime.Now; historyItem.EmployeeId = identityId; context.SubmitChanges(); } scope.Complete(); } }
private IEnumerable<string> GetAuthorsBoss(ProcessInstance processInstance, string parameter) { using (var context = new DataModelDataContext()) { var document = context.Documents.FirstOrDefault(d => d.Id == processInstance.ProcessId); if (document == null) return new List<string> {}; return context.vHeads.Where(h => h.Id == document.AuthorId) .Select(h => h.HeadId) .ToList() .Select(c => c.ToString("N")); } }