示例#1
0
    public void OnButton1Clicked()
    {
        Button1ClickCount++;

        // Log event by name, without data
        LogSession.Log("Button1Clicked");
    }
示例#2
0
        /// <summary>
        /// Executes a select command that returns a collection of records.
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        private List <LogSession> PerformSelect(SqlPreparedCommand command)
        {
            var result = new List <LogSession>();

            using (IDataReader reader = command.Command.ExecuteReader()) {
                while (reader.Read())
                {
                    var session = new LogSession()
                    {
                        Id             = Sql.GetInt64(reader, "Id"),
                        ClientId       = Sql.GetInt64(reader, "ClientId"),
                        StartTime      = Sql.GetDateTime(reader, "StartTime"),
                        EndTime        = Sql.GetDateTime(reader, "EndTime"),
                        CountRequests  = Sql.GetInt64(reader, "CountRequests"),
                        OtherBytesSent = Sql.GetInt64(reader, "OtherBytesSent"),
                        HtmlBytesSent  = Sql.GetInt64(reader, "HtmlBytesSent"),
                        JsonBytesSent  = Sql.GetInt64(reader, "JsonBytesSent"),
                        ImageBytesSent = Sql.GetInt64(reader, "ImageBytesSent"),
                        AudioBytesSent = Sql.GetInt64(reader, "AudioBytesSent"),
                    };

                    result.Add(session);
                }
            }

            return(result);
        }
