Exemple #1
0
 private void DoSaveArchiveWorkflow(AuditStatus status, ArchiveWorkflow flow)
 {
     archiveFlowSaved           = true;
     BusyIndicator1.IsBusy      = true;
     BusyIndicator1.BusyContent = "正在保存流程...";
     flow.SubmitUserId          = AuthenticateStatus.CurrentUser.UserId;
     flow.Status = status;
     flowContext.SaveWorkflow(flow, obj =>
     {
         BusyIndicator1.IsBusy = false;
         if (Utility.Utility.CheckInvokeOperation(obj))
         {
             if (obj.Value == null)
             {
                 CustomMessageBox.Show("流程保存失败,请您检查输入是否正确!");
             }
             else
             {
                 ArchiveFlow = obj.Value;
                 if (ArchiveFlow.Status == AuditStatus.Draft)
                 {
                     LayoutRoot.DataContext = ArchiveFlow;
                 }
                 else if (ArchiveFlow.Status == AuditStatus.Auditing)
                 {
                     CustomMessageBox.Alert("流程提交成功!");
                     OnBackToBrowseButtonClick(this, null);
                 }
             }
         }
     }, null);
 }
Exemple #2
0
        private void BindWorkflowInfo()
        {
            new DocumentDomainContext().GetFolder(FolderId, obj =>
            {
                if (Utility.Utility.CheckInvokeOperation(obj))   //检查操作
                {
                    ArchiveFlow.FolderId           = FolderId;
                    CurrentFolderLabel.DataContext = obj.Value;
                }
            }, null);

            new OrganizationDomainContext().GetOrganizationInfo(OrgId, obj =>
            {
                if (Utility.Utility.CheckInvokeOperation(obj))  //检查操作
                {
                    CurrentOrganizationLabel.DataContext = obj.Value;
                }
            }, null);

            if (ArchiveFlow == null)
            {
                ArchiveFlow = new ArchiveWorkflow();
            }
            IsRevise = ArchiveFlow.IsRevise;
            btnUploadFile.Content = IsRevise ? "更新文件" : "添加文件";

            if (IsRevise && ArchiveFlow.Files != null && ArchiveFlow.Files.Count > 0)
            {
                ReviseFile = ArchiveFlow.Files[0].DocumentInfo;
            }

            Title = "编辑归档流程 - " + ArchiveFlow.FlowTitle;
            LayoutRoot.DataContext        = ArchiveFlow;
            UploadedFilesList.ItemsSource = ArchiveFlow.Files;
        }
Exemple #3
0
        //保存存档工作流
        public ArchiveWorkflow SaveWorkflow(ArchiveWorkflow flow)
        {
            if (flow != null && !string.IsNullOrEmpty(flow.FlowTitle) && flow.Files != null && flow.Files.Count > 0)
            {
                flow.SubmitTime = DateTime.Now;
                FlowAuditRecord record = null;
                if (flow.Status == AuditStatus.Submitted)
                {
                    record = new FlowAuditRecord
                    {
                        Id               = 0,
                        FlowId           = flow.FlowId,
                        AuditUserId      = flow.SubmitUserId,
                        AuditTime        = DateTime.Now,
                        AuditDescription = flow.SubmitDescription
                    };
                    var wf = GetWorkflowInfo(flow.FlowType);
                    if (wf != null && wf.AuditSteps != null && wf.AuditSteps.Count > 0)
                    {
                        flow.Status      = AuditStatus.Auditing;
                        flow.CurrentStep = wf.AuditSteps.OrderBy(o => o.AuditIndex).First().StepId;
                    }
                }
                int n = flow.FlowId > 0 ? SqlHelper.Update(flow) : SqlHelper.Insert(flow);
                if (n > 0)
                {
                    if (record != null)
                    {
                        record.FlowId = flow.FlowId;
                        SqlHelper.Insert(record);
                    }

                    var docService = new DocumentDomainService();
                    var rootFolder = docService.GetFolder(flow.FolderId);
                    foreach (var file in flow.Files)
                    {
                        file.FlowId     = flow.FlowId;
                        file.DocumentId = file.DocumentInfo.Identity;
                        if (file.DocumentInfo.Status == DocumentStatus.Deleted)
                        {
                            int tmpFolderId = file.DocumentInfo.FolderId;
                            file.DocumentInfo.FolderId = (rootFolder != null && rootFolder.Identity > 0) ? flow.FolderId : 0;
                            docService.CheckAndCreateFolder(file.DocumentInfo);
                            if (tmpFolderId != file.DocumentInfo.FolderId)
                            {
                                SqlHelper.Update(file.DocumentInfo);
                            }
                        }
                        n = file.Id > 0 ? SqlHelper.Update(file) : SqlHelper.Insert(file);
                    }
                    docService.Dispose();
                    return(flow);
                }
            }
            return(null);
        }
