public override async Task <CommandResult> Execute(string input) { if (RemoteConnectionManager.GetServiceClient() == null) { await RemoteConnectionManager.ConnectAsync(Settings.Default.ServerAddress, Settings.Default.PortNumber); } return(Succeeded(new[] { Settings.Default.ServerAddress })); }
private CharacterContext(Character character) { // いもうとの定義 Character = character; // ルートディレクトリ BaseDirectory = character.Directory; // プロファイルを読み込む Profile = Profile.LoadFrom(Path.Combine(BaseDirectory, "profile.yml")) ?? new Profile { Age = Character.Age, TsundereLevel = Character.TsundereLevel }; // バルーン読み込み Balloon = BalloonManager.GetValueOrDefault(Profile.LastBalloon); // ルートからイメージ用ディレクトリを作る SurfaceLoader = new SurfaceLoader(Path.Combine(BaseDirectory, "images")); // ウィンドウを作成する BalloonWindow = new BalloonWindow { Context = this, Balloon = Balloon, LocationOffset = Profile.BalloonOffset }; CharacterWindow = new CharacterWindow { Context = this, BalloonWindow = BalloonWindow }; // メニューのコマンドを定義する var contextMenu = CharacterWindow.ContextMenu; contextMenu.CommandBindings.Add(new CommandBinding(Input.DefaultCommands.Character, CharacterCommand_Executed, CharacterCommand_CanExecute)); contextMenu.CommandBindings.Add(new CommandBinding(Input.DefaultCommands.Balloon, BalloonCommand_Executed, BalloonCommand_CanExecute)); contextMenu.CommandBindings.Add(new CommandBinding(Input.DefaultCommands.Option, OptionCommand_Executed)); contextMenu.CommandBindings.Add(new CommandBinding(Input.DefaultCommands.Version, VersionCommand_Executed)); contextMenu.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseCommand_Executed)); // スクリプトエンジンを作成する ScriptEngine = new ScriptEngine(Path.Combine(BaseDirectory, "scripts")); InitializeScriptEngine(); // スクリプトプレイヤーを作成 ScriptPlayer = new ScriptPlayer(this); RemoteConnectionManager = new RemoteConnectionManager(); RemoteCommandManager = new RemoteCommandManager(Character, RemoteConnectionManager); }
protected override async Task <CommandResult> PreExecuteCore(string input) { var serviceClient = RemoteConnectionManager.GetServiceClient(); var match = Pattern.Match(input); var target = match.Groups[1].Value; var directory = (await serviceClient.GetCurrentDirectoryAsync(new Empty())).Path; _path = AbsolutePath(directory, target); return(Succeeded(new[] { Escape(_path) })); }
public RemoteCommandManager(Character character, RemoteConnectionManager remoteConnectionManager) { _commands = new CommandBase[] { new CallName(character.Name), new Connect(remoteConnectionManager), new Disconnect(remoteConnectionManager), new ChangeDirectory(remoteConnectionManager), new DosCommand(remoteConnectionManager), new ExecuteFile(remoteConnectionManager), new OpenFile(remoteConnectionManager), new DeleteFile(remoteConnectionManager), new ScreenShot(remoteConnectionManager), new Close() }; }
protected override async Task <CommandResult> ExecuteCore(string input) { var serviceClient = RemoteConnectionManager.GetServiceClient(); var existsResponse = await serviceClient.ExistsAsync(new ExistsRequest { Path = _path }); if (!existsResponse.Exists || existsResponse.Kind != Kind.File) { return(Failed(new[] { Escape(_path), "not exist" })); } var executeResponse = await serviceClient.ExecuteAsync(new ExecuteRequest { Path = _path }); if (!executeResponse.Succeeded) { return(Failed(new[] { Escape(_path), "unknown" })); } return(Succeeded(new[] { Escape(_path) })); }
public DosCommand(RemoteConnectionManager remoteConnectionManager) : base(@".+", remoteConnectionManager) { }
public ChangeDirectory(RemoteConnectionManager remoteConnectionManager) : base(@"^(.+?)[へに]移動", remoteConnectionManager) { }
protected RemoteCommandBase(string pattern, RemoteConnectionManager remoteConnectionManager) : base(pattern) { RemoteConnectionManager = remoteConnectionManager; }
public OpenFile(RemoteConnectionManager remoteConnectionManager) : base("(.+?)を(開く|開いて|表示)", remoteConnectionManager) { }
public Connect(RemoteConnectionManager remoteConnectionManager) : base("接続", remoteConnectionManager) { }
public Disconnect(RemoteConnectionManager remoteConnectionManager) : base("切断", remoteConnectionManager) { }
protected override async Task <CommandResult> ExecuteCore(string input) { await RemoteConnectionManager.DisconnectAsync(); return(Succeeded()); }
public ScreenShot(RemoteConnectionManager remoteConnectionManager) : base("スクリーンショット", remoteConnectionManager) { }
public ExecuteFile(RemoteConnectionManager remoteConnectionManager) : base("(.+?)を実行", remoteConnectionManager) { }
public DeleteFile(RemoteConnectionManager remoteConnectionManager) : base(@"(.+?)を削除", remoteConnectionManager) { }
//------------------------------------------------------------------ //SendFilesBySword //------------------------------------------------------------------ public static void SendFilesBySword(List <Article> articlesList, string OwnerName, string SentPackagesFolder, string OriginalDirectoryPath, string OriginalFilePathPatren, string targetNameSpace, string schemaUri, string ErrorLogFile) { if (!Directory.Exists(SentPackagesFolder)) { Directory.CreateDirectory(SentPackagesFolder); } if (File.Exists(SentPackagesFolder)) { File.Delete(ErrorLogFile); } //------------------------------------------------------------------ //Open remote connection with local server //------------------------------------------------------------------ RemoteConnectionManager.OpenImpersonation(OriginalDirectoryPath); //------------------------------------------------------------------ string DistenationFileName = ""; string DistenationPdfFileName = ""; string DistenationXmlMetaDataFileName = ""; string DistenationZipPackagePath = ""; //------------------------------------------------------------------ string DistenationMetsXmlFileName = ""; string DistenationMetsXmlFileContents = ""; //------------------------------------------------------------------ string SourceFilePath = ""; string SourcePdfFilPath = ""; string SourceXmlMetaDataFilePath = ""; //------------------------------------------------------------------ foreach (Article currentArticle in articlesList) { try { if (currentArticle.ArticleId != "197514") { continue; } //------------------------------------------------------------------ DistenationFileName = BuildFileName(currentArticle); DistenationPdfFileName = DistenationFileName + ".pdf"; DistenationXmlMetaDataFileName = DistenationFileName + ".xml"; DistenationMetsXmlFileName = "mets.xml"; DistenationZipPackagePath = DistenationFileName + ".zip"; //------------------------------------------------------------------ SourceFilePath = OriginalDirectoryPath + string.Format(OriginalFilePathPatren, currentArticle.VolumeNumber.ToString(), currentArticle.JournalCode, currentArticle.Pii.ToString(), currentArticle.PublicationYear); SourcePdfFilPath = SourceFilePath + ".pdf"; SourceXmlMetaDataFilePath = SourceFilePath + ".xml"; //------------------------------------------------------------------ //Create Mets.xml contents DistenationMetsXmlFileContents = SwordXmlManager.BuildMetaDataXmlContents(currentArticle, OwnerName, DistenationPdfFileName); //------------------------------------------------------------------ // if (true) if (XmlManager.CheckXMLContentValidation(DistenationMetsXmlFileContents, targetNameSpace, schemaUri)) { //------------------------------------------------------------------------------------------ //Create zip package //------------------------------------------------------------------------------------------ //Add pdf file ZipFile zipFile = ZipFilesManager.CreateZipFile(DistenationPdfFileName, SourcePdfFilPath); //Add xml file zipFile = ZipFilesManager.CreateZipFile(zipFile, DistenationXmlMetaDataFileName, SourceXmlMetaDataFilePath); //Add mets file zipFile.AddEntry(DistenationMetsXmlFileName, DistenationMetsXmlFileContents); //Save package file ZipFilesManager.SaveZipFile(zipFile, DistenationZipPackagePath); //------------------------------------------------------------------------------------------ //string RsponseFromServer = WebRequetsManger.CreateWebRequest(AppSettings.RepositoryAddress, DistenationZipPackagePath); File.Move(DistenationZipPackagePath, "SentPackages/" + DistenationZipPackagePath); //------------------------------------------------------------------------------------------ } else { throw new Exception("Invalid XML"); } //------------------------------------------------------------------ } catch (Exception ex) { LogError(ErrorLogFile, currentArticle.JournalCode.ToString() + " _ " + currentArticle.PublicationYear.ToString() + " _ " + currentArticle.Pii.ToString(), ex.Message); } } //---------RemoteConnectionManager--------------------------------------------------------- //close remote connection with local server //------------------------------------------------------------------ RemoteConnectionManager.CloseImpersonation(); //------------------------------------------------------------------ }