示例#1
0
        public JsonResult UploadImage()
        {
            var result = "";

            if (Request.Files.Count > 0)
            {
                var Imgfile = Request.Files[0];
                try
                {
                    var buffer = new byte[Imgfile.ContentLength];
                    Imgfile.InputStream.Read(buffer, 0, buffer.Length);
                    using (var client = new FileUploadClient())
                    {
                        var res = client.UploadImage(new ImageUploadRequest()
                        {
                            Contents      = buffer,
                            DirectoryName = "TaskConfig",
                            MaxHeight     = 1920,
                            MaxWidth      = 1920
                        });
                        if (res.Success && res.Result != null)
                        {
                            result = ImageHelper.GetImageUrl(res.Result);
                        }
                    }
                }
                catch (Exception exp)
                {
                    WebLog.LogException(exp);
                }
            }
            return(Json(result));
        }
示例#2
0
        public JsonResult UploadImage()
        {
            var result = "";

            if (Request.Files.Count > 0)
            {
                var Imgfile = Request.Files[0];
                try
                {
                    var buffer = new byte[Imgfile.ContentLength];
                    Imgfile.InputStream.Read(buffer, 0, buffer.Length);
                    using (var client = new FileUploadClient())
                    {
                        var res = client.UploadImage(new ImageUploadRequest()
                        {
                            Contents      = buffer,
                            DirectoryName = "BannerConfigImg",
                            MaxHeight     = 1920,
                            MaxWidth      = 1920
                        });
                        if (res.Success && res.Result != null)
                        {
                            result = WebConfigurationManager.AppSettings["DoMain_image"] + res.Result;
                        }
                    }
                }
                catch (Exception exp)
                {
                    WebLog.LogException(exp);
                }
            }
            return(Json(result));
        }
示例#3
0
        public JsonResult BatchLogOutUserByUserIdAction()
        {
            try
            {
                if (Request.Files.Count > 0)
                {
                    var file = Request.Files[0];
                    if (!file.FileName.Contains(".xlsx") && !file.FileName.Contains(".xls"))
                    {
                        return(Json(new { Status = -1, Error = "请上传.xlsx文件或者.xls文件!" }, "text/html"));
                    }

                    var excel = new Controls.ExcelHelper(file.InputStream, file.FileName);
                    var dt    = excel.ExcelToDataTable("sheet1", true);

                    foreach (DataRow dr in dt.Rows)
                    {
                        var userid = dr[0].ToString();
                        if (!string.IsNullOrWhiteSpace(userid))
                        {
                            LogOutUserByUserId(userid);
                        }
                    }
                }
                return(Json(new { Status = -1, Error = "请选择文件" }, "text/html"));
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
                return(Json(new { Status = -2, Error = ex }, "text/html"));
            }
        }
