private static void GenerateUserMenuBaseData() { var session = Session.DatabaseConnection; Models.Core.User user = session.CreateCriteria(typeof(Models.Core.User)) .Add(Expression.Eq("UserName", "admin")) .Add(Expression.Eq("Active", true)) .UniqueResult <Models.Core.User>(); Models.Core.Menu menu = new Models.Core.Menu(); menu.Description = "Default"; Crud.Put(menu); Models.Core.UserGroup ug = user.UserGroup; Models.Core.UserGroupMenu ugMenu = new Models.Core.UserGroupMenu(); ugMenu.UserGroup = ug; ugMenu.Menu = menu; ugMenu.Sequence = 10; Crud.Put(ugMenu); Models.Core.MenuItem menuItem = new Models.Core.MenuItem(); menuItem.Sequence = 10; menuItem.Menu = menu; menuItem.Program = Crud.GetById <Models.Core.Program, string>("FHCore.MenuForm"); Crud.Put(menuItem); }
private void GoToApplication(Models.Core.User user) { Common.Session.CurrentUser = user; BusinessLayer.General.Logging.Log("Password correct", BusinessLayer.General.Logging.LogLevel.Info); BusinessLayer.General.Logging.Log("Creating session for user", BusinessLayer.General.Logging.LogLevel.Debug); Models.Core.Session sess = new Models.Core.Session(); sess.HostName = Environment.MachineName; sess.User = user; sess.SessionStart = DateTime.Now; sess.SessionEnd = DateTime.Now.AddHours(1); Crud.Add(sess); Common.Session.CurrentSession = sess; BusinessLayer.General.Logging.Log("Creating MainForm object", BusinessLayer.General.Logging.LogLevel.Debug); MainForm mainForm = new MainForm(); Common.Session.MainForm = mainForm; Common.MenuBuilder.Build(); Context.Transfer(mainForm); BusinessLayer.General.Logging.Log("MainForm loaded", BusinessLayer.General.Logging.LogLevel.Debug); BusinessLayer.General.Logging.Log("Login form closed", BusinessLayer.General.Logging.LogLevel.Debug); Dispose(); }
public static bool BecosoftUser(Models.Core.User userObject, string password) { BECO_Pro_FAM_CCLink.Users user = new BECO_Pro_FAM_CCLink.Users(); Tuple <string, string> userFullName = null; bool result = user.Authenticate(userObject.UserName, password, ref userFullName); userObject.FirstName = userFullName.Item1; userObject.LastName = userFullName.Item2; Crud.Put(userObject); return(result); }
private static void GenerateBaseData() { Models.Core.UserGroup adminUserGroup = new Models.Core.UserGroup(); adminUserGroup.Name = "Default"; Crud.Put(adminUserGroup); Models.Core.User adminUser = new Models.Core.User(); adminUser.Active = true; adminUser.FirstName = "Administrator"; adminUser.Language = "en"; adminUser.UserName = "******"; adminUser.Password = Encryption.Encrypt.EncryptText("admin"); adminUser.UserGroup = adminUserGroup; Crud.Put(adminUser); }
public static void Log(string text, LogLevel level, Models.Core.User user = null) { int logLevel = Convert.ToInt16(Crud.GetById <Models.Core.Property, string>("DebugLevel")?.Value ?? "0"); if ((int)level >= logLevel) { Models.Core.Logging log = new Models.Core.Logging(); log.Text = text; log.Timestamp = DateTime.Now; log.User = user; log.Hostname = Environment.MachineName; log.Level = (int)level; Crud.Add(log); Debug.WriteLine("(" + log.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff") + ") " + level.ToString().ToUpper() + ": " + text); } }
private bool ExistingUser(string userName) { var session = Common.Session.DatabaseConnection; Models.Core.User user = session.CreateCriteria(typeof(Models.Core.User)) .Add(Expression.Eq("UserName", userName)) .Add(Expression.Eq("Active", true)) .UniqueResult <Models.Core.User>(); if (user != null) { return(true); } else { return(false); } }
public UserForm(FHFormTab caller, Models.Core.User user) { InitializeComponent(); this.caller = caller; this.dataObject = user; LoadLanguages(); LoadUserGroups(); if (this.dataObject == null) { this.dataObject = new Models.Core.User(); } else { LoadData(); } LoadWorkflow(); }
private void Proceed() { try { BusinessLayer.General.Logging.Log("Loading user data for user " + txtUsername.Text, BusinessLayer.General.Logging.LogLevel.Debug); var session = Common.Session.DatabaseConnection; Models.Core.User user = session.CreateCriteria(typeof(Models.Core.User)) .Add(Expression.Eq("UserName", txtUsername.Text.ToLower())) .Add(Expression.Eq("Active", true)) .UniqueResult <Models.Core.User>(); BusinessLayer.General.Logging.Log("User trying to login: "******"Password incorrect for user " + txtUsername.Text, BusinessLayer.General.Logging.LogLevel.Warning); txtPassword.Text = ""; txtUsername.Text = ""; txtUsername.Focus(); Common.Interaction.ThrowMessage(this, "Password incorrect"); } } catch (Exception ex) { Common.ExceptionHandling.HandleException(ex); } }
public static void Build() { try { var session = Session.DatabaseConnection; List <string> Permissionlist = new List <string>(); Models.Core.User user = Session.CurrentUser; string nodename = null; Session.MainForm.navigationMenu.Controls.Clear(); System.Drawing.Font nodeFont = new System.Drawing.Font("Tahoma", 10); System.Drawing.Font topNodeFont = new System.Drawing.Font("Tahoma", 10, System.Drawing.FontStyle.Bold); ImageList tabImages = new ImageList(); Session.MainForm.navigationMenu.ImageList = tabImages; int imageIdx = 0; if (user.UserGroup != null) { IList <Models.Core.UserGroupMenu> userGroupMenus = session.CreateCriteria(typeof(Models.Core.UserGroupMenu)) .Add(Expression.Eq("UserGroup", user.UserGroup)) .AddOrder(Order.Asc("Sequence")) .List <Models.Core.UserGroupMenu>(); foreach (Models.Core.UserGroupMenu ugmMenu in userGroupMenus) { TreeView menuTree = new TreeView(); menuTree.SelectedNode = null; menuTree.SelectOnRightClick = true; menuTree.Nodes.Clear(); Models.Core.Menu menu = ugmMenu.Menu; IList <Models.Core.MenuItem> menuPrograms = session.CreateCriteria(typeof(Models.Core.MenuItem)) .Add(Expression.Eq("Menu", menu)) .AddOrder(Order.Asc("Sequence")) .List <Models.Core.MenuItem>(); foreach (Models.Core.MenuItem menuProgram in menuPrograms) { Models.Core.Program program = menuProgram.Program; nodename = Localization.TranslateCpt(program.Form, "_form", Session.CurrentUser.Language ?? "en", program.Description); menuTree.Nodes.Add(program.Code, nodename).NodeFont = nodeFont; Permissionlist.Add(program.Code.ToLower()); } NavigationTab objTabControls = new NavigationTab(menu.Description); menuTree.Dock = DockStyle.Fill; menuTree.ShowLines = false; menuTree.NodeMouseClick += Session.MainForm.menuTree_MouseClick; objTabControls.Controls.Add(menuTree); if (!string.IsNullOrEmpty(menu.Icon)) { tabImages.Images.Add(new Gizmox.WebGUI.Common.Resources.IconResourceHandle(menu.Icon)); objTabControls.ImageIndex = imageIdx; imageIdx++; } Session.MainForm.navigationMenu.Controls.Add(objTabControls); } } } catch (Exception ex) { ExceptionHandling.HandleException(ex); } }
public static void AddPoints(Models.Customers.Customer customer, Models.Customers.LoyaltyPartner partner, long points, string comments, Models.Core.User user) { if (points > 0) { using (var session = DataConnector.NHibernateConnector.OpenSession()) { using (var dbTransaction = session.BeginTransaction()) { try { Models.Customers.LoyaltyTransaction transaction = new Models.Customers.LoyaltyTransaction(); transaction.TransactionDate = DateTime.Now; if (points > 0) { transaction.PointsDestination = partner; } if (points < 0) { transaction.PointsOrigin = partner; } transaction.Points = points; transaction.User = user; transaction.Comments = comments; transaction.Customer = customer; session.Save(transaction); var balanceObject = session.CreateCriteria(typeof(Models.Customers.LoyaltyBalance)) .Add(Expression.Eq("Customer", customer)) .Add(Expression.Eq("Partner", partner)) .UniqueResult <Models.Customers.LoyaltyBalance>(); if (balanceObject == null) { balanceObject = new Models.Customers.LoyaltyBalance(); balanceObject.Customer = customer; balanceObject.Partner = partner; balanceObject.Points = 0; } balanceObject.Points = balanceObject.Points + points; session.SaveOrUpdate(balanceObject); dbTransaction.Commit(); } catch (Exception ex) { dbTransaction.Rollback(); throw ex; } } } } else if (points < 0) { UsePoints(customer, partner, points, comments); } }
public static void AddPoints(Models.Customers.Customer customer, Models.Customers.LoyaltyPartner partner, long points, Models.Core.User user) { AddPoints(customer, partner, points, null, user); }