Пример #1
0
        public MainForm()
        {
            InitializeComponent();

            ENErrorCode VLoadCode = VAppSettings.FLoad();

            if (VLoadCode != ENErrorCode.EC_OK)
            {
                SCGlobal.FShowMessage("Что-то пошло не так...", "Код - " + VLoadCode.ToString());

                Application.Exit();
            }

            VScriptsController.FLoadScripts();

            VWebSites = VScriptsController.FGetScriptNames();

            foreach (String Script in VScriptsController.FGetScripts())
            {
                List <Tuple <String, String> > VScriptCategories = new List <Tuple <String, String> >();

                foreach (Tuple <String, String> ScriptCategory in VScriptsController.FGetScriptCategories(Script))
                {
                    VScriptCategories.Add(ScriptCategory);
                }

                VCategories.Add(new Tuple <String, List <Tuple <String, String> > >(Script, VScriptCategories));
            }

            FSetupForm();

            FFIllSettingsControls();
        }
Пример #2
0
        public ENErrorCode FLoad()
        {
            List <Tuple <String, String> >[] VExceptionLists = new List <Tuple <String, String> > [2];
            ENErrorCode VResultCode = ENErrorCode.EC_OK;

            try {
                VSettings.Load(SCGlobal.VAppSettingsFilePath);
            } catch (XmlException _Exception) {
                /*
                 * There is a load or parse error in the XML. In this case, a System.IO.FileNotFoundException is raised.
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FXmlFormattedEventBody(( UInt32 )_Exception.LineNumber, ( UInt32 )_Exception.LinePosition, _Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_FILE_HAS_NOT_BEEN_LOADED;
            } catch (ArgumentNullException _Exception) {
                /*
                 * Filename is null.
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FClassicFormattedEventBody(_Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_FILE_HAS_EMPTY_NAME;
            } catch (PathTooLongException _Exception) {
                /*
                 * The specified path, file name, or both exceed the system-defined maximum length.
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FClassicFormattedEventBody(_Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_FILE_HAS_TOO_LONG_NAME;
            } catch (DirectoryNotFoundException _Exception) {
                /*
                 * The specified path is invalid (for example, it is on an unmapped drive).
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FClassicFormattedEventBody(_Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_INVALID_PATH;
            } catch (UnauthorizedAccessException _Exception) {
                /*
                 * Filename specified a file that is read-only or this operation is not supported on the current platform or filename specified a directory or the caller does not have the required permission.
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FClassicFormattedEventBody(_Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_PERHAPS_READ_ONLY_FILE;
            } catch (FileNotFoundException _Exception) {
                /*
                 * The file specified in filename was not found.
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FClassicFormattedEventBody(_Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_FILE_NOT_FOUND;
            } catch (NotSupportedException _Exception) {
                /*
                 * Filename is in an invalid format.
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FClassicFormattedEventBody(_Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_INCORRECT_FILE_CONTENT;
            } catch (SecurityException _Exception) {
                /*
                 * The caller does not have the required permission.
                 */

                VExceptionLists[0] = SCJournal.FSimpleFormattedEventHeader(GetType().FullName);
                VExceptionLists[1] = SCJournal.FClassicFormattedEventBody(_Exception.Message, _Exception.StackTrace, _Exception.Data.ToString());

                VResultCode = ENErrorCode.EC_REQUIRED_START_APP_WITH_ADMINISTRATOR_PRIVILEGES;
            }

            if (VExceptionLists[0] != null && VExceptionLists[1] != null)
            {
                SCGlobal.VJournal.FAppendEvent(VExceptionLists[0], VExceptionLists[1]);
            }
            else
            {
                SCGlobal.VJournal.FAppendEvent(SCJournal.FSimpleFormattedEventHeader("SCAppSettings::FLoad"), SCJournal.FSimpleFormattedEventHeader("FLoad has been successful passed"));
            }

            VRoot = VSettings.DocumentElement;

            return(VResultCode);
        }