Пример #1
0
        public ActionResult EditProject(WS_Project project)
        {
            _db.WS_Projects.Find(project.Id).Name        = project.Name;
            _db.WS_Projects.Find(project.Id).Description = project.Description;


            _db.SaveChanges();

            return(RedirectToAction("Index", new { id = project.Id }));
        }
Пример #2
0
        public void publishProject(PublishProjectP3ViewModel model)
        {
            WS_Project project = _inflowDb.WS_Projects.Find(model.Id);

            string startsubjectname = "";

            string wfmBaseAddress      = ConfigurationSettings.AppSettings["wfmBaseAddress"].ToString();
            string wfmUsername         = ConfigurationSettings.AppSettings["wfmUsername"].ToString();
            string wfmPassword         = ConfigurationSettings.AppSettings["wfmPassword"].ToString();
            string sqlConnectionString = ConfigurationSettings.AppSettings["repositoryConnectionString"].ToString();

            string companyScopeName = ConfigurationSettings.AppSettings["companyScopeName"].ToString();

            string wfMessageTierPath = ConfigurationSettings.AppSettings["wfMessageTierPath"].ToString();
            string wfTaskTierPath    = ConfigurationSettings.AppSettings["wfTaskTierPath"].ToString();

            InFlowWFM wfm = new InFlowWFM(wfmBaseAddress, wfmUsername, wfmPassword, sqlConnectionString);

            List <strICT.InFlow.WFM.Utilities.SubjectConfig> subjects = new List <strICT.InFlow.WFM.Utilities.SubjectConfig>();


            foreach (WS_Subject subject in project.Subjects)
            {
                if (subject.U_Role_Id == 0)
                {
                    throw new Exception("Role for Subject " + subject.Name + " not Set!");
                }
                if (subject.CanBeStarted)
                {
                    startsubjectname = subject.Name;
                }
                subjects.Add(new strICT.InFlow.WFM.Utilities.SubjectConfig {
                    Name = subject.Name, Xaml = subject.Xaml_Data, Role_Id = subject.U_Role_Id, MultiSubject = subject.MultiSubject
                });
            }

            string processscopename = System.IO.Path.GetRandomFileName();

            while (_inflowDb.P_Processes.Count(result => result.WFM_ProcessScope == companyScopeName & result.WFM_ProcessScope == processscopename) > 0)
            {
                processscopename = System.IO.Path.GetRandomFileName();
            }

            wfm.addProcess(companyScopeName, processscopename, wfMessageTierPath, subjects, true, startsubjectname, model.Id, model.Version, model.ProcessInfo);

            //Lock Model Version

            int modelId = _inflowDb.WS_ModelVersions.First(r => r.WS_ProjectId == model.Id & r.Version == model.Version).PD_ProcessId;
            var m       = _designerDb.PD_Processes.Find(modelId);

            m.LockedBy = "InFlow_BackEnd";
            _designerDb.SaveChanges();
        }
Пример #3
0
        public ActionResult CreateProject(WS_Project project)
        {
            project.CurrentVersion = 1;
            _db.WS_Projects.Add(project);
            _db.SaveChanges();

            PD_Process pmodel = new PD_Process()
            {
                Name = project.Name, Locked = false
            };

            _pDesignerDB.PD_Processes.Add(pmodel);
            _pDesignerDB.SaveChanges();

            WS_ModelVersion model = new WS_ModelVersion()
            {
                WS_ProjectId = project.Id, Version = 1, PD_ProcessId = pmodel.Id
            };

            _db.WS_ModelVersions.Add(model);
            _db.SaveChanges();

            return(View("Index"));
        }
