Пример #1
0
        protected void btnCreateQR_Click(object sender, EventArgs e)
        {
            this.txtQRUrl.Text = string.Empty;
            this.ImageQR.ImageUrl = "";
            if (this.txtPassword.Text.Equals("createQRAdministrator"))
            {
                if (string.IsNullOrEmpty(this.txtSourceFrom.Text.Trim()) || this.txtSourceFrom.Text.Trim().Length > 59)
                {
                    JavaScript.Alert("推广渠道填写错误,最多60个字,不能空白");
                }
                #region 先判断以前有没有,有就直接返回
                const string querySql = "select * from [dbo].[WXQRInfos] where sourceFrom =@sourceFrom order by AddDate desc ";
                var param = new DynamicParameters();
                param.Add("@SourceFrom", this.txtSourceFrom.Text.Trim());

                var wxQrInfos =PublicConn.QueryActivityBySql<WXQRInfo>(querySql,ref param);
                if (wxQrInfos.Count >=1)
                {
                    this.txtQRUrl.Text = wxQrInfos.FirstOrDefault().QrUrl;
                    this.ImageQR.ImageUrl = "http://s.jiathis.com/qrcode.php?url=" + wxQrInfos.FirstOrDefault().QrUrl;
                    JavaScript.Alert("已经生成过这样的推广二维码了哦!");
                    return;
                }

                #endregion
                #region  调用接口获取
                ThirdLoginSDK sdk = new ThirdLoginSDK();
                sdk.InitSDK(ThirdLoginSDK.ThirdLoginType.WeiXin);
                var wxQr = sdk.GetWXQrInfoBy(this.txtSourceFrom.Text);
                if (wxQr != null)
                {
                    this.txtQRUrl.Text = wxQr.url;
                    const string insertSql = @"insert into [dbo].[WXQRInfos]([Id],[SourceFrom],[AddDate],[QrUrl],[Ticket])
                                                values (@Id,@SourceFrom,@AddDate,@QrUrl,@Ticket)";

                    var param2 = new DynamicParameters();
                    param2.Add("@Id", Guid.NewGuid());
                    param2.Add("@SourceFrom", this.txtSourceFrom.Text);
                    param2.Add("@AddDate", DateTime.Now);
                    param2.Add("@QrUrl", wxQr.url);
                    param2.Add("@Ticket", wxQr.ticket);

                    PublicConn.ExecuteActivity(insertSql,ref param2); 
                    this.ImageQR.ImageUrl = "http://s.jiathis.com/qrcode.php?url=" + wxQr.url;
                }
                #endregion
            }
            else
            {
                Jscript.Alert("请输入正确的管理员密码");
            }
        }
Пример #2
0
        private string GetSharedAddress(int functonType, int shareToolType)
        {
            string sql = @"SELECT ShareUrl FROM dbo.SharedSetting(NOLOCK) WHERE FunctionType=@FunctionType AND ShareToolType=@ShareToolType AND IsEnabled=1 AND IsGenerateShortUrl=1";

            DynamicParameters whereParams = new DynamicParameters();

            whereParams.Add("@FunctionType", functonType);
            whereParams.Add("@ShareToolType", shareToolType);
            List <string> list = new List <string>();

            list = PublicConn.QueryActivityBySql <string>(sql, ref whereParams);

            if (list.Count > 0)
            {
                return(list[0]);
            }
            return(string.Empty);
        }
Пример #3
0
        /// <summary>
        /// 获取进行中的活动信息
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageSize">条数</param>
        /// <param name="typeId">类型:0-所有,1-线上活动,2-线下活动,3-要客来访</param>
        /// <returns></returns>
        public static WXAcivityList GetActivityList(int pageIndex, int pageSize, int typeId = 0)
        {
            List <ActivityInfo> list         = new List <ActivityInfo>();
            WXAcivityList       billResponse = new WXAcivityList();

            var paras = new DynamicParameters();

            paras.Add("@pageIndex", pageIndex);
            paras.Add("@pageSize", pageSize);
            paras.Add("@TypeId", typeId);
            paras.Add("@total", 0, DbType.Int32, ParameterDirection.Output);
            string sqlText = string.Empty;

            sqlText = @"SELECT @total=COUNT(1) FROM( SELECT 1 AS cnt FROM dbo.Activity A
                            WHERE A.TypeId in(1,3,4) ) AS main;
                        WITH oa AS(
                        SELECT ROW_NUMBER() OVER(ORDER BY  (CASE WHEN GETDATE()<EndDate THEN 0 ELSE 1 END),SortOrder DESC,EndDate DESC) RowNum,Title, TypeId, Summary, Content, StartDate, EndDate,CreateDate, ImageUrl, LinkUrl, Status
                        FROM Activity WHERE Status=1 AND TypeId in(4) and getdate() between StartDate and EndDate) SELECT * FROM oa
                        WHERE RowNum between (@pageIndex-1)*@pageSize+1 and @pageIndex*@pageSize";
            list    = PublicConn.QueryActivityBySql <ActivityInfo>(sqlText, ref paras);
            if (list == null)
            {
                list = new List <ActivityInfo>();
            }
            billResponse.List       = list;
            billResponse.TotalCount = paras.Get <int>("@total");
            if (billResponse.TotalCount > 0)
            {
                billResponse.result = "1";
            }
            else
            {
                billResponse.result = "2";
            }
            return(billResponse);
        }