Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(Page.Request.QueryString["modeId"], out modeId))
     {
         base.GotoResourceNotFound();
     }
     else
     {
         btnUpdate.Click += new EventHandler(btnUpdate_Click);
         if (!Page.IsPostBack)
         {
             PaymentModeInfo paymentMode = SubsiteSalesHelper.GetPaymentMode(modeId);
             if (paymentMode == null)
             {
                 base.GotoResourceNotFound();
             }
             else
             {
                 Globals.EntityCoding(paymentMode, false);
                 txtSelectedName.Value = paymentMode.Gateway.ToLower();
                 ConfigData data = new ConfigData(Cryptographer.Decrypt(paymentMode.Settings));
                 txtConfigData.Value           = data.SettingsXml;
                 txtName.Text                  = paymentMode.Name;
                 fcContent.Text                = paymentMode.Description;
                 txtCharge.Text                = paymentMode.Charge.ToString("F", CultureInfo.InvariantCulture);
                 chkIsPercent.Checked          = paymentMode.IsPercent;
                 radiIsUseInpour.SelectedValue = paymentMode.IsUseInpour;
             }
         }
     }
 }
        static void ConvertOldPasswordFormat()
        {
            int processed = 0;

            var toBeUpdated = new List <IUser>();

            foreach (var user in DataFacade.GetData <IUser>())
            {
                if (string.IsNullOrEmpty(user.EncryptedPassword) || !string.IsNullOrEmpty(user.PasswordHashSalt))
                {
                    continue;
                }

                string password = Cryptographer.Decrypt(user.EncryptedPassword);

                var salt = UserFormLoginManager.GenerateHashSalt();

                user.PasswordHashSalt  = Convert.ToBase64String(salt);
                user.EncryptedPassword = UserFormLoginManager.GeneratePasswordHash(password, salt);

                toBeUpdated.Add(user);

                processed++;
            }

            if (toBeUpdated.Any())
            {
                DataFacade.Update(toBeUpdated);
            }

            if (processed > 0)
            {
                Log.LogInformation(LogTitle, "User passwords converted to a new format: " + processed);
            }
        }
Beispiel #3
0
        private static void Main(string[] args)
        {
            Cryptographer c = new Cryptographer("aaaaaaaa");

            byte[] vs = Encoding.Unicode.GetBytes("'sÙ%šM6›>‚êUÝãÄ›ýÿ%šM6›>‚êýÿãÄ›");

            printeByte(vs);

            var r = c.Encrypt(vs);

            Console.WriteLine();
            printeByte(r);
            Console.WriteLine();
            printeByte(c.Decrypt(r));
            //var handle = GetConsoleWindow();
            //FixExeptions();
            //load();
            //loadConfig();
            //if (!startconsol)
            //    ShowWindow(handle, SW_HIDE);


            //if (exe != "" && name != "")
            //{
            //    start();
            //}
            //while (startconsol)
            //    Consol();
            Console.WriteLine("Press any Key to exit...");
            //if (!startconsol)
            Console.ReadKey();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            openIdType = base.Request.QueryString["t"];
            if (string.IsNullOrEmpty(openIdType) || (openIdType.Trim().Length == 0))
            {
                base.GotoResourceNotFound();
            }
            PluginItem pluginItem = OpenIdPlugins.Instance().GetPluginItem(openIdType);

            if (pluginItem == null)
            {
                base.GotoResourceNotFound();
            }
            if (!Page.IsPostBack)
            {
                txtName.Text          = pluginItem.DisplayName;
                lblDisplayName.Text   = pluginItem.DisplayName;
                txtSelectedName.Value = openIdType;
                OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType);
                if (openIdSettings != null)
                {
                    ConfigData data = new ConfigData(Cryptographer.Decrypt(openIdSettings.Settings));
                    txtConfigData.Value = data.SettingsXml;
                    txtName.Text        = openIdSettings.Name;
                    fcContent.Text      = openIdSettings.Description;
                }
            }
        }
        protected override string AuthenticateToken(UsernameToken token)
        {
            LoginUserStatus invalidCredentials = LoginUserStatus.InvalidCredentials;

            try
            {
                SiteManager user = Users.GetUser(0, token.Identity.Name, false, false) as SiteManager;

                if ((user != null) && user.IsAdministrator)
                {
                    HiContext current = HiContext.Current;

                    user.Password = Cryptographer.Decrypt(token.Password);

                    invalidCredentials = Users.ValidateUser(user);
                }
                else
                {
                    invalidCredentials = LoginUserStatus.InvalidCredentials;
                }
            }
            catch
            {
                invalidCredentials = LoginUserStatus.InvalidCredentials;
            }

            if (invalidCredentials == LoginUserStatus.Success)
            {
                return(token.Password);
            }

            return(Cryptographer.CreateHash(token.Password));
        }
