Ejemplo n.º 1
0
 public Finales()
 {
     LoggingService = new Logging.Logging(1);
     InitializeComponent();
     maakWedstrijden();
     setLabels();
 }
Ejemplo n.º 2
0
        public override string UploadImage(MemoryStream memoryStream, string imageName, out ImageErrorModel errorModel)
        {
            string imagePath = "";

            Logging.Logging logging = new Logging.Logging();

            errorModel = new ImageErrorModel();
            try
            {
                Image image = null;
                using (image = Image.FromStream(memoryStream))
                {
                    if (image.Width < defaultWidth || image.Height < defaultHeight)
                    {
                        //      image = resize(defaultWidth, defaultHeight, image);
                    }
                    imagePath = defaultLocationImage + "\\" + imageName;
                    image.Save(imagePath);
                    errorModel.isSuccess = true;
                    return("~/" + subRoot + "/" + imageName);
                }
            }
            catch (Exception e)
            {
                errorModel.exception       = e;
                errorModel.isSuccess       = false;
                errorModel.message         = "Không thể upload hình thành công";
                errorModel.ImageUploadEnum = Common.Enum.Log.ImageUploadEnum.Local;
                logging.ErrorLogs(errorModel.ToString());
                return("false");
            }
        }
Ejemplo n.º 3
0
        private void ShowResults(ICollection <FixFileDetail> fixFiles, TimeSpan duration)
        {
            var scannerResults = new ScannerResults(Games);

            scannerResults.Show(_scannerWindow, 5, 5);

            var scannerStatistics = new ScannerStatistics(Games, duration, fixFiles);

            scannerStatistics.Show(_scannerWindow, 5, scannerResults.Window.Height + WindowMargin, scannerResults.Window.Width);

            var scannerExplorer = new ScannerExplorer(Games);

            scannerExplorer.Show(_scannerWindow, scannerStatistics.Window.Width + WindowMargin, scannerResults.Window.Height + WindowMargin, scannerStatistics.Window.Height);

            _loggingWindow = new Logging.Logging();
            _loggingWindow.Show(_scannerWindow, scannerResults.Window.Width + WindowMargin, 5, scannerResults.Window.Height);

            scannerResults.Window.Closed += (_, _) =>
            {
                scannerStatistics.Close();
                scannerExplorer.Close();
                _loggingWindow.Close();
                _scannerWindow.Show();
            };
        }
Ejemplo n.º 4
0
        private IExecutionContext CreateContext(string cookie)
        {
            IExecutionContext context = new Gin.Context.ExecutionContext(_ginRoot);

            Logging.Logging loggingObject = new Logging.Logging();

            Directory.CreateDirectory(_cookiePath);

            string          mainLoggerPath = Path.Combine(_ginRoot, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME);
            ExecutionLogger mainFileLogger = new ExecutionLoggerTextFile(mainLoggerPath);

            loggingObject.AddLogger(mainFileLogger);

            string          textLoggerPath = Path.Combine(_cookiePath, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME);
            ExecutionLogger textFileLogger = new ExecutionLoggerTextFile(textLoggerPath);

            loggingObject.AddLogger(textFileLogger);
            _state.LogPath = textLoggerPath;

            _progressProxy = new ExecutionProgressProxy(OnProgress);
            loggingObject.SetProgress(_progressProxy);

            context.Log = loggingObject;

            return(context);
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            ServerData.Init();
            logging = Logging.Logging.GetLogging(ServerData.ServerAppName, new ServerJournal(ServerData.ServerAppName),
                                                 new FileLogger(ServerData.ServerAppName, ServerData.LOG_DIRECTORY + FileLogger.GetNowFile(), FLgType.OVERWRITE_DTOR));

            Console.Title = ServerData.ServerAppName + " - SERVER";
            Console.SetWindowSize((int)Math.Floor(Console.WindowWidth * 1.2), (int)Math.Floor(Console.WindowHeight * 1.2));

            if (!Directory.Exists(ServerData.LOG_DIRECTORY))
            {
                Directory.CreateDirectory(ServerData.LOG_DIRECTORY);
            }
            if (!Directory.Exists(ServerData.CUR_PACKET_LOG_DIRECTORY))
            {
                Directory.CreateDirectory(ServerData.CUR_PACKET_LOG_DIRECTORY);
            }

            logging.Eyecatch("Server starting...");

            Listener.Setup();
            PacketOperations.Setup();
            Client.SetAdminPwdHash(ServerData.ADMIN_HASH_PWD);
            SetConsoleCtrlHandler(__ctrl_eventHandler, true);

            //The current (main server) thread will hang until the signal is set using Stop
            __hanger.WaitOne();

            __INTERN_EXIT();
        }
