public FormStudent(string reg_num, FormLogin login) { InitializeComponent(); this.login = login; //Courses List: A list that displays professor's courses CoursesList.Bounds = new Rectangle(new Point(450, 50), new Size(275, 400)); CoursesList.View = View.Details; CoursesList.FullRowSelect = true; CoursesList.GridLines = true; CoursesList.Sorting = SortOrder.Ascending; CoursesList.Columns.Add("Courses", -2, HorizontalAlignment.Center); CoursesList.Columns.Add("ID", -2, HorizontalAlignment.Center); currentUser = Database.GetUser("student", reg_num); user = (Student)currentUser; Dictionary <string, string> Courses = Database.getAllCourses(); foreach (KeyValuePair <string, string> course in Courses) { var row = new String[] { course.Value , course.Key }; var listViewItem = new ListViewItem(row); CoursesList.Items.Add(listViewItem); } SelectedCourseLabel.Location = new Point(475, 20); SelectCourseBtn.Location = new Point(551, 458); //============================================================================== //======================================================================== ProjectsList.Bounds = new Rectangle(new Point(150, 12), new Size(275, 500)); ProjectsList.View = View.Details; ProjectsList.FullRowSelect = true; ProjectsList.GridLines = true; ProjectsList.Sorting = SortOrder.Ascending; ProjectsList.Columns.Add("Project ID", -2, HorizontalAlignment.Left); ProjectsList.Columns.Add("Project", -2, HorizontalAlignment.Left); ProjectsList.Columns.Add("Sent", -2, HorizontalAlignment.Left); ProjectsList.Columns.Add("Grade", -2, HorizontalAlignment.Left); //============================================================== ProjectsList.Hide(); UploadGroupBox.Hide(); CoursesList.Show(); SelectCourseBtn.Show(); SelectCourseMnBtn.BackColor = Color.FromArgb(66, 131, 178); UploadGroupBox.Location = new Point(450, 12); UploadBtn.Enabled = false; ProjectsMnBtn.Enabled = false; BrowseBtn.Enabled = false; UploadGroupBox.Paint += Paint; }
private async Task DeleteProject(ProjectOutDto project) { var response = await _projectRepository.DeleteProject(project); ProjectsList.Remove(project); StateHasChanged(); }
//Добавление в поток уже созданного проекта, 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(); }
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(); }
//Запускает один полный расчет без чтения списка параметров private void Cycle() { double sc = IsReadSources ? Sources.Count * 30 + Imitators.Count * 15 : 0, pc = Projects.Count * 20, ac = IsWriteArchives ? Projects.Count * 15 : 0, rc = IsWriteReceivers ? Receivers.Count * 10 : 0, vc = VedSaver != null ? 20 : 0; if (sc + pc + ac + rc > 1) { double n = 100.0 / (sc + pc + ac + rc + vc + 15), i = 0; if (IsReadSources) { IsSourcesRead = Start(ReadSources, i, i += sc * n); } Start(Calculate, i, i += pc * n); if (IsWriteReceivers) { Start(WriteReceivers, i, i += rc * n); } if (IsWriteArchives) { Start(WriteArchives, i, i += ac * n); } if (IsWriteVed) { StartAtom(Atom.WriteVed, new VedSaver(ProjectsList.First(), VedFile, VedTask).SaveVed, i, i + vc * n); } LastPeriodBegin = PeriodBegin; LastPeriodEnd = PeriodEnd; } }
public void ReloadProjects() { ProjectsList.Clear(); foreach (var project in Projects) { ProjectsList.Add(project.Cast <ProjectItemViewModel>()); } }
private void ProjectsMnBtn_Click(object sender, EventArgs e) { YouAreHere(ProjectsMnBtn); CoursesList.Hide(); SelectCourseBtn.Hide(); SelectedCourseLabel.Hide(); label11.Text = CoursesList.SelectedItems[0].Text; ProjectsList.Show(); UploadGroupBox.Show(); ProjectsList.Items.Clear(); try { Team team = Database.GetTeamOfStudent(user, SelectedCourse); var listViewItem = new ListViewItem(); foreach (KeyValuePair <Project, ProjectFile> pair in team.getProjectAssignmentsD()) { if (DateTime.Compare(pair.Key.getDueDate(), DateTime.Now) > 0) { listViewItem = new ListViewItem(); listViewItem.Text = pair.Key.getProjectID(); listViewItem.SubItems.Add(pair.Key.getname()); if (pair.Value == null) { listViewItem.SubItems.Add("No"); } else { listViewItem.SubItems.Add("Yes"); } try { if (!(pair.Value.getGrade() < 0)) { listViewItem.SubItems.Add(pair.Value.getGrade().ToString()); } else { listViewItem.SubItems.Add("-"); } } catch (NullReferenceException ex) { listViewItem.SubItems.Add("-"); } ProjectsList.Items.Add(listViewItem); } } } catch (Exception msg) { MessageBox.Show("You have no team"); } }
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); }); }
protected void Page_Load(object sender, EventArgs e) { if (Convert.ToInt32(HostSettingManager.Get(HostSettingNames.UserRegistration)) == (int)UserRegistration.None) { if (LoginView1.FindControl("RegisterLink") != null) { LoginView1.FindControl("RegisterLink").Visible = false; } } var oHelper = new SuckerFishMenuHelper(ProjectId); litMenu.Text = oHelper.GetHtml(); if (HostSettingManager.Get(HostSettingNames.EnableGravatar, true)) { var user = Membership.GetUser(Security.GetUserName()); if (user != null) { Image img = (System.Web.UI.WebControls.Image)LoginView1.FindControl("Avatar"); img.ImageUrl = PresentationUtils.GetGravatarImageUrl(user.Email, 32); } } ProjectsList.DataTextField = "Name"; ProjectsList.DataValueField = "Id"; if (!Page.IsPostBack) { string localizedSelectProject = GetGlobalResourceObject("SharedResources", "SelectProject").ToString(); if (Page.User.Identity.IsAuthenticated) { ProjectsList.DataSource = ProjectManager.GetByMemberUserName(Security.GetUserName(), true); ProjectsList.DataBind(); ProjectsList.Items.Insert(0, new ListItem(localizedSelectProject)); } else if (!Page.User.Identity.IsAuthenticated && Boolean.Parse(HostSettingManager.Get(HostSettingNames.AnonymousAccess))) { ProjectsList.DataSource = ProjectManager.GetPublicProjects(); ProjectsList.DataBind(); ProjectsList.Items.Insert(0, new ListItem(localizedSelectProject)); } else { ProjectsList.Visible = false; } var item = ProjectsList.Items.FindByValue(ProjectId.ToString()); if (item != null) { ProjectsList.SelectedValue = item.Value; } } }
public void ProjectsList_ToString_ReturnCorrectlyFormatedValue() { List <Project> projects = new List <Project>(); string expectedResult = string.Format("ProjectsCount: {0}", projects != null ? projects.Count : 0); var projectsList = new ProjectsList { Projects = projects }; Assert.AreEqual(expectedResult, projectsList.ToString()); }
private void SelectCourseMnBtn_Click(object sender, EventArgs e) { YouAreHere(SelectCourseMnBtn); CoursesList.Show(); SelectCourseBtn.Show(); SelectedCourseLabel.Show(); ProjectsList.Hide(); UploadGroupBox.Hide(); BrowseBtn.Enabled = false; }
protected override void OnBuildInitialized() { GitHubClient = new GitHubClient(new ProductHeaderValue("nuke-build")) { Credentials = new Credentials(GitHubToken, AuthenticationType.Bearer) }; var gitIdParts = GitRepository.Identifier.Split("/"); GitHubOwner = gitIdParts[0]; GitHubRepo = gitIdParts[1]; Projects = new ProjectsList(this); }
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 HandleLoadedCommand(object parameter) { this.ProjectsList = new ObservableCollection <ProjectListDto>(this.ProjectService.GetProjectsForDropdown()); this.creatorId = this.UserService.GetUsernames().SingleOrDefault(x => x.Username == EventCreator).Id; if (this.SelectedCalendarEvent != null) { this.Id = (int)this.selectedCalendarEvent.Row.ItemArray[0]; this.Title = (string)this.selectedCalendarEvent.Row.ItemArray[1]; this.Description = (string)this.selectedCalendarEvent.Row.ItemArray[2]; this.StartDate = (DateTime)this.selectedCalendarEvent.Row.ItemArray[3]; this.EndDate = (DateTime)this.selectedCalendarEvent.Row.ItemArray[4]; this.selectedColor = (Color)this.selectedCalendarEvent.Row.ItemArray[5]; var projectDto = (ProjectListDto)SelectedCalendarEvent.Row.ItemArray[7];//You saw this one! It is important to do this selection, because it will not select username if you directly pass the dto. this.SelectedProject = ProjectsList.SingleOrDefault(x => x.Id == projectDto.Id); } }
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"); } }
protected virtual ProjectsList CreateListItem(PXResult item) { PMProject project = PXResult.Unwrap <PMProject>(item); ContractBillingSchedule schedule = PXResult.Unwrap <ContractBillingSchedule>(item); Customer customer = PXResult.Unwrap <Customer>(item); ProjectsList result = new ProjectsList(); result.ProjectID = project.ContractID; result.ProjectCD = project.ContractCD; result.Description = project.Description; result.CustomerID = project.CustomerID; result.LastDate = schedule.LastDate; DateTime?fromDate = null; if (schedule.NextDate != null) { switch (schedule.Type) { case BillingType.Annual: fromDate = schedule.NextDate.Value.AddYears(-1); break; case BillingType.Monthly: fromDate = schedule.NextDate.Value.AddMonths(-1); break; case BillingType.Weekly: fromDate = schedule.NextDate.Value.AddDays(-7); break; case BillingType.Quarterly: fromDate = schedule.NextDate.Value.AddMonths(-3); break; } } result.FromDate = fromDate; result.NextDate = schedule.NextDate; return(result); }
//Добавить к потоку новый файл проекта 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 StudentForm() { InitializeComponent(); //======================================================================== ProjectsList.Bounds = new Rectangle(new Point(150, 12), new Size(275, 500)); ProjectsList.View = View.Details; ProjectsList.FullRowSelect = true; ProjectsList.GridLines = true; ProjectsList.Sorting = SortOrder.Ascending; ProjectsList.Columns.Add("Course", -2, HorizontalAlignment.Left); ProjectsList.Columns.Add("Project", -2, HorizontalAlignment.Left); ProjectsList.Columns.Add("Sent", -2, HorizontalAlignment.Left); ProjectsList.Columns.Add("Grade", -2, HorizontalAlignment.Left); //============================================================== ProjectsList.Show(); UploadGroupBox.Location = new Point(450, 12); }
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); }
//Удаление проекта project из потока, isSetup = false - удаление при настройке другого потока public void DeleteProject(Project project) { AddEvent("Удаление проекта", project.Code); try { foreach (var p in project.Providers.Values) { p.Projects.Remove(project.Code); if (p.Projects.Count == 0) { ProvidersDic.Remove(p.Name); } } Projects.Remove(project.Code); ProjectsList.Remove(project); } catch (Exception ex) { AddError("Ошибка при удалении проекта", ex); } MakeProviders(); MakeProjectString(); }
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 ProjectsTabControl() { ViewModel = WpfFactory.CreateViewModel <ProjectsTabControlModel>(); ViewModel.OnAssetsUpdate += () => { Dispatcher.Invoke(() => { RenderFiles(ViewModel.SelectedProject); }); }; InitializeComponent(); this.WhenActivated(d => { RefreshBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.RefreshCommand) .DisposeWith(d); AddProjectBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.AddProjectCommand) .DisposeWith(d); StageBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.StageCommand) .DisposeWith(d); PackageBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.PackageCommand) .DisposeWith(d); CopyModBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.CopyModCommand) .DisposeWith(d); LaunchGameBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.StartGameCommand) .DisposeWith(d); DevExpressBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.DevExpressCommand) .DisposeWith(d); /*GameVersionSelectorCombo * .Events() * .SelectionChanged * .Select(e => e.Source as ComboBox) * .Select(c => c.SelectedIndex) * .InvokeCommand(ViewModel.SetGameVersionCommand) * .DisposeWith(d);*/ /*ViewModel * .WhenAnyValue(vm => vm.SelectedGame) * .Select(gameVersion => (int)gameVersion) * .BindTo(this, v => v.GameVersionSelectorCombo.SelectedIndex) * .DisposeWith(d);*/ ProjectsList .Events() .SelectionChanged .Select(e => ((ListItem <Guid, string>?)ProjectsList.SelectedItem)?.Key) .WhereNotNull() .BindTo(ViewModel, vm => vm.SelectedProject) .DisposeWith(d); ViewModel .WhenAnyValue(vm => vm.SelectedProject) .WhereNotNull() .Where(v => v != Guid.Empty) .Subscribe(RenderFiles) .DisposeWith(d); ViewModel .WhenAnyValue(vm => vm.ProjectList) .Select(list => list .ToList() .Select(project => new ListItem <Guid, string>(project.Id, project.Name))) .Subscribe(items => { ProjectsList.Dispatcher.InvokeAsync(() => { ProjectsList.ItemsSource = items; if (items.Any() && ViewModel.SelectedProject == Guid.Empty) { ProjectsList.SelectedIndex = 0; } }); }) .DisposeWith(d); TreeViewAddContextBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.AddProjectFilesCommand) .DisposeWith(d); TreeViewDeleteContextBtn .Events() .Click .Select(e => { var selectedItems = FilesTreeView.SelectedItems .Cast <FileTreeViewNode>() .ToList(); return(selectedItems .Select(item => item.FileId) .ToList() as IReadOnlyCollection <Guid>); }) .InvokeCommand(ViewModel.DeleteAssetsCommand) .DisposeWith(d); ListBoxDeleteContextBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.DeleteProjectCommand) .DisposeWith(d); ListBoxEditContextBtn .Events() .Click .Select(e => Unit.Default) .InvokeCommand(ViewModel.EditProjectCommand) .DisposeWith(d); }); FilesTreeView.SelectedItemChanged += FilesTreeView_SelectedItemChanged; FilesTreeView.Focusable = true; }
protected virtual IEnumerable items() { BillingFilter filter = Filter.Current; if (filter == null) { yield break; } bool found = false; foreach (ProjectsList item in Items.Cache.Inserted) { found = true; yield return(item); } if (found) { yield break; } PXSelectBase <PMProject> select = new PXSelectJoin <PMProject, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> > > >, Where2 <Where <ContractBillingSchedule.nextDate, LessEqual <Current <BillingFilter.invoiceDate> >, Or <ContractBillingSchedule.type, Equal <BillingType.BillingOnDemand> > >, And <PMProject.baseType, Equal <PMProject.ProjectBaseType>, And <PMProject.nonProject, Equal <False>, And <PMProject.isTemplate, Equal <False> > > > > >(this); if (filter.StatementCycleId != null) { select.WhereAnd <Where <Customer.statementCycleId, Equal <Current <BillingFilter.statementCycleId> > > >(); } if (filter.CustomerClassID != null) { select.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >(); } if (filter.CustomerID != null) { select.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >(); } if (filter.TemplateID != null) { select.WhereAnd <Where <PMProject.templateID, Equal <Current <BillingFilter.templateID> > > >(); } foreach (PXResult <PMProject, ContractBillingSchedule, Customer> item in select.Select()) { PMProject project = (PMProject)item; ContractBillingSchedule schedule = (ContractBillingSchedule)item; Customer customer = (Customer)item; ProjectsList result = new ProjectsList(); result.ProjectID = project.ContractID; result.ProjectCD = project.ContractCD; result.Description = project.Description; result.CustomerID = project.CustomerID; result.CustomerName = customer.AcctName; result.LastDate = schedule.LastDate; DateTime?fromDate = null; if (schedule.NextDate != null) { switch (schedule.Type) { case BillingType.Annual: fromDate = schedule.NextDate.Value.AddYears(-1); break; case BillingType.Monthly: fromDate = schedule.NextDate.Value.AddMonths(-1); break; case BillingType.Weekly: fromDate = schedule.NextDate.Value.AddDays(-7); break; case BillingType.Quarterly: fromDate = schedule.NextDate.Value.AddMonths(-3); break; } } result.FromDate = fromDate; result.NextDate = schedule.NextDate; yield return(Items.Insert(result)); } Items.Cache.IsDirty = false; }
protected override void ClearData() { ProjectsList.Clear(); }
//Загружет списки проектов и провайдеров для потока 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); }
protected virtual IEnumerable items() { BillingFilter filter = Filter.Current; if (filter == null) { yield break; } bool found = false; foreach (ProjectsList item in Items.Cache.Inserted) { found = true; yield return(item); } if (found) { yield break; } PXSelectBase <PMProject> selectUnbilled = new PXSelectJoinGroupBy <PMProject, InnerJoin <PMUnbilledDailySummary, On <PMUnbilledDailySummary.projectID, Equal <PMProject.contractID> >, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMUnbilledDailySummary.projectID>, And <PMTask.isActive, Equal <True>, And <PMTask.taskID, Equal <PMUnbilledDailySummary.taskID>, And <Where <PMTask.billingOption, Equal <PMBillingOption.onBilling>, Or2 <Where <PMTask.billingOption, Equal <PMBillingOption.onTaskCompletion>, And <PMTask.isCompleted, Equal <True> > >, Or <Where <PMTask.billingOption, Equal <PMBillingOption.onProjectCompetion>, And <PMProject.isCompleted, Equal <True> > > > > > > > > >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID>, And <PMBillingRule.accountGroupID, Equal <PMUnbilledDailySummary.accountGroupID> > > > > > > >, Where2 <Where <ContractBillingSchedule.nextDate, LessEqual <Current <BillingFilter.invoiceDate> >, Or <ContractBillingSchedule.type, Equal <BillingType.BillingOnDemand> > >, And2 <Where <PMBillingRule.includeNonBillable, Equal <False>, And <PMUnbilledDailySummary.billable, Greater <int0>, Or <Where <PMBillingRule.includeNonBillable, Equal <True>, And <Where <PMUnbilledDailySummary.nonBillable, Greater <int0>, Or <PMUnbilledDailySummary.billable, Greater <int0> > > > > > > >, And2 <Where <PMUnbilledDailySummary.date, LessEqual <Current <BillingFilter.invoiceDate> > >, And <Match <Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <PMProject.contractID> > >(this); if (Setup.Current.CutoffDate == PMCutOffDate.Excluded) { selectUnbilled = new PXSelectJoinGroupBy <PMProject, InnerJoin <PMUnbilledDailySummary, On <PMUnbilledDailySummary.projectID, Equal <PMProject.contractID> >, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMUnbilledDailySummary.projectID>, And <PMTask.isActive, Equal <True>, And <PMTask.taskID, Equal <PMUnbilledDailySummary.taskID>, And <Where <PMTask.billingOption, Equal <PMBillingOption.onBilling>, Or2 <Where <PMTask.billingOption, Equal <PMBillingOption.onTaskCompletion>, And <PMTask.isCompleted, Equal <True> > >, Or <Where <PMTask.billingOption, Equal <PMBillingOption.onProjectCompetion>, And <PMProject.isCompleted, Equal <True> > > > > > > > > >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID>, And <PMBillingRule.accountGroupID, Equal <PMUnbilledDailySummary.accountGroupID> > > > > > > >, Where2 <Where <ContractBillingSchedule.nextDate, LessEqual <Current <BillingFilter.invoiceDate> >, Or <ContractBillingSchedule.type, Equal <BillingType.BillingOnDemand> > >, And2 <Where <PMBillingRule.includeNonBillable, Equal <False>, And <PMUnbilledDailySummary.billable, Greater <int0>, Or <Where <PMBillingRule.includeNonBillable, Equal <True>, And <Where <PMUnbilledDailySummary.nonBillable, Greater <int0>, Or <PMUnbilledDailySummary.billable, Greater <int0> > > > > > > >, And2 <Where <PMUnbilledDailySummary.date, Less <Current <BillingFilter.invoiceDate> > >, And <Match <Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <PMProject.contractID> > >(this); } PXSelectBase <PMProject> selectRecurring = new PXSelectJoinGroupBy <PMProject, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMProject.contractID> >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID> >, InnerJoin <PMRecurringItem, On <PMTask.projectID, Equal <PMRecurringItem.projectID>, And <PMTask.taskID, Equal <PMRecurringItem.taskID>, And <PMTask.isCompleted, Equal <False> > > > > > > > >, Where2 <Where <ContractBillingSchedule.nextDate, LessEqual <Current <BillingFilter.invoiceDate> >, Or <ContractBillingSchedule.type, Equal <BillingType.BillingOnDemand> > >, And <Match <Current <AccessInfo.userName> > > >, Aggregate <GroupBy <PMProject.contractID> > >(this); PXSelectBase <PMProject> selectProgressive = new PXSelectJoinGroupBy <PMProject, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMProject.contractID> >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID> >, InnerJoin <PMBudget, On <PMTask.projectID, Equal <PMBudget.projectID>, And <PMTask.taskID, Equal <PMBudget.projectTaskID>, And <PMBudget.type, Equal <GL.AccountType.income>, And <PMBudget.amountToInvoice, NotEqual <decimal0> > > > > > > > > >, Where <Match <Current <AccessInfo.userName> > >, Aggregate <GroupBy <PMProject.contractID> > >(this); if (filter.StatementCycleId != null) { selectUnbilled.WhereAnd <Where <Customer.statementCycleId, Equal <Current <BillingFilter.statementCycleId> > > >(); selectRecurring.WhereAnd <Where <Customer.statementCycleId, Equal <Current <BillingFilter.statementCycleId> > > >(); selectProgressive.WhereAnd <Where <Customer.statementCycleId, Equal <Current <BillingFilter.statementCycleId> > > >(); } if (filter.CustomerClassID != null) { selectUnbilled.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >(); selectRecurring.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >(); selectProgressive.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >(); } if (filter.CustomerID != null) { selectUnbilled.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >(); selectRecurring.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >(); selectProgressive.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >(); } if (filter.TemplateID != null) { selectUnbilled.WhereAnd <Where <PMProject.templateID, Equal <Current <BillingFilter.templateID> > > >(); selectRecurring.WhereAnd <Where <PMProject.templateID, Equal <Current <BillingFilter.templateID> > > >(); selectProgressive.WhereAnd <Where <PMProject.templateID, Equal <Current <BillingFilter.templateID> > > >(); } foreach (PXResult item in selectUnbilled.Select().Union(selectRecurring.Select()).Union(selectProgressive.Select())) { PMProject project = PXResult.Unwrap <PMProject>(item); ContractBillingSchedule schedule = PXResult.Unwrap <ContractBillingSchedule>(item); Customer customer = PXResult.Unwrap <Customer>(item); ProjectsList result = new ProjectsList(); result.ProjectID = project.ContractID; result.ProjectCD = project.ContractCD; result.Description = project.Description; result.CustomerID = project.CustomerID; result.CustomerName = customer.AcctName; result.LastDate = schedule.LastDate; DateTime?fromDate = null; if (schedule.NextDate != null) { switch (schedule.Type) { case BillingType.Annual: fromDate = schedule.NextDate.Value.AddYears(-1); break; case BillingType.Monthly: fromDate = schedule.NextDate.Value.AddMonths(-1); break; case BillingType.Weekly: fromDate = schedule.NextDate.Value.AddDays(-7); break; case BillingType.Quarterly: fromDate = schedule.NextDate.Value.AddMonths(-3); break; } } result.FromDate = fromDate; result.NextDate = schedule.NextDate; if (Items.Locate(result) == null) { yield return(Items.Insert(result)); } } Items.Cache.IsDirty = false; }
public ProjectsList GetCompatibleBuilds() { WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK; return(ProjectsList.GetProjectsList()); }