Beispiel #6
0
        public void Decrypt_ResultIsSameAfterEncrypt()
        {
            string password          = "******";
            string encryptedPassword = cryptographer.Encypt(password);
            string decryptedPassword = cryptographer.Decrypt(encryptedPassword);

            Assert.That(password, Is.EqualTo(decryptedPassword));
        }
Beispiel #7
0
        public void EncryptEmpty()
        {
            string data      = "";
            string encrypted = Cryptographer.Encrypt(data).Result;
            string decrypted = Cryptographer.Decrypt(encrypted).Result;

            Assert.AreNotEqual <int>(0, encrypted.Length);
            Assert.AreEqual <string>(data, decrypted);
        }
Beispiel #8
0
        private string GetDecryptedPassword(Profile p, string publicKey)
        {
            var cp = new CryptoPassword {
                EncryptedPassword = p.Password,
                IV        = p.IV,
                Salt      = p.Salt,
                KeyPhrase = publicKey
            };

            return(Cryptographer.Decrypt(cp));
        }
Beispiel #9
0
        public async Task DoLogin()
        {
            MakeFormEnable(false);
            ChangeResultText("Please wait while logging you in...", Color.Black);

            if (txtUserName.Text == "")
            {
                ChangeResultText("Please enter the Username", Color.Red);
                MakeFormEnable(true);
                return;
            }

            if (txtPassword.Text == "")
            {
                ChangeResultText("Please enter the Password", Color.Red);
                MakeFormEnable(true);
                return;
            }

            try
            {
                using (var dbx = new AppDBContext())
                {
                    var user = dbx.AppUsers.Where(x => x.Username == txtUserName.Text.Trim()).FirstOrDefault();

                    if (user != null)
                    {
                        if (Cryptographer.Decrypt(user.Password) != txtPassword.Text.Trim())
                        {
                            ChangeResultText("Invalid Password.", Color.Red);
                            MakeFormEnable(true);
                        }
                        else
                        {
                            ShowMainForm(user);
                        }
                    }
                    else
                    {
                        ChangeResultText("Invalid Username.", Color.Red);
                        MakeFormEnable(true);
                    }
                }

                MakeFormEnable(true);
            }
            catch (Exception ex)
            {
                ChangeResultText("There was an error processing request", Color.Red);
                MakeFormEnable(true);
            }
        }
Beispiel #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         SiteSettings siteSettings = SettingsManager.GetSiteSettings(HiContext.Current.User.UserId);
         if (siteSettings.SMSEnabled)
         {
             txtSelectedName.Value = siteSettings.SMSSender.ToLower();
             ConfigData data = new ConfigData(Cryptographer.Decrypt(siteSettings.SMSSettings));
             txtConfigData.Value = data.SettingsXml;
         }
     }
 }
Beispiel #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
         if (masterSettings.EmailEnabled)
         {
             txtSelectedName.Value = masterSettings.EmailSender.ToLower();
             ConfigData data = new ConfigData(Cryptographer.Decrypt(masterSettings.EmailSettings));
             txtConfigData.Value = data.SettingsXml;
         }
     }
 }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.Request.QueryString["orderId"] != null)
            {
                string orderId = Page.Request.QueryString["orderId"];

                OrderInfo orderInfo = TradeHelper.GetOrderInfo(orderId);

                if (orderInfo != null)
                {
                    if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        PaymentModeInfo paymentMode = TradeHelper.GetPaymentMode(orderInfo.PaymentTypeId);

                        if (paymentMode == null)
                        {
                            Response.Write("<div><font color='red'>您之前选择的支付方式已经不存在</font></div>");
                        }
                        else
                        {
                            string showUrl = Globals.FullPath(Globals.GetSiteUrls().Home);

                            if (string.Compare(paymentMode.Gateway, "Hishop.Plugins.Payment.BankRequest", true) == 0)
                            {
                                showUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("bank_pay", new object[] { orderInfo.OrderId }));
                            }
                            if (string.Compare(paymentMode.Gateway, "Hishop.Plugins.Payment.AdvanceRequest", true) == 0)
                            {
                                showUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("advance_pay", new object[] { orderInfo.OrderId }));
                            }

                            string attach = "";

                            HttpCookie cookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];

                            if (!((cookie == null) || string.IsNullOrEmpty(cookie.Value)))
                            {
                                attach = cookie.Value;
                            }

                            PaymentRequest.CreateInstance(paymentMode.Gateway, Cryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单支付", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, showUrl, Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), attach).SendRequest();
                        }
                    }
                    else
                    {
                        Page.Response.Write("订单当前状态不能支付");
                    }
                }
            }
        }
