Exemple #1
0
        public void Recompile(GncFileWrapper file)
        {
            try
            {
                var usings = "using AccountsWeb; using GnuCashSharp; using System; using System.Collections.Generic; using System.Linq; using RT.TagSoup; ";
                CompiledCode      = CSScript.Evaluator.LoadCode <AccountsWebScript>(usings + Code);
                CompiledCode.File = file;
                Errors.Clear();
                Warnings.Clear();
            }
            catch (CompilerException e)
            {
                CompiledCode = null;
                Values.Clear();
                Errors   = (List <string>)e.Data["Errors"];
                Warnings = (List <string>)e.Data["Warnings"];
                Values.Clear();
                return;
            }

            try
            {
                Errors.Clear();
                Values = CompiledCode.Compute().ToList();
            }
            catch (Exception e)
            {
                Errors.Add($"{e.GetType().Name}: {e.Message}\n{e.StackTrace}");
                Values.Clear();
            }
        }
Exemple #2
0
 public static void Show(GncFileWrapper wrapper)
 {
     if (_instance == null)
     {
         _instance = new ConfigForm(wrapper);
         _instance.Show();
     }
     else
     {
         _instance.BringToFront();
     }
 }
Exemple #3
0
        /// <summary>
        /// Closes the current file, if any, and creates a new one under the specified name.
        /// The new file will have no GnuCash session loaded.
        /// </summary>
        public static void NewFile(string filename)
        {
            if (CurFile != null)
            {
                CloseFile();
            }

            CurFile = new GncFileWrapper();
            CurFile.LoadedFromFile = filename;
            CurFile.SaveToFile();
            CurFile.ReloadSession();

            AddRecent(filename);
        }
Exemple #4
0
        public ConfigForm(GncFileWrapper wrapper)
            : base(Program.Settings.ConfigFormSettings)
        {
            _wrapper = wrapper;
            InitializeComponent();
            translate();

            _languageHelper = new LanguageHelperWinForms <Translation>(
                "AccountsWeb", "AccountsWeb", true,
                Program.Settings.TranslationFormSettings, Icon, () => Program.Settings.Language);
            _languageHelper.TranslationChanged += translationChanged;

            tabsMain.SelectedIndex = _activeTab;
            SettingsToGui();
        }
Exemple #5
0
        /// <summary>
        /// Opens a GncFileWrapper of the specified file name. Loads a <see cref="GncSession"/> for
        /// the underlying file.
        /// </summary>
        /// <remarks>
        /// <para>If successful, attempts to start the server.</para>
        /// <para>If there is an exception loading the GnuCash session, displays the message
        /// in a dialog box and does not open a file, but returns successfully.</para>
        /// <para>If the session opens successfully but has warnings, displays a dialog box
        /// with a button to view the warnings in the browser.</para>
        /// </remarks>
        public static void OpenFile(string filename)
        {
            Program.CloseFile();

#if !DEBUG
            try
#endif
            {
                CurFile = GncFileWrapper.LoadFromFile(filename);
                CurFile.ReloadSession();
            }
#if !DEBUG
            catch (Exception e)
            {
                CurFile = null;
                DlgMessage.ShowWarning(Tr.Warning_CouldNotOpenAccountsWeb.Fmt(filename, CurFile == null ? Tr.Warning_AccWeb_NA.Translation : (CurFile.GnuCashFile ?? "-"), e.Message));
                return;
            }
#endif

            Interface.StartServer(Program.CurFile.ServerOptions, Program.CurFile.FileSystemOptions);

            AddRecent(filename);
        }
Exemple #6
0
 /// <summary>
 /// Closes the currently open file.
 /// </summary>
 /// <remarks>
 /// <para>Any unsaved changes will be discarded. This method does not display any
 /// prompts or dialogs to the user.</para>
 /// </remarks>
 public static void CloseFile()
 {
     CurFile = null;
 }