Ejemplo n.º 1
0
        private static List <IWfProcessDescriptor> SaveProcessDescriptor(WfProcessImporterContext context)
        {
            List <IWfProcessDescriptor> result = new List <IWfProcessDescriptor>();

            XElementFormatter formatter = new XElementFormatter();

            formatter.OutputShortType = false;

            foreach (PackagePart part in context.ProcessDescParts)
            {
                XDocument            xmlDoc      = XDocument.Load(part.GetStream());
                IWfProcessDescriptor processDesp = (IWfProcessDescriptor)formatter.Deserialize(xmlDoc.Root);

                WfProcessDescriptorManager.SaveDescriptor(processDesp);

                IUser user = null;

                if (DeluxePrincipal.IsAuthenticated)
                {
                    user = DeluxeIdentity.CurrentUser;
                }

                WfProcessDescriptorInfoAdapter.Instance.UpdateImportTime(processDesp.Key, user);

                result.Add(processDesp);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static List <IWfProcessDescriptor> ImportProcessDescriptors(Stream stream, Action <string> notifyEveryStep = null)
        {
            stream.NullCheck("stream");

            List <IWfProcessDescriptor> result = null;

            using (Package package = ZipPackage.Open(stream))
            {
                notifyEveryStep.Notify("开始导入文件...\n");

                PackagePartCollection packageParts = package.GetParts();

                WfProcessImporterContext context = new WfProcessImporterContext(packageParts);

                notifyEveryStep.Notify(string.Format("	共发现{0}个矩阵定义,{1}个流程矩阵数据,{2}个流程模板文件...\n",
                                                     context.MatrixDefParts.Count, context.MatrixParts.Count, context.ProcessDescParts.Count));

                using (TransactionScope scope = TransactionScopeFactory.Create())
                {
                    SaveMatrix(context);
                    notifyEveryStep.Notify("	导入流程矩阵完成...\n");

                    result = SaveProcessDescriptor(context);
                    notifyEveryStep.Notify("	导入流程模板完成...\n");

                    scope.Complete();
                }

                notifyEveryStep.Notify("文件导入完成!");
            }

            return(result);
        }
Ejemplo n.º 3
0
        private static void SaveMatrix(WfProcessImporterContext context)
        {
            foreach (var part in context.MatrixParts)
            {
                WfPackageRelationMapping partMapInfo = context.MappingInfo[part.Uri.ToString()];
                WfMatrixDefinition       matrixDef   = context.MatrixDefinitions[partMapInfo.MatrixDefID];

                WfMatrix.ImportNewMatrixFromExcel2007(part.GetStream(), null, partMapInfo.ProcessDescriptionID, matrixDef);
            }
        }