Example #1
0
        public void SendRequest(int orderID)
        {
            Order order = cnn.Orders.Find(orderID);

            string[] words = order.listCustomer.Split(',');
            if (words.Count() > 0 && order.listCustomer.Length > 0)
            {
                Customer cus  = cnn.Customers.Find(int.Parse(words[0]));
                string   list = "";
                for (int index = 1; index < words.Count(); index++)
                {
                    if (words[index].Length > 0)
                    {
                        list += (words[index] + ",");
                    }
                }
                order.listCustomer = list;
                order.LastPushAt   = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                cnn.SaveChanges();
                if (cus != null)
                {
                    DataOnesignal datta = new DataOnesignal();
                    datta.type     = SystemParam.HAVE_A_NEW_ORDER;
                    datta.orderID  = order.ID;
                    datta.deviceID = cus.DeviceID;
                    datta.timeWait = cnn.Configsses.Where(u => u.NameConst.Equals("TimeWaiting")).Select(u => u.ValueConst).FirstOrDefault() / 1000;
                    string value = StartPushNoti(datta, cus.DeviceID, null, cus.Role);
                    PushOneSignal(value);
                }
            }
            else
            {
                Customer cus = cnn.Customers.Find(SystemParam.CUSTOMER_DEFAULT);
                order.Status      = SystemParam.STATUS_REQUEST_SUCCESS;
                order.Agent_id    = SystemParam.CUSTOMER_DEFAULT;
                order.ConfirmDate = DateTime.Now;
                cnn.SaveChanges();
                if (order.CustomerID != null)
                {
                    notiBus.CreateNoti(order.CustomerID.Value, SystemParam.TYPE_NOTI_CONFIRM_ORDER, orderID, "", "", null);
                }
                else
                {
                    notiBus.PushNotify(orderID, "", 1, null);
                }
                notiBus.CreateNoti(order.Agent_id.Value, SystemParam.AGENT_DEFAULT_TYPE, orderID, "", "", null);
            }
        }
Example #2
0
 public void SenotiForAllCustomer()
 {
     if (DateTime.Now.Hour == 8 && DateTime.Now.Minute == 0)
     {
         var listCustomer = cnn.Customers.Where(u => u.IsActive.Equals(SystemParam.ACTIVE) && u.ID != SystemParam.CUSTOMER_DEFAULT && u.Point <= SystemParam.MIN_MONEY_SENNOTI && u.Role.Equals(SystemParam.ROLE_ADMIN)).ToList();
         listCustomer = listCustomer.Where(u => u.ExpireTocken.AddDays(3).Date < DateTime.Today).ToList();
         foreach (Customer cus in listCustomer)
         {
             DataOnesignal datta = new DataOnesignal();
             datta.type     = SystemParam.HAVE_A_NEW_NOTI;
             datta.deviceID = cus.DeviceID;
             string value = StartPushNoti(datta, cus.DeviceID, "Tài khoản của quý khách dưới " + SystemParam.MIN_MONEY_SENNOTI + " để tiếp tục sử dụng dịch vụ vui lòng nạp thêm tiền vào tài khoản", cus.Role);
             PushOneSignal(value);
             cus.ExpireTocken = DateTime.Now;
         }
         cnn.SaveChanges();
     }
 }
Example #3
0
        public string PushNotify(int orderID, string content, int type, int?customerID)
        {
            try
            {
                Order    od  = cnn.Orders.Find(orderID);
                Customer cus = cnn.Customers.Find(customerID.Value);

                string deviceID = "";
                string ct       = content;

                if (od != null && type <= SystemParam.TYPE_NOTI_ORDER_CANCEL)
                {
                    deviceID = od.DeviceID;
                    if (od.CustomerID != null)
                    {
                        cus      = cnn.Customers.Find(od.CustomerID.Value);
                        deviceID = cus.DeviceID;
                    }
                }
                else
                {
                    deviceID = cus.DeviceID;
                }
                switch (type)
                {
                case SystemParam.TYPE_NOTI_CONFIRM_ORDER:
                    content = "Đơn hàng " + od.Code + " đã được xác nhận bởi " + od.Customer1.Name;
                    break;

                case SystemParam.TYPE_NOTI_ORDER_CUSSCESS:
                    content = "Đơn hàng " + od.Code + " đã hoàn thành";
                    break;

                case SystemParam.TYPE_NOTI_ORDER_CANCEL:
                    content = "Đơn hàng " + od.Code + " đã bị hủy";
                    break;
                }

                DataOnesignal datta = new DataOnesignal();
                datta.orderID = orderID;
                datta.type    = SystemParam.HAVE_A_NEW_NOTI;
                if (type == SystemParam.AGENT_DEFAULT_TYPE || type == SystemParam.HAVE_A_NEWS || type == SystemParam.HISPOINT_HE_THONG_CONG_DIEM || type == SystemParam.CHANGE_MINUS_POINT_ITEM)
                {
                    if (type == SystemParam.AGENT_DEFAULT_TYPE)
                    {
                        deviceID = od.Customer1.DeviceID;
                    }
                    datta.type = type;
                }
                string value = packBus.StartPushNotiNewS(datta, deviceID, content, cus.Role);
                if (type <= SystemParam.TYPE_NOTI_ORDER_CANCEL)
                {
                    value = packBus.StartPushNoti(datta, deviceID, content, cus.Role);
                }
                string a = packBus.PushOneSignals(value);
                return(a);
            }
            catch (Exception ex)
            {
                return("Hệ thống đang bảo trì");
            }
        }