private void SaveServiceMySqlConnection(string configPath) { try { if (System.IO.File.Exists(configPath)) { var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(configPath); // 写入数据库连接信息 if (config.AppSettings.Settings["CurDomainUrl"] != null) { config.AppSettings.Settings["CurDomainUrl"].Value = CurrentUrlHelper.CurrentUrl(); } if (config.ConnectionStrings.ConnectionStrings["mysql"] != null) { config.ConnectionStrings.ConnectionStrings["mysql"].ConnectionString = GetSimpleConnectionString(); } config.Save(); } } catch (Exception ex) { Core.Log.Error("设置服务数据库链接异常:" + ex.Message); } }
public JsonResult List(long?categoryId, string titleKeyWords, int rows, int page, string Sort, bool?isAsc) { var articles = _iArticleService.Find(categoryId, titleKeyWords, rows, page, Sort: Sort, isAsc: isAsc); string host = CurrentUrlHelper.CurrentUrl(); string urltmp = string.Format(@"{0}{1}/", host, Url.Action("Details", "Article", new { Area = "Web" })); ////如果未开启PC端授权,则只保留平台公告分类数据(FG:无平台公告分类) //if (!SiteSettingApplication.SiteSettings.IsOpenPC ) //{ // articles.Models.RemoveAll(p => !p.ArticleCategoryInfo.Name.Contains("平台公告")); //} var categories = _iArticleCategoryService.GetCategories(); var articleModels = articles.Models.Select(item => new { id = item.Id, categoryId = item.CategoryId, categoryName = categories.FirstOrDefault(p => p.Id == item.CategoryId)?.Name ?? string.Empty, isShow = item.IsRelease, title = item.Title, displaySequence = item.DisplaySequence, showurl = urltmp + item.Id.ToString(), addDate = item.AddDate.ToString("yyyy-MM-dd HH:mm:ss") }); var data = new { rows = articleModels, total = articles.Total }; return(Json(data)); }
private bool SaveConfig(out string errorMsg) { try { Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); // 删除安装标识配置节 config.AppSettings.Settings["IsInstalled"].Value = "true"; //写入当前网址 var curhttp = System.Web.HttpContext.Current; config.AppSettings.Settings["CurDomainUrl"].Value = CurrentUrlHelper.CurrentUrl(); // 写入数据库连接信息 //config.ConnectionStrings.ConnectionStrings["Entities"].ConnectionString = GetEFConnectionString(); config.ConnectionStrings.ConnectionStrings["mysql"].ConnectionString = GetSimpleConnectionString(); config.Save(); errorMsg = null; return(true); } catch (Exception ex) { errorMsg = ex.Message; return(false); } }
private string GetQRCode(string verificationCode) { string qrCodeImagePath = string.Empty; Image qrcode = Core.Helper.QRCodeHelper.Create(verificationCode); string fileName = DateTime.Now.ToString("yyMMddHHmmssffffff") + ".jpg"; qrCodeImagePath = CurrentUrlHelper.CurrentUrl() + "/temp/" + fileName; qrcode.Save(HttpContext.Current.Server.MapPath("~/temp/") + fileName); return(qrCodeImagePath); }
public ActionResult HasReceive(long id, string openId = "", long grantid = 0, string wxhead = "", string host = "") //已领取过 { host = CurrentUrlHelper.CurrentUrl(); ShopBonusDataModel dataModel = new ShopBonusDataModel(); dataModel.GrantId = grantid; dataModel.ShareHref = host + "/m-weixin/shopbonus/index/" + grantid.ToString(); dataModel.OpenId = openId; dataModel.HeadImg = wxhead; ShopBonusModel model = new ShopBonusModel(this._bonusService.GetShopBonus(id)); dataModel.ShopAddress = GetShopAddress(model.ShopId); ViewBag.DataModel = dataModel; model.ShareImg = host + model.ShareImg; return(View(model)); }
private List <string> ReplaceImage(string content, ProductInfo.VirtualProductItemType type) { if (type != ProductInfo.VirtualProductItemType.Picture) { return new List <string>() { content } } ; List <string> list = content.Split(',').ToList(); return(list.Select(a => a = CurrentUrlHelper.CurrentUrl() + a).ToList()); } }
private string GetQRCode(string verificationCode) { string qrCodeImagePath = string.Empty; Image qrcode = Core.Helper.QRCodeHelper.Create(verificationCode); string fileName = DateTime.Now.ToString("yyMMddHHmmssffffff") + ".jpg"; qrCodeImagePath = CurrentUrlHelper.CurrentUrl() + "/temp/" + fileName; // qrcode.Save(HttpContext.Current.Server.MapPath("~/temp/") + fileName); var env = EngineContext.Current.Resolve <IWebHostEnvironment>(); qrcode.Save(env.ContentRootPath + "/temp/" + fileName); return(qrCodeImagePath); }
public JsonResult List(int page, int rows) { var topics = _iTopicService.GetTopics(page, rows); var curUrl = CurrentUrlHelper.CurrentUrl(); var list = new { rows = topics.Models.Select(item => new { id = item.Id, name = item.Name, url = curUrl + "/topic/detail/" + item.Id, IsRecommend = item.IsRecommend }), total = topics.Total }; return(Json(list)); }
public JsonResult SendGift(long id, string expname, string expnum) { Result result = new Result(); _iGiftsOrderService.SendGood(id, expname, expnum); string host = CurrentUrlHelper.CurrentUrl(); var returnurl = String.Format("{0}/Common/ExpressData/SaveExpressData", host); var key = SiteSettingApplication.SiteSettings.Kuaidi100Key; if (!string.IsNullOrEmpty(key)) { Task.Factory.StartNew(() => ServiceApplication.Create <IExpressService>().SubscribeExpress100(expname, expnum, key, string.Empty, returnurl)); } result.success = true; result.status = 1; result.msg = "发货成功"; return(Json(result)); }
public ActionResult Completed(long id, string openId = "", decimal price = 0, string user = "", long grantid = 0, long rid = 0, string wxhead = "", string host = "") { host = CurrentUrlHelper.CurrentUrl(); ShopBonusDataModel dataModel = new ShopBonusDataModel(); ShopBonusModel model = new ShopBonusModel(this._bonusService.GetShopBonus(id)); var shop = ShopApplication.GetShop(model.ShopId); dataModel.GrantId = grantid; dataModel.ShareHref = host + "/m-weixin/shopbonus/index/" + grantid.ToString(); dataModel.HeadImg = wxhead; //dataModel.HeadImg = Mall.Core.MallIO.GetImagePath(dataModel.HeadImg); dataModel.ShopAddress = GetShopAddress(model.ShopId); dataModel.UserName = user; dataModel.Price = price; dataModel.OpenId = openId; dataModel.ShopName = shop.ShopName; ViewBag.DataModel = dataModel; model.ShareImg = MallIO.GetRomoteImagePath(model.ShareImg); if (!string.IsNullOrWhiteSpace(model.ShareImg)) { if (model.ShareImg.Substring(0, 4) != "http") { model.ShareImg = host + model.ShareImg; } } model.ReceiveId = rid; #region 步微信前信息准备 if (model.SynchronizeCard == true && this.PlatformType == PlatformType.WeiXin) { model.WXJSInfo = _iWXCardService.GetSyncWeiXin(id, rid, ThisCouponType, Request.GetDisplayUrl()); if (model.WXJSInfo != null) { model.IsShowSyncWeiXin = true; //model.WXJSCardInfo = ser_wxcard.GetJSWeiXinCard(id, rid, ThisCouponType); //同步方式有重复留的Bug } } #endregion return(View(model)); }
private bool SaveConfig(out string errorMsg) { try { /* * Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); * * * * // 删除安装标识配置节 * config.AppSettings.Settings["IsInstalled"].Value = "true"; * * //写入当前网址 * var curhttp = HttpContext; * config.AppSettings.Settings["CurDomainUrl"].Value = CurrentUrlHelper.CurrentUrl(); * * // 写入数据库连接信息 * * //config.ConnectionStrings.ConnectionStrings["Entities"].ConnectionString = GetEFConnectionString(); * config.ConnectionStrings.ConnectionStrings["mysql"].ConnectionString = GetSimpleConnectionString(); * config.Save(); * */ CommonHelper.AddOrUpdateAppSetting <bool>("Mall:isIntalled", true); CommonHelper.AddOrUpdateAppSetting <string>("Mall:CurDomainUrl", CurrentUrlHelper.CurrentUrl()); CommonHelper.AddOrUpdateAppSetting <string>("Mall:ConnectionString", GetSimpleConnectionString()); errorMsg = null; return(true); } catch (Exception ex) { errorMsg = ex.Message; return(false); } }
/// <summary> /// 微商城模板管理 /// </summary> /// <returns></returns> public ActionResult VHomepage() { string crrentTemplateName = "t1"; var curr = _iTemplateSettingsService.GetCurrentTemplate(0); if (null != curr) { crrentTemplateName = curr.CurrentTemplateName; } var helper = new GalleryHelper(); var themes = helper.LoadThemes(); var CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals(crrentTemplateName.ToLower())); if (CurTemplateObj == null) { CurTemplateObj = themes.FirstOrDefault(t => t.ThemeName.Equals("t1")); } if (CurTemplateObj == null) { throw new MallException("错误的模板:" + crrentTemplateName); } ViewBag.CurrentTemplate = CurTemplateObj; #region 二维码图片 string qrCodeImagePath = string.Empty; string url = CurrentUrlHelper.CurrentUrl(); Bitmap map; map = Core.Helper.QRCodeHelper.Create(url + "/m-wap"); MemoryStream ms = new MemoryStream(); map.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); qrCodeImagePath = "data:image/gif;base64," + Convert.ToBase64String(ms.ToArray()); // 将图片内存流转成base64,图片以DataURI形式显示 ms.Dispose(); ViewBag.CurUrl = url; ViewBag.QrCodeImagePath = qrCodeImagePath; #endregion return(View(themes.Where(t => t.ThemeName != crrentTemplateName.ToLower()).ToList())); }
public ActionResult Index(long id) { if (this.PlatformType != Core.PlatformType.WeiXin) { Log.Info(this.PlatformType.ToString()); return(Content("只能在微信端访问")); } var bonus = this._bonusService.GetByGrantId(id); if (bonus == null) { Log.Info("红包失踪,id = " + id); return(Redirect("/m-weixin/ShopBonus/Invalidtwo")); } //授权获取openid相关 string code = HttpContext.Request.Query["code"].ToString(); OAuthAccessTokenResult wxOpenInfo = null; var settings = SiteSettingApplication.SiteSettings; if (string.IsNullOrEmpty(code)) { string selfAddress = Request.GetDisplayUrl(); string url = OAuthApi.GetAuthorizeUrl(settings.WeixinAppId.Trim(), selfAddress, "STATE", Senparc.Weixin.MP.OAuthScope.snsapi_userinfo, "code"); return(Redirect(url)); } else { try { wxOpenInfo = OAuthApi.GetAccessToken(settings.WeixinAppId.Trim(), settings.WeixinAppSecret.Trim(), code, "authorization_code"); } catch (Exception e) { Exception innerEx = e.InnerException == null ? e : e.InnerException; Log.Error(innerEx.Message); if (innerEx.Message.IndexOf("code been used") != -1) { return(Content("该红包已被领取过")); } else { return(Content(innerEx.Message)); } } } OAuthUserInfo wxUserInfo = OAuthApi.GetUserInfo(wxOpenInfo.access_token, wxOpenInfo.openid); var openId = wxOpenInfo.openid; if (!string.IsNullOrEmpty(wxUserInfo.unionid)) { var moInfo = MemberApplication.GetMemberOpenIdInfoByOpenIdOrUnionId(openId, wxUserInfo.unionid); if (moInfo != null && !string.IsNullOrEmpty(moInfo.OpenId)) { openId = moInfo.OpenId; } } ShopBonusModel model = new ShopBonusModel(bonus); if (model.DateEnd <= DateTime.Now || model.IsInvalid || model.BonusDateEnd <= DateTime.Now) //过期、失效 { return(Redirect("/m-weixin/ShopBonus/Expired/" + model.Id + "?openId=" + openId + "&grantid=" + id + "&wxhead=" + wxUserInfo.headimgurl)); } else if (model.DateStart > DateTime.Now) // 未开始 { return(Redirect("/m-weixin/ShopBonus/NotStart/" + model.Id)); } ShopReceiveModel obj = (ShopReceiveModel)this._bonusService.Receive(id, openId, wxUserInfo.headimgurl, wxUserInfo.nickname); //防两次刷新 string cacheDName = "WXSB_U" + openId + "_D" + id.ToString(); if (obj.State == ShopReceiveStatus.Receive) { var _tmp = Cache.Get <ShopReceiveModel>(cacheDName); if (_tmp != null && _tmp.State == ShopReceiveStatus.CanReceive) { obj = _tmp; } } var host = CurrentUrlHelper.CurrentUrl(); if (obj.State == ShopReceiveStatus.CanReceive) { Cache.Insert <ShopReceiveModel>(cacheDName, obj, 2); return(Redirect("/m-weixin/ShopBonus/Completed/" + model.Id + "?openId=" + openId + "&price=" + obj.Price + "&user="******"&grantid=" + id + "&rid=" + obj.Id + "&wxhead=" + wxUserInfo.headimgurl + "&host=" + host)); } else if (obj.State == ShopReceiveStatus.CanReceiveNotUser) { return(Redirect("/m-weixin/ShopBonus/CompletedNotUser/" + model.Id + "?openId=" + openId + "&price=" + obj.Price + "&grantid=" + id + "&rid=" + obj.Id + "&wxhead=" + wxUserInfo.headimgurl + "&host=" + host)); } else if (obj.State == ShopReceiveStatus.Receive) { return(Redirect("/m-weixin/ShopBonus/HasReceive/" + model.Id + "?openId=" + openId + "&grantid=" + id + "&wxhead=" + wxUserInfo.headimgurl + "&host=" + host)); } else if (obj.State == ShopReceiveStatus.HaveNot) { return(Redirect("/m-weixin/ShopBonus/HaveNot/" + model.Id + "?openId=" + openId + "&grantid=" + id + "&wxhead=" + wxUserInfo.headimgurl)); } else if (obj.State == ShopReceiveStatus.Invalid) { return(Redirect("/m-weixin/ShopBonus/Expired/" + model.Id + "?openId=" + openId + "&grantid=" + id + "&wxhead=" + wxUserInfo.headimgurl)); } else { throw new Exception("领取发生异常"); } }
private string SendDaDaExpress(long orderId, long shopid, long sbid, bool isQueryOrder) { //Log.Error("达达发货ShopBranchOrder-01:orderId:" + orderId); var order = OrderApplication.GetOrder(orderId); if (order == null || order.ShopBranchId != sbid || order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery) { throw new HimallApiException("错误的订单编号"); } var dadaconfig = CityExpressConfigApplication.GetDaDaCityExpressConfig(shopid); if (!dadaconfig.IsEnable) { throw new HimallApiException("未开启同城合作物流"); } //Log.Error("达达发货ShopBranchOrder-02:OrderStatus:" + order.OrderStatus + "--RegionId:" + order.RegionId); if (order.ReceiveLatitude <= 0 || order.ReceiveLongitude <= 0) { throw new HimallApiException("未获取到客户收货地址坐标信息,无法使用该配送方式"); } var sbdata = ShopBranchApplication.GetShopBranchById(sbid); if (sbdata == null || string.IsNullOrWhiteSpace(sbdata.DaDaShopId)) { throw new HimallApiException("门店未在达达注册,或所在城市达达不支持配送,无法发单,请商家在后台进行设置"); } //Log.Error("达达发货ShopBranchOrder-03:Latitude:" + sbdata.DaDaShopId); string cityCode = ""; var _adregion = RegionApplication.GetRegion(order.RegionId); var _city = GetCity(_adregion); try { string cityJson = ExpressDaDaHelper.cityCodeList(shopid); var cityObj = JsonConvert.DeserializeObject(cityJson) as JObject; JArray citylist = (JArray)cityObj["result"]; foreach (JToken item in citylist) { if (_city.ShortName == item["cityName"].ToString()) { cityCode = item["cityCode"].ToString(); break; } } } catch { } //达达不支持的城市 if (cityCode == "") { throw new HimallApiException("配送范围超区,无法配送"); } string callback = CurrentUrlHelper.CurrentUrl() + "/pay/dadaOrderNotify/"; bool isreaddorder = (order.DadaStatus == DadaStatus.Cancel.GetHashCode()); if (isQueryOrder) { isreaddorder = false; } //Log.Error(DateTime.Now + "ShopBranchOrder-0:callback:" + callback + "|shopid:" + shopid + "|DaDaShopId:" + sbdata.DaDaShopId + "|orderId:" + order.Id + "|cityCode:" + cityCode + "|isreaddorder:" + isreaddorder); string json = ExpressDaDaHelper.addOrder(shopid, sbdata.DaDaShopId, order.Id.ToString() , cityCode, (double)order.TotalAmount, 0, ExpressDaDaHelper.DateTimeToUnixTimestamp(DateTime.Now.AddMinutes(15)) , order.ShipTo, order.Address, order.ReceiveLatitude, order.ReceiveLongitude , callback, order.CellPhone, order.CellPhone, isQueryDeliverFee: isQueryOrder , isReAddOrder: isreaddorder); //Log.Error(DateTime.Now + "达达发货ShopBranchOrder-1:json:" + json); return(json); }