Esempio n. 1
0
        public void SaveToDB(RootJsonObject root)
        {
            foreach (var item in root.GeneralItems)
            {
                Company company = new Company
                {
                    Name         = "A",
                    CUI          = "A",
                    Code         = 99999,
                    NetTurnover  = 111000,
                    Shareholders = "A,B,C,D",
                    Percentages  = "10,20,40,40"
                };
                string name = Convert.ToString(item["nume"]);
                company.Name = name;
                company.CUI  = Convert.ToString(item["cui"]);
                //company.CUI = Convert.ToString(item["cui"]);


                mDb.AddCompany(company);
            }


            mDb.GetAllCompanies();
        }
Esempio n. 2
0
        public void fillDB()
        {
            string[] json_files = new string[] { "1.json", "2.json" };
            string   str1       = "{\"Date Generale\":[{\"nume\":\"TERMENE JUST SRL\",\"cui\":\"33034700\"}]}";
            string   str2       = "";

            string[] json_files_mem = new string[] { str1, str2 };

            int count = 0;

            string currentDir = Directory.GetCurrentDirectory();

            if (string.IsNullOrEmpty(currentDir))
            {
                Console.WriteLine("Cannot build path: current dir empty");
                System.Environment.Exit(1);
            }
            DirectoryInfo parent = Directory.GetParent(currentDir);

            if (parent == null)
            {
                Console.WriteLine("Cannot build path: parent dir empty");
                System.Environment.Exit(1);
            }

            string dir = parent.Parent.FullName;

            if (string.IsNullOrEmpty(dir))
            {
                Console.WriteLine("Cannot build path: dir empty");
                System.Environment.Exit(1);
            }

            for (int i = 0; i < json_files.Length; i++)
            {
                string     path       = "D:\\aml\\aml\\AML\\" + json_files[i];
                ParserJson parserJson = new ParserJson(path);

                // Read all info from json
                RootJsonObject rootObj = null;
                bool           parsed  = parserJson.LoadJson(parserJson.JsonString, ref rootObj);
                if (!parsed)
                {
                    Console.WriteLine("Read from memory");
                    parsed = parserJson.LoadJson(json_files_mem[i], ref rootObj);
                }

                // Store all data in a database
                if (rootObj != null && parsed)
                {
                    SaveToDB(rootObj);
                    count++;
                }
            }
        }
Esempio n. 3
0
        public bool LoadJson(string jsonString, ref RootJsonObject jsonObj)
        {
            ReadJson();

            if (string.IsNullOrEmpty(jsonString))
            {
                return(false);
            }

            jsonObj = JsonConvert.DeserializeObject <RootJsonObject>(jsonString);

            return(true);
        }