Пример #1
0
        public void Save()
        {
            try
            {
                base.Save(OptionsFileName_);
            }
            catch (System.Exception e)
            {
                System.InvalidOperationException ioe = e as System.InvalidOperationException;
                if (ioe != null && ioe.Message.Contains("CS2001") && ioe.Message.Contains("CS2008"))
                {
                    //error with xml serialization
                    //Unhandled exception : System.InvalidOperationException
                    //Message : Unable to generate a temporary class (result=1).
                    //error CS2001: Source file 'C:\Windows\Temp\2cehzm2v.0.cs' could not be found
                    //error CS2008: No inputs specified

                    ErrorMessageBox.Show(string.Format(LangPack.TranslateString(
                                                           "Error on saving config file to {0}" +
                                                           "\r\nPossible reason - denyed write access to system TEMP directory."),
                                                       OptionsFileName_),
                                         LangPack.TranslateString("Error on saving config file"),
                                         e);
                }
                else
                {
                    ErrorMessageBox.Show(string.Format(LangPack.TranslateString(
                                                           "Error on saving config file to {0}"), OptionsFileName_),
                                         LangPack.TranslateString("Error on saving config file"),
                                         e);
                }
            }
        }
Пример #2
0
        public static void Send(string email, string subject, string body)
        {
            string data = string.Format("mailto:{0}?subject={1}&body={2}",
                                        email, subject, body);

            data = data.Replace("\r\n", "%0D%0A");
            data = data.Replace(" ", "%20");
            if (data.Length > 2000)
            {
                data = data.Substring(0, 2000);
            }

            try
            {
                System.Diagnostics.Process.Start(data);
            }
            catch (Exception e)
            {
                ErrorMessageBox.Show(string.Format(LangPack.TranslateString(
                                                       "Error on sending email to : {0}\r\n" +
                                                       "Error message : {1}"),
                                                   email, e.Message),
                                     LangPack.TranslateString("Error on sending email"),
                                     e);
            }
        }
Пример #3
0
 public static void StartIE(string fileName)
 {
     try
     {
         InitIE();
         System.Diagnostics.Process.Start(iePath, fileName);
     }
     catch (Exception e)
     {
         ErrorMessageBox.Show(string.Format(LangPack.TranslateString(
                                                "Error on opening url : {0}\r\n" +
                                                "Error message : {1}"),
                                            fileName, e.Message),
                              LangPack.TranslateString("Error on opening url"),
                              e);
     }
 }
Пример #4
0
        public static DialogResult Show(
            IWin32Window owner,
            string text,
            string caption,
            MessageBoxButtons buttons,
            Exception exception
            )
        {
            DialogResult result = DialogResult.Cancel;

            try
            {
                GlobalEvents.AllowIdleProcessing = false;
                try
                {
                    if (Application.SplashForm != null && Application.SplashForm.Visible)
                    {
                        Application.SplashForm.Hide();
                    }
                }
                catch
                {
                }

                ErrorMessageBox t = new ErrorMessageBox(
                    text,
                    caption,
                    buttons,
                    exception);

                if (owner == null)
                {
                    result = t.ShowDialog();
                }
                else
                {
                    result = t.ShowDialog(owner);
                }
            }
            finally
            {
                GlobalEvents.AllowIdleProcessing = true;
            }
            return(result);
        }
Пример #5
0
        public static BaseOptions Load(BaseOptions source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            BaseOptions result = source;

            try
            {
                if (System.IO.File.Exists(source.OptionsFileName_))
                {
                    FileStream FStream = new FileStream(source.OptionsFileName_, FileMode.Open, FileAccess.Read, FileShare.Read);
                    if (FStream.Length > 0)
                    {
                        result = (BaseOptions)XmlSerializableObject.Load(FStream, source.GetType(), source.UseSoapSerialization);
                    }
                }
            }
            catch (System.Exception e)
            {
                ErrorMessageBox.Show(
                    string.Format(LangPack.TranslateString(
                                      "Error on opening config file from {0}" +
                                      ".\r\nPossible reason - error in options file format" +
                                      ".\r\nThe configuration will be reset to default values."
                                      ), source.OptionsFileName_),
                    LangPack.TranslateString("Error on opening config file"),
                    e);
            }
            if (result == source)
            {
                result.OnLoaded();
            }

            return(result);
        }
Пример #6
0
 public static void Start(string fileName)
 {
     try
     {
         System.Diagnostics.Process.Start(fileName);
     }
     catch (Exception e)
     {
         if (fileName.ToLowerInvariant().StartsWith("http://"))
         {
             StartIE(fileName);
         }
         else
         {
             ErrorMessageBox.Show(string.Format(LangPack.TranslateString(
                                                    "Error on start process : {0}\r\n" +
                                                    "Error message : {1}"),
                                                fileName, e.Message),
                                  LangPack.TranslateString("Error on start process"),
                                  e);
         }
     }
 }
Пример #7
0
        public static DialogResult Show(
            IWin32Window owner,
            string text,
            string caption,
            MessageBoxButtons buttons,
            Exception exception
            )
        {
            DialogResult result = DialogResult.Cancel;

            try
            {
                GlobalEvents.AllowIdleProcessing = false;
                try
                {
                    if(Application.SplashForm != null && Application.SplashForm.Visible)
                        Application.SplashForm.Hide();
                }
                catch
                {

                }

                ErrorMessageBox t = new ErrorMessageBox(
                    text,
                    caption,
                    buttons,
                    exception);

                if(owner == null)
                    result = t.ShowDialog();
                else
                    result = t.ShowDialog(owner);
            }
            finally
            {
                GlobalEvents.AllowIdleProcessing = true;

            }
            return result;
        }