Example #1
0
        [HttpPost]//[AcceptVerbs("Post")]
        public IActionResult confirmPkg([FromBody] confirmPkgInfo confirm)
        {
            try
            {
                //要存redis往後帶
                string guid       = confirm.guid;
                string confirmStr = JsonConvert.SerializeObject(confirm);
                RedisHelper.SetRedis(confirmStr, "bid:ec:confirm:" + guid, 30);
                //confirmStr = "";
                //confirm = JsonConvert.DeserializeObject<confirmPkgInfo>(RedisHelper.getProdInfotoRedis("bid:ec:confirm:" + guid));

                //金額要再確認....
                returnStatus status = new returnStatus();
                status.status = "OK";

                return(Json(status));
            }
            catch (Exception ex)
            {
                Website.Instance.logger.Debug($"product_confirmPkg_err:{ex.ToString()}");
                returnStatus status = new returnStatus();
                status.status = "Error";
                status.msgErr = "資料錯誤,請重新讀取頁";//要改

                return(Json(status));
            }
        }
        public Shooter(FileInfo fileInfo, bool enableEngSub, bool enableOnlyOneSub, int taskIndex)
        {
            this.videoFile = fileInfo;
            this.enableEngSub = enableEngSub;
            this.enbaleOnlyOneSub = enableOnlyOneSub;
            this.taskIndex = taskIndex;
            this.status = returnStatus.Unknown;
            this.hashValue = SVPlayerHash.ComputeFileHash(fileInfo);

            //Thread t = new Thread(action);
            //t.Start();
        }
Example #3
0
        [HttpPost]//[AcceptVerbs("Post")]
        public IActionResult reflashPkg([FromBody] prodQury prodQury)
        {
            try
            {
                //B2d分銷商資料
                var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

                //先確認是否有selDate ,如果沒有表示是第一次
                //如果有 selDate要依selDate決定可用的套餐


                string allCanUseDate = "";

                //取挖字
                Dictionary <string, string> uikey = CommonRepostory.getuiKey(RedisHelper, UserData.LOCALE);;// Redishelper.getuiKey(fakeContact.lang);

                ProdTitleModel title = ProductRepostory.getProdTitle(uikey);
                ViewData["prodTitle"] = title;
                ViewData["currency"]  = UserData.CURRENCY;//先從這裡取得幣別就不用再抓prod

                //ProductforEcModel prod = ApiHelper.getProdDtl(fakeContact.companyXid, fakeContact.state, fakeContact.lang, fakeContact.currency, prodQury.prodOid);
                //prod = prodRep.getProdInfo(prod, prodQury.prodOid, fakeContact.lang, fakeContact.currency, uikey); //prod.guidNo = guid;
                //ViewData["prodInfo"] = prod;

                PackageModel pkgs = ProductRepostory.getProdPkg(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, prodQury.prodOid, title);

                Int64 nowDatetime = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmss"));
                pkgs.pkgs = pkgs.pkgs.Where(x => nowDatetime >= Convert.ToInt64(x.online_s_date) && Convert.ToInt64(x.online_e_date) > nowDatetime).ToList();

                Website.Instance.logger.Debug($"product_reflashPkg_err:{JsonConvert.SerializeObject(pkgs)}");
                List <PkgDateforEcModel> prodPkgDateList = ProductRepostory.getProdPkgDate(pkgs, UserData.LOCALE, UserData.CURRENCY, uikey, out allCanUseDate);

                //設定每個pkg裡面可以使用的日期有那些
                pkgs = ProductRepostory.InitPkg(prodQury, title, pkgs, prodPkgDateList);

                return(Content(this.RenderPartialViewToString(ViewEngine, "_prodPkg", pkgs)));
            }
            catch (Exception ex)
            {
                //error
                Website.Instance.logger.Debug($"product_reflashPkg_err:{ex.ToString()}");
                returnStatus status = new returnStatus();
                status.status = "Error";
                status.msgErr = "資料錯誤,請重新讀取頁";//要改

                return(Json(status));
            }
        }
