コード例 #1
0
ファイル: WxMaterialData.cs プロジェクト: radtek/etowncode
 public int EditMaterial(WxMaterial material)
 {
     using (var helper = new SqlHelper())
     {
         var id = new InternalWxMaterial(helper).EditMaterial(material);
         return(id);
     }
 }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower();

            //根据域名读取商户ID,如果没有绑定域名直接跳转后台
            if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid
            {
                //先通过正则表达式获取COMid
                comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString());
                if (comid == 0)
                {
                    comid = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl).Comid;
                }
            }
            else
            {
                B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl);
                if (companyinfo != null)
                {
                    comid = companyinfo.Com_id;
                }
            }


            WxMaterialData wxdate = new WxMaterialData();

            aid = wxdate.FrowardingSetList(comid);
            if (aid != 0)
            {
                WxMaterial wxinfo = wxdate.GetWxMaterial(aid);
                if (wxinfo != null)
                {
                    wxTitle   = wxinfo.Title;
                    wxsummary = wxinfo.Summary;
                }
            }
        }
コード例 #3
0
 public async Task <ApiResult <string> > Add([FromBody] WxMaterial model)
 {
     return(await _meterialService.Add(model, null));
 }
コード例 #4
0
        public async Task <ApiResult <string> > PushMaterial([FromBody] WxMaterial model)
        {
            var res = new ApiResult <string>();

            var gzhModel = _settingService.GetModelAsync(m => m.Id == model.WxId).Result.data;
            var token    = WxTools.GetAccess(gzhModel.AppId, gzhModel.AppSecret);

            await _meterialService.Add(model, null);

            var articleList = new List <WxMeterArticle>();
            //定义标识,是否有素材没有上传成功
            var isUploadOk = true;
            //根据公众号查询所有
            var list = _meterialService.GetListAsync(m => m.WxId == model.WxId && m.Position == 1, m => m.AddDate, DbOrderEnum.Desc).Result.data;

            if (list.Count > 0)
            {
                //到微信服务端获得thumb_media_id
                foreach (var item in list)
                {
                    item.Position = 2;
                    if (!string.IsNullOrEmpty(item.TestJson))
                    {
                        var resList = JsonConvert.DeserializeObject <List <WxMaterial> >(item.TestJson);
                        foreach (var row in resList)
                        {
                            var fileExt = FileHelperCore.GetFileExtension(row.Img);
                            var path    = row.Img;
                            if (!path.ToLower().StartsWith("http") && !path.ToLower().StartsWith("https"))
                            {
                                path = FileHelperCore.MapPath("/wwwroot" + row.Img);
                            }
                            var resultJson = WxTools.UploadFile(token.access_token, path, fileExt);
                            if (resultJson.code == 200)
                            {
                                articleList.Add(new WxMeterArticle()
                                {
                                    title              = row.Title,
                                    thumb_media_id     = resultJson.media_id,
                                    author             = row.Author,
                                    digest             = row.Summary,
                                    content            = row.Content,
                                    content_source_url = row.Link
                                });
                            }
                            else
                            {
                                isUploadOk = false;
                            }
                        }
                    }
                }
            }
            if (!isUploadOk)
            {
                res.statusCode = 500;
                res.message    = "同步素材失败~";
                return(res);
            }

            var    postStr     = JsonConvert.SerializeObject(new { articles = articleList });
            var    url         = string.Format("https://api.weixin.qq.com/cgi-bin/material/add_news?access_token={0}", token.access_token);
            string resMewsJson = WxTools.PostResponse(url, postStr);

            if (resMewsJson.Contains("errcode"))
            {
                res.statusCode = 500;
                res.message    = "上传图文失败~";
                return(res);
            }
            //修改状态
            await _meterialService.UpdateAsync(list);

            return(res);
        }
コード例 #5
0
ファイル: WxMaterialController.cs プロジェクト: uvaa/ytjkb
 public async Task <IActionResult> Add([FromBody] WxMaterial model)
 {
     return(Ok(await _meterialService.Add(model, null)));
 }