Пример #4
0
        public ActionResult ImportBPMN(BPMNImportViewModel model)
        {
            model.description = "Imported from BPMN";
            ZipArchive         a       = new ZipArchive(model.zipfile.InputStream);
            List <definitions> imports = new List <definitions>();

            foreach (ZipArchiveEntry entry in a.Entries)
            {
                if (entry.FullName.EndsWith(".bpmn", StringComparison.OrdinalIgnoreCase))
                {
                    StreamReader reader = new StreamReader(entry.Open());


                    XmlRootAttribute xRoot = new XmlRootAttribute();
                    xRoot.ElementName = "definitions";
                    xRoot.Namespace   = "http://www.omg.org/spec/BPMN/20100524/MODEL";
                    xRoot.IsNullable  = true;
                    XmlSerializer serializer = new XmlSerializer(typeof(definitions), xRoot);
                    XmlReader     xRdr       = XmlReader.Create(reader);
                    definitions   import     = (definitions)serializer.Deserialize(xRdr);
                    //   BPMNImport import = (BPMNImport)serializer.Deserialize(new XmlTextReader(reader));


                    imports.Add(import);
                }
            }



            foreach (definitions i in imports)
            {
                WS_Project p = new WS_Project();

                p.Name        = i.BPMNDiagram.name;
                p.Description = model.description;
                p.Folder_Id   = model.folderId;

                this.CreateProject(p);

                int pd_id = p.ModelVersions.FirstOrDefault().PD_ProcessId;


                PD_Process pdp = _pDesignerDB.PD_Processes.Find(pd_id);
                int        n   = 50;
                int        c   = 0;
                int        t   = 50;
                foreach (var x in i.collaboration.participant)
                {
                    PD_Subject s = new PD_Subject();

                    s.Name = x.name;
                    if (c == 10)
                    {
                        t += 400;
                        c  = 0;
                        n  = 50;
                    }
                    s.PositionLeft = n;

                    s.PositionTop = t;
                    c++;
                    n += 200;
                    s.CanvasHeight = 1000;
                    s.CanvasWidth  = 1000;
                    s.Id           = IdHelper.getSubjectId(_pDesignerDB, pdp.Id);

                    pdp.Subjects.Add(s);
                    pdp.CanvasHeight = 200 + t;
                    if (s.PositionLeft > pdp.CanvasWidth)
                    {
                        pdp.CanvasWidth = s.PositionLeft;
                    }
                }
                if (i.collaboration.messageFlow != null)
                {
                    foreach (var x in i.collaboration.messageFlow)
                    {
                        PD_MessageType pdm = new PD_MessageType();
                        pdm.PD_Process_Id = pdp.Id;
                        pdm.Id            = IdHelper.getMessageTypeId(_pDesignerDB, pdp.Id);
                        pdm.Name          = x.name;
                        pdp.MessageTypes.Add(pdm);

                        /* try {
                         * PD_Message m = new PD_Message();
                         * m.Id = IdHelper.getMessageId(_pDesignerDB, pdp.Id);
                         *
                         *
                         * string fname = i.collaboration.participant.Where(s => s.id.Equals(x.sourceRef)).FirstOrDefault().name;
                         * m.From = pdp.Subjects.Where(y => y.Name.Equals(fname)).FirstOrDefault().Id;
                         * m.To = pdp.Subjects.Where(y => y.Name.Equals(i.collaboration.participant.Where(s => s.id.Equals(x.targetRef)).FirstOrDefault().name)).FirstOrDefault().Id;
                         * m.PD_MessageType_Id = pdm.Id;
                         * pdp.Messages.Add(m);
                         *  }
                         * catch (Exception e)
                         * {
                         *
                         * }*/
                    }
                }
                foreach (var x in i.process)
                {
                    PD_Subject pds = pdp.Subjects.Where(z => z.Name.Equals(x.name)).FirstOrDefault();
                    foreach (var y in x.Items)
                    {
                        PD_FunctionState pdf = new PD_FunctionState();
                        const string     pre = "strICT.InFlow.Web.Models.";
                        Type             w   = y.GetType();
                        switch (w.FullName)
                        {
                        case pre + "definitionsProcessAssociation":

                            definitionsProcessAssociation var1 = (definitionsProcessAssociation)y;

                            break;

                        case pre + "definitionsProcessDataStoreReference":

                            definitionsProcessDataStoreReference var2 = (definitionsProcessDataStoreReference)y;

                            break;

                        case pre + "definitionsProcessIntermediateCatchEvent":

                            definitionsProcessIntermediateCatchEvent var3 = (definitionsProcessIntermediateCatchEvent)y;
                            pdf               = new PD_FunctionState();
                            pdf.Name          = var3.name;
                            pdf.PD_Process_Id = pdp.Id;
                            pdf.PD_Subject_Id = pds.Id;
                            pdf.Type          = PD_StateTypes.FunctionState;
                            pdf.Id            = IdHelper.getStateId(_pDesignerDB, pdp.Id, pds.Id);
                            if (var3.incoming == null)
                            {
                                pdf.StartState = true;
                            }
                            if (var3.outgoing == null)
                            {
                                pdf.EndState = true;
                            }

                            pds.States.Add(pdf);


                            break;

                        case pre + "definitionsProcessIntermediateThrowEvent":

                            definitionsProcessIntermediateThrowEvent var4 = (definitionsProcessIntermediateThrowEvent)y;
                            pdf               = new PD_FunctionState();
                            pdf.Name          = var4.name;
                            pdf.PD_Process_Id = pdp.Id;
                            pdf.PD_Subject_Id = pds.Id;
                            pdf.Type          = PD_StateTypes.FunctionState;
                            pdf.Id            = IdHelper.getStateId(_pDesignerDB, pdp.Id, pds.Id);
                            if (var4.incoming == null)
                            {
                                pdf.StartState = true;
                            }
                            if (var4.outgoing == null)
                            {
                                pdf.EndState = true;
                            }

                            pds.States.Add(pdf);
                            break;

                        case pre + "definitionsProcessSequenceFlow":

                            definitionsProcessSequenceFlow var5 = (definitionsProcessSequenceFlow)y;

                            break;

                        case pre + "definitionsProcessServiceTask":

                            definitionsProcessServiceTask var6 = (definitionsProcessServiceTask)y;
                            pdf               = new PD_FunctionState();
                            pdf.Name          = var6.name;
                            pdf.PD_Process_Id = pdp.Id;
                            pdf.PD_Subject_Id = pds.Id;
                            pdf.Type          = PD_StateTypes.FunctionState;
                            pdf.Id            = IdHelper.getStateId(_pDesignerDB, pdp.Id, pds.Id);
                            if (var6.incoming == null)
                            {
                                pdf.StartState = true;
                            }
                            if (var6.outgoing == null)
                            {
                                pdf.EndState = true;
                            }
                            pds.States.Add(pdf);
                            break;

                        case pre + "definitionsProcessTextAnnotation":

                            definitionsProcessTextAnnotation var7 = (definitionsProcessTextAnnotation)y;

                            break;

                        case pre + "definitionsProcessUserTask":

                            definitionsProcessUserTask var8 = (definitionsProcessUserTask)y;
                            pdf               = new PD_FunctionState();
                            pdf.Name          = var8.name;
                            pdf.PD_Process_Id = pdp.Id;
                            pdf.PD_Subject_Id = pds.Id;
                            pdf.Type          = PD_StateTypes.FunctionState;
                            pdf.Id            = IdHelper.getStateId(_pDesignerDB, pdp.Id, pds.Id);
                            if (var8.incoming == null)
                            {
                                pdf.StartState = true;
                            }
                            if (var8.outgoing == null)
                            {
                                pdf.EndState = true;
                            }
                            pds.States.Add(pdf);
                            break;
                        }
                    }
                }

                pdp.CanvasWidth  += 100;
                pdp.CanvasHeight += 100;
            }

            _pDesignerDB.SaveChanges();
            return(View("Index"));
        }