Example #4
0
        [HttpPost]//[AcceptVerbs("Post")]
        public IActionResult GetEventTime([FromBody] prodEvent prodEvent)
        {
            try
            {
                //B2d分銷商資料
                var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

                //取挖字
                String json = TempData["ProdTitleKeep"] as string;
                if (string.IsNullOrEmpty(json))
                {
                    throw new Exception("資料錯誤,請重新讀取頁面");
                }
                ProdTitleModel title = JsonConvert.DeserializeObject <ProdTitleModel>(json);
                TempData.Keep();

                PkgEventsModel getEventTime = ProductRepostory.getEvent(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, prodEvent.prodno, prodEvent.pkgno, title);
                if (getEventTime.result == "0000")
                {
                    var result = getEventTime.events.Where(x => x.day == prodEvent.DateSelected);
                    //result = new List<Event> { };

                    getEventTime.events = result.ToList();
                    return(Json(new { errMsg = "", data = result.ToList() }));
                }
                else
                {
                    return(Json(new { errMsg = "false" }));
                }
            }
            catch (Exception ex)
            {
                //error
                Website.Instance.logger.Debug($"product_eventtime_err:{ex.ToString()}");
                returnStatus status = new returnStatus();
                status.status = "Error";
                status.msgErr = "資料錯誤,請重新讀取頁面";//要改

                return(Json(status));
            }
        }
        private void DownFirstSub()
        {
            int count = 0;
            Logger.Log(string.Format("starting download for {0}",
                Path.GetFileNameWithoutExtension(videoFile.FullName)));

            int expectCnt = 0;
            if (subinfoChn != null)
            {
                foreach (Subinfo sub in subinfoChn)
                {
                    expectCnt += sub.Files.Length;
                }
            }
            if (enableEngSub && subinfoEng != null)
            {
                foreach (Subinfo sub in subinfoEng)
                {
                    expectCnt += sub.Files.Length;
                }
            }

            if (expectCnt <= 0)
            {
                status = returnStatus.NoSubtitle;
                return;
            }

            #region Download Chinese subtitles
            if (subinfoChn != null)
            {

                WebClient client = new WebClient();
                string dir = videoFile.DirectoryName;
                string subFileNameBase = Path.GetFileNameWithoutExtension(videoFile.FullName);
                Logger.Log(string.Format("Get {0} subs returned.", subinfoChn.Length));

                Logger.Log(string.Format("Downloading {0} file", 0));

                Console.WriteLine(subinfoChn[0].Files[0].Ext);
                Logger.Log(subinfoChn[0].Files[0].Ext);
                Console.WriteLine(subinfoChn[0].Files[0].Link);
                Logger.Log(subinfoChn[0].Files[0].Link);
                string subFileName = subFileNameBase +
                    "." + subinfoChn[0].Files[0].Ext;

                try
                {
                    client.DownloadFile(new Uri(subinfoChn[0].Files[0].Link),
                                        dir + Path.DirectorySeparatorChar + subFileName);
                    if (subinfoChn[0].Delay != 0)
                    {
                        string delayFileName = subFileName + ".delay";
                        FileStream delayFile = new FileStream(
                            dir + Path.DirectorySeparatorChar + delayFileName, FileMode.OpenOrCreate);
                        StreamWriter sw = new StreamWriter(delayFile);
                        sw.Write(subinfoChn[0].Delay);
                        sw.Flush();
                        sw.Close();
                        delayFile.Close();
                    }
                    ++count;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Caught exception while downloading.");
                    Console.WriteLine(e.GetType().ToString());
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);

                    Logger.Log("Caught exception while downloading.");
                    Logger.Log(e.GetType().ToString());
                    Logger.Log(e.Message);
                    Logger.Log(e.StackTrace);
                    //status = returnStatus.DownloadFailed;
                    //return;
                }

            }
            #endregion

            if (count > 0)
            {
                status = returnStatus.Success;
            }
            else
            {
                status = returnStatus.DownloadFailed;
            }
            Logger.Log(string.Format("Download {0} files for {1} in total.", count,
                Path.GetFileNameWithoutExtension(videoFile.FullName)));
            Logger.Log("download finished.");
        }
        public void startDownload()
        {
            Logger.Log(string.Format("Shooter working for {0}", Path.GetFileNameWithoutExtension(videoFile.FullName)));
            try
            {
                getSubInfoFromShooter();
            }
            catch (Exception e)
            {
                status = returnStatus.DownloadFailed;
                Logger.Log("Exception when getting sub info");
                Logger.Log(e.GetType().ToString());
                Logger.Log(e.Message);
                Logger.Log(e.StackTrace);
                return;
            }

            try
            {
                if (enbaleOnlyOneSub)
                {
                    DownFirstSub();
                }
                else
                {
                    Down();
                }

            }
            catch (Exception e)
            {
                status = returnStatus.DownloadFailed;
                Logger.Log("Exception when downloading");
                Logger.Log(e.GetType().ToString());
                Logger.Log(e.Message);
                Logger.Log(e.StackTrace);
                return;
            }

            Logger.Log(string.Format("Shooter finsihed for {0}", Path.GetFileNameWithoutExtension(videoFile.FullName)));
        }
