private bool ValidateParameters()
 {
     try
     {
         int temp;
         if (string.IsNullOrEmpty(txtReceiveTimeout.Text) ||
             !int.TryParse(txtReceiveTimeout.Text, out temp) ||
             temp < 0)
         {
             writeToLog(ReceiveTimeoutCannotBeNull);
             return(false);
         }
         receiveTimeout = temp;
         if (string.IsNullOrEmpty(txtSessionTimeout.Text) ||
             !int.TryParse(txtSessionTimeout.Text, out temp) ||
             temp < 0)
         {
             writeToLog(SessionTimeoutCannotBeNull);
             return(false);
         }
         sessionTimeout = temp;
         if (string.IsNullOrEmpty(txtPrefetchCount.Text) ||
             !int.TryParse(txtPrefetchCount.Text, out temp))
         {
             writeToLog(PrefetchCountCannotBeNull);
             return(false);
         }
         prefetchCount = temp;
         if (!int.TryParse(txtReceiveBatchSize.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiverBatchSizeMustBeANumber);
             return(false);
         }
         receiverBatchSize = temp;
         if (!int.TryParse(txtReceiveTaskCount.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiveTaskCountMustBeANumber);
             return(false);
         }
         receiverTaskCount = temp;
         var sqlFilter = new SqlFilter(!string.IsNullOrEmpty(txtFilterExpression.Text)
                                                           ? txtFilterExpression.Text
                                                           : DefaultFilterExpression);
         sqlFilter.Validate();
         filter = sqlFilter.Preprocess();
         if (filter == null)
         {
             writeToLog(FilterExpressionIsNotValid);
         }
     }
     catch (Exception ex)
     {
         HandleException(ex);
         return(false);
     }
     return(true);
 }
 private void pictFindDeadletter_Click(object sender, EventArgs e)
 {
     try
     {
         deadletterDataGridView.SuspendDrawing();
         deadletterDataGridView.SuspendLayout();
         if (deadletterBindingList == null)
         {
             return;
         }
         using (var form = new TextForm(FilterExpressionTitle, FilterExpressionLabel, deadletterFilterExpression))
         {
             form.Size = new Size(600, 200);
             if (form.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             deadletterFilterExpression = form.Content;
             if (string.IsNullOrWhiteSpace(deadletterFilterExpression))
             {
                 deadletterBindingSource.DataSource = deadletterBindingList;
                 deadletterDataGridView.DataSource = deadletterBindingSource;
                 writeToLog(FilterExpressionRemovedMessage);
             }
             else
             {
                 Filter filter;
                 try
                 {
                     var sqlFilter = new SqlFilter(deadletterFilterExpression);
                     sqlFilter.Validate();
                     filter = sqlFilter.Preprocess();
                 }
                 catch (Exception ex)
                 {
                     writeToLog(string.Format(FilterExpressionNotValidMessage, deadletterFilterExpression, ex.Message));
                     return;
                 }
                 var filteredList = deadletterBindingList.Where(filter.Match).ToList();
                 var bindingList = new SortableBindingList<BrokeredMessage>(filteredList)
                 {
                     AllowEdit = false,
                     AllowNew = false,
                     AllowRemove = false
                 };
                 deadletterBindingSource.DataSource = bindingList;
                 deadletterDataGridView.DataSource = deadletterBindingSource;
                 writeToLog(string.Format(FilterExpressionAppliedMessage, deadletterFilterExpression, bindingList.Count));
             }
         }
     }
     catch (Exception ex)
     {
         HandleException(ex);
     }
     finally
     {
         deadletterDataGridView.ResumeLayout();
         deadletterDataGridView.ResumeDrawing();
     }
 }
 private bool ValidateParameters()
 {
     try
     {
         if (string.IsNullOrWhiteSpace(txtMessageText.Text))
         {
             writeToLog(MessageCannotBeNull);
             return false;
         }
         int temp;
         if (string.IsNullOrWhiteSpace(txtReceiveTimeout.Text) ||
             !int.TryParse(txtReceiveTimeout.Text, out temp) ||
             temp < 0)
         {
             writeToLog(ReceiveTimeoutCannotBeNull);
             return false;
         }
         receiveTimeout = temp;
         if (string.IsNullOrWhiteSpace(txtServerTimeout.Text) ||
             !int.TryParse(txtServerTimeout.Text, out temp) ||
             temp < 0)
         {
             writeToLog(SessionTimeoutCannotBeNull);
             return false;
         }
         sessionTimeout = temp;
         if (string.IsNullOrWhiteSpace(txtPrefetchCount.Text) ||
             !int.TryParse(txtPrefetchCount.Text, out temp))
         {
             writeToLog(PrefetchCountCannotBeNull);
             return false;
         }
         prefetchCount = temp;
         if (!int.TryParse(txtMessageCount.Text, out temp) || temp < 0)
         {
             writeToLog(MessageCountMustBeANumber);
             return false;
         }
         messageCount = temp;
         if (!int.TryParse(txtSendBatchSize.Text, out temp) || temp <= 0)
         {
             writeToLog(SenderBatchSizeMustBeANumber);
             return false;
         }
         senderBatchSize = temp;
         if (!int.TryParse(txtReceiveBatchSize.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiverBatchSizeMustBeANumber);
             return false;
         }
         receiverBatchSize = temp;
         if (!int.TryParse(txtSenderThinkTime.Text, out temp) || temp <= 0)
         {
             writeToLog(SenderThinkTimeMustBeANumber);
             return false;
         }
         senderThinkTime = temp;
         if (!int.TryParse(txtReceiverThinkTime.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiverThinkTimeMustBeANumber);
             return false;
         }
         receiverThinkTime = temp;
         if (!int.TryParse(txtSendTaskCount.Text, out temp) || temp <= 0)
         {
             writeToLog(SendTaskCountMustBeANumber);
             return false;
         }
         senderTaskCount = temp;
         if (!int.TryParse(txtReceiveTaskCount.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiveTaskCountMustBeANumber);
             return false;
         }
         receiverTaskCount = temp;
         var sqlFilter = new SqlFilter(!string.IsNullOrWhiteSpace(txtFilterExpression.Text)
                                                           ? txtFilterExpression.Text
                                                           : DefaultFilterExpression);
         sqlFilter.Validate();
         filter = sqlFilter.Preprocess();
         if (filter == null)
         {
             writeToLog(FilterExpressionIsNotValid);
         }
         if (messageTabControl.SelectedIndex == FilesTabPage)
         {
             var fileList = messageFileListView.Items.Cast<ListViewItem>()
                         .Where(i => i.Checked)
                         .Select(i => i.Text)
                         .ToList();
             if (fileList.Count == 0)
             {
                 writeToLog(NoMessageSelected);
                 return false;
             }
         }
         if (messageTabControl.SelectedIndex == GeneratorTabPage && cboBrokeredMessageGeneratorType.SelectedIndex < 1)
         {
             writeToLog(string.Format(SelectBrokeredMessageGeneratorWarning, topic.Path));
             return false;
         }
     }
     catch (Exception ex)
     {
         HandleException(ex);
         return false;
     }
     return true;
 }
 private bool ValidateParameters()
 {
     try
     {
         if (string.IsNullOrEmpty(txtMessageText.Text))
         {
             writeToLog(MessageCannotBeNull);
             return false;
         }
         int temp;
         if (string.IsNullOrEmpty(txtReceiveTimeout.Text) ||
             !int.TryParse(txtReceiveTimeout.Text, out temp) ||
             temp <= 0)
         {
             writeToLog(ReceiveTimeoutCannotBeNull);
             return false;
         }
         receiveTimeout = temp;
         if (string.IsNullOrEmpty(txtSessionTimeout.Text) ||
             !int.TryParse(txtSessionTimeout.Text, out temp) ||
             temp <= 0)
         {
             writeToLog(SessionTimeoutCannotBeNull);
             return false;
         }
         sessionTimeout = temp;
         if (string.IsNullOrEmpty(txtPrefetchCount.Text) ||
             !int.TryParse(txtPrefetchCount.Text, out temp))
         {
             writeToLog(PrefetchCountCannotBeNull);
             return false;
         }
         prefetchCount = temp;
         if (!int.TryParse(txtMessageCount.Text, out temp) || temp < 0)
         {
             writeToLog(MessageCountMustBeANumber);
             return false;
         }
         messageCount = temp;
         if (!int.TryParse(txtSendTaskCount.Text, out temp) || temp <= 0)
         {
             writeToLog(SendTaskCountMustBeANumber);
             return false;
         }
         senderTaskCount = temp;
         if (!int.TryParse(txtReceiveTaskCount.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiveTaskCountMustBeANumber);
             return false;
         }
         receiverTaskCount = temp;
         var sqlFilter = new SqlFilter(!string.IsNullOrEmpty(txtFilterExpression.Text)
                                                           ? txtFilterExpression.Text
                                                           : DefaultFilterExpression);
         sqlFilter.Validate();
         filter = sqlFilter.Preprocess();
         if (filter == null)
         {
             writeToLog(FilterExpressionIsNotValid);
         }
     }
     catch (Exception ex)
     {
         mainForm.HandleException(ex);
         return false;
     }
     return true;
 }
 private bool ValidateParameters()
 {
     try
     {
         int temp;
         if (string.IsNullOrWhiteSpace(txtReceiveTimeout.Text) ||
             !int.TryParse(txtReceiveTimeout.Text, out temp) ||
             temp < 0)
         {
             writeToLog(ReceiveTimeoutCannotBeNull);
             return false;
         }
         receiveTimeout = temp;
         if (string.IsNullOrWhiteSpace(txtServerTimeout.Text) ||
             !int.TryParse(txtServerTimeout.Text, out temp) ||
             temp < 0)
         {
             writeToLog(SessionTimeoutCannotBeNull);
             return false;
         }
         sessionTimeout = temp;
         if (string.IsNullOrWhiteSpace(txtPrefetchCount.Text) ||
             !int.TryParse(txtPrefetchCount.Text, out temp))
         {
             writeToLog(PrefetchCountCannotBeNull);
             return false;
         }
         prefetchCount = temp;
         if (!int.TryParse(txtReceiveBatchSize.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiverBatchSizeMustBeANumber);
             return false;
         }
         receiverBatchSize = temp;
         if (!int.TryParse(txtReceiverThinkTime.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiverThinkTimeMustBeANumber);
             return false;
         }
         receiverThinkTime = temp;
         if (!int.TryParse(txtReceiveTaskCount.Text, out temp) || temp <= 0)
         {
             writeToLog(ReceiveTaskCountMustBeANumber);
             return false;
         }
         receiverTaskCount = temp;
         
         var sqlFilter = new SqlFilter(!string.IsNullOrWhiteSpace(txtFilterExpression.Text)
                                                           ? txtFilterExpression.Text
                                                           : DefaultFilterExpression);
         sqlFilter.Validate();
         filter = sqlFilter.Preprocess();
         if (filter == null)
         {
             writeToLog(FilterExpressionIsNotValid);
         }
     }
     catch (Exception ex)
     {
         HandleException(ex);
         return false;
     }
     return true;
 }