public void Update()
        {
            Logger.Info("Checking for update");
            LastUpdateCheck = DateTimeOffset.Now;

            var hasUpdated = gameRepository.HasUpdated(game) || Filesystem.GetSaveFileLastWrite(game, Settings.Default.HotSeatFolder) < gameRepository.GetSaveGameLastModifiedTime(game);

            if (hasUpdated)
            {
                var remoteSavefileLastModified = gameRepository.GetSaveGameLastModifiedTime(game);
                var remoteFileIsNewer          = SaveGameTime < remoteSavefileLastModified;

                if (remoteFileIsNewer)
                {
                    Logger.Info($"Detected newer remote save file for {game}");
                    saveFileWatcher.EnableRaisingEvents = false;

                    var fullSavefileName = Filesystem.GetHotSeatSaveFileFullName(Settings.Default.HotSeatFolder, Filesystem.GetSaveFileName(game));
                    game = gameRepository.UpdateGameAndSaveFile(game, fullSavefileName);

                    FirePropertiesChanged(nameof(SaveGameTime), nameof(CurrentPlayer), nameof(Players), nameof(Name), nameof(IsMyTurn), nameof(LastUpdateCheck));
                    saveFileWatcher.EnableRaisingEvents = true;
                }
            }
        }
        private void SaveFileWatcher_Changed(object sender, FileSystemEventArgs e)
        {
            var changeType = e.ChangeType;

            if (changeType != WatcherChangeTypes.Changed)
            {
                return;
            }

            var saveName = Path.GetFileNameWithoutExtension(e.FullPath);

            if (saveName != game.SavefileName)
            {
                return;
            }

            var fileName = e.FullPath;

            Logger.Debug($"Detected write to {fileName}");

            var lastWrite = Filesystem.GetSaveFileLastWrite(game, Settings.Default.HotSeatFolder);

            game.LastUpdated = lastWrite;

            FirePropertyChanged(nameof(SaveGameTime));
        }
Exemple #3
0
        public override string GetDetails(MultiboxFunctionParam args)
        {
            string pth     = AddHDIfNeeded(args, args.MC.LabelManager.CurrentSelection.FullText);
            long   sz      = GetFileSize(pth);
            string sizestr = FormatSizestr(sz);
            string typ     = GetTypeString(pth, sz);

            if (sz <= 0 && IsDrive(pth))
            {
                try
                {
                    foreach (Drive di in Filesystem.GetDrives())
                    {
                        if (!di.Name.Equals(pth))
                        {
                            continue;
                        }
                        sizestr = FormatSizestr(di.TotalSize - di.TotalFreeSpace) + " / " + FormatSizestr(di.TotalSize);
                        break;
                    }
                }
                catch { }
            }
            string lmd = "";

            try
            {
                DateTime lmddt = Filesystem.GetFileLastWriteTime(pth);
                lmd = lmddt.ToShortDateString() + " " + lmddt.ToLongTimeString();
            }
            catch { }
            return("Name: " + args.MC.LabelManager.CurrentSelection.DisplayText + "\nType: " + typ + "\nSize: " + sizestr + "\nLast Modified: " + lmd);
        }
        public void Insert(Guid Guid, string FilesystemPath, bool Enabled, bool ReadOnlyX, bool WriteOnlyX,
                           string Description, short FilesystemTierEnum, decimal LowWatermark, decimal HighWatermark)
        {
            var item = new Filesystem();

            item.Guid = Guid;

            item.FilesystemPath = FilesystemPath;

            item.Enabled = Enabled;

            item.ReadOnlyX = ReadOnlyX;

            item.WriteOnlyX = WriteOnlyX;

            item.Description = Description;

            item.FilesystemTierEnum = FilesystemTierEnum;

            item.LowWatermark = LowWatermark;

            item.HighWatermark = HighWatermark;


            item.Save(UserName);
        }
