Beispiel #1
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();

        }
        public ActionResult PublishProject_P3_Roles(PublishProjectP3ViewModel model)
        {
            try
            {

                foreach (var i in model.Subjects)
                {
                    _db.WS_Subjects.Find(i.SubjectId).U_Role_Id = i.SelectedRole;
                }
                _db.SaveChanges();

                ProjectHelper helper = new ProjectHelper();
                helper.publishProject(model);
                return RedirectToAction("Index",new { id = model.Id});
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message;
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                    ViewBag.Error = ViewBag.Error + e.Message;
                }
                return View("Error");
            }
        }
        public ActionResult PublishProject_P3_Roles(int projectId)
        {
            var project = _db.WS_Projects.Find(projectId);
            var model = new PublishProjectP3ViewModel { Id = project.Id, ProjectName = project.Name, Version = project.CurrentVersion };
            List<SelectListItem> ar = new List<SelectListItem>();

            foreach (var role in _db.U_Roles)
            {
                ar.Add(new SelectListItem() { Text = role.Name, Value = "" + role.Id });
            }

            ar.First().Selected = true;
            int selected = Int32.Parse(ar.First().Value);

            foreach (var subject in project.Subjects)
            {
                PublishProjectP3SubjectViewModel sv = new PublishProjectP3SubjectViewModel() { SubjectId = subject.Id, SubjectName = subject.Name, AvailableRoles = ar, SelectedRole = selected };
                model.Subjects.Add(sv);
            }

            return View(model);
        }