Example #1
0
        private static PepperiDbContext GenerateAndUploadData(DataQuatities DataQuatities)
        {
            System.Console.WriteLine("Generating and Uploading Data...");
            DataGenerator DataGenerator = new DataGenerator(Logger, ApiClient, On_DataGenerator_Progress);

            PepperiDbContext PepperiDbContext = DataGenerator.GenerateAndUploadData(DataQuatities);

            System.Console.WriteLine("finished uploading all data successfully!");

            return(PepperiDbContext);
        }
Example #2
0
        static void Main(string[] args)
        {
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls12
                                                              | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls;

            try
            {
                #region Set ApiClient

                ApiClient = Factory.CreateApiClientForPrivateApplication(Logger);

                #endregion

                #region Ask Should Generate And UploadData

                bool ShouldGenerateAndUploadData = Ask_ShouldGenerateAndUploadData();

                #endregion

                #region read DataQuatities, Generate And upload Data

                if (ShouldGenerateAndUploadData)
                {
                    DataQuatities    DataQuatities    = GetDataQuatities();
                    PepperiDbContext PepperiDbContext = GenerateAndUploadData(DataQuatities);
                }

                #endregion

                #region Populate Transacion changes from Pepperi UI to ERP

                bool makeAnotherTransaction = true;
                while (makeAnotherTransaction == true)
                {
                    string userInput = null;

                    #region Change data on Pepperi using Pepperi ui, setting its status to Submitted. (eg, submit transaction)

                    while (userInput != "ok")
                    {
                        System.Console.WriteLine("Please Login to Pepperi , view the uploaded data, then make a transaction/s and once you submitted type below ok to see the transaction/s here");
                        userInput = System.Console.ReadLine();
                    }

                    #endregion

                    #region Read submitted data from Pepperi using Pepperi API (Status = Submitted)

                    IEnumerable <Transaction> transactions = ReadSubmittedTransactions();

                    #endregion

                    #region Print submitted transaction lines

                    PrintTransactions(transactions);

                    #endregion

                    #region Update ERP with the submitted Pepperi data
                    #endregion

                    #region Update Status of the transactions On Pepperi (to inidcate the changes were saved to ERP)

                    UpdateTransactionStatus(transactions, eStatus.Invoice);

                    #endregion

                    #region ask: make another transaction or exit

                    userInput = null;
                    while (userInput != "yes" && userInput != "no")
                    {
                        System.Console.WriteLine("The program updated the Status field to simulate the integration process - so that only new submitted transactions will be displayed the next time you type 'ok'.\r\n");
                        System.Console.WriteLine("type 'yes' to make another transaction or 'no' to display how many transactions made in the last 30 days.");

                        userInput = System.Console.ReadLine();
                        if (userInput == "yes")
                        {
                            makeAnotherTransaction = true;
                        }
                        if (userInput == "no")
                        {
                            makeAnotherTransaction = false;
                        }
                    }

                    #endregion
                }

                #endregion


                #region Print number of transactions in last 30 days

                double numberOfDays = 30;
                long   count        = CountTransactions(numberOfDays);
                System.Console.WriteLine("There were " + count + " Transactions in the last " + numberOfDays + " days");

                #endregion

                #region Goodbye

                System.Console.WriteLine("This was a demo program to help you integrate quickly with Pepperi. Visit us on developer.pepperi.com. ");
                System.Console.ReadKey();

                #endregion
            }

            catch (Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
                System.Console.ReadKey();
            }
        }