Example #1
0
        public ActionResult GetLiveVideoViews(string livePageID)
        {
            Session["views"] = null;
            string userid = User.Identity.GetUserId();

            try
            {
                //string token = Session["token"].ToString();

                string token = FanPageService.GetToken(userid);
                int    views = FBRequestService.GetLiveVideoViews(livePageID, token);
                if (Session["views"] == null)
                {
                    Session["views"] = views;
                }
                else
                {
                    if ((int)Session["views"] < views)
                    {
                        Session["views"] = views;
                    }
                }

                return(Json(views, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public void SendMsgByButton(string livePageID)
        {
            var live_repo  = new LivePostsRepository();
            int liveid     = live_repo.Select(livePageID);
            var order_repo = new OrderRepositories();
            //List<string> ids = new List<string> { "3032519476788720", "2762673820474754" };
            List <MsgTextViewModel> ordersinfo = order_repo.SelectAllOrdersInfo(liveid);
            //string token = (string)Session["token"];
            string userid = User.Identity.GetUserId();
            string token  = FanPageService.GetToken(userid);
            var    orders = new List <OrderList>();

            foreach (var orderinfo in ordersinfo)
            {
                var order = new OrderList();
                order.CustomerID   = orderinfo.CustomerID;
                order.CustomerName = orderinfo.CustomerName;
                order.OrderID      = orderinfo.OrderID;
                order.Product      = new ProductViewModel {
                    Salepage_id = orderinfo.ProductPageID, SkuId = orderinfo.ProductID, ProductName = orderinfo.ProductName
                };
                order.Quantity = orderinfo.Quantity;
                orders.Add(order);
                FBSendMsgService.SuccessOrderToSendMsg(livePageID, order, token);
            }
        }
Example #3
0
        public ActionResult GetPlusOneBuyOrders(string livePageID, string keywordPattern)
        {
            //try
            //{
            //string token = Session["token"].ToString();
            string userid        = User.Identity.GetUserId();
            string token         = FanPageService.GetToken(userid);
            var    products      = ProductService.GetCurrentProducts().ProductItems;
            var    OrderList     = CommentFilterService.getNewOrderList(livePageID, token, products, keywordPattern);
            var    Success_order = new List <OrderList>();

            if (OrderList.Count > 0)
            {
                var order_repo = new OrderRepositories();
                Session["lastPostTime"] = OrderList.Last().OrderDateTime;
                foreach (var order in OrderList)
                {
                    //留言成功,數量修改
                    if (ProductService.UpdateProductQty(order.Product.SkuId, order.Quantity))
                    {
                        Success_order.Add(order);
                        order_repo.InsertOrder(order);
                        FBSendMsgService.SuccessOrderToSendMsg(livePageID, order, token);
                    }
                    else  //留言失敗
                    {
                        FBSendMsgService.FailedOrderToSendMsg(livePageID, order, token);
                    }
                }
            }
            var result = JsonConvert.SerializeObject(Success_order);

            return(Json(result));
            //}
            //catch (Exception e)
            //{
            //    DateTime date = DateTime.UtcNow.AddHours(8);
            //    string today = date.ToString("yyyy-MM-dd");
            //    string now = date.ToString("yyyy-MM-dd HH:mm:ss");
            //    if (!Directory.Exists("C:\\log"))
            //    {
            //        Directory.CreateDirectory("C:\\log\\");
            //    }

            //    string nowPath = "C:\\log\\" + today + ".txt";

            //    System.IO.File.AppendAllText("C:\\log\\" + today + ".txt", "\r\n" + now + " : " + e);

            //    return Json("error");
            //}
        }
Example #4
0
        public ActionResult Video()
        {
            string userid = User.Identity.GetUserId();

            //var fpage_repo = new FanPagesRepository();

            //string token = Session["token"].ToString();

            //var fpage = fpage_repo.SelectBinding(userid);
            //string decodetoken = ReCodeService.Base64Decode(fpage.FbPageLongToken);
            string token  = FanPageService.GetToken(userid);
            var    result = FBRequestService.getLivePageID(token);

            ViewData["liveIDList"]  = result;
            ViewData["fanpagename"] = FanPageService.GetPageName(userid);
            return(View());
        }
Example #5
0
        public ActionResult Index(string livePageID, string liveName, string keywordPattern)
        {
            string userid = User.Identity.GetUserId();
            //string fanpageid = (string)Session["FanPageID"];
            int fanpageid = FanPageService.GetPageId(userid);

            //新增直播進資料庫
            LivePostService.CreateLivePost(livePageID, liveName, fanpageid);
            //新增商品進資料庫
            ProductRepositories product_repo = new ProductRepositories();
            var products = ProductService.GetCurrentProducts().ProductItems;

            foreach (var item in products)
            {
                if (!product_repo.SelectProduct(item.SkuId))
                {
                    product_repo.InsertProduct(item);
                }
            }
            ViewData["products"]       = products;
            ViewData["livePageID"]     = livePageID;
            ViewData["keywordPattern"] = keywordPattern;
            return(View());
        }