Exemplo n.º 1
0
        private void HandleException(Exception ex)
        {
            EnableUi();
            var exceptionForm = new ExceptionForm(ex);

            exceptionForm.Closed += ExceptionForm_Closed;
            exceptionForm.Show();
        }
Exemplo n.º 2
0
        private void ShowExceptionForm()
        {
            backgroundProcessTimer.Stop();
            ExceptionForm ef = new ExceptionForm(_exception);

            ef.ShowDialog();
            _exception = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 显示异常对话框
        /// </summary>
        /// <param name="ex">异常对象</param>
        public static void ShowExceptionForm(Exception ex)
        {
            ExceptionForm exForm = new ExceptionForm();

            exForm.ExceptionObject = ex;
            exForm.ShowDialog();
            exForm.Dispose();
        }
Exemplo n.º 4
0
 private static void HandleUnhandledException(Exception exc)
 {
     Locale.Current.TryGetString("CriticalError", out string message);
     Log.Fatal(message, exc);
     using (var form = new ExceptionForm(exc))
     {
         form.ShowDialog();
     }
 }
Exemplo n.º 5
0
        public void Report()
        {
            ExceptionForm form = new ExceptionForm(message, ex);

            if (form.ShowDialog(owner) == DialogResult.OK)
            {
                ErrorReporter reporter = new ErrorReporter();
                reporter.Report(ex);
            }
        }
Exemplo n.º 6
0
        private void DetermineOpenGLRenderingMethod(DebugLogger debugLogger)
        {
            var str1 = (string)null;

            try
            {
                str1 = "DetermineOpenGLRenderingMethod::GL.GetInteger";
                GL.GetInteger(GetPName.MajorVersion, out var data1);
                GL.GetInteger(GetPName.MinorVersion, out var data2);
                var version = new Version(data1, data2);
                debugLogger.Add("DetermineOpenGLRenderingMethod()", "OpenGL vendor: " + GL.GetString(StringName.Vendor) + ".", DebugLogger.LogType.Primary);
                debugLogger.Add("DetermineOpenGLRenderingMethod()", "OpenGL renderer: " + GL.GetString(StringName.Renderer) + ".", DebugLogger.LogType.Primary);
                debugLogger.Add("DetermineOpenGLRenderingMethod()", "OpenGL version: " + version.ToString() + ".", DebugLogger.LogType.Primary);
                debugLogger.Add("DetermineOpenGLRenderingMethod()", "OpenGL Shading Language Version: " + GL.GetString(StringName.ShadingLanguageVersion) + ".", DebugLogger.LogType.Primary);
                var dictionary = new Dictionary <string, bool>();
                if (version.Major >= 3)
                {
                    str1 = "DetermineOpenGLRenderingMethod::version.Major >= 3";
                    var integer = GL.GetInteger(GetPName.NumExtensions);
                    for (var index = 0; index < integer; ++index)
                    {
                        var key = GL.GetString(StringNameIndexed.Extensions, index);
                        dictionary.Add(key, true);
                    }
                }
                else
                {
                    str1 = "DetermineOpenGLRenderingMethod::else";
                    var    str2    = GL.GetString(StringName.Extensions);
                    char[] chArray = new char[1] {
                        ' '
                    };
                    foreach (var key in str2.Split(chArray))
                    {
                        dictionary.Add(key, true);
                    }
                }
                if (version.Major >= 2)
                {
                    str1 = "DetermineOpenGLRenderingMethod::OpenGLRendererObject.OpenGLRenderMode.VBOs";
                    OpenGLRendererObject.openGLRenderMode = OpenGLRendererObject.OpenGLRenderMode.VBOs;
                }
                else
                {
                    str1 = "DetermineOpenGLRenderingMethod::OpenGLRendererObject.OpenGLRenderMode.ImmediateMode";
                    OpenGLRendererObject.openGLRenderMode = OpenGLRendererObject.OpenGLRenderMode.ImmediateMode;
                }
                debugLogger.Add("DetermineOpenGLRenderingMethod()", "OpenGL render mode: " + OpenGLRendererObject.openGLRenderMode.ToString() + ".", DebugLogger.LogType.Primary);
            }
            catch (Exception ex)
            {
                var extra_info = str1;
                ExceptionForm.ShowExceptionForm(ex, extra_info);
            }
        }
Exemplo n.º 7
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception exception = e.ExceptionObject as Exception;

            if (exception == null)
            {
                return;
            }

            using (ExceptionForm exceptionForm = new ExceptionForm())
                exceptionForm.ShowDialog(exception);
        }
