Beispiel #1
0
        // Queue Functionality testing
        public static void TestQueueQuery(ManagerConnection ami)
        {
            ResponseEvents re;

            try
            {
                re = ami.SendEventGeneratingAction(new QueueStatusAction());
            }
            catch (EventTimeoutException e)
            {
                re = e.PartialResult;
            }
            DebuggingTools.Dump("Starting");
            foreach (ManagerEvent ev in re.Events)
            {
                if (ev is QueueParamsEvent)
                {
                    ((QueueParamsEvent)ev).Dump();
                }
                if (ev is QueueMemberEvent)
                {
                    ((QueueMemberEvent)ev).Dump();
                }
                if (ev is QueueEntryEvent)
                {
                    ((QueueEntryEvent)ev).Dump();
                }
            }
            DebuggingTools.Dump("Finished");
        }
Beispiel #2
0
        public static void PullExtensions(ManagerConnection ami)
        {
            List <string> _siplines     = new List <string>();
            List <string> retrievedSips = new List <string>();
            Dictionary <string, PABXExtensionStatus> pabxStatuses = new Dictionary <string, PABXExtensionStatus>();

            //get initial extension list direct from PABX
            using (HttpClient n = new HttpClient())
            {
                string downloadString = "http://" + PABX.CurrentUser.host + "/if/windows_comms.php?u=" + PABX.CurrentUser.login + "&p=" + PABX.CurrentUser.password + "&extensionstatus=1";
                Console.WriteLine(downloadString);
                try
                {
                    string json = n.GetStringAsync(downloadString).Result; // use HTTPClient instead of WebClient, avoids crashing with larger PABX's. Result is required as it is a task
                    pabxStatuses = JsonConvert.DeserializeObject <Dictionary <string, PABXExtensionStatus> >(json);
                }
                catch
                {
                    MessageBox.Show("SmartPABX not up to date, please contact system admin.", "PABX Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            PABXExtensions.Clear();
            pabxStatuses.Keys.ToList().ForEach(e =>
            {
                Extension ext = new Extension();
                ext.Number    = Convert.ToInt32(e);
                ext.Comment   = pabxStatuses[e].comment;
                ext.Status    = Convert.ToInt32(pabxStatuses[e].status);
                ext.GroupId   = Convert.ToInt32(pabxStatuses[e].groupid);
                PABXExtensions.Add(ext);
            });
            DebuggingTools.VarDump(PABXExtensions);
        }
Beispiel #3
0
        /**
         * no confirmations are created and applied
         */
        private void StartTestCycle(SimulationInterval simulationInterval, bool shouldPersist)
        {
            Quantity customerOrderQuantity = new Quantity(ZppConfiguration.CacheManager
                                                          .GetTestConfiguration().CustomerOrderPartQuantity);


            // init transactionData
            ZppConfiguration.CacheManager.ReloadTransactionData();

            _customerOrderCreator = new CustomerOrderCreator(customerOrderQuantity);
            _customerOrderCreator.CreateCustomerOrders(simulationInterval, customerOrderQuantity);

            // execute mrp2
            Zpp.Mrp2.impl.Mrp2 mrp2 = new Zpp.Mrp2.impl.Mrp2(simulationInterval);
            mrp2.StartMrp2();

            DebuggingTools.PrintStateToFiles(simulationInterval,
                                             ZppConfiguration.CacheManager.GetDbTransactionData(), "", true);

            // no confirmations

            // persisting cached/created data
            if (shouldPersist)
            {
                ZppConfiguration.CacheManager.Persist();
            }
        }
Beispiel #4
0
        public static async void LoadContacts()
        {
            UserContacts = await PABXFile <Dictionary <string, UserContactData> > .LoadObjectAsync("contacts.json");

            DebuggingTools.VarDump(UserContacts);
            if (UserContacts == null)
            {
                UserContacts = new Dictionary <string, UserContactData>();
            }
        }
Beispiel #5
0
        private void ExecutePerformanceStudy(string testConfigurationFileName, bool shouldPersist)
        {
            PerformanceMonitor performanceMonitor = new PerformanceMonitor(InstanceToTrack.Global);
            // int maxPossibleCops = int.MaxValue / 100;
            int maxPossibleCops = 1000;

            ZppConfiguration.CacheManager.ReadInTestConfiguration(testConfigurationFileName);
            TestConfiguration testConfiguration =
                ZppConfiguration.CacheManager.GetTestConfiguration();
            int customerOrderCount = ZppConfiguration.CacheManager.GetTestConfiguration()
                                     .CustomerOrderPartQuantity;
            int customerOrderCountOriginal = customerOrderCount;
            int elapsedMinutes             = 0;
            int elapsedSeconds             = 0;
            int maxTime = 5;
            int cycles  = testConfiguration.SimulationMaximumDuration /
                          testConfiguration.SimulationInterval;

            string performanceLogLastCycles = "[";

            // n cycles here each cycle create & plan configured CustomerOrderPart
            while (customerOrderCount <= maxPossibleCops && elapsedMinutes < 5)
            {
                InitThisTest(testConfigurationFileName);

                IZppSimulator zppSimulator = new ZppSimulator.impl.ZppSimulator();
                performanceMonitor.Start();

                zppSimulator.StartPerformanceStudy(shouldPersist);
                performanceMonitor.Stop();
                if (performanceLogLastCycles.Length > 1)
                {
                    performanceLogLastCycles += ",";
                }
                performanceLogLastCycles += "{" + performanceMonitor.ToString();
                long currentMemoryUsage = Process.GetCurrentProcess().WorkingSet64;
                performanceLogLastCycles +=
                    $"\"CurrentMemoryUsage\": \"{currentMemoryUsage}\"" +
                    Environment.NewLine;
                performanceLogLastCycles += "}" + Environment.NewLine;

                customerOrderCount += customerOrderCountOriginal;
                testConfiguration.CustomerOrderPartQuantity = customerOrderCount;
            }
            // just for correct log name
            customerOrderCount -= customerOrderCountOriginal;
            testConfiguration.CustomerOrderPartQuantity = customerOrderCount;

            performanceLogLastCycles += "]";
            string logType = $"_{testConfiguration.Name}_cycles_{cycles}_COs_{testConfiguration.CustomerOrderPartQuantity}_lastCycles";

            ;
            DebuggingTools.WritePerformanceLog(performanceLogLastCycles, logType);
        }
Beispiel #6
0
        public void StartOneCycle(SimulationInterval simulationInterval,
                                  Quantity customerOrderQuantity)
        {
            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();

            _performanceMonitors.Start(InstanceToTrack.CreateCustomerOrders);
            _customerOrderCreator.CreateCustomerOrders(simulationInterval, customerOrderQuantity);
            _performanceMonitors.Stop(InstanceToTrack.CreateCustomerOrders);

            // Mrp2
            _performanceMonitors.Start(InstanceToTrack.Mrp2);
            Mrp2.impl.Mrp2 mrp2 = new Mrp2.impl.Mrp2(_performanceMonitors, simulationInterval);
            mrp2.StartMrp2();
            _performanceMonitors.Stop(InstanceToTrack.Mrp2);
            DebuggingTools.PrintStateToFiles(simulationInterval, dbTransactionData, "1_after_mrp2",
                                             true);

            // CreateConfirmations
            _performanceMonitors.Start(InstanceToTrack.CreateConfirmations);
            _confirmationManager.CreateConfirmations(simulationInterval);
            _performanceMonitors.Stop(InstanceToTrack.CreateConfirmations);
            DebuggingTools.PrintStateToFiles(simulationInterval, dbTransactionData,
                                             "2_after_create_confirmations", false);

            // ApplyConfirmations
            // TODO: disable these two lines

            /*DemandToProviderGraph demandToProviderGraph = new DemandToProviderGraph();
             * string demandToProviderGraphString = demandToProviderGraph.ToString();
             * ZppConfiguration.CacheManager.UseArchiveForGetters();
             * DemandToProviderGraph demandToProviderGraphArchive = new DemandToProviderGraph();
             * string demandToProviderGraphArchiveString = demandToProviderGraphArchive.ToString();
             * ZppConfiguration.CacheManager.UseArchiveForGettersRevert();*/

            _performanceMonitors.Start(InstanceToTrack.ApplyConfirmations);
            _confirmationManager.ApplyConfirmations();
            _performanceMonitors.Stop(InstanceToTrack.ApplyConfirmations);

            DebuggingTools.PrintStateToFiles(simulationInterval, dbTransactionData,
                                             "3_after_apply_confirmations", false);

            // TODO: disable following lines

            /* DemandToProviderGraph demandToProviderGraph2 = new DemandToProviderGraph();
             * string demandToProviderGraphString2 = demandToProviderGraph2.ToString();
             * /*ZppConfiguration.CacheManager.UseArchiveForGetters();
             * DemandToProviderGraph demandToProviderGraphArchive2 = new DemandToProviderGraph();
             * string demandToProviderGraphArchiveString2 = demandToProviderGraphArchive2.ToString();
             * ZppConfiguration.CacheManager.UseArchiveForGettersRevert();*/
        }
Beispiel #7
0
        public void StartPerformanceStudy(bool shouldPersist)
        {
            ZppConfiguration.IsInPerformanceMode = true;

            int maxSimulatingTime = ZppConfiguration.CacheManager.GetTestConfiguration()
                                    .SimulationMaximumDuration;
            int defaultInterval =
                ZppConfiguration.CacheManager.GetTestConfiguration().SimulationInterval;
            Quantity customerOrderQuantity = new Quantity(ZppConfiguration.CacheManager
                                                          .GetTestConfiguration().CustomerOrderPartQuantity);

            _customerOrderCreator = new CustomerOrderCreator(customerOrderQuantity);

            string performanceLogCycles = "[";

            _performanceMonitors.Start(InstanceToTrack.Global);

            for (int i = 0; i *defaultInterval <= maxSimulatingTime; i++)
            {
                SimulationInterval simulationInterval =
                    new SimulationInterval(i * defaultInterval, defaultInterval - 1);

                StartOneCycle(simulationInterval, customerOrderQuantity);

                if (ZppConfiguration.CacheManager.GetDbTransactionDataArchive()
                    .CustomerOrderPartGetAll().Count() > customerOrderQuantity.GetValue())
                {
                    break;
                }

                performanceLogCycles += _performanceMonitors.ToString() + ",";
            }

            _performanceMonitors.Stop(InstanceToTrack.Global);
            performanceLogCycles += $"{_performanceMonitors.ToString()}]";

            // DebuggingTools.PrintStateToFiles(dbTransactionData, true);
            DebuggingTools.WritePerformanceLog(performanceLogCycles);

            // persisting cached/created data
            if (shouldPersist)
            {
                ZppConfiguration.CacheManager.Persist();
            }
        }
Beispiel #8
0
        public void StartPerformanceStudy(bool shouldPersist)
        {
            ZppConfiguration.IsInPerformanceMode = true;

            int maxSimulatingTime = ZppConfiguration.CacheManager.GetTestConfiguration()
                                    .SimulationMaximumDuration;
            int defaultInterval =
                ZppConfiguration.CacheManager.GetTestConfiguration().SimulationInterval;
            Quantity customerOrderQuantity = new Quantity(ZppConfiguration.CacheManager
                                                          .GetTestConfiguration().CustomerOrderPartQuantity);

            _customerOrderCreator = new CustomerOrderCreator(customerOrderQuantity);

            string performanceLogCycles = "[";

            for (int i = 0; i *defaultInterval <= maxSimulatingTime; i++)
            {
                SimulationInterval simulationInterval =
                    new SimulationInterval(i * defaultInterval, defaultInterval - 1);

                StartOneCycle(simulationInterval, customerOrderQuantity);

                if (ZppConfiguration.CacheManager.GetDbTransactionDataArchive()
                    .CustomerOrderPartGetAll().Count() > customerOrderQuantity.GetValue())
                {
                    break;
                }
            }
            // TODO: here is no performance measure anymore, remove whole surounding method ?
            // DebuggingTools.PrintStateToFiles(dbTransactionData, true);
            DebuggingTools.WritePerformanceLog(performanceLogCycles);

            // persisting cached/created data
            if (shouldPersist)
            {
                ZppConfiguration.CacheManager.Persist();
            }
        }
 public void RenderPlayerState(Player player)
 {
     _text.text = DebuggingTools.PrintPlayerState(player.GetFrameState());
 }
Beispiel #10
0
        public MainWindow()
        {
            InitializeComponent();
#if DEBUG
            DebuggingTools DebuggingTools = new DebuggingTools();
            Debug.WriteLine("DEBUG MODE. DEBUGGING TOOLS HAVE BEEN INSTANTIATED");
#endif

            #region Checks wether the values of the settings are valid. If they aren't, set the default value
            if (Settings.Default.Language != "it" && Settings.Default.Language != "en")
            {
                Settings.Default.Language = "en";
                Settings.Default.Save();
                Settings.Default.Reload();
                Process.Start(Application.ResourceAssembly.Location); //Restart the application
                Application.Current.Shutdown(0);
            }
            if (ThemeManager.ThemeColors.Contains(Settings.Default.ThemeColor) == false)
            {
                Settings.Default.ThemeColor = ThemeManager.ThemeColors[0];
                Settings.Default.Save();
                Settings.Default.Reload();
                Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown(0);
            }
            if (ThemeManager.ThemeModes.Contains(Settings.Default.ThemeMode) == false)
            {
                Settings.Default.ThemeMode = ThemeManager.ThemeModes[0];
                Settings.Default.Save();
                Settings.Default.Reload();
                Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown(0);
            }
            if (Settings.Default.TempFolderPath == "" || Directory.Exists(Settings.Default.TempFolderPath) == false)
            {
                Directory.CreateDirectory($"{Path.GetTempPath()}ImageConverter");
                Settings.Default.TempFolderPath = $"{Path.GetTempPath()}ImageConverter";
                Settings.Default.Save();
                Settings.Default.Reload();
            }
            #endregion

            #region Apply theme type and themecolor
            MainWindowGrid.Background    = ThemeManager.SolidColorBrushOfThemeMode();
            TitleTextBox.Foreground      = ThemeManager.SolidColorBrushOfThemeColor();
            ThemeManager.solidColorBrush = new SolidColorBrush()
            {
                Color = ThemeManager.RunningOrStaticConversionTextBlockColor,
            };
            ConversionResultTextBlock.Foreground = ThemeManager.solidColorBrush;

            //Applies the selected theme color to every label's background in every ComboBox
            foreach (var control in OptionsStackPanel.Children)
            {
                foreach (var label in UtilityMethods.FindLabelsInComboBoxesInSPs(ref OptionsStackPanel))
                {
                    label.Background = ThemeManager.SolidColorBrushOfThemeColor();
                }
            }

            //If the selected ThemeMode is DarkTheme the ThemeColor will be applied to the text of all the labels in the options stackpanel
            if (Settings.Default.ThemeMode == "DarkTheme")
            {
                ThemeManager.ApplyThemeColorToLabelsInSP(ref OptionsStackPanel);
                ImagesNamesTextBlock.Foreground      = ThemeManager.SolidColorBrushOfThemeColor();
                ConversionResultTextBlock.Foreground = ThemeManager.SolidColorBrushOfThemeColor();
                IconSizesTextBlock.Foreground        = ThemeManager.SolidColorBrushOfThemeColor();
                foreach (CheckBox checkBox in IconSizesMatrixGrid.Children)
                {
                    checkBox.Foreground = ThemeManager.SolidColorBrushOfThemeColor();
                }
            }
            #endregion
            #region Hide some controls that should not viewable at the initial state of the app
            InsertNewImagesModeBttn.Source       = new BitmapImage(new System.Uri("pack://application:,,,/Resources/ReplaceImages.png"));
            ConversionResultTextBlock.Visibility = Visibility.Collapsed;
            WarningTextBlock.Text            = string.Empty;
            GifOptionsSP.Visibility          = Visibility.Collapsed;
            ReplaceTransparencySP.Visibility = Visibility.Collapsed;
            QualityOptionSP.Visibility       = Visibility.Collapsed;
            TiffOptionsSP.Visibility         = Visibility.Collapsed;
            IcoOptionsSP.Visibility          = Visibility.Collapsed;
            SavePathOptionSP.Visibility      = Visibility.Collapsed;
            #endregion
            #region Apply translation to all the visible controls
            if (Settings.Default.Language == "it")
            {
                ImgViewer.Source = new BitmapImage(new System.Uri("pack://application:,,,/Resources/ImageConverterDragAndDropIT.png"));
                StartConversionBttn.ButtonText      = LanguageManager.IT_StartConversionBttnText;
                ChooseFormatLabel.Content           = LanguageManager.IT_ChooseFormatLabelText;
                ConversionResultTextBlock.Text      = LanguageManager.IT_ConversionResultTextBlockRunning;
                GifRepeatTimes.Content              = LanguageManager.IT_GifRepeatTimesLabelText;
                EmptyImgViewerCntxtMenuBttn.Header  = LanguageManager.IT_ImageViewerContextMenuText;
                GifFramesDelayTimeLabel.Content     = LanguageManager.IT_GifFramesDelayTimeLabelText;
                InsertNewImagesModeBttn.ToolTip     = LanguageManager.IT_ReplaceExistingImagesToolTip;
                ReplacePngTransparencyLabel.Content = LanguageManager.IT_ReplacePngTransparencyLabelText;
                QualityLabel.Content         = LanguageManager.IT_QualityLabelText;
                CompressionAlgoLabel.Content = LanguageManager.IT_CompressionAlgoLabelText;
                ImageSavePathLabel.Content   = LanguageManager.IT_ImageSavePathLabelText;
                ChooseFolderBttn.Content     = LanguageManager.IT_ChooseFolderBttnText;
                IconSizesTextBlock.Text      = LanguageManager.IT_IconSizesTextBlockText;
                //Each item in the combobox that contains a series of colors to replace a png transparency with
                foreach (Label item in ReplTranspColCB.Items)
                {
                    switch (item.Content)
                    {
                    case "Nothing":
                        item.Content = LanguageManager.IT_Nothing;
                        break;

                    case "White":
                        item.Content = LanguageManager.IT_White;
                        break;

                    case "Black":
                        item.Content = LanguageManager.IT_Black;
                        break;

                    default:
                        return;
                    }
                }
            }
            else if (Settings.Default.Language == "en")
            {
                ImgViewer.Source = new BitmapImage(new System.Uri("pack://application:,,,/Resources/ImageConverterDragAndDropEN.png"));
                StartConversionBttn.ButtonText      = LanguageManager.EN_StartConversionBttnText;
                ChooseFormatLabel.Content           = LanguageManager.EN_ChooseFormatLabelText;
                ConversionResultTextBlock.Text      = LanguageManager.EN_ConversionResultTextBlockRunning;
                GifRepeatTimes.Content              = LanguageManager.EN_GifRepeatTimesLabelText;
                EmptyImgViewerCntxtMenuBttn.Header  = LanguageManager.EN_ImageViewerContextMenuText;
                GifFramesDelayTimeLabel.Content     = LanguageManager.EN_GifRepeatTimesLabelText;
                InsertNewImagesModeBttn.ToolTip     = LanguageManager.EN_ReplaceExistingImagesToolTip;
                ReplacePngTransparencyLabel.Content = LanguageManager.EN_ReplacePngTransparencyLabelText;
                QualityLabel.Content         = LanguageManager.EN_QualityLabelText;
                CompressionAlgoLabel.Content = LanguageManager.EN_CompressionAlgoLabelText;
                ImageSavePathLabel.Content   = LanguageManager.EN_ImageSavePathLabelText;
                ChooseFolderBttn.Content     = LanguageManager.EN_ChooseFolderBttnText;
                IconSizesTextBlock.Text      = LanguageManager.EN_IconSizesTextBlockText;
                //Each item in the combobox that contains a series of colors to replace a png transparency with
                foreach (Label item in ReplTranspColCB.Items)
                {
                    switch (item.Content)
                    {
                    case "Nothing":
                        item.Content = LanguageManager.EN_Nothing;
                        break;

                    case "White":
                        item.Content = LanguageManager.EN_White;
                        break;

                    case "Black":
                        item.Content = LanguageManager.EN_Black;
                        break;

                    default:
                        return;
                    }
                }
            }
            #endregion
        }