public async Task <IActionResult> PutServiceWorkflow([FromRoute] int id,
                                                             [FromBody] ServiceWorkflow serviceWorkflow)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != serviceWorkflow.ServiceWorkflowId)
            {
                return(BadRequest());
            }

            _context.Entry(serviceWorkflow).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceWorkflowExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(NoContent());
        }
        public static IList <MemberUserGroup> GetMemberUserGroup(ServiceWorkflow swf)//by kittikun 2014-08-31
        {
            IList <MemberUserGroup> memberUserGroups = new List <MemberUserGroup>();

            foreach (ApprovalBracket ab in swf.ApprovalBrackets)
            {
                foreach (ApprovalTier at in ab.ApprovalTiers)
                {
                    if (at.ApproverGroup != null)
                    {
                        if (at.ApproverGroup.Role == UserGroupRole.Approver)
                        {
                            memberUserGroups.Add(at.ApproverGroup);
                        }
                    }
                }
            }

            if (swf.CreatorGroup != null)
            {
                memberUserGroups.Add(swf.CreatorGroup);
            }

            return(memberUserGroups);
        }
        public async Task <IActionResult> PostProjectSubstitute([FromBody] ProjectSubstitute projectSubstitute)
        {
            //if (!ModelState.IsValid)
            //{
            //  return BadRequest(ModelState);
            //}
            var postProjectSubstitute = projectSubstitute;

            postProjectSubstitute.CreatedUserId = 1;
            postProjectSubstitute.IsActive      = false;

            var serviceApplication = new ServiceApplication();

            serviceApplication.InvestorId      = projectSubstitute.InvestorId;
            serviceApplication.ProjectId       = projectSubstitute.ProjectId;
            serviceApplication.CaseNumber      = "1";
            serviceApplication.ServiceId       = projectSubstitute.ServiceId;
            serviceApplication.CurrentStatusId = 44446;
            serviceApplication.IsSelfService   = true;
            serviceApplication.IsPaid          = true;
            serviceApplication.StartDate       = DateTime.Now;
            serviceApplication.CreatedUserId   = 1;
            serviceApplication.IsActive        = false;

            var serviceWorkflow = new ServiceWorkflow
            {
                StepId             = 9,
                ActionId           = 3,
                FromStatusId       = 3,
                ToStatusId         = 5,
                PerformedByRoleId  = 1,
                NextStepId         = 1015,
                GenerateEmail      = true,
                GenerateLetter     = true,
                IsDocumentRequired = true,
                ServiceId          = projectSubstitute.ServiceId,
                LegalStatusId      = 3,
                CreatedUserId      = 1,
                IsActive           = false
            };

            serviceApplication.ServiceWorkflow.Add(serviceWorkflow);
            _context.ServiceApplication.Add(serviceApplication);
            await _context.SaveChangesAsync();

            postProjectSubstitute.ServiceApplicationId = serviceApplication.ServiceApplicationId;

            _context.ProjectSubstitute.Add(postProjectSubstitute);

            //ServiceApplication.Add(serviceApplication);
            //postProjectSubstitute.ServiceApplication = serviceApplication;
            //_context.Project.Add(editedProject);

            //_context.ProjectSubstitute.Add(postProjectSubstitute);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProjectSubstitute", new { id = postProjectSubstitute.ProjectSubstituteId },
                                   postProjectSubstitute));
        }