Beispiel #13
0
    void ChangeOutput(object s, System.EventArgs e)
    {
        result_string = new Cryptographer(usr_input.Text, (int)key_input.Value);

        // If combo box is on "Encrypt"
        if (actions.SelectedIndex == 0)
        {
            result.Text = result_string.Encrypt();
        }
        // If on "Decrypt"
        else
        {
            result.Text = result_string.Decrypt();
        }
    }
Beispiel #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string openIdType = "hishop.plugins.openid.alipay.alipayservice";

            OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType);

            if (openIdSettings != null)
            {
                string alipaytoken = Request.QueryString["alipaytoken"];

                XmlDocument document = new XmlDocument();

                document.LoadXml(Cryptographer.Decrypt(openIdSettings.Settings));

                SortedDictionary <string, string> dicArrayPre = new SortedDictionary <string, string>();

                dicArrayPre.Add("service", "user.logistics.address.query");

                dicArrayPre.Add("partner", document.FirstChild.SelectSingleNode("Partner").InnerText);

                dicArrayPre.Add("_input_charset", "utf-8");

                dicArrayPre.Add("return_url", Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("LogisticsAddress_url")));

                dicArrayPre.Add("token", alipaytoken);

                Dictionary <string, string> dicArray = OpenIdFunction.FilterPara(dicArrayPre);

                string sign = OpenIdFunction.BuildMysign(dicArray, document.FirstChild.SelectSingleNode("Key").InnerText, "MD5", "utf-8");

                dicArray.Add("sign", sign);

                dicArray.Add("sign_type", "MD5");

                StringBuilder builder = new StringBuilder();

                foreach (KeyValuePair <string, string> pair in dicArray)
                {
                    builder.Append(OpenIdFunction.CreateField(pair.Key, pair.Value));
                }

                dicArrayPre.Clear();

                dicArray.Clear();

                OpenIdFunction.Submit(OpenIdFunction.CreateForm(builder.ToString(), "https://mapi.alipay.com/gateway.do?_input_charset=utf-8"));
            }
        }
Beispiel #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     litReturnUrl.Text = Globals.FullPath(Globals.ApplicationPath + "/Shopadmin/TaobaoSessionReturn_url.aspx");
     if (!Page.IsPostBack)
     {
         SiteSettings masterSettings = SettingsManager.GetSiteSettings(HiContext.Current.User.UserId);; // SettingsManager.GetMasterSettings(false);
         if (!string.IsNullOrEmpty(masterSettings.Topkey))
         {
             txtTopkey.Text = Cryptographer.Decrypt(masterSettings.Topkey);
         }
         if (!string.IsNullOrEmpty(masterSettings.TopSecret))
         {
             txtTopSecret.Text = Cryptographer.Decrypt(masterSettings.TopSecret);
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            productIds = Request.QueryString["productIds"];

            HttpCookie cookie = HiContext.Current.Context.Request.Cookies["TopSession_" + HiContext.Current.User.UserId.ToString()];

            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            appkey = Cryptographer.Decrypt(masterSettings.Topkey);

            appsecret = Cryptographer.Decrypt(masterSettings.TopSecret);

            if (!((cookie == null) || string.IsNullOrEmpty(cookie.Value)))
            {
                sessionkey = cookie.Value;
            }
        }
Beispiel #17
0
 internal static SMSSender CreateSMSSender(SiteSettings settings, out string msg)
 {
     try
     {
         msg = "";
         if (!settings.SMSEnabled)
         {
             return(null);
         }
         return(SMSSender.CreateInstance(settings.SMSSender, Cryptographer.Decrypt(settings.SMSSettings)));
     }
     catch (Exception exception)
     {
         msg = exception.Message;
         return(null);
     }
 }
Beispiel #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Context.Request.IsAuthenticated)
            {
                FormsAuthentication.SignOut();

                HttpCookie authCookie = FormsAuthentication.GetAuthCookie(HiContext.Current.User.Username, true);

                IUserCookie userCookie = HiContext.Current.User.GetUserCookie();

                if (userCookie != null)
                {
                    userCookie.DeleteCookie(authCookie);
                }

                RoleHelper.SignOut(HiContext.Current.User.Username);
            }

            openIdType = Page.Request.QueryString["HIGW"];

            OpenIdSettingsInfo openIdSettings = MemberProcessor.GetOpenIdSettings(openIdType);

            if (openIdSettings == null)
            {
                Response.Write("登录失败,没有找到对应的插件配置信息。");
            }
            else
            {
                NameValueCollection values = new NameValueCollection();

                values.Add(Page.Request.Form);

                values.Add(Page.Request.QueryString);

                parameters = values;

                OpenIdNotify notify = OpenIdNotify.CreateInstance(openIdType, parameters);

                notify.Authenticated += new EventHandler <AuthenticatedEventArgs>(Notify_Authenticated);

                notify.Failed += new EventHandler <FailedEventArgs>(Notify_Failed);

                notify.Verify(0x7530, Cryptographer.Decrypt(openIdSettings.Settings));
            }
        }
        static void Main(string[] args)
        {
            ICryptographer cryptographer = new Cryptographer();
            var            rawString     = "Hello World";

            var salt            = cryptographer.CreateSalt();
            var encryptedString = cryptographer.Encrypt(rawString, salt);

            WriteLine($"Encrypted String - {encryptedString}");
            WriteLine();

            var decryptedString = cryptographer.Decrypt(encryptedString, salt);

            WriteLine($"Decrypted String - {decryptedString}");
            WriteLine();


            ReadLine();
        }
