public override CommandResult Execute(Station station) { string message = string.Format("Performed Command: {0} for station {1}", this.Name, station.StationDescription); Console.WriteLine(message); CommandResultWritable result = new CommandResultWritable { Command = this, Station = station, Instance = null, Success = true, Message = message }; return result; }
public override CommandResult Execute(Station station, Instance instance) { FileInstanceInfo i = (FileInstanceInfo)instance; CommandResultWritable result = new CommandResultWritable { Command = this, Station = station, Instance = instance, Success = true, }; try { using (FileSystemConnectionManager.Instance.GetConnection(i.User, i.Password, i.Path)) { File.Delete(i.Path); } } catch (Exception ex) { result.Success = false; result.Message = Util.ExceptionMessageIncludingInners(ex); } return result; }
/// <summary> /// Perform the retry. Copies the file to a designated retry folder, /// using the ID as the file basename, /// and cleans up the failed file and associated files/records. /// </summary> /// <param name="station"></param> /// <param name="instance">Expect IFileInstanceInfo type, such as FileFolderInstance</param> /// <returns></returns> public override CommandResult Execute(Station station, Instance instance) { FileInstanceInfo i = (FileInstanceInfo)instance; FileRetryHandler handler = (FileRetryHandler)station; CommandResultWritable result = new CommandResultWritable { Command = this, Station = station, Instance = instance, Success = true, }; try { using (FileSystemConnectionManager.Instance.GetConnection(i.User, i.Password, i.Path)) { CopyToRetry(i); handler.CleanUpFailed(i); } } catch (Exception ex) { result.Success = false; result.Message = Util.ExceptionMessageIncludingInners(ex); if (possibleError != null) result.Message = result.Message + "; " + possibleError; } return result; }