public void SendProgress(CommandProgress progress) { using (Stream progressReport = Convert(Progress.Parse(progress))) { communicationProtocol.SendMessage(progressReport); } }
/// <summary> /// Records a command progress update received. /// </summary> /// <param name="item">The CommandProgress item</param> /// <param name="save">If true, caches the item in permanent storage</param> public static void AddCommandProgress(CommandProgress item, bool save = true) { ExceptionUtility.Try(() => { if (item != null && item.ProgressResponse != null) { if (item.CommandId != null && item.CommandId != "-100") { //if it's the final one, we can clear the history if (item.Status.IsFinal) { ClearCommandProgress(item.CommandId, save); } else { //add or update existing if (!_commandProgresses.ContainsKey(item.CommandId)) { _commandProgresses.AddOrUpdate(item.CommandId, (arg) => item, (arg1, arg2) => item); //save if (save) { DataCache.Save(); } } } } } }); }
public static Progress Parse(CommandProgress commandProgress) { return(new Progress(commandProgress.Command.RawCommand, commandProgress.Command.ParsedCommand, (int)Math.Round(commandProgress.NormalizedProgress * CommunicationConstants.ProgressResolution), 0, CommunicationConstants.ProgressResolution, commandProgress.Message ?? string.Empty, commandProgress.ProgressId)); }
/// <summary> /// 打开数据连接 /// </summary> public void Open() { if (conOpen == null) { conOpen = Provider.DbFactory.CreateConnection(); conOpen.ConnectionString = Provider.ConntionString; } conOpen.Open(); this.Progress = CommandProgress; }
public void CommandProgress_ConstructWithMessage_SetsExpectedPropertyValues() { // Arrange / Act var sut = new CommandProgress("message"); // Assert Assert.False(sut.HasKey); Assert.Null(sut.Key); Assert.Null(sut.Value); Assert.Equal("message", sut.Message); }
public void CommandProgress_ConstructWithKeyAndValue_SetsExpectedPropertyValues() { // Arrange / Act var sut = new CommandProgress("key", "value"); // Assert Assert.True(sut.HasKey); Assert.Equal("key", sut.Key); Assert.Equal("value", sut.Value); Assert.Equal("key: value", sut.Message); }
/// <summary> /// 使用事务 /// </summary> internal DbTransaction UseTran(IsolationLevel isolationLevel) { DbConnection con = Provider.DbFactory.CreateConnection();// con.ConnectionString = this.Provider.ConntionString; con.Open(); DbTransaction tran = con.BeginTransaction(isolationLevel); this.Progress = this.TrasactionProgress; this.TranCmd = tran.Connection.CreateCommand(); this.TranCmd.Transaction = tran; return(tran); }
private void _bgw_ProgressChanged(object sender, ProgressChangedEventArgs e) { CommandProgress?.Raise(this, new ProgressEventArgs(e.ProgressPercentage, e.UserState.ToString())); }
public ProgressReceivedEventArgs(CommandProgress progress) { Progress = progress; }
public Sqler(DbCommonProvider dbProvider, CommandProgress progress, bool autoPfx) { this.dbProvider = dbProvider; this.Command = progress; this.isAutoPfx = autoPfx; }
public Sqler(DbCommonProvider dbProvider, CommandProgress progress) { this.dbProvider = dbProvider; this.Command = progress; this.isAutoPfx = true; }