// api/pawn_info/get_in_ban_cam_ket_xe_khong_chinh_chu?User_ID=9&Pawn_ID=1167678&filetemp=in-ban-cam-ket-xe-khong-chinh-chu.html
        public HttpResponseMessage get_in_ban_cam_ket_xe_khong_chinh_chu([FromUri] int User_ID, [FromUri] int Pawn_ID, [FromUri] string filetemp)
        {
            string       html = "";
            oPawnInfo    pawn = null;
            oCacheResult rs   = this.post_Search(new oCacheRequest("Pawn_ID != null && Pawn_ID = " + Pawn_ID));

            if (rs.Ok && rs.Result.Length > 0)
            {
                pawn = (oPawnInfo)rs.Result[0];
            }
            //pawn = JsonConvert.DeserializeObject<oPawnInfo>(File.ReadAllText(Path.Combine(Path.GetFullPath("../"), "MessageUI/pdf/pawn.json")));
            if (pawn != null)
            {
                string file = Path.Combine(Path.GetFullPath("../"), "MessageUI/pdf/" + filetemp);
                string temp = File.ReadAllText(file);
                temp = temp.Replace("[SO_HOP_DONG]", pawn.PawnCode);

                Helpers.Clear();
                Helpers.Register("FormatGender", fn_format_Gender);
                Helpers.Register("FormatDateTime", fn_formatDateTime_ddMMyyyy);
                Helpers.Register("FormatDateTimeNow", fn_formatDateTimeNow);
                Helpers.Register("FormatDateTime1", fn_formatDateTime);
                Helpers.Register("FormatDateTime2", fn_formatDateTime);
                Helpers.Register("FormatMoney1", fn_formatMoney);
                Helpers.Register("NumberToText1", fn_numberToText);

                html = Render.StringToString(temp, pawn);
            }

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(html, Encoding.UTF8, "text/html");
            return(response);
        }
Example #2
0
        public oCacheResult post_AddNew([FromBody] dtoUserLogin_addNew item)
        {
            if (item == null)
            {
                return(new oCacheResult().ToFailConvertJson("Please check format string json of input."));
            }

            oCacheResult rs = this.sqlExecute <dtoUserLogin_addNewResult, dtoUserLogin_addNew>(_DB_STORE_USER_LOGIN._addNew, item);

            rs.Request = null;
            if (rs.Ok && rs.Result.Length > 0)
            {
                object obj = rs.Result[0];
                dtoUserLogin_addNewResult it = (dtoUserLogin_addNewResult)obj;
                if (it.Ok)
                {
                    if (!string.IsNullOrWhiteSpace(it.ServiceCache))
                    {
                        this.reloadCacheByServiceNameArray(it.ServiceCache.Split(',').Select(x => x.Trim().ToLower()).ToArray());
                    }
                }
                else
                {
                    rs.Ok      = false;
                    rs.Message = it.Message;
                    rs.Result  = new dynamic[] { };
                }
            }
            return(rs);
            //return new oCacheResult() { Result = new dynamic[] { item } };
        }
        public oCacheResult post_Search([FromBody] oCacheRequest value)
        {
            if (value == null)
            {
                return(new oCacheResult().ToFailConvertJson("Please check format string json of input."));
            }

            value.RequestId = Guid.NewGuid().ToString();
            oCacheResult result = _cache.executeRequestJsonReplyCacheKey(value.ToJson()).getResultByCacheKey();

            result.Request = value;
            return(result);
        }
