public void CreateXFerProject(string projectName) { XFerProject newXFerProject = new XFerProject(); newXFerProject.ProjectConfig = new XFerProjectConfig() { ProjectName = projectName, ProjectCommands = new List <XFerProjectCommand>() }; using (var conn = new SqliteConnection(Statics.ConfigDBConnString)) { try { conn.Open(); if (!DBMaintenance.InstantiatedDB(conn)) { DBMaintenance.InstantiateDB(conn); } conn.Execute(@"INSERT INTO CXFProjects (ProjectName,ProjectCreationTime) VALUES (@ProjectName, @ProjectCreationTime)", new { ProjectName = projectName, ProjectCreationTime = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString() }); } catch { throw; } finally { conn.Close(); } } }
public IEnumerable <XFerProject> GetAllProjects() { List <XFerProject> allProjects = new List <XFerProject>(); // { // new XFerProject() { ProjectConfig = new XFerProjectConfig() { ProjectName = "TestProj1" } }, // new XFerProject() { ProjectConfig = new XFerProjectConfig() { ProjectName = "TestProj2" } } // }; using (var conn = new SqliteConnection(Statics.ConfigDBConnString)) { try { conn.Open(); if (DBMaintenance.InstantiatedDB(conn)) { } } catch { throw; } finally { conn.Close(); } } return(allProjects); }
public JsonResult UpdateDatabaseData(MaintenanceModel maintenance) { var result = 0; DBMaintenance dbmaintenance = new DBMaintenance(); if (maintenance.ProcessType == "1") { result = dbmaintenance.UpdateReleasingData(maintenance); } else if (maintenance.ProcessType == "2") { result = dbmaintenance.UpdateReceivingData(maintenance); } if (result != 0) { return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(result)); }
private void MainWindowUI_Loaded(object sender, RoutedEventArgs e) { //MessageBox.Show(UserAccessLevel.getInstance().gsCurrentUserName); DBMaintenance.getInsance().checkFileExist(); database.selectQuery("SELECT RunningDate FROM DateKeeper"); if (database.sqlDataTable.Rows.Count == 0) { string originalDate = DateTime.Today.ToShortDateString(); string editedDate = originalDate.Replace('/', '_'); object[] paramArray = { editedDate }; database.insertQuery("INSERT INTO DateKeeper(RunningDate) VALUES(@p0)", paramArray); } else { string dateToday = DateTime.Today.ToShortDateString(); string convertedDateToday = dateToday.Replace('/', '_'); string dateInDb = database.sqlDataTable.Rows[0][0].ToString(); if (convertedDateToday != dateInDb) { database.updateQuery("UPDATE DateKeeper SET RunningDate = '" + convertedDateToday + "';"); database.createTable("CREATE TABLE `Sales_" + convertedDateToday + "` (" + " `ProductNum` INTEGER PRIMARY KEY AUTOINCREMENT," + " `ProductName` TEXT NOT NULL,"+ " `ProductQty` NUMERIC NOT NULL DEFAULT 0," + " `AvgPrice` NUMERIC NOT NULL DEFAULT 0," + " `TotalDebits` NUMERIC NOT NULL DEFAULT 0"+ " ); "); } else { database.createTable("CREATE TABLE IF NOT EXISTS `Sales_" + convertedDateToday + "` (" + " `ProductNum` INTEGER PRIMARY KEY AUTOINCREMENT," + " `ProductName` TEXT NOT NULL,"+ " `ProductQty` NUMERIC NOT NULL DEFAULT 0," + " `AvgPrice` NUMERIC NOT NULL DEFAULT 0," + " `TotalDebits` NUMERIC NOT NULL DEFAULT 0"+ " ); "); } } }
//[ValidateAntiForgeryToken] public ActionResult ResetPassword(MaintenanceModel maintenance) { DBConnection(); DBMaintenance dBMaintenance = new DBMaintenance(); var result = dBMaintenance.ResetPassword(maintenance); maintenance = dBMaintenance.PopulateUserInformationDB(maintenance.UserID); //ViewBag.LoginAuthentication = "Login"; //ViewBag.HeaderSuccess = string.Format("New password set."); //ViewBag.MessageSuccess = string.Format("Your Password has been changed."); Session["UserID"] = maintenance.UserID; Session["Fullname"] = maintenance.Fullname; Session["UserRoleID"] = maintenance.RoleID; Session["UserRole"] = maintenance.RoleName; Session["Department"] = maintenance.DepartmentID; Session["GroupID"] = maintenance.GroupID; Session["DesignationID"] = maintenance.DesignationID; Session["GroupName"] = maintenance.Group; Session["DesignationName"] = maintenance.Designation; FormsAuthentication.SetAuthCookie(Session["UserID"].ToString(), false); // render Session into Authentication Cookie SqlDependency.Start(con); SqlDependency.Start(con2); SqlDependency.Start(con3); NotificationComponent NC = new NotificationComponent(); NC.group = maintenance.DesignationID; NC.Notificaton(maintenance.DesignationID); NC.UpdateItemRequestNotificaton(); NC.NotificatonItem(); NC.NotificatonUpdateItem(); return(Json(result)); }
public ActionResult LoginAuthentication(MaintenanceModel maintenance) { var username = maintenance.Username; var password = maintenance.Password; //if (User.Identity.IsAuthenticated) //{ // return RedirectToAction("Dashboard", "Home"); //} //System.Web.Helpers.AntiForgery.Validate(); try { DBConnection(); DBMaintenance dBMaintenance = new DBMaintenance(); maintenance = dBMaintenance.UserAuthentication(maintenance); } catch { ViewBag.LoginAuthentication = "Login"; ViewBag.HeaderError = string.Format("Unable to connect to server."); ViewBag.MessageError = string.Format("Check your server connection settings."); ViewBag.UserField = username; return(View()); } if (maintenance != null) { if (maintenance.Status == "2") { ViewBag.LoginAuthentication = "Login"; ViewBag.HeaderError = string.Format("Account Issue."); ViewBag.MessageError = string.Format("Your account has been inactive."); ViewBag.UserField = username; return(View()); } else if (maintenance.ResetPassword == 1) { if (maintenance.Code.Trim() == password || maintenance.Password.Trim() == "P@ssw0rd") { ViewBag.LoginAuthentication = "ResetPassword"; AllModels models = new AllModels(); models.Maintenance = maintenance; return(View(models)); } else { ViewBag.LoginAuthentication = "Login"; ViewBag.HeaderWarning = string.Format("Reset Password."); ViewBag.MessageWarning = string.Format("Please Enter Code."); ViewBag.UserField = username; return(View()); } } else { if (maintenance.Code == password) { ViewBag.LoginAuthentication = "Login"; ViewBag.HeaderError = string.Format("Login Failed."); ViewBag.MessageError = string.Format("Username or Password is incorrect."); ViewBag.UserField = username; return(View()); } else { Session["UserID"] = maintenance.UserID; Session["Fullname"] = maintenance.Fullname; Session["UserRoleID"] = maintenance.RoleID; Session["UserRole"] = maintenance.RoleName; Session["Department"] = maintenance.DepartmentID; Session["GroupID"] = maintenance.GroupID; Session["DesignationID"] = maintenance.DesignationID; Session["GroupName"] = maintenance.Group; Session["DesignationName"] = maintenance.Designation; FormsAuthentication.SetAuthCookie(Session["UserID"].ToString(), false); // render Session into Authentication Cookie SqlDependency.Start(con); SqlDependency.Start(con2); SqlDependency.Start(con3); NotificationComponent NC = new NotificationComponent(); NC.group = maintenance.GroupID; NC.Notificaton(maintenance.GroupID); NC.UpdateItemRequestNotificaton(); NC.NotificatonItem(); NC.NotificatonUpdateItem(); return(RedirectToAction("Dashboard", "Home")); } } } else { ViewBag.LoginAuthentication = "Login"; ViewBag.HeaderError = string.Format("Login Failed."); ViewBag.MessageError = string.Format("Username or Password is incorrect."); ViewBag.UserField = username; return(View()); } }