Exemple #4
0
 public static WorkflowBankAccount GetInstance(MemberBankAccount bankAccount, ServiceWorkflow functionWorkflow)
 {
     return(new WorkflowBankAccount
     {
         Account = bankAccount,
         Workflow = functionWorkflow,
     });
 }
        public async Task <IActionResult> PostProject([FromBody] ProjectRenewal projectRenewal)
        {
            //if (!ModelState.IsValid)
            //{
            //  return BadRequest(ModelState);
            //}

            var editProjectRenewal = projectRenewal;

            //editProjectRenewal.ServiceApplicationId = projectRenewal.ServiceApplicationId;
            editProjectRenewal.ProjectStatus = 1;
            editProjectRenewal.ApprovedBy    = 1;
            editProjectRenewal.SiteId        = 3;
            editProjectRenewal.CreatedUserId = 1;
            editProjectRenewal.ApprovedDate  = DateTime.Now;

            var serviceApplication = new ServiceApplication();

            serviceApplication.InvestorId      = editProjectRenewal.InvestorId;
            serviceApplication.ProjectId       = editProjectRenewal.ProjectId;
            serviceApplication.CaseNumber      = "1";
            serviceApplication.ServiceId       = editProjectRenewal.ServiceId;
            serviceApplication.CurrentStatusId = 44446;
            serviceApplication.IsSelfService   = true;
            serviceApplication.IsPaid          = true;
            serviceApplication.StartDate       = DateTime.Now;
            serviceApplication.CreatedUserId   = 1;
            serviceApplication.IsActive        = false;

            var serviceWorkflow = new ServiceWorkflow
            {
                StepId             = 9,
                ActionId           = 3,
                FromStatusId       = 3,
                ToStatusId         = 5,
                PerformedByRoleId  = 1,
                NextStepId         = 1015,
                GenerateEmail      = true,
                GenerateLetter     = true,
                IsDocumentRequired = true,
                ServiceId          = editProjectRenewal.ServiceId,
                LegalStatusId      = 3,
                CreatedUserId      = 1,
                IsActive           = false
            };

            serviceApplication.ServiceWorkflow.Add(serviceWorkflow);
            context.ServiceApplication.Add(serviceApplication);
            await context.SaveChangesAsync();

            editProjectRenewal.ServiceApplicationId = serviceApplication.ServiceApplicationId;

            context.ProjectRenewal.Add(editProjectRenewal);

            await context.SaveChangesAsync();

            return(CreatedAtAction("GetProjectRenewals", new { id = projectRenewal.ProjectRenewalId }, projectRenewal));
        }
        public async Task <IActionResult> PostServiceWorkflow([FromBody] ServiceWorkflow serviceWorkflow)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ServiceWorkflow.Add(serviceWorkflow);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetServiceWorkflow", new { id = serviceWorkflow.ServiceWorkflowId }, serviceWorkflow));
        }
Exemple #7
0
 public static ServiceWorkflow GetFunctionServiceWorkflow(MemberUser memberUser, int functionId)
 {
     try
     {
         var fwf = new ServiceWorkflow();
         foreach (var fw in memberUser.GetEffectiveCreatorServiceWorkflows().Where(fw => fw.MemberFunction.FunctionID == functionId))
         {
             fwf = fw;
             break;
         }
         return(fwf);
     }
     catch (NullReferenceException)
     {
         throw new NullReferenceException("function work flow is null");
     }
 }
        public static ServiceWorkflow GetInstance(MemberFunction memberfunction, MemberUserGroup memberUserGroup, IList <WorkflowBankAccount> workflowBankAccounts, UserGroupRole role)
        {
            ServiceWorkflow functionWorkFlow = null;

            switch (role)
            {
            case UserGroupRole.Admin:
                functionWorkFlow = new ServiceWorkflow
                {
                    MemberFunction = memberfunction,
                    CreatorGroup   = memberUserGroup,
                    //DebitableBankAccounts = workflowBankAccounts,
                };
                break;

            case UserGroupRole.Creator:
                functionWorkFlow = new ServiceWorkflow
                {
                    MemberFunction = memberfunction,
                    CreatorGroup   = memberUserGroup,
                    //DebitableBankAccounts = workflowBankAccounts,
                };
                break;

            case UserGroupRole.Approver:
                functionWorkFlow = new ServiceWorkflow
                {
                    MemberFunction = memberfunction,
                    //ApprovalTiers = new List<ApprovalTier>{
                    //    new ApprovalTier{
                    //        ApproverGroup = memberUserGroup,
                    //    },
                    //},
                    //DebitableBankAccounts = workflowBankAccounts,
                };
                break;

            default:
                break;
            }
            return(functionWorkFlow);
        }
        public bool Initialize()
        {
            bool result = false;

            try
            {
                folderProcess      = new FolderWorkflow(options);
                projectProcess     = new ProjectWorkflow(options);
                serviceProcess     = new ServiceWorkflow(options);
                accountProcess     = new AccountWorkflow(options);
                projectUserProcess = new ProjectUserWorkflow(options);

                result = true;
            }
            catch (Exception e)
            {
                result = false;
                Log.Error(e, "Error during intitialization");
            }
            return(result);
        }
