Esempio n. 1
0
 public void SendProgress(CommandProgress progress)
 {
     using (Stream progressReport = Convert(Progress.Parse(progress)))
     {
         communicationProtocol.SendMessage(progressReport);
     }
 }
Esempio 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();
                                }
                            }
                        }
                    }
                }
            });
        }
Esempio 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));
 }
Esempio n. 4
0
 /// <summary>
 /// 打开数据连接
 /// </summary>
 public void Open()
 {
     if (conOpen == null)
     {
         conOpen = Provider.DbFactory.CreateConnection();
         conOpen.ConnectionString = Provider.ConntionString;
     }
     conOpen.Open();
     this.Progress = CommandProgress;
 }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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;
 }
Esempio n. 10
0
 public Sqler(DbCommonProvider dbProvider, CommandProgress progress, bool autoPfx)
 {
     this.dbProvider = dbProvider;
     this.Command    = progress;
     this.isAutoPfx  = autoPfx;
 }
Esempio n. 11
0
 public Sqler(DbCommonProvider dbProvider, CommandProgress progress)
 {
     this.dbProvider = dbProvider;
     this.Command    = progress;
     this.isAutoPfx  = true;
 }