Beispiel #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Context.Request.IsAuthenticated)
            {
                FormsAuthentication.SignOut();

                HttpCookie authCookie = FormsAuthentication.GetAuthCookie(HiContext.Current.User.Username, true);

                IUserCookie userCookie = HiContext.Current.User.GetUserCookie();

                if (userCookie != null)
                {
                    userCookie.DeleteCookie(authCookie);
                }

                RoleHelper.SignOut(HiContext.Current.User.Username);
            }

            string fullName = base.Request.QueryString["ot"];

            if (OpenIdPlugins.Instance().GetPluginItem(fullName) == null)
            {
                lblMsg.Text = "没有找到对应的插件,<a href=\"" + Globals.GetSiteUrls().Home + "\">返回首页</a>。";
            }
            else
            {
                OpenIdSettingsInfo openIdSettings = MemberProcessor.GetOpenIdSettings(fullName);

                if (openIdSettings == null)
                {
                    lblMsg.Text = "请先配置此插件所需的信息,<a href=\"" + Globals.GetSiteUrls().Home + "\">返回首页</a>。";
                }
                else
                {
                    string returnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("OpenIdEntry_url", new object[] { fullName }));

                    OpenIdService.CreateInstance(fullName, Cryptographer.Decrypt(openIdSettings.Settings), returnUrl).Post();
                }
            }
        }
Beispiel #21
0
        void DoValidate()
        {
            NameValueCollection values2 = new NameValueCollection();

            values2.Add(Page.Request.Form);
            values2.Add(Page.Request.QueryString);
            NameValueCollection parameters = values2;

            Gateway = Page.Request.QueryString["HIGW"];
            Notify  = PaymentNotify.CreateInstance(Gateway, parameters);
            if (isBackRequest)
            {
                Notify.ReturnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("DistributorInpourReturn_url", new object[] { Gateway }));
                Notify.ReturnUrl = Notify.ReturnUrl + "?" + Page.Request.Url.Query;
            }
            InpourId      = Notify.GetOrderId();
            Amount        = Notify.GetOrderAmount();
            InpourRequest = SubsiteStoreHelper.GetInpouRequest(InpourId);
            if (InpourRequest == null)
            {
                ResponseStatus(true, "success");
            }
            else
            {
                Amount  = InpourRequest.InpourBlance;
                paymode = SubsiteStoreHelper.GetPaymentMode(InpourRequest.PaymentId);
                if (paymode == null)
                {
                    ResponseStatus(true, "gatewaynotfound");
                }
                else
                {
                    Notify.Finished          += new EventHandler <FinishedEventArgs>(Notify_Finished);
                    Notify.NotifyVerifyFaild += new EventHandler(Notify_NotifyVerifyFaild);
                    Notify.Payment           += new EventHandler(Notify_Payment);
                    Notify.VerifyNotify(0x7530, Cryptographer.Decrypt(paymode.Settings));
                }
            }
        }