Ejemplo n.º 6
0
 public Nieuwe_Speler()
 {
     LoggingService = new Logging.Logging(1);
     InitializeComponent();
     voegTeamsToe();
      tekstvakken = new System.Windows.Forms.TextBox[20];
     tekstvakken[0] = textBox1;
     tekstvakken[1] = textBox2;
     tekstvakken[2] = textBox3;
     tekstvakken[3] = textBox4;
     tekstvakken[4] = textBox5;
     tekstvakken[5] = textBox6;
     tekstvakken[6] = textBox7;
     tekstvakken[7] = textBox8;
     tekstvakken[8] = textBox9;
     tekstvakken[9] = textBox10;
     tekstvakken[10] = textBox11;
     tekstvakken[11] = textBox12;
     tekstvakken[12] = textBox13;
     tekstvakken[13] = textBox14;
     tekstvakken[14] = textBox15;
     tekstvakken[15] = textBox16;
     tekstvakken[16] = textBox17;
     tekstvakken[17] = textBox18;
     tekstvakken[18] = textBox19;
     tekstvakken[19] = textBox20;
 }
Ejemplo n.º 7
0
 public GespeeldeWedstrijd()
 {
     InitializeComponent();
     maakTabellen();
     setLabels();
     LoggingService = new Logging.Logging(1);
 }
Ejemplo n.º 8
0
 private IExecutionContext CreateExecutionContext()
 {
     string rootPath = ConfigurationManager.AppSettings["ROOT_PATH"];
     string logPath = ConfigurationManager.AppSettings["LOG_PATH"];
     IExecutionContext context = new ExecutionContext(rootPath);
     Logging.Logging log = new Logging.Logging();
     log.AutoFlushLoggers = true;
     log.AddLogger(new ExecutionLoggerTextFile(logPath));
     context.Log = log;
     return context;
 }
Ejemplo n.º 9
0
        private IExecutionContext CreateExecutionContext()
        {
            string            rootPath = ConfigurationManager.AppSettings["ROOT_PATH"];
            string            logPath  = ConfigurationManager.AppSettings["LOG_PATH"];
            IExecutionContext context  = new ExecutionContext(rootPath);

            Logging.Logging log = new Logging.Logging();
            log.AutoFlushLoggers = true;
            log.AddLogger(new ExecutionLoggerTextFile(logPath));
            context.Log = log;
            return(context);
        }
Ejemplo n.º 10
0
        public void TestInit()
        {
            _context              = new ExecutionContextMock();
            _testCommand          = new EmptyCommand();
            _testCommand.UserInfo = new UserInfoEmbedded
            {
                MessageGuid = "guid",
                MessageText = "text"
            };

            Logging.Logging log = new Logging.Logging();
            _logger = new ExecutionLoggerMock();
            log.AddLogger(_logger);
            _context.Log = log;
        }
Ejemplo n.º 11
0
        public LabelManager()
        {
            this.logging       = new Logging.Logging();
            this.labelFiles    = new List <AxLabelFile>();
            this.labelContents = new Dictionary <string, string>();

            // Initialize label files (each languages)
            // Most likely there is a better way to get the AxLabelFile elements.
            // This works only if the label files are in the same model than the other elements.
            // Use CreateLabels.model(modelname) otherwise.
            this.labelFiles.Add(LabelManager.currentModel().GetLabelFile($"{LABELFILEID}_{"en-GB"}"));
            this.labelFiles.Add(LabelManager.currentModel().GetLabelFile($"{LABELFILEID}_{"en-US"}"));

            this.initContents();
        }
