Esempio n. 1
0
        static void ErrorCSVWriter()
        {
            context = new AdventureWorksContext();
            List <ErrorLog> errorList = context.ErrorLog.ToList();

            foreach (ErrorLog error in errorList)
            {
                FileWriting.WriteError(error);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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");
        }