コード例 #1
0
 public ActionResult SetCookie(string txtName, string bgColor)
 {
     CookieHelper cookieHelper = new CookieHelper();
     cookieHelper.SetUserName(txtName);
     cookieHelper.SetUserColor(bgColor);
     return RedirectToAction("Index");
 }
コード例 #2
0
 public ActionResult Index()
 {
     CookieHelper cookieHelper = new CookieHelper();
     ViewBag.UserName = cookieHelper.GetUserName();
     ViewBag.UserColor = cookieHelper.GetUserColor();
     return View();
 }
コード例 #3
0
 public void OnActionExecuting(ActionExecutingContext filterContext)
 {
     CookieHelper cookie = new CookieHelper();
     if (cookie.IsLogin)
     {
         filterContext.RequestContext.HttpContext.Response.Redirect("/Home/Index");
     }
 }
コード例 #4
0
ファイル: CookieHelper.cs プロジェクト: sillyx/TaskRelease
 /// <summary>
 /// 实例化入口
 /// </summary>
 /// <returns>实例对象</returns>
 public static CookieHelper CreateInstance()
 {
     if (_instance == null)
     {
         lock (_lock)
         {
             if (_instance == null)
             {
                 _instance = new CookieHelper();
             }
         }
     }
     return _instance;
 }
コード例 #5
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CookieHelper cookie = new CookieHelper();
            if (cookie.IsLogin)
            {
                //filterContext.Result = new RedirectResult("/Home/Index");
                filterContext.Result = new RedirectResult("/LogoVotes/Index");

            }
            //else
            //{
            //    filterContext.Result = new RedirectResult("/Users/Login");
            //}
        }
コード例 #6
0
        public ActionResult SignIn(string userName, string password)
        {
            var res = _unitOfWork.UserRepository.HasPermitionToSignIn(userName, password);

            if (res)
            {
                CookieHelper cookieHelper = new CookieHelper(HttpContext.Request, HttpContext.Response);
                cookieHelper.SetLoginCookie(userName, password, true);

                return RedirectToAction("Index", "Home");
            }

            return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
        }
コード例 #7
0
        /// <summary>
        /// Handles encryption of the session data into a HTTP cookie.
        /// </summary>
        /// <param name="context"></param>
        public static void ProcessPostRequest(HttpContextBase context)
        {
            var session = GetSession(context, false);
            if (session == null || !session.IsDirty)
            {
                return;
            }

            var plaintext = SessionSerializer.Serialize(session);
            var encryption = new Encryption(Configuration.EncryptionKey, Configuration.SignatureKey);
            var encrypted = encryption.Encrypt(plaintext);

            var cookies = new CookieHelper(Configuration.CookieName);
            cookies.Set(context, encrypted);
        }
コード例 #8
0
        public static bool Login(string UserName, string Password, bool createPersistentCookie = false)
        {
            string encryptPassword = CryptographyHelper.Encrypt(Password);
            CookieHelper cookie = new CookieHelper();

            var objUser = TTRepository.GetUser(UserName);
            if (objUser != null && objUser.Password == encryptPassword)//Utente presente controllo il cookie
            {
                if (!cookie.Exist(cookieName))
                {
                    cookie.CreateCookie(cookieName)
                        .SetCookie("UserName", UserName)
                        .SetCookie("Password", encryptPassword);
                }

                Authenticate(UserName, createPersistentCookie);
                return true;
            }
            return false;
        }
コード例 #9
0
        /// <summary>
        /// Handles decryption of the Session cookie value. Resets the session after
        /// expiration.
        /// </summary>
        /// <param name="context"></param>
        public static void ProcessPreRequest(HttpContextBase context)
        {
            var cookies = new CookieHelper(Configuration.CookieName);
            var encrypted = cookies.Gets(context);
            if (string.IsNullOrEmpty(encrypted))
            {
                return;
            }

            var encryption = new Encryption(Configuration.EncryptionKey, Configuration.SignatureKey);
            var decrypted = encryption.Decrypt(encrypted);
            if (string.IsNullOrEmpty(decrypted))
            {
                return;
            }

            var session = SessionSerializer.Deserialize(decrypted);
            if (session.CreatedAt + session.Duration < DateTime.UtcNow)
            {
                session.Reset(Configuration.Duration);
            }

            context.Items[ItemKey] = session;
        }
コード例 #10
0
    /// <summary>
    /// Sends the given file within response.
    /// </summary>
    /// <param name="file">File to send</param>
    protected void SendFile(CMSOutputSharePointFile file)
    {
        // Clear response.
        CookieHelper.ClearResponseCookies();
        Response.Clear();

        Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);

        if ((file != null) && file.IsValid)
        {
            // Prepare etag in ""
            string etag = "\"" + file.SharePointFilePath + "\"";

            // Client caching - only on the live site
            if (useClientCache && AllowCache && CacheHelper.CacheImageEnabled(CurrentSiteName) && ETagsMatch(etag, file.LastModified))
            {
                RespondNotModified(etag, true);
                return;
            }

            // If the output data should be cached, return the output data
            bool cacheOutputData = false;
            if (file.OutputData != null)
            {
                cacheOutputData = CacheHelper.CacheImageAllowed(CurrentSiteName, file.OutputData.Length);
            }

            // Ensure the file data
            if (!file.DataLoaded)
            {
                byte[] cachedData = GetCachedOutputData();

                // Ensure data are retrieved from SharePoint
                if (file.EnsureData(cachedData))
                {
                    if ((cachedData == null) && cacheOutputData)
                    {
                        SaveOutputDataToCache(file.OutputData, null);
                    }
                }
            }

            // Send the file
            if (file.OutputData != null)
            {
                byte[] data = null;

                // Check if the request is for partial data (Range HTTP header)
                long[,] rangePosition = GetRange(file.OutputData.Length, HttpContext.Current);

                // Send all file contens
                if (rangePosition.GetUpperBound(0) == 0)
                {
                    // Setup the mime type - Fix the special types
                    string mimetype = file.MimeType;
                    switch (file.FileExtension.ToLower())
                    {
                    case ".flv":
                        mimetype = "video/x-flv";
                        break;
                    }

                    // Prepare response
                    Response.ContentType = mimetype;

                    // get file name without the path
                    string fileName = Path.GetFileName(file.SharePointFilePath);

                    SetDisposition(fileName, file.FileExtension);

                    // Setup Etag property
                    ETag = etag;

                    // Set if resumable downloads should be supported
                    AcceptRange = !IsExtensionExcludedFromRanges(file.FileExtension);

                    if (useClientCache && AllowCache && (CacheHelper.CacheImageEnabled(CurrentSiteName)))
                    {
                        DateTime expires = DateTime.Now;

                        // Send last modified header to allow client caching
                        Response.Cache.SetLastModified(file.LastModified);

                        Response.Cache.SetCacheability(HttpCacheability.Public);
                        if (DocumentBase.AllowClientCache() && DocumentBase.UseFullClientCache)
                        {
                            expires = DateTime.Now.AddMinutes(CacheHelper.CacheImageMinutes(CurrentSiteName));
                        }


                        Response.Cache.SetExpires(expires);
                        Response.Cache.SetETag(etag);
                    }

                    data = file.OutputData;
                }
                // Send partial contens
                else
                {
                    data = new byte[file.OutputData.Length - rangePosition[0, RANGE_START]];

                    // Get part of file
                    Array.Copy(file.OutputData, rangePosition[0, RANGE_START], data, 0, data.Length);
                }

                // Use output data of the file in memory if present
                WriteBytes(data);
            }
            else
            {
                NotFound();
            }
        }
        else
        {
            NotFound();
        }

        CompleteRequest();
    }
コード例 #11
0
        public JsonResult SaveProjectStatus(string param)
        {
            //转成实体对象
            T_ENGIN_INFO arr = new T_ENGIN_INFO();

            arr = JsonHelper.JSONToObject <T_ENGIN_INFO>(param);

            // 接口
            string method = "wavenet.fxsw.engin.farm.update";
            // 接口所需传递的参数
            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();

            #region
            //基本信息
            paramDictionary.Add("s_id", arr.S_ID); //id
            paramDictionary.Add("s_name", arr.S_NAME);
            paramDictionary.Add("s_project_no", arr.S_PROJECT_NO);
            paramDictionary.Add("n_year", arr.N_YEAR);                 //年度
            paramDictionary.Add("n_pace_status", arr.N_PACE_STATUS);   //工程状态 1:工前准备,10:开工,20:完工,30:完工验收,40:决算审批,50:竣工验收
            paramDictionary.Add("s_town", arr.S_TOWN);                 //所属镇
            paramDictionary.Add("s_address", arr.S_ADDRESS);
            paramDictionary.Add("s_legal_person", arr.S_LEGAL_PERSON); //项目法人
            paramDictionary.Add("s_unit_design", arr.S_UNIT_DESIGN);   //设计单位
            paramDictionary.Add("s_unit_build", arr.S_UNIT_BUILD);
            paramDictionary.Add("s_unit_supervise", arr.S_UNIT_SUPERVISE);
            paramDictionary.Add("n_reckon_total_amt", arr.N_RECKON_TOTAL_AMT);
            paramDictionary.Add("s_remark", arr.S_REMARK);

            //批复工程量
            paramDictionary.Add("n_ggsl", arr.N_GGSL);     //灌区数量
            paramDictionary.Add("n_ggmj", arr.N_GGMJ);     //灌区面积
            paramDictionary.Add("n_bzzs", arr.N_BZZS);     //泵站座数
            paramDictionary.Add("n_bztt", arr.N_BZTT);     //泵站台套
            paramDictionary.Add("n_dxqd", arr.N_DXQD);     //地下渠道
            paramDictionary.Add("n_dc", arr.N_DC);         //渡槽
            paramDictionary.Add("n_dxh", arr.N_DXH);       //倒虹吸
            paramDictionary.Add("n_cqmq", arr.N_CQMQ);     //衬砌明渠
            paramDictionary.Add("n_xfjdl", arr.N_WCXFJDL); //新翻建道路

            //概算投资
            paramDictionary.Add("n_total_invest", arr.N_TOTAL_INVEST);         //总投资
            paramDictionary.Add("n_engin_cost", arr.N_ENGIN_COST);             //工程直接费
            paramDictionary.Add("n_independent_cost", arr.N_INDEPENDENT_COST); //独立费用
            paramDictionary.Add("n_prep_cost", arr.N_PREP_COST);               //预备费
            paramDictionary.Add("n_sight_cost", arr.N_SIGHT_COST);             //景观等费用
            //资金配套组成
            paramDictionary.Add("n_subsidy_city", arr.N_SUBSIDY_CITY);         //市补
            paramDictionary.Add("n_subsidy_district", arr.N_SUBSIDY_DISTRICT); //区配套
            paramDictionary.Add("n_subsidy_town", arr.N_SUBSIDY_TOWN);         //镇配套

            //完成工程量
            paramDictionary.Add("n_complete_ggsl", arr.N_WCGGSL);   //灌区数量
            paramDictionary.Add("n_complete_ggmj", arr.N_WCGGMJ);   //灌区面积
            paramDictionary.Add("n_complete_bzzs", arr.N_WCBZZS);   //泵站座数
            paramDictionary.Add("n_complete_bztt", arr.N_WCBZTT);   //泵站台套
            paramDictionary.Add("n_complete_dxqd", arr.N_WCDXQD);   //地下渠道
            paramDictionary.Add("n_complete_dc", arr.N_WCDC);       //渡槽
            paramDictionary.Add("n_complete_dxh", arr.N_WCDXH);     //倒虹吸
            paramDictionary.Add("n_complete_cqmq", arr.N_WCCQMQ);   //衬砌明渠
            paramDictionary.Add("n_complete_xfjdl", arr.N_WCXFJDL); //新翻建道路

            // paramDictionary.Add("remove_pic_ids", "3156467F238740B59C6650828698B2A2,BA4D7B0736564E05B51F181F9BB6F9B9");//删除的图片ID
            //paramDictionary.Add("is_delete", "0");//是否删除 1删除

            Dictionary <string, string> fileParams = new Dictionary <string, string>();
            fileParams.Add("picture_file", @"D:\timg (2).jpg");
            fileParams.Add("picture_file2", @"D:\Paul .jpg");
            fileParams.Add("picture_file3", @"D:\timg (1).jpg");
            fileParams.Add("picture_file4", @"D:\Paul .jpg");
            fileParams.Add("picture_file5", @"D:\timg (1).jpg");
            fileParams.Add("picture_file6", @"D:\Paul .jpg");
            fileParams.Add("picture_file7", @"D:\timg (1).jpg");
            #endregion

            // 调用接口
            string authorization = CookieHelper.GetData(Request, method, paramDictionary);
            return(Json(authorization));
        }