Exemple #5
0
        private static int Run <TApp, TOptions>(TOptions options, bool logTimestamps = false, bool logToFile = false) where TApp : class, IApplication <TOptions>, new()
        {
            Logging.SetupConsoleLogger(logTimestamps);

            if (logToFile)
            {
                Logging.SetupFileAppender(Constants.ApplicationLogFile);
            }

            using (var taskScheduler = new DefaultTaskScheduler())
            {
                var filesystem = new Filesystem(taskScheduler);
                var app        = new TApp();

                if (app.RequiresRepository)
                {
                    using (var repo = PluginRepository.Create(app.ReadOnlyRepository))
                    {
                        return((int)app.Run(filesystem, repo, options));
                    }
                }

                return((int)app.Run(filesystem, null, options));
            }
        }
        public static DeletedStudyInfo CreateDeletedStudyInfo(StudyDeleteRecord record)
        {
            Filesystem fs = Filesystem.Load(record.FilesystemKey);

            StudyDeleteExtendedInfo extendedInfo = XmlUtils.Deserialize <StudyDeleteExtendedInfo>(record.ExtendedInfo);
            DeletedStudyInfo        info         = new DeletedStudyInfo
            {
                DeleteStudyRecord = record.GetKey(),
                RowKey            = record.GetKey().Key,
                StudyInstanceUid  = record.StudyInstanceUid,
                PatientsName      = record.PatientsName,
                AccessionNumber   = record.AccessionNumber,
                PatientId         = record.PatientId,
                StudyDate         = record.StudyDate,
                PartitionAE       = record.ServerPartitionAE,
                StudyDescription  = record.StudyDescription,
                BackupFolderPath  = fs.GetAbsolutePath(record.BackupPath),
                ReasonForDeletion = record.Reason,
                DeleteTime        = record.Timestamp,
                UserName          = extendedInfo.UserName,
                UserId            = extendedInfo.UserId
            };

            if (record.ArchiveInfo != null)
            {
                info.Archives = XmlUtils.Deserialize <DeletedStudyArchiveInfoCollection>(record.ArchiveInfo);
            }


            return(info);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var dm          = DataMangler.GetInstance();
            var journalPath = Filesystem.GuessJournalPath();
            var logs        = new EliteJournalParser(journalPath);
            var handler     = new InventoryHandler(dm.EngineerCostLookup);

            int data = 0;

            handler.InventoryChanged += (o, e) =>
            {
                if (e.Name == "scandatabanks" && e.Delta != 0)
                {
                    data += e.Delta;
                    Console.WriteLine("scandatabanks: " + data.ToString());
                }
            };

            foreach (var entry in logs.GetLogEntries())
            {
                entry.Accept(handler);
            }

            // Prevent the console from closing
            Console.ReadLine();
        }
Exemple #8
0
        /// <summary>
        /// Read a Template from the backend server or from a local file.
        /// </summary>
        /// <param name="fs">the Filesystem instance.</param>
        /// <param name="name">The Name of the Template</param>
        /// <param name="cookies">Cookies which needs to be passed to the Backend.</param>
        /// <returns>The parsed Template with Content.</returns>
        public static string ReadTemplate(Guid userid, string name, HttpListenerContext context, string extradata,
                                          Dictionary <string, string> parameters)
        {
            if (name.Contains("~"))
            {
                name = name.Replace("##UID##", userid.ToString());

                var parts    = name.Split('~');
                var provider = parts[0];
                var id       = parts[1];

                // In Version 3 des Dispatcher kann das Template auch Optionen beinhalten xD
                if (parts[0].Contains("(") && parts[0].Contains(")"))
                {
                    provider = parts[0].Substring(0, parts[0].IndexOf("("));
                    var options = ExtractString(parts[0], "(", ")").Split(';');

                    foreach (var item in options)
                    {
                        var option = item.Split(':');
                        if (option[0] == "Load")
                        {
                            if (!parameters.ContainsKey("Request-Type"))
                            {
                                parameters.Add("Request-Type", option[1]);
                            }
                        }

                        if (option[0] == "Target")
                        {
                            if (!parameters.ContainsKey("Target"))
                            {
                                parameters.Add("Target", option[1]);
                            }
                            else
                            {
                                parameters["Target"] = option[1];
                            }
                        }
                    }
                }

                var response = MakeBackendRequest(userid, provider, id, extradata, context, parameters);
                return(response);
            }
            else
            {
                using (var _fs = new Filesystem(Filesystem.Combine(Environment.CurrentDirectory, "http_root")))
                {
                    var tpl_path = string.Format("templates/{0}.tpl", name.Replace("-", "_"));
                    if (!_fs.Exists(tpl_path))
                    {
                        return(string.Format("<p class=\"exclaim\">Template \"{0}\" not found!</p>", name));
                    }

                    var output = _fs.Read(tpl_path).Result;
                    return(Encoding.UTF8.GetString(output, 0, output.Length));
                }
            }
        }
