public void download(string options) { string url; string filePath; string callbackId; try { url = JSON.JsonHelper.Deserialize<string[]>(options)[0]; filePath = JSON.JsonHelper.Deserialize<string[]>(options)[1]; callbackId = JSON.JsonHelper.Deserialize<string[]>(options)[2]; } catch (ArgumentException ex) { XLog.WriteError("download arguments occur Exception JSON_EXCEPTION " + ex.Message); DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } string workspace = this.app.GetWorkSpace(); string target = XUtils.ResolvePath(workspace, filePath); if (null == target) { FileTransfer.FileTransferError error = new FileTransfer.FileTransferError(FILE_NOT_FOUND_ERR, url, filePath, 0); PluginResult result = new PluginResult(PluginResult.Status.ERROR, error); DispatchCommandResult(result); return; } String abstarget = XUtils.BuildabsPathOnIsolatedStorage(target); if (!url.StartsWith("http://")) { FileTransfer.FileTransferError error = new FileTransfer.FileTransferError(INVALID_URL_ERR, url, filePath, 0); PluginResult result = new PluginResult(PluginResult.Status.ERROR, error); DispatchCommandResult(result); return; } EventHandler<PluginResult> DispatchPluginResult = delegate(object sender, PluginResult result) { DispatchCommandResult(result, callbackId); }; FileTransferManager.AddFileTranferTask(url, abstarget, workspace, DispatchPluginResult, COMMAND_DOWNLOAD); }
public void OnError(int errorCode) { SetState(INIT); FileTransfer.FileTransferError error = new FileTransfer.FileTransferError(errorCode, Url, LocalFilePath, 0); PluginResult result = new PluginResult(PluginResult.Status.ERROR, error); DispatchCommandResult(result); isRun = false; }