Example #4
0
        public oCacheResult post_Login([FromBody] oUserLogin item)
        {
            if (item == null)
            {
                return(new oCacheResult().ToFailConvertJson("Please check format string json of input."));
            }

            oCacheResult result = _cache
                                  .executeConditonsReplyCacheKey("Username=\"" + item.Username + "\" And Password=\"" + item.Password + "\"")
                                  .getResultByCacheKey();

            return(result);
        }
        public oCacheResult post_AddNew([FromBody] oPosPushNotify item)
        {
            if (item == null)
            {
                return(new oCacheResult().ToFailConvertJson("Please check format string json of input."));
            }

            oCacheResult rs = this.sqlExecute <dtoPosPushNotify_addResult, oPosPushNotify>("pos_push_notify_createNew", item);

            rs.Request = null;
            if (rs.Ok && rs.Result.Length > 0)
            {
                var it = (dtoPosPushNotify_addResult)rs.Result[0];
                if (!string.IsNullOrWhiteSpace(it.ServiceCache))
                {
                    this.reloadCacheByServiceNameArray(it.ServiceCache.Split(',').Select(x => x.Trim().ToLower()).ToArray());
                }
            }
            return(rs);
        }
        static void test_1()
        {
            int port = (int)getOptions("port");

            ServiceHost host2 = new ServiceHost(typeof(UserLoginService), new Uri("http://localhost:" + port + "/test/"));

            host2.AddServiceEndpoint(typeof(ICacheService), new BasicHttpBinding(), "");
            host2.Description.Behaviors.Add(new UserLoginBehavior(new UserLoginService(Dataflow, new oCacheModel())));
            host2.Open();

            ChannelFactory <ICacheService> factory2 = new ChannelFactory <ICacheService>(new BasicHttpBinding(), new EndpointAddress("http://localhost:" + port + "/test/"));
            ICacheService proxy2 = factory2.CreateChannel();
            oCacheResult  rs2    = proxy2.executeConditonsReplyCacheKey("UserName=\"admin\"").getResultByCacheKey();

            rs2.clearCacheIfExist();

            Console.WriteLine("test-> {0}", rs2.ToJson());

            ((IClientChannel)proxy2).Close();
            factory2.Close();
            host2.Close();
        }
        public oCacheResult get_All()
        {
            oCacheResult result = _cache.getAllJsonReplyCacheKey().getResultByCacheKey();

            return(result);
        }
        public oCacheResult post_AddNew([FromBody] dtoPawnInfo_addNew item)
        {
            if (item == null)
            {
                return(new oCacheResult().ToFailConvertJson("Please check format string json of input."));
            }

            //string json = JsonConvert.SerializeObject(item);
            //;

            #region [ If API_POS is not exist, Get automation PawnCode will be genation as follow ]
            //////String sixdigit = new Random().Next(0, 999999).ToString("D6");
            //////string formatByCompay = DateTime.Now.ToString("yyMM");
            //////string GenCodeNo = string.Format("HĐCC/DR/{0}/{1}", formatByCompay, sixdigit);
            #endregion

            //Call API: must only
            var    request_Id = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            string json       = JsonConvert.SerializeObject(new dtoPawnInfo_addNewOnPOS()
            {
                CustomerName      = item.Custorer_Name,
                IdNumber          = Convert.ToInt64(item.CMND_CCCD),
                IdType            = "0",
                IdPlace           = item.CMND_CreatePlace,
                IdDate            = Convert.ToString(item.CMND_CreateDate),
                Phone             = item.Custorer_Phone,
                LoanPurpose       = "Vay đăng ký xe máy qua đối tác ECPAY",
                Email             = "",
                District          = item.Custorer_AddressPlace,
                FamilyMemberName  = item.RegistrationBook_Name,
                FamilyMemberPhone = item.RegistrationBook_Phone,
                FriendName        = item.Colleague_Name,
                FriendPhone       = item.Colleague_Phone,
                LocationCode      = "1001",
                AssetName         = "Đăng ký xe máy",
                ReceiveMethod     = "CASH",
                media             = new dtoPawnInfoMedia_addNewOnPOS()
                {
                    IDImageFront = item.Image_Asset_1,
                    IDImageAfter = item.Image_Asset_2,
                    AssetImage1  = item.Image_InvoiceElectric_1,
                    AssetImage2  = item.Image_RegistrationBook_1,
                    AssetImage3  = item.Image_RegistrationBook_2,
                    AssetImage4  = item.Image_VehicleRegistration_1,
                    AssetImage5  = item.Image_VehicleRegistration_2,
                    AssetImage6  = item.Image_Asset_1,
                    IDImage1     = item.Image_Asset_1,
                    IDImage2     = item.Image_Asset_2
                },
                bank = new dtoPawnInfoBank_addNewOnPOS()
                {
                    AccountCode = item.PayAccount_No,
                    AccountName = item.Custorer_Name,
                    BankName    = item.Bank_ID.ToString(),
                    BranchName  = item.Bank_ID.ToString()
                },
                Amount          = item.LoanAmount,
                StaffName       = item.InviteUser_ID.ToString(),
                StaffPhone      = item.InviteUser_ID.ToString(),
                StaftCreateDate = request_Id,
                ShopIDSelected  = item.ContractSettlementShop_ID,
                //requestId = "1910101010141010126",
                requestId    = request_Id,
                partnerCode  = "ECPAY",
                locationCode = "500",
                signKey      = HMAC_SHA1("F88Viettel2019", request_Id + item.InviteUser_ID)
            }, Formatting.Indented);
            try
            {
                //var api = ECPAY.CreatePawn;
                var res = (ResponseApiData)RestApi.RestApiPost("partner/create-contract ", json);
                if (res.code == MessageBroker.ApiUrl.ApiConstants.Code.Success)
                {
                    // return true;
                    //var dataOut = res.data;
                    //IList collection = (IList)dataOut;
                    MessageBroker.ApiUrl.oPOS.RootObject instance = JsonConvert.DeserializeObject <MessageBroker.ApiUrl.oPOS.RootObject>(res.data.ToString());
                    //Lấy ra CodeNo để gán ngược lại cho [dtoPawnInfo_addNew item]
                    var CodeNo = instance.PawnResponse[0].PawnCode;
                    item.PawnCode = CodeNo;
                    //Gọi API check trạng thái HĐ
                    var TransactionCode = instance.PawnResponse[0].RefereceCode;
                    var TransactionDate = instance.PawnResponse[0].Created;
                    var ReferenceId     = instance.PawnResponse[0].PaymementRef;
                    var TransactionType = TransactionTypeEnum.CHECK_TRANG_THAI_HOP_DONG.ToString();

                    string json_checktrans = JsonConvert.SerializeObject(new MessageBroker.Api.ApiUrl.oCheckTransactionRequest()
                    {
                        TransactionCode = TransactionCode,
                        TransactionDate = TransactionDate,
                        PawnID          = instance.PawnResponse[0].PawnID,
                        TransactionType = TransactionType,
                        ReferenceId     = ReferenceId,
                        requestId       = request_Id,
                        partnerCode     = "ECPAY",
                        locationCode    = "500",
                        signKey         = HMAC_SHA1("F88Viettel2019", request_Id + item.InviteUser_ID)
                    }, Formatting.Indented);
                    var res_check = (ResponseApiData)RestApi.RestApiPost("partner/check-trans", json_checktrans);
                    if (res_check.code == MessageBroker.ApiUrl.ApiConstants.Code.Success)
                    {
                    }

                    oCacheResult rs = this.sqlExecute <dtoPawnInfo_addNewResult, dtoPawnInfo_addNew>(_DB_STORE_PAWN_INFO._addNew, item);
                    if (rs.Ok && rs.Result.Length > 0)
                    {
                        var it = (dtoPawnInfo_addNewResult)rs.Result[0];
                        if (!string.IsNullOrWhiteSpace(it.ServiceCache))
                        {
                            this.reloadCacheByServiceNameArray(it.ServiceCache.Split(',').Select(x => x.Trim().ToLower()).ToArray());
                        }
                    }
                    return(rs);
                }
                else
                {
                    //String sixdigit = new Random().Next(0, 999999).ToString("D6");
                    //string formatByCompay = DateTime.Now.ToString("yyMM");
                    //GenCodeNo = string.Format("HĐCC/DR/{0}/{1}", formatByCompay, sixdigit);
                    //return FailResult(response.code, response.message);
                    return(new oCacheResult().ToFailException("(1) Tạo hợp đồng trên POS thất bại"));
                }
            }
            catch (Exception exception)
            {
                var ex = exception.Message.ToString();
                return(new oCacheResult().ToFailException("(2) Tạo hợp đồng trên POS thất bại"));
            }
            //return new oCacheResult().ToOk();
        }