Exemple #10
0
        /// <summary>
        /// runs the upload to the BIM360 environment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Upload_OnClick(object sender, RoutedEventArgs e)
        {
            var progress = new updates_upload();

            progress.Show();
            // convert string to stream
            byte[]       byteArray = Encoding.UTF8.GetBytes(AccProjectConfig.ExportBim360Projects());
            MemoryStream dataset   = new MemoryStream(byteArray);

            //dataset.Position = 0;


            //Updates
            progress.pgb.Value             = 10;
            progress.ProgressLabel.Content = "Build Connection";
            // ProgressBar "refresh"
            CallDispatch(progress);

            //maybe change
            string[] input = new string[] { "-c", ClientId, "-s", ClientSecret, "-a", BimId,
                                            "-h", AdminMail, "-f", " .\\sample", "-t", ",",
                                            "-z", ",", "-e", "UTF-8", "-d", "yyyy-MM-dd" };


            // Delete previous versions of log.txt
            System.IO.File.Delete("Log/logInfo.txt");
            System.IO.File.Delete("Log/logImportant.txt");

            AppOptions options = AppOptions.Parse(input);

            // options.AccountRegion = "EU";
            options.AdminRole = "Project Manager";

            ProjectWorkflow projectProcess = new ProjectWorkflow(options);

            System.Threading.Thread.Sleep(1000);
            // load all existing projects from the BIM360 environment
            List <BimProject> projects = projectProcess.GetAllProjects();

            FolderWorkflow      folderProcess      = new FolderWorkflow(options);
            ProjectUserWorkflow projectUserProcess = new ProjectUserWorkflow(options);
            AccountWorkflow     accountProcess     = new AccountWorkflow(options);

            //Updates
            progress.pgb.Value             = 25;
            progress.ProgressLabel.Content = "Convert Data from GUI";
            // ProgressBar "refresh"
            CallDispatch(progress);

            // load data from custom CSV file. Filepath was set in constructor of projectProcess by pushing the options instance
            DataTable csvData = new DataTable();

            csvData = ProjectWorkflow.CustomGetDataFromCsv_stream(dataset);

            //Updates
            progress.pgb.Value             = 40;
            progress.ProgressLabel.Content = "Uploading";
            // ProgressBar "refresh"
            CallDispatch(progress);

            List <BimCompany>   companies      = null;
            BimProject          currentProject = null;
            List <HqUser>       projectUsers   = null;
            List <NestedFolder> folders        = null;
            NestedFolder        currentFolder  = null;

            //Uploading
            try
            {
                for (int row = 0; row < csvData.Rows.Count; row++)
                {
                    string projectName = csvData.Rows[row]["project_name"].ToString();

                    // check if the current row defines the start point for another project (project_name column must be set)
                    if (!string.IsNullOrEmpty(projectName))
                    {
                        Util.LogImportant($"\nCurrent project: {projectName}");

                        // check if the requested project name is already present inside BIM360
                        currentProject = projects.Find(x => x.name == projectName);

                        if (currentProject == null)
                        {
                            // create the project
                            projects = projectProcess.CustomCreateProject(csvData, row, projectName, projectProcess);

                            // set the current project variable to the recently created project
                            currentProject = projects.Find(x => x.name == projectName);

                            // verify the initialization of the new project
                            CheckProjectCreated(currentProject, projectName);
                        }



                        // create the folder structure
                        folders = folderProcess.CustomGetFolderStructure(currentProject);

                        // add the companies
                        companies = accountProcess.CustomUpdateCompanies(csvData, row, accountProcess);

                        // create or update the project users
                        projectUsers = projectUserProcess.CustomUpdateProjectUsers(csvData, row, companies,
                                                                                   currentProject, projectUserProcess);

                        //activate all services
                        ServiceWorkflow serviceProcess = new ServiceWorkflow(options);

                        //check what servers needs to be activated
                        if (ServiceTab.CheckBoxservices.IsChecked == true)
                        {
                            #region Add Services
                            var listname = new List <string>();
                            listname.Add("admin");
                            listname.Add("doc_manage");
                            if (ServiceTab.CheckBoxpm.IsChecked == true)
                            {
                                listname.Add("pm");
                            }
                            if (ServiceTab.CheckBoxfng.IsChecked == true)
                            {
                                listname.Add("fng");
                            }
                            if (ServiceTab.CheckBoxcollab.IsChecked == true)
                            {
                                listname.Add("collab");
                            }
                            if (ServiceTab.CheckBoxcost.IsChecked == true)
                            {
                                listname.Add("cost");
                            }
                            if (ServiceTab.CheckBoxgng.IsChecked == true)
                            {
                                listname.Add("gng");
                            }
                            if (ServiceTab.CheckBoxglue.IsChecked == true)
                            {
                                listname.Add("glue");
                            }
                            if (ServiceTab.CheckBoxplan.IsChecked == true)
                            {
                                listname.Add("plan");
                            }
                            if (ServiceTab.CheckBoxfield.IsChecked == true)
                            {
                                listname.Add("field");
                            }
                            if (ServiceTab.CheckBoxassete.IsChecked == true)
                            {
                                listname.Add("assets");
                            }
                            #endregion

                            var serviceList = new List <ServiceActivation>();
                            foreach (var iter in listname)
                            {
                                serviceList.Add(new ServiceActivation());
                                serviceList.Last().service_type = iter;
                                serviceList.Last().project_name = projectName;
                                //test hardcoded Test company name needs to be enter or find out
                                serviceList.Last().company = ServiceTab.Company.Text.Trim();
                                serviceList.Last().email   = AdminMail;
                            }

                            serviceProcess.ActivateServicesProcess(
                                new List <BimProject>(new BimProject[] { currentProject }), serviceList);
                        }
                    }

                    // assign permissions
                    currentFolder = CreateFoldersAndAssignPermissions(csvData, row, projectUsers, folderProcess,
                                                                      folders, currentFolder, currentProject, projectUserProcess);

                    // run the file upload if requested
                    UploadFilesFromFolder(csvData, row, folderProcess, currentFolder, currentProject.id,
                                          options.LocalFoldersPath);
                    //Updates
                    progress.pgb.Value             = 50 + (50 / csvData.Rows.Count * row);
                    progress.ProgressLabel.Content = "Uploading";
                    // ProgressBar "refresh"
                    CallDispatch(progress);
                }
            }
            catch (Exception ex)
            {
                //show the error
                statusbar.Text = ex.Message;
                progress.Close();
                return;
            }

            statusbar.Text = "Upload successful";
            progress.Close();
        }
