Exemplo n.º 1
0
        /// <summary>
        /// 创建新的面对面群
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="password">口令</param>
        /// <param name="lon">经度</param>
        /// <param name="lat">纬度</param>
        /// <returns></returns>
        public string CreateNewGroup(string userID, string password, string lon, string lat)
        {
            string  result  = "";
            GroupEL groupEL = new GroupEL();

            groupEL.GroupPassword = password;
            groupEL.GroupName     = "面对面群组" + DateTime.Now.ToString("hhmmss");
            groupEL.Introduce     = "面对面群组";
            groupEL.CreateTime    = DateTime.Now.ToString();
            groupEL.Lon           = lon;
            groupEL.Lat           = lat;

            groupEL.OwnerUserID = long.Parse(userID);
            groupEL.Valid       = 1;
            int  ra;
            long groupResultID = groupEL.ExecNonQuery(1, out ra);

            HF.Cloud.BLL.Common.Logger.Error("CreateNewGroup方法创建群组后结果(大于0成功):" + groupResultID);

            if (groupResultID > 0)
            {
                //创建完群组需要把用户在用户与群关联表中添加记录关联起来
                UserUniteGroupEL uugEL = new UserUniteGroupEL();
                uugEL.UserID     = long.Parse(userID);
                uugEL.GroupID    = groupResultID;
                uugEL.CreateTime = DateTime.Now.ToString();
                uugEL.IsTop      = 0;
                uugEL.Valid      = 1;
                int  uugRa;
                long uugResultID = uugEL.ExecNonQuery(1, out uugRa);
                HF.Cloud.BLL.Common.Logger.Error("CreateNewGroup方法创建群组后用户与群组关联结果(大于0成功):" + uugResultID);
                if (uugResultID > 0)
                {
                    result = groupResultID.ToString();
                }
                else
                {
                    result = "error";
                }
            }
            else
            {
                result = "error";
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取群组小程序码图片路径
        /// </summary>
        /// <param name="path">小程序码跳转路径</param>
        /// <param name="groupID">群组ID</param>
        /// <returns></returns>
        public string GetQRCode_Group(string path, string groupID)
        {
            HF.Cloud.BLL.Common.Logger.Error("GetQRCode_Group方法,获取的参数path:" + path + "------groupID:" + groupID);
            string imgPath = "";
            //判断数据库中是否有值
            GroupEL groupEL = new GroupEL();

            groupEL.ID = long.Parse(groupID);
            DataTable dt = groupEL.ExecDT(3);

            HF.Cloud.BLL.Common.Logger.Error("GetQRCode_Group方法,查找群组记录:" + dt.Rows.Count);
            if (dt != null && dt.Rows.Count > 0)
            {
                //如果数据库中"QRCode"有值,则从数据库中取值
                if (!string.IsNullOrEmpty(dt.Rows[0]["QRCode"].ToString()) && dt.Rows[0]["QRCode"].ToString() != "")
                {
                    //获取图片名称
                    string qrCodeImageName = dt.Rows[0]["QRCode"].ToString();
                    //获取图片路径
                    string qrCodeImagePath = System.Configuration.ConfigurationManager.AppSettings["QRCodeGet_Group"];
                    imgPath = qrCodeImagePath + qrCodeImageName;
                }
                //如果没有值则请求小程序服务器获取小程序码图片,并把图片名称保存到数据库中
                else
                {
                    //获取token
                    WX_TokenBLL tokenBLL = new WX_TokenBLL();
                    string      token    = tokenBLL.GetToken();
                    //获取小程序码接口
                    string url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + token;
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("path", path);
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    js.MaxJsonLength = int.MaxValue;
                    string json = js.Serialize(dic);
                    HF.Cloud.BLL.Common.Logger.Error("GetQRCode_Group方法,url:" + url + "-----Path:" + path);
                    //post返回的小程序码流
                    Stream QRCodeStream = WeChatAppDecrypt.Post(url, json);
                    //将图片流转换成图片
                    Bitmap tp = new Bitmap(QRCodeStream);
                    string QRCodeSave_Group = System.Configuration.ConfigurationManager.AppSettings["QRCodeSave_Group"];
                    string image_userName   = Guid.NewGuid().ToString();
                    string qrCodeImageName  = image_userName + ".jpg";
                    tp.Save(QRCodeSave_Group + qrCodeImageName);
                    //把小程序码图片名称保存到数据库中
                    groupEL.QRCode = qrCodeImageName;
                    int  ra;
                    long returnValue = groupEL.ExecNonQuery(21, out ra);
                    HF.Cloud.BLL.Common.Logger.Error("GetQRCode_Group方法,保存小程序图片名称结果:" + ra);
                    if (ra > 0)
                    {
                        string QRCodeGet_Group = System.Configuration.ConfigurationManager.AppSettings["QRCodeGet_Group"];
                        imgPath = QRCodeGet_Group + qrCodeImageName;
                    }
                    else
                    {
                        imgPath = "error";
                    }
                }
            }
            else
            {
                imgPath = "error";
            }
            HF.Cloud.BLL.Common.Logger.Error("GetQRCode_Group方法,小程序码图片路径:" + imgPath);
            return(imgPath);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新建群组  修改群组
        /// </summary>
        /// <param name="session">session</param>
        /// <param name="groupName">群组名称</param>
        /// <param name="Introduce">群组简介</param>
        /// <param name="isOpen">公开或私密</param>
        /// <param name="groupID">群组ID 0添加 大于0修改</param>
        /// <returns></returns>
        public string CreateGroup(string session, string groupName, string introduce, string isOpen, string groupID)
        {
            string result = "";

            HF.Cloud.BLL.Common.Logger.Error("CreateGroup方法获取到的参数session:" + session + "----groupName:" + groupName + "---Introduce:" + introduce + "---isOpen:" + isOpen + "---groupID:" + groupID);
            GroupEL groupEL = new GroupEL();

            groupEL.GroupName  = groupName;
            groupEL.Introduce  = introduce;
            groupEL.CreateTime = DateTime.Now.ToString();
            //通过session获取UserID
            UserBLL userBLL = new UserBLL();
            long    userID  = userBLL.GetUserIDBySession(session);

            groupEL.OwnerUserID = userID;
            groupEL.IsOpen      = Int32.Parse(isOpen);
            groupEL.Valid       = 1;
            long groupResultID       = 0; //添加群组返回值
            long updateGroupResultID = 0; //修改群组返回值

            if (groupID == "0")           //添加群组
            {
                int ra;
                groupResultID = groupEL.ExecNonQuery(1, out ra);
                HF.Cloud.BLL.Common.Logger.Error("CreateGroup方法创建群组后结果(大于0成功):" + groupResultID);
            }
            else//修改群组
            {
                groupEL.ID = long.Parse(groupID);
                int ra;
                updateGroupResultID = groupEL.ExecNonQuery(22, out ra);
                //updateGroupResultID = groupID;
                HF.Cloud.BLL.Common.Logger.Error("CreateGroup方法修改群组后结果(大于0成功):" + ra);
            }

            if (groupResultID > 0)
            {
                //创建完群组需要把用户在用户与群关联表中添加记录关联起来
                UserUniteGroupEL uugEL = new UserUniteGroupEL();
                uugEL.UserID     = userID;
                uugEL.GroupID    = groupResultID;
                uugEL.CreateTime = DateTime.Now.ToString();
                uugEL.IsTop      = 0;
                uugEL.Valid      = 1;
                int  uugRa;
                long uugResultID = uugEL.ExecNonQuery(1, out uugRa);
                HF.Cloud.BLL.Common.Logger.Error("CreateGroup方法创建群组后用户与群组关联结果(大于0成功):" + uugResultID);
                if (uugResultID > 0)
                {
                    result = groupResultID.ToString();
                }
                else
                {
                    result = "error";
                }
            }
            else if (updateGroupResultID > 0)
            {
                result = groupID;
            }
            else
            {
                result = "error";
            }
            return(result);
        }