コード例 #12
0
ファイル: HomeController.cs プロジェクト: Mistrall/DreamPaWeb
 public RedirectResult SetLanguagePreference(string locale)
 {
     CookieHelper.SetCookie("DreamPaLang", "Locale", locale);
     return(Redirect(Request.UrlReferrer.ToString()));
 }
コード例 #13
0
    /// <summary>
    /// Handles the PreRender event of the Page control.
    /// </summary>
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (QueryHelper.Contains(SEARCH_TEXT_CODE))
        {
            // Get the search text from the current url
            txtSearch.Text = HttpUtility.UrlDecode(URLHelper.GetUrlParameter(RequestContext.CurrentURL, SEARCH_TEXT_CODE).Replace(SPACE_REPLACEMENT, " "));

            // Hide the scrollPanel when the search filter will be applied (skip this when changing displayed category)
            if (Request.Form[Page.postEventArgumentID] != CATEGORY_CHANGED_CODE)
            {
                scrollPanel.Style.Add("display", "none");
            }
        }

        // Add the javascript file and scripts into the page
        ScriptHelper.RegisterJQueryCookie(Page);
        ScriptHelper.RegisterScriptFile(Page, "DesignMode/WebPartToolbar.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-url.js");
        ScriptHelper.RegisterStartupScript(this, typeof(string), "wptPageScripts", ScriptHelper.GetScript(GetPageScripts() + @"
wptSetupSearch();
var WPTImgBaseSrc = '""" + ResolveUrl("~/CMSPages/GetMetaFile.aspx?maxsidesize=64&fileguid=") + @"';
"));

        // Adjust the page to accommodate the web part toolbar
        scrollPanel.Layout = RepeatDirection.Vertical;
        scrollPanel.IsRTL  = uiCultureRTL;

        // Set the selected category
        if (!RequestHelper.IsPostBack())
        {
            if (SelectedCategory == CATEGORY_ALL)
            {
                // Select the "All web parts" category by index (value for the "All" category is not known)
                categorySelector.DropDownListControl.SelectedIndex = 1;
            }
            else
            {
                categorySelector.DropDownListControl.SelectedValue = SelectedCategory;
            }
        }
        else
        {
            SelectedCategory = categorySelector.DropDownListControl.SelectedValue;

            // Refresh scroll panel
            ScriptHelper.RegisterClientScriptBlock(pnlU, typeof(string), "wptRefreshScrollPanel", "$cmsj(document).ready(function () { wptInit(true); wptReloadScrollPanel(true); wptLoadWebpartImages(); });", true);
        }

        // Load the web part items according to the selected category and the search text condition
        LoadWebParts(false);

        // Register script for web part lazy load
        if (limitItems)
        {
            const string appearScript = @"
            $cmsj(document).ready(
            function () {
                $cmsj('.AppearElement').appear(
                    function () {
                        $cmsj(this).html(wpLoadingMoreString); 
                        DoToolbarPostBack(); 
                     });
            });";

            string postBackScript = @"
            function DoToolbarPostBack(){
                " + ControlsHelper.GetPostBackEventReference(btnLoadMore, "") + @"
            };";

            ScriptHelper.RegisterStartupScript(Page, typeof(string), "DoToolbarPostback", ScriptHelper.GetScript(appearScript + postBackScript));
        }

        bool isMinimized = ValidationHelper.GetBoolean(CookieHelper.GetValue(CookieName.WebPartToolbarMinimized), false);

        if (isMinimized)
        {
            // Renew the cookie
            CookieHelper.SetValue(CookieName.WebPartToolbarMinimized, "true", "/", DateTime.Now.AddDays(31), false);

            // Hide the expanded web part toolbar
            pnlMaximized.Style.Add("display", "none");
        }
        else
        {
            // Register the OnLoad javascript for the expanded bar
            ltrScript.Text = ScriptHelper.GetScript("function pageLoad(sender, args) { wptInit(true); }");

            // Hide the minimized toolbar
            pnlMinimized.Style.Add("display", "none");
        }

        ScriptHelper.RegisterJQueryAppear(Page);
    }
コード例 #14
0
 public static void Logout()
 {
     CookieHelper cookie = new CookieHelper();
     cookie.DeleteCookie(cookieName);
     FormsAuthentication.SignOut();
 }
コード例 #15
0
ファイル: LoginService.cs プロジェクト: daydream163/ktproject
 private void ClearCookies()
 {
     CookieHelper.ClearCookie(Constants.TOKEN);
 }
コード例 #16
0
        public ActionResult SaveQuick(CartViewModel.CartForm form)
        {
            if (!ModelState.IsValid)
            {
                Menu menu = _menuRepository.Get(o => o.id_ == form.ProductId);
                return(RedirectToRoute("ChiTietSanPham", new { splink = menu.Link }));
            }
            IList <CartViewModel.ProductCart> productCarts = new List <CartViewModel.ProductCart>();

            #region cart
            CookieHelper cookieHelper = new CookieHelper("Cart");

            if (cookieHelper.GetCookie() != null)
            {
                string json = HttpUtility.UrlDecode(cookieHelper.GetCookie().Values["Cart"]);
                productCarts = JsonConvert.DeserializeObject <List <CartViewModel.ProductCart> >(json);
            }
            //neu trung id va ma vach thi cong thêm số lượng, ngược lại thì mới add cookie
            bool exist = productCarts.Any(o => o.ProductId == form.ProductId && o.Barcode.Equals(form.Barcode));
            if (exist)
            {
                foreach (var p in productCarts)
                {
                    if (p.ProductId == form.ProductId && p.Barcode.Equals(form.Barcode))
                    {
                        p.Quantity += 1;
                        break;
                    }
                }
            }
            else
            {
                productCarts.Add(new CartViewModel.ProductCart()
                {
                    ProductId = form.ProductId,
                    Barcode   = form.Barcode,
                    Quantity  = 1
                });
            }
            string jsonString = JsonConvert.SerializeObject(productCarts);
            cookieHelper.SetCartCookie(jsonString);
            #endregion

            #region items
            // PromotionMapping.PromotionCheck promotion = _promotionRepository.GetCurrentPromotion();
            IList <PromotionMapping.PromotionCheckProduct>  promotions       = _promotionRepository.GetActives();
            IList <ProductFrontPageMapping.ProductShowCart> productShowCarts =
                _menuRepository.GetProductShowCartByBarcode(productCarts.Select(o => o.Barcode).ToList());

            if (!productShowCarts.Any())
            {
                return(RedirectToRoute("Cart"));
            }
            IList <string> ghiChuQT = new List <string>();
            IList <CartViewModel.CartItem> cartItems = new List <CartViewModel.CartItem>();
            if (productCarts.Any())
            {
                foreach (var o in productCarts)
                {
                    var item = productShowCarts.FirstOrDefault(p => p.Barcode.Equals(o.Barcode));
                    if (item == null)
                    {
                        return(RedirectToRoute("Cart"));
                    }

                    #region insert sản phẩm quà tặng

                    var quatang = _khoQuaTangRepository.Get(p => p.IdMenu == o.ProductId);
                    if (quatang != null)
                    {
                        int idQT      = Convert.ToInt32(quatang.IdSanPhamTang);
                        var barcodeqt = _menuOptionRepository.Get(p => p.IdMenu == idQT);

                        var productquatang  = _menuRepository.Get(p => p.id_ == idQT);
                        var cartItemquatang = new CartViewModel.CartItem()
                        {
                            ProductId      = productquatang.id_,
                            Name           = productquatang.NameProduct,
                            Image          = productquatang.Img,
                            Price          = productquatang.PricePro.HasValue ? productquatang.PricePro.Value : 0,
                            PricePromotion = productquatang.PricePro.HasValue ? productquatang.PricePro.Value : 0,
                            Barcode        = barcodeqt != null ? barcodeqt.Barcode : "",
                            Quantity       = 1,
                            AttributeImg   = "",
                            AttributeName  = "",
                            AttributeFlag  = 1,
                            Iquatang       = true
                        };
                        ghiChuQT.Add(productquatang.NameProduct);
                        cartItems.Add(cartItemquatang);
                    }

                    #endregion
                    var cartItem = new CartViewModel.CartItem()
                    {
                        ProductId      = o.ProductId,
                        Name           = item.NameProduct,
                        Image          = item.Img,
                        Price          = item.Price,
                        PricePromotion = item.Price,
                        Barcode        = o.Barcode,
                        Quantity       = o.Quantity,
                        AttributeImg   = item.AttributeImg,
                        AttributeName  = item.AttributeName,
                        AttributeFlag  = item.AttributeFlag
                    };

                    #region check promotion
                    if (promotions.Any())
                    {
                        foreach (var pr in promotions)
                        {
                            var promotionDetail = pr.PromotionDetails.FirstOrDefault(dt => dt.ProductId == cartItem.ProductId);
                            if (promotionDetail != null)
                            {
                                cartItem.HasPromotion   = true;
                                cartItem.PricePromotion = (int)promotionDetail.PriceDiscount;
                                cartItem.Discount       = (short)promotionDetail.Percent;
                                break;
                            }
                        }
                    }

                    #endregion
                    cartItems.Add(cartItem);
                }
            }
            #endregion

            #region Insert DetailMenuComment
            DetailMenuComment order = new DetailMenuComment()
            {
                id_Menu        = 9999,
                idBrand        = form.BrandId,
                Name           = form.Name,
                Link           = form.Phone.Trim().TrimEnd().TrimStart(),
                Code           = "Đặt hàng từ Website",
                Content        = form.Note + (ghiChuQT.Any() ? "<span style=\"color: red;font-weight: bold;\"> - Quà tặng</span> " + string.Join(",", ghiChuQT) : ""),
                HuongDanSuDung = form.Email,
                GiaoHang       = form.Address,
                sDate          = DateTime.Now,
                sDateOk        = DateTime.Now
            };
            _detailMenuCommentRepository.Add(order);

            #endregion

            IList <string> str = new List <string>();

            IList <KHLHProduct> khlhProducts = new List <KHLHProduct>();

            #region Insert DetailMenuCommentItem

            foreach (var dt in cartItems)
            {
                DetailMenuCommentItem detail = new DetailMenuCommentItem()
                {
                    id_Menu = order.id_,
                    Name    = dt.Name,
                    Link    = dt.ProductId + "",
                    Price   = dt.Price + "",
                    PriceOf = dt.PricePromotion + "",
                    Content = string.Format("Mã đơn hàng<#{0}#>", order.id_),
                    Number  = dt.Quantity,
                    BarCode = dt.Barcode,
                    sDate   = DateTime.Now,
                    sDateOk = DateTime.Now,
                    Img     = dt.Image
                };
                _detailMenuCommentItemRepository.Add(detail);

                if (!dt.Iquatang)
                {
                    str.Add(string.Format("{0}({1})", dt.Barcode, dt.Quantity));
                }

                khlhProducts.Add(new KHLHProduct()
                {
                    Code      = detail.BarCode,
                    GiaWeb    = int.Parse(detail.PriceOf),
                    NgayTao   = detail.sDate,
                    SL        = dt.Quantity,
                    LinkImage = "https://beautygarden.vn/Upload/Files/" + dt.Image,
                    Quatang   = dt.Iquatang
                });
            }
            #endregion

            #region insert KH_LH
            string dh = string.Format("{0}#,{1}", order.id_, string.Join(",", str));

            string sql =
                string.Format(
                    "INSERT INTO [bg.hvnet.vn].dbo.KH_LH (NguoiNhap,Nguon,Ten,Phone,DiaChi,GhiChu,idTinh,TrangThai,DonHang,idShop) values (" +
                    " '{0}',{1},N'{2}','{3}',N'{4}',N'{5}',{6},{7},'{8}',{9} " +
                    ")", "system", 1,
                    order.Name,
                    order.Link,
                    order.GiaoHang,
                    //string.Format("Mã đơn hàng<#{0}#>", order.id_),
                    order.Content,
                    1,
                    0,
                    dh,
                    order.idBrand
                    );

            int id = _detailMenuCommentRepository.InsertIntoKHLH(sql, order.Link);


            #endregion

            #region Insert KH_LH_product
            if (khlhProducts.Any() && id != 0)
            {
                foreach (var khlhProduct in khlhProducts)
                {
                    khlhProduct.IdKH = id;
                }
                _detailMenuCommentRepository.InsertKHLHProduct(khlhProducts);
            }

            #endregion

            _unitOfWork.Commit();
            //sau khi thanh toán thành công thì clear cookie
            cookieHelper.ClearCookie();
            //cookieHelperform.ClearCookie();

            CookieHelper cookieInfo = new CookieHelper("User_Infor");

            string jsonStringinfo = JsonConvert.SerializeObject(new LienHeModel()
            {
                GiaoHang       = form.Address,
                HuongDanSuDung = form.Email,
                Link           = form.Phone,
                Name           = form.Name
            });
            cookieInfo.SetUserInforCookie(jsonStringinfo);

            return(RedirectToRoute("OrderSuccess", new { id = order.id_ }));
        }
コード例 #17
0
ファイル: UserSendController.cs プロジェクト: fjwgrace/MLRMS
        public ActionResult Index()
        {
            string name, error;

            if (CookieHelper.HasCookie(out name, out error) == false)
            {
                return(RedirectToAction("", "LoginUI"));
            }
            else
            {
                new RoleHelper().GetRoles(name, out role, out department1Code, out LoginName);
                ViewData["VisitorRole"] = role;
                ViewData["username"]    = LoginName;
            }
            List <CompanyItem>  unBindItemList   = new List <CompanyItem>();
            List <CompanyItem>  bindItemList     = new List <CompanyItem>();
            List <ClientDevice> deviceList       = new List <ClientDevice>();
            List <CompanyItem>  bindResultList   = new List <CompanyItem>();
            List <CompanyItem>  unBindResultList = new List <CompanyItem>();

            try
            {
                using (BemEntities db = new BemEntities())
                {
                    deviceList          = db.clientdevice.ToList();
                    ViewData["devList"] = deviceList;

                    //var companyList = from emp in db.employee
                    //                  join rel in db.deviceemployeerelation
                    //                  on emp.EmpCode equals rel.EmpCode into dc
                    //                  from dci in dc.DefaultIfEmpty()
                    //                  group dci by new { emp.EmpGroupCode, emp.EmpGroupName, emp.EmpCode, emp.EmpName, dci.DevCode } into g
                    //                  select new { grpName = g.Key.EmpGroupName, grpCode = g.Key.EmpGroupCode, empName = g.Key.EmpName, empCode = g.Key.EmpCode, devCode = g.Key.DevCode };
                    var unbindList = from item in (from emp in db.employee
                                                   join rel in db.deviceemployeerelation
                                                   on emp.EmpCode equals rel.EmpCode into dc
                                                   from dci in dc.DefaultIfEmpty()
                                                   where string.IsNullOrEmpty(dci.DevCode) == true
                                                   select new { emp.EmpCode, emp.EmpName, emp.EmpGroupCode, emp.EmpGroupName })
                                     group item by new { item.EmpGroupCode, item.EmpGroupName } into g
                    select g;

                    var bindlist = from item in (from emp in db.employee
                                                 join rel in db.deviceemployeerelation
                                                 on emp.EmpCode equals rel.EmpCode into dc
                                                 from dci in dc.DefaultIfEmpty()
                                                 where string.IsNullOrEmpty(dci.DevCode) == false
                                                 select new { emp.EmpCode, emp.EmpName, emp.EmpGroupCode, emp.EmpGroupName })
                                   group item by new { item.EmpGroupCode, item.EmpGroupName } into g
                    select g;
                    foreach (var item in unbindList)
                    {
                        CompanyItem item1 = new CompanyItem();
                        item1.CompanyCode = item.Key.EmpGroupCode;
                        item1.CompanyName = item.Key.EmpGroupName;
                        item1.subList     = new List <Employee>();
                        foreach (var subItem in item)
                        {
                            item1.subList.Add(new Employee()
                            {
                                EmpCode = subItem.EmpCode, EmpName = subItem.EmpName
                            });
                        }
                        unBindItemList.Add(item1);
                    }
                    foreach (var item in bindlist)
                    {
                        CompanyItem item1 = new CompanyItem();
                        item1.CompanyCode = item.Key.EmpGroupCode;
                        item1.CompanyName = item.Key.EmpGroupName;
                        item1.subList     = new List <Employee>();
                        foreach (var subItem in item)
                        {
                            if (item1.subList.Where(m => m.EmpCode == subItem.EmpCode).Count() <= 0)
                            {
                                item1.subList.Add(new Employee()
                                {
                                    EmpCode = subItem.EmpCode, EmpName = subItem.EmpName
                                });
                            }
                        }
                        bindItemList.Add(item1);
                    }
                    //foreach (var company in result)
                    //{
                    //    CompanyItem item1 = new CompanyItem();
                    //    item1.CompanyCode = company.Key.grpCode;
                    //    item1.CompanyName = company.Key.grpName;
                    //    item1.subList = new List<Employee>();

                    //    CompanyItem item2 = new CompanyItem();
                    //    item2.CompanyCode = company.Key.grpCode;
                    //    item2.CompanyName = company.Key.grpName;
                    //    item2.subList = new List<Employee>();
                    //    foreach (var emp in company)
                    //    {
                    //        if (string.IsNullOrEmpty(emp.devCode))
                    //        {
                    //            item1.subList.Add(new Employee() { EmpCode = emp.empCode, EmpName = emp.empName });
                    //        }
                    //        else
                    //        {
                    //            if (item2.subList.Where(m => m.EmpCode == emp.empCode).Count() <= 0)
                    //            {
                    //                item2.subList.Add(new Employee() { EmpCode = emp.empCode, EmpName = emp.empName });
                    //            }
                    //        }
                    //    }

                    //    unBindItemList.Add(item1);
                    //    bindItemList.Add(item2);
                    //}

                    foreach (var item in unBindItemList)
                    {
                        if (item.subList.Count > 0)
                        {
                            unBindResultList.Add(item);
                        }
                    }
                    foreach (var item in bindItemList)
                    {
                        if (item.subList.Count > 0)
                        {
                            bindResultList.Add(item);
                        }
                    }
                    ViewData["notBindList"] = unBindResultList;
                    ViewData["bindList"]    = bindResultList;
                    return(View());
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("设备下发获取部门信息失败", ex);
            }
            return(View());
        }
コード例 #18
0
ファイル: WebHelper.cs プロジェクト: absdk/RslSDK
 public WebHelper()
 {
     _cookie = new CookieHelper();
     _request = HttpContext.Current.Request;
     _response = HttpContext.Current.Response;
 }
コード例 #19
0
    private void Login1_LoggedIn(object sender, EventArgs e)
    {
        // ScreenLock - unlock screen
        IsScreenLocked = false;

        // Ensure response cookie
        CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName);

        // Set cookie expiration
        if (Login1.RememberMeSet)
        {
            CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddYears(1), false);
        }
        else
        {
            // Extend the expiration of the authentication cookie if required
            if (!AuthenticationHelper.UseSessionCookies && (HttpContext.Current != null) && (HttpContext.Current.Session != null))
            {
                CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(Session.Timeout), false);
            }
        }

        // Current username
        string userName = Login1.UserName;

        // Get info on the authenticated user
        UserInfo ui       = UserInfoProvider.GetUserInfoForSitePrefix(userName, SiteContext.CurrentSite);
        String   siteName = SiteContext.CurrentSiteName;

        // For site prefix user, authenticate manually
        if (ui != null)
        {
            if (UserInfoProvider.UserNameSitePrefixEnabled(siteName) && UserInfoProvider.IsSitePrefixedUser(ui.UserName))
            {
                AuthenticationHelper.AuthenticateUser(ui.UserName, Login1.RememberMeSet);
            }
        }
        // Check whether safe user name is required and if so get safe username
        else if (RequestHelper.IsMixedAuthentication() && UserInfoProvider.UseSafeUserName)
        {
            userName = ValidationHelper.GetSafeUserName(userName, SiteContext.CurrentSiteName);

            if (UserInfoProvider.UserNameSitePrefixEnabled(siteName))
            {
                // Check for site prefix
                ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, SiteContext.CurrentSite);
                if (ui != null)
                {
                    userName = ui.UserName;
                }
            }

            AuthenticationHelper.AuthenticateUser(userName, Login1.RememberMeSet);
        }

        // Set culture
        CMSDropDownList drpCulture = (CMSDropDownList)Login1.FindControl("drpCulture");

        if (drpCulture != null)
        {
            string selectedCulture = drpCulture.SelectedValue;

            // Not the default culture
            if (selectedCulture != "")
            {
                // Update the user
                if (ui != null)
                {
                    ui.PreferredUICultureCode = selectedCulture;
                    UserInfoProvider.SetUserInfo(ui);
                }

                // Update current user
                MembershipContext.AuthenticatedUser.PreferredUICultureCode = selectedCulture;
            }
        }

        URLHelper.LocalRedirect(ReturnUrl);
    }
