Esempio n. 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);
        }
Esempio n. 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();
            }
        }
Esempio n. 3
0
        private static DataQuatities GetDataQuatities()
        {
            //step1: ask user whether to use default data quantities
            bool?useDefaultDataQuanitites = null;

            while (useDefaultDataQuanitites == null)
            {
                System.Console.WriteLine("enter 'yes' to generate and upload data in default size or 'no' to select data size");
                string resultAsString = System.Console.ReadLine();

                if (resultAsString == "yes")
                {
                    useDefaultDataQuanitites = true;
                }

                if (resultAsString == "no")
                {
                    useDefaultDataQuanitites = false;
                }
            }


            //step2: set size
            string size = null;

            if (useDefaultDataQuanitites.Value == true)
            {
                size = "low";
            }


            while (size == null)
            {
                System.Console.WriteLine("enter high/mid/low");
                string resultAsString = System.Console.ReadLine();

                if (resultAsString == "low" || resultAsString == "mid" || resultAsString == "high")
                {
                    size = resultAsString;
                }
            }

            //step3: initialize DataQuantiites
            DataQuatities DataQuatities = new DataQuatities();

            switch (size)
            {
            case "low":
            {
                DataQuatities.generate_X_Item                           = 1000;
                DataQuatities.generate_X_PriceList                      = 10;
                DataQuatities.generate_X_accounts                       = 100;
                DataQuatities.generate_X_contactsPerAccount             = 5;
                DataQuatities.generate_X_transactionsPerAccount         = 10;
                DataQuatities.generate_X_transactionLinesPerTransaction = 5;
                DataQuatities.generate_X_activitierPerAccount           = 4;
                break;
            }

            case "mid":
            {
                DataQuatities.generate_X_Item                           = 10000;
                DataQuatities.generate_X_PriceList                      = 10;
                DataQuatities.generate_X_accounts                       = 1000;
                DataQuatities.generate_X_contactsPerAccount             = 5;
                DataQuatities.generate_X_transactionsPerAccount         = 10;
                DataQuatities.generate_X_transactionLinesPerTransaction = 10;
                DataQuatities.generate_X_activitierPerAccount           = 10;
                break;
            }

            case "high":
            {
                DataQuatities.generate_X_Item                           = 100000;
                DataQuatities.generate_X_PriceList                      = 10;
                DataQuatities.generate_X_accounts                       = 10000;
                DataQuatities.generate_X_contactsPerAccount             = 5;
                DataQuatities.generate_X_transactionsPerAccount         = 10;
                DataQuatities.generate_X_transactionLinesPerTransaction = 10;
                DataQuatities.generate_X_activitierPerAccount           = 10;
                break;
            }

            default:
                throw new PepperiException("unexpected size: " + size == null ? " " : size);
            }

            return(DataQuatities);
        }