Ejemplo n.º 12
0
        private IExecutionContext CreateExecutionContext()
        {
            string            rootPath = ConfigurationManager.AppSettings["ROOT_PATH"];
            string            logPath  = ConfigurationManager.AppSettings["LOG_PATH"];
            IExecutionContext context  = new ExecutionContext(rootPath);

            context.ControlContainer = panelMain;
            Logging.Logging log = new Logging.Logging();
            log.AutoFlushLoggers = true;
            log.AddLogger(new ExecutionLoggerTextFile(logPath));
            log.AddLogger(new ExecutionLoggerMessageBox(this));
            log.SetProgress(new ExecutionProgressWindowsForms(MainProgressBar, MainProgressLabel));
            context.Log = log;
            return(context);
        }
Ejemplo n.º 13
0
        public LabelManager()
        {
            this.logging    = new Logging.Logging();
            this.labelFiles = new List <AxLabelFile>();

            this.dte     = CoreUtility.ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
            this.context = new VSApplicationContext(dte);

            // Todo Declarer all labels files here
            // Initialize label files (each languages)
            // Most likely there is a better way to get the AxLabelFile elements.
            // This works only if the label files are in the same model than the other elements.
            // Use LabelManager.model(modelname) otherwise.
            this.labelFiles.Add(LabelManager.currentModel().GetLabelFile($"{LABELFILEID}_{"en-GB"}"));
            this.labelFiles.Add(LabelManager.currentModel().GetLabelFile($"{LABELFILEID}_{"en-US"}"));
        }
        //
        // Constructor
        //
        public SimpleAuthentication(string serverName, string server, RequestAuthentication requestAuthentication, Logging.Logging logger)
        {
            InitializeComponent();

            // Save our properties
            m_requestAuthentication = requestAuthentication;
            m_logger = logger;

            // Set up our default state
            textBox_Server.Text = server;
            this.Text           = serverName + @" Authentication";
            UpdateAuthenticateDialogState(false);

            // We need to populate the initial content
            PopulateExistingCredentials(server);
        }
        //
        // Clears an existing credentials object
        //
        public static Credentials Clear(string server, Logging.Logging logger)
        {
            logger.Log("Clearing credentials for {0}", server);
            string filePath = GetServerFilePath(server);

            if (File.Exists(filePath) == true)
            {
                logger.Log(" * Deleted credentials file {0}", filePath);
                File.Delete(filePath);
            }

            // Load the credentials in
            Credentials loadedCredentials = Create(server, logger);

            return(loadedCredentials);
        }
Ejemplo n.º 16
0
        private void LoadPackageAsync(string packageFilePath)
        {
            string            rootPath = ConfigurationManager.AppSettings["ROOT_PATH"];
            string            logPath  = ConfigurationManager.AppSettings["LOG_PATH"];
            IExecutionContext context  = new Gin.Context.ExecutionContext(rootPath);

            Logging.Logging log = new Logging.Logging();
            log.AutoFlushLoggers = true;
            log.AddLogger(new ExecutionLoggerTextFile(logPath));
            context.Log = log;
            Package pkg = new Package(context);

            SetCurrentStatus("Загрузка пакета");
            SetFilePathStatus(packageFilePath);
            pkg.Load(packageFilePath);
            BuildPackageTree(pkg);
        }
        //
        // Creates a credentials object from an existing server file
        //
        public static Credentials Create(string server, Logging.Logging logger)
        {
            logger.Log("Creating credentials object for {0}", server);

            // Get the path to these credentials
            string filePath = GetServerFilePath(server);

            if (File.Exists(filePath) == false)
            {
                logger.Log(" * Unable to find the credentials file {0}", filePath);
                return(null);
            }

            Credentials credentials = null;

            try
            {
                // Load in the data
                string[] credentialData = File.ReadAllLines(filePath);

                // Convert the data from the credentials file into it's own array
                string[] fileData = new string[credentialData.Length - 2];
                for (int i = 0; i < fileData.Length; ++i)
                {
                    fileData[i] = credentialData[i + 2];
                }

                // Create our object
                Type thisType = Type.GetType("RB_Tools.Shared.Authentication.Credentials." + credentialData[0]);
                credentials = (Credentials)Activator.CreateInstance(thisType, fileData);

                logger.Log("Creating credentials object {0}", thisType.Name);

                // Set our server
                credentials.Server = credentialData[1];
            }
            catch (Exception e)
            {
                logger.Log(" * Unable to load the credentials data\n{0}\n", e.Message);
                return(null);
            }

            // We have an object
            return(credentials);
        }
