示例#1
0
 private FineOffice.Entity.OA_FlowProcess Changes(FineOffice.Entity.OA_FlowProcess temp)
 {
     return(new FineOffice.Entity.OA_FlowProcess
     {
         TimeLimit = temp.TimeLimit,
         Remind = temp.Remind,
         AllowGoBack = temp.AllowGoBack,
         AllowRefuse = temp.AllowRefuse,
         AllowSync = temp.AllowSync,
         Feedback = temp.Feedback,
         FlowID = temp.FlowID,
         ID = temp.ID,
         IsEnd = temp.IsEnd,
         IsStart = temp.IsStart,
         MailTo = temp.MailTo,
         MessageTo = temp.MessageTo,
         Next = temp.Next,
         Version = temp.Version,
         ProcessDepartment = temp.ProcessDepartment,
         ProcessPersonnel = temp.ProcessPersonnel,
         ProcessName = temp.ProcessName,
         Remark = temp.Remark,
         ProcessRole = temp.ProcessRole,
         Serial = temp.Serial,
         TopDefault = temp.TopDefault
     });
 }
示例#2
0
        /// <summary>
        /// 更改流程明细列表
        /// </summary>
        public FineOffice.Entity.OA_Flow UpdateProcess(FineOffice.Entity.OA_Flow entity)
        {
            using (DataContext cxt = ContextFactory.CreateContext())
            {
                Table <FineOffice.Entity.OA_Flow>        flow        = cxt.GetTable <FineOffice.Entity.OA_Flow>();
                Table <FineOffice.Entity.OA_FlowProcess> flowProcess = cxt.GetTable <FineOffice.Entity.OA_FlowProcess>();

                try
                {
                    flow.Attach(entity, true);
                    flowProcess.AttachAll(entity.OA_FlowProcess, true);                                                                                            //以当前实体更新数据
                    flowProcess.DeleteAllOnSubmit(flowProcess.Where(f => f.FlowID == entity.ID && !(from e in entity.OA_FlowProcess select e.ID).Contains(f.ID))); //删除数据
                    cxt.SubmitChanges(ConflictMode.ContinueOnConflict);                                                                                            //乐观并发
                }
                catch (ChangeConflictException)
                {
                    foreach (ObjectChangeConflict occ in cxt.ChangeConflicts)
                    {
                        FineOffice.Entity.OA_FlowProcess newDetail = occ.Object as FineOffice.Entity.OA_FlowProcess;
                        if (occ.IsDeleted)
                        {
                            if (newDetail != null)
                            {
                                flowProcess.InsertOnSubmit(Changes(newDetail));
                            }
                        }
                        else
                        {
                            foreach (MemberChangeConflict mc in occ.MemberConflicts)
                            {
                                MemberInfo mi         = mc.Member;
                                string     memberName = mi.Name;
                                if (memberName == "ProcessName" ||
                                    memberName == "Remark" || memberName == "Next")
                                {
                                    mc.Resolve(RefreshMode.KeepCurrentValues);
                                }
                                else
                                {
                                    mc.Resolve(RefreshMode.OverwriteCurrentValues);
                                }
                            }
                        }
                        occ.Resolve();
                    }
                    cxt.SubmitChanges(ConflictMode.FailOnFirstConflict);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                return(flow.Where(f => f.ID == entity.ID).FirstOrDefault());
            }
        }