internal void SelectWhereCompanyID(long CompanyID) { ClearData(); this.ExecuteCommand(SELECT_ALL_FROM_TABLE, "PROJECTS"); String subQuery = String.Format(" WHERE COMPANY_ID = '{0}'", CompanyID); this.Query += subQuery; Statement = new SqlCommand(Query, Connection); this.dataReader = this.Statement.ExecuteReader(); Projects temp; while (dataReader.Read()) { temp = new Projects( dataReader.GetValue(0), dataReader.GetValue(1), dataReader.GetValue(2), dataReader.GetValue(3), dataReader.GetValue(4), dataReader.GetValue(5), dataReader.GetValue(6)); temp.szProjectSizeName = ((ProjectSizes)(App.workObjects.projectSizesTable.ProjectSizesList.Where(x => x.lID.Equals(temp.lProjectSizeID))).First()).szProjectSize; ProjectsList.Add(temp); } CloseDatabaseConnection(); }
//Добавление в поток уже созданного проекта, isSetup = false - добавление при настройке другого потока public void PasteProject(Project project) { AddEvent("Добавление проекта", "Проект " + project.Code + " из потока " + project.ThreadCalc.Id); try { project.ThreadCalc = this; Projects.Add(project.Code, project); ProjectsList.Add(project); var list = project.Providers.Values.Select(p => p.Copy(this)).ToList(); project.Providers.Clear(); foreach (var p in list) { if (ProvidersDic.ContainsKey(p.Name)) { project.Providers.Add(p.Name, ProvidersDic[p.Name]); } else { project.Providers.Add(p.Name, p); ProvidersDic.Add(p.Name, p); } ProvidersDic[p.Name].Projects.Add(project.Code); } } catch (Exception ex) { AddError("Ошибка при добавлении проекта", ex); } MakeProviders(); MakeProjectString(); }
public void ReloadProjects() { ProjectsList.Clear(); foreach (var project in Projects) { ProjectsList.Add(project.Cast <ProjectItemViewModel>()); } }
public ProjectsViewModel(IProjectService projects, IAppStateService state, IDialogService dialog) { _projects = projects; _state = state; _dialog = dialog; _state.KeysChanged += async(s, e) => { await LoadAsync(); }; this.ShowCreate = new RelayCommand(() => { IsCreating = true; }); this.SelectProject = new RelayCommand <Project>((project) => { if (project == null) { return; } _state.CurrentProject = project; _state.SetCurrentPackage(null); ApplicationData.Current.LocalSettings.Values["LastProject"] = _state.CurrentProject.Name; }); this.CreateProject = new RelayCommand <string>(async(project) => { if (string.IsNullOrWhiteSpace(project)) { return; } var newProject = await _projects.CreateProjectAsync(project); ProjectsList.Add(newProject); CurrentProject = newProject; IsCreating = false; }); this.ManageProjects = new RelayCommand(async() => { await _dialog.OpenAsync(DialogKeys.ManageProjects, this); }); this.DeleteProject = new RelayCommand <Project>(async(project) => { Debug.WriteLine($"Delete {project.Name}"); var confirm = await _dialog.ConfirmAsync("Confirm", $"Are you sure you want to delete {project.Name}?", "Yes", "No"); if (!confirm) { return; } await _projects.DeleteProjectAsync(project.Id); if (CurrentProject.Id == project.Id) { CurrentProject = null; } ProjectsList.Remove(project); }); }
public void ReadProjects() { using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile)) { var projects = conn.Table <Project>().ToList(); ProjectsList.Clear(); foreach (var project in projects) { ProjectsList.Add(project); } } }
private void GetProjectsList() { try { Logger.Info("GetProjectsList Method"); var projectsList = DatabaseHelper.GetList <Project>(); ProjectsList.Clear(); foreach (var item in projectsList) { ProjectsList.Add(item); } } catch (Exception ex) { Logger.Error(ex, "Exception occured from getting projects list"); } }
//Добавить к потоку новый файл проекта public void AddProject() { var op = new OpenFileDialog { AddExtension = true, CheckFileExists = true, DefaultExt = "accbd", Multiselect = false, Title = "Файл проекта", Filter = "Файлы MS Access (.accdb) | *.accdb" }; op.ShowDialog(); if (op.FileName.IsEmpty()) { return; } using (Start()) { var proj = new Project(op.FileName, this); if (Command.IsError) { if (Command.IsError && Projects.ContainsKey(proj.Code)) { AddError("Проект уже есть в потоке", null, "Код=" + proj.Code); } Different.MessageError(Command.ErrorMessage()); } else { ProjectsList.Add(proj); Projects.Add(proj.Code, proj); AddEvent("Добавлен проект", proj.Code + ", " + proj.File); proj.ReadProviders(); if (Command.IsError) { Different.MessageError(Command.ErrorMessage()); } } MakeProviders(); MakeProjectString(); } }
public async Task LoadAsync() { ProjectsList.Clear(); var projects = await _projects.GetProjectsAsync(true); foreach (var p in projects) { ProjectsList.Add(p); } var last = ApplicationData.Current.LocalSettings.Values["LastProject"] as string; var found = (last != null) ? (from p in projects where p.Name == last select p).FirstOrDefault() : null; if (found == null) { CurrentProject = (from p in projects select p).FirstOrDefault(); } else { CurrentProject = found; } }
internal static ProjectsList getProjectsList(HttpResponseMessage responce) { var projectList = new ProjectsList(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("projects")) { var projectsArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["projects"].ToString()); foreach(var projectObj in projectsArray) { var project = new Project(); project = JsonConvert.DeserializeObject<Project>(projectObj.ToString()); projectList.Add(project); } } if (jsonObj.ContainsKey("page_context")) { var pageContext = new PageContext(); pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString()); projectList.page_context = pageContext; } return projectList; }
internal static ProjectsList getProjectsList(HttpResponseMessage responce) { var projectList = new ProjectsList(); var jsonObj = JsonConvert.DeserializeObject <Dictionary <string, object> >(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("projects")) { var projectsArray = JsonConvert.DeserializeObject <List <object> >(jsonObj["projects"].ToString()); foreach (var projectObj in projectsArray) { var project = new Project(); project = JsonConvert.DeserializeObject <Project>(projectObj.ToString()); projectList.Add(project); } } if (jsonObj.ContainsKey("page_context")) { var pageContext = new PageContext(); pageContext = JsonConvert.DeserializeObject <PageContext>(jsonObj["page_context"].ToString()); projectList.page_context = pageContext; } return(projectList); }
private void GetUserProjects() { RestClient client = new RestClient("https://api.bimsync.com"); //Get users projects RestRequest projectsRequest = new RestRequest("v2/projects", Method.GET); projectsRequest.AddHeader("Authorization", "Bearer " + _access_token); IRestResponse <List <Project> > projectsResponse = client.Execute <List <Project> >(projectsRequest); ProjectsList.Clear(); foreach (Project project in projectsResponse.Data) { ProjectsList.Add(project); } //Is there is an existing project id ? Project selectedProject = null; if (GetValueOrDefault("project_id") != "") { _projectId = GetValueOrDefault("project_id"); selectedProject = projectsResponse.Data.Where(x => x.id == _projectId).FirstOrDefault(); if (selectedProject != null) { comboBoxProjects.SelectedItem = selectedProject; } } if (selectedProject == null) { selectedProject = ProjectsList.FirstOrDefault(); comboBoxProjects.SelectedItem = selectedProject; _projectId = selectedProject.id; } }
//Загружет списки проектов и провайдеров для потока public void ReadSetup() { try { Projects.Clear(); ProjectsList.Clear(); foreach (var provider in ProvidersDic.Values) { var pi = provider.ProviderInstance; if (pi != null) { if (ApplicationType == ApplicationType.Controller && General.ProvidersQueues.ContainsKey(pi.Hash)) { General.ProvidersQueues.Remove(pi.Hash); } pi.Dispose(); } } ProvidersDic.Clear(); Sources.Clear(); Receivers.Clear(); Imitators.Clear(); Archive = null; ArchivePr = null; using (var rec = new RecDao(General.ControllerFile, "SELECT * FROM Projects WHERE ThreadId =" + Id + " ORDER BY Project")) while (rec.Read()) { var proj = new Project(rec, this); if (!Command.IsError && !Projects.ContainsKey(proj.Code)) { Projects.Add(proj.Code, proj); ProjectsList.Add(proj); AddEvent("Добавлен проект", proj.Code + ", " + proj.File); proj.ReadProviders();//Чтение списка провайдеров } } MakeProviders(); MakeProjectString(); } catch (Exception ex) { AddError("Ошибка загрузки списка проектов. Необходимо повторить настройку", ex); } Procent = 70; try //Список провайдеров { AddEvent("Чтение настроек провайдеров"); using (var rec = new RecDao(General.ControllerFile, "SELECT * FROM Providers WHERE ThreadId =" + Id)) while (rec.Read()) { var name = rec.GetString("ProviderName"); if (ProvidersDic.ContainsKey(name)) { var prov = ProvidersDic[name]; prov.Code = rec.GetString("ProviderCode"); prov.Inf = rec.GetString("ProviderInf"); prov.Otm = rec.GetBool("Otm"); } } foreach (var prov in ProvidersDic.Values) { if (prov.Otm) { prov.ProviderInstance = General.RunProvider(prov.Code, prov.Name, prov.Inf, this); if (prov.ProviderInstance != null) { switch (prov.Type.ToProviderType()) { case ProviderType.Archive: Archive = (IArchive)prov.ProviderInstance; ArchivePr = prov; break; case ProviderType.Source: Sources.Add(prov.Name, (ISource)prov.ProviderInstance); break; case ProviderType.Imitator: var ims = (Imitator)prov.ProviderInstance; Imitators.Add(prov.Name, ims); var pname = prov.Name.Substring(0, prov.Name.Length - 4); if (Projects.ContainsKey(pname)) { Projects[pname].Imitator = ims; } else { AddError("Недопустимое имя провайдера имитатора", null, prov.Name); } break; case ProviderType.Receiver: Receivers.Add(prov.Name, (IReceiver)prov.ProviderInstance); break; } if (ApplicationType == ApplicationType.Controller) { string hash = prov.ProviderInstance.Hash; if (!General.ProvidersQueues.ContainsKey(hash)) { General.ProvidersQueues.Add(hash, new Queue <int>()); } prov.ProviderQueue = General.ProvidersQueues[hash]; } } } } MakeProviders(); } catch (Exception ex) { AddError("Ошибка при чтении настроек провайдеров", ex); } }
public ProjectItem FindProjectItem(object property, FindProjectProperty findProjectProperty, bool createIfNotFound = true) { ProjectItem found; List <ProjectItem> projList = ProjectsList.ToList(); switch (findProjectProperty) { case FindProjectProperty.UniqueName: var uniqueName = (string)property; found = projList.Find(item => item.UniqueName == uniqueName); break; case FindProjectProperty.FullName: var fullName = (string)property; found = projList.Find(item => item.FullName == fullName); break; case FindProjectProperty.ProjectObject: found = projList.Find(item => ReferenceEquals(item.StorageProject, property)); break; case FindProjectProperty.UniqueNameProjectDefinition: { var projDef = (UniqueNameProjectDefinition)property; found = projList.Find(item => item.UniqueName == projDef.UniqueName && item.Configuration == projDef.Configuration && PlatformsIsEquals(item.Platform, projDef.Platform)); } break; case FindProjectProperty.FullNameProjectDefinition: { var projDef = (FullNameProjectDefinition)property; found = projList.Find(item => item.FullName == projDef.FullName && item.Configuration == projDef.Configuration && PlatformsIsEquals(item.Platform, projDef.Platform)); } break; default: throw new ArgumentOutOfRangeException("findProjectProperty"); } if (found != null) { return(found); } Project proj; switch (findProjectProperty) { case FindProjectProperty.UniqueName: var uniqueName = (string)property; proj = SolutionItem.StorageSolution.GetProject(item => item.UniqueName == uniqueName); break; case FindProjectProperty.FullName: var fullName = (string)property; proj = SolutionItem.StorageSolution.GetProject(item => item.FullName == fullName); break; case FindProjectProperty.ProjectObject: proj = SolutionItem.StorageSolution.GetProject(item => ReferenceEquals(item, property)); break; case FindProjectProperty.UniqueNameProjectDefinition: { var projDef = (UniqueNameProjectDefinition)property; proj = SolutionItem.StorageSolution.GetProject(item => item.UniqueName == projDef.UniqueName && item.ConfigurationManager.ActiveConfiguration.ConfigurationName == projDef.Configuration && PlatformsIsEquals(item.ConfigurationManager.ActiveConfiguration.PlatformName, projDef.Platform)); } break; case FindProjectProperty.FullNameProjectDefinition: { var projDef = (FullNameProjectDefinition)property; proj = SolutionItem.StorageSolution.GetProject(item => item.FullName == projDef.FullName && item.ConfigurationManager.ActiveConfiguration.ConfigurationName == projDef.Configuration && PlatformsIsEquals(item.ConfigurationManager.ActiveConfiguration.PlatformName, projDef.Platform)); } break; default: throw new ArgumentOutOfRangeException("findProjectProperty"); } if (proj == null) { return(null); } var newProjItem = new ProjectItem(proj); ProjectsList.Add(newProjItem); return(newProjItem); }