Beispiel #22
0
        void DoValidate()
        {
            NameValueCollection values2 = new NameValueCollection();

            values2.Add(this.Page.Request.Form);
            values2.Add(this.Page.Request.QueryString);
            NameValueCollection parameters = values2;

            this.Gateway = this.Page.Request.QueryString["HIGW"];
            this.Notify  = PaymentNotify.CreateInstance(this.Gateway, parameters);
            if (this.isBackRequest)
            {
                this.Notify.ReturnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { this.Gateway })) + "?" + this.Page.Request.Url.Query;
            }
            this.Amount  = this.Notify.GetOrderAmount();
            this.OrderId = this.Notify.GetOrderId();
            this.Order   = TradeHelper.GetOrderInfo(this.OrderId);
            if (this.Order == null)
            {
                this.ResponseStatus(true, "ordernotfound");
            }
            else
            {
                this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId();
                PaymentModeInfo paymentMode = TradeHelper.GetPaymentMode(this.Order.PaymentTypeId);
                if (paymentMode == null)
                {
                    this.ResponseStatus(true, "gatewaynotfound");
                }
                else
                {
                    this.Notify.Finished          += new EventHandler <FinishedEventArgs>(this.Notify_Finished);
                    this.Notify.NotifyVerifyFaild += new EventHandler(this.Notify_NotifyVerifyFaild);
                    this.Notify.Payment           += new EventHandler(this.Notify_Payment);
                    this.Notify.VerifyNotify(0x7530, Cryptographer.Decrypt(paymentMode.Settings));
                }
            }
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            PaymentModeInfo   paymentMode   = SubsiteStoreHelper.GetPaymentMode(paymentModeId);
            InpourRequestInfo inpourRequest = new InpourRequestInfo();

            inpourRequest.InpourId     = GenerateInpourId();
            inpourRequest.TradeDate    = DateTime.Now;
            inpourRequest.InpourBlance = balance;
            inpourRequest.UserId       = HiContext.Current.User.UserId;
            inpourRequest.PaymentId    = paymentMode.ModeId;

            if (SubsiteStoreHelper.AddInpourBalance(inpourRequest))
            {
                string     attach = "";
                HttpCookie cookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];
                if (!((cookie == null) || string.IsNullOrEmpty(cookie.Value)))
                {
                    attach = cookie.Value;
                }
                string orderId = inpourRequest.InpourId.ToString(CultureInfo.InvariantCulture);
                PaymentRequest.CreateInstance(paymentMode.Gateway, Cryptographer.Decrypt(paymentMode.Settings), orderId, inpourRequest.InpourBlance + paymentMode.CalcPayCharge(inpourRequest.InpourBlance), "预付款充值", "操作流水号-" + orderId, HiContext.Current.User.Email, inpourRequest.TradeDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("DistributorInpourReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("DistributorInpourNotify_url", new object[] { paymentMode.Gateway })), attach).SendRequest();
            }
        }
Beispiel #24
0
        private static void Decrypt()
        {
            Console.Clear();
            Console.WriteLine("DECRYPT OPERATION SELECTED...");
            Console.WriteLine("Enter with Pass Phrase:");
            var passPhrase = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(passPhrase))
            {
                Reset("Invalid value. Try Again.");
            }

            Console.WriteLine("Enter with Text Value:");
            var textValue = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(textValue))
            {
                Reset("Invalid value. Try Again.");
            }

            var result = Cryptographer.Decrypt(textValue, passPhrase);

            Reset($"Result value is: {result}");
        }
Beispiel #25
0
        void btnConfirm_Click(object sender, EventArgs e)
        {
            PaymentModeInfo   paymentMode = TradeHelper.GetPaymentMode(this.paymentModeId);
            InpourRequestInfo info3       = new InpourRequestInfo();

            info3.InpourId     = this.GenerateInpourId();
            info3.TradeDate    = DateTime.Now;
            info3.InpourBlance = this.balance;
            info3.UserId       = HiContext.Current.User.UserId;
            info3.PaymentId    = paymentMode.ModeId;
            InpourRequestInfo inpourRequest = info3;

            if (PersonalHelper.AddInpourBlance(inpourRequest))
            {
                string     attach = "";
                HttpCookie cookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];
                if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value))
                {
                    attach = cookie.Value;
                }
                string orderId = inpourRequest.InpourId.ToString(CultureInfo.InvariantCulture);
                PaymentRequest.CreateInstance(paymentMode.Gateway, Cryptographer.Decrypt(paymentMode.Settings), orderId, inpourRequest.InpourBlance + ((decimal)this.ViewState["PayCharge"]), "预付款充值", "操作流水号-" + orderId, HiContext.Current.User.Email, inpourRequest.TradeDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("InpourReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("InpourNotify_url", new object[] { paymentMode.Gateway })), attach).SendRequest();
            }
        }
