public static void CreateItemDescriptionNode(ItemDescriptionWrapper objWrap) { Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod()); Logger.WriteObjectToLogFile <ItemDescription>(objWrap.objItem); ItemDescription objItem = objWrap.objItem; Brand objBrand = objWrap.objBrand; var result = Neo4jController.m_graphClient.Cypher .Match("(A:" + objBrand.getLabel() + " { id: { brandid }})") .Create("(B:" + objItem.getLabel() + "{ objItem })") .Merge("(A)-[:" + Rel_Brand.brand_item + "]->(B)") .WithParams(new { brandid = objBrand.id, objItem = objItem }) .Return((B) => new { NodeCount = B.Count() }) .Results .Single(); if (result.NodeCount == 1) { Logger.WriteToLogFile("Successfully created Item"); } else { Logger.WriteToLogFile("unable to create Item"); } }
public static void AddItemDescription(string sheetName) { Logger.WriteToLogFile(Utilities.GetCurrentMethod()); Excel.Worksheet sheet = ExcelController.GetWorkSheet(sheetName); Excel.Range usedRange = sheet.UsedRange; ItemDescriptionWrapper objWrap = new ItemDescriptionWrapper(); //Do not consider row 1 as its the header for (int Row = 2; Row <= usedRange.Rows.Count; Row++) { Brand objBrand = new Brand(); Category objCategory = new Category(); SubCategory objSubCategory = new SubCategory(); ItemDescription objItem = null; for (int Col = 1; Col <= usedRange.Columns.Count; Col++) { string name = (string)(usedRange.Cells[1, Col] as Excel.Range).Value2; name = name.Trim(); string value = null; if ((usedRange.Cells[Row, Col] as Excel.Range).Value2 != null) { value = (usedRange.Cells[Row, Col] as Excel.Range).Value2.ToString(); } else { continue; } switch (name) { case ExcelSheets.EXCELSHEET_CATEGORY: objCategory.Name = value; continue; break; case ExcelSheets.EXCELSHEET_BRAND: objBrand.Name = value; continue; break; case ExcelSheets.EXCELSHEET_SUBCATEGORY: objSubCategory.Name = value; objItem = ItemFactory.GetItem(objSubCategory); continue; break; default: break; } ExcelUtilities.PopulateStructure <ItemDescription>(name, value, ref objItem); } //Add the country in the Neo4j Database objWrap.objBrand = objBrand; objWrap.objCategory = objCategory; objWrap.objSubCetegory = objSubCategory; objWrap.objItem = objItem; DBAddinterface.CreateItemDescriptionNode(objWrap); } }