Ejemplo n.º 18
0
        //
        // Starts authenticating against the Jira server
        //
        public static Credentials.Credentials Authenticate(Logging.Logging logger)
        {
            // Get our data
            string serverUrl  = Server.Names.Url[(int)Server.Names.Type.Jira];
            string serverName = Server.Names.Type.Jira.ToString();

            logger.Log("Starting authentication");
            logger.Log(" * Name: {0}", serverName);
            logger.Log(" * Url: {0}", serverUrl);

            // Kick off the RB authentation
            Dialogs.SimpleAuthentication authDialog = new Dialogs.SimpleAuthentication(serverName, serverUrl, Jira.Authenticate, logger);
            authDialog.ShowDialog();

            // Load in our credentials object
            Credentials.Credentials rbCredentials = Credentials.Credentials.Create(serverUrl, logger);
            return(rbCredentials);
        }
Ejemplo n.º 19
0
        /*
         * Method        : ParseQueryTeamMessage
         * Returns       : Stream of the class containing the needed data
         * Parameters    : Stream of the class containing the needed data and a string of the message to be parsed
         * Description   : Builds string to send to the registry
         */
        public static string ParseQueryTeamMessage(Data data, string message)
        {
            Logging.Logging log            = new Logging.Logging();
            char[]          delimiterChars = { '|' };
            string[]        words          = message.Split(delimiterChars);

            if (words[1] == "OK")
            {
                message  = words[1];
                data.log = message;
                log.logger(message);
            }
            else
            {
                data.log = message;
                log.logger(message);
            }
            return(message);
        }
Ejemplo n.º 20
0
        /*
        * Method        : ParseQueryTeamMessage
        * Returns       : Stream of the class containing the needed data
        * Parameters    : Stream of the class containing the needed data and a string of the message to be parsed
        * Description   : Builds string to send to the registry
        */
        public static string ParseQueryTeamMessage(Data data, string message)
        {
            Logging.Logging log = new Logging.Logging();
            char[] delimiterChars = {'|'};
            string[] words = message.Split(delimiterChars);

            if (words[1] == "OK")
            {
                message = words[1];
                data.log = message;
                log.logger(message);
            }
            else
            {
                data.log = message;
                log.logger(message);
            }
            return message;
        }
Ejemplo n.º 21
0
        private static void messageRegister(Socket handler, String data)
        {
            Logging.Logging log = new Logging.Logging();

            Data   dataFromClient = ExecuteServiceMessage.ParseExecuteServiceMessage(data);
            string message        = QueryTeamMessage.SendQueryTeamMessage(dataFromClient);

            log.logger(message);

            string answer = registryConnector.connectReg(message, "127.0.0.1", 3128);
            string isOkay = QueryTeamMessage.ParseQueryTeamMessage(dataFromClient, answer);

            log.logger(isOkay);

            double[] returnedData = Purchase_Totaller_BL.Totaller.getTotal(dataFromClient.argValue2, dataFromClient.argValue1);

            dataFromClient = ExecuteServiceMessage.createReturnMessage(returnedData);
            log.logger(dataFromClient.log);
            SendToClient(handler, dataFromClient.message);
        }
        //
        // Returns the log for a specific revision
        //
        public static string GetLog(string workingDirectory, string revision, bool xml, Logging.Logging logger)
        {
            // Generate the info
            string infoPath = string.Format(@"log ""{0}"" --revision {1} {2}", workingDirectory, revision, xml == true ? "--xml" : "");

            logger.Log("Running SVN command '{0}'", infoPath);

            // Run the process
            Process.Output infoOutput = Process.Start(null, "svn", infoPath);
            if (string.IsNullOrWhiteSpace(infoOutput.StdOut) == true)
            {
                logger.Log("Log command generated no output");
                return(null);
            }

            // Sanitise it
            string sanitisedOutput = infoOutput.StdOut.Replace("\r\n", "\n");

            logger.Log("Command returned\n{0}\n", sanitisedOutput);

            // Done
            return(sanitisedOutput);
        }