示例#3
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public LogSession EstablishSession(string ipAddress, string userName)
        {
            LogSession result = null;

            lock (_SyncLock) {
                CreateConnection();

                var client = Client_GetByIpAddress(ipAddress);
                if (client == null)
                {
                    client = new LogClient()
                    {
                        IpAddress = ipAddress
                    };
                    Client_Insert(client);
                }

                result = new LogSession()
                {
                    ClientId  = client.Id,
                    UserName  = userName,
                    StartTime = Provider.UtcNow,
                    EndTime   = Provider.UtcNow,
                };
                Session_Insert(result);
            }

            return(result);
        }
        public async Task <IActionResult> LogOut(string token)
        {
            try
            {
                LogSession entityOld = _contextConfiguration.LogSession.First(c => c.Token == token && c.State == true);

                if (entityOld != null)
                {
                    entityOld.State = false;
                    _contextConfiguration.Update <LogSession>(entityOld);

                    await _contextConfiguration.SaveChangesAsync();

                    return(Ok(new
                    {
                        Success = true,
                        Date = DateTime.Now,
                    }));
                }
                else
                {
                    ModelState.AddModelError("Error", "Token invalido.");
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#5
0
        public SlaveContext(string configDataStr)
        {
            _configData    = JsonConvert.DeserializeObject <Dictionary <string, string> >(configDataStr);
            this._msgIndex = -1;

            this.I18N      = I18N.GetInstance(Constants.I18nName);
            this.Convertor = new TypeConvertor(this);

            SessionId        = this.GetProperty <int>("Session");
            State            = RuntimeState.NotAvailable;
            this.StatusQueue = new LocalEventQueue <SequenceStatusInfo>(CoreConstants.DefaultEventsQueueSize);
            string instanceName = _configData["InstanceName"];
            string sessionName  = _configData["SessionName"];

            this.LogSession = new RemoteLoggerSession(instanceName, sessionName, SessionId, GetProperty <LogLevel>("LogLevel"));

            this.MessageTransceiver   = new MessageTransceiver(this, SessionId);
            this.UplinkMsgProcessor   = new UplinkMessageProcessor(this);
            this.CallBackEventManager = new CallBackEventManager();
            this.FlowControlThread    = null;
            this.RmtGenMessage        = null;
            this.CtrlStartMessage     = null;
            this.CtrlStartMessage     = null;
            this.TraceVariables       = new HashSet <string>();
            this.ReturnVariables      = new HashSet <string>();
            this.RuntimeType          = GetProperty <RuntimeType>("RuntimeType");
            this.Cancellation         = new CancellationTokenSource();
            this.TimingManager        = new StopWatchManager(this);
            this.CoroutineManager     = new CoroutineManager(this);
            this.DebugManager         = new DebugManager(this);
            LogSession.Print(LogLevel.Debug, SessionId, "Slave context constructed.");
        }
示例#6
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="session"></param>
        public void UpdateSession(LogSession session)
        {
            if(session == null) throw new ArgumentNullException("session");
            if(_Connection == null) throw new InvalidOperationException("The connection must be opened before the session can be updated");

            lock(_SyncLock) {
                _SessionTable.Update(_Connection, _TransactionHelper.Transaction, null, session);
            }
        }
示例#7
0
    public void OnButton3Clicked()
    {
        Button3ClickCount++;

        // Log event by type; name will be derived from class name, and object contents will be serialized into JSON data
        ButtonClicked data = new ButtonClicked("Button 3", Button2ClickCount);

        LogSession.Log(data);
    }
示例#8
0
    public void OnButton2Clicked()
    {
        Button2ClickCount++;

        // Log event by name, with JSON data
        ButtonClicked data     = new ButtonClicked("Button 2", Button2ClickCount);
        string        jsonData = JsonUtility.ToJson(data);

        LogSession.Log("ButtonClicked", jsonData);
    }
示例#9
0
 private void m_pLogSessions_DoubleClick(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     if (this.m_pLogSessions.SelectedItems.Count > 0)
     {
         LogSession    logSession    = (LogSession)this.m_pLogSessions.SelectedItems[0].Tag;
         LogViewerForm logViewerForm = new LogViewerForm(logSession.LogText, this.m_pContainsText.Text);
         logViewerForm.ShowDialog(this);
     }
     this.Cursor = Cursors.Default;
 }
示例#10
0
        public void LogSession_TotalBytesSent_Sums_Together_All_BytesSent_Properties()
        {
            var logSession = new LogSession();

            foreach (var propertyInfo in typeof(LogSession).GetProperties().OfType <PropertyInfo>().Where(p => p.Name.EndsWith("BytesSent") && p.Name != "TotalBytesSent"))
            {
                propertyInfo.SetValue(logSession, 42L, null);
                Assert.AreEqual(42L, logSession.TotalBytesSent, propertyInfo.Name);

                propertyInfo.SetValue(logSession, 0L, null);
                Assert.AreEqual(0L, logSession.TotalBytesSent);
            }
        }
示例#11
0
        public ActionResult InsertSession(string browser, int MEID, int UserID, string pageurl)
        {
            LogSession logSession = new LogSession();

            logSession.MEID           = MEID;
            logSession.SessionId      = UserID;
            logSession.UserId         = UserID;
            logSession.PageUrl        = pageurl;
            logSession.Browser        = browser;
            logSession.LogCreatedDate = System.DateTime.Now;
            _logSessionService.AddSession(Mapper.Map <HCRGUniversityApp.NEPService.LogSessionService.LogSession>(logSession));
            return(Json(GlobalConst.Message.Success, GlobalConst.Message.text_html));
        }
示例#12
0
        private void m_pGet_Click(object sender, EventArgs e)
        {
            if (this.m_pVirtualServer.Items.Count == 0)
            {
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            this.m_pLogSessions.BeginUpdate();
            this.m_pLogSessions.Items.Clear();
            DateTime startTime = new DateTime(this.m_pDate.Value.Year, this.m_pDate.Value.Month, this.m_pDate.Value.Day, this.m_pStartTime.Value.Hour, this.m_pStartTime.Value.Minute, 0);
            DateTime endTime   = new DateTime(this.m_pDate.Value.Year, this.m_pDate.Value.Month, this.m_pDate.Value.Day, this.m_pEndTime.Value.Hour, this.m_pEndTime.Value.Minute, 0);

            LogSession[]  array         = null;
            VirtualServer virtualServer = (VirtualServer)((WComboBoxItem)this.m_pVirtualServer.SelectedItem).Tag;

            if (this.m_pService.Text == "SMTP")
            {
                array = virtualServer.Logs.GetSmtpLogSessions((int)this.m_pLimit.Value, this.m_pDate.Value, startTime, endTime, this.m_pContainsText.Text);
            }
            else if (this.m_pService.Text == "POP3")
            {
                array = virtualServer.Logs.GetPop3LogSessions((int)this.m_pLimit.Value, this.m_pDate.Value, startTime, endTime, this.m_pContainsText.Text);
            }
            else if (this.m_pService.Text == "IMAP")
            {
                array = virtualServer.Logs.GetImapLogSessions((int)this.m_pLimit.Value, this.m_pDate.Value, startTime, endTime, this.m_pContainsText.Text);
            }
            else if (this.m_pService.Text == "RELAY")
            {
                array = virtualServer.Logs.GetRelayLogSessions((int)this.m_pLimit.Value, this.m_pDate.Value, startTime, endTime, this.m_pContainsText.Text);
            }
            else if (this.m_pService.Text == "FETCH")
            {
                array = virtualServer.Logs.GetFetchLogSessions((int)this.m_pLimit.Value, this.m_pDate.Value, startTime, endTime, this.m_pContainsText.Text);
            }
            LogSession[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                LogSession   logSession   = array2[i];
                ListViewItem listViewItem = new ListViewItem(logSession.StartTime.ToString());
                listViewItem.SubItems.Add(logSession.UserName);
                listViewItem.SubItems.Add(logSession.RemoteEndPoint.ToString());
                listViewItem.SubItems.Add(logSession.SessionID);
                listViewItem.Tag = logSession;
                this.m_pLogSessions.Items.Add(listViewItem);
            }
            this.m_pLogSessions.EndUpdate();
            this.Cursor = Cursors.Default;
        }
示例#13
0
 private void Session_Insert(LogSession session)
 {
     session.Id = _Connection.ExecuteScalar <long>(Commands.Session_Insert, new {
         @clientId       = session.ClientId,
         @userName       = session.UserName,
         @startTime      = session.StartTime,
         @endTime        = session.EndTime,
         @countRequests  = session.CountRequests,
         @otherBytesSent = session.OtherBytesSent,
         @htmlBytesSent  = session.HtmlBytesSent,
         @jsonBytesSent  = session.JsonBytesSent,
         @imageBytesSent = session.ImageBytesSent,
         @audioBytesSent = session.AudioBytesSent,
     }, transaction: _Transaction);
 }
示例#14
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="session"></param>
        public void UpdateSession(LogSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (_Connection == null)
            {
                throw new InvalidOperationException("The connection must be opened before the session can be updated");
            }

            lock (_SyncLock) {
                Session_Update(session);
            }
        }
示例#15
0
 private void Session_Update(LogSession session)
 {
     _Connection.Execute(Commands.Session_Update, new {
         @clientId       = session.ClientId,
         @userName       = session.UserName,
         @startTime      = session.StartTime,
         @endTime        = session.EndTime,
         @countRequests  = session.CountRequests,
         @otherBytesSent = session.OtherBytesSent,
         @htmlBytesSent  = session.HtmlBytesSent,
         @jsonBytesSent  = session.JsonBytesSent,
         @imageBytesSent = session.ImageBytesSent,
         @audioBytesSent = session.AudioBytesSent,
         @id             = session.Id,
     }, transaction: _TransactionHelper.Transaction);
 }
示例#16
0
        public void LogSession_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            var logSession = new LogSession();

            TestUtilities.TestProperty(logSession, "AudioBytesSent", 0L, 102L);
            TestUtilities.TestProperty(logSession, "ClientId", 0L, 1291L);
            TestUtilities.TestProperty(logSession, "CountRequests", 0L, 12L);
            TestUtilities.TestProperty(logSession, "Duration", TimeSpan.Zero, new TimeSpan(9L));
            TestUtilities.TestProperty(logSession, "EndTime", DateTime.MinValue, DateTime.Now);
            TestUtilities.TestProperty(logSession, "HtmlBytesSent", 0L, 23L);
            TestUtilities.TestProperty(logSession, "Id", 0L, 234L);
            TestUtilities.TestProperty(logSession, "ImageBytesSent", 0L, 45L);
            TestUtilities.TestProperty(logSession, "JsonBytesSent", 0L, 98L);
            TestUtilities.TestProperty(logSession, "OtherBytesSent", 0L, 9873L);
            TestUtilities.TestProperty(logSession, "StartTime", DateTime.MinValue, DateTime.Now);
        }
        private IActionResult BuildToken(AccountDTO dto)
        {
            var claims = new[]
            {
                new Claim(JwtRegisteredClaimNames.UniqueName, dto.UserEmail),
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
            };

            var key   = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVlciBhZGlwaXNjaW5nIGVsaXQuIEFlbmVhbiBjb21tb2RvIGxpZ3VsYSBlZ2V0IGRvbG9yLiBBZW5lYW4gbWFzc2EuIEN1bSBzb2NpaXMgbmF0b3F1ZSBwZW5hdGlidXMgZXQgbWFnbmlzIGRpcyBwYXJ0dXJpZW50IG1vbnRlcywgbmFzY2V0dXIgcmlkaWN1bHVzIG11cy4gRG9uZWMgcXVhbSBmZWxpcywgdWx0cmljaWVzIG5lYywgcGVsbGVudGVzcXVlIGV1LCBwcmV0aXVtIHF1aXMsIHNlbS4gTnVsbGEgY29uc2VxdWF0IG1hc3NhIHF1aXMgZW5pbS4gRG9uZWMgcGVkZSBqdXN0bywgZnJpbmdpbGxhIHZlbCwgYWxpcXVldCBuZWMsIHZ1bHB1dGF0ZSBlZ2V0LCBhcmN1LiBJbiBlbmltIGp1c3RvLCByaG9uY3VzIHV0LCBpbXBlcmRpZXQgYSwgdmVuZW5hdGlzIHZpdGFlLCBqdXN0by4gTnVsbGFtIGRpY3R1bSBmZWxpcyBldSBwZWRlIG1vbGxpcyBwcmV0aXVtLiBJbnRlZ2VyIHRpbmNpZHVudC4gQ3JhcyBkYXBpYnVzLiBWaXZhbXVzIGVsZW1lbnR1bSBzZW1wZXIgbmlzaS4gQWVuZWFuIHZ1bHB1dGF0ZSBlbGVpZmVuZCB0ZWxsdXMuIEFlbmVhbiBsZW8gbGlndWxhLCBwb3J0dGl0b3IgZXUsIGNvbnNlcXVhdCB2aXRhZSwgZWxlaWZlbmQgYWMsIGVuaW0uIEFsaXF1YW0gbG9yZW0gYW50ZSwgZGFwaWJ1cyBpbiwgdml2ZXJyYSBxdWlzLCBmZXVnaWF0IGEsIHRlbGx1cy4gUGhhc2VsbHVzIHZpdmVycmEgbnVsbGEgdXQgbWV0dXMgdmFyaXVzIGxhb3JlZXQuIFF1aXNxdWUgcnV0cnVtLiBBZW5lYW4gaW1wZXJkaWV0LiBFdGlhbSB1bHRyaWNpZXMgbmlzaSB2ZWwgYXVndWUuIEN1cmFiaXR1ciB1bGxhbWNvcnBlciB1bHRyaWNpZXMgbmlzaS4gTmFtIGVnZXQgZHVpLiBFdGlhbSByaG9uY3VzLiBNYWVjZW5hcyB0ZW1wdXMsIHRlbGx1cyBlZ2V0IGNvbmRpbWVudHVtIHJob25jdXMsIHNlbSBxdWFtIHNlbXBlciBsaWJlcm8sIHNpdCBhbWV0IGFkaXBpc2Npbmcgc2VtIG5lcXVlIHNlZCBpcHN1bS4gTmFtIHF1YW0gbnVuYywgYmxhbmRpdCB2ZWwsIGx1Y3R1cyBwdWx2aW5hciwgaGVuZHJlcml0IGlkLCBsb3JlbS4gTWFlY2VuYXMgbmVjIG9kaW8gZXQgYW50ZSB0aW5jaWR1bnQgdGVtcHVzLiBEb25lYyB2aXRhZSBzYXBpZW4gdXQgbGliZXJvIHZlbmVuYXRpcyBmYXVjaWJ1cy4gTnVsbGFtIHF1aXMgYW50ZS4gRXRpYW0gc2l0IGFtZXQgb3JjaSBlZ2V0IGVyb3MgZmF1Y2lidXMgdGluY2lkdW50LiBEdWlzIGxlby4gU2VkIGZyaW5naWxsYSBtYXVyaXMgc2l0IGFtZXQgbmliaC4gRG9uZWMgc29kYWxlcyBzYWdpdHRpcyBtYWduYS4gU2VkIGNvbnNlcXVhdCwgbGVvIGVnZXQgYmliZW5kdW0gc29kYWxlcywgYXVndWUgdmVsaXQgY3Vyc3VzIG51bmMs"));
            var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);

            var expiration = DateTime.UtcNow.AddHours(1);

            JwtSecurityToken token = new JwtSecurityToken(
                issuer: "*****@*****.**",
                audience: "*****@*****.**",
                claims: claims,
                expires: expiration,
                signingCredentials: creds
                );


            #region Log

            LogSession log = new LogSession()
            {
                LogSessionId   = 0,
                Token          = new JwtSecurityTokenHandler().WriteToken(token),
                IP             = _accessor.HttpContext.Connection.RemoteIpAddress.ToString(),
                CreationDate   = DateTime.Now,
                State          = true,
                ExpirationDate = expiration,
            };

            _contextConfiguration.LogSession.Add(log);
            _contextConfiguration.SaveChanges();


            #endregion

            return(Ok(new
            {
                token = new JwtSecurityTokenHandler().WriteToken(token),
                expire = expiration,
            }));
        }
示例#18
0
            public int Compare(ListViewItem lhs, ListViewItem rhs)
            {
                int result = Object.ReferenceEquals(lhs, rhs) ? 0 : -1;

                if (result != 0)
                {
                    ClientAndSession lhsClientAndSession = (ClientAndSession)lhs.Tag;
                    ClientAndSession rhsClientAndSession = (ClientAndSession)rhs.Tag;
                    LogClient        lhsClient           = lhsClientAndSession.Client;
                    LogClient        rhsClient           = rhsClientAndSession.Client;
                    LogSession       lhsSession          = lhsClientAndSession.Session;
                    LogSession       rhsSession          = rhsClientAndSession.Session;

                    switch (SortColumn)
                    {
                    case SortColumn.AudioBytesSent:     result = Compare(lhsSession.AudioBytesSent, rhsSession.AudioBytesSent); break;

                    case SortColumn.BytesSent:          result = Compare(lhsSession.TotalBytesSent, rhsSession.TotalBytesSent); break;

                    case SortColumn.Duration:           result = TimeSpan.Compare(lhsSession.Duration, rhsSession.Duration); break;

                    case SortColumn.HtmlBytesSent:      result = Compare(lhsSession.HtmlBytesSent, rhsSession.HtmlBytesSent); break;

                    case SortColumn.ImageBytesSent:     result = Compare(lhsSession.ImageBytesSent, rhsSession.ImageBytesSent); break;

                    case SortColumn.IpAddress:          result = _IPAddressComparer.Compare(lhsClient.Address, rhsClient.Address); break;

                    case SortColumn.IsLocal:            result = Compare(lhsClient.IsLocal, rhsClient.IsLocal); break;

                    case SortColumn.JsonBytesSent:      result = Compare(lhsSession.JsonBytesSent, rhsSession.JsonBytesSent); break;

                    case SortColumn.OtherBytesSent:     result = Compare(lhsSession.OtherBytesSent, rhsSession.OtherBytesSent); break;

                    case SortColumn.Requests:           result = Compare(lhsSession.CountRequests, rhsSession.CountRequests); break;

                    case SortColumn.StartTime:          result = DateTime.Compare(lhsSession.StartTime, rhsSession.StartTime); break;

                    default:                            throw new NotImplementedException();
                    }
                }

                return(Ascending ? result : -result);
            }
        public void PriceAction_AddsNewRow()
        {
            //Arrange
            var manager = new LogSession();

            manager.Open();

            var writer    = manager.CreatePriceActionLogWriter();
            var reader    = manager.CreatePriceActionLogReader();
            var timestamp = DateTime.Now.Ticks;

            //Act
            writer.PriceAction(timestamp, 1, 2);

            //Asssert
            var result = reader.GetPriceAction(timestamp, timestamp);

            Assert.Single(result);

            manager.Close();
        }
示例#20
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <returns></returns>
        public LogSession EstablishSession(string ipAddress)
        {
            LogSession result = null;

            lock(_SyncLock) {
                CreateConnection();

                var client = _ClientTable.SelectByIpAddress(_Connection, _TransactionHelper.Transaction, null, ipAddress);
                if(client == null) {
                    client = new LogClient() { IpAddress = ipAddress };
                    _ClientTable.Insert(_Connection, _TransactionHelper.Transaction, null, client);
                }

                result = new LogSession() {
                    ClientId = client.Id,
                    StartTime = Provider.UtcNow,
                    EndTime = Provider.UtcNow,
                };
                _SessionTable.Insert(_Connection, _TransactionHelper.Transaction, null, result);
            }

            return result;
        }
        public void LogSession()
        {
            var session = new LogSession();

            session.SessionStarted();
            session.Persist(new StringBuilder("Hello World"));
            session.SessionStopped();

            Assert.AreEqual(File.ReadAllText(session.LogFilePath), "Hello World");
            Assert.IsTrue(session.LogFilePath.EndsWith("logs1"));
            Assert.AreEqual(session.GetPreviousSessionLogFilePath(), session.LogFilePath.Replace("logs1", "logs2"));

            session = new LogSession();
            session.SessionStarted();
            session.Persist(new StringBuilder("Hello World"));
            session.SessionStopped();

            Assert.IsTrue(session.LogFilePath.EndsWith("logs2"));
            Assert.AreEqual(session.GetPreviousSessionLogFilePath(), session.LogFilePath.Replace("logs2", "logs1"));

            session = new LogSession();
            session.SessionStarted();
            session.Persist(new StringBuilder("Hello World"));
            session.SessionStopped();

            Assert.IsTrue(session.LogFilePath.EndsWith("logs1"));
            Assert.AreEqual(session.GetPreviousSessionLogFilePath(), session.LogFilePath.Replace("logs1", "logs2"));

            session = new LogSession();
            session.SessionStarted();
            session.Persist(new StringBuilder("Hello World"));
            session.SessionStopped();

            Assert.IsTrue(session.LogFilePath.EndsWith("logs2"));
            Assert.AreEqual(session.GetPreviousSessionLogFilePath(), session.LogFilePath.Replace("logs2", "logs1"));
        }
 public void UpdateSession(LogSession session)
 {
     ;
 }
示例#23
0
        /// <summary>
        /// Updates an existing record.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <param name="log"></param>
        /// <param name="session"></param>
        public void Update(IDbConnection connection, IDbTransaction transaction, TextWriter log, LogSession session)
        {
            SqlPreparedCommand command = PrepareCommand(connection, transaction, "Update",
                                                        String.Format("UPDATE [{0}] SET" +
                                                                      " [ClientId] = ?, [StartTime] = ?, [EndTime] = ?, [CountRequests] = ?, " +
                                                                      " [OtherBytesSent] = ?, [HtmlBytesSent] = ?, [JsonBytesSent] = ?, " +
                                                                      " [ImageBytesSent] = ?, [AudioBytesSent] = ?" +
                                                                      " WHERE [Id] = ?", TableName), 10);

            Sql.SetParameters(command, session.ClientId, session.StartTime, session.EndTime, session.CountRequests,
                              session.OtherBytesSent, session.HtmlBytesSent, session.JsonBytesSent,
                              session.ImageBytesSent, session.AudioBytesSent,
                              session.Id);
            Sql.LogCommand(log, command.Command);
            command.Command.ExecuteNonQuery();
        }
示例#24
0
        /// <summary>
        /// Removes an existing record from the database.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <param name="log"></param>
        /// <param name="session"></param>
        public void Delete(IDbConnection connection, IDbTransaction transaction, TextWriter log, LogSession session)
        {
            SqlPreparedCommand command = PrepareCommand(connection, transaction, "Delete",
                                                        String.Format("DELETE FROM [{0}] WHERE [Id] = ?", TableName), 1);

            Sql.SetParameters(command, session.Id);
            Sql.LogCommand(log, command.Command);
            command.Command.ExecuteNonQuery();
        }
示例#25
0
        /// <summary>
        /// Adds a new record to the table.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <param name="log"></param>
        /// <param name="session"></param>
        public void Insert(IDbConnection connection, IDbTransaction transaction, TextWriter log, LogSession session)
        {
            SqlPreparedCommand command = PrepareInsert(connection, transaction, "Insert",
                                                       "Id",
                                                       "ClientId", "StartTime", "EndTime", "CountRequests", "OtherBytesSent",
                                                       "HtmlBytesSent", "JsonBytesSent", "ImageBytesSent", "AudioBytesSent");

            session.Id = Sql.ExecuteInsert(command, log,
                                           session.ClientId, session.StartTime, session.EndTime, session.CountRequests, session.OtherBytesSent,
                                           session.HtmlBytesSent, session.JsonBytesSent, session.ImageBytesSent, session.AudioBytesSent);
        }
示例#26
0
        private void BtnStart_Click(object sender, RoutedEventArgs e)
        {
            var btn = (Button)sender;

            if (btn.Content.ToString() == "START")
            {
                BtnDisableTime(sender);
                if (_routineThread != null && _routineThread.IsAlive)
                {
                    NewLog("Error starting new routine, please, restart the application and try again", LogType.Red);
                    return;
                }
                if (string.IsNullOrEmpty(SelectedDeviceName))
                {
                    NewLog("Empty account name", LogType.Red);
                    return;
                }
                // Reset and define Session Logs
                LogSession.CleanSession();
                LogSession.Name   = SelectedDeviceName;
                LogSession.Serial = DataBindingConfig.Serial;
                // Update Json Config with Name Textbox
                UpdateNameFromSerial();
                SaveProfile();
                // Starting Routine Thread
                _routineThread = new Thread(() => {
                    try
                    {
                        LogWizard.Name   = SelectedDeviceName;
                        _routineProccess = new Routine(DataBindingConfig.Serial, DataBindingConfig, this);
                        while (_routineProccess.IsRunning)
                        {
                            _routineProccess.DoNextAction();
                            Thread.Sleep(100);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                    }
                    finally
                    {
                        Dispatcher.Invoke(() => {
                            LogWizard = new Wizard();
                            _routineProccess.IsRunning = false;
                            _routineProccess           = null;
                        });
                    }
                });
                _routineThread.Start();
                SetBotStatus("Running.", new SolidColorBrush(Colors.ForestGreen));
                btn.Content = "STOP";
            }
            else
            {
                BtnDisableTime(sender, 10000);
                try
                {
                    _routineThread.Abort();
                    _routineThread = null;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    throw;
                }
                btn.Content = "START";
                NewLog("Routine stopped with success", LogType.Green);
            }
        }