コード例 #20
0
        public void DeleteUserIdamDataCookie(HttpContext context)
        {
            var cookie = new CookieHelper(Settings.UserDataCookieName, context);

            cookie.Delete();
        }
コード例 #21
0
    /// <summary>
    /// Logged in handler.
    /// </summary>
    private void Login1_LoggedIn(object sender, EventArgs e)
    {
        // Set view mode to live site after login to prevent bar with "Close preview mode"
        PortalContext.ViewMode = ViewModeEnum.LiveSite;

        // Ensure response cookie
        CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName);

        // Set cookie expiration
        if (Login1.RememberMeSet)
        {
            CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddYears(1), false);
        }
        else
        {
            // Extend the expiration of the authentication cookie if required
            if (!AuthenticationHelper.UseSessionCookies && (HttpContext.Current != null) && (HttpContext.Current.Session != null))
            {
                CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(Session.Timeout), false);
            }
        }

        // Current username
        string userName = Login1.UserName;

        // Get user name (test site prefix too)
        UserInfo ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, SiteContext.CurrentSite);

        // Check whether safe user name is required and if so get safe username
        if (RequestHelper.IsMixedAuthentication() && UserInfoProvider.UseSafeUserName)
        {
            // Get info on the authenticated user
            if (ui == null)
            {
                // User stored with safe name
                userName = ValidationHelper.GetSafeUserName(Login1.UserName, SiteContext.CurrentSiteName);

                // Find user by safe name
                ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, SiteContext.CurrentSite);
                if (ui != null)
                {
                    // Authenticate user by site or global safe username
                    AuthenticationHelper.AuthenticateUser(ui.UserName, Login1.RememberMeSet);
                }
            }
        }

        if (ui != null)
        {
            // If user name is site prefixed, authenticate user manually
            if (UserInfoProvider.IsSitePrefixedUser(ui.UserName))
            {
                AuthenticationHelper.AuthenticateUser(ui.UserName, Login1.RememberMeSet);
            }

            // Log activity
            int      contactID     = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
            Activity activityLogin = new ActivityUserLogin(contactID, ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables);
            activityLogin.Log();
        }

        // Redirect user to the return URL, or if is not defined redirect to the default target URL
        var    redirectUrl = RequestContext.CurrentURL;
        string url         = ResolveUrl(QueryHelper.GetString("ReturnURL", String.Empty));
        string hash        = QueryHelper.GetString("hash", String.Empty);

        if (!String.IsNullOrEmpty(url))
        {
            if (URLHelper.IsLocalUrl(url, RequestContext.CurrentDomain))
            {
                redirectUrl = url;
            }
            else if (!String.IsNullOrEmpty(hash))
            {
                if (QueryHelper.ValidateHash("hash", "aliaspath"))
                {
                    redirectUrl = url;
                }
                else
                {
                    redirectUrl = UIHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext");
                }
            }
        }
        else if (!String.IsNullOrEmpty(DefaultTargetUrl))
        {
            redirectUrl = ResolveUrl(DefaultTargetUrl);
        }

        URLHelper.Redirect(redirectUrl);
    }
