private void ValidateToSchema()
        {
            HourGlass.Start();
            var error = new StringBuilder(1024 * 1024 * 6);
            InstrumentDescription instrument = InstrumentDescription;

            try
            {
                if (!SchemaManager.ValidateXml(instrument.Serialize(), ATMLCommon.InstrumentNameSpace, error))
                {
                    HourGlass.Stop();
                    string name = GetName(instrument);
                    ATMLErrorForm.ShowValidationMessage(
                        string.Format("The \"{0}\" Instrument has failed validation against the {1} ATML schema.", name,
                                      ATMLCommon.InstrumentNameSpace),
                        error.ToString(), "Note: This error will not prevent you from continuing.");
                }
                else
                {
                    HourGlass.Stop();
                    MessageBox.Show(@"This Instrument generated valid ATML");
                }
            }
            catch (Exception)
            {
                HourGlass.Stop();
            }
        }
    static int hourglassSum2(int[][] arr)
    {
        int rows    = arr.Length;
        int columns = arr[0].Length;
        int maxSum  = int.MinValue;
        List <HourGlass> hourGlasses = new List <HourGlass>();

        for (int i = 0; i < rows - 2; i++)
        {
            for (int j = 0; j < columns - 2; j++)
            {
                HourGlass hrgs = new HourGlass();
                int       sum  = arr[i][j] + arr[i][j + 1] + arr[i][j + 2];
                sum           += arr[i + 2][j] + arr[i + 2][j + 1] + arr[i + 2][j + 2];
                sum           += arr[i + 1][j + 1];
                hrgs.Summation = sum;
                hourGlasses.Add(hrgs);
                maxSum = Math.Max(maxSum, hrgs.Summation);
            }
        }

        int x = 0;

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                Console.Write(hourGlasses[x].Summation + " ");
                x++;
            }
            Console.WriteLine();
        }

        return(maxSum);
    }
