Beispiel #1
0
        /// <summary>
        /// Sprocket calls this method in response to ASP.Net's Error event, called when an unhandled
        /// exception is thrown.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void FireError(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            Exception       ex  = app.Server.GetLastError();

            ErrorNotifier.Process(ex);
            SystemEvents.Instance.NotifyExceptionThrown(ex);
            if (OnApplicationError != null)
            {
                OnApplicationError(ex);
            }
            if (SprocketSettings.Instance.HasErrors)
            {
                Core.Instance.Reset();
            }
        }
 public PredictorTypeInfo(Type predictorType, string displayName)
 {
     this.predictorType = predictorType;
     this.displayName   = displayName;
     try
     {
         predictorProperties = (List <PredictorPropertyBase>)PredictorType.InvokeMember("Properties", BindingFlags.GetField | BindingFlags.Static | BindingFlags.Public, null, null, null);
     }
     catch
     {
         ErrorNotifier.showError("Class \"" + predictorType.FullName + "\" is not implemented correctly.");
     }
     try
     {
         toolTipInfo = (string)PredictorType.InvokeMember("ToolTipInfo", BindingFlags.GetField | BindingFlags.Static | BindingFlags.Public, null, null, null);
     }
     catch
     {
         toolTipInfo = displayName + " Branch Predictor";
     }
 }
        /// <summary>
        ///     Runs all steps and user interaction that is required during the conversion
        /// </summary>
        public WorkflowResult RunWorkflow(Job job)
        {
            Job = job;
            try
            {
                try
                {
                    DoWorkflowWork();
                }
                catch (AbortWorkflowException ex)
                {
                    // we need to clean up the job when it was cancelled
                    _logger.Warn(ex.Message + " No output will be created.");
                    _workflowResult = WorkflowResult.AbortedByUser;
                }
            }
            catch (WorkflowException ex)
            {
                _logger.Error(ex.Message);
                _workflowResult = WorkflowResult.Error;
            }
            catch (ProcessingException ex)
            {
                _logger.Error("Error " + ex.ErrorCode + ": " + ex.Message);
                ErrorNotifier.Notify(new ActionResult(ex.ErrorCode));
                _workflowResult = WorkflowResult.Error;
            }
            catch (ManagePrintJobsException)
            {
                throw;
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _workflowResult = WorkflowResult.Error;
            }

            return(_workflowResult);
        }
Beispiel #4
0
 public IPredictor createPredictorInstance()
 {
     try
     {
         Assembly assembly = Assembly.GetExecutingAssembly();
         object   instance = assembly.CreateInstance(predictorTypeFullName, false, BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.Public, null, arguments, null, null);
         if (!(instance is IPredictor))
         {
             throw new Exception("Invalid PropertyInfo attributes. Instantiation is not possible.");
         }
         return(instance as IPredictor);
     }
     catch (OutOfMemoryException outOfMemoryException)
     {
         ErrorNotifier.showError("The Predictor " + predictorTypeFullName + " requires too much memory to be instatiated.");
         return(null);
     }
     catch (Exception e)
     {
         ErrorNotifier.showError(e.Message);
         return(null);
     }
 }
        /// <summary>
        /// Loads the application configuration from settings_server.ini file and creates one if it doesn't exist
        /// </summary>
        /// <returns>Returns false whenever an error occurs.</returns>
        public bool loadOptions()
        {
            try
            {
                PropertyFileHandler propertyFileHandler = new PropertyFileHandler(SERVER_SETTINGS_FILE_NAME);

                // path to benchmarks
                TracePathMain = propertyFileHandler.getPropertyValue("PathToBenchmarks", "");

                // ports
                string portsString = propertyFileHandler.getPropertyValue("ListeningPorts", "9050, 9051, 9052");

                string[] portsArray = portsString.Split(',');
                foreach (string portString in portsArray)
                {
                    int port;
                    if (int.TryParse(portString, out port))
                    {
                        listeningPorts.Add(port);
                    }
                }
                if (listeningPorts.Count == 0)
                {
                    ErrorNotifier.showError("No valid port numbers could be read from configuration file.");
                    return(false);
                }

                propertyFileHandler.save(); // this will create the file if it didn't exist
                return(true);
            }
            catch (Exception e)
            {
                ErrorNotifier.showError("Couldn't read options from disk: " + e.Message);
                return(false);
            }
        }
Beispiel #6
0
 public ProductVM()
 {
     errorNotifier = new ErrorNotifier();
     errorNotifier.ErrorsChanged += ErrorNotifier_ErrorsChanged;
 }
Beispiel #7
0
        public Task Execute(IJobExecutionContext context)
        {
            ErrorNotifier.NotifyErrorsAsync(null);

            return(null);
        }
        public static void loadApplicationSettingsFromDisk(ApplicationOptionsClient applicationOptions, WindowMain connectionHolder)
        {
            if (!File.Exists(APP_SETTINGS_FILE_NAME))
            {
                return;
            }

            XmlTextReader textReader = null;

            try
            {
                textReader = new XmlTextReader(APP_SETTINGS_FILE_NAME);
                textReader.Read(); // read declaration

                // read root node
                do
                {
                    textReader.Read();
                }while (textReader.NodeType == XmlNodeType.Whitespace);

                if (textReader.NodeType != XmlNodeType.Element || textReader.Name != XML_TAG_ROOT)
                {
                    throw new Exception("Error processing xml metadata file. The file might be corrupted.");
                }

                while (textReader.Read())
                {
                    if (textReader.NodeType == XmlNodeType.Element)
                    {
                        switch (textReader.Name)
                        {
                        case XML_TAG_LANGUAGE:
                            string lang_id = textReader.GetAttribute(XML_ATTR_LANGUAGE_ID);
                            Localization.LanguageSelector.Global.ChangeLanguage(Localization.LanguageInfo.getLanguageInfo(lang_id));
                            break;

                        case XML_TAG_IsPredictorComparison:
                            applicationOptions.IsPredictorCompareMode = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_TRACE_PATH_MAIN:
                            applicationOptions.TracePathMain = textReader.GetAttribute(XML_ATTR_VALUE);
                            break;

                        case XML_TAG_SHOW_AM:
                            applicationOptions.ShowAM = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_SHOW_GM:
                            applicationOptions.ShowGM = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_SHOW_HM:
                            applicationOptions.ShowHM = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_SHOW_LINE:
                            applicationOptions.ShowLine = bool.Parse(textReader.GetAttribute(XML_ATTR_VALUE));
                            break;

                        case XML_TAG_CONNECTIONS:
                            break;

                        case XML_TAG_CONNECTION:
                            string host = textReader.GetAttribute(XML_ATTR_CONNECTION_HOSTNAME);
                            string port = textReader.GetAttribute(XML_ATTR_CONNECTION_PORT);

                            TCPSimulatorProxy newproxy = new TCPSimulatorProxy(host, int.Parse(port));
                            newproxy.messagePosted       += new EventHandler <StringEventArgs>(connectionHolder.TCPProxy_MessagePosted);
                            newproxy.taskRequestReceived += new EventHandler(connectionHolder.proxyTaskRequestReceived);
                            newproxy.resultsReceived     += new statisticsResultReceivedEventHandler(connectionHolder.proxyResultsReceived);
                            connectionHolder.TCPConnections.Add(newproxy);
                            break;

                        default:
                            throw new Exception(string.Format("Unrecognised tag '{}' found in xml representation of the acquisition metadata. The file may be corrupt.", textReader.Name));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorNotifier.showError(e.Message);
            }
            finally
            {
                if (textReader != null)
                {
                    textReader.Close();
                }
            }
        }