コード例 #22
0
        public JsonResult UpdateProjectData(string param, string drawingFiles, string pictureFiles)
        {
            //转成实体对象
            BackboneRiverwayInfo Arr = new BackboneRiverwayInfo();

            Arr = JsonHelper.JSONToObject <BackboneRiverwayInfo>(param);

            // 接口
            string method = "wavenet.fxsw.engin.core.update";

            // 接口所需传递的参数
            #region
            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();
            paramDictionary.Add("s_id", Arr.s_id); //id
            paramDictionary.Add("s_name", Arr.s_name);
            paramDictionary.Add("s_project_no", Arr.s_project_no);
            paramDictionary.Add("n_year", Arr.n_year);                 //年度
            paramDictionary.Add("n_pace_status", Arr.n_pace_status);   //工程状态 1:工前准备,10:开工,20:完工,30:完工验收,40:决算审批,50:竣工验收,60:工程完结
            paramDictionary.Add("s_town", Arr.s_town);                 //所属镇
            paramDictionary.Add("s_address", Arr.s_address);           //项目法人s_legal_person
            paramDictionary.Add("s_legal_person", Arr.s_legal_person); //工程地址
            paramDictionary.Add("s_unit_design", Arr.s_unit_design);   //设计单位
            paramDictionary.Add("s_unit_build", Arr.s_unit_build);
            paramDictionary.Add("s_unit_supervise", Arr.s_unit_supervise);
            paramDictionary.Add("n_reckon_total_amt", Arr.n_reckon_total_amt); //估计总投资
            paramDictionary.Add("n_water_area", Arr.n_water_area);             //新增水面积
            paramDictionary.Add("n_draft", Arr.n_draft);                       //是否有草图 1.有 0.没有
            paramDictionary.Add("s_remark", Arr.s_remark);

            //批复工程量
            paramDictionary.Add("n_length", Arr.n_length);                     //长度
            paramDictionary.Add("n_land_area", Arr.n_land_area);               //土方
            paramDictionary.Add("n_protect_hard", Arr.n_protect_hard);         //硬质护岸
            paramDictionary.Add("n_protect_ecology", Arr.n_protect_ecology);   //生态护岸
            paramDictionary.Add("n_bridge", Arr.n_bridge);                     //桥梁
            paramDictionary.Add("n_plant_bank", Arr.n_plant_bank);             //岸域绿化
            paramDictionary.Add("n_plant_slope", Arr.n_plant_slope);           //斜坡绿化
            paramDictionary.Add("n_plant_depth", Arr.n_plant_depth);           //水深绿化
            paramDictionary.Add("n_river_count", Arr.n_river_count);           //条段
            //概算投资
            paramDictionary.Add("n_total_invest", Arr.n_total_invest);         //总投资
            paramDictionary.Add("n_engin_cost", Arr.n_engin_cost);             //工程直接费
            paramDictionary.Add("n_independent_cost", Arr.n_independent_cost); //独立费用
            paramDictionary.Add("n_prep_cost", Arr.n_prep_cost);               //预备费
            paramDictionary.Add("n_sight_cost", Arr.n_sight_cost);             //景观等费用
            paramDictionary.Add("n_empty_area", Arr.n_empty_area);             //腾地面积
            paramDictionary.Add("n_build_cost", Arr.n_build_cost);             //建设用地费
            //资金配套组成
            paramDictionary.Add("n_subsidy_city", Arr.n_subsidy_city);         //市补
            paramDictionary.Add("n_subsidy_district", Arr.n_subsidy_district); //区配套
            paramDictionary.Add("n_subsidy_town", Arr.n_subsidy_town);         //镇配套

            //完成工程量
            paramDictionary.Add("n_complete_length", Arr.n_complete_length);                   //长度
            paramDictionary.Add("n_complete_land_area", Arr.n_complete_land_area);             //土方
            paramDictionary.Add("n_complete_protect_hard", Arr.n_complete_protect_hard);       //硬质护岸
            paramDictionary.Add("n_complete_protect_ecology", Arr.n_complete_protect_ecology); //生态护岸
            paramDictionary.Add("n_complete_bridge", Arr.n_complete_bridge);                   //桥梁
            paramDictionary.Add("n_complete_plant_bank", Arr.n_complete_plant_bank);           //岸域绿化
            paramDictionary.Add("n_complete_plant_slope", Arr.n_complete_plant_slope);         //斜坡绿化
            paramDictionary.Add("n_complete_plant_depth", Arr.n_complete_plant_depth);         //水深绿化
            paramDictionary.Add("n_complete_river_count", Arr.n_complete_river_count);         //条段

            paramDictionary.Add("is_delete", "0");                                             //是否删除 1删除
            paramDictionary.Add("remove_pic_ids", Arr.remove_pic_ids);
            #endregion
            //文件路径
            string path = Request.ApplicationPath;
            path = Server.MapPath(path += "/upload/");

            Dictionary <string, string> fileParams = new Dictionary <string, string>();
            if (!string.IsNullOrEmpty(drawingFiles))
            {
                //文件类型picture_file1 drawing_file1 sketch_file
                string[] Files = drawingFiles.Split(',');
                for (int i = 0; i < Files.Length - 1; i++)
                {
                    fileParams.Add("drawing_file" + (i + 1), path + Files[i]);
                }
            }
            if (!string.IsNullOrEmpty(pictureFiles))
            {
                //文件类型picture_file1 drawing_file1 sketch_file
                string[] Files = pictureFiles.Split(',');

                for (int i = 0; i < Files.Length - 1; i++)
                {
                    fileParams.Add("picture_file" + (i + 1), path + Files[i]);
                }
            }
            // 调用接口
            string authorization = CookieHelper.GetData(Request, method, paramDictionary, fileParams);
            return(Json(authorization));
        }
コード例 #23
0
        public JsonResult UpdateProjectStatus(string param)
        {
            //转成实体对象
            BackboneRiverwayInfo Arr = new BackboneRiverwayInfo();

            Arr = JsonHelper.JSONToObject <BackboneRiverwayInfo>(param);

            // 接口
            string method = "wavenet.fxsw.engin.core.update";

            // 接口所需传递的参数
            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();

            paramDictionary.Add("s_id", Arr.s_id); //id
            paramDictionary.Add("s_name", Arr.s_name);
            paramDictionary.Add("s_project_no", Arr.s_project_no);
            paramDictionary.Add("n_year", Arr.n_year);               //年度
            paramDictionary.Add("n_pace_status", Arr.n_pace_status); //工程状态 1:工前准备,10:开工,20:完工,30:完工验收,40:决算审批,50:竣工验收,60:工程完结
            paramDictionary.Add("s_town", Arr.s_town);               //所属镇
            paramDictionary.Add("s_address", Arr.s_address);         //项目法人
            paramDictionary.Add("s_legal_person", Arr.s_legal_person);
            paramDictionary.Add("s_unit_design", Arr.s_unit_design); //设计单位
            paramDictionary.Add("s_unit_build", Arr.s_unit_build);
            paramDictionary.Add("s_unit_supervise", Arr.s_unit_supervise);
            paramDictionary.Add("n_reckon_total_amt", Arr.n_reckon_total_amt); //估计总投资
            paramDictionary.Add("n_water_area", Arr.n_water_area);             //新增水面积
            paramDictionary.Add("n_draft", Arr.n_draft);                       //是否有草图 1.有 0.没有
            paramDictionary.Add("s_remark", Arr.s_remark);

            //批复工程量
            paramDictionary.Add("n_length", Arr.n_length);                     //长度
            paramDictionary.Add("n_land_area", Arr.n_land_area);               //土方
            paramDictionary.Add("n_protect_hard", Arr.n_protect_hard);         //硬质护岸
            paramDictionary.Add("n_protect_ecology", Arr.n_protect_ecology);   //生态护岸
            paramDictionary.Add("n_bridge", Arr.n_bridge);                     //桥梁
            paramDictionary.Add("n_plant_bank", Arr.n_plant_bank);             //岸域绿化
            paramDictionary.Add("n_plant_slope", Arr.n_plant_slope);           //斜坡绿化
            paramDictionary.Add("n_plant_depth", Arr.n_plant_depth);           //水深绿化
            paramDictionary.Add("n_river_count", Arr.n_river_count);           //条段
            //概算投资
            paramDictionary.Add("n_total_invest", Arr.n_total_invest);         //总投资
            paramDictionary.Add("n_engin_cost", Arr.n_engin_cost);             //工程直接费
            paramDictionary.Add("n_independent_cost", Arr.n_independent_cost); //独立费用
            paramDictionary.Add("n_prep_cost", Arr.n_prep_cost);               //预备费
            paramDictionary.Add("n_sight_cost", Arr.n_sight_cost);             //景观等费用
            paramDictionary.Add("n_empty_area", Arr.n_empty_area);             //腾地面积
            paramDictionary.Add("n_build_cost", Arr.n_build_cost);             //建设用地费
            //资金配套组成
            paramDictionary.Add("n_subsidy_city", Arr.n_subsidy_city);         //市补
            paramDictionary.Add("n_subsidy_district", Arr.n_subsidy_district); //区配套
            paramDictionary.Add("n_subsidy_town", Arr.n_subsidy_town);         //镇配套

            //完成工程量
            paramDictionary.Add("n_complete_length", Arr.n_complete_length);                   //长度
            paramDictionary.Add("n_complete_land_area", Arr.n_complete_land_area);             //土方
            paramDictionary.Add("n_complete_protect_hard", Arr.n_complete_protect_hard);       //硬质护岸
            paramDictionary.Add("n_complete_protect_ecology", Arr.n_complete_protect_ecology); //生态护岸
            paramDictionary.Add("n_complete_bridge", Arr.n_complete_bridge);                   //桥梁
            paramDictionary.Add("n_complete_plant_bank", Arr.n_complete_plant_bank);           //岸域绿化
            paramDictionary.Add("n_complete_plant_slope", Arr.n_complete_plant_slope);         //斜坡绿化
            paramDictionary.Add("n_complete_plant_depth", Arr.n_complete_plant_depth);         //水深绿化
            paramDictionary.Add("n_complete_river_count", Arr.n_complete_river_count);         //条段

            paramDictionary.Add("remove_pic_ids", "");
            paramDictionary.Add("is_delete", "0");//是否删除 1删除

            // 调用接口
            string authorization = CookieHelper.GetData(Request, method, paramDictionary);

            return(Json(authorization));
        }
コード例 #24
0
        /// <summary>
        /// 设置公测cookie
        /// </summary>
        /// <returns></returns>
        public static void SetOpenBetaCookie(string invitationCode)
        {
            string value = string.Format("{0}_{1}", invitationCode, (invitationCode + betaCookieKey).ConvertToMd5());

            CookieHelper.SetCookie(betaCookieName, value, "M", 2, true, "bailun.com");
        }
