Exemple #1
0
        public async Task CreateDirectory(JObject directoryJson)
        {
            DebugHandler.TraceMessage("CreateDirectory called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
            DebugHandler.TraceMessage(directoryJson.ToString(), DebugSource.TASK, DebugType.PARAMETERS);
            try
            {
                string filePath = directoryJson.Value <string>("path");
                if (filePath.Contains("//"))
                {
                    filePath.Replace("//", "/");
                }

                if (filePath.Contains("\\\\"))
                {
                    filePath.Replace("\\\\", "\\");
                }
                string result = DirectoryHandler.CreateDirectory(filePath, "");
                await WebSocketHandler.SendMessage(result);
            }
            catch (Exception e)
            {
                DebugHandler.TraceMessage(e.ToString(), DebugSource.TASK, DebugType.WARNING);

                JsonError error = new JsonError()
                {
                    type         = "create_directory_error",
                    errormessage = "Could not create directory.",
                    errortype    = "exception",
                    exception    = e.ToString()
                };

                await WebSocketHandler.SendMessage(error.ToJson());
            }
        }
        public async Task Setfullfilepath(JObject fullfilepathJson)
        {
            DebugHandler.TraceMessage("Setfullfilepath Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
            DebugHandler.TraceMessage(fullfilepathJson.ToString(), DebugSource.TASK, DebugType.PARAMETERS);
            try
            {
                string path = fullfilepathJson.Value <string>("path");
                DirectoryHandler.CreateDirectory(path, "");
                IrcSettings.fullfilepath = path;
                SetAllIrcSettings(IrcSettings);
                SettingsHandler.WriteIrcSettings(IrcSettings);
                await GetCurrentIrcSettings();
            }
            catch (Exception e)
            {
                DebugHandler.TraceMessage(e.ToString(), DebugSource.TASK, DebugType.WARNING);

                JsonError jsonError = new JsonError
                {
                    type         = "set_download_directory_error",
                    errortype    = "Exception",
                    errormessage = "Failed to set custom download directory.",
                    exception    = e.ToString()
                };

                await WebSocketHandler.SendMessage(jsonError.ToJson());
            }
        }