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); }
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); }
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); }
public void ShouldProvideFileNameWithTagAtTheEnd() { //Arrange var p = new LogFileProvider(new YamlLoggerOptions(), new TestFsTools()); //Act var filename = p.ProvideFilename("foo"); //Assert Assert.EndsWith(".foo.yml", filename); }
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); }
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); }
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); }
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>"); } } }
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); } }
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); }
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"; } }
void loadFileWorker_DoWork(object sender, DoWorkEventArgs e) { LogFileProvider.Open((string)e.Argument, (BackgroundWorker)sender, e); }