コード例 #25
0
    /// <summary>
    /// Process valid values of this step.
    /// </summary>
    public override bool ProcessStep()
    {
        if (plcAccount.Visible)
        {
            string siteName = SiteContext.CurrentSiteName;

            // Existing account
            if (radSignIn.Checked)
            {
                // Authenticate user
                UserInfo ui = AuthenticationHelper.AuthenticateUser(txtUsername.Text.Trim(), txtPsswd1.Text, SiteContext.CurrentSiteName, false);
                if (ui == null)
                {
                    lblError.Text    = GetString("ShoppingCartCheckRegistration.LoginFailed");
                    lblError.Visible = true;
                    return(false);
                }

                // Sign in customer with existing account
                AuthenticationHelper.AuthenticateUser(ui.UserName, false);

                // Registered user has already started shopping as anonymous user -> Drop his stored shopping cart
                ShoppingCartInfoProvider.DeleteShoppingCartInfo(ui.UserID, siteName);

                // Assign current user to the current shopping cart
                ShoppingCart.User = ui;

                // Save changes to database
                if (!ShoppingCartControl.IsInternalOrder)
                {
                    ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
                }

                // Log "login" activity
                MembershipActivityLogger.LogLogin(ui.UserName, DocumentContext.CurrentDocument);

                LoadStep(true);

                // Return false to get to Edit customer page
                return(false);
            }
            // New registration
            else if (radNewReg.Checked)
            {
                txtEmail2.Text             = txtEmail2.Text.Trim();
                pnlCompanyAccount1.Visible = chkCorporateBody.Checked;

                string[] siteList = { siteName };

                // If AssignToSites field set
                if (!String.IsNullOrEmpty(ShoppingCartControl.AssignToSites))
                {
                    siteList = ShoppingCartControl.AssignToSites.Split(';');
                }

                // Check if user exists
                UserInfo ui = UserInfoProvider.GetUserInfo(txtEmail2.Text);
                if (ui != null)
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("ShoppingCartUserRegistration.ErrorUserExists");
                    return(false);
                }

                // Check all sites where user will be assigned
                if (!UserInfoProvider.IsEmailUnique(txtEmail2.Text.Trim(), siteList, 0))
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("UserInfo.EmailAlreadyExist");
                    return(false);
                }

                // Create new customer and user account and sign in
                // User
                ui           = new UserInfo();
                ui.UserName  = txtEmail2.Text.Trim();
                ui.Email     = txtEmail2.Text.Trim();
                ui.FirstName = txtFirstName1.Text.Trim();
                ui.LastName  = txtLastName1.Text.Trim();
                ui.FullName  = ui.FirstName + " " + ui.LastName;
                ui.Enabled   = true;
                ui.SiteIndependentPrivilegeLevel = UserPrivilegeLevelEnum.None;
                ui.UserURLReferrer = CookieHelper.GetValue(CookieName.UrlReferrer);
                ui.UserCampaign    = Service.Resolve <ICampaignService>().CampaignCode;
                ui.UserSettings.UserRegistrationInfo.IPAddress = RequestContext.UserHostAddress;
                ui.UserSettings.UserRegistrationInfo.Agent     = HttpContext.Current.Request.UserAgent;

                try
                {
                    UserInfoProvider.SetPassword(ui, passStrength.Text);

                    foreach (string site in siteList)
                    {
                        UserInfoProvider.AddUserToSite(ui.UserName, site);

                        // Add user to roles
                        if (ShoppingCartControl.AssignToRoles != "")
                        {
                            AssignUserToRoles(ui.UserName, ShoppingCartControl.AssignToRoles, site);
                        }
                    }

                    // Log registered user
                    AnalyticsHelper.LogRegisteredUser(siteName, ui);

                    MembershipActivityLogger.LogRegistration(ui.UserName, DocumentContext.CurrentDocument);
                }
                catch (Exception ex)
                {
                    lblError.Visible = true;
                    lblError.Text    = ex.Message;
                    return(false);
                }

                // Customer
                CustomerInfo ci = new CustomerInfo();
                ci.CustomerFirstName = txtFirstName1.Text.Trim();
                ci.CustomerLastName  = txtLastName1.Text.Trim();
                ci.CustomerEmail     = txtEmail2.Text.Trim();

                ci.CustomerCompany           = "";
                ci.CustomerOrganizationID    = "";
                ci.CustomerTaxRegistrationID = "";
                if (chkCorporateBody.Checked)
                {
                    ci.CustomerCompany = txtCompany1.Text.Trim();
                    if (mShowOrganizationIDField)
                    {
                        ci.CustomerOrganizationID = txtOrganizationID.Text.Trim();
                    }
                    if (mShowTaxRegistrationIDField)
                    {
                        ci.CustomerTaxRegistrationID = txtTaxRegistrationID.Text.Trim();
                    }
                }

                ci.CustomerUserID  = ui.UserID;
                ci.CustomerSiteID  = 0;
                ci.CustomerCreated = DateTime.Now;
                CustomerInfoProvider.SetCustomerInfo(ci);

                // Track successful registration conversion
                string name = ShoppingCartControl.RegistrationTrackConversionName;
                ECommerceHelper.TrackRegistrationConversion(ShoppingCart.SiteName, name);

                CreateContactRelation(ci);

                // Sign in
                if (ui.Enabled)
                {
                    AuthenticationHelper.AuthenticateUser(ui.UserName, false);
                    ShoppingCart.User = ui;

                    MembershipActivityLogger.LogLogin(ui.UserName, DocumentContext.CurrentDocument);
                }

                ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;

                // Send new registration notification email
                if (ShoppingCartControl.SendNewRegistrationNotificationToAddress != "")
                {
                    SendRegistrationNotification(ui);
                }
            }
            // Anonymous customer
            else if (radAnonymous.Checked)
            {
                CustomerInfo ci = null;
                if (ShoppingCart.ShoppingCartCustomerID > 0)
                {
                    // Update existing customer account
                    ci = CustomerInfoProvider.GetCustomerInfo(ShoppingCart.ShoppingCartCustomerID);
                }
                if (ci == null)
                {
                    // Create new customer account
                    ci = new CustomerInfo();
                }

                ci.CustomerFirstName = txtFirstName2.Text.Trim();
                ci.CustomerLastName  = txtLastName2.Text.Trim();
                ci.CustomerEmail     = txtEmail3.Text.Trim();

                ci.CustomerCompany           = "";
                ci.CustomerOrganizationID    = "";
                ci.CustomerTaxRegistrationID = "";

                if (chkCorporateBody2.Checked)
                {
                    ci.CustomerCompany = txtCompany2.Text.Trim();
                    if (mShowOrganizationIDField)
                    {
                        ci.CustomerOrganizationID = txtOrganizationID2.Text.Trim();
                    }
                    if (mShowTaxRegistrationIDField)
                    {
                        ci.CustomerTaxRegistrationID = txtTaxRegistrationID2.Text.Trim();
                    }
                }

                ci.CustomerCreated = DateTime.Now;
                ci.CustomerSiteID  = SiteContext.CurrentSiteID;
                CustomerInfoProvider.SetCustomerInfo(ci);

                CreateContactRelation(ci);

                // Assign customer to shoppingcart
                ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;
            }
            else
            {
                return(false);
            }
        }
        else
        {
            // Save the customer data
            bool         newCustomer = false;
            CustomerInfo ci          = CustomerInfoProvider.GetCustomerInfoByUserID(ShoppingCartControl.UserInfo.UserID);
            if (ci == null)
            {
                ci = new CustomerInfo();
                ci.CustomerUserID = ShoppingCartControl.UserInfo.UserID;
                ci.CustomerSiteID = 0;
                newCustomer       = true;
            }

            // Old email address
            string oldEmail = ci.CustomerEmail.ToLowerCSafe();

            ci.CustomerFirstName = txtEditFirst.Text.Trim();
            ci.CustomerLastName  = txtEditLast.Text.Trim();
            ci.CustomerEmail     = txtEditEmail.Text.Trim();

            pnlCompanyAccount2.Visible = chkEditCorpBody.Checked;

            ci.CustomerCompany           = "";
            ci.CustomerOrganizationID    = "";
            ci.CustomerTaxRegistrationID = "";
            if (chkEditCorpBody.Checked)
            {
                ci.CustomerCompany = txtEditCompany.Text.Trim();
                if (mShowOrganizationIDField)
                {
                    ci.CustomerOrganizationID = txtEditOrgID.Text.Trim();
                }
                if (mShowTaxRegistrationIDField)
                {
                    ci.CustomerTaxRegistrationID = txtEditTaxRegID.Text.Trim();
                }
            }

            // Update customer data
            CustomerInfoProvider.SetCustomerInfo(ci);

            // Update corresponding user email when required
            if (oldEmail != ci.CustomerEmail.ToLowerCSafe())
            {
                UserInfo user = UserInfoProvider.GetUserInfo(ci.CustomerUserID);
                if (user != null)
                {
                    user.Email = ci.CustomerEmail;
                    UserInfoProvider.SetUserInfo(user);
                }
            }

            if (newCustomer)
            {
                CreateContactRelation(ci);
            }

            // Set the shopping cart customer ID
            ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;
        }

        try
        {
            if (!ShoppingCartControl.IsInternalOrder)
            {
                ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
            }

            ShoppingCart.Evaluate();
            return(true);
        }
        catch
        {
            return(false);
        }
    }
コード例 #26
0
    /// <summary>
    /// Logged in handler.
    /// </summary>
    private void Login1_LoggedIn(object sender, EventArgs e)
    {
        // Set view mode to live site after login to prevent bar with "Close preview mode"
        PortalContext.ViewMode = ViewModeEnum.LiveSite;

        // Ensure response cookie
        CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName);

        // Set cookie expiration
        if (Login1.RememberMeSet)
        {
            CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddYears(1), false);
        }
        else
        {
            // Extend the expiration of the authentication cookie if required
            if (!AuthenticationHelper.UseSessionCookies && (HttpContext.Current != null) && (HttpContext.Current.Session != null))
            {
                CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(Session.Timeout), false);
            }
        }

        // Current username
        string userName = Login1.UserName;

        // Get user name (test site prefix too)
        UserInfo ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, SiteContext.CurrentSite);

        // Check whether safe user name is required and if so get safe username
        if (RequestHelper.IsMixedAuthentication() && UserInfoProvider.UseSafeUserName)
        {
            // Get info on the authenticated user
            if (ui == null)
            {
                // User stored with safe name
                userName = ValidationHelper.GetSafeUserName(Login1.UserName, SiteContext.CurrentSiteName);

                // Find user by safe name
                ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, SiteContext.CurrentSite);
                if (ui != null)
                {
                    // Authenticate user by site or global safe username
                    AuthenticationHelper.AuthenticateUser(ui.UserName, Login1.RememberMeSet);
                }
            }
        }

        if (ui != null)
        {
            // If user name is site prefixed, authenticate user manually
            if (UserInfoProvider.IsSitePrefixedUser(ui.UserName))
            {
                AuthenticationHelper.AuthenticateUser(ui.UserName, Login1.RememberMeSet);
            }

            // Log activity
            MembershipActivityLogger.LogLogin(ui.UserName, DocumentContext.CurrentDocument);
        }

        // Redirect user to the return URL, or if is not defined redirect to the default target URL
        var    redirectUrl = RequestContext.CurrentURL;
        string url         = QueryHelper.GetString("ReturnURL", String.Empty);

        if (!String.IsNullOrEmpty(url) && URLHelper.IsLocalUrl(url))
        {
            redirectUrl = url;
        }
        else if (!String.IsNullOrEmpty(DefaultTargetUrl))
        {
            redirectUrl = ResolveUrl(DefaultTargetUrl);
        }

        URLHelper.Redirect(redirectUrl);
    }
コード例 #27
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (Globals.AddRequestPermissions)
            {
                string      url         = filterContext.RequestContext.HttpContext.Request.RawUrl;
                string      requestType = filterContext.RequestContext.HttpContext.Request.RequestType;
                RoleManager roleManager = new RoleManager(Globals.DBConnectionKey);
                string      name        = roleManager.NameFromPath(url);
                roleManager.CreatePermission(name, requestType, url, "site");
            }

            //Cookies will be the most likely way to get the token in a site request
            //For the api its required in the headers because it's gonna be an ajax call which should be set by the dev.
            string authorizationToken = CookieHelper.GetValue(filterContext.HttpContext.Request.Cookies, "Authorization");

            if (string.IsNullOrWhiteSpace(authorizationToken) && filterContext.HttpContext.Request.Headers["Authorization"] != null)
            {
                authorizationToken = filterContext.HttpContext.Request.Headers["Authorization"].ToString();
            }

            if (string.IsNullOrWhiteSpace(authorizationToken))
            {
                RedirectToRoute(filterContext, HttpStatusCode.Unauthorized, "Account", "Login", filterContext.RequestContext.HttpContext.Request.Path, true, "You must be logged in to access this page.");
                return;
            }
            SessionManager sessionManager = new SessionManager(Globals.DBConnectionKey);

            if (sessionManager.IsValidSession(authorizationToken) == false)
            {
                RedirectToRoute(filterContext, HttpStatusCode.Unauthorized, "Account", "Login", filterContext.RequestContext.HttpContext.Request.Path, true, "Session expired.");
                return;
            }

            UserSession us = sessionManager.GetSession(authorizationToken, false);

            if (us == null)
            {
                RedirectToRoute(filterContext, HttpStatusCode.Unauthorized, "Account", "Login", filterContext.RequestContext.HttpContext.Request.Path, true, "Invalid session data.");
                return;
            }

            User currentUser = JsonConvert.DeserializeObject <User>(us.UserData);

            if (currentUser == null)
            {
                sessionManager.DeleteSession(authorizationToken);
                RedirectToRoute(filterContext, HttpStatusCode.Unauthorized, "Account", "Login", filterContext.RequestContext.HttpContext.Request.Path, true, "Invalid user data in session.");
                return;
            }

            if (!currentUser.SiteAdmin && !string.IsNullOrWhiteSpace(Role))
            {
                RoleManager roleManager = new RoleManager(Globals.DBConnectionKey);

                if (!roleManager.IsUserAuthorized(currentUser.UUID, currentUser.AccountUUID, filterContext.RequestContext.HttpContext.Request.Path))
                {
                    RedirectToRoute(filterContext, HttpStatusCode.Unauthorized, "Home", "Index", filterContext.RequestContext.HttpContext.Request.Path, true, "You are not authorized to view this page.");
                    return;
                }
            }

            base.OnActionExecuting(filterContext);
        }
コード例 #28
0
        /// <summary>
        /// 追加内容到cookie
        /// </summary>
        /// <param name="value"></param>
        private void AddAccountTokenToCookie(string value)
        {
            HttpCookie _cookie = CookieHelper.Create("AccountToken", value);

            Response.Cookies.Add(_cookie);
        }
