Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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"));
                }
            }
        }
Exemplo n.º 3
0
        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);
                }
            }
        }
Exemplo n.º 4
0
        public decimal?GetOnSalePrice()
        {
            if (IsOnSale())
            {
                if (onSalePrice == null)
                {
                    SqlStoredProcedures sqlSP = new SqlStoredProcedures();
                    onSalePrice = sqlSP.StoreGetOnSalePrice(GetProductID());
                }

                return((decimal)onSalePrice);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        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);
                }
            }
        }
Exemplo n.º 6
0
 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();
     }
 }
Exemplo n.º 7
0
        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));
            }
        }
Exemplo n.º 8
0
        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"));
            }
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        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();
            }
        }
Exemplo n.º 11
0
        public static Dictionary <string, string> GetLangListNative()
        {
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();

            return(sqlSP.LangSelectLangListNative());
        }
Exemplo n.º 12
0
        public static string GetLangNameNative(string langName)
        {
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();

            return(sqlSP.LangGetLangNameNative(langName));
        }
Exemplo n.º 13
0
        public static Dictionary <int, string> GetAllTicketCategoryies()
        {
            SqlStoredProcedures sp = new SqlStoredProcedures();

            return(sp.SupportSelectTicketCategories());
        }
Exemplo n.º 14
0
        public static Dictionary <int, string> GetProductCategories()
        {
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();

            return(sqlSP.StoreSelectProductCategories());
        }
Exemplo n.º 15
0
        public static List <Product> GetAllProducts()
        {
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();

            return(sqlSP.StoreSelectProducts(-1, null, -1, -1, -1));
        }
Exemplo n.º 16
0
        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));
        }
Exemplo n.º 17
0
 public static List <StudentModel> StoredProceduraGetAll()
 {
     return(SqlStoredProcedures.StoredProcedureGetAll <StudentModel>());
 }
Exemplo n.º 18
0
 public static List <StudentModel> StoredProceduraGetID(int ID)
 {
     return(SqlStoredProcedures.StoredProcedureGetID <StudentModel>(ID));
 }
Exemplo n.º 19
0
        public bool HasPolicy(Policy policy)
        {
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();

            return(sqlSP.PermissionDoesUserContainPolicy(GetUserID(), policy.GetPolicyName()));
        }
Exemplo n.º 20
0
        public static bool VerifyEmail(string emailAddress, string verifyString)
        {
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();

            return(sqlSP.UserVerifyEmail(emailAddress, verifyString));
        }