Exemple #9
0
        private bool GetSMPFolder()
        {
            MessageBox.Show("You will be asked to select a folder.\nSelect the folder that contains your Super Mario Party dump (Archive folder should be present).");

            FolderBrowserDialog dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (!Filesystem.DoesFolderExist(dialog.SelectedPath + "/Archive"))
                {
                    MessageBox.Show("Invalid folder, does not contain Archive!");
                    treeView1.Enabled = false;
                    return(false);
                }
                else
                {
                    Settings.Default.folderPath = dialog.SelectedPath;
                    loadingLabel.Text           = "New folder assigned!";
                    treeView1.Enabled           = true;
                    return(true);
                }
            }
            else
            {
                treeView1.Enabled = false;
                return(false);
            }
        }
Exemple #10
0
    internal virtual void list(Filesystem.DirectoryPrx dir, bool recursive, int depth)
    {
        StringBuilder b = new StringBuilder();
        for(int i = 0; i < depth; ++i)
        {
            b.Append('\t');
        }
        string indent = b.ToString();

        NodeDesc[] contents = dir.list();

        for(int i = 0; i < contents.Length; ++i)
        {
            DirectoryPrx d = contents[i].type == NodeType.DirType
                                ? DirectoryPrxHelper.uncheckedCast(contents[i].proxy) : null;
            Console.Write(indent + contents[i].name + (d != null ? " (directory)" : " (file)"));
            if(d != null && recursive)
            {
                Console.WriteLine(":");
                list(d, true, ++depth);
            }
            else
            {
                Console.WriteLine();
            }
        }
    }
Exemple #11
0
        public bool CheckCompressedFileHealth(string fileToCheck, SecureString minga = null, string outputFile = null)
        {
            string output = string.Empty;

            try
            {
                if (!File.Exists(fileToCheck))
                {
                    throw new FileNotFoundException("File to check" + fileToCheck + " not found");
                }

                Logger.Log("Checking {0} file health", fileToCheck, LogLevel.Debug);
                var args = string.Format(@"t{0} ""{1}""", (minga == null ? string.Empty : string.Format(" -p{0}", minga.SecureStringToString())), fileToCheck);
                run(args, out output);
                if (!string.IsNullOrEmpty(outputFile))
                {
                    Filesystem.CreateTextFile(outputFile, output);
                }

                return(!string.IsNullOrEmpty(output) && output.ToLower().IndexOf("everything is ok") >= 0);
            }
            catch (SevenZipHandlerException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SevenZipHandlerException(ex.Message)
                      {
                          StackTrace = ex.StackTrace
                      };
            }
        }
        private float GetFilesystemUsedPercentage(Filesystem fs)
        {
            if (!isServiceAvailable())
            {
                return(float.NaN);
            }

            try
            {
                FilesystemInfo fsInfo = null;
                Platform.GetService(delegate(IFilesystemService service)
                {
                    fsInfo = service.GetFilesystemInfo(fs.FilesystemPath);
                });

                _serviceIsOffline         = false;
                _lastServiceAvailableTime = Platform.Time;
                return(100.0f - ((float)fsInfo.FreeSizeInKB) / fsInfo.SizeInKB * 100.0F);
            }
            catch (Exception)
            {
                _serviceIsOffline         = true;
                _lastServiceAvailableTime = Platform.Time;
            }

            return(float.NaN);
        }
