static void Main(string[] args) { // Delete previous versions of log.txt System.IO.File.Delete("Log/logInfo.txt"); System.IO.File.Delete("Log/logImportant.txt"); AppOptions options = AppOptions.Parse(args); ProjectWorkflow projectProcess = new ProjectWorkflow(options); FolderWorkflow folderProcess = new FolderWorkflow(options); ProjectUserWorkflow projectUserProcess = new ProjectUserWorkflow(options); AccountWorkflow accountProcess = new AccountWorkflow(options); DataTable csvData = projectProcess.CustomGetDataFromCsv(); List <BimProject> projects = projectProcess.GetAllProjects(); List <BimCompany> companies = null; BimProject currentProject = null; List <HqUser> projectUsers = null; List <NestedFolder> folders = null; NestedFolder currentFolder = null; for (int row = 0; row < csvData.Rows.Count; row++) { string projectName = csvData.Rows[row]["project_name"].ToString(); if (!string.IsNullOrEmpty(projectName)) { Util.LogImportant($"\nCurrent project: {projectName}"); currentProject = projects.Find(x => x.name == projectName); if (currentProject == null) { projects = projectProcess.CustomCreateProject(csvData, row, projectName, projectProcess); currentProject = projects.Find(x => x.name == projectName); CheckProjectCreated(currentProject, projectName); } folders = folderProcess.CustomGetFolderStructure(currentProject); companies = accountProcess.CustomUpdateCompanies(csvData, row, accountProcess); projectUsers = projectUserProcess.CustomUpdateProjectUsers(csvData, row, companies, currentProject, projectUserProcess); } currentFolder = CreateFoldersAndAssignPermissions(csvData, row, projectUsers, folderProcess, folders, currentFolder, currentProject, projectUserProcess); UploadFilesFromFolder(csvData, row, folderProcess, currentFolder, currentProject.id, options.LocalFoldersPath); } }
private async Task <Subscriber> NewUserFlow(ILogger log, string chatId) { log.LogInformation($"NewUserFlow() is executed for chatId '{chatId}'"); await Task.Delay(PauseBeforeAnswer); var workflow = new AccountWorkflow(); workflow.Inject(_serviceProvider, _config, log); var subscriber = new Subscriber { Email = string.Empty, TelegramId = chatId, StartWorkingHoursUtc = default,
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); }
/// <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(); }
public WorkflowFacade() { _accountWorkflow = new AccountWorkflow(); }
static void Main(string[] args) { // Delete previous versions of log.txt System.IO.File.Delete("Log/logInfo.txt"); System.IO.File.Delete("Log/logImportant.txt"); AppOptions options = AppOptions.Parse(args); // options.AccountRegion = "EU"; ProjectWorkflow projectProcess = new ProjectWorkflow(options); FolderWorkflow folderProcess = new FolderWorkflow(options); ProjectUserWorkflow projectUserProcess = new ProjectUserWorkflow(options); AccountWorkflow accountProcess = new AccountWorkflow(options); // load data from custom CSV file. Filepath was set in constructor of projectProcess by pushing the options instance DataTable csvData = projectProcess.CustomGetDataFromCsv(); // load all existing projects from the BIM360 environment List <BimProject> projects = projectProcess.GetAllProjects(); List <BimCompany> companies = null; BimProject currentProject = null; List <HqUser> projectUsers = null; List <NestedFolder> folders = null; NestedFolder currentFolder = null; 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); } // 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); } }
/// <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(); } }
/// <summary> /// Переопределение для создания workflow. /// </summary> /// <returns>Рабочий процесс.</returns> protected override WorkflowArea CreateWorkflow() { var workflow = new AccountWorkflow(); return(workflow.Create()); }