Exemple #1
0
        public static string ExporttoJSON(string modelName, string option)
        {
            //pass in parameters
            string json = JsonResult("api/" + modelName).Result;
            //convert json to xml to csv with pipe delimeter
            string csv = ConvertJson(json);

            //use file write method to write string to file

            if (option == "json")
            {
                FileWriting.WriteStringToFile(json, "C:\\Json\\" + modelName + ".json");
            }
            else if (option == "csv")
            {
                FileWriting.WriteStringToFile(csv, "C:\\Csv\\" + modelName + ".csv");
            }

            return(json);
        }
Exemple #2
0
        public static void ExportCustomers()
        {
            Customer customer = new Customer();

            customer.customerId   = 30119;
            customer.nameStyle    = false;
            customer.title        = "Mr.";
            customer.firstName    = "Carleton";
            customer.lastName     = "cabarrus";
            customer.middleName   = "lee";
            customer.suffix       = "jr";
            customer.companyName  = "ACompany";
            customer.salesPerson  = "adventure-works\\pamela0|[email protected]";
            customer.phone        = "804-337-1521";
            customer.passwordHash = new HashCode().ToString();
            customer.passwordSalt = "salt";
            customer.rowguid      = Guid.NewGuid();
            customer.modifiedDate = DateTime.Now;
            string csv = ConvertJson(JsonConvert.SerializeObject(customer));

            FileWriting.WriteStringToFile(csv, "C:\\Customers\\allCustomers.csv");
        }