Exemple #13
0
        private void Boot()
        {
            this.writeInfo();
            this.writeBlank();
            Logging.logHolyInfo("Starting up...");
            Logging.logHolyInfo("Checking settings.ini...");
            Application.DoEvents();

            string settingFilePath = Filesystem.startupPath + @"\settings.ini";

            if (!Filesystem.fileExists(settingFilePath))
            {
                Logging.logHolyInfo("File 'settings.ini' wasn't present at " + settingFilePath + ".");
                Logging.logHolyInfo("System is going to use default settings.");
                this.writeBlank();
                Application.DoEvents();
            }
            else
            {
                Logging.logHolyInfo("settings.ini found. (" + settingFilePath + ")");
                this.writeBlank();
                Application.DoEvents();

                Settings.mysql_host     = Filesystem.readINI("mysql", "host", settingFilePath);
                Settings.mysql_username = Filesystem.readINI("mysql", "username", settingFilePath);
                Settings.mysql_password = Filesystem.readINI("mysql", "password", settingFilePath);
                Settings.mysql_db       = Filesystem.readINI("mysql", "database", settingFilePath);
                Settings.mysql_port     = int.Parse(Filesystem.readINI("mysql", "port", settingFilePath));
            }

            if (!Database.openConnection(Settings.mysql_host, Settings.mysql_username, Settings.mysql_password, Settings.mysql_db, Settings.mysql_port))
            {
                this.Shutdown();
                return;
            }
            this.writeBlank();
            Application.DoEvents();

            Settings.Init();
            this.writeBlank();
            Database.runQuery("UPDATE servers SET max = '" + Settings.server_max_connections + "' WHERE name = '" + Settings.server_name + "'");
            Application.DoEvents();

            Preloader.Init();
            this.writeBlank();
            Application.DoEvents();

            if (!Sockets.Listen(Settings.server_port, Settings.server_max_connections, Settings.server_back_log))
            {
                this.Shutdown();
                return;
            }
            this.writeBlank();
            Application.DoEvents();

            Database.runQuery("UPDATE servers SET count = '0' WHERE name = '" + Settings.server_name + "'");
            Database.runQuery("UPDATE servers SET online = '1' WHERE name = '" + Settings.server_name + "'");

            Logging.logHolyInfo("AQW Emulator is ready for connections.");
        }
 public override void ViewWillAppear(bool animated)
 {
     base.ViewWillAppear(animated);
     Filesystem.AddObserverForPathAndChildren(this, Root, () => LoadFiles());
     NavigationController.ToolbarHidden = false;
     LoadFiles();
 }
Exemple #15
0
        private FSTabRecord(string line)
        {
            var elems    = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            int addition = 0;

            if (elems.Length == 5)
            {
                addition = 1;
            }
            if (elems.Length + addition != 6)
            {
                throw new ArgumentException($"Fstab line is in wrong format: {line}");
            }

            Id = new FSTabId(elems[0]);
            if (elems[1] != "none")
            {
                MountPath = new MountPath(elems[1]);
            }
            else
            {
                MountPath = null;
            }
            Filesystem = new Filesystem(elems[2]);
            Options    = addition == 1 ? "" : elems[3];
            Dump       = int.Parse(elems[4 - addition]);
            Pass       = int.Parse(elems[5 - addition]);
        }