Beispiel #26
0
        public async Task <IActionResult> GenerateCode()
        {
            string         key;
            string         hw;
            RequestMessage requestMessage;
            string         requestBody;
            LicenseSession session;

            try
            {
                requestBody = await GetBody();

                session = await SaveSession(StringUtils.Decrypt(requestBody));

                requestMessage = Cryptographer.Decrypt <RequestMessage>(requestBody);
                hw             = requestMessage.Hardware;
                key            = requestMessage.Key;
            }
            catch (Exception e)
            {
                return(Json(new ResponseMessage {
                    ServerError = "Некорректный формат запроса"
                }));
            }

            if (session.Address.IsBanned)
            {
                return(Json(new ResponseMessage {
                    ServerError = "IP заблокирован"
                }));
            }

            if (string.IsNullOrWhiteSpace(hw))
            {
                return(Json(new ResponseMessage {
                    ServerError = "Не указан идентификатор железа"
                }));
            }

            if (string.IsNullOrWhiteSpace(key))
            {
                return(Json(new ResponseMessage {
                    ServerError = "Не указан лицензионный ключ"
                }));
            }

            var license = await _context.Licenses
                          .Include(l => l.Client)
                          .Include(l => l.LicenseHardwares)
                          .ThenInclude(lh => lh.Hardware)
                          .ThenInclude(h => h.Client)
                          .Include(l => l.Sessions)
                          .FirstOrDefaultAsync(l => l.Key.Equals(key, StringComparison.OrdinalIgnoreCase));

            if (license == null)
            {
                return(Json(new ResponseMessage {
                    ServerError = "Лицензия не найдена"
                }));
            }

            if (license.IsBanned)
            {
                return(Json(new ResponseMessage {
                    ServerError = "Лицензия заблокирована"
                }));
            }

            if (license.ExpirationDate < DateTime.Now)
            {
                return(Json(new ResponseMessage {
                    ServerError = "Лицензия истекла"
                }));
            }

            if (license.Client.IsBanned)
            {
                return(Json(new ResponseMessage {
                    ServerError = "Пользователь заблокирован"
                }));
            }

            if (license.LicenseHardwares.Count == license.HardwaresLimit && !license.LicenseHardwares.Any(l =>
                                                                                                          l.Hardware.Value.Equals(hw, StringComparison.OrdinalIgnoreCase)))
            {
                return(Json(new ResponseMessage {
                    ServerError = "Неизвестный идентификатор железа"
                }));
            }

            if (license.ActivationDate == null)
            {
                license.ActivationDate = DateTimeHelper.GetCurrentTime();
            }

            var licenseHw = license.LicenseHardwares.FirstOrDefault(lh =>
                                                                    lh.Hardware.Value.Equals(hw, StringComparison.OrdinalIgnoreCase));

            if (licenseHw != null)
            {
                if (licenseHw.Hardware.IsBanned)
                {
                    return(Json(new ResponseMessage {
                        ServerError = "Идентификатор железа заблокирован"
                    }));
                }

                licenseHw.LastUse = DateTimeHelper.GetCurrentTime();
                _context.Entry(licenseHw).State = EntityState.Modified;
            }
            else if (license.LicenseHardwares.Count < license.HardwaresLimit)
            {
                var newHardware = new Hardware {
                    ClientId = license.ClientId, Value = hw
                };
                licenseHw = new LicenseHardware
                {
                    Hardware = newHardware,
                    License  = license,
                    LastUse  = DateTimeHelper.GetCurrentTime(),
                    HardwareAttachingDate = DateTimeHelper.GetCurrentTime()
                };
                license.LicenseHardwares.Add(licenseHw);

                await _context.Hardwares.AddAsync(newHardware);

                await _context.LicenseHardwares.AddAsync(licenseHw);

                await _context.SaveChangesAsync();
            }

            session.Hardware  = licenseHw.Hardware;
            session.LicenseId = license.Id;
            license.LastUse   = DateTimeHelper.GetCurrentTime();

            _context.Entry(session).State = EntityState.Modified;
            _context.Entry(license).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            await RemoveOldSession();


            string code;

            try
            {
                code = CodeGenerator.Generate(requestMessage.GenerationData);
            }
            catch (Exception e)
            {
                return(Json(new ResponseMessage {
                    GeneratorError = "ExceptionMessage: " + e.Message + Environment.NewLine + Environment.NewLine + "StackTrace:" + Environment.NewLine + e.StackTrace
                }));
            }

            return(Json(new ResponseMessage {
                Code = code
            }));
        }
