private void InitCommands() { OpenCommand = new OpenCommand(this); ApplyCommand = new ApplyCommand(this); FlipCommand = new FlipCommand(this); HistogramEqualizeCommand = new HistogramEqualizeCommand(this); HistogramStretchCommand = new HistogramStretchCommand(this); CropCommand = new CropCommand(this); InpaintCommand = new InpaintCommand(this); ResizeCommand = new ResizeCommand(this); RotateCommand = new RotateCommand(this); SaveAsCommand = new SaveAsCommand(this); SaveCommand = new SaveCommand(this); ZoomCommand = new ZoomCommand(this); ResetCommand = new ResetCommand(this); CloseCommand = new CloseCommand(this); SelectToolCommand = new SelectToolCommand(this); UndoCommand = new UndoCommand(this); RedoCommand = new RedoCommand(this); DropboxCommand = new DropboxCommand(this); DownloadCommand = new DownloadCommand(this); UploadCommand = new UploadCommand(this); DCommand = new DCommand(this); ECommand = new ECommand(this); PrewittCommand = new PrewittCommand(this); }
private static bool RunCommands() { ICommand cmd = new HelpCommand(); if (!string.IsNullOrEmpty(ArgSettings.Help)) { cmd = new HelpCommand(); } else if (ArgSettings.List) { cmd = new ListCommand(); } else if (ArgSettings.Remove) { cmd = new RemoveCommand(); } else if (ArgumentsHelper.IsValidUri(ArgSettings.Source) && ArgumentsHelper.IsValidUri(ArgSettings.Destination) && ArgumentsHelper.IsValidAzureConnection(ArgSettings.SourceConnection)) { cmd = new CopyCommand(); } else if (ArgumentsHelper.IsValidUri(ArgSettings.Source) && ArgumentsHelper.IsValidFileSystemPath(ArgSettings.Destination)) { cmd = new DownloadCommand(); } else if (ArgumentsHelper.IsValidFileSystemPath(ArgSettings.Source) && ArgumentsHelper.IsValidUri(ArgSettings.Destination)) { cmd = new UploadCommand(); } return(cmd.Execute()); }
public BookViewModel(IFileReader fileReader) { ShowCommand = new ShowCommand(this); UploadCommand = new UploadCommand(this); ClearCommand = new ClearCommand(this); Books = new ObservableCollection <Book>(); _fileReader = fileReader; }
private void OpenCreateForm(object sender, RibbonControlEventArgs e) { if (!ExeCheck()) { return; } try { if (menuForm == null || menuForm.IsDisposed) { Cursor preCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; Reload(); Dictionary <object, object> titleDict = null; if (selectedRange.ListObject == null) { titleDict = XlsOperation.GetTitleDict(activeSh); } UploadRequestParam paras = new UploadRequestParam { FileFullName = XlsOperation.MakeSelectedRangeTempFile(activePath, selectedRange, titleDict, activeSh), Method = "train" }; InputFormData <UploadRequestParam> data = new InputFormData <UploadRequestParam> { SettingFile = settingFile, RequestParam = paras, BookPath = activePath, ModelIdFile = modelIdFile }; var rsltData = UploadCommand.UploadCSV(data); if (rsltData.MsgType == 0) { data.RequestParam.ModelID = rsltData.DsName; } else { return; } Cursor.Current = preCursor; menuForm = new ModelCreateEntranceForm(data); menuForm.Show(); } } catch (Exception ex) { MsgBox.MsgBoxShowErr(ex.Message); } }
private void ApplicationStateService_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (ExtractMemberName(() => ApplicationStateService.CurrentUser) == e.PropertyName) { OnPropertyChanged(() => CurrentUsername); OnPropertyChanged(() => CanLogin); OnPropertyChanged(() => CanLogout); LoginCommand.RaiseCanExecuteChanged(); LogoutCommand.RaiseCanExecuteChanged(); UploadCommand.RaiseCanExecuteChanged(); } }
public void TestMethod1() { var uploadCommand = new UploadCommand(); var options = new BlobCommandOptions { Mode = "upload", Source = DataLocation, Destination = DevelopmentStorage, Container = "sample-files" }; uploadCommand.Run(options); }
/// <summary> /// Initialize the view model. /// </summary> public AdcpUtilitiesViewModel() : base("ADCP Utilities") { // Set Event Aggregator _events = IoC.Get <IEventAggregator>(); // Compass Cal command CompassCalCommand = ReactiveCommand.Create(); CompassCalCommand.Subscribe(_ => CompassCal()); // Compass Utility command CompassUtilityCommand = ReactiveCommand.Create(); CompassUtilityCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.CompassUtilityView))); // Terminal command TerminalCommand = ReactiveCommand.Create(); TerminalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.TerminalView))); // Download command DownloadCommand = ReactiveCommand.Create(); DownloadCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DownloadDataView))); // Upload Firmware command UploadCommand = ReactiveCommand.Create(); UploadCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.UpdateFirmwareView))); // Screen data command ScreenCommand = ReactiveCommand.Create(); ScreenCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ScreenDataView))); VmOptionsCommand = ReactiveCommand.Create(); VmOptionsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.VesselMountOptionsView))); // Predicition Model command PredicitionModelCommand = ReactiveCommand.Create(); PredicitionModelCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.AdcpPredictionModelView))); // RTI Compass Calibration Model command RtiCompassCalCommand = ReactiveCommand.Create(); RtiCompassCalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.RtiCompassCalView))); // Diagnostics View command DiagnosticsCommand = ReactiveCommand.Create(); DiagnosticsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DiagnosticView))); // Data Output View command DataOutputCommand = ReactiveCommand.Create(); DataOutputCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DataOutputView))); }
public ViewModelUploader() { UploadCommand = new UploadCommand(this); ContinueUploadCommand = new ContinueUploadCommand(this); HideInfoCommand = new HideInfoCommand(this); ShowInfoCommand = new ShowInfoCommand(this); try { _dal = new DataAccessLayer(); UploadQueue = _dal.GetNotUploaded(); } catch (Exception ex) { ShowMessage(ex.Message); } }
public void Execute(UploadCommand command) { if (Connection == null) { Console.WriteLine("There is no connection to server!"); return; } var localFileName = $"Resources{Path.DirectorySeparatorChar}{command.FileName}"; var fileInfo = new FileInfo(localFileName); if (!File.Exists(localFileName)) { Console.WriteLine("File not found!"); return; } var message = new FileInfoCommand() { CommandType = CommandType.UploadFileRequest, ClientId = ClientId, FileName = command.FileName, Size = fileInfo.Length, IsExist = true }; Connection.Send(message); var serverFileInfoResponse = Connection.Receive().Deserialize <FileInfoCommand>(); var bytes = File.ReadAllBytes(localFileName).Skip((int)serverFileInfoResponse.Size).ToArray(); var stopwatch = new Stopwatch(); stopwatch.Restart(); Connection.Send(bytes); Connection.Receive().Deserialize <Commands.Command>(); stopwatch.Stop(); Console.WriteLine($"File uploaded successfully! " + $"Average upload speed is {((double)bytes.Length / (1024 * 1024)) / (((double)stopwatch.ElapsedMilliseconds + 1) / 1000)} Mbps."); }
/// <summary> /// 上传文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menu_upLoad_Click(object sender, EventArgs e) { try { ToolStripMenuItem load = (ToolStripMenuItem)sender; string path = load.Tag.ToString(); if (File.Exists(path) || (Directory.Exists(path))) { TransferCommand transfer = new UploadCommand(myFTP, path, ""); transfer.Execute(); } } catch (NullReferenceException) { MessageBox.Show("请先与服务器建立连接!", "提示"); } }
public ICommand Parse(string command) { var type = command.Split(' ').First(); var data = string.Join(' ', command.Split(' ').Skip(1)); switch (type) { case HelpCommand.Command: { return(HelpCommand.Parse(data)); } case EchoCommand.Command: { return(EchoCommand.Parse(data)); } case TimeCommand.Command: { return(TimeCommand.Parse(data)); } case UploadCommand.Command: { return(UploadCommand.Parse(data)); } case DownloadCommand.Command: { return(DownloadCommand.Parse(data)); } case ConnectCommand.Command: { return(ConnectCommand.Parse(data)); } case DisconnectCommand.Command: { return(DisconnectCommand.Parse(data)); } default: throw new CommandNotFoundException($"Unsupported command: {command}"); } }
public USBCarViewModel() { Upload = new UploadCommand(this); }
private void ModelApplied(object sender, EventArgs e) { btnExec.BackColor = Color.BurlyWood; Cursor preCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; Library.AllCtrlSwInForm(this, false); IsDoing = true; try { ModelApplyRequestRaram reqParam = new ModelApplyRequestRaram(); if (cbHowToModelID.SelectedIndex == 0) { if (cbModelID.Items.Count >= 1) { reqParam.ModelID = cbModelID.SelectedItem.ToString(); } } else { reqParam.ModelID = tbInputModelID.Text; } if (String.IsNullOrEmpty(reqParam.ModelID)) { throw new Exception("モデルIDを選択または入力して下さい。"); } Dictionary <object, object> titleDict = null; var selectedRange = Globals.ThisAddIn.Application.Selection as Excel.Range; if (selectedRange.ListObject == null) { titleDict = XlsOperation.GetTitleDict(ThisSh); } UploadRequestParam paras = new UploadRequestParam { FileFullName = XlsOperation.MakeSelectedRangeTempFile(FilePath, selectedRange, titleDict, ThisSh), Method = "predict", ModelID = reqParam.ModelID }; InputFormData <UploadRequestParam> data = new InputFormData <UploadRequestParam> { SettingFile = SettingFile, RequestParam = paras }; var rsltData = UploadCommand.UploadCSV(data); if (rsltData.MsgType != 0) { return; } reqParam.DsName = rsltData.DsName; InputFormData <ModelApplyRequestRaram> iData = new InputFormData <ModelApplyRequestRaram> { SettingFile = SettingFile, RequestParam = reqParam }; ModelApplyResultData resData = ModelApplyCommand.ModelApplied(iData); if (resData.MsgType != 0) { return; } MsgBox.MsgBoxShowInfo("モデル適用が完了しました。"); } catch (Exception ex) { MsgBox.MsgBoxShowErr(ex.Message); } finally { Library.AllCtrlSwInForm(this, false); Cursor.Current = preCursor; btnExec.BackColor = Color.Empty; IsDoing = false; this.Close(); this.Dispose(); } }
/// <summary> /// Uploads the specified file to the vault. /// </summary> /// <param name="upload">The file to upload.</param> /// <param name="async">if set to <c>true</c>, download asynchronously. Otherwise, /// a resolved promise will be returned</param> /// <returns>A promise to return a stream of the resulting AML</returns> public IPromise <Stream> Upload(UploadCommand upload, bool async) { return(upload.Commit(async)); }
private static void Main(string[] args) { var record = new Command("rec") { new Argument <FileInfo>("file") { Description = "The filename to save the record" }, new Option(new [] { "--command", "-c" }, "The command to record, default to be powershell.exe", typeof(string)) }; record.Description = "Record and save a session"; record.Handler = CommandHandler.Create((FileInfo file, string command) => { var recordCmd = new RecordCommand(new RecordArgs { Filename = file.FullName, Command = command }); recordCmd.Execute(); }); var play = new Command("play") { new Argument <FileInfo>("file") { Description = "The record session" } }; play.Description = "Play a recorded session"; play.Handler = CommandHandler.Create((FileInfo file) => { var playCommand = new PlayCommand(new PlayArgs { Filename = file.FullName, EnableAnsiEscape = true }); playCommand.Execute(); }); var auth = new Command("auth") { Handler = CommandHandler.Create(() => { var authCommand = new AuthCommand(); authCommand.Execute(); }), Description = "Auth with asciinema.org" }; var upload = new Command("upload") { new Argument <FileInfo>("file") { Description = "The file to be uploaded" } }; upload.Description = "Upload a session to ascinema.org"; upload.Handler = CommandHandler.Create((FileInfo file) => { var uploadCommand = new UploadCommand(file.FullName); uploadCommand.Execute(); }); var rooCommand = new RootCommand { record, play, auth, upload }; rooCommand.Description = "Record, Play and Share your PowerShell Session."; rooCommand.InvokeAsync(args).Wait(); }
public void AddFiles(UploadCommand upload) { _upload = upload; }
private void OnTargetUpdated(Object sender, EventArgs e) { UploadCommand.RaiseCanExecuteChanged(); }
public IPromise<Stream> Upload(UploadCommand upload, bool async) { // Files need to be uploaded, so build the vault request // Compile the headers and AML query into the appropriate content var multiWriter = new MultiPartFormWriter(async, _conn.AmlContext.LocalizationContext); multiWriter.AddFiles(upload); _conn.SetDefaultHeaders(multiWriter.WriteFormField); multiWriter.WriteFormField("SOAPACTION", upload.Action.ToString()); multiWriter.WriteFormField("VAULTID", upload.Vault.Id); multiWriter.WriteFormField("XMLdata", "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:i18n=\"http://www.aras.com/I18N\"><SOAP-ENV:Body><ApplyItem>" + upload.ToNormalizedAml(_conn.AmlContext.LocalizationContext) + "</ApplyItem></SOAP-ENV:Body></SOAP-ENV:Envelope>"); // Transform the vault URL (as necessary) var urlPromise = upload.Vault.Url.IndexOf("$[") < 0 ? Promises.Resolved(upload.Vault.Url) : _conn.Process(new Command("<url>@0</url>", upload.Vault.Url) .WithAction(CommandAction.TransformVaultServerURL), async) .Convert(s => s.AsString()); //GetResult("TransformVaultServerURL", "<url>" + upload.Vault.Url + "</url>", async); return urlPromise.Continue(u => { // Determine the authentication used by the vault if (u != upload.Vault.Url) upload.Vault.Url = u; return CheckAuthentication(upload.Vault, async); }).Continue(a => { // Build the request to perform the upload var hReq = (HttpWebRequest)System.Net.WebRequest.Create(upload.Vault.Url); hReq.AllowWriteStreamBuffering = false; hReq.Timeout = -1; hReq.ReadWriteTimeout = 300000; hReq.SendChunked = true; hReq.Method = "POST"; hReq.KeepAlive = true; hReq.ProtocolVersion = HttpVersion.Version11; hReq.ContentType = multiWriter.ContentType; hReq.ContentLength = multiWriter.GetLength(); hReq.CookieContainer = upload.Vault.Cookies; switch (a) { case AuthenticationSchemes.Negotiate: hReq.PreAuthenticate = true; hReq.UnsafeAuthenticatedConnectionSharing = true; break; case AuthenticationSchemes.Ntlm: hReq.UnsafeAuthenticatedConnectionSharing = true; break; case AuthenticationSchemes.Basic: hReq.PreAuthenticate = true; break; } var req = new WebRequest(hReq, _conn.Compression); foreach (var ac in _conn.DefaultSettings) { ac.Invoke(req); } if (upload.Settings != null) upload.Settings.Invoke(req); //hReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MyIE2; .NET CLR 1.1.4322)"; req.SetContent(multiWriter.WriteToRequest); return req.Execute(async); }).Convert(r => r.AsStream); }