コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: WorkflowRole.cs プロジェクト: jiguixin/WF
 public bool IsInRole(Guid identityId, Guid roleId)
 {
     using (var context = new DataModelDataContext())
     {
         return context.EmployeeRoles.Count(er => er.EmloyeeId == identityId && er.RoleId == roleId) > 0;
     }
 }
コード例 #3
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"));
     }
 }
コード例 #4
0
ファイル: WorkflowActions.cs プロジェクト: lulzzz/WF
        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();
            }
        }
コード例 #5
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;
     }
 }
コード例 #6
0
ファイル: WorkflowRole.cs プロジェクト: lulzzz/WF
 public IEnumerable <Guid> GetAllInRole(Guid roleId)
 {
     using (var context = new DataModelDataContext())
     {
         return(context.EmployeeRoles.Where(er => er.RoleId == roleId).Select(er => er.EmloyeeId).ToList());
     }
 }
コード例 #7
0
ファイル: WorkflowRole.cs プロジェクト: jiguixin/WF
 public IEnumerable<Guid> GetAllInRole(Guid roleId)
 {
     using (var context = new DataModelDataContext())
     {
         return context.EmployeeRoles.Where(er => er.RoleId == roleId).Select(er=>er.EmloyeeId).ToList();
     }
 }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
ファイル: DocumentHelper.cs プロジェクト: jiguixin/WF
 //根据id获取指定文档
 public static Document Get(Guid id)
 {
     using (var context = new DataModelDataContext())
     {
         return Get(id, context);
     }
 }
コード例 #10
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;
     }
 }
コード例 #11
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);
     }
 }
コード例 #12
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();
            }
        }
コード例 #13
0
 public static Document Get(Guid id)
 {
     using (var context = new DataModelDataContext())
     {
         return(Get(id, context));
     }
 }
コード例 #14
0
ファイル: WorkflowRole.cs プロジェクト: lulzzz/WF
 public bool IsInRole(Guid identityId, Guid roleId)
 {
     using (var context = new DataModelDataContext())
     {
         return(context.EmployeeRoles.Count(er => er.EmloyeeId == identityId && er.RoleId == roleId) > 0);
     }
 }
コード例 #15
0
ファイル: WorkflowActions.cs プロジェクト: jiguixin/WF
 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;
     }
 }
コード例 #16
0
ファイル: WorkflowActions.cs プロジェクト: jiguixin/WF
 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;
     }
 }
コード例 #17
0
ファイル: WorkflowActions.cs プロジェクト: jiguixin/WF
 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;
     }
 }
コード例 #18
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);
                    }
                }
            }
        }
コード例 #19
0
        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));
        }
コード例 #20
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();
            }
        }
コード例 #21
0
ファイル: WorkflowActions.cs プロジェクト: lulzzz/WF
 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;
     }
 }
コード例 #22
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);
     }
 }
コード例 #23
0
ファイル: WorkflowActions.cs プロジェクト: lulzzz/WF
 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;
     }
 }
コード例 #24
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);
     }
 }
コード例 #25
0
ファイル: WorkflowActions.cs プロジェクト: lulzzz/WF
 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;
     }
 }
コード例 #26
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;
     }
 }
コード例 #27
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")));
     }
 }
コード例 #28
0
        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);
        }
コード例 #29
0
 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;
     }
 }
コード例 #30
0
ファイル: EmployeeHelper.cs プロジェクト: kanpinar/unity3.1th
 public static List<Employee> GetAll()
 {
     using (var context = new DataModelDataContext())
     {
         context.LoadOptions = GetDefaultDataLoadOptions();
         return context.Employees.OrderBy(c=>c.Name).ToList();
     }
 }
コード例 #31
0
ファイル: DocumentHelper.cs プロジェクト: jiguixin/WF
 /// <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();
     }
 }
コード例 #32
0
ファイル: DocumentHelper.cs プロジェクト: jiguixin/WF
 /// <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();
     }
 }
コード例 #33
0
 public static List <Employee> GetAll()
 {
     using (var context = new DataModelDataContext())
     {
         context.LoadOptions = GetDefaultDataLoadOptions();
         return(context.Employees.OrderBy(c => c.Name).ToList());
     }
 }
コード例 #34
0
 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);
      }
 }
コード例 #35
0
 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));
     }
 }
コード例 #36
0
 public static List <Document> GetAll()
 {
     using (var context = new DataModelDataContext())
     {
         context.LoadOptions = GetDefaultDataLoadOptions();
         return(context.Documents.ToList());
     }
 }
コード例 #37
0
 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());
     }
 }
コード例 #38
0
 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());
     }
 }
コード例 #39
0
 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();
      }
 }
コード例 #40
0
ファイル: Storage.cs プロジェクト: gangadhardoddi/youtubeapps
 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);
     }
 }
コード例 #41
0
        public ActionResult Clean()
        {
            using (var context = new DataModelDataContext())
            {
                context.LoadTestingOperations.DeleteAllOnSubmit(context.LoadTestingOperations);
                context.SubmitChanges();
            }

            return(Content(""));
        }
コード例 #42
0
ファイル: WorkflowRule.cs プロジェクト: jiguixin/WF
 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};
     }
 }
コード例 #43
0
 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;
     }
 }
コード例 #44
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());
     }
 }
コード例 #45
0
ファイル: DocumentHelper.cs プロジェクト: kanpinar/unity3.1th
 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();
     }
 }
コード例 #46
0
ファイル: EmployeeHelper.cs プロジェクト: kanpinar/unity3.1th
 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;
 }
コード例 #47
0
ファイル: WorkflowRule.cs プロジェクト: jiguixin/WF
        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};
            }
        }
コード例 #48
0
ファイル: WorkflowRule.cs プロジェクト: jiguixin/WF
        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();
            }
        }
コード例 #49
0
        private static void PreExecuteAndFillInbox(ProcessStatusChangedEventArgs e)
        {
            var processId = e.ProcessId;

            using (var context = new DataModelDataContext())
            {
                FillInbox(processId, context);

                context.SubmitChanges();
            }
        }
コード例 #50
0
ファイル: DocumentHelper.cs プロジェクト: kanpinar/unity3.1th
        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();
            }
        }
コード例 #51
0
        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());
            }
        }
コード例 #52
0
ファイル: WorkflowRule.cs プロジェクト: lulzzz/WF
 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);
     }
 }
コード例 #53
0
        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();
            }
        }
コード例 #54
0
ファイル: WorkflowRule.cs プロジェクト: lulzzz/WF
 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);
     }
 }
コード例 #55
0
ファイル: WorkflowRule.cs プロジェクト: lulzzz/WF
 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);
     }
 }
コード例 #56
0
ファイル: WorkflowActions.cs プロジェクト: jiguixin/WF
        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();
            }
        }
コード例 #57
0
        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();
            }
        }
コード例 #58
0
ファイル: DocumentHelper.cs プロジェクト: jiguixin/WF
        //删除文档
        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();
            }
        }
コード例 #59
0
ファイル: WorkflowActions.cs プロジェクト: jiguixin/WF
        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();
            }
        }
コード例 #60
0
        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"));
            }
        }