Exemplo n.º 8
0
 private void listView1_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         EditColour();
     }
     catch (Exception ex)
     {
         ExceptionForm ef = new ExceptionForm(ex);
         ef.ShowDialog();
     }
 }
Exemplo n.º 9
0
        static void WinFormApp(Arguments arg)
        {
            InitServices();

            var welcome = new WelcomeController(new ViewFactory());

            welcome.TryShow();

            var manager = new DataManager();

            try {
                manager.StartDelayedLoading();
                manager.LoadProfiles();
            }
            catch (Exception e) {
                MessageBox.Show(e.Message, ClientServiceLocator.GetService <ILanguage>().GetText("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                UseTrace(e);
            }

            var frm = new MainForm(manager);

            try {
                new MainController(frm, manager);
                if (arg.Minimalize)
                {
                    frm.GoToTray();
                    Application.Run();
                    manager.SaveSettings();
                }
                else if (arg.ConsoleMode)
                {
                    ApplyProfile(manager, arg.Profiles[0]);
                }
                else
                {
                    Application.Run(frm);
                    manager.SaveSettings();
                }
            }
            catch (Exception e) {
                using (var form = new ExceptionForm(e.Message + "\n\n" + e.StackTrace)) {
                    form.FormBorderStyle = FormBorderStyle.FixedDialog;
                    form.StartPosition   = FormStartPosition.CenterScreen;
                    form.ShowDialog();
                }
                UseTrace(e);
            }
            finally {
                manager.Dispose();
                frm.Dispose();
                Properties.Settings.Default.Save();
            }
        }
Exemplo n.º 10
0
        private static void ShowExceptionForm(Exception InException)
        {
            ExceptionForm Form = new ExceptionForm();

            Form.ShowException(InException);

            DialogResult Result = Form.ShowDialog();

            if (Result == DialogResult.No)
            {
                Application.Exit();
            }
        }
Exemplo n.º 11
0
        static void HandleException(Exception ex, bool appstateinvalid)
        {
            Trace.WriteLine(LINE, EXCP);
            Trace.WriteLine(ex, EXCP);
            Trace.WriteLine(LINE, EXCP);

            if (!(ex is System.Threading.ThreadAbortException))
            {
                ExceptionForm exform = new ExceptionForm();
                exform.Exception = ex;
                exform.ApplicationStateInvalid = appstateinvalid;
                exform.ShowDialog(ServiceHost.Window.MainForm);
            }
        }
Exemplo n.º 12
0
        public void Handle(Exception exception, MethodBase currentMethod, bool run)
        {
            try
            {
                if (currentMethod.DeclaringType != null)
                {
                    var exceptionFrom = GetExceptionFrom(currentMethod.Name,
                                                         OnlyClassName(currentMethod.DeclaringType.ToString()),
                                                         Application.ProductName,
                                                         Application.ProductVersion);

                    // LoadValues(exceptions)
                    Values.ExceptionFrom    = exceptionFrom;
                    Values.ExceptionType    = exception.GetType().ToString();
                    Values.ExceptionMessage = exception.Message;

                    var exceptionForm = new ExceptionForm();
                    exceptionForm.Values = Values;

                    if (run == false)
                    {
                        if (exceptionForm.InvokeRequired)
                        {
                            exceptionForm.BeginInvoke((MethodInvoker)exceptionForm.Show);
                        }
                        else
                        {
                            _exceptionForm = exceptionForm;
                            var appThread = new Thread(LaunchExceptionForm);
                            appThread.SetApartmentState(ApartmentState.STA);
                            appThread.Start();
                        }
                    }
                    else
                    {
                        Application.Run(exceptionForm);
                    }

                    // Gets the exception and saves to the Exceptions variable
                    Values.Exceptions += BuildExceptionMessage(Values.ExceptionFrom, Values.ExceptionType,
                                                               Values.ExceptionMessage, "Automated collection");
                }
            }

            // Do not use ExceptionForm
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void MasterListView_SelectedIndexChanged(Object sender, EventArgs e)
 {
     try
     {
         if (this.wrapper != null && this.currentFormKey != null && this.MasterListView.SelectedItems.Count > 0)
         {
             this.wrapper.MasterIdChanged(this.currentFormKey, this.MasterListView.SelectedIndices[0]);
         }
     }
     catch (Exception ex)
     {
         ExceptionForm.ShowDialog(ex);
     }
 }
Exemplo n.º 14
0
        public void Run(ApiCredentials credentials, Form owner, bool debugMode)
        {
            if (credentials == null)
            {
                throw new ArgumentNullException(nameof(credentials));
            }
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }

            _engine = new Engine(p => p
                                 .DebugMode(debugMode)
                                 .AllowClr()
                                 );

            _engine.SetValue("require", new Func <string, object>(RequireFunction));
            _engine.SetValue("console", FirebugConsole.CreateFirebugConsole(_engine, _output));

            new JavaScriptUtil(credentials).Setup(_engine, owner);

            try
            {
                RequireFunction("main.js");
            }
            catch (Exception ex)
            {
                var javaScriptException = ex as JavaScriptException;
                if (javaScriptException != null)
                {
                    ExceptionForm.Show(owner, javaScriptException);
                    return;
                }

                MessageBox.Show(
                    owner,
                    new StringBuilder()
                    .AppendLine("An exception occurred while executing the script:")
                    .AppendLine()
                    .Append(ex.Message).Append(" (").Append(ex.GetType().FullName).AppendLine(")")
                    .AppendLine()
                    .AppendLine(ex.StackTrace)
                    .ToString(),
                    owner.Text,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }
Exemplo n.º 15
0
        private void initSqlDatabases()
        {
            DateTime dt = DateTime.Now;

            _sqlDatabases.Clear();

            try
            {
                foreach (MySqlServerObject so in _sqlServerObjects)
                {
                    MyOutput.NewMessage(EOutputMessageType.PROGRESS, string.Format("Loading databases from server ({0}) '{1}'...", so.ServerObjectId, getDataSourceName(so.ServerObjectId)));

                    var conn = ConnectionPool.GetConnection(so.ServerObjectId);
                    if (conn != null)
                    {
                        SqlCommand cmd = (SqlCommand)ConnectionPool.GetConnection(so.ServerObjectId).CreateCommand();
                        cmd.CommandText    = QueryReader.Read("databases.sql");
                        cmd.CommandTimeout = UserSettings.Default.CommandTimeout;
                        cmd.CommandType    = CommandType.Text;
                        SqlDataReader rdr = cmd.ExecuteReader();
                        while (rdr.Read())
                        {
                            _sqlDatabases.Add(new MySqlDatabase
                            {
                                ServerObjectId     = so.ServerObjectId,
                                ServerObjectName   = so.ServerObjectName,
                                DatabaseId         = (int)rdr["database_id"],
                                DatabaseName       = (string)rdr["database_name"],
                                State              = (string)rdr["state_desc"],
                                UserHasDbAccess    = (bool)rdr["has_db_access"],
                                CompatibilityLevel = Convert.ToInt32(rdr["compatibility_level"]),
                                CollationName      = (string)rdr["collation_name"],
                                RecoveryModel      = (string)rdr["recovery_model_desc"]
                            });
                        }
                        rdr.Close();

                        MyOutput.AppendToLastMessage(EOutputMessageType.INFORMATION, string.Format("Done. Loaded {0:n0} databases.", _sqlDatabases.Count(x => x.ServerObjectId == so.ServerObjectId)), (DateTime.Now - dt).TotalSeconds);
                    }
                }
            }
            catch (Exception ex)
            {
                MyOutput.NewMessage(EOutputMessageType.ERROR, string.Format("Error loading databases: {0}", ex.Message));
                var exForm = new ExceptionForm(ex);
                exForm.ShowDialog();
            }
        }
Exemplo n.º 16
0
            /// <summary>
            /// The "Design Report" action.
            /// </summary>
            public void DesignReport()
            {
                // Get a reference to the parent designer's associated control
                WebReport webreport = (WebReport)_parent.Component;
                Report    report    = new Report();

                bool fileBased = false;

                if (!String.IsNullOrEmpty(webreport.ReportFile))
                {
                    string fileName = webreport.ReportFile;
                    fileName = MapPath(webreport.Site, fileName);
                    report.Load(fileName);
                    fileBased = true;
                }
                else if (!String.IsNullOrEmpty(webreport.ReportResourceString))
                {
                    report.ReportResourceString = webreport.ReportResourceString;
                }

                try
                {
                    RegisterData(webreport, report, webreport.Site);
                }
                catch (Exception ex)
                {
                    using (ExceptionForm form = new ExceptionForm(ex))
                    {
                        form.ShowDialog();
                    }
                    return;
                }
                using (DesignerForm designerForm = new DesignerForm())
                {
                    designerForm.Designer.Report  = report;
                    designerForm.Designer.AskSave = fileBased;
                    designerForm.ShowInTaskbar    = true;
                    designerForm.ShowDialog();
                    if (designerForm.Designer.Modified && !fileBased)
                    {
                        string oldValue = webreport.ReportResourceString;
                        webreport.ReportResourceString = report.SaveToStringBase64();
                        PropertyDescriptorCollection props = TypeDescriptor.GetProperties(webreport);
                        PropertyDescriptor           prop  = props.Find("ReportResourceString", false);
                        _parent.RaiseComponentChanged(prop, oldValue, webreport.ReportResourceString);
                    }
                }
            }
Exemplo n.º 17
0
 private void testToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         var client = new WebClient();
         if (settings != null)
         {
             settings.Initialize(client);
         }
         client.DownloadFile(new Uri("http://www.google.com.by/"), @"c:\test.html");
     }
     catch (Exception ex)
     {
         ExceptionForm.ShowException("Error dowload file", "F**k", ex);
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// Executes this command.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        public override void Execute(object parameter)
        {
            try
            {
                if (AppCore.OpenFileDialog.ShowDialog(AppCore.FormMain) != DialogResult.OK)
                {
                    return;
                }

                AppCore.FormMain.SchemaBrowser.ShowSchema(AppCore.OpenFileDialog.FileName);
            }
            catch (Exception ex)
            {
                ExceptionForm.ShowException("Open file", "Error open file", ex);
            }
        }
Exemplo n.º 19
0
 public void OnPaint(OpenGLConnection.RenderTaskDelegate renderTask)
 {
     try
     {
         GL.ClearColor(0.913725f, 0.905882f, 0.9098f, 1f);
         GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit);
         GL.MatrixMode(MatrixMode.Modelview);
         GL.LoadIdentity();
         GL.Translate(0.0f, 0.0f, -500f);
         renderTask();
         GLControl1.SwapBuffers();
     }
     catch (Exception ex)
     {
         ExceptionForm.ShowExceptionForm(ex);
     }
 }
Exemplo n.º 20
0
        public override object EditValue(ITypeDescriptorContext context,
                                         IServiceProvider provider,
                                         object value)
        {
            Palette original = (Palette)value;

            try
            {
                IWindowsFormsEditorService editorService
                    = (IWindowsFormsEditorService)
                      provider.GetService(typeof(IWindowsFormsEditorService));

                _paletteForm = new PaletteForm();

                if (value == null)
                {
                    value = new Palette();
                }

                // Take a copy of the original Palette in case the user cancels
                // the PaletteForm
                Palette copy = new Palette();
                foreach (Color c in original)
                {
                    copy.Add(c);
                }

                _paletteForm.Value         = original;
                _paletteForm.EditorService = editorService;
                DialogResult result = editorService.ShowDialog(_paletteForm);
                if (result == DialogResult.OK)
                {
                    return(_paletteForm.Value);
                }
                else
                {
                    return(copy);
                }
            }
            catch (Exception ex)
            {
                ExceptionForm ef = new ExceptionForm(ex);
                ef.ShowDialog();
                return(original);
            }
        }
 //Methods
 #region MenuListBox_DoubleClick
 private void MenuListBox_DoubleClick(Object sender, EventArgs e)
 {
     try
     {
         this.currentFormKey = (this.menuListBox.SelectedItem as MenuItem).Key;
         var subFormHandle = this.wrapper.Load((this.menuListBox.SelectedItem as MenuItem).Key);
         SetParent((IntPtr)subFormHandle, this.formPanel.Handle);
         this.wrapper.SetAppearance(
             this.currentFormKey,
             this.formPanel.Height,
             this.formPanel.Width,
             0,
             0);
         this.formTitle.Text = (this.menuListBox.SelectedItem as MenuItem).Text;
     }
     catch (Exception ex)
     {
         ExceptionForm.ShowDialog(ex);
     }
 }
Exemplo n.º 22
0
        private void DesignVerb(object sender, EventArgs e)
        {
            if (FReport.Dictionary.DataSources.Count == 0 && FReport.Dictionary.Connections.Count == 0)
            {
                SelectDataSourceVerb(sender, e);
            }
            else
            {
                FReport.Dictionary.ReRegisterData();
            }

            try
            {
                using (DesignerForm designerForm = new DesignerForm())
                {
                    designerForm.Designer.Report  = FReport;
                    designerForm.Designer.AskSave = !FReport.StoreInResources;
                    designerForm.ShowInTaskbar    = true;
                    designerForm.ShowDialog();
                    if (designerForm.Designer.Modified && FReport.StoreInResources)
                    {
                        RaiseReportChanged();
                    }
                }
            }
            catch (Exception ex)
            {
                using (ExceptionForm form = new ExceptionForm(ex))
                {
                    form.ShowDialog();
                }
            }

            DesignerActionUIService designerActionUISvc =
                GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;

            if (designerActionUISvc != null)
            {
                designerActionUISvc.HideUI(FReport);
            }
        }
Exemplo n.º 23
0
 private void contextMenuColor_Opening(object sender, CancelEventArgs e)
 {
     try
     {
         if (listView1.SelectedItems.Count == 0)
         {
             editColourToolStripMenuItem.Enabled   = false;
             deleteColourToolStripMenuItem.Enabled = false;
         }
         else
         {
             editColourToolStripMenuItem.Enabled   = true;
             deleteColourToolStripMenuItem.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         ExceptionForm ef = new ExceptionForm(ex);
         ef.ShowDialog();
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Executes this command.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        public override void Execute(object parameter)
        {
            using (var f = new FormConnectionString())
            {
                if (f.ShowDialog(AppCore.FormMain) != DialogResult.OK)
                {
                    return;
                }
                try
                {
                    var builder = DatabaseSchema.CreateBuilder(f.ProviderType);
                    var schema  = builder.BuildDatabaseSchema(f.ConnectionString);

                    AppCore.FormMain.SchemaBrowser.ShowSchema(schema);
                }
                catch (Exception ex)
                {
                    ExceptionForm.ShowException("Open file", "Error open file", ex);
                }
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Executes this command.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        public override void Execute(object parameter)
        {
            DatabaseSchema schema = AppCore.FormMain.SchemaBrowser.SelectedSchema;

            if (schema == null)
            {
                return;
            }

            if (AppCore.SaveFileDialog.ShowDialog(AppCore.FormMain) != DialogResult.OK)
            {
                return;
            }
            try
            {
                schema.Save(AppCore.SaveFileDialog.FileName);
            }
            catch (Exception ex)
            {
                ExceptionForm.ShowException("Open file", "Error open file", ex);
            }
        }
Exemplo n.º 26
0
        private void Export_Click(object sender, EventArgs e)
        {
            if (IsPreviewEmpty)
            {
                return;
            }

            ObjectInfo info = (sender as ButtonItem).Tag as ObjectInfo;

            if (info == null)
            {
                Save();
            }
            else
            {
                ExportBase export = Activator.CreateInstance(info.Object) as ExportBase;
                export.CurPage           = CurrentPreview.PageNo;
                export.AllowSaveSettings = true;
                export.ShowProgress      = true;
                try
                {
                    export.Export(Report);
                }
#if !DEBUG
                catch (Exception ex)
                {
                    using (ExceptionForm form = new ExceptionForm(ex))
                    {
                        form.ShowDialog();
                    }
                }
#endif
                finally
                {
                }
            }
        }
Exemplo n.º 27
0
        private void listView1_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                switch (e.KeyValue)
                {
                case 65:        //A
                    AddColour();
                    break;

                case 46:        //Suppr (delete)
                    DeleteColour();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ExceptionForm ef = new ExceptionForm(ex);
                ef.ShowDialog();
            }
        }
Exemplo n.º 28
0
        public void Draw()
        {
            try
            {
                if (openGLRender != null && openGLRender.RenderMode != OpenGLRendererObject.openGLRenderMode)
                {
                    Delete();
                }

                if (openGLRender == null)
                {
                    Create();
                }

                openGLRender.Draw();
            }
            catch (Exception ex)
            {
                Reset();
                if (OpenGLRendererObject.openGLRenderMode == OpenGLRendererObject.OpenGLRenderMode.ImmediateMode)
                {
                    ++try_count;
                    if (try_count <= 2)
                    {
                        return;
                    }

                    ExceptionForm.ShowExceptionForm(new Exception("VBOObject::Draw::Failure", ex));
                }
                else
                {
                    Reset();
                    OpenGLRendererObject.openGLRenderMode = OpenGLRendererObject.OpenGLRenderMode.ImmediateMode;
                }
            }
        }
Exemplo n.º 29
0
        public void Init(GUIHost host, string xmlScript, ButtonCallback MyButtonCallback)
        {
            this.host = host;
            var s             = xmlScript;
            var xmlSerializer = new XmlSerializer(typeof(XMLFrame));

            Sprite.pixel_perfect = true;
            using (var textReader = (TextReader) new StringReader(s))
            {
                try
                {
                    childFrame = (XMLFrame)xmlSerializer.Deserialize(textReader);
                    childFrame.Init(host, MyButtonCallback);
                }
                catch (Exception ex)
                {
                    ExceptionForm.ShowExceptionForm(ex);
                }
            }
            Sprite.pixel_perfect = false;
            RemoveAllChildElements();
            AddChildElement(childFrame);
            childFrame.Refresh();
        }
Exemplo n.º 30
0
 public void SpoolerStartUp(DebugLogger debugLogger)
 {
     try
     {
         print_spooler_client = new SpoolerClient(debugLogger)
         {
             IgnoreConnectingPrinters = false
         };
         print_spooler_client.OnReceivedPrinterList += new OnReceivedPrinterListDel(OnReceivedPrinterList);
         print_spooler_client.OnReceivedMessage     += new OnReceivedMessageDel(OnReceivedMessage);
         print_spooler_client.OnGotNewPrinter       += new SpoolerClient.OnGotNewPrinterDel(OnGotNewPrinterInternal);
         print_spooler_client.OnPrinterDisconnected += new SpoolerClient.OnPrinterDisconnectedDel(OnPrinterDisconnectedInternal);
         print_spooler_client.OnProcessFromServer   += new SpoolerClient.OnPrintProcessDel(OnPrintProcessChangedInternal);
         print_spooler_client.OnPrintStopped        += new SpoolerClient.OnPrintStoppedDel(OnPrintStoppedInternal);
         var directorySeparatorChar = Path.DirectorySeparatorChar;
         Form1.debugLogger.Add("SpoolerConnection.SpoolerStartUp", "Setup", DebugLogger.LogType.Secondary);
         var num = (int)print_spooler_client.StartSession(Paths.ResourceFolder + directorySeparatorChar.ToString() + "Spooler" + directorySeparatorChar.ToString() + "M3DSpooler.exe", Paths.ResourceFolder + directorySeparatorChar.ToString() + "Spooler", "H B A D PSM", 2000);
         Form1.debugLogger.Add("SpoolerConnection.SpoolerStartUp", "Session Started", DebugLogger.LogType.Secondary);
     }
     catch (Exception ex)
     {
         ExceptionForm.ShowExceptionForm(ex);
     }
 }
Exemplo n.º 31
0
        unsafe void ThreadFunc()
        {
            try
            {
                int size = 65536;
                var hFile = WinAPI.OpenFileMapping(
                    WinAPI.FileMapAccess.FileMapAllAccess,
                    false,
                    "ulHelper_fmSend_" + acc.Name);
                var lpBaseAddress = WinAPI.MapViewOfFile(
                    hFile,
                    WinAPI.FileMapAccess.FileMapAllAccess,
                    0, 0, 0);

                bool createdNew;
                mutex = new Mutex(false, "ulHelper_mutexSend_" + acc.Name, out createdNew);
                eventWH = new EventWaitHandle(true, EventResetMode.AutoReset, "ulHelper_eventSend_" + acc.Name);

                var stream = new UnmanagedMemoryStream((byte*)lpBaseAddress.ToPointer(), size, size, FileAccess.ReadWrite);
                var br = new BinaryReader(stream);
                var bw = new BinaryWriter(stream);

                byte[] buf = new byte[size];

                while (true)
                {
                    addPacketEvent.WaitOne();
                    if (acc.NeedTerminate)
                        break;
                    mutex.WaitOne();
                    try
                    {
                        stream.Position = 0;
                        int pckCount = br.ReadInt32();
                        int index = br.ReadInt32();
                        stream.Position = index;

                        int bufferCount;
                        lock (acc.SendBuffer)
                        {
                            bufferCount = acc.SendBuffer.Count;
                            for (int i = 0; i < acc.SendBuffer.Count; i++)
                                acc.SendBuffer[i].WriteTo(bw);
                            acc.SendBuffer.Clear();
                        }

                        index = (int)stream.Position;
                        stream.Position = 0;
                        bw.Write((int)pckCount + bufferCount);
                        bw.Write((int)index);
                    }
                    finally
                    {
                        mutex.ReleaseMutex();
                    }
                    eventWH.Set();
                }

                WinAPI.UnmapViewOfFile(lpBaseAddress);
                WinAPI.CloseHandle(hFile);
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                var f = new ExceptionForm(ex);
                f.ShowDialog();
            }
        }
Exemplo n.º 32
0
        public static void ShowException(Exception e)
        {
            if (e is FileNotFoundException && e.Message.Contains("System.Core"))
            {
                DialogResult res = MessageBox.Show(Language.Startup.RequireNET35_Message, Language.General.Error, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (res == DialogResult.OK)
                {
                    Process.Start("http://www.microsoft.com/downloads/details.aspx?familyid=AB99342F-5D1A-413D-8319-81DA479AB0D7&displaylang=en");
                }

                Environment.Exit(-1);
                return;
            }

            Cursor.Current = Cursors.WaitCursor;
            using (ExceptionForm form = new ExceptionForm(e.Message, e.ToString(), false, false))
            {
                Cursor.Current = Cursors.Default;
                form.ShowDialog();
            }
        }
Exemplo n.º 33
0
        private static unsafe void ThreadFunc()
        {
            try
            {
                int size = 65536;
                bool createdMain = false;
                var hFile = WinAPI.OpenFileMapping(
                    WinAPI.FileMapAccess.FileMapAllAccess,
                    false,
                    "ulHelper_fm");
                if (hFile == IntPtr.Zero)
                {
                    hFile = WinAPI.CreateFileMapping(
                        new IntPtr(-1),
                        IntPtr.Zero,
                        WinAPI.FileMapProtection.PageReadWrite,
                        (uint)0, (uint)size,
                        "ulHelper_fm");
                    createdMain = true;
                }
                var lpBaseAddress = WinAPI.MapViewOfFile(
                    hFile,
                    WinAPI.FileMapAccess.FileMapAllAccess,
                    0, 0, 0);

                Mutex = new Mutex(false, "ulHelper_mutex");
                Stream = new UnmanagedMemoryStream((byte*)lpBaseAddress.ToPointer(), size, size, FileAccess.ReadWrite);

                eventWH = new EventWaitHandle(false, EventResetMode.AutoReset, "ulHelper_event");

                int accCount;
                byte[] buf = new byte[size];

                if (createdMain)
                {
                    Mutex.WaitOne();
                    try
                    {
                        buf[0] = buf[1] = buf[2] = buf[3] = 0;
                        Stream.Position = 0;
                        Stream.Write(buf, 0, 4);
                    }
                    finally
                    {
                        Mutex.ReleaseMutex();
                    }
                }

                eventWH.Set();
                while (true)
                {
                    eventWH.WaitOne();
                    if (MainForm.NeedTerminate)
                        break;
                    Mutex.WaitOne();
                    try
                    {
                        Stream.Position = 0;
                        accCount = Stream.ReadByte();
                        lock (Accounts.List)
                            if (Accounts.List.Count != accCount)
                            {
                                foreach (var acc in Accounts.List)
                                    acc.Active = false;
                                for (int i = 0; i < accCount; i++)
                                {
                                    string accountName = "";
                                    int index = 0;
                                    Stream.Position = 8 + i * 128;
                                    Stream.Read(buf, 0, 128);
                                    while (buf[index] != 0)
                                        accountName += (char)buf[index++];
                                    if (!Accounts.List.Any(acc => acc.Name == accountName))
                                    {
                                        var accData = new AccountData(accountName);
                                        Accounts.List.Add(accData);
                                    }
                                    Accounts.List.First(acc => acc.Name == accountName).Active = true;
                                }
                                PerformNewAccount();
                            }
                    }
                    finally
                    {
                        Mutex.ReleaseMutex();
                    }
                }

                WinAPI.UnmapViewOfFile(lpBaseAddress);
                WinAPI.CloseHandle(hFile);
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                var f = new ExceptionForm(ex);
                f.ShowDialog();
            }
        }
Exemplo n.º 34
0
		private void ShowExceptionForm()
		{
			backgroundProcessTimer.Stop();
			ExceptionForm ef = new ExceptionForm( _exception );
			ef.ShowDialog();
			_exception = null;
		}