コード例 #29
0
        public void Bind()
        {
            string type   = Context.Request.Form["type"];
            int    result = 1;
            Guid   userid = WebUserAuth.UserId.Value;

            if (string.IsNullOrEmpty(type))
            {
                string code        = Context.Request.Form["code"];
                string mobilePhone = Context.Request.Form["mobilePhone"];
                if (!mobilePhone.IsPhone())
                {
                    Response.Write("{\"result\":\"-2\",\"msg\":\"手机号格式不对\"}");
                    Response.End();
                }
                CookieHelper.WriteCookie("shellben4tel", Tool.Common.Utils.StringHandler.MaskTelNo(mobilePhone));
                var model = new UserBLL().GetUserBasicInfoModelByTelNo(mobilePhone);
                if (model == null)
                {
                    Response.Write("{\"result\":\"-1\",\"msg\":\"手机号未在团贷网注册\"}");
                    Response.End();
                }
                result = new CodeRecordBLL().CheckCodeRecord(code, mobilePhone, MsCodeType.PhoneCode,
                                                             MsCodeType2.BindWeiXinOpenId, model.Id, true);
                userid = model.Id;
            }

            if (result == 1)
            {
                var    posturl = GlobalUtils.MsgApiUrl;
                string err     = "";
                string openId  = GlobalUtils.OpenId;
                if (string.IsNullOrEmpty(openId))
                {
                    Response.Write("{\"result\":\"-4\",\"msg\":\"获取不到微信OpenId\"}");
                    Response.End();
                }
                //openId = "oUYJbuHDRnoxUw0UbTQUTO_nkUtQ";
                string resp = "";
                try
                {
                    var descStr =
                        TuanDai.WXSystem.Core.Common.MsgDesc.GetDescStr("{\"Data\":{\"WeiXinOpenId\":\"" + openId +
                                                                        "\",\"UserId\":\"" + userid + "\"}}");
                    resp = HttpClient.HttpUtil.HttpPostJson(TdConfig.ApplicationName,
                                                            posturl + "/6/UpdateMsgSetInfoWeixinOpenId", descStr,
                                                            out err, null, 3);
                }
                catch (Exception ex)
                {
                    TuanDai.LogSystem.LogClient.LogClients.ErrorLog(TdConfig.ApplicationName, "用户团贷网账户绑定微信", userid.ToString(), ex.Message);
                }

                if (!string.IsNullOrEmpty(resp))
                {
                    var returnmsg =
                        JsonConvert.DeserializeObject <TuanDai.WXSystem.Core.Common.MsgApiResponseMessage <bool> >(
                            resp);
                    if (returnmsg != null && returnmsg.Data)
                    {
                        TuandaiCommnetTool.BaseCommon.TaskAsyncHelper.RunAsync(() =>
                        {
                            if (getCount(userid) <= 0 && InsertRecord(userid, openId) > 0) //插入成功说明是首次绑定
                            {
                                SendTuanBi(userid);
                            }
                            else
                            {
                                UpdateRecord(userid, openId);
                            }
                        });
                        Response.Write("{\"result\":\"1\",\"msg\":\"绑定成功\"}");
                        Response.End();
                    }
                }
                Response.Write("{\"result\":\"0\",\"msg\":\"绑定失败\"}");
                Response.End();
            }
            else
            {
                Response.Write("{\"result\":\"-3\",\"msg\":\"验证码错误\"}");
                Response.End();
            }
        }
コード例 #30
0
        public ActionResult Index()
        {
            //thanh toan don hang
            IList <CartViewModel.ProductCart> productCarts = new List <CartViewModel.ProductCart>();
            CookieHelper cookieHelper = new CookieHelper("Cart");

            if (cookieHelper.GetCookie() != null)
            {
                string json = HttpUtility.UrlDecode(cookieHelper.GetCookie().Values["Cart"]);
                productCarts = JsonConvert.DeserializeObject <List <CartViewModel.ProductCart> >(json);
            }

            IList <ProductFrontPageMapping.ProductShowCart> productShowCarts =
                _menuRepository.GetProductShowCartByBarcode(productCarts.Select(o => o.Barcode).ToList());
            IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives();
            IList <CartViewModel.CartItem> cartItems = new List <CartViewModel.CartItem>();
            int gia = 0;

            if (productCarts.Any())
            {
                foreach (var o in productCarts)
                {
                    IList <ProductStockSyncMapping.TonKho> tonKhos = _productStockSyncRepository.GetTonKhoCuaSanPham(o.ProductId);
                    var tonkho = tonKhos.FirstOrDefault(t => t.Barcode.Equals(o.Barcode));
                    var item   = productShowCarts.FirstOrDefault(p => p.Barcode.Equals(o.Barcode));
                    if (item != null)
                    {
                        #region ghép combo < 80K
                        if (item.Price < 80000 && o.Quantity >= 2)
                        {
                            //nếu số lượng > 2  và giá < 80000 bắt đầu tính giá combo
                            int giatru = (item.Price * 10) / 100;
                            gia = item.Price - giatru;
                        }
                        else
                        {
                            gia = item.Price;
                        }
                        #endregion

                        var cartItem = new CartViewModel.CartItem()
                        {
                            ProductId      = o.ProductId,
                            Name           = item.NameProduct,
                            Image          = item.Img,
                            Link           = item.Link,
                            Price          = item.Price,
                            PricePromotion = gia,
                            Barcode        = o.Barcode,
                            Quantity       = o.Quantity,
                            AttributeImg   = item.AttributeImg,
                            AttributeName  = item.AttributeName,
                            AttributeFlag  = item.AttributeFlag,
                            Available      = tonkho != null && tonkho.OnHand >= o.Quantity
                        };
                        #region check promotion
                        if (promotions.Any())
                        {
                            foreach (var pr in promotions)
                            {
                                var promotionDetail = pr.PromotionDetails.FirstOrDefault(dt => dt.ProductId == cartItem.ProductId);
                                if (promotionDetail != null)
                                {
                                    cartItem.HasPromotion   = true;
                                    cartItem.PricePromotion = (int)promotionDetail.PriceDiscount;
                                    cartItem.Discount       = (short)promotionDetail.Percent;
                                    break;
                                }
                            }
                        }

                        #endregion
                        cartItems.Add(cartItem);
                    }
                }
            }
            CartViewModel.OrderModel cartModel = new CartViewModel.OrderModel()
            {
                CartItems = cartItems,
                Total     = cartItems.Sum(o => o.Quantity * o.PricePromotion),
                CartForm  = new CartViewModel.CartForm()
            };
            return(View("Index", cartModel));
        }
コード例 #31
0
        private void ConfigureApplicationIdentity(IServiceCollection services)
        {
            services.AddScoped <IPasswordHasher <ApplicationUser>, Kentico.Membership.PasswordHasher <ApplicationUser> >();
            services.AddScoped <IMessageService, MessageService>();

            services.AddApplicationIdentity <ApplicationUser, ApplicationRole>(options =>
            {
                // A place to configure Identity options, such as password strength requirements
                options.SignIn.RequireConfirmedEmail = true;
            })
            // Adds default token provider used to generate tokens for
            // email confirmations, password resets, etc.
            .AddApplicationDefaultTokenProviders()
            // Adds an implementation of the UserStore for working
            // with Xperience user objects
            .AddUserStore <ApplicationUserStore <ApplicationUser> >()
            // Adds an implementation of the RoleStore used for
            // working with Xperience roles
            .AddRoleStore <ApplicationRoleStore <ApplicationRole> >()
            // Adds an implementation of the UserManager for Xperience membership
            .AddUserManager <ApplicationUserManager <ApplicationUser> >()
            // Adds the default implementation of the SignInManger
            .AddSignInManager <SignInManager <ApplicationUser> >();

            //DocSection:ExternalAuth
            services.AddAuthentication()
            .AddFacebook(facebookOptions =>
            {
                facebookOptions.AppId     = "placeholder";
                facebookOptions.AppSecret = "placeholder";
            })
            .AddMicrosoftAccount(microsoftAccountOptions =>
            {
                microsoftAccountOptions.ClientSecret = "placeholder";
                microsoftAccountOptions.ClientId     = "placeholder";
            })
            .AddGoogle(googleOptions =>
            {
                googleOptions.ClientId     = "placeholder";
                googleOptions.ClientSecret = "placeholder";
            })
            .AddTwitter(twitterOptions =>
            {
                twitterOptions.ConsumerKey         = "placeholder";
                twitterOptions.ConsumerSecret      = "placeholder";
                twitterOptions.RetrieveUserDetails = true;
            });
            //EndDocSection:ExternalAuth

            services.AddAuthorization();

            services.ConfigureApplicationCookie(c =>
            {
                c.LoginPath         = new PathString("/");
                c.ExpireTimeSpan    = TimeSpan.FromDays(14);
                c.SlidingExpiration = true;
                c.Cookie.Name       = AUTHENTICATION_COOKIE_NAME;
            });

            // Registers the authentication cookie with the 'Essential' cookie level
            // Ensures that the cookie is preserved when changing a visitor's allowed cookie level below 'Visitor'
            CookieHelper.RegisterCookie(AUTHENTICATION_COOKIE_NAME, CookieLevel.Essential);
        }
コード例 #32
0
 /// <summary>
 /// 将用户登录状态记录从cookie中移除
 /// </summary>
 public static void RemoveCookie()
 {
     CookieHelper.Remove(CookieNames.LoginCookie);
 }
コード例 #33
0
 public ActionResult ClearBGCookie()
 {
     CookieHelper cookieHelper = new CookieHelper();
     cookieHelper.ClearCookie();
     return RedirectToAction("Index");
 }
コード例 #34
0
        public string GetCookieUID(HttpContext context = null)
        {
            context = this.GetContext(context);

            return(CookieHelper.GetCookie(context, this.COOKIE_LOGIN_UID));
        }
コード例 #35
0
        public ActionResult Edit(string param, string drawingFiles, string pictureFiles)
        {
            T_ENGIN_INFO arr = new T_ENGIN_INFO();

            arr = JsonHelper.JSONToObject <T_ENGIN_INFO>(param); //转成实体对象

            string method = "wavenet.fxsw.engin.farm.update";
            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();

            //基本信息
            paramDictionary.Add("s_id", arr.S_ID); //id

            #region
            paramDictionary.Add("s_name", arr.S_NAME);
            paramDictionary.Add("s_project_no", arr.S_PROJECT_NO);
            paramDictionary.Add("n_year", arr.N_YEAR);                 //年度
            paramDictionary.Add("n_pace_status", arr.N_PACE_STATUS);   //工程状态 1:工前准备,10:开工,20:完工,30:完工验收,40:决算审批,50:竣工验收
            paramDictionary.Add("s_town", arr.S_TOWN);                 //所属镇
            paramDictionary.Add("s_address", arr.S_ADDRESS);
            paramDictionary.Add("s_legal_person", arr.S_LEGAL_PERSON); //项目法人
            paramDictionary.Add("s_unit_design", arr.S_UNIT_DESIGN);   //设计单位
            paramDictionary.Add("s_unit_build", arr.S_UNIT_BUILD);
            paramDictionary.Add("s_unit_supervise", arr.S_UNIT_SUPERVISE);
            paramDictionary.Add("n_reckon_total_amt", arr.N_RECKON_TOTAL_AMT); //估计总投资
            paramDictionary.Add("s_remark", arr.S_REMARK);
            paramDictionary.Add("s_person", "小张");                             //上传图片人
            paramDictionary.Add("n_draft", arr.N_DRAFT);                       //是否有草图 1.有 0.没有

            //批复工程量
            paramDictionary.Add("n_ggsl", arr.N_GGSL);     //灌区数量
            paramDictionary.Add("n_ggmj", arr.N_GGMJ);     //灌区面积
            paramDictionary.Add("n_bzzs", arr.N_BZZS);     //泵站座数
            paramDictionary.Add("n_bztt", arr.N_BZTT);     //泵站台套
            paramDictionary.Add("n_dxqd", arr.N_DXQD);     //地下渠道
            paramDictionary.Add("n_dc", arr.N_DC);         //渡槽
            paramDictionary.Add("n_dxh", arr.N_DXH);       //倒虹吸
            paramDictionary.Add("n_cqmq", arr.N_CQMQ);     //衬砌明渠
            paramDictionary.Add("n_xfjdl", arr.N_WCXFJDL); //新翻建道路

            //概算投资
            paramDictionary.Add("n_total_invest", arr.N_TOTAL_INVEST);         //总投资
            paramDictionary.Add("n_engin_cost", arr.N_ENGIN_COST);             //工程直接费
            paramDictionary.Add("n_independent_cost", arr.N_INDEPENDENT_COST); //独立费用
            paramDictionary.Add("n_prep_cost", arr.N_PREP_COST);               //预备费
            paramDictionary.Add("n_sight_cost", arr.N_SIGHT_COST);             //景观等费用
            //资金配套组成
            paramDictionary.Add("n_subsidy_city", arr.N_SUBSIDY_CITY);         //市补
            paramDictionary.Add("n_subsidy_district", arr.N_SUBSIDY_DISTRICT); //区配套
            paramDictionary.Add("n_subsidy_town", arr.N_SUBSIDY_TOWN);         //镇配套

            //完成工程量
            paramDictionary.Add("n_complete_ggsl", arr.N_WCGGSL);   //灌区数量
            paramDictionary.Add("n_complete_ggmj", arr.N_WCGGMJ);   //灌区面积
            paramDictionary.Add("n_complete_bzzs", arr.N_WCBZZS);   //泵站座数
            paramDictionary.Add("n_complete_bztt", arr.N_WCBZTT);   //泵站台套
            paramDictionary.Add("n_complete_dxqd", arr.N_WCDXQD);   //地下渠道
            paramDictionary.Add("n_complete_dc", arr.N_WCDC);       //渡槽
            paramDictionary.Add("n_complete_dxh", arr.N_WCDXH);     //倒虹吸
            paramDictionary.Add("n_complete_cqmq", arr.N_WCCQMQ);   //衬砌明渠
            paramDictionary.Add("n_complete_xfjdl", arr.N_WCXFJDL); //新翻建道路
            #endregion

            paramDictionary.Add("remove_pic_ids", arr.REMOVE_PIC_IDS);//删除的图片ID
            //paramDictionary.Add("is_delete", "0");//是否删除 1删除

            //文件路径
            string path = Request.ApplicationPath;
            path = Server.MapPath(path += "/upload/");

            Dictionary <string, string> fileParams = new Dictionary <string, string>();
            if (!string.IsNullOrEmpty(drawingFiles))
            {
                //文件类型picture_file1 drawing_file1 sketch_file
                string[] Files = drawingFiles.Split(',');
                for (int i = 0; i < Files.Length - 1; i++)
                {
                    fileParams.Add("drawing_file" + (i + 1), path + Files[i]);
                }
            }
            if (!string.IsNullOrEmpty(pictureFiles))
            {
                //文件类型picture_file1 drawing_file1 sketch_file
                string[] Files = pictureFiles.Split(',');

                for (int i = 0; i < Files.Length - 1; i++)
                {
                    fileParams.Add("picture_file" + (i + 1), path + Files[i]);
                }
            }

            string sss = CookieHelper.GetData(Request, method, paramDictionary, fileParams);
            // webPost.Post(url, Encoding.UTF8, null, paramDictionary, fileParams);
            return(Json(sss));
        }