Ejemplo n.º 23
0
        private static void messageRegister(Socket handler, String data)
        {
            Logging.Logging log = new Logging.Logging();

            Data dataFromClient = ExecuteServiceMessage.ParseExecuteServiceMessage(data);
            string message = QueryTeamMessage.SendQueryTeamMessage(dataFromClient);
            log.logger(message);

            string answer = registryConnector.connectReg(message, "127.0.0.1", 3128);
            string isOkay = QueryTeamMessage.ParseQueryTeamMessage(dataFromClient, answer);
            log.logger(isOkay);

            double[] returnedData = Purchase_Totaller_BL.Totaller.getTotal(dataFromClient.argValue2, dataFromClient.argValue1);

            dataFromClient = ExecuteServiceMessage.createReturnMessage(returnedData);
            log.logger(dataFromClient.log);
            SendToClient(handler, dataFromClient.message);
        }
Ejemplo n.º 24
0
 public Nieuwe_Wedstrijd()
 {
     LoggingService = new Logging.Logging(1);
     InitializeComponent();
 }
Ejemplo n.º 25
0
 public ExtStorage()
 {
     this._logger = new Logging.Logging();
 }
Ejemplo n.º 26
0
 public Wedstrijdschema()
 {
     InitializeComponent();
     LoggingService = new Logging.Logging(1);
     vulGrid("");
 }
        //
        // Creates a new credentials file for a given server
        //
        public static Credentials Create(string server, string user, string password, Logging.Logging logger)
        {
            logger.Log("Creating credentials for {0} using username", server, user);

            // Encrypt the password
            password = Cipher.Encrypt(password, Identifiers.UUID);
            StoreCredentials(typeof(Simple).Name, server, new string[] { user, password }, logger);

            // Load the credentials in
            Credentials loadedCredentials = Create(server, logger);

            return(loadedCredentials);
        }
 /// <summary>
 /// Merely to be called when setting up listeners. Will link listeners and extensions.
 /// </summary>
 /// <param name="folderPath">The path of the folder containing extensions</param>
 /// <param name="output">The dictionary to put the link between ports and extensions</param>
 /// <param name="logOutput">Default : null. Logger to log information (ex : listener set up)</param>
 public static void FolderSetup_listeners(string folderPath, Dictionary <PEndPoint, ServerExtensionInitializer> output, Logging.Logging logOutput = null)
 {
     foreach (var file in Directory.GetFiles(folderPath))
     {
         if (!file.EndsWith(".dll") || !Path.GetFileName(file).StartsWith("Extension."))
         {
             continue;
         }
         LoadAssembly(file, output, logOutput);
     }
 }
Ejemplo n.º 29
0
        //
        // Authenticates against the given Jira server
        //
        private static Result Authenticate(string server, string username, string password, Logging.Logging logger)
        {
            // Check we have the properties we need
            bool validServer   = string.IsNullOrWhiteSpace(server) == false;
            bool validUser     = string.IsNullOrWhiteSpace(username) == false;
            bool validPassword = string.IsNullOrWhiteSpace(password) == false;

            // If it's not valid, throw and we're done
            if (validServer == false || validUser == false || validPassword == false)
            {
                logger.Log("Invalid server, username or password requested");
                throw new ArgumentException("Invalid server, username or password requested");
            }

            // Create our rest client
            Atlassian.Jira.Jira jiraInstance = null;
            try
            {
                jiraInstance = Atlassian.Jira.Jira.CreateRestClient(server, username, password);
            }
            catch (Exception e)
            {
                string message = string.Format("Unable to generate Jira instance for user '{0}'\n\n{1}", username, e.InnerException.Message);

                logger.Log(message);
                throw new InvalidOperationException(message);
            }

            // Check we can access this user
            try
            {
                // Pull out the user
                Task <Atlassian.Jira.JiraUser> thisUser = jiraInstance.Users.GetUserAsync(username);
                thisUser.Wait();

                // If we get here, the user exists and is fine
            }
            catch (Exception)
            {
                string message = string.Format("Unable to access Jira user '{0}'\n\nIf your username and password is correct, it is likely you have been locked out of your account.\n\nPlease visit {1} to unlock your account and then try again", username, server);

                logger.Log(message);
                throw new InvalidOperationException(message);
            }

            // Return the result
            return(new Result(true, "Successfully authenticated against the Jira server"));
        }