Esempio n. 3
0
        private void OpenSelectedStockTypes()
        {
            List <int>     lst   = new List <int>();
            string         title = this.CreateQuickViewTitle();
            string         tag   = this.CreateQuickViewTag();
            WinFormSession sess  = (WinFormSession)this.Project.Library.Session;

            if (sess.Application.GetView(tag) != null)
            {
                sess.Application.ActivateView(tag);
            }
            else
            {
                using (HourGlass h = new HourGlass())
                {
                    FlowPathwayDiagram d = this.GetFlowDiagram();

                    foreach (StockTypeShape s in d.SelectedShapes)
                    {
                        lst.Add(s.StockTypeId);
                    }

                    StockTypeQuickView v = (StockTypeQuickView)this.Session.CreateDataFeedView(
                        typeof(StockTypeQuickView), this.Library, this.Project, this.Scenario, null);

                    v.LoadStockTypes(this.DataFeed, lst);
                    sess.Application.HostView(v, title, tag);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private void SearchFile()
        {
            LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];

            SearchCriteria sc = new SearchCriteria();

            sc.Type    = (Global.SearchType)dropdownSearchType.SelectedIndex;
            sc.Pattern = textSearch.Text;
            sc.Id      = lf.Searches.Add(sc, toolButtonCumulative.Checked);

            if (sc.Id == 0)
            {
                UserInterface.DisplayMessageBox(this, "The search pattern already exists", MessageBoxIcon.Exclamation);
                return;
            }

            // Add the ID so that any matches show up straight away
            lf.FilterIds.Add(sc.Id);

            this.processing = true;
            this.hourGlass  = new HourGlass(this);
            SetProcessingState(false);
            statusProgress.Visible       = true;
            this.cancellationTokenSource = new CancellationTokenSource();
            lf.Search(sc, toolButtonCumulative.Checked, cancellationTokenSource.Token, config.NumContextLines);
        }
Esempio n. 5
0
        /**
         * Physically remove the project from the project folder. The project must be opened
         * on order to delete it. If the user accepts the verification to delete the project
         * the project will be unloaded then all folders and files will be removed. This process
         * does NOT remove any related files from the document library.
         */
        public static void DeleteProject()
        {
            TestProgramSet testSet = Instance.CurrentTestProgramSet;

            if (testSet != null)
            {
                string testSetName = testSet.TestSetName;
                string fullName    = testSet.TestSetDirectory.FullName;
                if (DialogResult.Yes ==
                    MessageBox.Show(
                        string.Format("Are you sure you want to delete Test Set Project \"{0}\"?", testSetName),
                        @"V E R I F Y",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    HourGlass.Start();
                    try
                    {
                        CloseProject();
                        GC.Collect();
                        if (FileManager.DeleteDirectory(fullName, true))
                        {
                            LogManager.Trace("Test Set Project \"{0}\" has been deleted.", testSetName);
                        }
                    }
                    catch (Exception err)
                    {
                        LogManager.Error(err.Message);
                    }
                    finally
                    {
                        HourGlass.Stop();
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuToolsMultiStringSearch_Click(object sender, EventArgs e)
        {
            LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];

            using (FormSearch f = new FormSearch(lf.Searches))
            {
                DialogResult dr = f.ShowDialog(this);
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Clear any existing filter ID's as we will only show the multi-string search
                lf.FilterIds.Clear();
                lf.Searches.Reset();
                foreach (SearchCriteria sc in f.NewSearches)
                {
                    // Add the ID so that any matches show up straight away
                    lf.FilterIds.Add(sc.Id);
                    lf.Searches.Add(sc);
                }

                this.processing = true;
                this.hourGlass  = new HourGlass(this);
                SetProcessingState(false);
                statusProgress.Visible       = true;
                this.cancellationTokenSource = new CancellationTokenSource();
                lf.SearchMulti(f.NewSearches, cancellationTokenSource.Token, config.NumContextLines);
            }
        }
Esempio n. 7
0
        private void OnRastersValidated(object sender, EventArgs e)
        {
            this.Session.Application.SetStatusMessage(string.Empty);

            this.m_HourGlass.Dispose();
            this.m_HourGlass = null;
        }
Esempio n. 8
0
        private void OnValidatingRasters(object sender, EventArgs e)
        {
            this.Session.Application.SetStatusMessage("Validating rasters...");

            Application.DoEvents();
            this.m_HourGlass = new HourGlass();
        }
 private void btnValidate_Click(object sender, EventArgs e)
 {
     try
     {
         HourGlass.Start();
         var error = new StringBuilder(1024 * 1024 * 6);
         if (!SchemaManager.ValidateXml(atmlPreviewPanel.Text, ATMLCommon.TestDescriptionNameSpace, error))
         {
             HourGlass.Stop();
             ATMLErrorForm.ShowValidationMessage(
                 string.Format("The Test Description has failed validation against the ATML schema."),
                 error.ToString(),
                 "Note: This error will not prevent you from continuing.");
         }
         else
         {
             HourGlass.Stop();
             MessageBox.Show(@"This Test Description has generated a valid ATML document.");
         }
     }
     finally
     {
         HourGlass.Stop();
     }
 }
Esempio n. 10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private void SearchFile()
        {
            SearchCriteria sc = new SearchCriteria();

            sc.Type    = (Global.SearchType)dropdownSearchType.SelectedIndex;
            sc.Pattern = textSearch.Text;
            sc.Id      = searches.Add(sc, toolButtonCumulative.Checked);

            if (sc.Id == 0)
            {
                UserInterface.DisplayMessageBox(this, "The search pattern already exists", MessageBoxIcon.Exclamation);
                return;
            }

            //if (logs.ContainsKey(currentTabIndex) == false)
            //{
            //    UserInterface.DisplayMessageBox(this, "Log file not available", MessageBoxIcon.Exclamation);
            //    return;
            //}

            //// Add the ID so that any matches show up straight away
            //logs[currentTabIndex].FilterIds.Add(sc.Id);

            //filterIds.Add(sc.Id);

            this.processing = true;
            this.hourGlass  = new HourGlass(this);
            SetProcessingState(false);
            statusProgress.Visible = true;
            // this.cancellationTokenSource = new CancellationTokenSource();
            //lf.Search(sc, toolButtonCumulative.Checked, cancellationTokenSource.Token, config.NumContextLines);
            // logs[currentTabIndex].Search(sc, toolButtonCumulative.Checked, cancellationTokenSource.Token, config.NumContextLines);
        }
Esempio n. 11
0
        private void SetICSpatialFile(int rowIndex, int colIndex, string rasterFullFilename)
        {
            try
            {
                this.m_AllowColumnEdits = true;

                using (HourGlass h = new HourGlass())
                {
                    DataSheet            ds      = this.Scenario.GetDataSheet(Strings.DATASHEET_SPIC_NAME);
                    DataGridViewEditMode OldMode = this.m_FilesDataGrid.EditMode;

                    this.m_FilesDataGrid.EditMode    = DataGridViewEditMode.EditProgrammatically;
                    this.m_FilesDataGrid.CurrentCell = this.m_FilesDataGrid.Rows[rowIndex].Cells[colIndex];

                    this.m_FilesDataGrid.BeginEdit(false);
                    this.m_FilesDataGrid.EditingControl.Text = Path.GetFileName(rasterFullFilename);
                    this.m_FilesDataGrid.EndEdit();

                    this.m_FilesDataGrid.CurrentCell = this.m_FilesDataGrid.Rows[rowIndex].Cells[colIndex + 1];
                    this.m_FilesDataGrid.EditMode    = OldMode;

                    ds.AddExternalInputFile(rasterFullFilename);
                }
            }
            finally
            {
                this.m_AllowColumnEdits = false;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Chooses a new raster file
        /// </summary>
        /// <remarks>
        /// Just store the filename. For now, no path required. In the future may want to support absolute path, differentiated by x:\\
        /// </remarks>
        private void ChooseRasterFile(int rowIndex, int colIndex)
        {
            string FileName = RasterUtilities.ChooseRasterFileName("Initial Conditions Raster File", this);

            if (FileName == null)
            {
                return;
            }

            Application.DoEvents();

            using (HourGlass h = new HourGlass())
            {
                try
                {
                    StochasticTimeRaster rast = new StochasticTimeRaster(FileName, RasterDataType.DTInteger);

                    if (colIndex == PRIMARY_STRATUM_FILE_NAME_COLUMN_INDEX && rast.Projection == null)
                    {
                        const string msg = "There is no projection associated with this raster file. The model will still run but outputs will also have no projection.";
                        FormsUtilities.InformationMessageBox(msg);
                    }

                    SetICSpatialFile(rowIndex, colIndex, FileName);
                }
                catch (Exception e)
                {
                    FormsUtilities.ErrorMessageBox(e.Message);
                    return;
                }
            }
        }
Esempio n. 13
0
        private void GetMultiplierFile(int rowIndex)
        {
            if (!this.m_IsEnabled)
            {
                return;
            }

            DataSheet ds         = this.Scenario.GetDataSheet(Strings.DATASHEET_TRANSITION_SPATIAL_MULTIPLIER_NAME);
            string    RasterFile = RasterUtilities.ChooseRasterFileName("Transition Spatial Mulitplier Raster File", this);

            if (RasterFile == null)
            {
                return;
            }

            using (HourGlass h = new HourGlass())
            {
                DataGridViewEditMode OldMode = this.m_MultipliersDataGrid.EditMode;

                this.m_MultipliersDataGrid.EditMode    = DataGridViewEditMode.EditProgrammatically;
                this.m_MultipliersDataGrid.CurrentCell = this.m_MultipliersDataGrid.Rows[rowIndex].Cells[FILE_NAME_COLUMN_INDEX];
                this.m_MultipliersDataGrid.Rows[rowIndex].Cells[FILE_NAME_COLUMN_INDEX].Value = Path.GetFileName(RasterFile);
                this.m_MultipliersDataGrid.NotifyCurrentCellDirty(true);
                this.m_MultipliersDataGrid.BeginEdit(false);
                this.m_MultipliersDataGrid.EndEdit();
                this.m_MultipliersDataGrid.CurrentCell = this.m_MultipliersDataGrid.Rows[rowIndex].Cells[BROWSE_COLUMN_INDEX];

                ds.AddExternalInputFile(RasterFile);
                this.m_MultipliersDataGrid.EditMode = OldMode;
            }
        }
Esempio n. 14
0
        private void awbDropListTree_SignalSelected(object sender, XmlDocument tsfDocument)
        {
            var signal = sender as dbSignal;

            _currentSignalModel = sender as SignalModel;
            try
            {
                HourGlass.Start();
                Clear();
                if (!LoadSignalModel(signal))
                {
                    if (!LoadSignalModel(_currentSignalModel))
                    {
                        XmlNode node = SignalManager.Instance.SignalTree.SelectSingleNode("");
                        //--- ============================================================ ---//
                        //--- TODO: Determine what to do if the Signal Model does not load ---//
                        //--- ============================================================ ---//
                    }
                }
            }
            finally
            {
                HourGlass.Stop();
            }
        }
    // Complete the hourglassSum function below.
    static int hourglassSum(int[][] arr)
    {
        int maxSum = int.MinValue;
        List <HourGlass> hourGlasses = new List <HourGlass>();

        for (int i = 0, k = 2; i < 4 && k < 6; i++, k++)
        {
            int middleIndex  = 1;
            int topRowSum    = 0;
            int bottomRowSum = 0;
            for (int j = 0; j < 6; j++)
            {
                HourGlass hrgs = new HourGlass();
                if (j < 2)
                {
                    topRowSum    += arr[i][j];
                    bottomRowSum += arr[k][j];
                    continue;
                }
                else if (j == 2)
                {
                    hrgs          = new HourGlass();
                    topRowSum    += arr[i][j];
                    bottomRowSum += arr[k][j];

                    hrgs.topRowSum    = topRowSum;
                    hrgs.bottomRowSum = bottomRowSum;
                    hrgs.middleInt    = arr[i + 1][middleIndex];
                }
                else
                {
                    middleIndex++;
                    hrgs         = new HourGlass();
                    topRowSum    = topRowSum + arr[i][j] - arr[i][j - 3];
                    bottomRowSum = bottomRowSum + arr[k][j] - arr[k][j - 3];

                    hrgs.topRowSum    = topRowSum;
                    hrgs.bottomRowSum = bottomRowSum;
                    hrgs.middleInt    = arr[i + 1][middleIndex];
                }
                hourGlasses.Add(hrgs);
                maxSum = Math.Max(maxSum, hrgs.Sum);
            }
        }

        int x = 0;

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                Console.Write(hourGlasses[x].Sum + " ");
                x++;
            }
            Console.WriteLine();
        }

        return(maxSum);
    }
Esempio n. 16
0
        /// <summary>
        ///
        /// </summary>
        private void LoadSensors()
        {
            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);
            listSensors.ClearObjects();

            _querier.QuerySensors();
        }
Esempio n. 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="page"></param>
        private void LoadEvents(long page)
        {
            _currentPage = page;
            _hourGlass   = new HourGlass(this);
            SetProcessingStatus(false);
            Clear();

            _querier.QueryEvents((_currentPage - 1) * _pageLimit, _pageLimit + 1);
        }
Esempio n. 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="page"></param>
        private void LoadSearch(long page)
        {
            if (_filters == null)
            {
                return;
            }

            _currentPage = page;
            _hourGlass   = new HourGlass(this);
            SetProcessingStatus(false);
            Clear();

            try
            {
                string condition = string.Empty;
                switch (cboSearch.SelectedIndex)
                {
                case 0:
                    condition = " OR ";
                    break;

                case 1:
                    condition = " AND ";
                    break;
                }

                List <object> args = new List <object>();
                string where = "(";
                for (int index = 0; index < _filters.Count; index++)
                {
                    Filter           filter           = _filters[index];
                    FilterDefinition filterDefinition = filter.Definition;

                    if (index == 0)
                    {
                        where += string.Format(" {0} {1} @{2}", filterDefinition.ColumnName, filter.Condition, index);
                    }
                    else
                    {
                        where += string.Format(" {0} {1} {2} @{3}", condition, filterDefinition.ColumnName, filter.Condition, index);
                    }

                    args.Add(filter.Value);
                }

                where = where + ") LIMIT @" + _filters.Count + ", @" + (_filters.Count + 1);
                args.Add((_currentPage - 1) * _pageLimit);
                args.Add(_pageLimit + 1);

                _querier.QuerySearch(where, args.ToArray());
            }
            catch (Exception ex)
            {
                UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst generating the query: " + ex.Message);
            }
        }
Esempio n. 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        private void ExportSelected(string filePath)
        {
            this.processing = true;
            this.hourGlass  = new HourGlass(this);
            SetProcessingState(false);
            statusProgress.Visible = true;
            //  this.cancellationTokenSource = new CancellationTokenSource();

            //lf.Export(listLines.SelectedObjects, filePath, cancellationTokenSource.Token);
        }
Esempio n. 20
0
        private void ButtonClear_Click(object sender, System.EventArgs e)
        {
            using (HourGlass h = new HourGlass())
            {
                DataSheet ds = GetDataSheet();

                ds.ClearData();
                this.RefreshControls();
                this.EnableButtons();
            }
        }
Esempio n. 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private void LoadFile(string filePath, bool newTab)
        {
            this.processing = true;
            this.hourGlass  = new HourGlass(this);
            SetProcessingState(false);
            statusProgress.Visible             = true;
            this.cancellationTokenSource       = new CancellationTokenSource();
            menuToolsMultiStringSearch.Enabled = true;

            // Clear any existing filters/reset values
            //
            this.searches = new Searches();

            if (newTab == true)
            {
                LogFile lf = new LogFile();
                logs.Add(lf.Guid, lf);

                tabControl.TabPages.Add(lf.Initialise());
                lf.SetContextMenu(contextMenu);
                lf.ViewMode           = Global.ViewMode.Standard;
                lf.ProgressUpdate    += LogFile_LoadProgress;
                lf.LoadComplete      += LogFile_LoadComplete;
                lf.SearchComplete    += LogFile_SearchComplete;
                lf.ExportComplete    += LogFile_ExportComplete;
                lf.LoadError         += LogFile_LoadError;
                lf.List.ItemActivate += new EventHandler(this.listLines_ItemActivate);
                lf.List.DragDrop     += new DragEventHandler(this.listLines_DragDrop);
                lf.List.DragEnter    += new DragEventHandler(this.listLines_DragEnter);
                lf.Load(filePath, synchronizationContext, cancellationTokenSource.Token);
            }
            else
            {
                if (tabControl.SelectedTab == null)
                {
                    UserInterface.DisplayMessageBox(this, "Cannot identify current tab", MessageBoxIcon.Exclamation);
                    return;
                }

                if (!logs.ContainsKey(tabControl.SelectedTab.Tag.ToString()))
                {
                    UserInterface.DisplayMessageBox(this, "Cannot identify current tab", MessageBoxIcon.Exclamation);
                    return;
                }

                // Get the current selected log file and open the file using that object
                LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];
                lf.Dispose();
                lf.Load(filePath, synchronizationContext, cancellationTokenSource.Token);
            }

            // this.Text = "LogViewer - " + filePath;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            if (txtOutputFile.Text.Trim().Length == 0)
            {
                UserInterface.DisplayMessageBox(this, "The output file must be selected", MessageBoxIcon.Exclamation);
                btnOutputFile.Select();
                return;
            }

            bool text = false;

            if (cboFormat.SelectedIndex == 0)
            {
                text = true;
            }

            _hourGlass = new HourGlass(this);

            if (dtpDateTo.Checked == true)
            {
                if (txtInitials.Text.Trim().Length == 0)
                {
                    _exporter.ExportAcknowledgmentsFromToAll(txtOutputFile.Text,
                                                             dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                             dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                                             text);
                }
                else
                {
                    _exporter.ExportAcknowledgmentsFromTo(txtOutputFile.Text,
                                                          dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                          dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                                          txtInitials.Text,
                                                          text);
                }
            }
            else
            {
                if (txtInitials.Text.Trim().Length == 0)
                {
                    _exporter.ExportAcknowledgmentsFromAll(txtOutputFile.Text,
                                                           dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                           text);
                }
                else
                {
                    _exporter.ExportAcknowledgmentsFrom(txtOutputFile.Text,
                                                        dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                        txtInitials.Text,
                                                        text);
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        private void ExportSelected(string filePath)
        {
            this.processing = true;
            this.hourGlass  = new HourGlass(this);
            SetProcessingState(false);
            statusProgress.Visible       = true;
            this.cancellationTokenSource = new CancellationTokenSource();

            LogFile lf = logs[tabControl.SelectedTab.Tag.ToString()];

            lf.Export(lf.List.SelectedObjects, filePath, cancellationTokenSource.Token);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            if (txtOutputFile.Text.Trim().Length == 0)
            {
                UserInterface.DisplayMessageBox(this, "The output file must be selected", MessageBoxIcon.Exclamation);
                btnOutputFile.Select();
                return;
            }

            bool text = false;
            if (cboFormat.SelectedIndex == 0)
            {
                text = true;
            }

            _hourGlass = new HourGlass(this);

            if (dtpDateTo.Checked == true)
            {
                if (txtInitials.Text.Trim().Length == 0)
                {
                     _exporter.ExportAcknowledgmentsFromToAll(txtOutputFile.Text,
                                                              dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                              dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                                              text);
                }
                else
                {
                     _exporter.ExportAcknowledgmentsFromTo(txtOutputFile.Text,
                                                           dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                           dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                                           txtInitials.Text,
                                                           text);
                }
            }
            else
            {
                if (txtInitials.Text.Trim().Length == 0)
                {
                     _exporter.ExportAcknowledgmentsFromAll(txtOutputFile.Text,
                                                            dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                            text);
                }
                else
                {
                     _exporter.ExportAcknowledgmentsFrom(txtOutputFile.Text,
                                                         dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                         txtInitials.Text,
                                                         text);
                }
            }
        }
Esempio n. 25
0
        private void OnExecuteDeleteCommand(Command cmd)
        {
            if (FormsUtilities.ApplicationMessageBox(
                    "Are you sure you want to delete the selected stock types and associated flows?",
                    MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            using (HourGlass h = new HourGlass())
            {
                this.GetFlowDiagram().DeleteSelectedStockTypeShapes();
            }
        }
Esempio n. 26
0
 private void OnSelectedTabItemChanged(object sender, SelectedTabStripItemChangedEventArgs e)
 {
     using (HourGlass h = new HourGlass())
     {
         if (this.TabStripMain.SelectedItem == this.m_DiagramTab)
         {
             this.SwitchToDiagramView();
         }
         else
         {
             this.SwitchToGridView();
         }
     }
 }
Esempio n. 27
0
        public void HourGlassSolveTestCase1()
        {
            var inputArray = new int[6][];

            inputArray[0] = new int[] { 1, 1, 1, 0, 0, 0 };
            inputArray[1] = new int[] { 0, 1, 0, 0, 0, 0 };
            inputArray[2] = new int[] { 1, 1, 1, 0, 0, 0 };
            inputArray[3] = new int[] { 0, 0, 2, 4, 4, 0 };
            inputArray[4] = new int[] { 0, 0, 0, 2, 0, 0 };
            inputArray[5] = new int[] { 0, 0, 1, 2, 4, 0 };
            var outputArray = 19;
            int UniqueValue = HourGlass.Solve(inputArray);

            Assert.AreEqual(outputArray, UniqueValue);
        }
Esempio n. 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuToolsExcludesExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Title  = "Select the export CSV";
            saveFileDialog.Filter = "TSV Files|*.tsv";
            if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);

            _exporter.ExportExcludes(saveFileDialog.FileName);
        }
Esempio n. 29
0
 private void btnTranslateAIXML_Click(object sender, EventArgs e)
 {
     try
     {
         HourGlass.Start();
         _translator.TranslateAIXML();
     }
     catch (Exception err)
     {
         LogManager.SourceError(ATMLTranslator.SOURCE, err);
         throw;
     }
     finally
     {
         HourGlass.Stop();
     }
 }
Esempio n. 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        private void Export(string filePath)
        {
            this.processing = true;
            this.hourGlass  = new HourGlass(this);
            SetProcessingState(false);
            statusProgress.Visible = true;
            // this.cancellationTokenSource = new CancellationTokenSource();

            //if (listLines.ModelFilter == null)
            //{
            //    lf.Export(filePath, cancellationTokenSource.Token);
            //}
            //else
            //{
            //    lf.Export(listLines.FilteredObjects, filePath, cancellationTokenSource.Token);
            //}
        }
Esempio n. 31
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuFileImport_Click(object sender, EventArgs e)
        {
            using (FormImport formImport = new FormImport())
            {
                if (formImport.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                listEntries.ClearObjects();
                Helper.AutoResizeListColumns(listEntries);

                _hourGlass = new HourGlass(this);
                SetProcessingState(true);
                _importer.Start(_configuration, formImport.DriveMappings, formImport.RegistryPath, formImport.CatalogPath);
            }
        }
Esempio n. 32
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ctxMenuExtractIpInfoUniqueSourceList_Click(object sender, EventArgs e)
        {
            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);

            Signature rule = (Signature)cboRule.Items[cboRule.SelectedIndex];

            if (dtpDateTo.Checked == true)
            {
                _querier.QueryRuleIpsFromTo(rule.Id.ToString(),
                                            dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                            dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                            chkIncludeAcknowledged.Checked,
                                            true,
                                            false);
            }
            else
            {
                _querier.QueryRuleIpsFrom(rule.Id.ToString(),
                                          dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                          chkIncludeAcknowledged.Checked,
                                          true,
                                          false);
            }
        }
Esempio n. 33
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ctxMenuExportRules_Click(object sender, EventArgs e)
        {
            if (cboRule.Items.Count == 0)
            {
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Title = "Select the export CSV";
            saveFileDialog.Filter = "TSV Files|*.tsv";
            if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);

            List<Signature> sigs = new List<Signature>();
            foreach (Signature signature in cboRule.Items)
            {
                sigs.Add(signature);
            }

            _exporter.ExportRules(sigs, saveFileDialog.FileName);
        }
Esempio n. 34
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ctxMenuExportCurrent_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Title = "Select the export CSV";
            saveFileDialog.Filter = "TSV Files|*.tsv";
            if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);

            List<Event> events = (List<Event>)listEvents.Objects.Cast<Event>().ToList();
            _exporter.ExportEventCurrent(events, saveFileDialog.FileName);
        }
Esempio n. 35
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ctxMenuExportAll_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Title = "Select the export CSV";
            saveFileDialog.Filter = "TSV Files|*.tsv";
            if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);

            Signature rule = (Signature)cboRule.Items[cboRule.SelectedIndex];

            if (dtpDateTo.Checked == true)
            {
                _exporter.ExportEventsAll(saveFileDialog.FileName,
                                          dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                          dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                          rule.Sid);
            }
            else
            {
                _exporter.ExportEventsAll(saveFileDialog.FileName,
                                          dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                          rule.Sid);
            }
        }
Esempio n. 36
0
        /// <summary>
        /// 
        /// </summary>
        private void LoadRules()
        {
            if (cboPriority.SelectedIndex == -1)
            {
                UserInterface.DisplayMessageBox("The priority must be selected", MessageBoxIcon.Exclamation);
                return;
            }

            if (cboSensor.SelectedIndex == -1)
            {
                UserInterface.DisplayMessageBox("The sensor must be selected", MessageBoxIcon.Exclamation);
                return;
            }

            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);
            Clear();

            NameValue priority = (NameValue)cboPriority.Items[cboPriority.SelectedIndex];
            NameValue sensor = (NameValue)cboSensor.Items[cboSensor.SelectedIndex];

            if (dtpDateTo.Checked == true)
            {
                if (priority.Name.ToLower() == "all")
                {
                    _querier.QueryRulesFromTo(dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                              dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                              sensor.Value,
                                              chkIncludeAcknowledged.Checked,
                                              false);
                }
                else
                {
                    _querier.QueryRulesFromToPriority(dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                      dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                                      priority.Value,
                                                      sensor.Value,
                                                      chkIncludeAcknowledged.Checked,
                                                      false);
                }
            }
            else
            {
                if (priority.Name.ToLower() == "all")
                {
                    _querier.QueryRulesFrom(dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                            sensor.Value,
                                            chkIncludeAcknowledged.Checked,
                                            false);
                }
                else
                {
                    _querier.QueryRulesFromPriority(dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                    priority.Value,
                                                    sensor.Value,
                                                    chkIncludeAcknowledged.Checked,
                                                    false);
                }
            }
        }
Esempio n. 37
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="page"></param>
        private void LoadRuleEvents(long page)
        {
            MethodInvoker methodInvoker = delegate
            {
                _currentPage = page;
                _hourGlass = new HourGlass(this);
                SetProcessingStatus(false);
                Clear();

                if (cboRule.SelectedIndex == -1)
                {
                    UserInterface.DisplayMessageBox("No rule selected", MessageBoxIcon.Exclamation);
                    return;
                }

                Signature rule = (Signature)cboRule.Items[cboRule.SelectedIndex];

                if (dtpDateTo.Checked == true)
                {
                    _querier.QueryEventsRulesFromTo(dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                    dtpDateTo.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeTo.Text + ":00",
                                                    rule.Id.ToString(),
                                                    (_currentPage - 1) * _pageLimit,
                                                    _pageLimit,
                                                    chkIncludeAcknowledged.Checked);
                }
                else
                {
                    _querier.QueryEventsRulesFrom(dtpDateFrom.Value.Date.ToString("yyyy-MM-dd") + " " + cboTimeFrom.Text + ":00",
                                                  rule.Id.ToString(),
                                                  (_currentPage - 1) * _pageLimit,
                                                  _pageLimit,
                                                  chkIncludeAcknowledged.Checked);
                }
            };

            if (this.InvokeRequired == true)
            {
                this.BeginInvoke(methodInvoker);
            }
            else
            {
                methodInvoker.Invoke();
            }
        }
Esempio n. 38
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuToolsExcludesExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Title = "Select the export CSV";
            saveFileDialog.Filter = "TSV Files|*.tsv";
            if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);

            _exporter.ExportExcludes(saveFileDialog.FileName);
        }
