Exemplo n.º 1
0
 public void SendProgress(CommandProgress progress)
 {
     using (Stream progressReport = Convert(Progress.Parse(progress)))
     {
         communicationProtocol.SendMessage(progressReport);
     }
 }
Exemplo n.º 2
0
        /// <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();
                                }
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 打开数据连接
 /// </summary>
 public void Open()
 {
     if (conOpen == null)
     {
         conOpen = Provider.DbFactory.CreateConnection();
         conOpen.ConnectionString = Provider.ConntionString;
     }
     conOpen.Open();
     this.Progress = CommandProgress;
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
 private void _bgw_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     CommandProgress?.Raise(this, new ProgressEventArgs(e.ProgressPercentage, e.UserState.ToString()));
 }
 public ProgressReceivedEventArgs(CommandProgress progress)
 {
     Progress = progress;
 }
Exemplo n.º 10
0
 public Sqler(DbCommonProvider dbProvider, CommandProgress progress, bool autoPfx)
 {
     this.dbProvider = dbProvider;
     this.Command    = progress;
     this.isAutoPfx  = autoPfx;
 }
Exemplo n.º 11
0
 public Sqler(DbCommonProvider dbProvider, CommandProgress progress)
 {
     this.dbProvider = dbProvider;
     this.Command    = progress;
     this.isAutoPfx  = true;
 }