private void DeleteResources() { List <EnterpriseResource> resourceList = new List <EnterpriseResource>(); LV_ServerObjects.InvokeIfRequired(s => { ListView.SelectedListViewItemCollection selectedItems = s.SelectedItems; resourceList.AddRange(selectedItems.Cast <ListViewItem>().Select(selectedItem => (EnterpriseResource)selectedItem.Tag)); }); if (!resourceList.Any()) { return; } resourceList.ForEach(r => { if (r.IsCheckedOut) { Log.WriteVerbose(new SourceInfo(), TB_Status, "Checking in resource:{0}.", r.Name); r.ForceCheckIn(); } Log.WriteVerbose(new SourceInfo(), TB_Status, "Deleting resource:{0}.", r.Name); r.DeleteObject(); }); ProjContext.EnterpriseResources.Update(); ProjContext.ExecuteQuery(); Log.WriteVerbose(new SourceInfo(), TB_Status, _bgeResourcesDelete, "Refreshing Resources"); LoadResources(); }
private void LoadResourcesList() { IEnumerable <EnterpriseResource> resourcesList = ProjContext.LoadQuery(ProjContext.EnterpriseResources.Include(p => p.Name, p => p.Id, p => p.IsCheckedOut)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (EnterpriseResource res in resourcesList) { ListViewItem lvi = new ListViewItem(res.Id.ToString()); lvi.SubItems.Add(res.Name); lvi.SubItems.Add(res.IsCheckedOut.ToString()); lvi.Tag = res; Log.WriteVerbose(new SourceInfo(), TB_Status, "Found Resource {0}", res.Name); listViewItems.Add(lvi); } LV_ServerObjects.InvokeIfRequired(s => { s.Items.Clear(); s.Columns.Clear(); s.Columns.Add(new ColumnHeader { Text = "Id", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Name", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "CheckOut", DisplayIndex = 0, Width = 20 }); s.Items.AddRange(listViewItems.ToArray()); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void LoadProjects() { CB_ProjectList.InvokeIfRequired(s => { s.DataSource = null; s.Items.Clear(); }); IEnumerable <PublishedProject> projectList = ProjContext.LoadQuery(ProjContext.Projects.Include(p => p.Draft.Name, p => p.Draft, p => p.IsCheckedOut)); ProjContext.ExecuteQuery(); Dictionary <string, PublishedProject> projList = new Dictionary <string, PublishedProject> { { "Select a Project", null } }; foreach (PublishedProject project in projectList) { projList.Add(project.Draft.Name, project); } CB_ProjectList.InvokeIfRequired(s => { CB_ProjectList.SelectedIndexChanged += CB_ProjectList_SelectedIndexChanged; CB_ProjectList.DropDownStyle = ComboBoxStyle.DropDown; CB_ProjectList.AutoCompleteMode = AutoCompleteMode.SuggestAppend; CB_ProjectList.AutoCompleteSource = AutoCompleteSource.ListItems; CB_ProjectList.DataSource = new BindingSource(projList, null); CB_ProjectList.DisplayMember = "Key"; CB_ProjectList.ValueMember = "Value"; }); }
private void GetDraftProjectsList() { LV_Projects.InvokeIfRequired(s => s.Items.Clear()); IEnumerable <PublishedProject> projectList = ProjContext.LoadQuery(ProjContext.Projects.Include(p => p.Draft.Name, p => p.Draft.Id, p => p.IsCheckedOut)); ProjContext.ExecuteQuery(); PublishedProject[] publishedProjects = projectList.ToArray(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (PublishedProject project in publishedProjects) { ListViewItem lvi = new ListViewItem(project.Draft.Name) { Tag = project }; Log.WriteVerbose(new SourceInfo(), "Found Project:{0}", project.Draft.Name); listViewItems.Add(lvi); } LV_Projects.InvokeIfRequired(s => { s.Columns[0].Text = $"Projects({publishedProjects.Length})"; s.Items.AddRange(listViewItems.ToArray()); }); }
private void CheckInCheckoutProjects() { List <PublishedProject> projectList = new List <PublishedProject>(); LV_ServerObjects.InvokeIfRequired(s => { ListView.SelectedListViewItemCollection selectedItems = s.SelectedItems; projectList.AddRange(selectedItems.Cast <ListViewItem>().Select(selectedItem => (PublishedProject)selectedItem.Tag)); }); if (!projectList.Any()) { return; } if (_checkin) { List <QueueJob> jobs = projectList.Where(s => s.IsCheckedOut).Select(p => { QueueJob job = null; Log.WriteVerbose(new SourceInfo(), TB_Status, "Checking in Project {0}", p.Name); job = p.Draft.CheckIn(true); return(job); }).ToList(); if (jobs.Count <= 0) { return; } Log.WriteVerbose(new SourceInfo(), TB_Status, _backgroundExecutorWithStatus, "Waiting for the Queue jobs to complete"); CsomHelper.ExecuteAndWait(jobs, TB_Status); Log.WriteVerbose(new SourceInfo(), TB_Status, _backgroundExecutorWithStatus, "Loading Projects"); LoadProjects(); } else { bool needExecute = false; projectList.ForEach(p => { if (p.IsCheckedOut) { return; } Log.WriteVerbose(new SourceInfo(), TB_Status, "Checking out Project {0}", p.Name); p.CheckOut(); needExecute = true; }); if (needExecute) { ProjContext.ExecuteQuery(); LoadProjects(); } else { Log.WriteVerbose(new SourceInfo(), TB_Status, _backgroundExecutorWithStatus, "All selected projects are in checked out state."); } } }
private void LoadProjectsList() { LV_Projects.InvokeIfRequired(s => { s.Items.Clear(); s.Columns.Clear(); s.Columns.Add(new ColumnHeader { Text = "Id", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Name", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Owner", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "CheckOut by", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Published Date", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Updated Date", DisplayIndex = 0, Width = 20 }); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); IEnumerable <PublishedProject> projectList = ProjContext.LoadQuery(ProjContext.Projects.Include(p => p.Name, p => p.Id, p => p.IsCheckedOut, p => p.CheckedOutBy.LoginName, p => p.LastPublishedDate, p => p.Owner.LoginName, p => p.Draft.LastSavedDate)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (PublishedProject proj in projectList) { ListViewItem lvi = new ListViewItem(proj.Id.ToString()); lvi.SubItems.Add(proj.Name); lvi.SubItems.Add(proj.Owner.LoginName); lvi.SubItems.Add(proj.IsCheckedOut ? proj.CheckedOutBy.LoginName : string.Empty); lvi.SubItems.Add(proj.LastPublishedDate.ToString(CultureInfo.InvariantCulture)); lvi.SubItems.Add(proj.Draft.LastSavedDate.ToString(CultureInfo.InvariantCulture)); lvi.Tag = proj; listViewItems.Add(lvi); } LV_Projects.InvokeIfRequired(s => { s.Items.AddRange(listViewItems.ToArray()); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void LoadProjectInfo() { DGV_Project.InvokeIfRequired(dg => { dg.Columns.Clear(); dg.DataSource = null; dg.AllowUserToAddRows = false; }); CB_ProjectList.InvokeIfRequired(cb => _publishedProject = cb.SelectedValue as PublishedProject); if (_publishedProject == null) { return; } if (Settings.Default.LoadAllProperties) { LoadQueryFields(_publishedProject.Draft); } else { ProjContext.Load(_publishedProject.Draft, p => p, p => p.Tasks, p => p.Assignments, p => p.ProjectResources); } ProjContext.ExecuteQuery(); List <PropertyInfo> retrievedFields = DisplayFields(_publishedProject.Draft); DataTable dt = CreateDataTableForDisplay(retrievedFields); dt.ExtendedProperties.Add(dt.Rows.Count, _publishedProject.Draft); DataRow dr = dt.NewRow(); retrievedFields.ForEach(prop => SetPropertyValueInDataColumn(dr, prop, _publishedProject.Draft)); dt.Rows.Add(dr); DGV_Project.InvokeIfRequired(dg => { dg.DataSource = dt; dg.Refresh(); TP_Tasks.Text = $"Tasks({_publishedProject.Draft.Tasks.Count()})"; TP_Assignments.Text = $"Assignments({_publishedProject.Draft.Assignments.Count()})"; TP_Resources.Text = $"Resources({_publishedProject.Draft.ProjectResources.Count()})"; if (_publishedProject.Draft.Tasks.Any()) { LoadTasksInfo(_publishedProject.Draft.Tasks); } if (_publishedProject.Draft.Assignments.Any()) { LoadAssignments(_publishedProject.Draft.Assignments); } if (_publishedProject.Draft.ProjectResources.Any()) { LoadProjectResources(_publishedProject.Draft.ProjectResources); } }); }
private void LoadCustomFieldsList() { LV_ServerObjects.InvokeIfRequired(s => { s.Items.Clear(); s.Columns.Clear(); s.Columns.Add(new ColumnHeader { Text = "Id", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Name", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Type", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Required", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "LookupTable", DisplayIndex = 0, Width = 20 }); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); IEnumerable <CustomField> customFieldList = ProjContext.LoadQuery(ProjContext.CustomFields.Include(r => r.Name, r => r.EntityType.Name, r => r.Id, r => r.IsRequired, r => r.LookupTable.Name)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (CustomField cf in customFieldList) { ListViewItem lvi = new ListViewItem(cf.Id.ToString()); lvi.SubItems.Add(cf.Name); lvi.SubItems.Add(cf.EntityType.Name); lvi.SubItems.Add(cf.IsRequired.ToString()); if (cf.LookupTable.ServerObjectIsNull != null && !cf.LookupTable.ServerObjectIsNull.Value) { lvi.SubItems.Add(cf.LookupTable.Name); } lvi.Tag = cf; listViewItems.Add(lvi); } LV_ServerObjects.InvokeIfRequired(s => { s.Items.AddRange(listViewItems.ToArray()); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void LoadProjectsList() { IEnumerable <PublishedProject> projectList = ProjContext.LoadQuery(ProjContext.Projects.Include(p => p.Name, p => p.Id, p => p.IsCheckedOut, p => p.Owner.LoginName, p => p.CheckedOutBy.LoginName, p => p.CheckedOutDate)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (PublishedProject project in projectList) { ListViewItem lvi = new ListViewItem(project.Name); lvi.SubItems.Add(project.IsCheckedOut.ToString()); lvi.SubItems.Add(project.Owner.LoginName); if (project.IsCheckedOut) { lvi.SubItems.Add(project.CheckedOutBy.LoginName); lvi.SubItems.Add(project.CheckedOutDate.ToString(CultureInfo.InvariantCulture)); } lvi.Tag = project; Log.WriteVerbose(new SourceInfo(), TB_Status, "Found Project {0}", project.Name); listViewItems.Add(lvi); } LV_ServerObjects.InvokeIfRequired(s => { s.Items.Clear(); s.Columns.Clear(); s.Columns.Add(new ColumnHeader { Text = "Name", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "CheckOut", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Owner", DisplayIndex = 0, Width = 30 }); s.Columns.Add(new ColumnHeader { Text = "CheckOut By", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "CheckOut Date", DisplayIndex = 0, Width = 20 }); s.Items.AddRange(listViewItems.ToArray()); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void LoadResourcesList() { LV_ServerObjects.InvokeIfRequired(s => { s.Items.Clear(); s.Columns.Clear(); s.Columns.Add(new ColumnHeader { Text = "Id", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Name", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Active", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "CheckOut", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Modified", DisplayIndex = 0, Width = 20 }); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); IEnumerable <EnterpriseResource> resourcesList = ProjContext.LoadQuery(ProjContext.EnterpriseResources.Include(p => p.Name, p => p.Id, p => p.IsCheckedOut, p => p.Modified, p => p.IsActive)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (EnterpriseResource res in resourcesList) { ListViewItem lvi = new ListViewItem(res.Id.ToString()); lvi.SubItems.Add(res.Name); lvi.SubItems.Add(res.IsActive.ToString()); lvi.SubItems.Add(res.IsCheckedOut.ToString()); lvi.SubItems.Add(res.Modified.ToString(CultureInfo.InvariantCulture)); lvi.Tag = res; listViewItems.Add(lvi); } LV_ServerObjects.InvokeIfRequired(s => { s.Items.AddRange(listViewItems.ToArray()); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void DeleteCustomFields() { List <CustomField> customFieldList = new List <CustomField>(); LV_ServerObjects.InvokeIfRequired(s => { ListView.SelectedListViewItemCollection selectedItems = s.SelectedItems; customFieldList.AddRange(selectedItems.Cast <ListViewItem>().Select(selectedItem => (CustomField)selectedItem.Tag)); }); if (!customFieldList.Any()) { return; } customFieldList.ForEach(cf => cf.DeleteObject()); ProjContext.ExecuteQuery(); LoadCustomFields(); }
private void CreateCustomFields() { EntityType entityType = ProjContext.EntityTypes.ProjectEntity; CustomFieldType customFieldType = CustomFieldType.TEXT; LookupTable selectedLookupTable = null; bool allowMultiSelect = false; CB_EntityType.InvokeIfRequired(cb => entityType = cb.SelectedValue as EntityType); CB_Type.InvokeIfRequired(sb => customFieldType = (CustomFieldType)CB_Type.SelectedValue); CB_LookupTable.InvokeIfRequired(cb => { if (cb.SelectedIndex <= 0) { return; } selectedLookupTable = cb.SelectedValue as LookupTable; if (CBX_AllowMultiSelect.Checked) { allowMultiSelect = true; } }); for (int customFieldCount = 1; customFieldCount <= Convert.ToInt32(NUD_CFNumber.Value); customFieldCount++) { CustomFieldCreationInformation cfCi = new CustomFieldCreationInformation { Name = TB_Name.Text + customFieldCount, EntityType = entityType, FieldType = customFieldType }; Log.WriteVerbose(new SourceInfo(), TB_Status, "Creating custom field with name {0}", cfCi.Name); if (selectedLookupTable != null) { cfCi.LookupTable = selectedLookupTable; Log.WriteVerbose(new SourceInfo(), TB_Status, "Setting custom field to use lookup table {0}", selectedLookupTable.Name); } cfCi.LookupAllowMultiSelect = allowMultiSelect; ProjContext.CustomFields.Add(cfCi); } ProjContext.CustomFields.Update(); ProjContext.ExecuteQuery(); }
private void GetEnterpriseResourcesList() { LV_EnterpiseResources.InvokeIfRequired(s => s.Items.Clear()); IEnumerable <EnterpriseResource> resourcesList = ProjContext.LoadQuery(ProjContext.EnterpriseResources.Where(r => r.ResourceType == EnterpriseResourceType.Work)); ProjContext.ExecuteQuery(); EnterpriseResource[] enterpriseResources = resourcesList.ToArray(); foreach (EnterpriseResource res in enterpriseResources) { ListViewItem lvi = new ListViewItem(res.Name) { Tag = res }; Log.WriteVerbose(new SourceInfo(), "Found Resource:{0}", res.Name); LV_EnterpiseResources.InvokeIfRequired(s => s.Items.Add(lvi)); } LV_EnterpiseResources.InvokeIfRequired(s => s.Columns[0].Text = $"Enterprise Resources({enterpriseResources.Length})"); }
private void LoadLookupTables() { IEnumerable <LookupTable> lookupTables1 = ProjContext.LoadQuery(ProjContext.LookupTables); ProjContext.ExecuteQuery(); Dictionary <string, LookupTable> lookupTables = new Dictionary <string, LookupTable> { { "Select", null } }; foreach (LookupTable lt in lookupTables1) { lookupTables.Add(lt.Name, lt); } CB_LookupTable.InvokeIfRequired(cb => { cb.DataSource = new BindingSource(lookupTables, null); cb.DisplayMember = "Key"; cb.ValueMember = "Value"; }); }
private void CreateResources() { EnterpriseResourceType selectedEnterpriseResourceType = EnterpriseResourceType.Work; cbxResType.InvokeIfRequired(s => selectedEnterpriseResourceType = (EnterpriseResourceType)cbxResType.SelectedValue); for (int resourceCount = 1; resourceCount <= numResources.Value; resourceCount++) { EnterpriseResourceCreationInformation erCi = new EnterpriseResourceCreationInformation { Name = txtResourceName.Text + resourceCount, IsInactive = CB_Inactive.Checked, IsGeneric = CB_Generic.Checked, IsBudget = CB_Budget.Checked, ResourceType = selectedEnterpriseResourceType }; Log.WriteVerbose(new SourceInfo(), TB_Status, "Creating Resource with name {0}", erCi.Name); ProjContext.EnterpriseResources.Add(erCi); } ProjContext.EnterpriseResources.Update(); ProjContext.ExecuteQuery(); }
private void DeleteCalendars() { List <Calendar> calendarList = new List <Calendar>(); LV_ServerObjects.InvokeIfRequired(s => { ListView.SelectedListViewItemCollection selectedItems = s.SelectedItems; calendarList.AddRange(selectedItems.Cast <ListViewItem>().Select(selectedItem => (Calendar)selectedItem.Tag)); }); if (!calendarList.Any()) { return; } calendarList.ForEach(c => { c.DeleteObject(); }); ProjContext.ExecuteQuery(); LoadCalendars(); }
private void DeleteLookupTables() { List <LookupTable> lookupTableList = new List <LookupTable>(); LV_ServerObjects.InvokeIfRequired(s => { ListView.SelectedListViewItemCollection selectedItems = s.SelectedItems; lookupTableList.AddRange(selectedItems.Cast <ListViewItem>().Select(selectedItem => (LookupTable)selectedItem.Tag)); }); if (!lookupTableList.Any()) { return; } lookupTableList.ForEach(lt => { lt.DeleteObject(); }); ProjContext.ExecuteQuery(); LoadLookupTables(); }
private void LoadCalendarsList() { LV_ServerObjects.InvokeIfRequired(s => { s.Items.Clear(); s.Columns.Clear(); s.Columns.Add(new ColumnHeader { Text = "Id", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Name", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Changed Date", DisplayIndex = 0, Width = 20 }); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); IEnumerable <Calendar> calendarList = ProjContext.LoadQuery(ProjContext.Calendars.Include(r => r.Name, r => r.Id, r => r.Modified)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (Calendar cal in calendarList) { ListViewItem lvi = new ListViewItem(cal.Id.ToString()); lvi.SubItems.Add(cal.Name); lvi.SubItems.Add(cal.Modified.ToString(CultureInfo.InvariantCulture)); lvi.Tag = cal; listViewItems.Add(lvi); } LV_ServerObjects.InvokeIfRequired(s => { s.Items.AddRange(listViewItems.ToArray()); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void LoadLookupTablesList() { LV_ServerObjects.InvokeIfRequired(s => { s.Items.Clear(); s.Columns.Clear(); s.Columns.Add(new ColumnHeader { Text = "Id", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Name", DisplayIndex = 0, Width = 20 }); s.Columns.Add(new ColumnHeader { Text = "Type", DisplayIndex = 0, Width = 20 }); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); IEnumerable <LookupTable> lookupFieldList = ProjContext.LoadQuery(ProjContext.LookupTables.Include(r => r.Name, r => r.Id, r => r.FieldType)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (LookupTable lt in lookupFieldList) { ListViewItem lvi = new ListViewItem(lt.Id.ToString()); lvi.SubItems.Add(lt.Name); lvi.SubItems.Add(lt.FieldType.ToString()); lvi.Tag = lt; listViewItems.Add(lvi); } LV_ServerObjects.InvokeIfRequired(s => { s.Items.AddRange(listViewItems.ToArray()); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); s.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void GetDraftTeamForSelectedProject() { PublishedProject project = null; LV_Projects.InvokeIfRequired(s => project = s.SelectedItems[0].Tag as PublishedProject); LV_ProjectResources.InvokeIfRequired(s => s.Items.Clear()); IEnumerable <DraftProjectResource> resourceList = ProjContext.LoadQuery(project.Draft.ProjectResources); ProjContext.ExecuteQuery(); DraftProjectResource[] draftProjectResources = resourceList.ToArray(); foreach (ListViewItem lvi in draftProjectResources.Select(res => new ListViewItem(res.Name) { Tag = res })) { LV_ProjectResources.InvokeIfRequired(s => s.Items.Add(lvi)); } LV_ProjectResources.InvokeIfRequired(s => s.Columns[0].Text = $"Project Resources({draftProjectResources.Length})"); }
private void CheckInResources() { List <EnterpriseResource> resourceList = new List <EnterpriseResource>(); LV_ServerObjects.InvokeIfRequired(s => { ListView.SelectedListViewItemCollection selectedItems = s.SelectedItems; resourceList.AddRange(selectedItems.Cast <ListViewItem>().Select(selectedItem => (EnterpriseResource)selectedItem.Tag)); }); if (!resourceList.Any()) { return; } foreach (var res in resourceList.Where(r => r.IsCheckedOut)) { Log.WriteVerbose(new SourceInfo(), TB_Status, "Checking in Resource {0}", res.Name); res.ForceCheckIn(); } ProjContext.ExecuteQuery(); Log.WriteVerbose(new SourceInfo(), TB_Status, _backgroundExecutorWithStatus, "Loading Resources"); LoadResources(); }
private void LoadEnterpriseResources() { Log.WriteVerbose(new SourceInfo(), "Loading Enterprise Resources"); LV_EnterpiseResources.InvokeIfRequired(s => s.Items.Clear()); IEnumerable <EnterpriseResource> resourcesList = ProjContext.LoadQuery(ProjContext.EnterpriseResources.Include(r => r.Name, r => r.User)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = resourcesList.Where(r => !r.User.IsNull()).Select(res => { Log.WriteVerbose(new SourceInfo(), TB_Status, "Found Enterprise Resource {0}", res.Name); return(new ListViewItem(res.Name) { Tag = res }); }).ToList(); LV_EnterpiseResources.InvokeIfRequired(s => { s.Items.AddRange(listViewItems.ToArray()); s.Columns[0].Text = $"Enterprise Resources({listViewItems.Count})"; }); }
private void LoadProjects() { Log.WriteVerbose(new SourceInfo(), "Loading projects"); IEnumerable <PublishedProject> projectList = ProjContext.LoadQuery(ProjContext.Projects.Include(p => p.Name, p => p.Owner, p => p.Id, p => p.Owner.Title, p => p.IsCheckedOut, p => p.CheckedOutBy.Title, p => p.Draft.LastSavedDate, p => p.Draft)); ProjContext.ExecuteQuery(); List <ListViewItem> listViewItems = new List <ListViewItem>(); foreach (PublishedProject project in projectList) { ListViewItem lvi = new ListViewItem(project.Name); lvi.SubItems.Add(project.Owner.Title); if (project.CheckedOutBy.IsNull()) { lvi.SubItems.Add(String.Empty); } else { lvi.SubItems.Add(project.CheckedOutBy.Title); } lvi.SubItems.Add(project.Draft.LastSavedDate.ToString(CultureInfo.InvariantCulture)); lvi.Tag = project; Log.WriteVerbose(new SourceInfo(), "Found Project:{0}", project.Name); listViewItems.Add(lvi); } LV_Projects.InvokeIfRequired(s => { s.Items.Clear(); s.Items.AddRange(listViewItems.ToArray()); s.Columns[0].Text = $"Projects({listViewItems.Count})"; LV_Projects.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); LV_Projects.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }); }
private void CreateLookupTables() { for (int lookupTableCount = 1; lookupTableCount <= Convert.ToInt32(NUD_LTNumber.Value); lookupTableCount++) { List <LookupMask> masks = new List <LookupMask>(); for (int levelCount = 0; levelCount <= Convert.ToInt32(NUD_Levels.Value); levelCount++) { LookupMask lkm = new LookupMask { Length = 0, MaskType = LookupTableMaskSequence.CHARACTERS, Separator = "." }; masks.Add(lkm); } List <LookupEntryCreationInformation> lookupEntry = new List <LookupEntryCreationInformation>(); for (int levelCount = 1; levelCount <= Convert.ToInt32(NUD_Levels.Value); levelCount++) { //creating the parent level LookupEntryCreationInformation parentCi = new LookupEntryCreationInformation { Id = Guid.NewGuid(), SortIndex = 0, Value = new LookupEntryValue { TextValue = RandomEx.RandomString(Convert.ToInt32(NUD_Length.Value)) } }; lookupEntry.Add(parentCi); //creating the child levels for (int subLevel = 1; subLevel <= Convert.ToInt32(NUD_ValuePerLevel.Value); subLevel++) { LookupEntryCreationInformation childCi = new LookupEntryCreationInformation { Id = Guid.NewGuid(), ParentId = parentCi.Id, SortIndex = 0, Value = new LookupEntryValue { TextValue = RandomEx.RandomString(Convert.ToInt32(NUD_Length.Value)) } }; lookupEntry.Add(childCi); } } LookupTableSortOrder lookupTableSortOrder = LookupTableSortOrder.Ascending; CB_Sort.InvokeIfRequired(cb => lookupTableSortOrder = (LookupTableSortOrder)cb.SelectedValue); LookupTableCreationInformation ltCi = new LookupTableCreationInformation { Name = TB_Name.Text + lookupTableCount, Masks = masks, SortOrder = lookupTableSortOrder, Entries = lookupEntry }; Log.WriteVerbose(new SourceInfo(), TB_Status, "Creating lookup field with name {0}", ltCi.Name); ProjContext.LookupTables.Add(ltCi); } ProjContext.LookupTables.Update(); ProjContext.ExecuteQuery(); }
private void CreateProjects() { IList <EnterpriseResource> enterpriseResources = null; List <QueueJob> projectCreationJobs = new List <QueueJob>(); if (RB_AssignExistingEnterpriseResources.Checked) { IEnumerable <EnterpriseResource> resList = ProjContext.LoadQuery(ProjContext.EnterpriseResources.Where(r => r.ResourceType == EnterpriseResourceType.Work)); ProjContext.ExecuteQuery(); enterpriseResources = resList.ToList(); } for (int projCount = 1; projCount <= numProjects.Value; projCount++) { string projName = txtProjName.Text + projCount; List <EnterpriseResource> projectTeam = new List <EnterpriseResource>(); PublishedProject newProject = ProjContext.Projects.Add(new ProjectCreationInformation { Name = projName }); //Build the team first. if (RB_AssignExistingEnterpriseResources.Checked) { if (enterpriseResources.Count > 0) { projectTeam = enterpriseResources.PickRandom((int)numTasks.Value); projectTeam.ForEach(p => newProject.Draft.ProjectResources.AddEnterpriseResource(p)); } else { Log.WriteWarning(new SourceInfo(), TB_Status, "No enterprise resources available in the server."); } } else if (RB_AssignToMe.Checked) { if (CsomBase.CurrentResourceIsAssignable) { newProject.Draft.ProjectResources.AddEnterpriseResource(CsomBase.CurrentResource); } else { Log.WriteWarning(new SourceInfo(), TB_Status, "Current user is not resource. Not creating assignments."); } } List <TaskCreationInformation> dtc = CreateTasks(); if (CB_Tasks.Checked) { foreach (var task in dtc) { newProject.Draft.Tasks.Add(task); if (RB_AssignExistingEnterpriseResources.Checked) { if (projectTeam.Count > 0) { EnterpriseResource res = projectTeam.PickRandom(); newProject.Draft.Assignments.Add(new AssignmentCreationInformation { TaskId = task.Id, ResourceId = res.Id }); } else { Log.WriteWarning(new SourceInfo(), TB_Status, "No enterprise resources available in the server. Not creating assignments."); } } else if (RB_AssignToMe.Checked) { if (CsomBase.CurrentResourceIsAssignable) { AssignmentCreationInformation assnCi = CreateAssignment(task.Id, CsomBase.CurrentResource.Id); newProject.Draft.Assignments.Add(assnCi); } else { Log.WriteWarning(new SourceInfo(), TB_Status, "Current user is not resource. Not creating assignments."); } } } } if (RB_UseLocalResources.Checked) { for (int localResourceCount = 1; localResourceCount <= numTasks.Value; localResourceCount++) { ProjectResourceCreationInformation localResourceCi = CreateLocalResource(localResourceCount); newProject.Draft.ProjectResources.Add(localResourceCi); if (chkResAssign.Checked) { AssignmentCreationInformation assnCi = CreateAssignment(dtc.PickRandom().Id, localResourceCi.Id); newProject.Draft.Assignments.Add(assnCi); } } } Log.WriteVerbose(new SourceInfo(), TB_Status, "Creating project {0} of {1} with name {2}.", projCount, numProjects.Value, projName); projectCreationJobs.Add(newProject.Draft.Update()); } Log.WriteVerbose(new SourceInfo(), TB_Status, _backgroundExecutorWithStatus, "Waiting for the Project creation queue job to complete."); CsomHelper.ExecuteAndWait(projectCreationJobs, TB_Status); }
private void DataGridViewClick(object sender, EventArgs e) { DataGridView dgv = sender as DataGridView; var currentCell = dgv?.CurrentCell; if (currentCell == null || currentCell.ReadOnly) { return; } if (currentCell.OwningColumn.ValueType == typeof(DateTime)) { Rectangle oRectangle = dgv.GetCellDisplayRectangle(currentCell.ColumnIndex, currentCell.RowIndex, true); _dateTimePicker = new DateTimePicker { Format = DateTimePickerFormat.Short, Size = new Size(oRectangle.Width, oRectangle.Height), Location = new Point(oRectangle.X, oRectangle.Y) }; if (currentCell.FormattedValue.ToString() != string.Empty) { _dateTimePicker.Value = (DateTime)currentCell.Value; } _dateTimePicker.CloseUp += DateTimePickerCloseUp; _dateTimePicker.TextChanged += DateTimePickerOnTextChange; dgv.Controls.Add(_dateTimePicker); _dateTimePicker.Visible = true; } else if (currentCell.OwningColumn.ValueType.IsEnum) { var enumToDictionary = ParseTypeToDictionary(currentCell.OwningColumn.ValueType); DataGridViewComboBoxCell dgComboCell = new DataGridViewComboBoxCell { DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing, DataSource = new BindingSource(enumToDictionary, null), DisplayMember = "Value", ValueMember = "Key" }; dgv[currentCell.ColumnIndex, currentCell.RowIndex].ValueType = dgComboCell.ValueType; dgv[currentCell.ColumnIndex, currentCell.RowIndex] = dgComboCell; } else if (currentCell.OwningColumn.ValueType.IsSubclassOf(typeof(ClientObject))) { if (currentCell.OwningColumn.ValueType.Name.Contains("Calendar")) { if (_calendars == null) { _calendars = ProjContext.LoadQuery(ProjContext.Calendars); ProjContext.ExecuteQuery(); } Dictionary <string, Calendar> blah = _calendars.ToDictionary(er => er.Name, er => er); _dgvComboCell = new DataGridViewComboBoxCell { DataSource = new BindingSource(blah, null), DisplayMember = "Key", ValueMember = "Value", ValueType = typeof(Calendar) }; dgv[currentCell.ColumnIndex, currentCell.RowIndex] = _dgvComboCell; } else if (currentCell.OwningColumn.ValueType.Name.Contains("User")) { if (_enterpriseResources == null) { _enterpriseResources = ProjContext.LoadQuery(ProjContext.EnterpriseResources.Include(p => p.User)); ProjContext.ExecuteQuery(); } Dictionary <string, User> blah = _enterpriseResources.Where(resource => !resource.User.IsNull()) .ToDictionary(resource => resource.User.Title, resource => resource.User); _dgvComboCell = new DataGridViewComboBoxCell { DisplayMember = "Key", ValueMember = "Value", ValueType = typeof(User), DataSource = new BindingSource(blah, null) }; dgv[currentCell.ColumnIndex, currentCell.RowIndex] = _dgvComboCell; } } }