コード例 #36
0
        public string GetCookieTokenRaw(HttpContext context = null)
        {
            context = this.GetContext(context);

            return(CookieHelper.GetCookie(context, this.COOKIE_LOGIN_TOKEN));
        }
コード例 #37
0
        protected void Page_Load(object sender, EventArgs e)
        {
#if !MONO
            if (!WebConfigSettings.EnableOpenIdAuthentication)
            {
                this.Visible = false;
                return;
            }

            LoadSettings();

            PopulateLabels();



            if (!IsPostBack)
            {
                string returnUrl = WebConfigSettings.PageToRedirectToAfterSignIn;

                if (returnUrl.EndsWith(".aspx"))
                {
                    CookieHelper.SetCookie(returnUrlCookieName, returnUrl);
                    return;
                }

                if (Page.Request.UrlReferrer != null)
                {
                    string urlReferrer = Page.Request.UrlReferrer.ToString();
                    if ((urlReferrer.StartsWith(siteRoot)) || (urlReferrer.StartsWith(siteRoot.Replace("https://", "http://"))))
                    {
                        returnUrl = urlReferrer;
                    }
                }

                string returnUrlParam = Page.Request.Params.Get("returnurl");
                if (!String.IsNullOrEmpty(returnUrlParam))
                {
                    returnUrlParam = SecurityHelper.RemoveMarkup(returnUrlParam);
                    string redirectUrl = Page.ResolveUrl(SecurityHelper.RemoveMarkup(Page.Server.UrlDecode(returnUrlParam)));
                    if ((redirectUrl.StartsWith(siteRoot)) || (redirectUrl.StartsWith(siteRoot.Replace("https://", "http://"))))
                    {
                        returnUrl = redirectUrl;
                    }
                }

                //string returnUrlParam = Page.Request.Params.Get("returnurl");
                //if (!String.IsNullOrEmpty(returnUrlParam))
                //{



                //    returnUrl = Page.ResolveUrl(Page.Server.UrlDecode(returnUrlParam));
                //}

                if (returnUrl.Length > 0)
                {
                    CookieHelper.SetCookie(returnUrlCookieName, returnUrl);
                }
            }
#endif
        }