Ejemplo n.º 30
0
 public Nieuw_Team()
 {
     LoggingService = new Logging.Logging(1);
     InitializeComponent();
 }
Ejemplo n.º 31
0
 public MainWindow()
 {
     LoggingService = new Logging.Logging(1);
     InitializeComponent();
     setKnoppen();
 }
Ejemplo n.º 32
0
 private void LoadPackageAsync(string packageFilePath)
 {
     string rootPath = ConfigurationManager.AppSettings["ROOT_PATH"];
     string logPath = ConfigurationManager.AppSettings["LOG_PATH"];
     IExecutionContext context = new Gin.Context.ExecutionContext(rootPath);
     Logging.Logging log = new Logging.Logging();
     log.AutoFlushLoggers = true;
     log.AddLogger(new ExecutionLoggerTextFile(logPath));
     context.Log = log;
     Package pkg = new Package(context);
     SetCurrentStatus("Загрузка пакета");
     SetFilePathStatus(packageFilePath);
     pkg.Load(packageFilePath);
     BuildPackageTree(pkg);
 }
Ejemplo n.º 33
0
        //
        // Authenticates against the given RB server
        //
        private static Result Authenticate(string server, string username, string password, Logging.Logging logger)
        {
            // Check we have the properties we need
            bool validServer   = string.IsNullOrWhiteSpace(server) == false;
            bool validUser     = string.IsNullOrWhiteSpace(username) == false;
            bool validPassword = string.IsNullOrWhiteSpace(password) == false;

            // If it's not valid, throw and we're done
            if (validServer == false || validUser == false || validPassword == false)
            {
                logger.Log("Invalid server, username or password requested");
                throw new ArgumentException("Invalid server, username or password requested");
            }

            // Attempt to authenticate with the server
            string commandOptions = string.Format(@"login --server {0} --username {1} --password {2}", server, username, password);
            string rbtPath        = RB_Tools.Shared.Targets.Reviewboard.Path();

            logger.Log("Requesting authentication");
            logger.Log(" * {0} {1}", rbtPath, commandOptions.Replace(password, @"*****"));

            // Run the process
            Utilities.Process.Output output = Utilities.Process.Start(string.Empty, rbtPath, commandOptions);
            string errorFlag    = "ERROR: ";
            string criticalFlag = "CRITICAL: ";

            // Annoyingly, rbt seems to only post to stderr
            bool succeeded = string.IsNullOrWhiteSpace(output.StdErr) == true;

            if (succeeded == false)
            {
                logger.Log("Querying Standard Error for actual error message");
                succeeded = (output.StdErr.StartsWith(errorFlag) == false && output.StdErr.StartsWith(criticalFlag) == false);
            }

            // How did we do?
            string messageToShow = output.StdErr;

            if (succeeded == true)
            {
                logger.Log("Authentication succeeded");
                messageToShow = @"Successfully authenticated against the Reviewboard server";
            }
            else
            {
                logger.Log("Authentication failed - {0}", messageToShow);
            }

            // Return the result
            return(new Result(succeeded, messageToShow.Trim()));
        }