Exemple #11
0
        public async Task <IActionResult> PostProject([FromBody] Project project)
        {
            var investor = _context.Investors.FirstOrDefault(inv => inv.InvestorId == project.InvestorId);

            var service = _context.Service.FirstOrDefault(inv => inv.ServiceId == project.ServiceId);

            var squence = _context.Squences.FirstOrDefault();
            var lastSe  = squence.LastSquence + 1;

            var perminumber   = lastSe.ToString();
            var editedProject = project;

            //editedProject.InvestorId = 1018;
            //editedProject.ParentProjectId = 1;
            editedProject.ProjectNameSort    = "sort x";
            editedProject.ProjectNameSoundX  = "sound xxx";
            editedProject.IsActive           = false;
            editedProject.IsDeleted          = false;
            editedProject.EventDatetime      = DateTime.Now;
            editedProject.StartDate          = DateTime.Now;
            editedProject.CreatedUserId      = 1;
            editedProject.ProjectStatus      = 9;
            editedProject.ProjectStage       = 1;
            editedProject.SiteId             = 3;
            editedProject.InvestmentPermitNo = perminumber;

            var serviceApplication = new ServiceApplication
            {
                InvestorId          = project.InvestorId,
                CaseNumber          = perminumber,
                ServiceId           = project.ServiceId,
                CurrentStatusId     = 44450,
                IsSelfService       = true,
                IsPaid              = true,
                StartDate           = DateTime.Now,
                CreatedUserId       = 1,
                IsActive            = false,
                CreatedUserName     = editedProject.CreatedUserName,
                InvestorNameAmharic = investor.InvestorName,
                InvestorNameEnglish = investor.InvestorNameEng,
                ServiceNameAmharic  = service.DisplayName,
                ServiceNameEnglish  = service.DisplayNameEnglish,
                ProjectNameEnglish  = project.ProjectName,
                ProjectNameAmharic  = project.ProjectName
            };

            var serviceWorkflow = new ServiceWorkflow
            {
                StepId             = 9,
                ActionId           = 3,
                FromStatusId       = 3,
                ToStatusId         = 5,
                PerformedByRoleId  = 1,
                NextStepId         = 13,
                GenerateEmail      = true,
                GenerateLetter     = true,
                IsDocumentRequired = true,
                ServiceId          = project.ServiceId,
                LegalStatusId      = 3,
                CreatedUserId      = 1,
                IsActive           = false
            };

            squence.LastSquence           = lastSe;
            _context.Entry(squence).State = EntityState.Modified;

            serviceApplication.ServiceWorkflow.Add(serviceWorkflow);
            project.ServiceApplication.Add(serviceApplication);
            _context.Project.Add(editedProject);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProject", new { id = project.ProjectId }, editedProject));
        }
