// POST odata/ProjectParts public async Task <IHttpActionResult> Post(ProjectPart projectpart) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ProjectParts.Add(projectpart); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (ProjectPartExists(projectpart.Id)) { return(Conflict()); } else { throw; } } return(Created(projectpart)); }
public async Task <IActionResult> PutProjectPart(int id, [FromBody] ProjectPart projectPart) { if (DoesUserOwnPart(projectPart.ProjectPartID)) { if (id != projectPart.ProjectPartID) { return(BadRequest()); } if (projectPart.QuantityPurchased > 0 || projectPart.QuantityInstalled > 0) { projectPart.ExcludeFromTotal = false; } _context.Entry(projectPart).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectPartExists(id)) { return(NotFound()); } else { throw; } } } return(NoContent()); }
/// <summary> /// update project part /// </summary> /// <param name="projectPart"></param> /// <returns></returns> public OperationResult UpdateProjectPart(ProjectPart projectPart) { var operationResult = new OperationResult(); var existingProjectPart = _db.ProjectPart.Find(projectPart.ProjectPartId); if (existingProjectPart != null) { try { _db.Entry(existingProjectPart).CurrentValues.SetValues(projectPart); _db.SaveChanges(); operationResult.Success = true; operationResult.Message = "Success"; } catch (Exception ex) { operationResult.Success = false; operationResult.Message = "Error"; logger.ErrorFormat("An error occurred while updating project part. {0}", ex.ToString()); } } else { operationResult.Success = false; operationResult.Message = "Unable to find project part"; } return(operationResult); }
public void CreateMilestoneAndBacklogForProject(ProjectPart project) { var contentManager = this.services.ContentManager; // create project milestones this.CreateProjectionForProjectAttachableItems(project, ContentTypes.ProjectProjectionContentType, QueryNames.ProjectMilestonesQueryName, "Milestones", ContentTypes.MilestoneContentType); var backLogItem = contentManager .HqlQuery() .ForType(ContentTypes.MilestoneContentType) .Where(c => c.ContentPartRecord <AttachToProjectPartRecord>(), d => d.Eq("Project.Id", project.Id)) .List() .FirstOrDefault(c => c.As <MilestonePart>().IsBacklog); if (backLogItem == null) { // create project back-log var backLogContentItem = this.CreateAttachableItemToProject(project, ContentTypes.MilestoneContentType); MilestonePart milestone = backLogContentItem.As <MilestonePart>(); milestone.IsBacklog = true; TitlePart milestoneTitlePart = backLogContentItem.As <TitlePart>(); milestoneTitlePart.Title = T("Backlog").Text; contentManager.Publish(backLogContentItem); } }
public CreateAppViewModel(string displayName, Container dbcontext, ProjectPart part, DataServiceCollection <App> currentApps) { this.DisplayName = displayName; this._dbContext = dbcontext; this._part = part; this._currentApps = currentApps; }
public async Task <IHttpActionResult> Patch([FromODataUri] Guid key, Delta <ProjectPart> patch) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ProjectPart projectpart = await db.ProjectParts.FindAsync(key); if (projectpart == null) { return(NotFound()); } patch.Patch(projectpart); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectPartExists(key)) { return(NotFound()); } else { throw; } } return(Updated(projectpart)); }
private void HandleAddPart(ProjectPartViewModel model) { model = _currentModel; try { ProjectPart newPart = new ProjectPart(); newPart.Id = Guid.NewGuid(); newPart.PartName = "新部位"; newPart.ParentPart = model.ProjectPartID; DbContext.AddToProjectParts(newPart); DbContext.SaveChanges(); ProjectPartViewModel newModel = new ProjectPartViewModel(model, newPart, GetChildren); model.Children.Add(newModel); } catch (Exception ex) { Messenger.Default.Send <Exception>(ex); } }
// PUT odata/ProjectParts(5) public async Task <IHttpActionResult> Put([FromODataUri] Guid key, ProjectPart projectpart) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (key != projectpart.Id) { return(BadRequest()); } db.Entry(projectpart).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectPartExists(key)) { return(NotFound()); } else { throw; } } return(Updated(projectpart)); }
/// <summary> /// convert project part to rfq part view model /// </summary> /// <param name="part"></param> /// <returns></returns> public RfqPartViewModel ConvertToView(ProjectPart part) { RfqPartViewModel model = new RfqPartViewModel(); var _materialRepository = new MaterialRepository(); var material = _materialRepository.GetMaterial(part.MaterialId); model.ProjectPartId = part.ProjectPartId; model.PartId = part.PartId; model.PartNumber = (!string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A"; model.RevisionNumber = (!string.IsNullOrEmpty(part.RevisionNumber)) ? part.RevisionNumber : "N/A"; model.PartDescription = (!string.IsNullOrEmpty(part.Description)) ? part.Description : "N/A"; model.CustomerId = part.CustomerId; model.FoundryId = part.FoundryId; model.IsRaw = part.IsRaw; model.IsMachined = part.IsMachined; model.Weight = part.Weight; model.AnnualUsage = part.AnnualUsage; model.MaterialId = part.MaterialId; model.MaterialDescription = (material != null && !string.IsNullOrEmpty(material.Description)) ? material.Description : "N/A"; model.PartTypeId = part.PartTypeId; model.PartStatusId = part.PartStatusId; model.DestinationId = part.DestinationId; model.SurchargeId = part.SurchargeId; if (_materialRepository != null) { _materialRepository.Dispose(); _materialRepository = null; } return(model); }
public ProjectEdit() { InitializeComponent(); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "新建"; projectPartList = new ProjectPart(); }
/// <summary> /// convert quote part view model to project part /// </summary> /// <param name="model"></param> /// <returns></returns> public ProjectPart ConvertToDomain(QuotePartViewModel model) { ProjectPart projectPart = new ProjectPart(); projectPart.QuoteId = model.QuoteId; projectPart.ProjectPartId = model.ProjectPartId; projectPart.PartId = model.PartId; projectPart.Cost = model.Cost; projectPart.Price = model.Price; projectPart.Number = model.PartNumber; projectPart.Description = model.PartDescription; projectPart.CustomerId = model.CustomerId; projectPart.FoundryId = model.FoundryId; projectPart.IsRaw = projectPart.IsRaw; projectPart.IsMachined = projectPart.IsMachined; projectPart.RevisionNumber = model.RevisionNumber; projectPart.AnnualUsage = model.AnnualUsage; projectPart.Weight = model.Weight; projectPart.MaterialId = projectPart.MaterialId; projectPart.PatternCost = model.PatternCost; projectPart.PatternPrice = model.PatternPrice; projectPart.FixturePrice = model.FixturePrice; projectPart.FixtureCost = model.FixtureCost; projectPart.IsRaw = model.IsRaw; projectPart.IsMachined = model.IsMachined; return(projectPart); }
public IEnumerable <SuiteCRMProjectDetailViewModel> GetProjects(int pageNumber, int pageSize, bool basedOnSuiteCRMList) { IEnumerable <project> suiteCRMProjects = null; IEnumerable <SuiteCRMProjectPart> orchardCollaborationProjects = null; if (basedOnSuiteCRMList) { suiteCRMProjects = this.suiteCRMProjectService.GetProjects(pageNumber, pageSize); // TODO: it gets the list of all projects. Find a better way orchardCollaborationProjects = this.projectService.GetProjects(null).Where(c => c.Is <SuiteCRMProjectPart>()).Select(c => c.As <SuiteCRMProjectPart>()).ToList(); orchardCollaborationProjects = orchardCollaborationProjects.Where(c => suiteCRMProjects.Any(d => !string.IsNullOrEmpty(c.ExternalId) && d.id.ToLower() == c.ExternalId.ToLower())).ToList(); } else { var pager = new Pager(this.services.WorkContext.CurrentSite, pageNumber + 1, pageSize); orchardCollaborationProjects = this.projectService.GetProjects(pager).Where(c => c.Is <SuiteCRMProjectPart>()).Select(c => c.As <SuiteCRMProjectPart>()).ToList(); var suiteCRMIds = orchardCollaborationProjects.Select(c => c.ExternalId).ToArray(); suiteCRMProjects = this.suiteCRMProjectService.GetProjects(suiteCRMIds); } List <SuiteCRMProjectDetailViewModel> returnValue = new List <SuiteCRMProjectDetailViewModel>(); foreach (var project in orchardCollaborationProjects.OrderByDescending(c => c.As <CommonPart>().ModifiedUtc)) { SuiteCRMProjectDetailViewModel projectModel = new SuiteCRMProjectDetailViewModel(); projectModel.OrchardCollaborationProject = project.ContentItem; projectModel.LastSyncTime = project.LastSyncTime; ProjectPart projectPart = project.As <ProjectPart>(); if (projectPart != null) { projectModel.OrchardCollaborationTitle = projectPart.Title; } if (!string.IsNullOrEmpty(project.ExternalId)) { var suiteCRMPRoject = suiteCRMProjects.FirstOrDefault(c => c.id.ToLower() == project.ExternalId.ToLower()); if (suiteCRMPRoject != null) { projectModel.IsSync = true; projectModel.SuiteCRMProject = this.Convert(suiteCRMPRoject); } } returnValue.Add(projectModel); } foreach (var suiteCRMProject in suiteCRMProjects.Where(c => !returnValue.Any(d => d.SuiteCRMProject != null && d.SuiteCRMProject.Id == c.id))) { SuiteCRMProjectDetailViewModel projectModel = new SuiteCRMProjectDetailViewModel(); projectModel.SuiteCRMProject = this.Convert(suiteCRMProject); returnValue.Add(projectModel); } return(returnValue); }
public ProjectEdit(ProjectPart part) { InitializeComponent(); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "编辑"; projectPartList = part; MadeEdit(); }
public void T_projectPart() { Uri uri = new Uri(TestConfig.serviceUrl); var context = new DamServiceRef.Container(uri); context.Format.UseJson(); var itemList = context.ProjectParts.ToList(); int cnt1 = context.ProjectParts.Count(); var root = context.ProjectParts.Where(s => s.ParentPart == null).SingleOrDefault(); var newItem = new ProjectPart(); newItem.Id = Guid.NewGuid(); newItem.PartName = "测试部位"; newItem.ParentPart = root.Id; context.AddToProjectParts(newItem); context.SaveChanges(); int cnt2 = context.ProjectParts.Count(); Assert.IsTrue(cnt1 + 1 == cnt2, "插入 失败"); //在单独查询 context.Detach(newItem); var itemInDb = context.ProjectParts.Where(s => s.Id == newItem.Id).SingleOrDefault(); Assert.AreEqual(itemInDb.Id, newItem.Id, "插入失败"); //更新 itemInDb.PartName = newItem.PartName + "modify"; context.UpdateObject(itemInDb); context.SaveChanges(); context.Detach(itemInDb); var itemUpdated = context.ProjectParts.Where(s => s.Id == itemInDb.Id).SingleOrDefault(); Assert.AreEqual(itemUpdated.PartName, itemInDb.PartName, "更新失败"); //删除 context.DeleteObject(itemUpdated); context.SaveChanges(); int fCnt = context.ProjectParts.Count(); Assert.IsTrue(cnt1 == fCnt, "删除 失败"); }
public void CreateProjectDependencies(ProjectPart project) { var contentManager = this.services.ContentManager; // Create project tickets this.CreateProjectionForProjectAttachableItems(project, ContentTypes.ProjectTicketsContentType, QueryNames.ProjectTicketsQueryName, "Tickets", ContentTypes.TicketContentType); // Create project discussions this.CreateProjectionForProjectAttachableItems(project, ContentTypes.ProjectProjectionContentType, QueryNames.ProjectDiscussionsQueryName, "Discussions", ContentTypes.DiscussionContentType); // Create wiki var wiki = this.CreateAttachableItemToProject(project, ContentTypes.ProjectWikiContentType); var wikiActivityStreamPart = wiki.As <ActivityStreamPart>(); var wikiActivityStreamQuery = this.GetQuery(QueryNames.WikiActivityStreamQueryName); if (wikiActivityStreamQuery != null) { wikiActivityStreamPart.QueryId = wikiActivityStreamQuery.Record.Id; } contentManager.Publish(wiki); // Create wiki Root var wikiRoot = this.CreateAttachableItemToProject(project, ContentTypes.RootWikiContentType); contentManager.Publish(wikiRoot); // Create project detail var projectDetail = this.CreateAttachableItemToProject(project, ContentTypes.ProjectDetailContentType); project.Record.Detail = projectDetail.Record; var projectDetailContainerPart = projectDetail.As <ContainerPart>(); projectDetailContainerPart.Record.AdminListViewName = "DefaultListView"; // prevent original ContainerPart to render items projectDetailContainerPart.Record.ItemsShown = false; contentManager.Publish(projectDetail); // Create project activityStream var projectActivityStream = this.CreateAttachableItemToProject(project, ContentTypes.ProjectActivityStreamType); projectActivityStream.As <TitlePart>().Title = "Activity Stream"; var activityStreamPart = projectActivityStream.As <ActivityStreamPart>(); var activityStreamQuery = this.GetProjectActivityStreamQueryPart(); if (activityStreamQuery != null) { activityStreamPart.QueryId = activityStreamQuery.Record.Id; } contentManager.Publish(projectActivityStream); this.CreateMilestoneAndBacklogForProject(project); this.CreateProjectMenu(project); }
/// <summary> /// convert project part to part price /// </summary> /// <param name="projectPart"></param> /// <returns></returns> public IV00108_Part_Price ConvertToCreatePrice(ProjectPart projectPart) { IV00108_Part_Price part = new IV00108_Part_Price(); part.ITEMNMBR = projectPart.Number; part.PRCLEVEL = "STANDARD"; part.UOFM = "part"; return(part); }
/// <summary> /// convert project part to part currency /// </summary> /// <param name="projectPart"></param> /// <returns></returns> public IV00105_Part_Currency ConvertToCreateCurrency(ProjectPart projectPart) { IV00105_Part_Currency part = new IV00105_Part_Currency(); part.ITEMNMBR = projectPart.Number; part.CURNCYID = string.Empty; part.LISTPRCE = projectPart.Price; return(part); }
/// <summary> /// convert project part to vendor master /// </summary> /// <param name="projectPart"></param> /// <returns></returns> public IV00103_Part_Vendor_Master ConvertToCreateVendor(ProjectPart projectPart) { IV00103_Part_Vendor_Master part = new IV00103_Part_Vendor_Master(); part.ITEMNMBR = projectPart.Number; part.VENDORID = projectPart.FoundryId; part.VNDITNUM = projectPart.Number; return(part); }
/// <summary> /// convert project part to price sheet part cost view model /// </summary> /// <param name="part"></param> /// <returns></returns> public PriceSheetPartViewModel ConvertToCostView(ProjectPart part) { PriceSheetPartViewModel model = new PriceSheetPartViewModel(); model.AnnualUsage = Decimal.ToInt32(part.AnnualUsage); model.PartNumber = part.Number; model.Weight = part.Weight; model.ProjectPartId = part.ProjectPartId; return(model); }
/// <summary> /// convert projectPart to part price option /// </summary> /// <param name="projectPart"></param> /// <returns></returns> public IV00107_Part_Price_Option ConvertToCreatePriceOption(ProjectPart projectPart) { IV00107_Part_Price_Option part = new IV00107_Part_Price_Option(); part.ITEMNMBR = projectPart.Number; part.PRCLEVEL = "STANDARD"; part.UOFM = "part"; part.CURNCYID = string.Empty; return(part); }
public void Copy(ProjectPart source, project destination) { destination.name = source.Record.Title.Length > 50 ? source.Record.Title.Substring(0, 50) : source.Record.Title; destination.description = source.Record.Description; CommonPart commonPart = source.As <CommonPart>(); if (commonPart != null && commonPart.ModifiedUtc.HasValue) { destination.date_modified = commonPart.ModifiedUtc; } }
private void btnDel_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection rowCollection = this.dataGridView1.SelectedRows; foreach (DataGridViewRow row in rowCollection) { ProjectPart part = (ProjectPart)row.Tag; projData.Remove(part); this.dataGridView1.Rows.Remove(row); } OnCheckChanged(EventArgs.Empty); }
private ContentItem CreateAttachableItemToProject(ProjectPart project, string contentType) { var contentManager = this.services.ContentManager; var contentItem = contentManager.New(contentType); contentManager.Create(contentItem); var attachToProjectPart = contentItem.As <AttachToProjectPart>(); attachToProjectPart.Record.Project = project.Record; return(contentItem); }
// DELETE odata/ProjectParts(5) public async Task <IHttpActionResult> Delete([FromODataUri] Guid key) { ProjectPart projectpart = await db.ProjectParts.FindAsync(key); if (projectpart == null) { return(NotFound()); } db.ProjectParts.Remove(projectpart); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
private ContentItem CreateProjectionForProjectAttachableItems(ProjectPart project, string contentType, string queryName, string title, string itemContentType) { // get query var query = this.GetQuery(queryName); if (query != null) { var contentItem = this.CreateAttachableItemToProject(project, contentType); // projection var projection = contentItem.As <ProjectionWithDynamicSortPart>(); projection.Record.QueryPartRecord = query.Record; projection.Record.ItemsPerPage = 20; // layout var layout = this.layoutRepository.Table.FirstOrDefault(c => c.QueryPartRecord.Id == query.Id && c.Category == "Html" && c.Type == "Shape"); if (layout != null) { projection.Record.LayoutRecord = layout; } // Title TitlePart titlePart = contentItem.As <TitlePart>(); titlePart.Title = title; // item type var projectProjectionPart = contentItem.Parts.FirstOrDefault(c => c.PartDefinition.Name == ContentTypes.ProjectProjectionContentType); if (projectProjectionPart != null) { var field = projectProjectionPart.Fields.FirstOrDefault(c => c.Name == FieldNames.ProjectProjectionItemTypeFieldName); if (field != null) { ((InputField)field).Value = itemContentType; } var displayField = projectProjectionPart.Fields.FirstOrDefault(c => c.Name == FieldNames.ProjectProjectionItemTypeDisplayFieldName); if (displayField != null) { var contentTypeDefinition = this.services.ContentManager.GetContentTypeDefinitions().FirstOrDefault(c => c.Name == itemContentType); ((InputField)displayField).Value = contentTypeDefinition.DisplayName; } } this.services.ContentManager.Publish(contentItem); return(contentItem); } return(null); }
/// <summary> /// convert project part to part master /// </summary> /// <param name="projectPart"></param> /// <returns></returns> public IV00101_Part_Master ConvertToCreateMaster(ProjectPart projectPart) { IV00101_Part_Master part = new IV00101_Part_Master(); part.ITEMNMBR = projectPart.Number; part.ITEMDESC = projectPart.Description; part.ITEMSHWT = Convert.ToInt32(projectPart.Weight * 100.00m); part.STNDCOST = projectPart.Cost; part.LOCNCODE = projectPart.SiteId; part.ITMCLSCD = "STANDARD"; part.PRICMTHD = 2; part.INACTIVE = 0; return(part); }
public async Task <ActionResult <ProjectPart> > PostProjectPart(ProjectPart projectPart) { if (DoesUserOwnProject(projectPart.ProjectID)) { _context.ProjectPart.Add(projectPart); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProjectPart", new { id = projectPart.ProjectPartID }, projectPart)); } else { //todo use proper response return(null); } }
/// <summary> /// get project part by part number /// </summary> /// <param name="partNumber"></param> /// <returns></returns> public ProjectPart GetProjectPart(string partNumber) { var projectPart = new ProjectPart(); try { projectPart = _db.ProjectPart.FirstOrDefault(x => x.Number.Replace(" ", string.Empty).ToLower() == partNumber.Replace(" ", string.Empty).ToLower()); } catch (Exception ex) { logger.ErrorFormat("An error occurred while getting project part. {0}", ex.ToString()); } return(projectPart); }
/// <summary> /// get project part by id /// </summary> /// <param name="projectPartId"></param> /// <returns></returns> public ProjectPart GetProjectPart(Guid projectPartId) { var part = new ProjectPart(); try { part = _db.ProjectPart.FirstOrDefault(x => x.ProjectPartId == projectPartId); } catch (Exception ex) { logger.ErrorFormat("An error occurred while getting project part. {0}", ex.ToString()); } return(part); }
/// <summary> /// Pdf 合并 /// </summary> /// <param name="filePath">输出文件路径</param> /// <param name="filePathArry">合并文件路径集合</param> public void MergerPdf(string filePath, IList <string> filePathArry) { Stream output = new FileStream(filePath, FileMode.Create, FileAccess.Write); PdfSplitterMerger psm = new PdfSplitterMerger(output); Project project = new Project(); foreach (var item in filePathArry) { ProjectPart pp = new ProjectPart(); pp.Load(item); project.Parts.Add(pp); psm.Add(File.OpenRead(pp.path), pp.Pages); } psm.Finish(); }