public async Task <IActionResult> PutPartProperty([FromRoute] int id, [FromBody] PartProperty partProperty) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != partProperty.Id) { return(BadRequest()); } _context.Entry(partProperty).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PartPropertyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> DeleteConfirmed(string id) { PartProperty partProperty = await db.PartProperties.FindAsync(id); db.PartProperties.Remove(partProperty); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "PartID,PropertyName,IsPropertyConfigurable,PropertyValue")] PartProperty partProperty) { if (ModelState.IsValid) { db.Entry(partProperty).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(partProperty)); }
public async Task <IActionResult> PostPartProperty([FromBody] PartProperty partProperty) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PartProperty.Add(partProperty); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPartProperty", new { id = partProperty.Id }, partProperty)); }
// GET: VariableExpressions/Create public ActionResult Create() { PartProperty property = (PartProperty)Session["Property"]; var parents = db.PartStructures.Where(v => v.ChildID == property.PartID).Select(c => c.PartID).ToList(); foreach (var parent in parents) { IEnumerable <int> IntList = (db.ConfigurableAssemblyVariables.Where(c => c.PartID == parent).Select(b => b.ID).ToList()); ViewBag.Variables = new SelectList(IntList); } return(View()); }
// GET: PartProperties/Edit/5 public async Task <ActionResult> Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PartProperty partProperty = await db.PartProperties.FindAsync(id); if (partProperty == null) { return(HttpNotFound()); } return(View(partProperty)); }
public async Task <ActionResult> Create([Bind(Include = "Id,VariableId,Devisor,Constant,PropertyId")] VariableExpression variableExpression) { PartProperty property = (PartProperty)Session["Property"]; variableExpression.PropertyId = property.ID; if (ModelState.IsValid) { db.VariableExpressions.Add(variableExpression); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(variableExpression)); }
static PartProperty getPartData(string index, int fileid, string filetype) { PartProperty part = new PartProperty(); part.Add("filesize", "10000"); part.Add("filepath", path); part.Add("filename", index + "." + filetype.ToLower()); part.Add("fileid", fileid + ""); part.Add("filetype", filetype.ToUpper()); part.Add("partname", "partname" + index); part.Add("partNumber", "partNumber" + index); part.Add("DrawNo", "DrawNo" + index); return(part); }
/// <summary> /// Insert Update the material overview /// </summary> /// <param name="viewModel"></param> /// <returns></returns> public IResult ManageMaterialPartProperties(PartPropertyViewModel viewModel) { var result = new Result { Status = Status.Success }; try { if (string.IsNullOrEmpty(viewModel.PartPropertyId) || viewModel.PartPropertyId == null) { viewModel.PartPropertyId = null; var partProperty = new PartProperty(); partProperty.MapFromViewModel(viewModel, (ClaimsIdentity)_principal.Identity); partProperty.PartPropertyId = ObjectId.GenerateNewId(); var updateDefinition = Builders <Material> .Update.Set(x => x.ModifiedDate, GenericHelper.CurrentDate).AddToSet(t => t.PartProperties, partProperty); _materialRepository.UpdateOne(t => t.MaterialId.Equals(ObjectId.Parse(viewModel.RegardingId)), updateDefinition); result.Body = partProperty; result.Message = MaterialNotification.OverviewCreated; result.Operation = Operation.Create; } else { var updateDefinition = Builders <Material> .Update.Set(x => x.ModifiedDate, GenericHelper.CurrentDate).Set(t => t.PartProperties[-1].PropertyName, viewModel.PropertyName). Set(t => t.PartProperties[-1].PropertyValue, viewModel.PropertyValue); _materialRepository.UpdateOne( t => t.MaterialId.Equals(ObjectId.Parse(viewModel.RegardingId)) && t.PartProperties.Any(o => o.PartPropertyId.Equals(ObjectId.Parse(viewModel.PartPropertyId))), updateDefinition); result.Body = viewModel; result.Message = MaterialNotification.OverviewUpdated; result.Operation = Operation.Update; } } catch (Exception e) { result.Message = e.Message; result.Status = Status.Fail; } return(result); }
public async Task <ActionResult> Create([Bind(Include = "PartID,PropertyName,IsPropertyConfigurable,PropertyValue")] PartProperty partProperty) { if (ModelState.IsValid) { if (partProperty.IsPropertyConfigurable == true) { Session["Property"] = partProperty; db.PartProperties.Add(partProperty); await db.SaveChangesAsync(); return(RedirectToAction("Create", "VariableExpressions")); } db.PartProperties.Add(partProperty); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(partProperty)); }
public async Task <PropertyValue> AssignPropertyValue(PartProperty property) { var order = (Order)Session["Order"]; var variables = (List <ConfigurableAssemblyVariable>)Session["Variables"]; var variableValues = (List <VariableValue>)Session["VariableValues"]; var value = new PropertyValue(); if (property.IsPropertyConfigurable == false) { value.ExpressionResult = property.PropertyValue; value.PropertyId = property.ID; value.OrderId = order.Id; return(value); } var expression = await GetVariableExpression(property.ID); var variableValue = variableValues.Where(v => v.ConfigurableAssemblyVariableId == expression.VariableId).Select(c => c).First(); value.ExpressionResult = (SolveVariableExpression(expression, variableValue)).ToString(); value.PropertyId = property.ID; value.OrderId = order.Id; return(value); }
set => SetValue(PartProperty, value);
private static int AddPartToProject(PipingProject prjpart, string strSpec, ObjectId partId, PartRep.SpecPart specPart) { Autodesk.ProcessPower.DataObjects.PnPDatabase db = prjpart.DataLinksManager.GetPnPDatabase(); PartsRepository rep = PartsRepository.AttachedRepository(db, false); // Create new part in project Autodesk.ProcessPower.PartsRepository.Part part = rep.NewPart(specPart.PartType); rep.AutoAccept = false; // Assign property values in project StringCollection props = specPart.PropertyNames; for (int i = 0; i < props.Count; ++i) { PartProperty prop = rep.GetPartProperty(specPart.PartType, props[i], false); if (prop == null || prop.IsExpression) { continue; // can't be assigned } try { part[props[i]] = specPart[props[i]]; } catch (Autodesk.AutoCAD.Runtime.Exception ex) { // display exception on the command line Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(ex.ToString()); } } // assign special spec property // try { part["Spec"] = strSpec; } catch (Autodesk.AutoCAD.Runtime.Exception ex) { // display exception on the command line Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(ex.ToString()); } // add reference to spec record only if it is not set yet // try { if (part["SpecRecordId"] == System.DBNull.Value) { part["SpecRecordId"] = specPart.PartId; } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { // display exception on the command line Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(ex.ToString()); } // Ok now deal with the ports // Autodesk.ProcessPower.PartsRepository.PortCollection ports = specPart.Ports; Autodesk.ProcessPower.PartsRepository.Port principal_port = ports[0]; foreach (Autodesk.ProcessPower.PartsRepository.Port port in ports) { System.Guid sizeRecId = System.Guid.Empty; if (string.Compare(port.Name, principal_port.Name) != 0) { sizeRecId = (System.Guid)port["SizeRecordId"]; } Autodesk.ProcessPower.PartsRepository.Port newPort = null; bool bNew = true; bool bNeedAccept = false; // Principal port is embedded. // if (sizeRecId != System.Guid.Empty) { newPort = part.NewPortBySizeRecordId(port.Name, sizeRecId.ToString(), out bNew); bNeedAccept = true; } else { newPort = part.NewPort(port.Name); } if (bNew) { foreach (string prop in port.PropertyNames) { if (string.Compare(prop, "PortName", true) == 0) { continue; // dont copy port name } try { newPort[prop] = port[prop]; } catch (Autodesk.AutoCAD.Runtime.Exception ex) { // display exception on the command line Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(ex.ToString()); } } if (bNeedAccept) { try { rep.CommitPort(newPort); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { // display exception on the command line Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(ex.ToString()); } } } part.Ports.Add(newPort); } // Add new part to the project database rep.AddPart(part); // Transform properties sentitive to current project's unit settings switch (prjpart.ProjectUnitsType) { case ProjectUnitsType.eMetric: part.TransformPropertiesToUnits(Units.Mm, Units.Mm); break; case ProjectUnitsType.eMixedMetric: part.TransformPropertiesToUnits(Units.Mm, Units.Inch); break; case ProjectUnitsType.eImperial: part.TransformPropertiesToUnits(Units.Inch, Units.Inch); break; } int cacheId = part.PartId; // Finally now we can link entity to row in project if (cacheId != -1) { Autodesk.ProcessPower.DataLinks.DataLinksManager dlm = prjpart.DataLinksManager; try { dlm.Link(partId, cacheId); } catch { cacheId = -1;; } } return(cacheId); // -1 for error }