Example #1
0
        /// <summary>
        /// 将图片的URL或者Base64字符串转为图片并上传到服务器,返回上传后的完整图片URL
        /// </summary>
        /// <param name="imgBase64OrUrl">URL地址或者Base64字符串</param>
        /// <returns></returns>
        public static string GetImgUrl(string imgBase64OrUrl)
        {
            if (imgBase64OrUrl.Contains("data:image"))
            {
                Image  img      = ImgHelper.GetImgFromBase64Url(imgBase64OrUrl);
                string fileName = $"{GuidHelper.GenerateKey()}.jpg";

                string dir = Path.Combine(GlobalSwitch.WebRootPath, "Upload", "Img");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                img.Save(Path.Combine(dir, fileName));

                return($"{GlobalSwitch.WebRootUrl}/Upload/Img/{fileName}");
            }
            else
            {
                return(imgBase64OrUrl);
            }
        }
Example #2
0
        /// <summary>
        /// 获取当前用户的登录状态
        /// </summary>
        /// <param name="type">0:Head.html,1:HongRenHui下的Head.html</param>
        /// <returns></returns>
        private string GetUserLoginState(int type)
        {
            StringBuilder head_html = new StringBuilder();

            var http_url = "javascript:void(0);";

            int user_id = 0;

            if (type == 0)
            {
                user_id = GetCurUserID();
            }
            else if (type == 1)
            {
                user_id = GetCurUserID_HongRenHui();
            }

            if (user_id == 0)
            {
                if (type == 0)
                {
                    #region  类型0
                    head_html.AppendFormat("<div class=\"login-box\">");
                    head_html.AppendFormat("<a href=\"/userlogin/login\" title=\"登录\">登录</a>");
                    //head_html.AppendFormat("<a href=\"javascript:void(0)\" title=\"登录\" class=\"thirdlogin\">登录</a>");
                    head_html.AppendFormat("<i>丨</i>");
                    head_html.AppendFormat("<a href=\"/userlogin/register\" title=\"注册\">注册</a>");
                    head_html.AppendFormat("</div>");
                    #endregion
                }
                else if (type == 1)
                {
                    #region  类型0
                    //head_html.AppendFormat("<div class=\"opera-box\">");
                    ////head_html.AppendFormat("<span><a href=\"javascript:void(0)\" title=\"QQ\" id=\"qqLoginBtn\">QQ</a></span>");
                    //head_html.AppendFormat("<span><a class=\"login\" href=\"/login\" title=\"登录\">登录</a></span>");
                    ////head_html.AppendFormat("<span><a class=\"login\" href=\"javascript:;\" title=\"登录\" onclick=\"returnlogin()\">登录</a></span>");
                    //head_html.AppendFormat("<span>");
                    //head_html.AppendFormat("<a href=\"/register\" title=\"注册\">注册</a>");
                    //head_html.AppendFormat("</span>");
                    //head_html.AppendFormat("<span class=\"hrcolor\">");
                    //head_html.AppendFormat("<a href=\"/report\" title=\"红人求报道\">红人求报道</a>");
                    //head_html.AppendFormat("</span>");
                    //head_html.AppendFormat("<span class=\"hrcolor\">");
                    //head_html.AppendFormat("<a href=\"/hrip\" title=\"入驻红人爱品\">入驻红人爱品</a>");
                    //head_html.AppendFormat("</span>");
                    //head_html.AppendFormat("</div>");


                    head_html.AppendFormat("<div class=\"login\"><a href=\"/login\"  title=\"登录\">登录</a><a href=\"/register\" title=\"注册\">注册</a></div>");

                    #endregion
                }
            }
            else
            {
                NewXzc.Model.RED_USER user_model_head = user_bll_h.GetModel(user_id);

                if (user_model_head != null)
                {
                    if (type == 0)
                    {
                        #region  类型0

                        string nickname = user_model_head.USERNAME;

                        head_html.AppendFormat("<div class=\"login-box\">");
                        head_html.AppendFormat("<a class=\"user-center\" href=\"/people_c\" title=\"{0}\">", nickname);
                        head_html.AppendFormat("<span>");
                        head_html.AppendFormat("<img src=\"{0}\" height=\"28\" width=\"28\" alt=\"{1}\">", ImgHelper.Return_User_Head(user_model_head.USER_HEAD, 3), nickname);
                        head_html.AppendFormat("</span>");
                        head_html.AppendFormat("<em>{0}</em>", StringHelper.ReturnNumStr(nickname, 0, 7));
                        head_html.AppendFormat("</a>");
                        head_html.AppendFormat("<a href=\"/userlogin/logout\" title=\"退出\">退出</a>");
                        head_html.AppendFormat("</div>");
                        #endregion
                    }
                    else if (type == 1)
                    {
                        #region  类型0

                        string nickname = user_model_head.USERNAME;

                        //head_html.AppendFormat("<div class=\"opera-box login-box\">");
                        //head_html.AppendFormat("<a class=\"user-center\" href=\"/people_c\" title=\"{0}\">", nickname);
                        //head_html.AppendFormat("<span>");
                        //head_html.AppendFormat("<img src=\"{0}\" height=\"28\" width=\"28\" alt=\"{1}\">", ImgHelper.Return_User_Head(user_model_head.USER_HEAD, 3), nickname);
                        //head_html.AppendFormat("</span>");
                        //head_html.AppendFormat("<em>{0}</em>", StringHelper.ReturnNumStr(nickname, 0, 7));
                        //head_html.AppendFormat("</a>");
                        //head_html.AppendFormat("<a href=\"/logout\" title=\"退出\">退出</a>");

                        ////head_html.AppendFormat("<span>");
                        ////head_html.AppendFormat("<a href=\"/report\" title=\"红人求报道\">红人求报道</a>");
                        ////head_html.AppendFormat("</span>");

                        //head_html.AppendFormat("</div>");


                        head_html.AppendFormat("<div class=\"out\"><a href=\"/logout\" title=\"退出\" class=\"tc\">退出</a><a href=\"/people_c\" title=\"{0}\" class=\"name\">{0}</a></div>", nickname);


                        #endregion
                    }
                }
                else
                {
                    HttpContext.Current.Response.Redirect("/404");
                }
            }

            return(head_html.ToString());
        }