public void LoggedIn() { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); for (int i = chatLog.Count - 50 - 1 < 0 ? 0 : chatLog.Count - 50 - 1; i < chatLog.Count; i++) { Message message = chatLog[i]; string type = message.type; if (message.userID == onlineUsers[Context.ConnectionId]) { type = "self"; } Clients.Client(Context.ConnectionId).recieveMessage(sqlSP.UserGetDisplayName(message.userID), message.context, type, message.dateTime); } UpdateOnlineUserList(); }
public void UpdateTotal() { char store = userStoreDic[Context.ConnectionId]; decimal total; SqlStoredProcedures sqlSP = new SqlStoredProcedures(); total = sqlSP.StoreGetSaleTotal(store); Convert.ToDouble(total).ToString("N2"); foreach (KeyValuePair <string, char> userStorePair in userStoreDic) { if (userStorePair.Value == userStoreDic[Context.ConnectionId]) { Clients.Client(userStorePair.Key).UpdateTotal(Convert.ToDouble(total).ToString("N2")); } } }
public void SendMessage(string context) { if (!onlineUsers.ContainsKey(Context.ConnectionId)) { return; } int userID = onlineUsers[Context.ConnectionId]; User user = new User(userID); string displayName = user.GetDisplayName(); string type = "normal"; SqlStoredProcedures sqlSP = new SqlStoredProcedures(); if (user.HasRole("Store.Manager")) { type = "manager"; } else if (user.HasRole("Store.Employee")) { type = "employee"; } else if (userID == 33) { type = "system"; } Message message = new Message(userID, context, type); chatLog.Add(message); if (chatLog.Count > 100) { chatLog.RemoveRange(0, 10); } foreach (KeyValuePair <string, int> onlineUser in onlineUsers) { if (onlineUser.Value == userID) { Clients.Client(onlineUser.Key).recieveMessage(displayName, context, "self", message.dateTime); } else { Clients.Client(onlineUser.Key).recieveMessage(displayName, context, type, message.dateTime); } } }
public decimal?GetOnSalePrice() { if (IsOnSale()) { if (onSalePrice == null) { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); onSalePrice = sqlSP.StoreGetOnSalePrice(GetProductID()); } return((decimal)onSalePrice); } else { return(null); } }
public void Execute(IJobExecutionContext context) { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); Dictionary <int, char> shifts = sqlSP.StoreGetNextShifts(); foreach (KeyValuePair <int, char> shift in shifts) { if (sqlSP.UserIsEmailSub(shift.Key) || sqlSP.StoreHasMissedShift(shift.Key)) { string displayName = sqlSP.UserGetDisplayName(shift.Key); string langName = sqlSP.LangGetLangName(sqlSP.UserGetMainLang(shift.Key)); string emailAddress = sqlSP.UserGetMainEmailAddress(shift.Key); Email.SendShiftNotificationEmail(emailAddress, displayName, shift.Value, langName); System.Diagnostics.Debug.WriteLine("Sent shift notification to " + displayName + " at " + emailAddress); } } }
private void CPChangeProductOnSalePrice() { if (user.HasPolicy("Store.Product.Update")) { string productName = postData["productName"]; decimal?onSalePrice = Convert.ToDecimal(postData["onSalePrice"]); if (onSalePrice != null && onSalePrice <= 0) { onSalePrice = null; } SqlStoredProcedures sqlSP = new SqlStoredProcedures(); sqlSP.StoreChangeProductOnSalePrice(productName, onSalePrice); } else { throw new NoPermissionException(); } }
public ActionResult Marking() { string title = "Marking"; Load(title); if (user == null || !user.HasPolicy(new Policy("Store.Marking.Add"))) { return(RedirectToAction("Home", "Main")); } if (postData != null && postData.ContainsKey("userID") && postData.ContainsKey("date") && postData.ContainsKey("mark")) { try { int userID = Convert.ToInt32(postData["userID"]); DateTime date = Convert.ToDateTime(postData["date"]); int mark = Convert.ToInt32(postData["mark"]); string comment = postData.ContainsKey("comment") ? postData["comment"] : null; SqlStoredProcedures sqlSP = new SqlStoredProcedures(); sqlSP.StoreUpdateMarkAndComment(userID, date, mark, comment); return(Content("success")); } catch { return(Content("failed")); } } else { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); ViewBag.unmarkedSchedule = sqlSP.StoreSelectUnmarkedSchedule(user.GetUserID()); return(View(title)); } }
public ActionResult ShiftRequest() { string title = "ShiftRequest"; Load(title); if (postData == null || user == null) { return(Content("failed")); } try { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); string method = postData["method"]; switch (method) { case "add": int recieverID = sqlSP.StoreGetEmployeeID(postData["firstName"], postData["lastName"]); sqlSP.StoreAddShiftRequest(user.GetUserID(), recieverID, Convert.ToDateTime(postData["date"])); break; case "accept": int senderID = Convert.ToInt32(postData["senderID"]); DateTime date = Convert.ToDateTime(postData["date"]); sqlSP.StoreAcceptShiftRequest(senderID, user.GetUserID(), date); break; case "decline": sqlSP.StoreDeclineShiftRequest(Convert.ToInt32(postData["senderID"]), user.GetUserID(), Convert.ToDateTime(postData["date"])); break; default: break; } return(Content("success")); } catch { return(Content("failed")); } }
public void Login(int userID, string sessionToken, char store) { //Valid User and Is Manager User user = new User(userID); user.SignInWithSessionToken(sessionToken, GetIPAddress()); if (user.GetSessionToken() == null || !user.HasPolicy(new Policy("Store.Sales.Access"))) { return; } //Time between 9am to 3pm //TimeSpan time = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, "Pacific Standard Time").TimeOfDay; //if (time <= startTime || time >= endTime) //{ // return; //} //Working Today And In the Correct Store SqlStoredProcedures sqlSP = new SqlStoredProcedures(); var shift = sqlSP.StoreGetCurrentShifts(); if (!shift.ContainsKey(userID) && Char.ToLower(shift[userID]) != Char.ToLower(store)) { return; } //Add User onlineUsers.Add(Context.ConnectionId, userID); if (!uniqueOnlineUsers.Contains(userID)) { uniqueOnlineUsers.Add(userID); } userStoreDic.Add(Context.ConnectionId, Char.ToLower(store)); Clients.Client(Context.ConnectionId).LoginSuccess(); UpdateAllSaleCounts(); }
private ActionResult CPDownloadSales() { if (user.HasPolicy("Store.Sales.Download")) { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); DateTime startDate = Convert.ToDateTime(postData["startDate"]); DateTime endDate = Convert.ToDateTime(postData["endDate"]); List <Sale> saleCounts = sqlSP.StoreSelectSales(startDate, endDate); StringBuilder sb = new StringBuilder(); DateTime date = DateTime.Now; sb.AppendLine("\"Date\",\"Store\",\"Product Name\",\"Count\",\"Employee Count\""); foreach (Sale sale in saleCounts) { if (date != null && date != sale.GetDate()) { sb.AppendLine(); } date = sale.GetDate(); sb.Append("\"" + CSV.Escape(sale.GetDate().ToShortDateString()) + "\"" + ","); sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetStore())) + "\"" + ","); sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetProductName())) + "\"" + ","); sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetCount())) + "\"" + ","); sb.Append("\"" + CSV.Escape(Convert.ToString(sale.GetEmployeeCount())) + "\""); sb.Append("\n"); } byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, postData["startDate"] + "-" + postData["endDate"] + ".csv")); } else { throw new NoPermissionException(); } }
public static Dictionary <string, string> GetLangListNative() { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); return(sqlSP.LangSelectLangListNative()); }
public static string GetLangNameNative(string langName) { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); return(sqlSP.LangGetLangNameNative(langName)); }
public static Dictionary <int, string> GetAllTicketCategoryies() { SqlStoredProcedures sp = new SqlStoredProcedures(); return(sp.SupportSelectTicketCategories()); }
public static Dictionary <int, string> GetProductCategories() { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); return(sqlSP.StoreSelectProductCategories()); }
public static List <Product> GetAllProducts() { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); return(sqlSP.StoreSelectProducts(-1, null, -1, -1, -1)); }
public static List <Product> GetProducts(int productID, string keyword, int categoryID, decimal minPrice, decimal maxPrice) { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); return(sqlSP.StoreSelectProducts(productID, keyword, categoryID, minPrice, maxPrice)); }
public static List <StudentModel> StoredProceduraGetAll() { return(SqlStoredProcedures.StoredProcedureGetAll <StudentModel>()); }
public static List <StudentModel> StoredProceduraGetID(int ID) { return(SqlStoredProcedures.StoredProcedureGetID <StudentModel>(ID)); }
public bool HasPolicy(Policy policy) { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); return(sqlSP.PermissionDoesUserContainPolicy(GetUserID(), policy.GetPolicyName())); }
public static bool VerifyEmail(string emailAddress, string verifyString) { SqlStoredProcedures sqlSP = new SqlStoredProcedures(); return(sqlSP.UserVerifyEmail(emailAddress, verifyString)); }