示例#4
0
        public PartialViewResult LogOutUserByMobileInfo(string mobileNumber)
        {
            User info = new Service.UserAccount.Models.User();

            if (!string.IsNullOrWhiteSpace(mobileNumber))
            {
                try
                {
                    using (var client = new UserAccountClient())
                    {
                        var result = client.GetUserByMobile(mobileNumber);
                        result.ThrowIfException(true);
                        if (result.Success && result.Result != null)
                        {
                            info = result.Result;
                        }
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
            }
            return(PartialView(info));
        }
示例#5
0
        private void LogOutUserByUserId(string userId)
        {
            if (!string.IsNullOrWhiteSpace(userId))
            {
                Guid uId = new Guid(userId);
                try
                {
                    using (var client = new AccessTokenClient())
                    {
                        var result = client.RemoveAll(uId, "Setting站点工具登出");
                        result.ThrowIfException(true);
                    }

                    using (var useraccoutClient = new UserAccountClient())
                    {
                        var insertLog = useraccoutClient.LogUserAction(new UserLog
                        {
                            Action      = UserActionEnum.LogOut,
                            CreatedTime = DateTime.Now,
                            UserId      = uId,
                            ChannelIn   = nameof(ChannelIn.H5),
                            Content     = "Setting站点内手动登出该用户"
                        });
                        insertLog.ThrowIfException(true);
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
            }
        }
示例#6
0
        public static async Task <bool> PushArticleMessage(string userId, int batchId, int articleid, string userName)
        {
            try
            {
                using (var client = new Tuhu.Service.Push.TemplatePushClient())
                {
                    var result = await client.PushByUserIDAndBatchIDAsync(new List <string> {
                        userId
                    }, batchId, new Service.Push.Models.Push.PushTemplateLog()
                    {
                        Replacement = Newtonsoft.Json.JsonConvert.SerializeObject(new Dictionary <string, string> {
                            { "{{push_title}}", "" },
                            { "{{iOS_Nickname}}", userName },
                            { "{{Android_Nickname}}", userName },
                            { "{{App_Nickname}}", userName },
                            { "{{articleid}}", $"{articleid}" },
                        }),
                        DeviceType = Service.Push.Models.Push.DeviceType.MessageBox
                    });

                    result.ThrowIfException(true);
                    return(result.Result);
                }
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
            }
            return(false);
        }
示例#7
0
        public JsonResult UploadImage()
        {
            var    resultStatus = false;
            string resultMsg    = string.Empty;

            if (Request.Files.Count > 0)
            {
                var Imgfile = Request.Files[0];
                try
                {
                    var buffer = new byte[Imgfile.ContentLength];
                    Imgfile.InputStream.Read(buffer, 0, buffer.Length);
                    var uploadResult = buffer.UpdateLoadImage();
                    resultStatus = uploadResult.Item1;
                    resultMsg    = uploadResult.Item2;
                }
                catch (Exception exp)
                {
                    WebLog.LogException(exp);
                }
            }
            return(Json(new
            {
                Status = resultStatus,
                ImgUrl = resultMsg
            }));
        }
示例#8
0
 /// <summary>
 /// 获取用户信息by phone
 /// </summary>
 /// <param name="Phone"></param>
 /// <returns></returns>
 public static User GetUserByPhone(string Phone)
 {
     try
     {
         using (var client = new UserAccountClient())
         {
             var clientResult = client.GetUserByMobile(Phone);
             if (clientResult.Success && clientResult.Result != null)
             {
                 Log(UserActionEnum.Login, clientResult.Result.UserId, "chexian_获取用户信息,GetUserByPhone:成功");
                 return(clientResult.Result);
             }
             else
             {
                 Log(UserActionEnum.Login, null, "chexian_获取用户信息,GetUserByMobileAsync:失败");
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         WebLog.LogException(ex);
         return(null);
     }
 }
示例#9
0
        /// <summary>远程保存文件</summary>
        /// <param name="file">文件</param>
        /// <param name="filePath">文件路径。访问路径为http://image.tuhu.test+路径</param>
        /// <param name="maxWidth">图片最大宽,最小值为100。如果不限则为0</param>
        /// <param name="maxHeight">图片最大高,最小值为100。如果不限则为0</param>
        /// <returns>1:保存成功;0:没有保存;-1:没有路径;-2:内容为空;-3:maxWidth和maxHeight最少值为100</returns>
        public static string UploadImage(HttpPostedFileBase file, string filePath, short maxWidth, short maxHeight)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(filePath))
                {
                    return(null);
                }

                if (file == null || file.ContentLength < 1)
                {
                    return(null);
                }

                if (maxWidth != 0 && maxHeight != 0 && (maxWidth < 100 || maxHeight < 100))
                {
                    return(null);
                }

                using (var client = new FileUploadClient())
                {
                    var buffer = new byte[file.ContentLength];
                    file.InputStream.Read(buffer, 0, buffer.Length);

                    var result = client.UploadImage(new ImageUploadRequest(filePath, buffer, maxWidth, maxHeight));
                    result.ThrowIfException(true);
                    return(result.Result);
                }
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
            }
            return(null);
        }
示例#10
0
 public ActionResult SendMessage(string phone)
 {
     try
     {
         if (string.IsNullOrEmpty(phone) || !ValidatePhone(phone))
         {
             return(Json(new { isSuccess = false, status = EntryStatus.FormatError }, JsonRequestBehavior.AllowGet));
         }
         var vCode = GeneraCode();
         using (var client = new SmsClient())
         {
             client.SendVerificationCode(new SendVerificationCodeRequest
             {
                 Cellphone        = phone,
                 Host             = Request.Url.Host,
                 UserIp           = Request.UserIp(),
                 VerificationCode = vCode
             }).ThrowIfException(true);
         }
         var result = SetVcode(phone, vCode);
         return(Json(new { isSuccess = result }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         WebLog.LogException(ex);
         return(Json(new { isSuccess = false, status = EntryStatus.EntryError }, JsonRequestBehavior.AllowGet));
     }
 }
示例#11
0
 /// <summary>
 /// 报名参加
 /// </summary>
 /// <returns></returns>
 public static EntryStatus Entry(string phone)
 {
     try
     {
         //如果手机号已注册
         if (GetUserByPhone(phone) != null)
         {
             return(Insert(phone));
         }
         else
         {
             //如果手机号注册成功并且报名成功
             if (CreateUser(phone) != null && Insert(phone) == EntryStatus.Success)
             {
                 return(EntryStatus.RegisterASuccess);
             }
             else
             {
                 return(EntryStatus.EntryError);
             }
         }
     }
     catch (Exception ex)
     {
         WebLog.LogException(ex);
         return(EntryStatus.EntryError);
     }
 }
        public ViewResult ChangeMobileBindingOnDate(string SearchStartDate, string SearchEndDate)
        {
            IEnumerable <UserChangeBindMobileLog> changeMobileBindingLogs = new List <UserChangeBindMobileLog>();

            if (!string.IsNullOrEmpty(SearchStartDate) && !string.IsNullOrEmpty(SearchEndDate))
            {
                DateTime startTime, endTime;
                if (DateTime.TryParse(SearchStartDate, out startTime) && DateTime.TryParse(SearchEndDate, out endTime))
                {
                    try
                    {
                        using (var client = new UserAccountClient())
                        {
                            var result = client.QueryChangeBindMobileLogByDateTime(startTime, endTime);
                            result.ThrowIfException(true);
                            if (result.Success && result.Result != null)
                            {
                                changeMobileBindingLogs = result.Result;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        WebLog.LogException(ex);
                    }
                }
            }
            ViewBag.SearchStartDate = SearchStartDate;
            ViewBag.SearchEndDate   = SearchEndDate;
            return(View("ChangeMobileBinding", changeMobileBindingLogs));
        }
        public ViewResult ChangeMobileBindingOnMobile(string mobileToFind)
        {
            IEnumerable <UserChangeBindMobileLog> changeMobileBindingLogs = new List <UserChangeBindMobileLog>();

            if (!string.IsNullOrEmpty(mobileToFind))
            {
                try
                {
                    using (var client = new UserAccountClient())
                    {
                        var result = client.QueryChangeBindMobileLogByMobile(mobileToFind);
                        result.ThrowIfException(true);
                        if (result.Success && result.Result != null)
                        {
                            changeMobileBindingLogs = result.Result;
                        }
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
            }
            ViewBag.mobileToFind = mobileToFind;
            return(View("ChangeMobileBinding", changeMobileBindingLogs));
        }
        public async Task <JsonResult> SubmitChangeBindingAction(string oldNumber, string newNumber, string vCode)
        {
            try
            {
                using (var client = new UserAccountClient())
                {
                    var result = await client.ChangeBindMobileActionAsync(new UserChangeBindMobileAction
                    {
                        Operator         = User.Identity.Name,
                        SourceBindMobile = oldNumber,
                        TargetBindMobile = newNumber,
                        TargetMobileCode = vCode
                    });

                    result.ThrowIfException(false);
                    if (result.Success && result.Result)
                    {
                        var flag    = false;
                        var smsBody = "您的途虎账号已经与本手机号解绑, 如非本人操作请联系客服:400-111-8868【途虎养车】";
                        // 提交验证码
                        await Business.Sms.SmsManager.SubmitVerficationCodeAsync(newNumber, vCode);

                        // 模板:您的途虎账号已经与本手机号解绑, 如非本人操作请联系客服:400-111-8868
                        if (await Business.Sms.SmsManager.SendTemplateSmsMessageAsync(oldNumber, 75))
                        {
                            flag = true;
                        }

                        await client.LogChangeBindMobileActionAsync(
                            new UserChangeBindMobileLog
                        {
                            SourceBindMobile = oldNumber,
                            TargetBindMobile = newNumber,
                            Operator         = User.Identity.Name,
                            OperateStatus    = true,
                            CreatedTime      = DateTime.Now
                        });

                        return(flag ? Json("绑定成功但发送确认短信失败") : Json("绑定成功"));
                    }
                    await client.LogChangeBindMobileActionAsync(
                        new UserChangeBindMobileLog
                    {
                        SourceBindMobile = oldNumber,
                        TargetBindMobile = newNumber,
                        Operator         = User.Identity.Name,
                        OperateStatus    = false,
                        FailReason       = result.ErrorMessage,
                        CreatedTime      = DateTime.Now
                    });

                    return(Json(result.ErrorMessage));
                }
            }
            catch (Exception exception)
            {
                WebLog.LogException(exception);
                return(Json("未知异常"));
            }
        }
示例#15
0
        public JsonResult LogOffUserById(string userId, string mobile)
        {
            int flag = 0;

            if (!string.IsNullOrWhiteSpace(userId) && !string.IsNullOrWhiteSpace(mobile))
            {
                Guid uId = new Guid(userId);
                try
                {
                    var existYlh     = false;
                    var logoffResult = false;
                    using (var ylhClient = new YLHUserAccountClient())
                    {
                        var ylhUser = ylhClient.GetYLHUserInfoByMobile(mobile);
                        ylhUser.ThrowIfException(true);
                        if (ylhUser.Result != null && ylhUser.Result.UserId != Guid.Empty)
                        {
                            existYlh = true;
                        }
                    }

                    if (existYlh)
                    {
                        flag = -1;
                    }
                    else
                    {
                        using (var client = new UserAccountClient())
                        {
                            var logoff = client.LogOffUser(uId);
                            logoff.ThrowIfException(true);
                            logoffResult = logoff.Result;
                        }
                        if (logoffResult)
                        {
                            flag = 1;
                        }

                        using (var useraccoutClient = new UserAccountClient())
                        {
                            var insertLog = useraccoutClient.LogUserAction(new UserLog
                            {
                                Action      = UserActionEnum.LogOff,
                                CreatedTime = DateTime.Now,
                                UserId      = uId,
                                ChannelIn   = nameof(ChannelIn.H5),
                                Content     = ThreadIdentity.Operator.Name + "在Setting站点内手动注销该用户"
                            });
                            insertLog.ThrowIfException(true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
            }
            return(Json(flag));
        }
示例#16
0
        public void OnException(ExceptionContext filterContext)
        {
            WebLog.LogException(filterContext.Exception);
            var result = new JsonResult();

            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            result.Data                    = new { success = false, msg = filterContext.Exception.Message + ":" + filterContext.Exception.StackTrace, InnerException = filterContext.Exception.InnerException != null ? filterContext.Exception.InnerException.Message : string.Empty };
            filterContext.Result           = result;
            filterContext.ExceptionHandled = true;
        }
示例#17
0
        /// <summary>
        /// App首页瀑布流文章
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task <ActionResult> SelectArticleForAppHomePage(int pageIndex = 1, int pageSize = 30)
        {
            var dic = new Dictionary <string, object>();

            try
            {
                var versionNumber = Request.Headers.Get("VersionCode");
                var version       = Request.Headers.Get("version");

                var pager = new PagerModel {
                    CurrentPage = pageIndex, PageSize = pageSize
                };
                List <DiscoveryModel> articles = null;
                using (var reclient = CacheHelper.CreateCacheClient("SelectArticleForAppHomePage"))
                {
                    var result = await reclient.GetOrSetAsync("AppHomePage/" + pageIndex + "/" + pageSize, () => DiscoverBLL.SelectArticleForAppHomePage(pager), TimeSpan.FromHours(2));

                    if (result.Value != null)
                    {
                        articles = result.Value;
                    }
                    else
                    {
                        articles = await DiscoverBLL.SelectArticleForAppHomePage(pager);
                    }
                }
                pager.TotalItem = 100;
                dic.Add("Code", "1");
                dic.Add("TotalPage", pager.TotalPage);
                dic.Add("TotalCount", pager.TotalItem);
                var articleShowMode = await DistributedCacheHelper.SelectArticleShowMode();

                dic.Add("Articles", articles.Select(article => new
                {
                    ArticleId       = article.PKID,
                    Image           = JsonConvert.DeserializeObject <List <ShowImageModel> >(article.ShowImages).FirstOrDefault().BImage,
                    Title           = article.SmallTitle,
                    ArticleShowMode = articleShowMode,
                    //ContentUrl = ((string.IsNullOrEmpty(versionNumber) == false && (string.Compare(versionNumber, "50") < 0) ||
                    //    (string.IsNullOrEmpty(version) == false && string.Compare(version, "iOS 3.4.5") < 0))) ? article.ContentUrl : DiscoverySite + "/Article/Detail?Id=" + article.RelatedArticleId,
                    //URL = ((string.IsNullOrEmpty(versionNumber) == false && (string.Compare(versionNumber, "50") < 0) ||
                    //    (string.IsNullOrEmpty(version) == false && string.Compare(version, "iOS 3.4.5") < 0))) ? article.ContentUrl : DiscoverySite + "/Article/Detail?Id=" + article.RelatedArticleId
                    ContentUrl = (articleShowMode == "New" || article.Type == 5) ? DomainConfig.FaXian + " /react/findDetail/?bgColor=%23ffffff&textColor=%23333333&id=" + article.PKID : article.ContentUrl,
                    URL        = (articleShowMode == "New" || article.Type == 5) ? DomainConfig.FaXian + "/react/findDetail/?bgColor=%23ffffff&textColor=%23333333&id=" + article.PKID : article.ContentUrl
                }));
            }
            catch (Exception ex)
            {
                WebLog.LogException("App首页瀑布流文章", ex);
                dic.Clear();
                dic.Add("Code", "0");
            }
            return(Json(dic, JsonRequestBehavior.AllowGet));
        }
示例#18
0
 public RedisController()
 {
     try
     {
         ra = RedisAdapter.Create(this.GetType().Name);
     }
     catch (Exception ex)
     {
         lasterror = ex;
         WebLog.LogException(ex);
     }
 }
示例#19
0
        public static async Task <int> CreateOrUpdateTemplateAsync(PushTemplate template)
        {
            try
            {
#if DEBUG
                template.CreateUser = "******";
#endif
                if (template.PKID != 0)
                {
                    using (var client = new Tuhu.Service.Push.TemplatePushClient())
                    {
                        var result = await client.UpdatePushTemplateAsync(template);

                        result.ThrowIfException(true);
                        var datas = result.Result;

                        return(datas);
                    }
                }
                else
                {
                    if (template.BatchID != 0)
                    {
                        var temp = await SelectPushTemplateByBatchIDAndDeviceTypeAsync(template.BatchID, template.DeviceType);

                        if (temp != null)
                        {
                            template.PKID = temp.PKID;
                            return(await CreateOrUpdateTemplateAsync(template));
                        }
                    }
                    if (string.IsNullOrEmpty(template.PlanName))
                    {
                        template.PlanName = "计划名称";
                    }
                    using (var client = new Tuhu.Service.Push.TemplatePushClient())
                    {
                        var result = await client.CreateTemplateAsync(template);

                        result.ThrowIfException(true);
                        var datas = result.Result;

                        return(datas);
                    }
                }
            }
            catch (System.Exception ex)
            {
                WebLog.LogException(ex);
                return(0);
            }
        }
        public ActionResult DeleteAlipayBaoYangItem(int pkid)
        {
            bool flag = false;

            try
            {
                AliPayBaoYangManage.DeleteAliPayBaoYangItem(pkid);
                flag = true;
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
            }
            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
示例#21
0
        public ActionResult DeleteSupplier(int pkid)
        {
            bool flag = false;

            try
            {
                WeiXinCardManager.DeleteWeiXinCardSupplier(pkid);
                flag = true;
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
            }
            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
示例#22
0
        public void OnException(ExceptionContext filterContext)
        {
            WebLog.LogException(filterContext.Exception);
            var result = new JsonResult();

            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            result.Data = new
            {
                Success         = false,
                Message         = filterContext.Exception.Message,
                InnerExcception = filterContext.Exception.InnerException,
                StackTrace      = filterContext.Exception.StackTrace,
                Data            = filterContext.Exception.Data
            };
            filterContext.Result           = result;
            filterContext.ExceptionHandled = true;
        }
示例#23
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);

            var exception = Server.GetLastError();

            if (exception != null)
            {
                var httpException = exception is HttpException ? exception as HttpException : new HttpException(null, exception.InnerException ?? exception);

                StatusCode = httpException.GetHttpCode();
                exception  = exception.InnerException ?? exception;

                if (Request.IsAjaxRequest() && Context.IsCustomErrorEnabled)
                {
                    if (StatusCode == 500)
                    {
                        var exceptionID = WebLog.LogException(exception);
                        Context.Items["_ExceptionID_"] = exceptionID;

                        Response.Write("{ExceptionID:" + exceptionID + "}");
                    }
                    Response.End();
                }
                else if (StatusCode != 404)
                {
                    Context.Items["_ExceptionID_"] = WebLog.LogException(exception);
                }
            }
            else
            {
                int statusCode;
                if (int.TryParse(Request.QueryString["StatusCode"], out statusCode) && statusCode >= 400)
                {
                    StatusCode = statusCode;
                }
                else
                {
                    StatusCode = 500;
                }
            }

            Response.TrySkipIisCustomErrors = true;
            Response.StatusCode             = StatusCode;
        }
示例#24
0
        public static async Task <bool> ForumSynchronousData(string userHeard, string phone, string userName, string userId, string forumId, string conent, string commentImage, int userIdentity, int commentId, int topicCommentSouceId)
        {
            TimeSpan ts        = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            var      timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();
            //var sign = SecurityHelper.Hash($"lietome@2017!{timestamp}", Encoding.UTF8, true);
            var sign = SecurityHelper.GetHashAlgorithm(HashType.Md5).ComputeHash($"lietome@2017!{timestamp}", Encoding.UTF8, true);

            using (var client = new HttpClient())
            {
                try
                {
                    var result = await client.PostAsFormAsync <string>($"https://hushuoapi.tuhu.cn/v1/replies/sync?timestamp={timestamp}&sign={sign}",
                                                                       new SortedDictionary <string, string>
                    {
                        ["avatar"]           = userHeard,
                        ["mobile"]           = phone,
                        ["tuhu_name"]        = userName,
                        ["tuhu_userid"]      = userId,
                        ["topic_id"]         = forumId,
                        ["body"]             = conent,
                        ["image_urls"]       = commentImage,
                        ["tuhu_user_type"]   = userIdentity.ToString(),
                        ["jishi_comment_id"] = commentId.ToString(),
                        ["source_id"]        = topicCommentSouceId.ToString()
                    });

                    var jObj = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(result);
                    if (jObj.Value <int>("code") == 1)
                    {
                        var replyId = jObj.Value <int>("replyId");
                        if (replyId > 0)
                        {
                            await DiscoverBLL.InsertTopicCommentSouceIdById(commentId, replyId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
                return(true);
            }
        }
示例#25
0
        /// <summary>
        /// 查询多个产品(有缓存)
        /// </summary>
        /// <param name="pids"></param>
        /// <returns></returns>
        public static async Task <IEnumerable <SkuProductDetailModel> > SelectSkuProductListByPidsAsync(IEnumerable <string> pids)
        {
            IEnumerable <SkuProductDetailModel> products = null;

            try
            {
                using (var client = new ProductClient())
                {
                    var result = await client.SelectSkuProductListByPidsAsync(pids.Distinct().ToList());

                    result.ThrowIfException(true);
                    products = result.Result;
                }
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
            }
            return(products ?? new SkuProductDetailModel[0]);
        }
示例#26
0
        public JsonResult LogOutUserById(string userId)
        {
            bool flag = false;

            if (!string.IsNullOrWhiteSpace(userId))
            {
                Guid uId = new Guid(userId);
                try
                {
                    var cleanTokenResult = 0;
                    using (var client = new AccessTokenClient())
                    {
                        var result = client.RemoveAll(uId, "Setting站点工具登出");
                        result.ThrowIfException(true);
                        cleanTokenResult = result.Result;
                    }
                    if (cleanTokenResult >= 0)
                    {
                        flag = true;
                    }

                    using (var useraccoutClient = new UserAccountClient())
                    {
                        var insertLog = useraccoutClient.LogUserAction(new UserLog
                        {
                            Action      = UserActionEnum.LogOut,
                            CreatedTime = DateTime.Now,
                            UserId      = uId,
                            ChannelIn   = nameof(ChannelIn.H5),
                            Content     = "Setting站点内手动登出该用户"
                        });
                        insertLog.ThrowIfException(true);
                    }
                }
                catch (Exception ex)
                {
                    WebLog.LogException(ex);
                }
            }
            return(Json(flag));
        }
        private static async Task <string> GenerateVerificationCode(string phoneNumber, UserActionEnum userAction)
        {
            try
            {
                using (var client = new UserAccountClient())
                {
                    var result = await client.GenerateVerificationCodeAsync(phoneNumber, userAction);

                    result.ThrowIfException(true);
                    if (result.Success)
                    {
                        return(result.Result);
                    }
                }
            }
            catch (Exception exception)
            {
                WebLog.LogException(exception);
            }
            return(null);
        }
        public override void OnException(ExceptionContext filterContext)
        {
            if (filterContext == null)
            {
                throw new ArgumentNullException("filterContext");
            }

            if (!filterContext.IsChildAction && (!filterContext.ExceptionHandled && filterContext.HttpContext.IsCustomErrorEnabled))
            {
                var innerException = filterContext.Exception;

                if ((new HttpException(null, innerException).GetHttpCode() == 500) && this.ExceptionType.IsInstanceOfType(innerException))
                {
                    if (innerException.Message == "Additional text encountered after finished reading JSON content: ,. Path '', line 1, position 452.")
                    {
                    }
                    else
                    {
                        try {
                            WebLog.LogException(innerException);
                        } catch (Exception ex)
                        {
                        }
                    }


                    filterContext.Result = new JavaScriptResult {
                        Script = "{\"Code\":\"0\",\"Message\":\"服务器忙\",\"message\":\"" + innerException.Message + "\"}"
                    };
                    filterContext.ExceptionHandled = true;
                    filterContext.HttpContext.Response.Clear();
                    filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
                    try
                    {
                        filterContext.HttpContext.Response.StatusCode = 500;
                    }
                    catch { }
                }
            }
        }
        public ActionResult AddAlipayBaoYangItem(AliPayBaoYangItem item)
        {
            bool flag = false;

            try
            {
                List <AliPayBaoYangItem> items = AliPayBaoYangManage.GetAliPayBaoYangItem(-1);
                if (items != null)
                {
                    if (!items.Where(q => q != null).Any(p => p.KeyWord.Equals(item.KeyWord, StringComparison.OrdinalIgnoreCase)))
                    {
                        AliPayBaoYangManage.SaveAliPayBaoYangItem(item);
                        flag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                WebLog.LogException(ex);
            }
            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
示例#30
0
 /// <summary>
 /// 从Redis中获取验证码
 /// </summary>
 /// <param name="phone"></param>
 /// <returns></returns>
 private string GetReVCode(string phone)
 {
     try
     {
         using (var reclient = CacheHelper.CreateCacheClient("Che_Xian_Cache"))
         {
             var result = reclient.Get <string>(_cachePrefix + phone);
             if (result.Success == true && result.Exception == null)
             {
                 return(result.Value);
             }
             else
             {
                 return(string.Empty);
             }
         }
     }
     catch (Exception ex)
     {
         WebLog.LogException(ex);
         return(string.Empty);
     }
 }