Esempio n. 39
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="page"></param>
        private void LoadSearch(long page)
        {
            if (_filters == null)
            {
                return;
            }

            _currentPage = page;
            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);
            Clear();

            try
            {
                string condition = string.Empty;
                switch (cboSearch.SelectedIndex)
                {
                    case 0:
                        condition = " OR ";
                        break;
                    case 1:
                        condition = " AND ";
                        break;
                }

                List<object> args = new List<object>();
                string where = "(";
                for (int index = 0; index < _filters.Count; index++)
                {
                    Filter filter = _filters[index];
                    FilterDefinition filterDefinition = filter.Definition;

                    if (index == 0)
                    {
                        where += string.Format(" {0} {1} @{2}", filterDefinition.ColumnName, filter.Condition, index);
                    }
                    else
                    {
                        where += string.Format(" {0} {1} {2} @{3}", condition, filterDefinition.ColumnName, filter.Condition, index);
                    }

                    args.Add(filter.Value);
                }

                where = where + ") LIMIT @" + _filters.Count + ", @" + (_filters.Count + 1);
                args.Add((_currentPage - 1) * _pageLimit);
                args.Add(_pageLimit + 1);

                _querier.QuerySearch(where, args.ToArray());
            }
            catch (Exception ex)
            {
                UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst generating the query: " + ex.Message);
            }
        }