コード例 #38
0
 private bool Login(string userName, string password,bool rememberMe)
 {
     if (Membership.ValidateUser(userName, password))
     {
         CookieHelper newCookieHelper = new CookieHelper(HttpContext.Request,HttpContext.Response);
         newCookieHelper.SetLoginCookie(userName, password, rememberMe);
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #39
0
        /// <summary>
        /// 用用户名称判断角色的名称1是成功0是失败,3是请输入序列号,4是输入的企业账号不对,5是企业账号已停用
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="pwd"></param>
        /// <param name="rememberPwd"></param>
        /// <param name="context"></param>
        public void LoginS(string loginName, string pwd, bool rememberPwd, string EnName, HttpContext context)
        {
            U_UserInfoEntity entity       = new U_UserInfoEntity();
            EnterpriseEntity EnNameEntity = new EnterpriseEntity();

            EnNameEntity = MgrServices.EnNmberService.ENumberNames(EnName);//没搜到
            string EnterpriseCode = EnNameEntity.EnterpriseCode;

            if (EnterpriseCode != null && EnterpriseCode != "")
            {
                if (MgrServices.UserAddService.IsBannedOfCheckEnterpriseCode(EnterpriseCode) == 0)
                {
                    context.Response.Write(5);
                    context.Response.End();
                }

                entity = MgrServices.UserAddService.GetEntityInfo(loginName, EnterpriseCode);

                int isSuccess = 0;
                if (entity != null)
                {
                    string sss = MD5Helper.Upper32(pwd);
                    context.Session["userInfoEntity"] = entity;
                    if (entity._u_password == MD5Helper.Upper32(pwd))
                    {
                        isSuccess = 1;
                    }
                    else
                    {
                        isSuccess = 0;
                    }


                    if (isSuccess > 0)
                    {
                        context.Session["loginName"] = loginName;
                        context.Session["U_Name"]    = entity._u_name;
                        context.Session["UserID"]    = entity._u_id;
                        //context.Session["U_Img"] = entity._u_img;
                        if (entity._u_img != null && entity._u_img != "")
                        {
                            context.Session["U_Img"] = entity._u_img;
                        }
                        else
                        {
                            context.Session["U_Img"] = "";
                        }

                        context.Session["EnterpriseCode"] = entity._enterpriseCode;
                        context.Session["role_type"]      = entity._role_types;

                        context.Session["ActivationSNumber"]     = entity._activationsnumber;
                        context.Session["ActivatEnterpriseMark"] = entity._activatenterprisemark;
                        SetSessionFunctionByRoleID(Convert.ToInt32(entity._r_id), context);//将对应的权限放到Session里面
                        if (rememberPwd)
                        {
                            CookieHelper.SetCookie("LoginNameCookie", loginName, DateTime.MaxValue);
                            CookieHelper.SetCookie("LoginPwdCookie", pwd, DateTime.MaxValue);
                            CookieHelper.SetCookie("RememberPwd", rememberPwd.ToString(), DateTime.MaxValue);
                        }
                        else
                        {
                            CookieHelper.SetCookie("LoginNameCookie", "@@", DateTime.MaxValue);
                            CookieHelper.SetCookie("LoginPwdCookie", "@@", DateTime.MaxValue);
                        }
                        if (entity._isenterprisemark == 1 && entity._activatenterprisemark == 1)//已经激活标示
                        {
                            context.Response.Write(1);
                        }
                        else if (entity._isenterprisemark == 1 && entity._activatenterprisemark == 0)
                        {
                            context.Response.Write(3);
                        }
                        else
                        {
                            context.Response.Write(1);
                        }
                    }
                    else
                    {
                        CookieHelper.ClearCookie("LoginNameCookie");
                        CookieHelper.ClearCookie("LoginPwdCookie");
                        context.Response.Write(0);
                    }
                    context.Session["SecondMenu"] = null;
                    context.Session["FirstMenu"]  = null;
                }
                else
                {
                    CookieHelper.ClearCookie("LoginNameCookie");
                    CookieHelper.ClearCookie("LoginPwdCookie");
                    context.Response.Write(0);
                }
            }
            else
            {
                context.Response.Write(4);
            }
        }
コード例 #40
0
        private DateTime GMT = DateTime.Parse("1970-1-1 00:00:00");                  //格林时间;
        public void ProcessRequest(HttpContext context)
        {
            LoginJSData          myJson   = new LoginJSData();
            JavaScriptSerializer jsSerial = new JavaScriptSerializer();
            string validateCodeInSession  = (string)context.Session[Constants.ValidateCode];

            string userName        = context.Request.Params["userName"];
            string userPass        = context.Request.Params["userPass"];
            string isRemember      = context.Request.Params["isRemember"];
            string validateCode    = context.Request.Params["verifyTxt"];
            bool   isRequestStatus = context.Request.Params["status"] != null ? true : false;
            bool   isResign        = context.Request.Params["resign"] != null ? true : false;
            string sql             = "";

            if (isResign)
            {
                if (MySession.UserNameSession != null)
                {
                    MySession.UserNameSession = null;
                }
                if (CookieHelper.GetCookie(Constants.UserInfo) != null)
                {
                    CookieHelper.RemoveCookie(Constants.UserInfo);
                }
                context.Response.Write("OK");
                return;
            }

            if (isRequestStatus)
            {
                if (MySession.UserNameSession == null)
                {
                    context.Response.Write("");
                }
                else
                {
                    context.Response.Write(MySession.UserNameSession);
                }
                return;
            }

            //处理验证码是否已过期
            if (context.Session == null)
            {
                myJson.State   = EnumState.验证码错误;
                myJson.Message = "页面停留过长,验证码已失效!";
                context.Response.Write(jsSerial.Serialize(myJson));
                return;
            }
            //处理验证码是否输入正确
            if (!validateCode.Equals(validateCodeInSession, StringComparison.CurrentCultureIgnoreCase))
            {
                myJson.State   = EnumState.验证码错误;
                myJson.Message = "验证码错误!";
                context.Response.Write(jsSerial.Serialize(myJson));
                return;
            }
            //检测用户名是否存在或是否处于锁定状态
            sql = String.Format("select * from Users where UserName='******'", userName);
            if (!SqlHelper.IsRecordExists(sql))
            {
                myJson.State   = EnumState.用户不存在;
                myJson.Message = String.Format("“{0}”用户不存在!", userName);
                context.Response.Write(jsSerial.Serialize(myJson));
                return;
            }
            else
            {
                sql = String.Format("select * from Users where UserName = '******'", userName);
                DataTable dt = SqlHelper.ExcuteTable(sql, new SqlParameter("UserName", userName));//
                if ((bool)dt.Rows[0]["IsLock"])
                {
                    if (dt.Rows[0]["LockTime"] != DBNull.Value)
                    {
                        if ((DateTime.UtcNow - GMT).TotalMinutes - Convert.ToInt32(dt.Rows[0]["LockTime"]) > 30) // 距离上次输入错误大于30分钟 解锁账户
                        {
                            dt.Rows[0].BeginEdit();
                            dt.Rows[0]["IsLock"] = false;
                            dt.Rows[0]["Wrongs"] = 0;
                            dt.Rows[0].EndEdit();
                            SqlHelper.UpdateTable(dt, "Users");
                        }
                        else
                        {
                            myJson.State   = EnumState.用户不存在;
                            myJson.Message = String.Format("用户{0}已被锁定30分钟!", userName);
                            context.Response.Write(jsSerial.Serialize(myJson));
                            return;
                        }
                    }
                }
            }


            DataTable dt1;

            sql = String.Format("select * from Users where UserName = '******'", userName);
            dt1 = SqlHelper.ExcuteTable(sql, new SqlParameter("UserName", userName));

            sql = String.Format("select * from Users where UserName = '******' and UserPass = '******'", userName, Encription.MD5Encrypt(userPass));

            if (!SqlHelper.IsRecordExists(sql))  //输入账户密码不正确
            {
                int wrongNum = 0;
                wrongNum = dt1.Rows[0]["Wrongs"] == DBNull.Value ? 0 : (int)dt1.Rows[0]["Wrongs"];
                wrongNum++;
                dt1.Rows[0].BeginEdit();
                dt1.Rows[0]["Wrongs"] = wrongNum;
                dt1.Rows[0].EndEdit();
                SqlHelper.UpdateTable(dt1, "Users");

                if (wrongNum >= 5)
                {
                    dt1.Rows[0].BeginEdit();
                    dt1.Rows[0]["IsLock"]   = true;
                    dt1.Rows[0]["LockTime"] = (DateTime.UtcNow - GMT).TotalMinutes;
                    dt1.Rows[0].EndEdit();
                    SqlHelper.UpdateTable(dt1, "Users");
                    myJson.State   = EnumState.密码错误;
                    myJson.Message = "密码错误!输入错误已达5次," + userName + "账户已被锁定!";
                    context.Response.Write(jsSerial.Serialize(myJson));
                    return;
                }
                else
                {
                    myJson.State   = EnumState.密码错误;
                    myJson.Message = "密码错误!已累计错误" + wrongNum + "次,输入错误达5次将锁定账户!";
                    context.Response.Write(jsSerial.Serialize(myJson));
                    return;
                }
            }
            else                             //输入账户密码正确
            {
                dt1.Rows[0].BeginEdit();
                dt1.Rows[0]["Wrongs"] = 0;
                dt1.Rows[0].EndEdit();
                SqlHelper.UpdateTable(dt1, "Users");

                //用cookie记住用户信息
                if (isRemember == "true")
                {
                    if (CookieHelper.GetCookie(Constants.UserInfo) == null)
                    {
                        string     pass   = Encription.MD5Encrypt(userName + Encription.MD5Encrypt(userPass));
                        HttpCookie cookie = new HttpCookie(Constants.UserInfo);
                        cookie.Values.Add(Constants.UserName, userName);
                        cookie.Values.Add(Constants.UserPass, pass); //客户端cookie中密码的保密规则:用户名+原密码MD5加密,在对其再一次md5加密
                        cookie.Expires = DateTime.Now.AddMonths(1);
                        CookieHelper.AddCookie(cookie);
                    }
                    else
                    {
                        HttpCookie cookie = CookieHelper.GetCookie(Constants.UserInfo);
                        String     pass   = Encription.MD5Encrypt(userName + Encription.MD5Encrypt(userPass));
                        if (cookie.Values[Constants.UserName] != userName)
                        {
                            CookieHelper.SetCookie(Constants.UserInfo, Constants.UserName, userName, DateTime.Now.AddMonths(1));
                        }
                        if (cookie.Values[Constants.UserPass] != pass)
                        {
                            CookieHelper.SetCookie(Constants.UserInfo, Constants.UserPass, pass, DateTime.Now.AddMonths(1));
                        }
                    }
                }
                else
                {
                    if (CookieHelper.GetCookie(Constants.UserInfo) != null)
                    {
                        CookieHelper.RemoveCookie(Constants.UserInfo);
                    }
                }

                MySession.UserNameSession = userName;//登录状态记录到session中;
                myJson.State   = EnumState.登录成功;
                myJson.Message = userName + ",欢迎您回来!";
                context.Response.Write(jsSerial.Serialize(myJson));
                return;
            }
        }
コード例 #41
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="pwd"></param>
        /// <param name="rememberPwd"></param>
        /// <param name="context"></param>
        public void Login(string loginName, string pwd, bool rememberPwd, HttpContext context)
        {
            int    isSuccess = 0;
            string EName     = Common.GetRequest("ENameS");

            if (EName == "admin")
            {
                isSuccess = MgrServices.UserAddService.Login(loginName, MD5Helper.Upper32(pwd));
            }

            U_UserInfoEntity entity = new U_UserInfoEntity();

            if (isSuccess > 0)
            {
                entity = MgrServices.UserAddService.GetEntity(loginName);

                if (entity != null)
                {
                    context.Session["loginName"] = loginName;
                    context.Session["UserID"]    = isSuccess;
                    //context.Session["U_Img"] = entity._u_img;
                    if (entity._u_img != null && entity._u_img != "")
                    {
                        context.Session["U_Img"] = entity._u_img;
                    }
                    else
                    {
                        context.Session["U_Img"] = "";
                    }

                    context.Session["EnterpriseCode"] = entity._enterpriseCode;
                    context.Session["role_type"]      = entity._role_types;
                    context.Session["U_Name"]         = entity._u_name;
                    context.Session["UserID"]         = entity._u_id;

                    SetSessionFunctionByRoleID(Convert.ToInt32(entity._r_id), context);//将对应的权限放到Session里面
                    GetRoleFuntion(context);
                    if (rememberPwd)
                    {
                        CookieHelper.SetCookie("LoginNameCookie", loginName, DateTime.MaxValue);
                        CookieHelper.SetCookie("LoginPwdCookie", pwd, DateTime.MaxValue);
                        CookieHelper.SetCookie("RememberPwd", rememberPwd.ToString(), DateTime.MaxValue);
                    }
                    else
                    {
                        CookieHelper.SetCookie("LoginNameCookie", "@@", DateTime.MaxValue);
                        CookieHelper.SetCookie("LoginPwdCookie", "@@", DateTime.MaxValue);
                    }
                    context.Response.Write(1);
                    context.Session["SecondMenu"] = null;
                    context.Session["FirstMenu"]  = null;
                }
                else
                {
                    context.Response.Write(0);
                }
            }
            else
            {
                CookieHelper.ClearCookie("LoginNameCookie");
                CookieHelper.ClearCookie("LoginPwdCookie");
                context.Response.Write(isSuccess > 0);
            }
        }
コード例 #42
0
        public ActionResult Add(string param, string drawingFiles, string pictureFiles)
        {
            T_ENGIN_MAIN_SEWAGE arr = new T_ENGIN_MAIN_SEWAGE();

            arr = JsonHelper.JSONToObject <T_ENGIN_MAIN_SEWAGE>(param); //转成实体对象

            IDictionary <string, string> paramDictionary = new Dictionary <string, string>();
            var method = "wavenet.fxsw.engin.sewage.report";

            #region
            //基本信息
            paramDictionary.Add("s_name", arr.S_NAME);
            paramDictionary.Add("s_project_no", arr.S_PROJECT_NO);
            paramDictionary.Add("n_year", arr.N_YEAR);                 //年度
            paramDictionary.Add("n_pace_status", arr.N_PACE_STATUS);   //工程状态 1:工前准备,10:开工,20:完工,30:完工验收,40:决算审批,50:竣工验收
            paramDictionary.Add("s_town", arr.S_TOWN);                 //所属镇
            paramDictionary.Add("s_address", arr.S_ADDRESS);
            paramDictionary.Add("s_legal_person", arr.S_LEGAL_PERSON); //项目法人
            paramDictionary.Add("s_unit_design", arr.S_UNIT_DESIGN);   //设计单位
            paramDictionary.Add("s_unit_build", arr.S_UNIT_BUILD);
            paramDictionary.Add("s_unit_supervise", arr.S_UNIT_SUPERVISE);
            paramDictionary.Add("n_reckon_total_amt", arr.N_RECKON_TOTAL_AMT); //估计总投资
            paramDictionary.Add("s_remark", arr.S_REMARK);
            paramDictionary.Add("s_person", "小张");                             //上传图片人
            paramDictionary.Add("n_draft", arr.N_DRAFT);                       //是否有草图 1.有 0.没有

            //批复工程量
            paramDictionary.Add("n_czsl", arr.N_CZSL);     //村组数量
            paramDictionary.Add("n_zhs", arr.N_ZHS);       //总户数
            paramDictionary.Add("n_jdclhs", arr.N_JDCLHS); //就地处理户数
            paramDictionary.Add("n_sznghs", arr.N_SZNGHS); //市政纳管户数
            paramDictionary.Add("n_jdclz", arr.N_JDCLZ);   //就地处理站
            paramDictionary.Add("n_gwcd", arr.N_GWCD);     //管网长度
            paramDictionary.Add("n_xfjhfc", arr.N_XFJHFC); //新翻建化粪池

            //概算投资
            paramDictionary.Add("n_total_invest", arr.N_TOTAL_INVEST);         //总投资
            paramDictionary.Add("n_engin_cost", arr.N_ENGIN_COST);             //工程直接费
            paramDictionary.Add("n_independent_cost", arr.N_INDEPENDENT_COST); //独立费用
            paramDictionary.Add("n_prep_cost", arr.N_PREP_COST);               //预备费
            paramDictionary.Add("n_sight_cost", arr.N_SIGHT_COST);             //景观等费用
            //资金配套组成
            paramDictionary.Add("n_subsidy_city", arr.N_SUBSIDY_CITY);         //市补
            paramDictionary.Add("n_subsidy_district", arr.N_SUBSIDY_DISTRICT); //区配套
            paramDictionary.Add("n_subsidy_town", arr.N_SUBSIDY_TOWN);         //镇配套

            //完成工程量
            paramDictionary.Add("n_complete_czsl", arr.N_WCCZSL);     //村组数量
            paramDictionary.Add("n_complete_zhs", arr.N_WCZHS);       //总户数
            paramDictionary.Add("n_complete_jdclhs", arr.N_WCJDCLHS); //就地处理户数
            paramDictionary.Add("n_complete_sznghs", arr.N_WCSZNGHS); //市政纳管户数
            paramDictionary.Add("n_complete_jdclz", arr.N_WCJDCLZ);   //就地处理站
            paramDictionary.Add("n_complete_gwcd", arr.N_WCGWCD);     //管网长度
            paramDictionary.Add("n_complete_xfjhfc", arr.N_WCXFJHFC); //新翻建化粪池

            #endregion
            //文件路径
            string path = Request.ApplicationPath;
            path = Server.MapPath(path += "/upload/");

            Dictionary <string, string> fileParams = new Dictionary <string, string>();
            if (!string.IsNullOrEmpty(drawingFiles))
            {
                //文件类型picture_file1 drawing_file1 sketch_file
                string[] Files = drawingFiles.Split(',');
                for (int i = 0; i < Files.Length - 1; i++)
                {
                    fileParams.Add("drawing_file" + (i + 1), path + Files[i]);
                }
            }
            if (!string.IsNullOrEmpty(pictureFiles))
            {
                //文件类型picture_file1 drawing_file1 sketch_file
                string[] Files = pictureFiles.Split(',');

                for (int i = 0; i < Files.Length - 1; i++)
                {
                    fileParams.Add("picture_file" + (i + 1), path + Files[i]);
                }
            }
            string sss = CookieHelper.GetData(Request, method, paramDictionary, fileParams);
            return(Json(sss));
        }
コード例 #43
0
        /// <summary>
        /// 合伙人信息完善
        /// </summary>
        /// <param name="model"></param>
        /// <param name="Code"></param>
        /// <returns></returns>
        public ActionResult SubmitUser(Ho_PartnerUser nmodel, string Code)
        {
            string realCode = DESEncrypt.Decrypt(CookieHelper.GetCookie("WebCode"));

            if (StringHelper.IsNullOrEmpty(Code) || Code != realCode)
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "验证码不正确"
                }.ToString()));
            }
            if (StringHelper.IsNullOrEmpty(nmodel.CardCode) || !IdCardHelper.CheckIDCard(nmodel.CardCode))
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "身份证号码不正确"
                }.ToString()));
            }
            //验证手机号码和身份证的唯一
            IDatabase database  = DataFactory.Database();
            int       codecount = database.FindCount <Ho_PartnerUser>(" and CardCode = '" + nmodel.CardCode + "'");

            if (codecount > 0)
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "身份证号码已存在"
                }.ToString()));
            }
            int Mobile = database.FindCount <Ho_PartnerUser>(" and Mobile = '" + nmodel.Mobile + "'");

            if (Mobile > 0)
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "手机号码已存在"
                }.ToString()));
            }
            WebData wbll  = new WebData();
            var     model = wbll.GetUserInfo(Request);

            model.Birthday   = Convert.ToDateTime(IdCardHelper.GetBrithdayFromIdCard(nmodel.CardCode));
            model.Sex        = IdCardHelper.GetSexFromIdCard(nmodel.CardCode);
            model.CardCode   = nmodel.CardCode;
            model.CodeImg1   = nmodel.CodeImg1;
            model.CodeImg2   = nmodel.CodeImg2;
            model.Mobile     = nmodel.Mobile;
            model.ModifyTime = DateTime.Now;
            model.Name       = nmodel.Name;
            model.Status     = 2;
            model.StatusStr  = "未认证";
            model.CreatTime  = DateTime.Now; //正式申请成为合伙人
            model.Modify(model.Number);

            int result = database.Update(model);

            if (result > 0)
            {
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = "提交成功"
                }.ToString()));
            }
            else
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "提交失败"
                }.ToString()));
            }
        }