//Application routines
        //private void LoadTextLines()
        //{
        //    textRuler.RulerText =           "LNTYPFIELD1         FIELDB            FIELDC                    FIELD_D                     COLHDR_E            FINALCOL       NUMBERS   ";
        //    textRuler.RulerTextLinesExtra = "LINE2xxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzzddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeefffffffffffffff0123456789";
        //}


        private void ShowFieldOffsets()
        {
            string fieldOffsets          = string.Empty;
            string colNamesPlusFieldLens = string.Empty;
            int    lineLength            = AppTextGlobals.ConvertStringToInt(this.txtExpectedLineWidth.Text, 1);

            if (textRuler.FieldOffSets.Count == 0)
            {
                object newValMin = (int)1;
                textRuler.FieldOffSets.Add(newValMin);
                object newValMax = lineLength + 1;
                textRuler.FieldOffSets.Add(newValMax);
            }

            textRuler.FieldOffSets.Sort();

            if ((int)textRuler.FieldOffSets[0] != 1)
            {
                object newVal = (int)1;
                textRuler.FieldOffSets.Add(newVal);
            }

            if ((int)textRuler.FieldOffSets[textRuler.FieldOffSets.Count - 1] != (lineLength + 1))
            {
                object newVal = lineLength + 1;
                textRuler.FieldOffSets.Add(newVal);
            }

            textRuler.FieldOffSets.Sort();

            int maxInx = textRuler.FieldOffSets.Count - 1;

            for (int i = 0; i < maxInx; i++)
            {
                int    startPos = (int)textRuler.FieldOffSets[i] - 1;
                int    colLen   = (int)textRuler.FieldOffSets[i + 1] - (int)textRuler.FieldOffSets[i];
                string colName  = this.TextLine1.Substring(startPos, colLen).Trim();
                if (colName.Trim() == string.Empty)
                {
                    colName = new string('?', colLen);
                }
                string val = this.TextLine1.Substring(startPos, colLen);
                if (i > 0)
                {
                    //fieldOffsets += Environment.NewLine + textRuler.FieldOffSets[i].ToString();
                    fieldOffsets += Environment.NewLine + colName + ", " + colLen.ToString();
                }
                else
                {
                    fieldOffsets += colName + ", " + colLen.ToString();
                    //fieldOffsets += textRuler.FieldOffSets[i].ToString();
                }
            }

            _msg.Length = 0;
            _msg.Append("Field offsets are: ");
            _msg.Append(Environment.NewLine);
            _msg.Append(fieldOffsets);
            AppMessages.DisplayMessage(_msg.ToString(), "Column Offsets", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void PreviewTestData()
        {
            int numPreviewRows = 1000;

            try
            {
                DisableFormControls();
                this.Cursor = Cursors.WaitCursor;

                numPreviewRows = AppTextGlobals.ConvertStringToInt(this.txtNumRowsToPreview.Text, 1000);

                runTestDataPreview(numPreviewRows);
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                WriteToMessageLog(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                EnableFormControls();
                this.Cursor = Cursors.Default;
                this.Focus();
            }
        }
        /// <summary>
        /// GetFieldNamesAndLengths method.
        /// </summary>
        /// <returns>Array of ColNameAndLength objects.</returns>
        public ColNameAndLength[] GetFieldNamesAndLengths()
        {
            ColNameAndLength[] colNamesAndLengths    = null;
            string             fieldOffsets          = string.Empty;
            string             colNamesPlusFieldLens = string.Empty;
            int lineLength = AppTextGlobals.ConvertStringToInt(this.txtExpectedLineWidth.Text, 1);

            if (textRuler.FieldOffSets.Count == 0)
            {
                object newValMin = (int)1;
                textRuler.FieldOffSets.Add(newValMin);
                if (lineLength < 1)
                {
                    lineLength = 0;
                }
                object newValMax = lineLength + 1;
                textRuler.FieldOffSets.Add(newValMax);
            }

            textRuler.FieldOffSets.Sort();

            if ((int)textRuler.FieldOffSets[0] != 1)
            {
                object newVal = (int)1;
                textRuler.FieldOffSets.Add(newVal);
            }

            if ((int)textRuler.FieldOffSets[textRuler.FieldOffSets.Count - 1] != (lineLength + 1))
            {
                object newVal = lineLength + 1;
                textRuler.FieldOffSets.Add(newVal);
            }

            textRuler.FieldOffSets.Sort();

            colNamesAndLengths = new ColNameAndLength[textRuler.FieldOffSets.Count];

            int maxInx = textRuler.FieldOffSets.Count - 1;

            for (int i = 0; i < maxInx; i++)
            {
                int    startPos = (int)textRuler.FieldOffSets[i] - 1;
                int    colLen   = (int)textRuler.FieldOffSets[i + 1] - (int)textRuler.FieldOffSets[i];
                string colName  = this.TextLine1.Substring(startPos, colLen).Trim();
                if (colName.Trim() == string.Empty)
                {
                    colName = new string('?', colLen);
                }
                string           val = this.TextLine1.Substring(startPos, colLen);
                ColNameAndLength cnl = new ColNameAndLength();
                cnl.colName           = colName;
                cnl.colLength         = colLen;
                colNamesAndLengths[i] = cnl;
            }

            return(colNamesAndLengths);
        }
예제 #4
0
 private static void InitializeFtpFromForm(MainForm frm, PFWinFTP ftp)
 {
     ftp.FtpHost     = frm.txtFtpHost.Text;
     ftp.FtpUsername = frm.txtFtpUsername.Text;
     ftp.FtpPassword = frm.txtFtpPassword.Text;
     //ftp.UseAsyncFileTransfer = frm.chkUseAsync.Checked;
     //ftp.ProgressIntervalInSeconds = AppTextGlobals.ConvertStringToInt(frm.txtProgressIntervalInSecs.Text, 1);
     //ftp.RetryTimeout = AppTextGlobals.ConvertStringToInt(frm.txtRetryTimeout.Text, 300000);
     //ftp.UseFipsCompliantMode = frm._useFipsCompliantMode;
     ftp.FtpBufferSize        = AppTextGlobals.ConvertStringToInt(frm.txtBufferSize.Text, 32767);
     ftp.SourceFile           = frm.txtLocalSourceFile.Text;
     ftp.RemoteFile           = frm.txtRemoteFile.Text;
     ftp.LocalDestinationFile = frm.txtLocalDestinationFile.Text;
 }
        //Application routines

        private void ProcessSelections()
        {
            _includeColumnHeadersInOutput = this.chkIncludeColumnHeadingsInOutput.Checked;
            _allowDataTruncation          = this.chkAllowDataTruncation.Checked;
            if (this.optCrLf.Checked)
            {
                _lineTerminatorChars = Environment.NewLine;
            }
            else if (this.optOtherLineTerminator.Checked)
            {
                _lineTerminatorChars = this.txtOtherLineTerminator.Text;
            }
            else
            {
                _lineTerminatorChars = Environment.NewLine;
            }
            if (_lineTerminatorChars == string.Empty)
            {
                _lineTerminatorChars = " ";
            }
            _columnWidthForStringData  = AppTextGlobals.ConvertStringToInt(this.txtColumnWidthForStringData.Text, 255);
            _maximumAllowedColumnWidth = AppTextGlobals.ConvertStringToInt(this.txtMaximumAllowedColumnWidth.Text, 1024);
        }
예제 #6
0
        //tests

        public static void TimedDialogBoxTest(MainForm frm)
        {
            ModelessPopupDialog diag = null;
            int maxSeconds           = 0;

            try
            {
                _msg.Length = 0;
                _msg.Append("TestTimedDialogBox started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                maxSeconds = AppTextGlobals.ConvertStringToInt(frm.txtNumSecs.Text, 0);

                if (maxSeconds == 0)
                {
                    maxSeconds = 5;
                }

                diag         = new ModelessPopupDialog(maxSeconds);
                diag.Message = "Processing will be done for " + maxSeconds.ToString() + " seconds.";
                diag.Show();
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... TestTimedDialogBox finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
        /// <summary>
        /// Creates a set of sequential numbers that start from a user specified start number and are incremented by a user specified number. This is a testing routine.
        /// </summary>
        /// <param name="incrementType">Time slice to increment with (seconds, minutes, hours, days, years).</param>
        /// <param name="numRows">Number of random values to generate.</param>
        /// <param name="incrementSize">Number to increment by.</param>
        /// <param name="startDateForSequence">First date in the sequence.</param>
        /// <param name="endDateForSequence">Maximum date in the sequence.</param>
        /// <param name="generateRandomTime">If true, a randomized time value will be generated for each sequential date.</param>
        /// <param name="fromTime">Minimum time value to generate.</param>
        /// <param name="toTime">Maximum time value to generate.</param>
        /// <param name="minNumDatesPerIncrement">For each date increment, the minimum number of dates that can be generated with same date into the sequence.</param>
        /// <param name="maxNumDatesPerIncrement">For each date increment, the maximum number of dates that can be generated with same date into the sequence.</param>
        /// <param name="initStartDateForSequence">If maximum date is passed during sequence generation, the sequence will be restarted with this date and new values will be appended to the existing sequence.</param>
        /// <param name="dateConversionType">Determines whether or not to convert the DateTime value to an integer. Useful for data warehousing scenarios.</param>
        /// <returns>ADO.NET DataTable containing the set of random values.</returns>
        /// <remarks>This routine is used for testing.</remarks>
        public DataTable CreateDateSequencePreviewDataTable(enRandomIncrementType incrementType, int numRows, string incrementSize, string startDateForSequence, string endDateForSequence, bool generateRandomTime, string fromTime, string toTime, string minNumDatesPerIncrement, string maxNumDatesPerIncrement, string initStartDateForSequence, enDateConversionType dateConversionType)
        {
            DataTable dt = new DataTable();

            int      sizeOfIncrement   = 1;
            DateTime startDate         = DateTime.MinValue;
            DateTime endDate           = DateTime.MaxValue;
            DateTime currDate          = DateTime.Now;
            DateTime initDate          = DateTime.MinValue;
            int      minIncrementDates = 1;
            int      maxIncrementDates = 1;
            TimeSpan fromTimeTs        = Convert.ToDateTime(fromTime).TimeOfDay;
            TimeSpan toTimeTs          = Convert.ToDateTime(toTime).TimeOfDay;
            double   fromSeconds       = fromTimeTs.TotalSeconds;
            double   toSeconds         = toTimeTs.TotalSeconds;
            double   randNum           = 0.0;

            try
            {
                sizeOfIncrement = AppTextGlobals.ConvertStringToInt(incrementSize, 1);
                startDate       = AppTextGlobals.ConvertStringToDateTime(startDateForSequence, new DateTime(1000, 1, 1));
                endDate         = AppTextGlobals.ConvertStringToDateTime(endDateForSequence, new DateTime(5999, 12, 31));
                initDate        = AppTextGlobals.ConvertStringToDateTime(initStartDateForSequence, new DateTime(1000, 1, 1));
                currDate        = IncrementDateTime(incrementType, -sizeOfIncrement, startDate, startDate);

                minIncrementDates = AppTextGlobals.ConvertStringToInt(minNumDatesPerIncrement, 1);
                maxIncrementDates = AppTextGlobals.ConvertStringToInt(maxNumDatesPerIncrement, 1);

                DataColumn dc = new DataColumn("RandomValue");
                //dc.DataType = Type.GetType("System.DateTime");
                switch (dateConversionType)
                {
                case enDateConversionType.DoNotConvert:
                    dc.DataType = Type.GetType("System.DateTime");
                    break;

                case enDateConversionType.ConvertDateTo32bitInt:
                    dc.DataType = Type.GetType("System.Int32");
                    break;

                case enDateConversionType.ConvertTimeTo32bitInt:
                    dc.DataType = Type.GetType("System.Int32");
                    break;

                case enDateConversionType.ConvertDateTimeTo64bitInt:
                    dc.DataType = Type.GetType("System.Int64");
                    break;

                default:
                    dc.DataType = Type.GetType("System.DateTime");
                    break;
                }

                dt.Columns.Add(dc);


                for (int i = 0; i < numRows; i++)
                {
                    currDate = IncrementDateTime(incrementType, sizeOfIncrement, currDate, startDate);

                    if (currDate > endDate)
                    {
                        currDate = initDate;
                    }

                    int      numDatesToGenerate = _rn.GenerateRandomInt(minIncrementDates, maxIncrementDates);
                    DateTime dtm = currDate;

                    for (int n = 0; n < numDatesToGenerate; n++)
                    {
                        DataRow dr = dt.NewRow();
                        if (generateRandomTime)
                        {
                            randNum = _rn.GenerateRandomNumber(fromSeconds, toSeconds);
                            TimeSpan ts2 = new TimeSpan(0, 0, 0, (int)randNum, 0);
                            try
                            {
                                dtm = currDate.AddSeconds(ts2.TotalSeconds);
                            }
                            catch (System.ArgumentOutOfRangeException)
                            {
                                dtm      = startDate;
                                currDate = startDate;
                            }
                        }
                        //dr[0] = dtm;
                        switch (dateConversionType)
                        {
                        case enDateConversionType.DoNotConvert:
                            dr[0] = dtm;
                            break;

                        case enDateConversionType.ConvertDateTo32bitInt:
                            dr[0] = Convert.ToInt32(dtm.ToString("yyyyMMdd"));
                            break;

                        case enDateConversionType.ConvertTimeTo32bitInt:
                            dr[0] = Convert.ToInt32(dtm.ToString("HHmmss"));
                            break;

                        case enDateConversionType.ConvertDateTimeTo64bitInt:
                            dr[0] = Convert.ToInt64(dtm.ToString("yyyyMMddHHmmss"));
                            break;

                        default:
                            dr[0] = dtm;
                            break;
                        }
                        dt.Rows.Add(dr);
                    }
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append("Error in CreateSequencePreviewDataTable routine.\r\n");
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                throw new System.Exception(_msg.ToString());
            }
            finally
            {
                ;
            }



            return(dt);
        }
예제 #8
0
        public static void SmtpTest(MainForm frm)
        {
            PFEmailMessage emMsg = new PFEmailMessage();
            PFEmailManager emMgr;
            string         connectionString = string.Empty;
            string         configValue      = string.Empty;

            try
            {
                _msg.Length = 0;
                _msg.Append("SmtpTest started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                configValue = AppConfig.GetStringValueFromConfigFile("EmailResendQueueDatabaseConnectionString", string.Empty);
                if (configValue.Length > 0)
                {
                    _emailResendQueueDatabaseConnectionString = configValue;
                }
                connectionString = _emailResendQueueDatabaseConnectionString;

                emMgr = new PFEmailManager(@"c:\temp\EmailResendQueue.xml");

                emMsg.SMTPServer = frm.txtSmtpServer.Text;
                emMsg.SmtpPort   = AppTextGlobals.ConvertStringToInt(frm.txtSmtpPort.Text, 25);
                if (frm.txtSendTimeout.Text.Length > 0)
                {
                    emMsg.SendTimeout = AppTextGlobals.ConvertStringToInt(frm.txtSendTimeout.Text, 100000);
                }
                if (frm.txtMaxIdleTime.Text.Length > 0)
                {
                    emMsg.MaxIdleTime = AppTextGlobals.ConvertStringToInt(frm.txtMaxIdleTime.Text, 1);
                }
                emMsg.EnableSsl     = frm.chkUseSsl.Checked;
                emMsg.SenderAddress = frm.txtFromAddress.Text;
                emMsg.FromAddress   = frm.txtFromAddress.Text;
                emMsg.ToAddress     = frm.txtToAddress.Text;
                if (frm.txtCCAddress.Text.Length > 0)
                {
                    emMsg.CCAddress = frm.txtCCAddress.Text;
                }
                if (frm.txtBCCAddress.Text.Length > 0)
                {
                    emMsg.BccAddress = frm.txtBCCAddress.Text;
                }
                emMsg.MessageSubject = frm.txtSubjectLine.Text;
                emMsg.MessageBody    = frm.txtMessageBody.Text;


                _msg.Length = 0;
                _msg.Append("SMTP Port = ");
                _msg.Append(emMsg.SmtpPort);
                _msg.Append("\r\n");
                _msg.Append("Send Timeout = ");
                _msg.Append(emMsg.SendTimeout);
                _msg.Append("\r\n");
                _msg.Append("Max Idle Time = ");
                _msg.Append(emMsg.MaxIdleTime);
                _msg.Append("\r\n");
                _msg.Append("SMTP Server = ");
                _msg.Append(emMsg.SMTPServer);
                _msg.Append("\r\n");
                _msg.Append("From Address = ");
                _msg.Append(emMsg.FromAddress);
                _msg.Append("\r\n");
                _msg.Append("To Address = ");
                _msg.Append(emMsg.ToAddress);
                _msg.Append("\r\n");
                _msg.Append("CC Address = ");
                _msg.Append(emMsg.CCAddress);
                _msg.Append("\r\n");
                _msg.Append("BCC Address = ");
                _msg.Append(emMsg.BccAddress);
                _msg.Append("\r\n");
                _msg.Append("Message Subject = ");
                _msg.Append(emMsg.MessageSubject);
                _msg.Append("\r\n");
                _msg.Append("Message Body = ");
                _msg.Append(emMsg.MessageBody);
                _msg.Append("\r\n");
                Program._messageLog.WriteLine(_msg.ToString());


                //emMsg.Send();
                stEmailSendResult res = emMgr.SendEmail(emMsg);


                _msg.Length = 0;
                _msg.Append("Email send result: ");
                _msg.Append(res.emailSendResult.ToString());
                if (res.emailSendResult != enEmailSendResult.Success)
                {
                    _msg.Append("\r\n");
                    _msg.Append("Failure reason: ");
                    _msg.Append(res.emailFailedReason.ToString());
                    _msg.Append("\r\nError Messages:\r\n");
                    _msg.Append(res.failureMessages);
                }
                Program._messageLog.WriteLine(_msg.ToString());
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... SmtpTest finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
        private DataTable CreateOrderTransactionDatesPreviewTable()
        {
            DataTable     dt                          = new DataTable();
            RandomNumber  rnd                         = new RandomNumber();
            int           numPreviewDates             = 10;
            DateTime      earliestDate                = DateTime.MinValue;
            DateTime      latestDate                  = DateTime.MinValue;
            DateTime      currDate                    = DateTime.MinValue;
            bool          includeWeekendDays          = this.chkIncludeWeekendDays.Checked;
            int           minNumSalesOrdersPerDate    = 1;
            int           maxNumSalesOrdersPerDate    = 1;
            int           minNumPurchaseOrdersPerDate = 1;
            int           maxNumPurchaseOrdersPerDate = 1;
            TimeSpan      minTimePerDate              = TimeSpan.MinValue;
            TimeSpan      maxTimePerDate              = TimeSpan.MinValue;
            int           minSecondsPerDate           = 1;
            int           maxSecondsPerDate           = 1;
            int           numSalesOrdersForDate       = 0;
            int           numPurchaseOrdersForDate    = 0;
            int           numSecondsForTx             = 0;
            TimeSpan      txTime                      = TimeSpan.MinValue;
            StringBuilder timeList                    = new StringBuilder();

            string errMsg = VerifyFormValues();

            if (errMsg.Length > 0)
            {
                WriteToMessageLog(errMsg);
                AppMessages.DisplayErrorMessage(errMsg);
                return(null);
            }


            DataColumn dc0 = new DataColumn();

            dc0.ColumnName        = "DayNum";
            dc0.DataType          = Type.GetType("System.Int32");
            dc0.AutoIncrement     = true;
            dc0.AutoIncrementSeed = 1;
            dc0.AutoIncrementStep = 1;

            DataColumn dc1 = new DataColumn();

            dc1.ColumnName = "DayOfWeek";
            dc1.DataType   = Type.GetType("System.String");
            dc1.MaxLength  = 255;

            DataColumn dc2 = new DataColumn();

            dc2.ColumnName = "DateAndTime";
            dc2.DataType   = Type.GetType("System.DateTime");

            DataColumn dc3 = new DataColumn();

            dc3.ColumnName = "NumSalesOrders";
            dc3.DataType   = Type.GetType("System.Int32");

            DataColumn dc4 = new DataColumn();

            dc4.ColumnName = "NumPurchaseOrders";
            dc4.DataType   = Type.GetType("System.Int32");

            DataColumn dc5 = new DataColumn();

            dc5.ColumnName = "Tx Times";
            dc5.DataType   = Type.GetType("System.String");
            dc5.MaxLength  = Int16.MaxValue;

            dt.Columns.Add(dc0);
            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            dt.Columns.Add(dc3);
            dt.Columns.Add(dc4);
            dt.Columns.Add(dc5);

            numPreviewDates             = AppTextGlobals.ConvertStringToInt(this.txtNumPreviewDates.Text, -1);
            earliestDate                = AppTextGlobals.ConvertStringToDateTime(this.txtEarliestTransactionDate.Text, DateTime.MinValue);
            latestDate                  = AppTextGlobals.ConvertStringToDateTime(this.txtLatestTransactionDate.Text, DateTime.MinValue);
            currDate                    = earliestDate;
            minNumSalesOrdersPerDate    = AppTextGlobals.ConvertStringToInt(this.txtMinNumSalesOrdersPerDate.Text, 1);
            maxNumSalesOrdersPerDate    = AppTextGlobals.ConvertStringToInt(this.txtMaxNumSalesOrdersPerDate.Text, 1);
            minNumPurchaseOrdersPerDate = AppTextGlobals.ConvertStringToInt(this.txtMinNumPurchaseOrdersPerDate.Text, 1);
            maxNumPurchaseOrdersPerDate = AppTextGlobals.ConvertStringToInt(this.txtMaxNumPurchaseOrdersPerDate.Text, 1);
            minTimePerDate              = AppTextGlobals.ConvertStringToTimeSpan(this.txtMinTimePerDate.Text, "00:00:00");
            maxTimePerDate              = AppTextGlobals.ConvertStringToTimeSpan(this.txtMaxTimePerDate.Text, "00:00:00");
            minSecondsPerDate           = (int)minTimePerDate.TotalSeconds;
            maxSecondsPerDate           = (int)maxTimePerDate.TotalSeconds;

            for (int r = 0; r < numPreviewDates; r++)
            {
                numSalesOrdersForDate    = rnd.GenerateRandomInt(minNumSalesOrdersPerDate, maxNumSalesOrdersPerDate);
                numPurchaseOrdersForDate = rnd.GenerateRandomInt(minNumPurchaseOrdersPerDate, maxNumPurchaseOrdersPerDate);

                DataRow dr = dt.NewRow();
                dr[1] = currDate.DayOfWeek.ToString();
                dr[2] = currDate;
                dr[3] = numSalesOrdersForDate;
                dr[4] = numPurchaseOrdersForDate;

                timeList.Length = 0;

                for (int so = 0; so < numSalesOrdersForDate; so++)
                {
                    numSecondsForTx = rnd.GenerateRandomInt(minSecondsPerDate, maxSecondsPerDate);
                    DateTime txDate = currDate.AddSeconds(numSecondsForTx);
                    timeList.Append("SO at ");
                    timeList.Append(txDate.ToString("HH:mm:ss"));
                    timeList.Append(", ");
                }

                for (int po = 0; po < numPurchaseOrdersForDate; po++)
                {
                    numSecondsForTx = rnd.GenerateRandomInt(minSecondsPerDate, maxSecondsPerDate);
                    DateTime txDate = currDate.AddSeconds(numSecondsForTx);
                    timeList.Append("PO at ");
                    timeList.Append(txDate.ToString("HH:mm:ss"));
                    timeList.Append(", ");
                }

                dr[5] = timeList.ToString().TrimEnd(' ').TrimEnd(',');

                dt.Rows.Add(dr);

                //increment counters and dates to continue loop
                currDate = currDate.AddDays(1);
                if (currDate > latestDate)
                {
                    break;
                }
                if (currDate.DayOfWeek == DayOfWeek.Sunday &&
                    includeWeekendDays == false)
                {
                    currDate = currDate.AddDays(1);
                }
                else if (currDate.DayOfWeek == DayOfWeek.Saturday &&
                         includeWeekendDays == false)
                {
                    currDate = currDate.AddDays(2);
                }
                else
                {
                    //keep the previously calculated date
                    ;
                }
            }


            return(dt);
        }
        private void EstimateTransactionRowCounts()
        {
            string errMsg = VerifyFormValues();

            if (errMsg.Length > 0)
            {
                WriteToMessageLog(errMsg);
                AppMessages.DisplayErrorMessage(errMsg);
                return;
            }


            try
            {
                _msg.Length = 0;

                DateTime earliestTxDate = AppTextGlobals.ConvertStringToDateTime(this.txtEarliestTransactionDate.Text, DateTime.MinValue);
                DateTime latestTxDate   = AppTextGlobals.ConvertStringToDateTime(this.txtLatestTransactionDate.Text, DateTime.MinValue);
                TimeSpan dateDiff       = latestTxDate.Subtract(earliestTxDate);
                double   numDays        = dateDiff.TotalDays;
                double   numWeeks       = numDays / 7.0;
                if (this.chkIncludeWeekendDays.Checked == false)
                {
                    numDays = numDays - (numWeeks * 2.0);
                }
                _msg.Append("Estimated number of days:                ");
                _msg.Append(numDays.ToString("#,##0"));
                _msg.Append(Environment.NewLine);

                double minNum                  = AppTextGlobals.ConvertStringToDouble(this.txtMinNumSalesOrdersPerDate.Text, 0.0);
                double maxNum                  = AppTextGlobals.ConvertStringToDouble(this.txtMaxNumSalesOrdersPerDate.Text, 0.0);
                double numSalesTxs             = numDays * ((minNum + maxNum) / 2.0);
                double numSalesDetails         = numSalesTxs * 3.0;
                double numInternetSalesDetails = numSalesTxs * 2.0;
                double numResellerSalesDetails = numSalesTxs * 16.0;

                _msg.Append("Estimated number of sales order headers:    ");
                _msg.Append(numSalesTxs.ToString("#,##0"));
                _msg.Append(Environment.NewLine);
                _msg.Append("Estimated number of sales order details:    ");
                _msg.Append(numSalesDetails.ToString("#,##0"));
                _msg.Append(Environment.NewLine);
                _msg.Append("Estimated number of internet order details: ");
                _msg.Append(numInternetSalesDetails.ToString("#,##0"));
                _msg.Append(Environment.NewLine);
                _msg.Append("Estimated number of reseller order details: ");
                _msg.Append(numResellerSalesDetails.ToString("#,##0"));
                _msg.Append(Environment.NewLine);

                minNum = AppTextGlobals.ConvertStringToDouble(this.txtMinNumPurchaseOrdersPerDate.Text, 0.0);
                maxNum = AppTextGlobals.ConvertStringToDouble(this.txtMaxNumPurchaseOrdersPerDate.Text, 0.0);
                double numPurchaseTxs     = numDays * ((minNum + maxNum) / 2.0);
                double numPurchaseDetails = numPurchaseTxs * 2.0;

                _msg.Append("Estimated number of purchase order headers: ");
                _msg.Append(numPurchaseTxs.ToString("#,##0"));
                _msg.Append(Environment.NewLine);
                _msg.Append("Estimated number of purchase order details: ");
                _msg.Append(numPurchaseDetails.ToString("#,##0"));
                _msg.Append(Environment.NewLine);


                WriteToMessageLog(_msg.ToString());
                AppMessages.DisplayInfoMessage(_msg.ToString());
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                ;
            }
        }