Esempio n. 40
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuExtractors_Click(object sender, EventArgs e)
        {
            string name = ((ToolStripMenuItem)sender).Tag.ToString();

            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            folderBrowserDialog.Description = "Select the output folder";

            if (folderBrowserDialog.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            string outputDirectory = folderBrowserDialog.SelectedPath;

            var temp = (from p in this.extractors where p.Name.ToLower() == name.ToLower() select p).SingleOrDefault();
            if (temp == null)
            {
                UserInterface.DisplayErrorMessageBox(this, "Unable to locate extractor");
                return;
            }

            _hourGlass = new HourGlass(this);

            Task task = Task.Factory.StartNew(() =>
            {
                this.extractor.Initialise(this._settings.Threads,
                                          temp,
                                          this.dataDirectory,
                                          outputDirectory);
                this.extractor.Start();

                foreach (Session session in listSession.Objects)
                {
                    extractor.Add(session);
                }

                extractor.SetProcessed();

            }, TaskCreationOptions.LongRunning);
        }
Esempio n. 41
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuFileImport_Click(object sender, EventArgs e)
        {
            using (FormImport formOpen = new FormImport())
            {
                if (formOpen.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                this.dataDirectory = formOpen.DatabaseFile;
                _hourGlass = new HourGlass(this);
                SetProcessingStatus(false);

                listSession.ClearObjects();

                _parser.IgnoreLocal = toolBtnRemoteOnly.Checked;
                _parser.BufferInterval = _settings.BufferInterval;
                _parser.SessionInterval = _settings.SessionInterval;

                _parser.ClearParsers();
                foreach (InterfaceParser parser in this.parsers)
                {
                    if (parser.Enabled == false)
                    {
                        continue;
                    }

                    _parser.SetParser(parser);
                }

                long maxSize = 0;
                switch (cboMaxSession.SelectedIndex)
                {
                    case 0: // None
                        break;
                    case 1: // 1 MB
                        maxSize = 1048576;
                        break;
                    case 2: // 2 MB
                        maxSize = 2097152;
                        break;
                    case 3: // 3 MB
                        maxSize = 3145728;
                        break;
                    case 4: // 4 MB
                        maxSize = 4194304;
                        break;
                    case 5: // 5 MB
                        maxSize = 5242880;
                        break;
                    case 6: // 10 MB
                        maxSize = 10485760;
                        break;
                    case 7: // 15 MB
                        maxSize = 15728640;
                        break;
                }

                _parser.Parse(formOpen.PcapFile, formOpen.DatabaseFile, maxSize);
            }
        }
Esempio n. 42
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="page"></param>
        private void LoadEvents(long page)
        {
            _currentPage = page;
            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);
            Clear();

            _querier.QueryEvents((_currentPage - 1) * _pageLimit, _pageLimit + 1);
        }
Esempio n. 43
0
        /// <summary>
        /// 
        /// </summary>
        private void LoadSensors()
        {
            _hourGlass = new HourGlass(this);
            SetProcessingStatus(false);
            listSensors.ClearObjects();

            _querier.QuerySensors();
        }