Exemple #12
0
        public async Task <IActionResult> PostServiceApplicationOfficer([FromBody] ServiceApplication serviceApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var editeTodoTask = serviceApplication.TodoTask;

            editeTodoTask.IsActive = false;


            var investor =
                _context.Investors.FirstOrDefault(inv => inv.InvestorId == serviceApplication.InvestorId);

            var service = _context.Service.FirstOrDefault(inv => inv.ServiceId == serviceApplication.ServiceId);

            var project = _context.Project.FirstOrDefault(inv => inv.ProjectId == serviceApplication.ProjectId);

            var squence = _context.Squences.FirstOrDefault();
            var lastSe  = squence.LastSquence + 1;

            var perminumber = lastSe.ToString();


            var editServiceApplication = new ServiceApplication
            {
                InvestorId          = serviceApplication.InvestorId,
                CaseNumber          = perminumber,
                ServiceId           = serviceApplication.ServiceId,
                CurrentStatusId     = 44450,
                IsSelfService       = true,
                IsPaid              = true,
                StartDate           = DateTime.Now,
                CreatedUserId       = 1,
                IsActive            = false,
                CreatedUserName     = serviceApplication.CreatedUserName,
                InvestorNameAmharic = investor.InvestorName,
                InvestorNameEnglish = investor.InvestorNameEng,
                ServiceNameAmharic  = service.DisplayName,
                ServiceNameEnglish  = service.DisplayNameEnglish,
                ProjectNameEnglish  = project.ProjectName,
                ProjectNameAmharic  = project.ProjectName
            };


            var serviceWorkflow = new ServiceWorkflow
            {
                StepId             = 9,
                ActionId           = 3,
                FromStatusId       = 3,
                ToStatusId         = 5,
                PerformedByRoleId  = 1,
                NextStepId         = 1015,
                GenerateEmail      = true,
                GenerateLetter     = true,
                IsDocumentRequired = true,
                ServiceId          = serviceApplication.ServiceId,
                LegalStatusId      = 3,
                CreatedUserId      = 1,
                IsActive           = false
            };

            editServiceApplication.ServiceWorkflow.Add(serviceWorkflow);
            editServiceApplication.TodoTask = editeTodoTask;
            _context.ServiceApplication.Add(editServiceApplication);
            editeTodoTask.ServiceApplication.Add(editServiceApplication);
            _context.TodoTask.Add(editeTodoTask);

            await _context.SaveChangesAsync();


            return(CreatedAtAction("GetServiceApplication", new { id = serviceApplication.ServiceApplicationId },
                                   editServiceApplication));
        }