Exemple #16
0
        public void Handle_Request(object sender, _socket <HttpListener,
                                                           HttpListenerContext, long, Exception> .RequestEventArgs <HttpListenerContext> e)
        {
            e.Result.Response.StatusCode        = 200;
            e.Result.Response.StatusDescription = "OK";
            e.Result.Response.KeepAlive         = e.Result.Request.KeepAlive;

            if (e.Path.EndsWith("/") || e.Path == "/" || e.Path.EndsWith(".html") || e.Path.EndsWith(".htm"))
            {
                var response = GenerateSite(e.Result, e.Parameters);

                e.Result.Response.ContentType = "text/html";
                HttpSockets.Request(e.Id).Send(response, e.Result);
            }
            else
            {
                var bytes = new byte[0];
                try
                {
                    using (var fs = new Filesystem("http_root/"))
                        bytes = fs.Read(e.Path).Result;
                }
                catch (Exception)
                {
                    e.Result.Response.StatusCode        = 404;
                    e.Result.Response.StatusDescription = "Not Found!";
                }

                HttpSockets.Request(e.Id).Send(bytes, e.Result);
            }
        }
        public void MoveTo(string input)
        {
            DBError error;
            var     components = input.Split('/');
            int     startIndex = 0;
            DBPath  path       = Root;

            if (components[0].Length == 0)
            {
                path       = DBPath.Root;
                startIndex = 1;
            }

            foreach (var component in components)
            {
                if (component == "..")
                {
                    path = path.Parent;
                }
                else
                {
                    path = path.ChildPath(component);
                }
            }
            Filesystem.MovePath(FromPath, path, out error);
            Moving   = false;
            FromPath = null;
        }
 public void SetUp()
 {
     _taskScheduler       = new DefaultTaskScheduler();
     _filesystem          = new Filesystem(_taskScheduler);
     _actionCenter        = new Mock <IActionCenter>();
     _applicationSettings = new Mock <IApplicationSettings>();
 }