コード例 #6
0
ファイル: Default.aspx.cs プロジェクト: radtek/etowncode
        protected void Page_Load(object sender, EventArgs e)
        {
            WxMaterialData Wx     = new WxMaterialData();
            WxMaterial     wmater = Wx.logGetidinfo(" SalePromoteTypeid !=4 order by operatime  desc ");

            int totalcount = 0;


            if (wmater != null)
            {
                Listtime = wmater.Operatime.ToString("yyyy-MM-dd");
            }


            ////判断如果是否为手机访问
            //if (detectmobilebrowser.HttpUserAgent(Request.ServerVariables["HTTP_USER_AGENT"]))
            //{
            //    if (Request["brow"]=="PC")//如果接收到传递PC访问则只PC版
            //    {
            //         Cookie.WriteCookie("Mobile_Brow_Set", "PC");
            //    }
            //
            //    //查看COOKIE 是否设定是否设定为PC
            //    if (Cookie.GetCookie("Mobile_Brow_Set") == "PC")
            //    {
            //    }
            //    else
            //    {
            //          Response.Redirect("/M/Default.aspx?brow=MO");
            //    }
            //}

            if (Session["AccountId"] != null)
            {
                //账户信息
                AccountId   = Int32.Parse(Session["AccountId"].ToString());
                AccountName = Session["AccountName"].ToString();
                AccountCard = Session["AccountCard"].ToString();
                RequestUrl  = Request.ServerVariables["SERVER_NAME"].ToLower();

                B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl);
                if (companyinfo != null)
                {
                    comid = companyinfo.Com_id;
                }

                if (comid != 101)
                {
                    Response.Redirect("/ui/shangjiaui/ProductList.aspx");
                }


                //会员信息
                B2bCrmData dateuser  = new B2bCrmData();
                B2b_crm    modeluser = dateuser.Readuser(AccountId, comid);

                if (modeluser != null)
                {
                    AccountWeixin = modeluser.Weixin;
                    AccountEmail  = modeluser.Email;
                    Accountphone  = modeluser.Phone;
                    Servercard    = modeluser.Servercard;
                    Imprest       = modeluser.Imprest;
                    Integral      = modeluser.Integral;
                    //密码
                    AccountPass = modeluser.Password1;
                    //微信关注
                    weixin = modeluser.Weixin == "" ? "未关注" : "已关注";
                }

                //渠道
                MemberChannelData channeldate = new MemberChannelData();

                //渠道信息
                Member_Channel channelmodel = channeldate.GetSelfChannelDetailByCardNo(AccountCard);
                if (channelmodel != null)
                {
                    channeltype = 1;
                    channelid   = channelmodel.Id;

                    RebateConsume = channelmodel.RebateConsume;
                    RebateOpen    = channelmodel.RebateOpen;
                    Opencardnum   = channelmodel.Opencardnum;
                    Firstdealnum  = channelmodel.Firstdealnum;
                    Summoney      = channelmodel.Summoney;
                }


                //服务专员信息,服务专员ID
                if (Servercard != 0)
                {
                    Member_Channel channelmode2 = channeldate.GetChannelDetail(Int32.Parse(Servercard.ToString()));
                    if (channelmode2 != null)
                    {
                        Servername   = channelmode2.Name;
                        Servermobile = channelmode2.Mobile;
                    }
                }

                //菜单项new WxSalePromoteTypeData()
                List <WxSalePromoteType> menulist = new WxSalePromoteTypeData().GetAllWxMaterialType(comid, out totalcount);

                if (comid == 101)
                {
                    List <WxSalePromoteType> list = new List <WxSalePromoteType>();
                    int[] i = { 0, 1, 2, 5, 12 };
                    foreach (int s in i)
                    {
                        WxSalePromoteType wxmaterial = new WxSalePromoteType();

                        wxmaterial.Id       = menulist[s].Id;
                        wxmaterial.Typename = menulist[s].Typename;
                        list.Add(wxmaterial);
                    }

                    menu.DataSource = list;
                    menu.DataBind();
                }
                else
                {
                    menu.DataSource = menulist;
                    menu.DataBind();
                }
            }
            else
            {
                Response.Redirect("/V/card.aspx");
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["AccountId"] != null)
            {
                WxMaterialData Wx     = new WxMaterialData();
                WxMaterial     wmater = Wx.logGetidinfo(" SalePromoteTypeid !=4 order by operatime  desc ");

                int totalcount = 0;


                if (wmater != null)
                {
                    Listtime = wmater.Operatime.ToString("yyyy-MM-dd");
                }

                //账户信息
                AccountId   = Int32.Parse(Session["AccountId"].ToString());
                AccountName = Session["AccountName"].ToString();
                AccountCard = Session["AccountCard"].ToString();
                RequestUrl  = Request.ServerVariables["SERVER_NAME"].ToLower();

                B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl);
                if (companyinfo != null)
                {
                    comid = companyinfo.Com_id;
                }

                //会员信息
                B2bCrmData dateuser  = new B2bCrmData();
                B2b_crm    modeluser = dateuser.Readuser(AccountId, comid);

                if (modeluser != null)
                {
                    AccountWeixin = modeluser.Weixin;
                    AccountEmail  = modeluser.Email;
                    Accountphone  = modeluser.Phone;
                    Servercard    = modeluser.Servercard;
                    Imprest       = modeluser.Imprest;
                    Integral      = modeluser.Integral;
                    //密码
                    AccountPass = modeluser.Password1;
                    //微信关注
                    weixin = modeluser.Weixin == "" ? "未关注" : "已关注";
                }

                //渠道
                MemberChannelData channeldate = new MemberChannelData();

                //渠道信息
                Member_Channel channelmodel = channeldate.GetSelfChannelDetailByCardNo(AccountCard);
                if (channelmodel != null)
                {
                    channeltype = 1;
                    channelid   = channelmodel.Id;

                    RebateConsume = channelmodel.RebateConsume;
                    RebateOpen    = channelmodel.RebateOpen;
                    Opencardnum   = channelmodel.Opencardnum;
                    Firstdealnum  = channelmodel.Firstdealnum;
                    Summoney      = channelmodel.Summoney;
                }


                //服务专员信息,服务专员ID
                if (Servercard != 0)
                {
                    Member_Channel channelmode2 = channeldate.GetChannelDetail(Int32.Parse(Servercard.ToString()));
                    if (channelmode2 != null)
                    {
                        Servername   = channelmode2.Name;
                        Servermobile = channelmode2.Mobile;
                    }
                }

                ////菜单项new WxSalePromoteTypeData()
                //List<WxSalePromoteType> menulist = new WxSalePromoteTypeData().GetAllWxMaterialType(comid, out totalcount);

                //菜单项new WxSalePromoteTypeData()
                List <WxSalePromoteType> menulist = new WxSalePromoteTypeData().GetRecommendWxMaterialType(comid, out totalcount);

                if (comid == 101)
                {
                    List <WxSalePromoteType> list = new List <WxSalePromoteType>();
                    int[] i = { 0, 1, 2, 5, 12 };
                    foreach (int s in i)
                    {
                        WxSalePromoteType wxmaterial = new WxSalePromoteType();

                        wxmaterial.Id       = menulist[s].Id;
                        wxmaterial.Typename = menulist[s].Typename;
                        list.Add(wxmaterial);
                    }

                    menu.DataSource = list;
                    menu.DataBind();
                }
                else
                {
                    menu.DataSource = menulist;
                    menu.DataBind();
                }

                //得到微信会员卡说明和使用门店说明
                int ttcount = 0;
                mcMaterilList = new MemberShipCardMaterialData().GetMCMateralListByComId(comid, out ttcount);
            }
            else
            {
                Response.Redirect("/byts/login.aspx");
            }
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WxMaterialData Wx     = new WxMaterialData();
            WxMaterial     wmater = Wx.logGetidinfo(" SalePromoteTypeid !=4 order by operatime  desc ");

            int totalcount = 0;


            if (wmater != null)
            {
                Listtime = wmater.Operatime.ToString("yyyy-MM-dd");
            }
            RequestUrl = Request.ServerVariables["SERVER_NAME"].ToString();
            comid      = Request["comid"].ConvertTo <int>(0);
            B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl);

            if (companyinfo != null)
            {
                comid = companyinfo.Com_id;
            }
            else
            { //判定是否为自助域名规则安 shop1.etown.cn
                if (Domain_def.Domain_yanzheng(RequestUrl))
                {
                    comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl));
                }
            }

            if (comid != 0)
            {
                B2b_company com = B2bCompanyData.GetAllComMsg(comid);

                if (com != null)
                {
                    Com_name     = com.Com_name;
                    Scenic_name  = com.Scenic_name;
                    Scenic_intro = com.B2bcompanyinfo.Scenic_intro;
                }
            }



            //菜单项new WxSalePromoteTypeData()
            List <WxSalePromoteType> menulist = new WxSalePromoteTypeData().GetAllWxMaterialType(comid, out totalcount);

            if (comid == 101)
            {
                List <WxSalePromoteType> list = new List <WxSalePromoteType>();
                int[] i = { 0, 1, 2, 5, 12 };
                foreach (int s in i)
                {
                    WxSalePromoteType wxmaterial = new WxSalePromoteType();

                    wxmaterial.Id       = menulist[s].Id;
                    wxmaterial.Typename = menulist[s].Typename;
                    list.Add(wxmaterial);
                }

                menu.DataSource = list;
                menu.DataBind();
            }
            else
            {
                List <WxSalePromoteType> list = new List <WxSalePromoteType>();
                //int[] i = { 0, 1, 2, 5, 12 };
                for (int s = 0; s < menulist.Count; s++)
                {
                    WxSalePromoteType wxmaterial = new WxSalePromoteType();

                    wxmaterial.Id       = menulist[s].Id;
                    wxmaterial.Typename = menulist[s].Typename;

                    var period = new WxMaterialData().GetPeriodicalBySaleType(comid, menulist[s].Id);
                    if (period != null)
                    {
                        list.Add(wxmaterial);
                    }
                }

                menu.DataSource = list;
                menu.DataBind();
            }
        }