Exemple #13
0
        /// <summary>
        /// runs the upload to the BIM360 environment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Upload_OnClick(object sender, RoutedEventArgs e)
        {
            var progress = new updates_upload();

            progress.Show();
            //main window closing prevention
            try
            {
                // convert string to stream
                byte[]       byteArray = Encoding.UTF8.GetBytes(AccProjectConfig.ExportBim360Projects());
                MemoryStream dataset   = new MemoryStream(byteArray);
                //dataset.Position = 0;


                //Updates
                progress.pgb.Value             = 10;
                progress.ProgressLabel.Content = "Build Connection";
                // ProgressBar "refresh"
                CallDispatch(progress);

                //input for upload
                string[] input = new string[]
                {
                    "-c", ClientId, "-s", ClientSecret, "-a", BimId,
                    "-h", AdminMail, "-f", " .\\sample", "-t", ",",
                    "-z", ",", "-e", "UTF-8", "-d", "yyyy-MM-dd"
                };

                // specify a folder in the %APPDATA% to store the logging files
                var loggingFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

                // Delete previous versions of log.txt
                try
                {
                    System.IO.File.Delete(Path.Combine(loggingFolder, "Bim360Interface/logInfo.txt"));
                    System.IO.File.Delete(Path.Combine(loggingFolder, "Bim360Interface/logInfo_important.txt"));
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                    // throw;
                }

                AppOptions options = AppOptions.Parse(input);
                // options.AccountRegion = "EU";
                options.AdminRole = "Project Manager";

                ProjectWorkflow projectProcess = new ProjectWorkflow(options);
                System.Threading.Thread.Sleep(1000);
                // load all existing projects from the BIM360 environment
                List <BimProject> projects = projectProcess.GetAllProjects();

                FolderWorkflow      folderProcess      = new FolderWorkflow(options);
                ProjectUserWorkflow projectUserProcess = new ProjectUserWorkflow(options);
                AccountWorkflow     accountProcess     = new AccountWorkflow(options);

                // this is the admin mail to activate the projects
                var adminMail = AdminMail;
                //Get defaut company name
                string defaultcomp;
                try
                {
                    defaultcomp = folderProcess.CustomDefaultCompanyName(adminMail);
                }
                catch (NullReferenceException)
                {
                    defaultcomp = "DefaultCompany";
                }

                //Updates
                progress.pgb.Value             = 25;
                progress.ProgressLabel.Content = "Convert Data from GUI";
                // ProgressBar "refresh"
                CallDispatch(progress);

                // load data from custom CSV file. Filepath was set in constructor of projectProcess by pushing the options instance
                DataTable csvData = new DataTable();
                csvData = ProjectWorkflow.CustomGetDataFromCsv_stream(dataset);

                //Updates
                progress.pgb.Value             = 40;
                progress.ProgressLabel.Content = "Uploading";
                // ProgressBar "refresh"
                CallDispatch(progress);

                List <BimCompany>   companies      = null;
                BimProject          currentProject = null;
                List <HqUser>       projectUsers   = null;
                List <NestedFolder> folders        = null;
                NestedFolder        currentFolder  = null;

                //Uploading
                try
                {
                    for (int row = 0; row < csvData.Rows.Count; row++)
                    {
                        string projectName = csvData.Rows[row]["project_name"].ToString();

                        // check if the current row defines the start point for another project (project_name column must be set)
                        if (!string.IsNullOrEmpty(projectName))
                        {
                            Util.LogImportant($"\nCurrent project: {projectName}");

                            // check if the requested project name is already present inside BIM360
                            currentProject = projects.Find(x => x.name == projectName);

                            if (currentProject == null)
                            {
                                // create the project
                                projects = projectProcess.CustomCreateProject(csvData, row, projectName,
                                                                              projectProcess);

                                // set the current project variable to the recently created project
                                currentProject = projects.Find(x => x.name == projectName);

                                // verify the initialization of the new project
                                CheckProjectCreated(currentProject, projectName);
                            }



                            // create the folder structure
                            folders = folderProcess.CustomGetFolderStructure(currentProject, adminMail);



                            // add the companies
                            companies = accountProcess.CustomUpdateCompanies(csvData, row, accountProcess);

                            // create or update the project users
                            projectUsers = projectUserProcess.CustomUpdateProjectUsers(csvData, row, companies,
                                                                                       currentProject, projectUserProcess);


                            //activate services
                            ServiceWorkflow serviceProcess = new ServiceWorkflow(options);

                            #region Add Services

                            // admin and doc_manage should be always activated
                            var serviceShortcuts = new List <string> {
                                "admin", "doc_manage"
                            };

                            // check which service should be activated in addition to admin and doc_manage
                            if (ServiceTab.CheckBoxProjectManagement.IsChecked == true)
                            {
                                serviceShortcuts.Add("pm");
                            }

                            if (ServiceTab.CheckBoxFieldManagement.IsChecked == true)
                            {
                                serviceShortcuts.Add("fng");
                            }

                            if (ServiceTab.CheckBoxDesignCollab.IsChecked == true)
                            {
                                serviceShortcuts.Add("collab");
                            }

                            if (ServiceTab.CheckBoxCostManagement.IsChecked == true)
                            {
                                serviceShortcuts.Add("cost");
                            }

                            if (ServiceTab.CheckBoxgng.IsChecked == true)
                            {
                                serviceShortcuts.Add("gng");
                            }

                            if (ServiceTab.CheckBoxglue.IsChecked == true)
                            {
                                serviceShortcuts.Add("glue");
                            }

                            if (ServiceTab.CheckBoxPlan.IsChecked == true)
                            {
                                serviceShortcuts.Add("plan");
                            }

                            if (ServiceTab.CheckBoxField.IsChecked == true)
                            {
                                serviceShortcuts.Add("field");
                            }

                            if (ServiceTab.CheckBoxAssets.IsChecked == true)
                            {
                                serviceShortcuts.Add("assets");
                            }

                            #endregion

                            var serviceList = new List <ServiceActivation>();

                            foreach (var serviceShortcut in serviceShortcuts)
                            {
                                //ToDo: this part needs revision

                                serviceList.Add(new ServiceActivation()
                                {
                                    email        = AdminMail,
                                    service_type = serviceShortcut,
                                    project_name = projectName,
                                    company      = defaultcomp
                                });
                            }

                            // take the current project and activate all services that were checked
                            serviceProcess.ActivateServicesProcess(
                                new List <BimProject>(new BimProject[] { currentProject }), serviceList);
                        }

                        // assign permissions
                        currentFolder = CreateFoldersAndAssignPermissions(csvData, row, projectUsers, folderProcess,
                                                                          folders, currentFolder, currentProject, projectUserProcess);

                        // run the file upload if requested
                        UploadFilesFromFolder(csvData, row, folderProcess, currentFolder, currentProject.id,
                                              options.LocalFoldersPath);
                        //Updates
                        progress.pgb.Value             = 50 + (50 / csvData.Rows.Count * row);
                        progress.ProgressLabel.Content = "Uploading";
                        // ProgressBar "refresh"
                        CallDispatch(progress);
                    }
                }
                catch (Exception ex)
                {
                    //show the error
                    statusbar.Text = ex.Message;
                    progress.Close();
                    return;
                }

                statusbar.Text = "Upload successful";
                progress.Close();
            }
            catch (Exception ex)
            {
                this.statusbar.Text = "Error on upload:" + ex.Message;
                progress.Close();
            }
        }
 public static void Update(BizPortalSessionContext context, int functionId, string action, ServiceWorkflow fwf, ref string message, ref int warningCount)
 {
     using (ITransaction tx = context.PersistenceSession.BeginTransaction())
     {
         try
         {
             fwf.Persist(context);
             tx.Commit();
             context.Log(functionId, 0, 0, action, message);
             message += "เรียบร้อย";
         }
         catch (Exception ex)
         {
             message = "ไม่สามารถทำรายการได้";
             tx.Rollback();
             warningCount++;
             context.Log(functionId, 0, 0, ex.Message, message);
         }
     }
 }