Ejemplo n.º 1
0
        public static void AddSubCategory(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

            Excel.Worksheet sheet = ExcelController.GetWorkSheet(sheetName);

            Excel.Range usedRange = sheet.UsedRange;

            SubCategoryWrapper objWrap     = new SubCategoryWrapper();
            Category           objCategory = new Category();



            //Do not consider row 1 as its the header
            for (int Row = 2; Row <= usedRange.Rows.Count; Row++)
            {
                SubCategory objSubCategory = new SubCategory();

                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;
                    }

                    if (name.CompareTo(ExcelSheets.EXCELSHEET_CATEGORY) == 0)
                    {
                        objCategory.Name = value;
                        continue;
                    }
                    ExcelUtilities.PopulateStructure <SubCategory>(name, value, ref objSubCategory);
                }

                //Add the country in the Neo4j Database


                objWrap.objCategory    = objCategory;
                objWrap.objSubCategory = objSubCategory;

                DBAddinterface.CreateSubCategoryNode(objWrap);
            }
        }
Ejemplo n.º 2
0
        public static void CreateSubCategoryNode(SubCategoryWrapper objWrap)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <SubCategory>(objWrap.objSubCategory);

            Category    objCategory    = objWrap.objCategory;
            SubCategory objSubCategory = objWrap.objSubCategory;

            if (objCategory == null)
            {
                Logger.WriteToLogFile("Category not found");
                throw new Exception("Cateogry is null");
            }

            var result = Neo4jController.m_graphClient.Cypher
                         .Match("(A:" + objCategory.getLabel() + " { id : { id }})")
                         .Merge("(A)-[R:" + Rel_Category.category_subCategory + "]->(B:" + objSubCategory.getLabel() + "{ Name : { Name }})")
                         .OnCreate()
                         .Set("B = { objSubCategory }")
                         .OnMatch()
                         .Set("B = { objSubCategory }")
                         .WithParams(new
            {
                id             = objCategory.id,
                objSubCategory = objSubCategory,
                Name           = objSubCategory.Name
            })
                         .Return((B, R) => new
            {
                SubCategoryCount = B.Count(),
                RelationCount    = R.Count()
            })
                         .Results
                         .Single();

            if (result.SubCategoryCount == 1)
            {
                Logger.WriteToLogFile("Successfully created Subcategory");
            }
            else
            {
                Logger.WriteToLogFile("unable to create Subcategory");
            }
        }