public int RemovePropertyFromMaterial(int materialId, int sourceMaterialId, int sourceId, int subgroupId, int propertyId, int sourcePropertyId, int rowId) { ElsevierMaterials.Models.Domain.Export.Exporter exporter = GetExporter(); ElsevierMaterials.Models.Domain.Export.Material material = exporter.Materials.Where(m => m.MaterialInfo.MaterialId == materialId && m.MaterialInfo.SourceMaterialId == sourceMaterialId && m.MaterialInfo.SourceId == sourceId && m.MaterialInfo.SubgroupId == subgroupId).FirstOrDefault(); material.Properties.Remove(material.Properties.Where(m => m.ElsBasicInfo.TypeId == propertyId && m.ElsBasicInfo.SourceTypeId == sourcePropertyId && m.ElsBasicInfo.RowId == rowId).FirstOrDefault()); Material materialForDelete = null; foreach (var materialobj in exporter.Materials) { if (materialobj.Properties.Count == 0) { materialForDelete = materialobj; break; } } int materialRowId = -1; if (materialForDelete != null) { materialRowId = materialForDelete.MaterialInfo.RowId; exporter.Materials.Remove(materialForDelete); } System.Web.HttpContext.Current.Session["Exporter"] = exporter; return(materialRowId); }
public ActionResult ChangeMaterial(int rowId) { //TODO:-Progress indicator ChangeMaterial ElsevierMaterials.Models.Domain.Export.Exporter exporter = _binder.GetExporter(); ElsevierMaterials.Models.Domain.Export.Material material = exporter.Materials.Where(m => m.MaterialInfo.RowId == rowId).FirstOrDefault(); return(Json(ResponseStatus.Success, RenderPartialViewToString("MaterialProperties", material), JsonRequestBehavior.AllowGet)); }
public ActionResult RemovePropertyFromMaterial(int materialId, int sourceMaterialId, int sourceId, int subgroupId, int propertyId, int sourcePropertyId, int rowId) { //TODO:-na Layout home napravi partial views za popupove koje pozivas int materialRowIdForDeleting = _binder.RemovePropertyFromMaterial(materialId, sourceMaterialId, sourceId, subgroupId, propertyId, sourcePropertyId, rowId); ElsevierMaterials.Models.Domain.Export.Exporter exporter = _binder.GetExporter(); ElsevierMaterials.Models.Domain.Export.Material material = exporter.Materials.Where(m => m.MaterialInfo.MaterialId == materialId && m.MaterialInfo.SourceMaterialId == sourceMaterialId && m.MaterialInfo.SourceId == sourceId && m.MaterialInfo.SubgroupId == subgroupId).FirstOrDefault(); return(Json(ResponseStatus.Success, new { hasMaterialsAdded = exporter.Materials.Count > 0 ? true: false, materialRowIdForDeleting = materialRowIdForDeleting, data = RenderPartialViewToString("MaterialProperties", material) }, JsonRequestBehavior.AllowGet)); }
private MemoryStream AddMaterialToZip(string[] typesString, ElsevierMaterials.Models.Domain.Export.Material material, ElsevierMaterials.Models.Domain.Export.Exporter exporter) { MemoryStream msMaterial = new MemoryStream(); msMaterial.Seek(0, SeekOrigin.Begin); using (ZipFile zip = new ZipFile()) { foreach (var item in typesString) { IList <ElsevierMaterials.Models.Domain.Export.Property> properties = material.Properties; ExportTypeEnum exportType = (ExportTypeEnum)int.Parse(item); bool hasAtLeatsOnePropertyForExport = false; ExportType ep = exporter.ExportTypes.Where(m => m.ExportTypeId == exportType).FirstOrDefault(); IList <TMPropertyTypeEnum> propertiesForSelectedExport = ep.Properties; foreach (var prop in material.Properties) { int notMappedPropertyId = prop.ElsBasicInfo.SourceTypeId != 0 ? prop.ElsBasicInfo.SourceTypeId : prop.ElsBasicInfo.TypeId; TMPropertyTypeEnum propertyId = MapElsPropertyId(notMappedPropertyId, (SourceTypeEnum)material.MaterialInfo.SourceId); if (propertiesForSelectedExport.Contains(propertyId)) { hasAtLeatsOnePropertyForExport = true; break; } } if (hasAtLeatsOnePropertyForExport) { MemoryStream mz = getZipStream(int.Parse(item), properties, material); mz.Seek(0, SeekOrigin.Begin); if (exportType == ExportTypeEnum.Esi) { zip.AddEntry("ESI ProCAST.zip", mz); } else if (exportType == ExportTypeEnum.Siemens) { zip.AddEntry("Siemens NX.zip", mz); } else { zip.AddEntry(exportType + ".zip", mz); } } } zip.Save(msMaterial); } return(msMaterial); }
public MemoryStream ExportData(string[] types, int[] materials, ElsevierMaterials.Models.Domain.Export.Exporter exporter) { MemoryStream zipStream = new MemoryStream(); zipStream.Seek(0, SeekOrigin.Begin); using (ZipFile zip = new ZipFile()) { bool atLeastOneMaterialHasProperties = false; foreach (var rowId in materials) { ElsevierMaterials.Models.Domain.Export.Material material = exporter.Materials.Where(m => m.MaterialInfo.RowId == rowId).FirstOrDefault(); bool materialContainsPropertiesForExport = false; foreach (var prop in material.Properties) { int notMappedPropertyId = prop.ElsBasicInfo.SourceTypeId != 0 ? prop.ElsBasicInfo.SourceTypeId : prop.ElsBasicInfo.TypeId; TMPropertyTypeEnum propertyId = MapElsPropertyId(notMappedPropertyId, (SourceTypeEnum)material.MaterialInfo.SourceId); if (exporter.Properties.Contains(propertyId)) { materialContainsPropertiesForExport = true; atLeastOneMaterialHasProperties = true; break; } } if (materialContainsPropertiesForExport) { MemoryStream mz = AddMaterialToZip(types, material, exporter); mz.Seek(0, SeekOrigin.Begin); zip.AddEntry(material.MaterialInfo.Name.Replace("/", "") + "_" + material.MaterialInfo.RowId + ".zip", mz); } } if (atLeastOneMaterialHasProperties) { zip.Save(zipStream); } } return(zipStream); }
public MemoryStream GetAbaqusZipStream(ElsevierMaterials.Models.Domain.Export.Material material, IList <ElsevierMaterials.Models.Domain.Export.Property> properties) { string inp = Abaqus.FillAbaqus(MapProperites(properties, material.MaterialInfo.SourceId), material.MaterialInfo.Name); MemoryStream memoryStreamAbaqus = new MemoryStream(); TextWriter twAbaqus = new StreamWriter(memoryStreamAbaqus); twAbaqus.Write(System.Text.ASCIIEncoding.ASCII.GetString(Encoding.ASCII.GetBytes(inp))); twAbaqus.Flush(); MemoryStream zipStreamAbaqus = new MemoryStream(); using (ZipFile zip = new ZipFile()) { memoryStreamAbaqus.Seek(0, SeekOrigin.Begin); //zip.AddEntry("Abaqus_" + material.MaterialInfo.Name.Replace(" ", "_") + "_" + material.MaterialInfo.Standard.Replace(" ", "_") + ".inp", memoryStreamAbaqus); zip.AddEntry("Abaqus_" + material.MaterialInfo.Name.Replace(" ", "_").Replace("/", "") + ".inp", memoryStreamAbaqus); zip.Save(zipStreamAbaqus); } return(zipStreamAbaqus); }
public ElsevierMaterials.Models.Domain.Export.Property AddProperty(int sourceMaterialId, int sourceId, int subgroupId, ElsevierMaterials.Models.Domain.Export.Material material, ElsevierMaterials.Models.Domain.Export.Property property, IMaterialsContextUow materialContextUow, PropertyFilter propertyClient, ElsevierMaterials.Models.Condition condition) { if (property == null) { property = new ElsevierMaterials.Models.Domain.Export.Property(); PropertyBasicInfo propertyInfo = _propertyBinder.FillPropertyBasicData(materialContextUow, propertyClient, null); property.ElsBasicInfo = propertyInfo; property.ElsBasicInfo.Name = _propertyBinder.FillPropertyName(sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); property.ElsBasicInfo.Unit = _propertyBinder.FillPropertyUnit(sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); material.Properties.Add(property); } property.Value = _propertyBinder.FillPropertyValue(material.MaterialInfo.MaterialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); property.Temperature = _propertyBinder.FillPropertyTemperature(material.MaterialInfo.MaterialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); return(property); }
//TODO:-Ovde je mogao da se iskoristi factoyPatern koji bi vracao u memory stream u zavisnosti od tipa public MemoryStream getZipStream(int type, IList <ElsevierMaterials.Models.Domain.Export.Property> properties, ElsevierMaterials.Models.Domain.Export.Material material) { switch ((ExportTypeEnum)type) { case ExportTypeEnum.Radioss: return(getRadiosZipStream(material, properties)); case ExportTypeEnum.Abaqus: return(GetAbaqusZipStream(material, properties)); case ExportTypeEnum.SolidWorks: return(GetSolidWorksZipStream(material, properties)); case ExportTypeEnum.SolidEdge: return(GetSolidEdgeZipStream(material, properties)); case ExportTypeEnum.Esi: return(GetESIZipStream(material, properties)); case ExportTypeEnum.ESIPamCrash: return(GetEsiPamCrashZipStream(material, properties)); case ExportTypeEnum.ANSYS: return(GetANSYSZipStream(material, properties)); case ExportTypeEnum.Siemens: return(GetSiemensZipStream(material, properties)); case ExportTypeEnum.LsDyna: return(GetLsDynaZipStream(material, properties)); case ExportTypeEnum.FEMAP: return(GetFEMAPZipStream(material, properties)); case ExportTypeEnum.NASTRAN: return(GetNastranZipStream(material, properties)); case ExportTypeEnum.Excel: return(GetKTMXlsZipStream(material, properties)); case ExportTypeEnum.KTMXml: return(GetKTMXmlZipStream(material, properties)); case ExportTypeEnum.PTCCreo: return(GetPTCCreoZipStream(material, properties)); case ExportTypeEnum.AutodeskNastran: return(GetAutodeskNastranZipStream(material, properties)); default: break; } return(null); }