Beispiel #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            cookie = HiContext.Current.Context.Request.Cookies["TopSession_" + HiContext.Current.User.UserId.ToString()];

            //if (!Page.IsPostBack && ((cookie == null) || string.IsNullOrEmpty(cookie.Value)))
            //{
            //    string str = "0";
            //    try
            //    {
            //        str = base.SendHttpRequest();
            //    }
            //    catch (Exception)
            //    {
            //        content1.Visible = false;
            //        content12.Visible = true;
            //        txtMsg.Text = "SAAS分销平台请求失败,可能是网络原因,请刷新重试";
            //        return;
            //    }
            //    string str5 = str;
            //    if (str5 != null)
            //    {
            //        if (!(str5 == "-1"))
            //        {
            //            if (str5 == "-2")
            //            {
            //                content1.Visible = false;
            //                content12.Visible = true;
            //                txtMsg.Text = "更新分销商信息出错";
            //                return;
            //            }
            //            if (str5 == "-3")
            //            {
            //                content1.Visible = false;
            //                content12.Visible = true;
            //                txtMsg.Text = "添加分销商记录出错";
            //                return;
            //            }
            //            if (str5 == "-99")
            //            {
            //                content1.Visible = false;
            //                content12.Visible = true;
            //                txtMsg.Text = "未知错误";
            //                return;
            //            }
            //            if (str5 == "0")
            //            {
            //                content1.Visible = false;
            //                content12.Visible = true;
            //                txtMsg.Text = "您提交的参数有误";
            //                return;
            //            }
            //        }
            //        else
            //        {
            //            content1.Visible = false;
            //            content12.Visible = true;
            //            txtMsg.Text = "您的供货商(即主站管理员)并没有注册开通同步淘宝";
            //            return;
            //        }
            //    }
            //}
            LoadParameters();
            shippingModeDropDownList.DataBind();
            btnSearch.Click += new EventHandler(btnSearch_Click);
            //SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
            SiteSettings masterSettings = SettingsManager.GetSiteSettings(HiContext.Current.User.UserId);

            if ((cookie == null) || string.IsNullOrEmpty(cookie.Value))
            {
                if (null != masterSettings)
                {
                    if (!(string.IsNullOrEmpty(masterSettings.Topkey) || string.IsNullOrEmpty(masterSettings.TopSecret)))
                    {
                        HttpCookie TaobaoSessionReturnUrlCookies = new HttpCookie("TaobaoSessionReturnUrl_" + HiContext.Current.User.UserId.ToString());
                        TaobaoSessionReturnUrlCookies.Value = HttpContext.Current.Request.Url.AbsoluteUri;
                        HttpContext.Current.Response.Cookies.Add(TaobaoSessionReturnUrlCookies);
                        Response.Redirect("http://container.api.taobao.com/container?appkey=" + Cryptographer.Decrypt(masterSettings.Topkey), true);
                    }
                }
                else
                {
                    this.ShowMsg("请先申请开店铺,设置淘宝同步信息!", false);
                }
            }
            else
            {
                string serverUrl = "http://gw.api.taobao.com/router/rest";
                string appKey    = Cryptographer.Decrypt(masterSettings.Topkey);
                string appSecret = Cryptographer.Decrypt(masterSettings.TopSecret);
                client = new DefaultTopClient(serverUrl, appKey, appSecret, "json");
                TradesSoldGetRequest request2 = new TradesSoldGetRequest();
                request2.Fields = "tid,created,buyer_nick,receiver_name,price,num,payment,shipping_type,post_fee,status,seller_rate,orders";
                TradesSoldGetRequest request = request2;
                if (startDate.HasValue)
                {
                    request.StartCreated = new DateTime?(startDate.Value);
                }
                if (endDate.HasValue)
                {
                    request.EndCreated = new DateTime?(endDate.Value);
                }
                request.Status = "WAIT_SELLER_SEND_GOODS";
                if (!string.IsNullOrEmpty(buyerNick))
                {
                    request.BuyerNick = buyerNick;
                }
                request.PageNo   = new long?((long)pager.PageIndex);
                request.PageSize = 40;
                TradesSoldGetResponse response = client.Execute <TradesSoldGetResponse>(request, cookie.Value);
                if (!response.IsError)
                {
                    List <Trade> trades = response.Trades;
                    if (trades != null)
                    {
                        foreach (Trade trade in trades)
                        {
                            trade.ShippingType = GetShippingType(trade.ShippingType);
                            trade.Status       = GetTradeStatus(trade.Status);
                            foreach (Order order in trade.Orders)
                            {
                                if (!string.IsNullOrEmpty(order.OuterSkuId))
                                {
                                    order.OuterSkuId = "商家编码:" + order.OuterSkuId;
                                }
                            }
                        }
                        rptTrades.DataSource = trades;
                        rptTrades.DataBind();
                        pager.TotalRecords  = int.Parse(response.TotalResults.ToString());
                        pager1.TotalRecords = int.Parse(response.TotalResults.ToString());
                    }
                }
            }
        }
Beispiel #28
0
 public string Decrypt(string encryptedValue)
 {
     return(Cryptographer.Decrypt(encryptedValue));
 }