Ejemplo n.º 34
0
 private IExecutionContext CreateExecutionContext()
 {
     string rootPath = ConfigurationManager.AppSettings["ROOT_PATH"];
     string logPath = ConfigurationManager.AppSettings["LOG_PATH"];
     IExecutionContext context = new ExecutionContext(rootPath);
     context.ControlContainer = panelMain;
     Logging.Logging log = new Logging.Logging();
     log.AutoFlushLoggers = true;
     log.AddLogger(new ExecutionLoggerTextFile(logPath));
     log.AddLogger(new ExecutionLoggerMessageBox(this));
     log.SetProgress(new ExecutionProgressWindowsForms(MainProgressBar, MainProgressLabel));
     context.Log = log;
     return context;
 }
        //
        // Saves a given credentials file
        //
        private static void StoreCredentials(string type, string server, string[] data, Logging.Logging logger)
        {
            logger.Log("Storing credentials for {0} using credentials type {1}", server, type);

            // Get the file path
            string path = GetServerFilePath(server);

            // Write our the data
            using (StreamWriter file = new StreamWriter(path))
            {
                // Write out the header info
                file.WriteLine(type);
                file.WriteLine(server);

                // Write out the specific data
                foreach (string thisLine in data)
                {
                    file.WriteLine(thisLine);
                }
            }
            logger.Log(" * Credentials stored - {0}", path);
        }
        /// <summary>
        /// Load a single extension. Has the same usage value as <see cref="FolderSetup_listeners(string, Dictionary{int, ServerExtensionInitializer}, Logging.Logging)"/>
        /// </summary>
        /// <param name="asmPath">Path to the assembly extension</param>
        /// <param name="output">The dictionary to put the link between ports and extensions</param>
        /// <param name="logOutput">Default : null. Logger to log information (ex : listener set up)</param>
        public static void LoadAssembly(string asmPath, Dictionary <PEndPoint, ServerExtensionInitializer> output, Logging.Logging logOutput = null)
        {
            var asm = Assembly.Load(File.ReadAllBytes(asmPath));

            foreach (var tstr in INTERACTION_CLASSES)
            {
                Type t = asm.GetType(tstr);
                if (t == null)
                {
                    continue;
                }
                MethodInfo minfo = t.GetMethod(LOAD_METHOD);
                if (minfo == null)
                {
                    continue;
                }

                var dic = (Dictionary <PEndPoint, Action <Client> >)minfo.Invoke(null, new object[] { logOutput });
                foreach (var entry in dic)
                {
                    if (output.ContainsKey(entry.Key))
                    {
                        if (logOutput != null)
                        {
                            logOutput.Alert("Assembly " + Path.GetFileNameWithoutExtension(asmPath) + " tried to bind port " + entry.Key.Port + ". That port is already bound");
                        }
                        continue;
                    }

                    output.Add(entry.Key, new ServerExtensionInitializer(asm, entry.Value, asmPath));
                    Listener.Instantiate(entry.Key);
                    if (logOutput != null)
                    {
                        logOutput.Log("Listener set up on port " + entry.Key.Port + " for assembly " + Path.GetFileNameWithoutExtension(asmPath));
                    }
                }
            }

            LOADED_ASSEMBLYS.Add(asm.GetName().Name, asm);
            EXTENSIONS_PATH.Add(asm.GetName().Name, asmPath);

            if (logOutput != null)
            {
                logOutput.Info("Extension assembly " + asm.GetName().Name + " loaded");
            }
        }
Ejemplo n.º 37
0
        private IExecutionContext CreateContext(string cookie)
        {
            IExecutionContext context = new Gin.Context.ExecutionContext(_ginRoot);
            Logging.Logging loggingObject = new Logging.Logging();

            Directory.CreateDirectory(_cookiePath);

            string mainLoggerPath = Path.Combine(_ginRoot, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME);
            ExecutionLogger mainFileLogger = new ExecutionLoggerTextFile(mainLoggerPath);
            loggingObject.AddLogger(mainFileLogger);

            string textLoggerPath = Path.Combine(_cookiePath, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME);
            ExecutionLogger textFileLogger = new ExecutionLoggerTextFile(textLoggerPath);
            loggingObject.AddLogger(textFileLogger);
            _state.LogPath = textLoggerPath;

            _progressProxy = new ExecutionProgressProxy(OnProgress);
            loggingObject.SetProgress(_progressProxy);

            context.Log = loggingObject;

            return context;
        }
Ejemplo n.º 38
0
        public void TestInit()
        {
            _context = new ExecutionContextMock();
            _testCommand = new EmptyCommand();
            _testCommand.UserInfo = new UserInfoEmbedded
            {
                MessageGuid = "guid",
                MessageText = "text"
            };

            Logging.Logging log = new Logging.Logging();
            _logger = new ExecutionLoggerMock();
            log.AddLogger(_logger);
            _context.Log = log;
        }