public void Run(string batchFilePath) { File = _fs.File(batchFilePath); // if it's just a file name, // - look for it beside the folder if (!File.Found) { var path = _fs.GetAssemblyDir().Bslash(batchFilePath); File = _fs.File(path); } ExecuteCmd(File); }
private async Task <int> UploadLocalFile(RemoteVsLocalFile inf, CancellationToken cancelToken) { inf.Status = "Uploading local file..."; var locFile = _fs.File(inf.Local.Path); return(await _client.Post(locFile, cancelToken, _targetDir)); }
public FileShim File(string searchPattern, bool expect1Match = true) { if (!expect1Match) { return(_fs.File(Path.Bslash(searchPattern))); } Trace_i("Finding file: “{0}”...", searchPattern); string e; List <FileShim> ff; FileShim f = null; if (! _fs.TryGetDirFiles(this.Path, searchPattern, out ff, out e) ) { return(Error_o_(f, "Error in finding file." + L.F + e)); } if (ff == null) { return(Error_o_(f, "Didn't expect files list to be NULL.")); } if (ff.Count > 1) { return(Error_o_(f, "{0:file} matched the search pattern.", ff.Count)); } if (ff.Count == 0) { return(Warn_o_(f, "File not found.")); } return(Trace_o_(ff.FirstOrDefault(), "File found in folder: " + this.Path)); }
private void ApppendLogsTo(string logFileName, LogEventArg e) { if (logFileName.IsBlank()) { return; } switch (e.Level) { case L4j.Off: // case L4j.Debug: // ignore these levels case L4j.Trace: return; // } if (e.ShowAs != ShowLogAs.Normal) { return; } if (_logFile == null) { _logFile = _fs.File(_fs.GetAssemblyDir().Bslash(logFileName)); } var line = L.f + TextLog.Format(e.Title, e.Message); _logFile.Write(line, EncodeAs.UTF8, false, false); }
public SessionAuth(IFileSystemShim fsShim, ISerializer serializer) { _fs = fsShim; _serialzr = serializer; var dir = _fs.GetSpecialDir(SpecialDir.LocalApplicationData) .Bslash(ParentDir); SessionFile = _fs.File(dir.Bslash("d7.session")); }
public bool LocalizeSessionFile(IBasicAuthenticationKey authKey) { if (authKey.BaseUrl.IsBlank() || authKey.UserName.IsBlank()) return Warn_n("Cannot localize session file.", "BaseURL / UserName of AuthKey is blank."); var loc = _fsShim.GetSpecialDir(SpecialDir.LocalApplicationData); var typ = this.GetType().Name; var dom = authKey.BaseUrl.TextAfter("//").Replace(":", "-"); var usr = authKey.UserName;//.Replace(" ", "_"); var end = "user.session"; var path = loc.Bslash(typ).Bslash(dom).Bslash(usr).Bslash(end); _auth.SessionFile = _fsShim.File(path); return true; }
public virtual bool ReadFromExeDir(string fileName = "SqlServerKey.cfg") { var fPath = _fs.GetAssemblyDir().Bslash(fileName); var file = _fs.File(fPath); if (!file.Found) { var s = _serialr.Write(new SqlServerKey(), true); file.Write(s); return(Warn_n("Server key file not found. (new one created)", file.Path)); } var obj = _serialr.Read <SqlServerKey>(file); this.ServerURL = obj.ServerURL; this.DatabaseName = obj.DatabaseName; this.UserName = obj.UserName; this.Password = obj.Password; return(IsLoaded = true); }
protected T ReadAs <T>(string fileName) where T : IBasicAuthenticationKey { _file = _fs.File(_fs.GetAssemblyDir().Bslash(fileName)); if (!_file.Found) { return(Warn_(default(T), $"Missing login file “{fileName}”.", _file.Path)); } var ret = _serialr.Read <T>(_file); if (ret == null) { return(Error_(ret, $"Failed to parse ‹{typeof(T).Name}›.", "")); } UserName = ret.UserName; Password = ret.Password; BaseUrl = ret.BaseUrl; return(ret); }