Beispiel #29
0
 private void btnSendGoods_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtShipOrderNumber.Text.Trim()) || (txtShipOrderNumber.Text.Trim().Length > 20))
     {
         ShowMsg("运单号码不能为空,在1至20个字符之间", false);
     }
     else
     {
         OrderInfo orderInfo = SubsiteSalesHelper.GetOrderInfo(orderId);
         if (orderInfo != null)
         {
             if ((orderInfo.GroupBuyId > 0) && (orderInfo.GroupBuyStatus != GroupBuyStatus.Success))
             {
                 ShowMsg("当前订单为团购订单,团购活动还未成功结束,所以不能发货", false);
             }
             else if (orderInfo.OrderStatus != OrderStatus.BuyerAlreadyPaid)
             {
                 ShowMsg("当前订单状态没有付款或不是等待发货的订单,所以不能发货", false);
             }
             else if (!radioShippingMode.SelectedValue.HasValue)
             {
                 ShowMsg("请选择配送方式", false);
             }
             else if (string.IsNullOrEmpty(expressRadioButtonList.SelectedValue))
             {
                 ShowMsg("请选择物流公司", false);
             }
             else
             {
                 ShippingModeInfo shippingMode = SubsiteSalesHelper.GetShippingMode(radioShippingMode.SelectedValue.Value, true);
                 orderInfo.RealShippingModeId = radioShippingMode.SelectedValue.Value;
                 orderInfo.RealModeName       = shippingMode.Name;
                 orderInfo.ExpressCompanyAbb  = expressRadioButtonList.SelectedValue;
                 orderInfo.ExpressCompanyName = expressRadioButtonList.SelectedItem.Text;
                 orderInfo.ShipOrderNumber    = txtShipOrderNumber.Text;
                 if (SubsiteSalesHelper.SendGoods(orderInfo))
                 {
                     if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && (orderInfo.GatewayOrderId.Trim().Length > 0))
                     {
                         PaymentModeInfo paymentMode = SubsiteSalesHelper.GetPaymentMode(orderInfo.PaymentTypeId);
                         if (paymentMode != null)
                         {
                             PaymentRequest.CreateInstance(paymentMode.Gateway, Cryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                         }
                     }
                     int userId = orderInfo.UserId;
                     if (userId == 0x44c)
                     {
                         userId = 0;
                     }
                     IUser user = Users.GetUser(userId);
                     Messenger.OrderShipping(orderInfo, user);
                     orderInfo.OnDeliver();
                     ShowMsg("发货成功", true);
                 }
                 else
                 {
                     ShowMsg("发货失败", false);
                 }
             }
         }
     }
 }
 private void btnSendGoods_Click(object sender, EventArgs e)
 {
     if (grdOrderGoods.Rows.Count <= 0)
     {
         ShowMsg("没有要进行发货的订单。", false);
     }
     else
     {
         DropdownColumn     column        = (DropdownColumn)grdOrderGoods.Columns[4];
         ListItemCollection selectedItems = column.SelectedItems;
         DropdownColumn     column2       = (DropdownColumn)grdOrderGoods.Columns[5];
         ListItemCollection items2        = column2.SelectedItems;
         int num = 0;
         for (int i = 0; i < selectedItems.Count; i++)
         {
             string   orderId = (string)grdOrderGoods.DataKeys[grdOrderGoods.Rows[i].RowIndex].Value;
             TextBox  box     = (TextBox)grdOrderGoods.Rows[i].FindControl("txtShippOrderNumber");
             ListItem item    = selectedItems[i];
             ListItem item2   = items2[i];
             int      result  = 0;
             int.TryParse(item.Value, out result);
             if ((!string.IsNullOrEmpty(box.Text.Trim()) && !string.IsNullOrEmpty(item.Value)) && ((int.Parse(item.Value) > 0) && !string.IsNullOrEmpty(item2.Value)))
             {
                 OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId);
                 if (((orderInfo.GroupBuyId <= 0) || (orderInfo.GroupBuyStatus == GroupBuyStatus.Success)) && (((orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid) && (result > 0)) && (!string.IsNullOrEmpty(box.Text.Trim()) && (box.Text.Trim().Length <= 20))))
                 {
                     ShippingModeInfo shippingMode = SalesHelper.GetShippingMode(result, true);
                     orderInfo.RealShippingModeId = shippingMode.ModeId;
                     orderInfo.RealModeName       = shippingMode.Name;
                     orderInfo.ExpressCompanyAbb  = item2.Value;
                     orderInfo.ExpressCompanyName = item2.Text;
                     orderInfo.ShipOrderNumber    = box.Text;
                     if (OrderHelper.SendGoods(orderInfo))
                     {
                         if (!string.IsNullOrEmpty(orderInfo.GatewayOrderId) && (orderInfo.GatewayOrderId.Trim().Length > 0))
                         {
                             PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(orderInfo.PaymentTypeId);
                             if (paymentMode != null)
                             {
                                 PaymentRequest.CreateInstance(paymentMode.Gateway, Cryptographer.Decrypt(paymentMode.Settings), orderInfo.OrderId, orderInfo.GetTotal(), "订单发货", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, Globals.FullPath(Globals.GetSiteUrls().Home), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentReturn_url", new object[] { paymentMode.Gateway })), Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("PaymentNotify_url", new object[] { paymentMode.Gateway })), "").SendGoods(orderInfo.GatewayOrderId, orderInfo.RealModeName, orderInfo.ShipOrderNumber, "EXPRESS");
                             }
                         }
                         int userId = orderInfo.UserId;
                         if (userId == 0x44c)
                         {
                             userId = 0;
                         }
                         IUser user = Users.GetUser(userId);
                         Messenger.OrderShipping(orderInfo, user);
                         orderInfo.OnDeliver();
                         num++;
                     }
                 }
             }
         }
         if (num == 0)
         {
             ShowMsg("批量发货失败!", false);
         }
         else if (num > 0)
         {
             BindData();
             ShowMsg(string.Format("批量发货成功!发货数量{0}个", num), true);
         }
     }
 }