Exemple #4
0
        //上传文件并保存流
        private void UploadFileAndSaveFlow(AuditStatus status, ArchiveWorkflow flow)
        {
            var file = GetNextUploadFile(flow);

            if (file != null)
            {
                BusyIndicator1.IsBusy      = true;
                BusyIndicator1.BusyContent = string.Format("正在{0}: {1}",
                                                           file.DocumentInfo.FileType == DocumentType.Folder ? "创建文件夹" : "上传文件",
                                                           file.DocumentInfo.FileName);
                if (file.DocumentInfo.Content == null && !string.IsNullOrEmpty(file.DocumentInfo.FilePath))
                {
                    using (var stream = new FileStream(file.DocumentInfo.FilePath, FileMode.Open))
                    {
                        int fileLenght = (int)stream.Length;
                        file.DocumentInfo.Content = new byte[fileLenght];
                        stream.Read(file.DocumentInfo.Content, 0, fileLenght);
                        file.DocumentInfo.FilePath = string.Empty;
                    }
                }
                WorkflowFileInfo file1 = file;
                docContext.UploadFile(file.DocumentInfo, obj =>
                {
                    if (Utility.Utility.CheckInvokeOperation(obj))
                    {
                        if (obj.Value != null)
                        {
                            file1.DocumentId            = obj.Value.Identity;
                            file1.DocumentInfo.Identity = obj.Value.Identity;
                        }
                        file1.DocumentInfo = obj.Value;
                        UploadFileAndSaveFlow(status, flow);
                    }
                }, null);
            }
            else
            {
                BusyIndicator1.IsBusy = false;
                DoSaveArchiveWorkflow(status, flow);
            }
        }
Exemple #5
0
        //获取存档工作流
        public ArchiveWorkflow GetArchiveWorkflow(int flowId)
        {
            IBaseEntity entity = new ArchiveWorkflow();

            SqlHelper.GetSingleEntity(flowId, ref entity, true, true);
            var flow = entity as ArchiveWorkflow;

            if (flow != null && flow.Files != null)
            {
                foreach (var file in flow.Files)
                {
                    IBaseEntity tmp = new Document();
                    SqlHelper.GetSingleEntity(file.DocumentId, ref tmp, true, true);
                    var doc = tmp as Document;
                    if (doc != null)
                    {
                        file.DocumentId = doc.DocumentId;
                    }
                    file.DocumentInfo = doc;
                }
            }
            return(flow);
        }
Exemple #6
0
 private WorkflowFileInfo GetNextUploadFile(ArchiveWorkflow flow)
 {
     return(flow.Files.FirstOrDefault(o => o.DocumentInfo.Identity < 1));
 }
Exemple #7
0
        //当用户导航到此页面时执行。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (NavigationService != null)
            {
                int flowId = NavigationContext.QueryString.ContainsKey("FlowId")
                    ? Convert.ToInt32(NavigationContext.QueryString["FlowId"])
                    : 0;
                Guid fileId = Guid.Empty;
                if (flowId > 0)
                {
                    BusyIndicator1.IsBusy      = true;
                    BusyIndicator1.BusyContent = "正在加载数据...";
                    flowContext.GetArchiveWorkflow(flowId, obj =>
                    {
                        BusyIndicator1.IsBusy = false;
                        if (Utility.Utility.CheckInvokeOperation(obj))
                        {
                            ArchiveFlow = obj.Value;
                            var doc     = ArchiveFlow.Files == null || ArchiveFlow.Files.Count < 1 ? null : ArchiveFlow.Files[0];
                            if (doc != null)
                            {
                                FolderId = NavigationContext.QueryString.ContainsKey("FolderId")
                                        ? Convert.ToInt32(NavigationContext.QueryString["FolderId"])
                                        : ArchiveFlow.FolderId;

                                OrgId = NavigationContext.QueryString.ContainsKey("OrgId")
                                        ? NavigationContext.QueryString["OrgId"]
                                        : doc.DocumentInfo.OrganizationId;
                            }
                            BindWorkflowInfo();
                        }
                    }, null);
                }
                else if (NavigationContext.QueryString.ContainsKey("ReviseFile") &&
                         Guid.TryParse(NavigationContext.QueryString["ReviseFile"], out fileId))
                {
                    ArchiveFlow = new ArchiveWorkflow {
                        IsRevise = true
                    };
                    IsRevise = true;
                    docContext.DownloadLatestFile(fileId, obj =>
                    {
                        if (Utility.Utility.CheckInvokeOperation(obj))
                        {
                            var doc = obj.Value;
                            if (doc == null)
                            {
                                CustomMessageBox.Alert("您要修订的文件不存在,请您确认已经正确操作!");
                                NavigationService.Navigate(new Uri(string.Empty, UriKind.Relative));
                            }
                            else
                            {
                                if (ArchiveFlow.Files == null)
                                {
                                    ArchiveFlow.Files = new List <WorkflowFileInfo>();
                                }
                                ArchiveFlow.Files.Clear();
                                doc.Identity = 0;
                                ArchiveFlow.Files.Add(new WorkflowFileInfo {
                                    DocumentId = 0, DocumentInfo = doc
                                });
                                ArchiveFlow.FlowTitle = string.Format("修订文档-{0}", doc.FileName);
                                OrgId    = doc.OrganizationId;
                                FolderId = doc.FolderId;
                                BindWorkflowInfo();
                            }
                        }
                    }, null);
                }
                else
                {
                    FolderId = NavigationContext.QueryString.ContainsKey("FolderId")
                        ? Convert.ToInt32(NavigationContext.QueryString["FolderId"])
                        : 0;
                    OrgId = NavigationContext.QueryString.ContainsKey("OrgId")
                     ? NavigationContext.QueryString["OrgId"]
                     : AuthenticateStatus.DefaultOrganization;
                    BindWorkflowInfo();
                }
            }
        }