示例#1
0
        public static void AddCity(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

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

            Excel.Range usedRange = sheet.UsedRange;

            CityWrapper objWrap    = new CityWrapper();
            Country     objCountry = new Country();
            State       objState   = new State();

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

                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_COUNTRY) == 0)
                    {
                        objCountry.Name = value;
                        continue;
                    }
                    else
                    if (name.CompareTo(ExcelSheets.EXCELSHEET_STATE) == 0)
                    {
                        objState.Name = value;
                        continue;
                    }

                    ExcelUtilities.PopulateStructure <City>(name, value, ref objCity);
                }

                //Add the country in the Neo4j Database

                objWrap.objState   = objState;
                objWrap.objCountry = objCountry;
                objWrap.objCity    = objCity;

                DBAddinterface.CreateCityNode(objWrap);
            }
        }
示例#2
0
        public static void AddBrand(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

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

            Excel.Range usedRange = sheet.UsedRange;

            BrandDescriptionWrapper objWrap = new BrandDescriptionWrapper();



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

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

                    ExcelUtilities.PopulateStructure <BrandDescription>(name, value, ref objBrand);
                }

                //Add the country in the Neo4j Database


                objWrap.objRoot  = new BrandRoot();
                objWrap.objBrand = objBrand;

                DBAddinterface.CreateBrandDescriptionNode(objBrand);
            }
        }
示例#3
0
        public static void AddCategory(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

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

            Excel.Range usedRange = sheet.UsedRange;

            CategoryRoot    objcategoryRoot = new CategoryRoot();
            CategoryWrapper objWrap         = new CategoryWrapper();

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

                for (int Col = 1; Col <= usedRange.Columns.Count; Col++)
                {
                    string name = (string)(usedRange.Cells[1, Col] as Excel.Range).Value2;

                    dynamic dValue = (usedRange.Cells[Row, Col] as Excel.Range).Value2;
                    string  value  = null;

                    if (dValue != null)
                    {
                        value = dValue.ToString();
                    }
                    else
                    {
                        continue;
                    }

                    ExcelUtilities.PopulateStructure <Category>(name, value, ref objCategory);
                }

                //Add the country in the Neo4j Database

                objWrap.objCategoryRoot = objcategoryRoot;
                objWrap.objCategory     = objCategory;

                DBAddinterface.CreateCategoryNode(objCategory);
            }
        }
示例#4
0
        public static void AddItem(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

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

            Excel.Range usedRange = sheet.UsedRange;

            ItemWrapper objWrap = new ItemWrapper();

            //Do not consider row 1 as its the header
            for (int Row = 2; Row <= usedRange.Rows.Count; Row++)
            {
                Item            objItem            = new Item();
                Store           objStore           = new Store();
                Brand           objBrand           = new Brand();
                Category        objCategory        = new Category();
                SubCategory     objSubCategory     = new SubCategory();
                ItemDescription objItemDescription = new ItemDescription();

                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_STOREID:
                        objStore.StoreId = value;
                        continue;
                        break;

                    case ExcelSheets.EXCELCOLUMN_ITEMDESCRIPTION_ITEMDESCRIPTIONID:
                        if (!GetItemFromDescriptionId(Convert.ToInt32(value), ref objBrand, ref objCategory, ref objSubCategory, ref objItemDescription))
                        {
                            Col += usedRange.Columns.Count;
                        }
                        continue;
                        break;

                    default: break;
                    }

                    ExcelUtilities.PopulateStructure <Item>(name, value, ref objItem);
                }

                //Add the country in the Neo4j Database

                objWrap.objStore           = objStore;
                objWrap.objBrand           = objBrand;
                objWrap.objCategory        = objCategory;
                objWrap.objSubCetegory     = objSubCategory;
                objWrap.objItem            = objItem;
                objWrap.objItemDescription = objItemDescription;

                DBAddinterface.CreateItemNode(objWrap);
            }
        }
示例#5
0
        private static bool GetItemFromDescriptionId(int DescriptionId, ref Brand objBrand, ref Category objCategory, ref SubCategory objSubCateogry, ref ItemDescription objItemDescription)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

            Excel.Worksheet sheet     = ExcelController.GetWorkSheet(ExcelSheets.EXCELSHEET_ITEMDESCRIPTION);
            Excel.Range     usedRange = sheet.UsedRange;

            int  iteDescriptionIDColumnNumber = 0;
            bool bFound = false;

            //Get item description column number
            //Do not consider row 1 as its the header
            for (int Col = 1; Col <= usedRange.Columns.Count; Col++)
            {
                string name = (string)(usedRange.Cells[1, Col] as Excel.Range).Value2;
                name = name.Trim();

                if (name.CompareTo(ExcelSheets.EXCELCOLUMN_ITEMDESCRIPTION_ITEMDESCRIPTIONID) == 0)
                {
                    iteDescriptionIDColumnNumber = Col;
                    bFound = true;
                    break;
                }
            }

            if (!bFound)
            {
                return(bFound);
            }

            bFound = false;
            int itemFoundRowId = 0;

            //Do not consider row 1 as its the header
            for (int Row = 2; Row <= usedRange.Rows.Count; Row++)
            {
                //Find the row which contails itemDescriptinid
                int value = (int)(usedRange.Cells[Row, iteDescriptionIDColumnNumber] as Excel.Range).Value2;
                if (value == DescriptionId)
                {
                    bFound         = true;
                    itemFoundRowId = Row;
                    break;
                }
            }

            if (!bFound)
            {
                return(bFound);
            }

            for (int Col = 1; Col <= usedRange.Columns.Count; Col++)
            {
                string strName = (string)(usedRange.Cells[1, Col] as Excel.Range).Value2;
                strName = strName.Trim();
                string value = null;

                if ((usedRange.Cells[itemFoundRowId, Col] as Excel.Range).Value2 != null)
                {
                    value = (usedRange.Cells[itemFoundRowId, Col] as Excel.Range).Value2.ToString();
                }
                else
                {
                    continue;
                }

                switch (strName)
                {
                case ExcelSheets.EXCELSHEET_CATEGORY:
                    objCategory.Name = value;
                    continue;
                    break;

                case ExcelSheets.EXCELSHEET_BRAND:
                    objBrand.Name = value;
                    continue;
                    break;

                case ExcelSheets.EXCELSHEET_SUBCATEGORY:
                    objSubCateogry.Name = value;
                    continue;
                    break;

                default: break;
                }

                ExcelUtilities.PopulateStructure <ItemDescription>(strName, value, ref objItemDescription);
            }


            return(bFound);
        }
示例#6
0
        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);
            }
        }