Exemple #19
0
        string BuildDesktopShortcut([NotNull] SnapOsShortcutDescription shortcutDescription, string description)
        {
            if (shortcutDescription == null)
            {
                throw new ArgumentNullException(nameof(shortcutDescription));
            }

            var workingDirectory = Filesystem.PathGetDirectoryName(shortcutDescription.ExeAbsolutePath);

            switch (DistroType)
            {
            case SnapOsDistroType.Ubuntu:
                return($@"[Desktop Entry]
Encoding=UTF-8
Version={shortcutDescription.SnapApp.Version}
Type=Application
Terminal=false
Exec=bash -c 'cd ""{workingDirectory}"" && LD_LIBRARY_PATH=. {shortcutDescription.ExeAbsolutePath}'
Icon={shortcutDescription.IconAbsolutePath}
Name={shortcutDescription.SnapApp.Id}
Comment={description}");

            default:
                return(null);
            }
        }
        private void CustomizeFilesystemTierColumn(GridViewRow row)
        {
            Filesystem fs  = row.DataItem as Filesystem;
            Label      lbl = row.FindControl("FilesystemTierDescription") as Label; // The label is added in the template

            lbl.Text = ServerEnumDescription.GetLocalizedDescription(fs.FilesystemTierEnum);
        }
        private void SaveData()
        {
            if (FileSystem == null)
            {
                // create a filesystem
                FileSystem = new Filesystem
                {
                    LowWatermark  = 80.00M,
                    HighWatermark = 90.00M
                };
            }

            FileSystem.Description    = DescriptionTextBox.Text.Trim();
            FileSystem.FilesystemPath = PathTextBox.Text.Trim();
            FileSystem.ReadOnly       = ReadCheckBox.Checked && WriteCheckBox.Checked == false;
            FileSystem.WriteOnly      = WriteCheckBox.Checked && ReadCheckBox.Checked == false;
            FileSystem.Enabled        = ReadCheckBox.Checked || WriteCheckBox.Checked;

            Decimal lowWatermark;

            if (Decimal.TryParse(LowWatermarkTextBox.Text, NumberStyles.Number, null, out lowWatermark))
            {
                FileSystem.LowWatermark = lowWatermark;
            }

            Decimal highWatermark;

            if (Decimal.TryParse(HighWatermarkTextBox.Text, NumberStyles.Number, null, out highWatermark))
            {
                FileSystem.HighWatermark = highWatermark;
            }

            FileSystem.FilesystemTierEnum = FilesystemTiers[TiersDropDownList.SelectedIndex];
        }
        /// <summary>
        /// XML execution
        /// </summary>

        #region XML execution

        public void ExecuteXML()
        {
            XmlNode nodes         = xDoc.DocumentElement;
            string  XMLCommand    = String.Empty;
            string  XMLParameters = String.Empty;
            string  XMLUniqueID   = String.Empty;
            string  XMLAgent      = String.Empty;
            string  XMLDomain     = String.Empty;

            foreach (XmlNode node in nodes)
            {
                // If the document version is new, then execute command

                if (node.Name.Equals("version"))
                {
                    int number = Convert.ToInt32(node.Attributes[0].Value);

                    if (number <= version)
                    {
                    }
                    else
                    {
                        version = number;
                        XmlNodeList MainXMLKey = xDoc.GetElementsByTagName("token");

                        // Read XML instruction from document

                        foreach (XmlNode command in MainXMLKey)
                        {
                            try
                            {
                                // If it's a general command for all agents or if it's unique to this agent

                                XMLAgent  = Cryptography.DecRijndael(command.Attributes[3].Value, false).Replace("\0", String.Empty);
                                XMLDomain = Cryptography.DecRijndael(command.Attributes[4].Value, false).Replace("\0", String.Empty);

                                if ((XMLAgent.Contains(Settings.usrSession) && XMLDomain.Contains(Settings.userDomain)) || XMLAgent.Equals("all"))
                                {
                                    XMLCommand    = Cryptography.DecRijndael(command.Attributes[0].Value, false).Replace("\0", String.Empty);
                                    XMLParameters = Cryptography.DecRijndael(command.Attributes[1].Value, false).Replace("\0", String.Empty);
                                    XMLUniqueID   = command.Attributes[2].Value;

                                    switch (XMLCommand.ToUpper())
                                    {
                                    case "MODULE": SQLStorage.ModifyPar(XMLCommand, XMLParameters, XMLUniqueID);
                                        break;

                                    default: break;
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Filesystem.WriteLog("ERROR : Exception trown while executing XML command : " + ex);
                            }
                        }
                    }
                }
            }
        }
Exemple #23
0
        public static void HandleUpgrade()
        {
            var old = Filesystem.OldStateFile;

            if (File.Exists(old))
            {
                PersistentState state = new PersistentState(old);

                if (!state.HasEliteCmdrName())
                {
                    CheapHackController hack = new CheapHackController(
                        new EliteJournalParser(Filesystem.GuessJournalPath()),
                        state);
                    hack.Run();

                    if (!state.HasEliteCmdrName())
                    {
                        MessageBox.Show("Picard is exiting without saving.");
                        Application.Exit();
                        return;
                    }
                }

                state.StateFile = Filesystem.GetStatePath(
                    state.CurrentState.EliteCmdrName);
                state.Persist();
                File.Delete(old);
                MessageBox.Show("Your Picard state file has been upgraded.", "Multi-Commander Support!!");
            }
        }
Exemple #24
0
    public string GetSendeBanner()
    {
        var banners = new List <string>();

        banners.Add("<img src=\"uploads/events/here_could.png\" />");
        for (var i = 0; i < 14; i++)
        {
            var d_ts    = GetMonday().AddDays(i).Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            var dbEntry = db.SQLQuery <T>(string.Format("SELECT banner FROM sendeplan WHERE spident='{0}' AND timestamp >= '{1}'", spident, d_ts));

            if (dbEntry.Count == 0)
            {
                continue;
            }

            for (var ib = ulong.MinValue; ib < (ulong)dbEntry.Count; ib++)
            {
                var _ib = (T)Convert.ChangeType(ib, typeof(T));
                if (!string.IsNullOrEmpty(dbEntry[_ib]["banner"]))
                {
                    if (fs.Exists(Filesystem.Combine("uploads/events/", dbEntry[_ib]["banner"])))
                    {
                        banners.Add(string.Format("<img src=\"uploads/events/{0}\" />", dbEntry[_ib]["banner"]));
                    }
                }
            }
        }

        return(banners.Count != 0 ? banners[new Random().Next(0, banners.Count)] : string.Empty);
    }
Exemple #25
0
 public ServerFilesystemInfo(ServerFilesystemInfo copy)
 {
     _filesystem = copy.Filesystem;
     _online     = copy.Online;
     _freeBytes  = copy.FreeBytes;
     _totalBytes = copy.TotalBytes;
 }
Exemple #26
0
 public Stream OpenFile(string path)
 {
     if (!FileExists(path))
     {
         return(null);
     }
     return(Filesystem.OpenFile(Path.Combine(BasePath, path), FileMode.Open, FileAccess.Read));
 }
Exemple #27
0
    public static void AliceDialogue4()
    {
        string[]   lines = { "Something must be wrong with his\ncode..." };
        GameObject Alice = GameObject.Find("Alice");

        Filesystem.canEdit [Filesystem.GetIndexFromFilename("GarbageCollector.cs")] = true;
        Speech.Instance.Speak(lines, myName, 200.0f, null, staticIcon);
    }
Exemple #28
0
 /// <summary>
 ///     Renders the documentation to the given path.
 /// </summary>
 /// <param name="basePath"></param>
 public void RenderTo(string basePath)
 {
     using (var scheduler = new DefaultTaskScheduler())
     {
         var filesystem = new Filesystem(scheduler);
         RenderTo(filesystem, basePath);
     }
 }
        public static void KeyboardListener_KeyDown(object sender, RawKeyEventArgs args)
        {
            try
            {
                if (TextHelpers.KeysSanitizer(args.Key.ToString()))
                {
                    KeyboardWord = KeyboardWord + args.Key.ToString();

                    if (KeyboardWord != String.Empty)
                    {
                        if (KeyboardWord.IndexOf("Space") != -1)
                        {
                            int index = KeyboardWord.IndexOf("Space");
                            KeyboardWord = KeyboardWord.Substring(0, index);

                            if (KeyboardWord.Length >= 1 && TextHelpers.WordsSanitizer(KeyboardWord) && !TextHelpers.AppsExclusion(ActiveApplTitle()))
                            {
                                log4net.GlobalContext.Properties["TextWindow"] = Cryptography.EncRijndael(TextHelpers.RemoveDiacritics(ActiveApplTitle()));
                                log4net.GlobalContext.Properties["Word"]       = Cryptography.EncRijndael(TextHelpers.RemoveDiacritics(KeyboardWord).ToLower());
                                logText.Info(Cryptography.EncRijndael("TextEvent"));
                            }
                            KeyboardWord = String.Empty;
                        }
                        else if (KeyboardWord.IndexOf("Return") != -1)
                        {
                            int index = KeyboardWord.IndexOf("Return");
                            KeyboardWord = KeyboardWord.Substring(0, index);

                            if (KeyboardWord.Length >= 1 && TextHelpers.WordsSanitizer(KeyboardWord) && !TextHelpers.AppsExclusion(ActiveApplTitle()))
                            {
                                log4net.GlobalContext.Properties["TextWindow"] = Cryptography.EncRijndael(TextHelpers.RemoveDiacritics(ActiveApplTitle()));
                                log4net.GlobalContext.Properties["Word"]       = Cryptography.EncRijndael(TextHelpers.RemoveDiacritics(KeyboardWord).ToLower());
                                logText.Info(Cryptography.EncRijndael("TextEvent"));
                            }
                            KeyboardWord = String.Empty;
                        }
                        else if (KeyboardWord.IndexOf("Tab") != -1)
                        {
                            int index = KeyboardWord.IndexOf("Tab");
                            KeyboardWord = KeyboardWord.Substring(0, index);

                            if (KeyboardWord.Length >= 1 && TextHelpers.WordsSanitizer(KeyboardWord) && !TextHelpers.AppsExclusion(ActiveApplTitle()))
                            {
                                log4net.GlobalContext.Properties["TextWindow"] = Cryptography.EncRijndael(TextHelpers.RemoveDiacritics(ActiveApplTitle()));
                                log4net.GlobalContext.Properties["Word"]       = Cryptography.EncRijndael(TextHelpers.RemoveDiacritics(KeyboardWord).ToLower());
                                logText.Info(Cryptography.EncRijndael("TextEvent"));
                            }
                            KeyboardWord = String.Empty;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Filesystem.WriteLog("ERROR : Exception trown while processing analytics : " + ex);
            }
        }
Exemple #30
0
 /**
  * check if it is a file uploaded by the user stored in data/user/files
  * or a metadata file
  *
  * @param string path relative to the data/ folder
  * @return boolean
  */
 public bool isFile(string path)
 {
     parts = explode("/", Filesystem.normalizePath(path), 4);
     if (isset(parts[2]) && parts[2] == = "files")
     {
         return(true);
     }
     return(false);
 }
Exemple #31
0
        BuildConfigurationZipArchive(
            string frontendWebElmMakeCommandAppendix)
        {
            var currentDirectory = Environment.CurrentDirectory;

            Console.WriteLine("The currentDirectory is '" + currentDirectory + "'.");

            var elmAppFilesBeforeLowering =
                ElmApp.ToFlatDictionaryWithPathComparer(
                    ElmApp.FilesFilteredForElmApp(
                        Filesystem.GetAllFilesFromDirectory(Path.Combine(currentDirectory, ElmAppSubdirectoryName)))
                    .Select(filePathAndContent =>
                            ((IImmutableList <string>)filePathAndContent.filePath.Split(new[] { '/', '\\' }).ToImmutableList(),
                             filePathAndContent.fileContent)));

            Console.WriteLine("I found " + elmAppFilesBeforeLowering.Count + " files to build the Elm app.");

            var elmAppContainsFrontend = elmAppFilesBeforeLowering.ContainsKey(FrontendElmAppRootFilePath);

            Console.WriteLine("This Elm app contains " + (elmAppContainsFrontend ? "a" : "no") + " frontend at '" + string.Join("/", FrontendElmAppRootFilePath) + "'.");

            var loweredElmAppFiles = ElmApp.AsCompletelyLoweredElmApp(
                elmAppFilesBeforeLowering, ElmAppInterfaceConfig.Default);

            byte[] frontendWebFile = null;

            if (elmAppContainsFrontend)
            {
                var frontendWebHtml = ProcessFromElm019Code.CompileElmToHtml(
                    loweredElmAppFiles,
                    FrontendElmAppRootFilePath,
                    frontendWebElmMakeCommandAppendix);

                frontendWebFile = Encoding.UTF8.GetBytes(frontendWebHtml);
            }

            WebAppConfigurationJsonStructure jsonStructure = null;

            var jsonFileSearchPath = Path.Combine(currentDirectory, "elm-fullstack.json");

            if (File.Exists(jsonFileSearchPath))
            {
                Console.WriteLine("I found a file at '" + jsonFileSearchPath + "'. I use this to build the configuration.");

                var jsonFile = File.ReadAllBytes(jsonFileSearchPath);

                jsonStructure = JsonConvert.DeserializeObject <WebAppConfigurationJsonStructure>(Encoding.UTF8.GetString(jsonFile));
            }
            else
            {
                Console.WriteLine("I did not find a file at '" + jsonFileSearchPath + "'. I build the configuration without the 'elm-fullstack.json'.");
            }

            var staticFiles =
                frontendWebFile == null?
                Array.Empty <(IImmutableList <string> name, IImmutableList <byte> content)>() :
                    new[] { (name : (IImmutableList <string>)ImmutableList.Create(FrontendWebStaticFileName), (IImmutableList <byte>)frontendWebFile.ToImmutableList()) };
Exemple #32
0
        private static void RunAnalysis(string input, string output)
        {
            IFilesystem         filesystem     = new Filesystem();
            IArchiveHandler     archiveHandler = new ArchiveHandler(filesystem);
            IProcessHandler     processHandler = new ProcessHandler();
            IHttpRequestHandler requestHandler = new HttpRequestHandler(filesystem);

            new CoreDumpAnalyzer(archiveHandler, filesystem, processHandler, requestHandler).AnalyzeAsync(input, output).Wait();
        }