コード例 #1
0
        public Int32 Save(LogFileProvider provider)
        {
            bool  IsSave  = false;
            Int32 longVal = 0;

            try
            {
                SqlCommand command = null;
                command = ProcedureFunction(provider);
                command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Insert;
                object obj = command.ExecuteScalar();
                this.CommitTransaction();
                this.ConnectionClosed();
                IsSave = true;
            }
            catch (Exception exp)
            {
                this.RollbackTransaction();
                throw new Exception(exp.Message);
            }
            finally
            {
                this.ConnectionClosed();
            }
            return(longVal);
        }
コード例 #2
0
        public bool Update(LogFileProvider provider)
        {
            bool IsUpdate = false;

            try
            {
                SqlCommand command = null;
                command = ProcedureFunction(provider);
                command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Update;
                command.ExecuteNonQuery();
                this.CommitTransaction();
                this.ConnectionClosed();
                IsUpdate = true;
            }
            catch (Exception exp)
            {
                this.RollbackTransaction();
                throw new Exception(exp.Message);
            }
            finally
            {
                this.ConnectionClosed();
            }
            return(IsUpdate);
        }
コード例 #3
0
        public bool DatabaseBackup(LogFileProvider provider)
        {
            bool IsUpdate = false;

            try
            {
                SqlCommand command = new SqlCommand();
                ConnectionOpen();
                command.Connection  = Connection;
                command.Transaction = this.Transaction;
                command             = new SqlCommand("backup database TechnoDrugsLive to disk='" + "D:\\LiveDBBackup" + "\\" + "TechnoDrugsLive" + "_" + DateTime.Now.ToLongDateString() + "_" + DateTime.Now.ToString("HHmmss") + ".Bak'", Connection);
                command.ExecuteNonQuery();
                this.CommitTransaction();
                this.ConnectionClosed();
                IsUpdate = true;
            }
            catch (Exception exp)
            {
                this.RollbackTransaction();
                throw new Exception(exp.Message);
            }
            finally
            {
                this.ConnectionClosed();
            }
            return(IsUpdate);
        }
コード例 #4
0
        public void ShouldProvideFileNameWithTagAtTheEnd()
        {
            //Arrange
            var p = new LogFileProvider(new YamlLoggerOptions(), new TestFsTools());

            //Act
            var filename = p.ProvideFilename("foo");

            //Assert
            Assert.EndsWith(".foo.yml", filename);
        }
コード例 #5
0
        public void ShouldCurrentDateInFilename()
        {
            //Arrange
            var p = new LogFileProvider(new YamlLoggerOptions(), new TestFsTools());

            //Act
            var filename = p.ProvideFilename("foo");

            //Assert
            Assert.StartsWith($"{DateTime.Now.Year}.{DateTime.Now.Month:D2}.{DateTime.Now.Day:D2}", filename);
        }
コード例 #6
0
        public void AddNewProvider()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.ShowDialog();
            var             fileName = dialog.FileName;
            LogFileProvider provider = new LogFileProvider();

            provider.FilePath = fileName;
            LogProviders.Add(provider);
            SelectProvider(provider);
        }
コード例 #7
0
        public void ShouldIncrementFileIndexIfOversize()
        {
            //Arrange
            var    p           = new LogFileProvider(new YamlLoggerOptions(), new TestFsTools());
            string expectedEnd = ".1.foo.yml";

            //Act
            var filename = p.ProvideFilename("foo");

            //Assert
            Assert.EndsWith(expectedEnd, filename);
        }
コード例 #8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var          userProvider = new UserProvider();
                UserProvider user         = userProvider.GetByUserNameAndPassword(txtUserName.Text, txtPassword.Text);

                Session[SessionConstants.User]    = user.UserID;
                Session["UserName"]               = user.UserID;
                Session[SessionConstants.IsAdmin] = user.IsAdmin;
                Session["IsAdmin"]       = user.IsAdmin;
                Session["ID"]            = user.ID;
                Session["WarhouseID"]    = user.WarehouseID;
                Session["WarehouseName"] = user.WarehouseName;
                Session["VatID"]         = user.VatID;
                #region
                String   MyIp     = "-";
                var      provider = new LogFileProvider();
                DateTime dt       = DateTime.Now;
                provider.LogID     = 0;
                provider.UserID    = user.UserID;
                provider.LogInTime = dt;

                IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());

                foreach (IPAddress ipAddress in ipHost.AddressList)
                {
                    if (ipAddress.AddressFamily.ToString() == "InterNetwork")
                    {
                        MyIp = ipAddress.ToString();
                    }
                }
                provider.IPAddress  = MyIp;
                provider.LogOutTime = dt;
                //long LogID = provider.Save();
                //Session[SessionConstants.LogID] = LogID.ToString();
                #endregion

                Response.Redirect("~/UI/Security/IndexUI.aspx", false);
            }
            catch (Exception)
            {
                var          userProvider = new UserProvider();
                UserProvider user         = userProvider.GetByUserNameAndPassword(txtUserName.Text, txtPassword.Text);

                if (user == null)
                {
                    ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid credential')</script>");
                }
            }
        }
コード例 #9
0
 protected void btnBackup_Click(object sender, EventArgs e)
 {
     try
     {
         LogFileProvider logFileProvider = new LogFileProvider();
         bool            value           = logFileProvider.DatabaseBackup();
         if (value)
         {
             lblsuccessfull.Text = "Database backup has been completed successfully";
         }
     }
     catch (Exception ex)
     {
         lblsuccessfull.Text = string.Empty;
         MessageHelper.ShowAlertMessage(ex.Message);
     }
 }
コード例 #10
0
        private SqlCommand ProcedureFunction(LogFileProvider provider)
        {
            SqlCommand command = new SqlCommand();

            this.ConnectionOpen();
            command.Connection = Connection;
            this.BeginTransaction(true);
            command.Transaction = this.Transaction;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = StoredProcedureNames.LogFileSet;
            command.Parameters.Add("@LogID", SqlDbType.BigInt).Value        = 1;
            command.Parameters.Add("@UserID", SqlDbType.VarChar).Value      = provider.UserID;
            command.Parameters.Add("@LogInTime", SqlDbType.DateTime).Value  = provider.LogInTime;
            command.Parameters.Add("@IPAddress", SqlDbType.VarChar).Value   = provider.IPAddress;
            command.Parameters.Add("@LogOutTime", SqlDbType.DateTime).Value = provider.LogOutTime;
            return(command);
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: fthevenet/logViewer
        private void loadToForm(LogFileProvider logs)
        {
            this.stopTail();
            this.logs     = logs;
            this.dataView = new DataView(this.logs.DataSet.Tables["LogData"]);
            this.dataGridView1.DataSource = this.dataView;
            this.filterView();

            guiProps.Get <long>("totalEventsNbr").Value = this.logs.DataSet.Tables["LogData"].Rows.Count;

            if (logs.Status == LogProviderStatus.Online)
            {
                this.mruMenu.AddFile(this.logs.Location);
                this.mruMenu.SetFirstFile(this.mruMenu.FindFilenameNumber(this.logs.Location));
                this.Text = string.Format("LogViewer - {0}", this.logs.Location);
            }
            else
            {
                this.Text = "LogViewer";
            }
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: fthevenet/logViewer
 void loadFileWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     LogFileProvider.Open((string)e.Argument, (BackgroundWorker)sender, e);
 }