public IActionResult AddNewBaseMaterial([FromBody] BaseMaterials newBaseMaterial) { DynamoDBContext aws_Context = new DynamoDBContext(client); if (newBaseMaterial == null) { return(BadRequest()); } else { try { BaseMaterials BaseMaterial = new BaseMaterials { Id = newBaseMaterial.Id, Name = newBaseMaterial.Name, Status = newBaseMaterial.Status }; aws_Context.SaveAsync(BaseMaterial); _context.BaseMaterial.Add(newBaseMaterial); _context.SaveChanges(); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } } return(CreatedAtRoute("GetHouseKeeper", new { id = newBaseMaterial.Id }, newBaseMaterial)); }
public void Start(BaseMaterials bm) { this.bm = bm; numericUpDown2.Value = bm.itemMaxAmount; numericUpDown1.Value = bm.itemStackSize; Show(); }
private void button6_Click(object sender, EventArgs e) { if (!textBox1.Text.Equals("")) { BaseMaterials bm = new BaseMaterials(true); bm.itemName = textBox1.Text; MapBuilder.gcDB.gameItems.Add(bm); reloadLB1(); } }
public async Task <IEnumerable <BaseMaterials> > GetAllBaseMaterials() { AwsAccessHelper awsAccessHelper = new AwsAccessHelper(configuration); var awsDb = awsAccessHelper.AwsConnecttion(); var request = new ScanRequest { TableName = tableName, Limit = 1, }; var allBaseMaterials = new List <BaseMaterials>(); ScanResponse response = null; try { do { if (response != null) { request.ExclusiveStartKey = response.LastEvaluatedKey; } response = await awsDb.ScanAsync(request); foreach (var item in response.Items) { var BaseMaterials = new BaseMaterials { Id = Convert.ToInt32(item["Id"].N), Name = item["Name"].S, Status = Convert.ToInt16(item["Status"].N) }; allBaseMaterials.Add(BaseMaterials); } } while (response.LastEvaluatedKey != null && response.LastEvaluatedKey.Count > 0); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } _context.BaseMaterial.ToList(); _context.BaseMaterial.ToList(); return(allBaseMaterials); }
void SetSpirit(int index = 0, Images image = Images.SpiritImage, Texts name = Texts.SpiritName, InfoIcons icon = InfoIcons.SpiritInfoIcon, Objects iconObject = Objects.SpiritInfoIcon) { BaseMaterials myMaterial = GameManager.Data.CurrentBaseMaterials.Count > index ? GameManager.Data.CurrentBaseMaterials[index] : null; if (myMaterial == null) { if (index == 0) { Get <GameObject>((int)Objects.SpiritErrorText).SetActive(true); GetButton((int)Buttons.DoButton).interactable = false; } return; } GetImage((int)image).sprite = myMaterial.image; GetText((int)name).text = myMaterial.Name; Get <GameObject>((int)iconObject).SetActive(true); Get <MaterialInfoIcon>((int)icon).myMaterial = myMaterial; }
/// <summary> /// Saves the specified stream. /// </summary> /// <param name="stream">The stream.</param> /// <param name="solids">The solids.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> internal static bool SaveModel(Stream stream, IList <TessellatedSolid> solids) { var objects = new List <Object>(); var baseMats = new BaseMaterials { id = 1 }; for (var i = 0; i < solids.Count; i++) { var solid = solids[i]; var thisObject = new Object { name = solid.Name, id = i + 2 }; // this is "+ 2" since the id's start with 1 instead of 0 plus BaseMaterials is typically 1, so start at 2. var triangles = new List <Triangle>(); foreach (var face in solid.Faces) { var colString = (face.Color ?? solid.SolidColor ?? new Color(Constants.DefaultColor)).ToString(); var colorIndex = baseMats.bases.FindIndex(col => col.colorString.Equals(colString)); if (colorIndex == -1) { colorIndex = baseMats.bases.Count; baseMats.bases.Add(new Base { colorString = colString }); } triangles.Add(new Triangle { v1 = face.Vertices[0].IndexInList, v2 = face.Vertices[1].IndexInList, v3 = face.Vertices[2].IndexInList, pid = 1, p1 = colorIndex }); } thisObject.mesh = new Mesh { vertices = solid.Vertices.Select(v => new threemfclasses.Vertex { x = v.X, y = v.Y, z = v.Z }).ToList(), triangles = triangles }; objects.Add(thisObject); } var metaData = new List <Metadata>(); var allRawComments = solids.SelectMany(s => s.Comments); var comments = new List <string>(); foreach (var comment in allRawComments.Where(string.IsNullOrWhiteSpace)) { var arrowIndex = comment.IndexOf("==>"); if (arrowIndex == -1) { comments.Add(comment); } else { var endOfType = arrowIndex - 1; var beginOfValue = arrowIndex + 3; //todo: check this -1 and +3 metaData.Add(new Metadata { type = comment.Substring(0, endOfType), Value = comment.Substring(beginOfValue) }); } } var threeMFData = new ThreeMFFileData { Units = solids[0].Units, Name = solids[0].Name.Split('_')[0], Language = solids[0].Language, metadata = metaData, build = new Build { Items = objects.Select(o => new Item { objectid = o.id }).ToList() }, resources = new Resources { basematerials = new[] { baseMats }.ToList(), //colors = colors, materials = materials, objects = objects } }; threeMFData.Comments.AddRange(comments); try { using (var writer = XmlWriter.Create(stream)) { writer.WriteComment(tvglDateMarkText); if (!string.IsNullOrWhiteSpace(solids[0].FileName)) { writer.WriteComment("Originally loaded from " + solids[0].FileName); } var serializer = new XmlSerializer(typeof(ThreeMFFileData), defXMLNameSpaceModel); serializer.Serialize(writer, threeMFData); } Message.output("Successfully wrote 3MF file to stream.", 3); return(true); } catch (Exception exception) { Message.output("Unable to write in model file.", 1); Message.output("Exception: " + exception.Message, 3); return(false); } }
public void AddBase(BaseMaterials material) { BaseIDList.Add(material.Id); AddTag(material.Tags); }
protected void AddBase(BaseMaterials material) { BaseIDList.Add(material.Id); AddTag(material.Tags); }