Example #7
0
        public IActionResult bookingStep1([FromBody] DataModel data)
        {
            try
            {
                string memUuid = Website.Instance.Configuration["kkdayKey:uuid"];

                string    userAgent = Request.Headers["User-Agent"].ToString();
                UserAgent ua        = new UserAgent(userAgent);

                //B2d分銷商資料
                var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

                string ip = httpContextAccessor.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString().Replace("::1", "127.0.0.1");
                data = BookingRepostory.setCardEncrypt(data);
                //log時把卡號移除
                DataModel dataTemp = data.Clone();
                dataTemp.card = null;
                Website.Instance.logger.Debug($"bookingStep1_inputdata:{ JsonConvert.SerializeObject(dataTemp)}");

                string prodStr = TempData["prod_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(prodStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModel prod = JsonConvert.DeserializeObject <ProductModel>(prodStr);

                string moduleStr = TempData["module_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModuleModel module = JsonConvert.DeserializeObject <ProductModuleModel>(moduleStr);

                string pkgStr = TempData["pkg_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pkgStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                PkgDetailModel pkg = JsonConvert.DeserializeObject <PkgDetailModel>(pkgStr);

                string pkgConfirmStr = TempData["confirm_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                confirmPkgInfo confirm = JsonConvert.DeserializeObject <confirmPkgInfo>(pkgConfirmStr);

                string titleStr = TempData["ProdTitleKeep_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProdTitleModel title = JsonConvert.DeserializeObject <ProdTitleModel>(titleStr);

                string discRuleStr = TempData["pkgsDiscRule_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(discRuleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                DiscountRuleModel rule = JsonConvert.DeserializeObject <DiscountRuleModel>(discRuleStr);

                string pmgwStr = TempData["pmgw_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pmgwStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                Pmgw pmgw = JsonConvert.DeserializeObject <Pmgw>(pmgwStr);

                string showStr = TempData["prodShow_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(showStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                //BookingShowProdModel show = JsonConvert.DeserializeObject<BookingShowProdModel>(showStr);

                TempData.Keep();
                data = BookingRepostory.setDefaultBookingInfo(memUuid, ua, data, prod, pkg, confirm, UserData, pmgw);

                //排除餐食
                data = BookingRepostory.exculdeFood(prod, data, module);

                data.company_xid = UserData.COMPANY_XID.ToString();
                data.channel_oid = UserData.KKDAY_CHANNEL_OID;
                data.locale      = UserData.LOCALE;
                data.ip          = ip;
                JObject order = ApiHelper.orderNew(data, title);

                string       orderMid = "";
                string       orderOid = "";
                returnStatus status   = new returnStatus();

                Website.Instance.logger.Debug($"bookingStep1_ordernewresponse:" + JsonConvert.SerializeObject(order));//要改
                //要先判斷是不是result='0000'
                if (order["result"].ToString() == "0000")
                {
                    orderMid = order["order_mid"].ToString();
                    orderOid = order["order_oid"].ToString();
                    //upd B2bOrder
                    //BookingRepostory.updB2dOrder(UserData.COMPANY_XID, orderOid, orderMid, b2bOrder, title);

                    status.pmchSslRequest = BookingRepostory.setPaymentInfo2(prod, data, orderMid, UserData, pmgw, memUuid, ip);
                    status.status         = "OK";
                    status.url            = Website.Instance.Configuration["kkUrl:pmchUrl"].ToString() + pmgw.pmchPayURL; //pmchUrl

                    //要把BookingShowProdModel 帶到訂購final頁
                    RedisHelper.SetRedis(showStr, "b2d:ec:order:final:prodShow:" + orderMid, 60);
                    RedisHelper.SetRedis(JsonConvert.SerializeObject(data), "b2d:ec:order:final:orderData:" + orderMid, 60);

                    //要存redis 付款主要資訊,最後訂單 upd時要使用,可和下面整合存一個就
                    BookingRepostory.setPayDtltoRedis(data, orderMid, UserData.UUID, RedisHelper);

                    //要存redis 因為付款後要從這個redis內容再進行payment驗證,可和上面整合存一個就好
                    //CallJsonPay rdsJson = (CallJsonPay)status.pmchSslRequest.json;
                    CallJsonPay2 rdsJson     = (CallJsonPay2)status.pmchSslRequest.json;
                    string       callPmchReq = JsonConvert.SerializeObject(status.pmchSslRequest.json);
                    RedisHelper.SetRedis(callPmchReq, "b2d:ec:pmchSslRequest:" + orderMid, 60);
                }
                else
                {
                    status.status = "Error";
                    status.msgErr = order["content"]["result"].ToString() + order["content"]["msg"].ToString();//要改
                }

                return(Json(status));
                //v1/channel/citi/auth
                //https://pmch.sit.kkday.com/citi/payment/auth
                //https://payment.kkday.com/v1/channel/adyen/auth
            }
            catch (Exception ex)
            {
                Website.Instance.logger.Debug($"bookingStep1_err_ordernew失敗:{ex.Message.ToString()}");
                ViewData["errMsg"] = ex.Message.ToString();
                Website.Instance.logger.Debug($"booking_index_err:{ex.Message.ToString()}");

                //導到錯誤頁
                return(RedirectToAction("Index", "Error", new ErrorViewModel {
                    ErrorType = ErrorType.Order_Fail, ErrorMessage = ex.Message.ToString()
                }));
            }
        }
Example #8
0
        public IActionResult bookingStep1([FromBody] DataModel data)
        {
            try
            {
                //B2d分銷商資料
                var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
                var UserData    = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

                string ip = httpContextAccessor.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString().Replace("::1", "127.0.0.1");
                data = BookingRepostory.setCardEncrypt(data);
                //log時把卡號移除
                DataModel dataTemp = data.Clone();
                dataTemp.card = null;
                Website.Instance.logger.Debug($"bookingStep1_inputdata:{ JsonConvert.SerializeObject(dataTemp)}");

                ApiSetting api = new ApiSetting();
                api.apiKey    = "kkdayapi";
                api.userOid   = "1";
                api.ver       = "1.0.1";
                api.locale    = UserData.LOCALE;
                api.currency  = UserData.CURRENCY;
                api.ipaddress = ip;

                string prodStr = TempData["prod_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(prodStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModel prod = JsonConvert.DeserializeObject <ProductModel>(prodStr);

                string moduleStr = TempData["module_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProductModuleModel module = JsonConvert.DeserializeObject <ProductModuleModel>(moduleStr);

                string pkgStr = TempData["pkg_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pkgStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                PkgDetailModel pkg = JsonConvert.DeserializeObject <PkgDetailModel>(pkgStr);

                string pkgConfirmStr = TempData["confirm_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                confirmPkgInfo confirm = JsonConvert.DeserializeObject <confirmPkgInfo>(pkgConfirmStr);

                string titleStr = TempData["ProdTitleKeep_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(moduleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                ProdTitleModel title = JsonConvert.DeserializeObject <ProdTitleModel>(titleStr);

                string discRuleStr = TempData["pkgsDiscRule_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(discRuleStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                DiscountRuleModel rule = JsonConvert.DeserializeObject <DiscountRuleModel>(discRuleStr);

                string pmgwStr = TempData["pmgw_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(pmgwStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                Pmgw pmgw = JsonConvert.DeserializeObject <Pmgw>(pmgwStr);

                string showStr = TempData["prodShow_" + data.guidNo] as string;
                if (string.IsNullOrEmpty(showStr))
                {
                    throw new Exception("資料錯誤,請重新讀取頁");
                }
                //BookingShowProdModel show = JsonConvert.DeserializeObject<BookingShowProdModel>(showStr);

                TempData.Keep();

                //排除餐食
                data = BookingRepostory.exculdeFood(prod, data, module);

                string b2bOrder = BookingRepostory.insB2dOrder(title, prod, pkg, confirm, data, UserData, rule);

                //轉 ordermodel
                //OrderRepostory res = new OrderRepostory();
                //OrderModel ord = res.setOrderModel(data,pmgw,title);
                //api.json = ord;
                //string orderModelStr = JsonConvert.SerializeObject(api);
                //Website.Instance.logger.Debug($"bookingStep1_ordernewdata:{ JsonConvert.SerializeObject(orderModelStr)}");

                //KKapiHelper kk = new KKapiHelper();
                //JObject order =kk.crtOrder(api);
                JObject order = ApiHelper.orderNew(data, title);

                string       orderMid = "";
                string       orderOid = "";
                returnStatus status   = new returnStatus();

                Website.Instance.logger.Debug($"bookingStep1_ordernewresponse:" + JsonConvert.SerializeObject(order));//要改
                //要先判斷是不是result='0000'
                if (order["content"]["result"].ToString() == "0000")
                {
                    string memUuid = "051794b8-db2a-4fe7-939f-31ab1ee2c719";
                    orderMid = order["content"]["orderMid"].ToString();
                    orderOid = order["content"]["orderOid"].ToString();
                    status.pmchSslRequest = BookingRepostory.setPaymentInfo2(prod, data, orderMid, UserData, pmgw, memUuid);
                    status.status         = "OK";
                    status.url            = Website.Instance.Configuration["kkUrl:pmchUrl"].ToString() + pmgw.pmchPayURL; //pmchUrl

                    //要把BookingShowProdModel 帶到訂購final頁
                    RedisHelper.SetRedis(showStr, "b2d:ec:order:final:prodShow:" + orderMid, 60);
                    RedisHelper.SetRedis(JsonConvert.SerializeObject(data), "b2d:ec:order:final:orderData:" + orderMid, 60);

                    //要存redis 付款主要資訊,最後訂單 upd時要使用,可和下面整合存一個就
                    BookingRepostory.setPayDtltoRedis(data, orderMid, memUuid, RedisHelper);

                    //要存redis 因為付款後要從這個redis內容再進行payment驗證,可和上面整合存一個就好
                    //CallJsonPay rdsJson = (CallJsonPay)status.pmchSslRequest.json;
                    CallJsonPay2 rdsJson     = (CallJsonPay2)status.pmchSslRequest.json;
                    string       callPmchReq = JsonConvert.SerializeObject(status.pmchSslRequest.json);
                    RedisHelper.SetRedis(callPmchReq, "b2d:ec:pmchSslRequest:" + orderMid, 60);
                }
                else
                {
                    status.status = "Error";
                    status.msgErr = order["content"]["result"].ToString() + order["content"]["msg"].ToString();//要改
                }

                return(Json(status));
                //v1/channel/citi/auth
                //https://pmch.sit.kkday.com/citi/payment/auth
                //https://payment.kkday.com/v1/channel/adyen/auth
            }
            catch (Exception ex)
            {
                //error
                Website.Instance.logger.Debug($"bookingStep1_err_ordernew失敗:{ex.Message.ToString()}");
                returnStatus status = new returnStatus();
                status.status = "Error";
                status.msgErr = ex.Message.ToString();

                return(Json(status));
            }
        }