コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.ContentType = "text/plain";
            JsonBaseObject jbo = new JsonBaseObject();
            string resultStr = string.Empty;
            try
            {
                string menberid = context.Request["menberid"];
                string detail = context.Request["detail"];
                string memo = context.Request["memo"];
                if (string.IsNullOrEmpty(detail)
                    || string.IsNullOrEmpty(menberid))
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "用户ID或反馈明细不能为空";
                    jbo.success = false;
                }
                else
                {
                    WG_FeebackEntity fe = new WG_FeebackEntity();
                    fe.PromoterID = int.Parse(menberid);
                    fe.Detail = detail;
                    fe.Memo = memo;
                    fe.CreateDate = DateTime.Now;
                    if (DataProvider.GetInstance().AddWG_Feeback(fe) > 0)
                    {
                        jbo.code = 0;
                        jbo.data = null;
                        jbo.message = "成功";
                        jbo.success = true;
                    }
                    else
                    {
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "提交反馈信息出错";
                        jbo.success = false;
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }


            resultStr = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(resultStr);

        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                //string menberID = context.Request["menberid"];
                //string teamName = context.Request["teamname"];
                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];

                int recordCount = -1;
                int pageCount = -1;
                string whereStr = " 1=1 ";

                // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                IList<WG_CommunityNewsEntity> NewsList = DataProvider.GetInstance().GetWG_CommunityNewsList(20, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                //如果所有数据分页后的总页数比请求的页数小,则返回空。
                if (int.Parse(PageIndex) > pageCount)
                    NewsList.Clear();

                if (NewsList != null && NewsList.Count > 0)
                {
                    jbo.code = 0;
                    jbo.data = NewsList;
                    jbo.success = true;
                    jbo.message = "成功获取社区动态列表列表。";
                }
                else
                {
                    //不存在
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.success = false;
                    jbo.message = "没有任何数据";

                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                string parentDistrictName = context.Request["ParentName"];
                List<RegionView> resultRegion = new List<RegionView>();
                IList<WG_RegionEntity> regionList;
                if (string.IsNullOrEmpty(parentDistrictName))
                {
                    //获取所有身份,parentid=0,0表示全国,父节点为0的所有身份
                    regionList = DataProvider.GetInstance().GetWG_RegionList(" ParentID= 0");
                }
                else
                {
                    //获取指定地区
                    regionList = DataProvider.GetInstance().GetWG_RegionList(" [name] = '" + parentDistrictName + "'");
                }

                //获取子地区
                foreach (WG_RegionEntity item in regionList)
                {
                    RegionView rv = new RegionView();
                    rv.Label = item.Name;
                    rv.Childrens = GetChilds(item.ID);
                    resultRegion.Add(rv);
                }

                //获取子地区
                jbo.code = 0;
                jbo.data = resultRegion;
                jbo.message = "获取区域成功";
                jbo.success = false;

            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }
コード例 #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";
            string GroupID = context.Request["GroupID"];
            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(GroupID))
                {
                    string whereStr = " IsEnable=0 AND GroupID=" + GroupID;
                    IList<GlobalPictureEntity> pictureList = DataProvider.GetInstance().GetGlobalPictureList(5,whereStr, " DisplayIndex ASC");
                    if (pictureList != null && pictureList.Count > 0)
                    {
                        //数据
                        jbo.code = 0;
                        jbo.data = pictureList;
                        jbo.message = "成功。";
                        jbo.success = true;
                    }
                    else
                    {
                        //没有任何数据
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "没有任何数据。";
                        jbo.success = false;
                    }
                }
                else
                {
                    //没有任何数据
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "必须指定分组ID以获取图片列表。";
                    jbo.success = false;

                }
            }
            catch (Exception ex)
            {
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现异常。";
                jbo.success = false;
            }
            
            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }
コード例 #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                IList<WG_ServiceIntentionEntity> serviceList = DataProvider.GetInstance().GetWG_ServiceIntentionList("1=1");
                var parentIdDataSource = from parentIdTabels in serviceList where parentIdTabels.ParentID == 0 select parentIdTabels;
                List<ServiceIntentionView> sivList = new List<ServiceIntentionView>();
                foreach (WG_ServiceIntentionEntity item in parentIdDataSource)
                {
                    ServiceIntentionView siv = new ServiceIntentionView();
                    siv.label = item.Content;
                    var childDataSource = from childTabels in serviceList where childTabels.ParentID == item.ID select childTabels;
                    List<ServiceIntentionView> sivListChild = new List<ServiceIntentionView>();
                    foreach (WG_ServiceIntentionEntity item2 in childDataSource)
                    {
                        ServiceIntentionView sivChild = new ServiceIntentionView();
                        sivChild.label = item2.Content;
                        sivListChild.Add(sivChild);
                    }
                    siv.childrens = sivListChild;
                    sivList.Add(siv);
                }

                jbo.code = 0;
                jbo.data = sivList;
                jbo.success = true;
                jbo.message = "成功获取服务意愿列表。";
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.ContentType = "text/plain";
            JsonBaseObject jbo = new JsonBaseObject();
            string resultStr = string.Empty;

            try
            {
                string jsonData= "[{\"appversion\":\"{#version#}\",\"appurl\":\"{#url#}\"}]";
                string appversion = ConfigurationManager.AppSettings["CurrentAppVirson"].ToString();
                string appurl = ConfigurationManager.AppSettings["CurrentAppDownLoadURL"].ToString();
                if(!string.IsNullOrEmpty(appversion)
                    && !string.IsNullOrEmpty(appurl))
                {
                    jsonData = jsonData.Replace("{#version#}", appversion).Replace("{#url#}", appurl);
                    jbo.code = 0;
                    jbo.data = jsonData;
                    jbo.message = "成功";
                    jbo.success = true;
                }
                else
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "没有相关版本信息";
                    jbo.success = false;
                }
            }
            catch (Exception ex)
            {
                //没有任何数据
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误:" + ex;
                jbo.success = false;
            }


            resultStr = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(resultStr);
        }
コード例 #7
0
        public void ProcessRequest(HttpContext context)
        {
            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                if (context.Request.Files.Count > 0)
                {
                    HttpPostedFile f = context.Request.Files[0];
                    //string path = ConfigurationManager.AppSettings["UserLogo"].ToString() + f.FileName;
                    f.SaveAs(ConfigurationManager.AppSettings["UserLogo"].ToString()+f.FileName);

                    //失败
                    jbo.code = 0;
                    jbo.data = null;
                    jbo.message = "文件上传成功";
                    jbo.success = true;
                }
                else
                {
                    //失败
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "没有任何文件";
                    jbo.success = false;
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);


        }
コード例 #8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            JsonBaseObject jbo = new JsonBaseObject();
            string resultStr = string.Empty;

            try
            {
                string menberid = context.Request["menberid"];
                if (string.IsNullOrEmpty(menberid))
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "用户ID不能为空";
                    jbo.success = false;
                }
                else
                {
                    WG_MenberEntity me = DataProvider.GetInstance().GetWG_MenberEntity(int.Parse(menberid));
                    if (me != null)
                    {
                        string psw = context.Request["psw"];
                        if (psw != null)
                            me.Psw = psw;
                        string avatar_url = ConfigurationManager.AppSettings["HostUrl"].ToString() + "imgs//" + context.Request["avatar_url"]; //context.Request["avatar_url"];
                        if (avatar_url != null)
                            me.PhotoUrl = avatar_url;
                        string nickname = context.Request["nickname"];
                        if (nickname != null)
                            me.NickName = nickname;
                        string sex = context.Request["sex"];
                        if (sex != null)
                            me.Sex = sex;
                        string birthday = context.Request["birthday"];
                        if (birthday != null)
                            me.Birthday = birthday;
                        string phoneNumber = context.Request["phoneNumber"];
                        if (phoneNumber != null)
                            me.Phone = phoneNumber;
                        string email = context.Request["email"];
                        if (email != null)
                            me.Email = email;
                        string QQnumber = context.Request["QQnumber"];
                        if (QQnumber != null)
                            me.QQ = QQnumber;
                        string country = context.Request["country"];
                        if (country != null)
                            me.Country = country;
                        string province = context.Request["province"];
                        if (province != null)
                            me.Province = province;
                        string city = context.Request["city"];
                        if (city != null)
                            me.City = city;
                        string district = context.Request["district"];
                        if (district != null)
                            me.District = district;
                        string town = context.Request["town"];
                        if (town != null)
                            me.Town = town;
                        string community = context.Request["community"];
                        if (community != null)
                            me.Community = community;
                        string personalid = context.Request["identity"];
                        if (personalid != null)
                            me.PersonalID = personalid;
                        string address = context.Request["address"];
                        if (address != null)
                            me.Address = address;
                        string weixinNumber = context.Request["weixinNumber"];
                        if (weixinNumber != null)
                            me.WeChat = weixinNumber;
                        string education = context.Request["education"];
                        if (education != null)
                            me.Education = education;
                        string profession = context.Request["profession"];
                        if (profession != null)
                            me.Major = profession;
                        string speciality = context.Request["speciality"];
                        if (speciality != null)
                            me.SpecialSkill = speciality;
                        string intention = context.Request["intention"];
                        if (intention != null)
                            me.ServiceIntention = intention;
                        string intentionTime = context.Request["intentionTime"];
                        if (intentionTime != null)
                            me.ServiceTimeInterval = intentionTime;
                        string flag = context.Request["flag"];
                        if (flag != null)
                        {
                            if (int.Parse(flag) > me.Flag)
                            {
                                me.Flag = int.Parse(flag);
                                me.Status = 1;//越级升级需要重新审核
                            }
                        }

                        if (DataProvider.GetInstance().UpdateWG_Menber(me))
                        {
                            jbo.code = 0;
                            jbo.data = null;
                            jbo.message = "成功";
                            jbo.success = true;
                        }
                        else
                        {
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "更新用户数据失败";
                            jbo.success = false;
                        }
                    }
                    else
                    {
                        //用户不存在
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "用户不存在";
                        jbo.success = false;
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            resultStr = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(resultStr);
        }
コード例 #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                string username = context.Request["username"];
                string psw = context.Request["psw"];
                if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(psw))
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "账号或密码不能为空!";
                    jbo.success = false;
                    result = JsonSerializer<JsonBaseObject>(jbo);
                    context.Response.Write(result);
                }

                string whereStr = " Name ='" + username + "'";
                IList<WG_MenberEntity> userList = DataProvider.GetInstance().GetWG_MenberList(whereStr);
                if (userList.Count > 0)
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "该用户已存在!";
                    jbo.success = false;
                }
                else
                {
                    try
                    {
                        string sex = context.Request["sex"];
                        //设置默认
                        string avatar_url = ConfigurationManager.AppSettings["HostUrl"].ToString()+"imgs/" + context.Request["avatar_url"]; //sex == "男" ? "http://120.24.230.139/AppData/imgs/man.jpg" : "http://120.24.230.139/AppData/imgs/woman.jpg";//context.Request["avatar_url"];
                        string nickname = context.Request["nickname"];
                        string birthday = context.Request["birthday"];
                        string phoneNumber = context.Request["phoneNumber"];
                        string email = context.Request["email"];
                        string QQnumber = context.Request["QQnumber"];
                        string country = context.Request["country"];
                        string province = context.Request["province"];
                        string city = context.Request["city"];
                        string district = context.Request["district"];
                        string town = context.Request["town"];
                        string community = context.Request["community"];
                        string personalid = context.Request["identity"];
                        string address = context.Request["address"];
                        string weixinNumber = context.Request["weixinNumber"];
                        string education = context.Request["education"];
                        string profession = context.Request["profession"];
                        string speciality = context.Request["speciality"];
                        string intention = context.Request["intention"];
                        string intentionTime = context.Request["intentionTime"];
                        string flag = context.Request["flag"];

                        WG_MenberEntity menber = new WG_MenberEntity();
                        menber.Name = username;
                        menber.NickName = nickname;
                        menber.Psw = psw;
                        menber.Sex = sex;
                        menber.PhotoUrl = avatar_url;
                        menber.Birthday = birthday;
                        menber.Phone = phoneNumber;
                        menber.Email = email;
                        menber.QQ = QQnumber;
                        menber.Country = country;
                        menber.Province = province;
                        menber.City = city;
                        menber.District = district;
                        menber.Town = town;
                        menber.Community = community;
                        menber.PersonalID = personalid;
                        menber.Address = address;
                        menber.WeChat = weixinNumber;
                        menber.Education = education;
                        menber.Major = profession;
                        menber.SpecialSkill = speciality;
                        menber.ServiceIntention = intention;
                        menber.ServiceTimeInterval = intentionTime;
                        //0为游客,1位求助者,2为志愿者。求助者和自愿者才需要审核
                        if (int.Parse(flag) > 0)
                            menber.Status = 1;//状态:0正常,1待审核,2状态异常
                        else
                        {
                            menber.Status = 0;
                        }
                        menber.Flag = int.Parse(flag);
                        menber.Scores = 100;//初始积分100
                        menber.ServiceHours = 0;///初始服务时长为0
                        menber.CreateDate = DateTime.Now;
                        menber.UpdateDate = DateTime.Now;

                        //新增用户
                        int mID = DataProvider.GetInstance().AddWG_Menber(menber);

                        //新增得分明细表
                        WG_ScoreEntity se = new WG_ScoreEntity();
                        se.MenberID = mID;
                        se.Scores = int.Parse(ConfigurationManager.AppSettings["DefaultScore"].ToString());
                        se.CreateDate = DateTime.Now;
                        se.Title = "新用户注册获得" + se.Scores + "积分";
                        DataProvider.GetInstance().AddWG_Score(se);
                        //看看是否心中其他表

                        #region 通知用户主程成功,等待审核 add by frde 20160130
                        NoticeEntity ne = new NoticeEntity();
                        ne.FromUserID = 0;
                        ne.ToUserID = mID.ToString();
                        ne.Title = "注册成功";
                        ne.CreateDate = DateTime.Now;
                        ne.NoticeContent = "您的账号注册成功,请等待审核认证。";

                        //给用户一条消息
                        DataProvider.GetInstance().AddNotice(ne);
                        #endregion


                        //返回数据
                        menber.ID = mID;
                        jbo.code = 0;
                        jbo.data = menber;
                        jbo.message = "注册成功!";
                        jbo.success = true;
                    }
                    catch (Exception ex)
                    {
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "注册过程中发生异常!";
                        jbo.success = false;
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }


            #region 返回json

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

            #endregion
        }
コード例 #10
0
        public void ProcessRequest(HttpContext context)
        {
            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.ContentType = "text/plain";
            JsonBaseObject jbo = new JsonBaseObject();
            string resultStr = string.Empty;

            try
            {
                string menberid = context.Request["menberid"];

                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];

                if (string.IsNullOrEmpty(menberid))
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "用户ID不能为空";
                    jbo.success = false;
                }
                else
                {
                    //toUser=0说明是系统群发的消息
                    string whereStr = " toUserID= " + menberid + " OR toUserID=0";
                    //IList<NoticeEntity> noticeList = DataProvider.GetInstance().GetNoticeList(whereStr);

                    int recordCount = -1;
                    int pageCount = -1;
                    // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                    IList<NoticeEntity> noticeList = DataProvider.GetInstance().GetNoticeList(20, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                    //获取未读信息的数量
                    string sqlStr = @" select count(*)from dbo.Notice where AlreadyRead = 0  and ( " + whereStr + " )";
                    DataSet ds = DbHelperSQL.Query(sqlStr);
                    int count = 0;
                    if (ds.Tables.Count > 0)
                    {
                        string countstr = ds.Tables[0].Rows[0][0].ToString();
                        int.TryParse(countstr, out count);
                    }

                    //如果所有数据分页后的总页数比请求的页数小,则返回空。
                    if (int.Parse(PageIndex) > pageCount)
                        noticeList.Clear();
                    if (noticeList != null && noticeList.Count > 0)
                    {
                        jbo.code = 0;
                        jbo.data = noticeList;
                        jbo.message = count.ToString(); ;
                        jbo.success = true;
                    }
                    else
                    {
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "数据为空";
                        jbo.success = false;
                    }
                }
            }
            catch (Exception ex)
            {
                //没有任何数据
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误:" + ex;
                jbo.success = false;
            }


            resultStr = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(resultStr);
        }
コード例 #11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {

                //排名分为全国、全省、全市、全区、本小区
                string country = context.Request["country"];//全国
                string province = context.Request["province"];//广东
                string city = context.Request["city"];//广州
                string district = context.Request["district"];//天河
                string community = context.Request["community"];//羊城花园

                string whereStr = " 1=1 ";
                if (!string.IsNullOrEmpty(country))
                    whereStr += " AND Country='" + country + "' ";
                else if (!string.IsNullOrEmpty(province))
                    whereStr += " AND Province='" + province + "' ";
                else if (!string.IsNullOrEmpty(city))
                    whereStr += " AND City='" + city + "'";
                else if (!string.IsNullOrEmpty(district))
                    whereStr += " AND District='" + district + "' ";
                else if (!string.IsNullOrEmpty(community))
                    whereStr += " AND Community='" + community + "' ";
                else
                    whereStr += "";


                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];

                //IList<WG_OnGoingGiftsEntity> OnGoingGiftList = DataProvider.GetInstance().GetWG_OnGoingGiftsList(whereStr);
                int recordCount = -1;
                int pageCount = -1;
                // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                IList<WG_MenberEntity> menberList = DataProvider.GetInstance().GetWG_MenberList(20, int.Parse(PageIndex), " WHERE " + whereStr, " ServiceHours Desc ", out recordCount, out pageCount);

                //如果所有数据分页后的总页数比请求的页数小,则返回空。
                if (int.Parse(PageIndex) > pageCount)
                    menberList.Clear();

                //SqlParameter[] parameters ={
                //                               new SqlParameter("@Country",SqlDbType.NVarChar,64),
                //                               new SqlParameter("@Province",SqlDbType.NVarChar,64),
                //                               new SqlParameter("@City",SqlDbType.NVarChar,64),
                //                               new SqlParameter("@District",SqlDbType.NVarChar,64),
                //                               new SqlParameter("@Community",SqlDbType.NVarChar,64)
                //                           };
                //parameters[0].Value = country;
                //parameters[1].Value = province;
                //parameters[2].Value = city;
                //parameters[3].Value = district;
                //parameters[4].Value = community;
                //DataSet ds = DbHelperSQL.RunProcedure("[dbo].[up_MenberRanking]", parameters);
                if (menberList != null && menberList.Count > 0)
                {
                    IList<MenberRankingView> list = new List<MenberRankingView>();
                   
                    // 组装
                    for (int i = 0; i < menberList.Count; i++)
                    {
                        MenberRankingView mrv = new MenberRankingView();
                        mrv.ID = menberList[i].ID;
                        mrv.Name = menberList[i].Name;
                        mrv.NickName = menberList[i].NickName;
                        mrv.ServiceHours = menberList[i].ServiceHours.ToString();
                        mrv.Rank = i + 1;
                        mrv.CreateDate = menberList[i].CreateDate.ToString();
                        list.Add(mrv);
                    }
                    //数据
                    jbo.code = 0;
                    jbo.data = list;
                    jbo.message = "成功。";
                    jbo.success = true;

                }
                else
                {
                    //没有任何数据
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "没有找到任何数据。";
                    jbo.success = false;
                }
            }
            catch (Exception ex)
            {
                //没有任何数据
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误。";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

        }
コード例 #12
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";
            JsonBaseObject jbo = new JsonBaseObject();
            WG_MenberEntityView menberView = new WG_MenberEntityView();
            string result = "";
            try
            {
                string userName = context.Request["username"];
                string psw = context.Request["psw"];

                //登录
                string userWhere = " Name ='" + userName + "' AND Psw='" + psw + "' ";

                IList<WG_MenberEntity> userList = DataProvider.GetInstance().GetWG_MenberList(userWhere);

                if (userList == null || userList.Count <= 0)
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "用户不存在或密码错误!";
                    jbo.success = false;
                }
                else
                {
                    string whereStr = " UserID=" + userList[0].ID;
                    List<PrivilegeViewEntity> peList = DataProvider.GetInstance().GetPrivilegeViewList(whereStr).ToList<PrivilegeViewEntity>();
                    menberView.Menber = userList[0];
                    menberView.Privilege = peList;

                    if (userList[0].Status == 0)
                    {
                        jbo.code = 0;
                        jbo.data = menberView;
                        jbo.message = "成功!";
                        jbo.success = true;
                    }
                    else if (userList[0].Status == 1)
                    {
                        //待审核
                        jbo.code = 0;
                        jbo.data = menberView;
                        jbo.message = "成功!但目前还在审核状态,可能影响部分功能";
                        jbo.success = true;
                    }
                    else
                    {
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "账号有异常,请联系管理员";
                        jbo.success = false;
                    }
                }
            }
            catch (Exception ex)
            {
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现异常。";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }
コード例 #13
0
        public void ProcessRequest(HttpContext context)
        {
            // todo: [KnownType(typeof(List<WG_ActivitiesEntity>))]

            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            context.Response.ContentType = "text/plain";
            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;
            try
            {

                string ID = context.Request["ID"];
                int count = 20;
                string countStr = context.Request["Count"];
                if (!string.IsNullOrEmpty(countStr))
                    int.TryParse(countStr, out count);

                //获取活动列表,所有活动和我的活动
                string menberID = context.Request["menberID"];

                string promoterID = context.Request["promoterID"];

                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];

                string whereStr = " 1 = 1 ";
                if (string.IsNullOrEmpty(menberID)
                    && string.IsNullOrEmpty(promoterID))
                {
                    //所有活动
                    //IList<WG_ActivitiesEntity> ae = DataProvider.GetInstance().GetWG_ActivitiesList(" 1=1 ");
                    //如果传了ID,就只有一条
                    if (!string.IsNullOrEmpty(ID))
                    {
                        whereStr = " ID=" + ID;
                    }

                    int recordCount = -1;
                    int pageCount = -1;
                    // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                    IList<WG_ActivitiesEntity> ae = DataProvider.GetInstance().GetWG_ActivitiesList(count, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                    //如果所有数据分页后的总页数比请求的页数小,则返回空。
                    if (int.Parse(PageIndex) > pageCount)
                        ae.Clear();

                    if (ae != null && ae.Count > 0)
                    {
                        jbo.code = 0;
                        jbo.data = ae;
                        jbo.message = "成功";
                        jbo.success = true;
                    }
                    else
                    {
                        //没有任何数据
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "活动列表为空";
                        jbo.success = false;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(menberID))
                    {
                        //我的活动
                         whereStr = " menberID = " + menberID;

                        //IList<WG_OnGoingActivitiesEntity> ogae = DataProvider.GetInstance().GetWG_OnGoingActivitiesList(whereStr);
                        int recordCount = -1;
                        int pageCount = -1;
                        // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                        IList<WG_OnGoingActivitiesEntity> ogae = DataProvider.GetInstance().GetWG_OnGoingActivitiesList(count, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                        //如果所有数据分页后的总页数比请求的页数小,则返回空。
                        if (int.Parse(PageIndex) > pageCount)
                            ogae.Clear();


                        if (null != ogae && ogae.Count > 0)
                        {
                            IList<WG_ActivitiesEntity> aeList = new List<WG_ActivitiesEntity>();
                            foreach (WG_OnGoingActivitiesEntity item in ogae)
                            {
                                WG_ActivitiesEntity ae = DataProvider.GetInstance().GetWG_ActivitiesEntity(item.ActivityID);
                                if (null != ae)
                                {
                                    aeList.Add(ae);
                                }
                            }

                            jbo.code = 0;
                            jbo.data = aeList;
                            jbo.message = "成功获取我的活动";
                            jbo.success = true;
                        }
                        else
                        {
                            //没有任何数据
                            //没有任何数据
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "您还未参加任何活动";
                            jbo.success = false;
                        }
                    }
                    else if (!string.IsNullOrEmpty(promoterID))
                    {
                        //我发布的活动
                         whereStr = " promoterid = " + promoterID;
                        //IList<WG_OnGoingActivitiesEntity> ogae = DataProvider.GetInstance().GetWG_OnGoingActivitiesList(whereStr);
                        int recordCount = -1;
                        int pageCount = -1;
                        // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                        IList<WG_ActivitiesEntity> aeList = DataProvider.GetInstance().GetWG_ActivitiesList(count, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                        //如果所有数据分页后的总页数比请求的页数小,则返回空。
                        if (int.Parse(PageIndex) > pageCount)
                            aeList.Clear();

                        if (aeList != null && aeList.Count > 0)
                        {
                            jbo.code = 0;
                            jbo.data = aeList;
                            jbo.message = "成功获取我的活动";
                            jbo.success = true;
                        }
                        else
                        {
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "你还没有发布任何活动";
                            jbo.success = false;
                        }

                    }
                    else
                    {


                    }

                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }


            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

        }
コード例 #14
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;
            try
            {
                string title = context.Request["title"];
                string type = context.Request["type"];
                string promoterID = context.Request["promoterID"];
                string linkman = context.Request["linkman"];
                string linkphone = context.Request["linkphone"];
                string beginTime = context.Request["beginTime"];
                string region = context.Request["region"];
                string serviceIntention = context.Request["serviceIntention"];
                string duration = context.Request["duration"];
                string detail = context.Request["detail"];
                string status = context.Request["status"];

                if (!string.IsNullOrEmpty(title) 
                    && !string.IsNullOrEmpty(linkphone)
                    && !string.IsNullOrEmpty(promoterID))
                {
                    WG_HelpRequestEntity currEntity = new WG_HelpRequestEntity();
                    currEntity.Title = title;
                    currEntity.Type = int.Parse(type);//1为求助,2为帮助
                    currEntity.PromoterID = int.Parse(promoterID);//提交人的ID
                    currEntity.LinkMan = linkman;
                    currEntity.LinkPhone = linkphone;
                    currEntity.BeginTime = Convert.ToDateTime(beginTime);
                    currEntity.Region = region;
                    currEntity.ServiceIntention = serviceIntention;
                    currEntity.Duration = int.Parse(duration);
                    currEntity.Detail = detail;
                    currEntity.Status = 0;// int.Parse(status);//0待匹配,1已匹配,2,已完成。
                    //注册,所以不用制定undertakerID
                    currEntity.CreateDate = DateTime.Now;
                    currEntity.UpdateDate = DateTime.Now;
                    int addResult = DataProvider.GetInstance().AddWG_HelpRequest(currEntity);
                    if (addResult < 0)
                    {
                        //失败
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "新增过程中失败";
                        jbo.success = false;
                    }
                    else
                    {
                        //成功
                        jbo.code = 0;
                        jbo.data = null;
                        jbo.message = "成功";
                        jbo.success = true;
                    }
                }
                else
                {
                    //最基本必须有标题和联系人电话,否则失败
                    //失败
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "标题或联系电话必须不能为空。";
                    jbo.success = false;
                }
            }
            catch (Exception ex)
            {
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现异常。";
                jbo.success = false;
            }

            #region 返回json

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

            #endregion
        }
コード例 #15
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            // todo: [KnownType(typeof(List<WG_ActivitiesEntity>))]

            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            JsonBaseObject jbo = new JsonBaseObject();
            string resultStr = string.Empty;

            try
            {
                string menberID = context.Request["menberID"];
                string activityID = context.Request["activityID"];
                string opc = context.Request["opc"];//1参加活动,2退出活动,3完成活动(发起人权利),4撤销活动,5.获取活动参与者列表,6发布活动


                if (string.IsNullOrEmpty(menberID)
                    || string.IsNullOrEmpty(activityID)
                    || string.IsNullOrEmpty(opc))
                {
                    //参数空
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "用户ID/活动ID/状态都不能为空";
                    jbo.success = false;
                }
                else
                {
                    //当前活动,ae.Status,0等待报名...,1活动正在进行(禁止报名),2,活动已结束
                    WG_ActivitiesEntity ae = new WG_ActivitiesEntity();
                    if (!string.IsNullOrEmpty(activityID))
                        ae = DataProvider.GetInstance().GetWG_ActivitiesEntity(int.Parse(activityID));
                    
                    if (opc == "6")
                    {
                        //发布活动,需要权限
                        string title = context.Request["title"];
                        string promoterid = context.Request["promoterid"];
                        string linkman = context.Request["linkman"];
                        string linkphone = context.Request["linkphone"];
                        string linkaddress = context.Request["linkaddress"];
                        string activitytype = context.Request["activitytype"];
                        string region = context.Request["region"];
                        string begintime = context.Request["begintime"];
                        string needmenbercount = context.Request["needmenbercount"];
                        string detail = context.Request["detail"];

                        if (!string.IsNullOrEmpty(title)
                            && !string.IsNullOrEmpty(linkman)
                            && !string.IsNullOrEmpty(linkphone))
                        {
                            WG_ActivitiesEntity aee = new WG_ActivitiesEntity();
                            aee.Title = title;
                            aee.PromoterID = int.Parse(menberID);
                            aee.LinkMan = linkman;
                            aee.LinkPhone = linkphone;
                            aee.Address = linkaddress;
                            aee.ActivityType = activitytype;
                            aee.Region = region;
                            aee.NeedMenberCount = int.Parse(needmenbercount);
                            aee.Detail = detail;
                            aee.BeginTime = Convert.ToDateTime(begintime);
                            aee.Status = 0;//正在报名中
                            aee.CreateDate = DateTime.Now;
                            aee.UpdateDate = DateTime.Now;

                            DataProvider.GetInstance().AddWG_Activities(aee);
                            //成功
                            jbo.code = 0;
                            jbo.data = null;
                            jbo.message = "创建活动成功";
                            jbo.success = false;

                        }
                        else
                        {
                            //信息不够,不能创建
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "标题,联系人、联系电话不能为空";
                            jbo.success = false;
                        }
                    }
                    else if (null == ae)
                    {
                        //活动不存在
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "活动不存在";
                        jbo.success = false;
                    }
                    else if (opc == "5")
                    {
                        #region 获取活动参与者列表
                        string whereStr = " activityID=" + activityID;
                        IList<WG_OnGoingActivitiesEntity> ogaeList = DataProvider.GetInstance().GetWG_OnGoingActivitiesList(whereStr);

                        IList<WG_MenberEntity> meList = new List<WG_MenberEntity>();
                        if (ogaeList != null && ogaeList.Count > 0)
                        {
                            foreach (WG_OnGoingActivitiesEntity item in ogaeList)
                            {
                                WG_MenberEntity me = DataProvider.GetInstance().GetWG_MenberEntity(item.MenberID);
                                meList.Add(me);
                            }
                        }
                        jbo.code = 0;
                        jbo.data = meList;
                        jbo.message = "成功获取活动参与者列表";
                        jbo.success = true;

                        #endregion
                    }
                    else if (ae.Status == 2)
                    {
                        //活动已经结束
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "活动已经结束";
                        jbo.success = false;
                    }
                    else if (ae.Status == 1 && opc != "3")
                    {
                        //活动已经开始
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "活动已经开始了";
                        jbo.success = false;
                    }
                    else if (ae.Status == 0 && opc == "4" && ae.PromoterID == int.Parse(menberID))
                    {
                        //只有在等待报名的活动才可以撤销,已经开始或者已经结束的都不可以撤销

                        //1.删除这个活动
                        DataProvider.GetInstance().DeleteWG_Activities(int.Parse(activityID));

                        //2.删除报名列表
                        string whereStr = " 1=1 AND activityID=" + activityID;
                        IList<WG_OnGoingActivitiesEntity> ogae = DataProvider.GetInstance().GetWG_OnGoingActivitiesList(whereStr);
                        if (ogae != null && ogae.Count > 0)
                        {
                            foreach (WG_OnGoingActivitiesEntity item in ogae)
                            {
                                DataProvider.GetInstance().DeleteWG_OnGoingActivities(item.ID);
                            }
                        }

                        //活动已经开始
                        jbo.code = 0;
                        jbo.data = null;
                        jbo.message = "撤销活动成功";
                        jbo.success = true;

                    }
                    else
                    {
                        //判断是否已经参加
                        string whereStr = " status= 0 " + " AND  menberID= " + menberID + " AND activityID= " + activityID;
                        IList<WG_OnGoingActivitiesEntity> ogaeList = DataProvider.GetInstance().GetWG_OnGoingActivitiesList(whereStr);

                        if ("1" == opc)
                        {
                            #region 1参加活动
                            if (null != ogaeList && ogaeList.Count > 0)
                            {
                                //已经参加
                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "您已参加了活动,无需重复";
                                jbo.success = false;
                            }
                            else
                            {
                                //判断参加活动的人数是否已经满了
                                string sql = " select * from dbo.WG_OnGoingActivities where ActivityID=" + activityID + " and Status=0 ";
                                DataSet ds = DbHelperSQL.Query(sql);
                                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count >= ae.NeedMenberCount)
                                {
                                    //人已经满了
                                    jbo.code = -1;
                                    jbo.data = null;
                                    jbo.message = "活动人数已满";
                                    jbo.success = false;
                                }
                                else
                                {
                                    //在WG_OnGoingActivitiesEntity新增一条记录
                                    WG_OnGoingActivitiesEntity ogae = new WG_OnGoingActivitiesEntity();
                                    ogae.ActivityID = int.Parse(activityID);
                                    ogae.MenberID = int.Parse(menberID);
                                    ogae.Status = 0;
                                    ogae.CreateDate = DateTime.Now;
                                    DataProvider.GetInstance().AddWG_OnGoingActivities(ogae);

                                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count + 1 == ae.NeedMenberCount)
                                    {
                                        //人满了
                                        ae.Status = 1;//活动被激活
                                        DataProvider.GetInstance().UpdateWG_Activities(ae);
                                    }

                                    AddNoticeToWG("您发布的活动有新成员参加", "您发布的活动:[ "+ae.Title+" ] 有新成员加入,请知悉。", ae.PromoterID.ToString(),2,ae.ID);

                                    jbo.code = 0;
                                    jbo.data = null;
                                    jbo.message = "成功参加活动";
                                    jbo.success = true;
                                }
                            }
                            #endregion

                        }
                        else if ("2" == opc)
                        {
                            //2只能是退出活动,如果是激活活动,是不能人工的,需要自动人数到了触发活动
                            #region 退出活动
                            if (null != ogaeList && ogaeList.Count > 0)
                            {
                                foreach (WG_OnGoingActivitiesEntity item in ogaeList)
                                {
                                    DataProvider.GetInstance().DeleteWG_OnGoingActivities(item.ID);
                                    AddNoticeToWG("有成员退出了您发布的活动", "您发布的活动:[ " + ae.Title + " ] 有成员退出,请知悉。", ae.PromoterID.ToString(), 2, ae.ID);
                                }

                                jbo.code = 0;
                                jbo.data = null;
                                jbo.message = "成功退出活动";
                                jbo.success = true;
                            }
                            else
                            {
                                //活动不存在
                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "你并未参加活动";
                                jbo.success = false;
                            }
                            #endregion
                        }
                        else if ("3" == opc)
                        {
                            //3活动完成,发起人有权限
                            ae.Status = 2;
                            DataProvider.GetInstance().UpdateWG_Activities(ae);

                            jbo.code = 0;
                            jbo.data = null;
                            jbo.message = "完成活动成功";
                            jbo.success = true;
                        }
                        else
                        {
                            //非法操作
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "非法操作";
                            jbo.success = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            resultStr = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(resultStr);

        }
コード例 #16
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                string OldPsw = context.Request["oldPsw"];//旧用户密码MD5值
                string NewPsw = context.Request["newPsw"];//新用户密码MD5值
                string UserIDStr = context.Request["menberID"];//用户ID

                int userID = -1;

                if (!string.IsNullOrEmpty(OldPsw)
                    && !string.IsNullOrEmpty(NewPsw)
                    && !string.IsNullOrEmpty(UserIDStr)
                    && int.TryParse(UserIDStr, out userID))
                {
                    //1.判断用户是否存在
                    WG_MenberEntity curMenber = DataProvider.GetInstance().GetWG_MenberEntity(userID);
                    if (curMenber == null)
                    {
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.success = false;
                        jbo.message = "用户不存在.";
                    }
                    else
                    {
                        IList<WG_MenberEntity> menberList = DataProvider.GetInstance().GetWG_MenberList(" ID=" + userID + "  AND Psw='" + OldPsw + "'");
                        if (menberList == null || menberList.Count <= 0)
                        {
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.success = false;
                            jbo.message = "旧密码有误.";
                        }
                        else
                        {
                            curMenber.Psw = NewPsw;
                            if (DataProvider.GetInstance().UpdateWG_Menber(curMenber))
                            {
                                jbo.code = 0;
                                jbo.data = null;
                                jbo.success = true;
                                jbo.message = "成功.";
                            }
                            else
                            {
                                jbo.code = -1;
                                jbo.data = null;
                                jbo.success = false;
                                jbo.message = "数据更新是出错.";
                            }
                        }
                    }

                }
                else
                {
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.success = false;
                    jbo.message = "参数有误.";
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

        }
コード例 #17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                string MenberID = context.Request["MenberID"];//用户ID

                string ID = context.Request["ID"];
                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];

                string whereStr = " 1=1 ";
                if (!string.IsNullOrEmpty(MenberID))
                {
                    //MenberID不为空,则说明是获取用户已经申请领取的礼物列表
                    whereStr += " AND MenberID=" + MenberID;
                    whereStr += " ";//加多一个空格,避免sql的语法问题

                    //IList<WG_OnGoingGiftsEntity> OnGoingGiftList = DataProvider.GetInstance().GetWG_OnGoingGiftsList(whereStr);
                    int recordCount = -1;
                    int pageCount = -1;

                    //如果传了ID,就只有一条
                    if (!string.IsNullOrEmpty(ID))
                    {
                        whereStr = " Status=0 AND ID=" + ID;
                    }

                    // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                    IList<WG_OnGoingGiftsEntity> OnGoingGiftList = DataProvider.GetInstance().GetWG_OnGoingGiftsList(20, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                    //如果所有数据分页后的总页数比请求的页数小,则返回空。
                    if (int.Parse(PageIndex) > pageCount)
                        OnGoingGiftList.Clear();

                    if (OnGoingGiftList != null && OnGoingGiftList.Count > 0)
                    {
                        List<OnGoingGiftsView> oggvList = new List<OnGoingGiftsView>();
                        foreach (WG_OnGoingGiftsEntity item in OnGoingGiftList)
                        {
                            WG_GiftsEntity Gift = DataProvider.GetInstance().GetWG_GiftsEntity(item.GiftID);
                            if (Gift != null)
                            {
                                OnGoingGiftsView oggv = new OnGoingGiftsView();
                                oggv.ValidateCode = item.Code;
                                oggv.GiftEntity = Gift;
                                oggv.Status = item.Status;
                                oggvList.Add(oggv);
                            }
                        }

                        jbo.code = 0;
                        jbo.data = oggvList;
                        jbo.success = true;
                        jbo.message = "成功获取您的礼物列表。";

                    }
                    else
                    {
                        //不存在
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.success = false;
                        jbo.message = "你还没有领取任何礼物。";
                    }
                }
                else
                {
                    //否则为获取全部礼品列表
                    //IList<WG_GiftsEntity> giftList = DataProvider.GetInstance().GetWG_GiftsList(" Status=0 ");              
                    int recordCount = -1;
                    int pageCount = -1;
                    // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                    //如果传了ID,就只有一条
                    if (!string.IsNullOrEmpty(ID))
                    {
                        whereStr = " Status=0 AND ID=" + ID;
                    }
                    IList<WG_GiftsEntity> giftList = DataProvider.GetInstance().GetWG_GiftsList(20, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                    //如果所有数据分页后的总页数比请求的页数小,则返回空。
                    if (int.Parse(PageIndex) > pageCount)
                        giftList.Clear();


                    if (giftList != null && giftList.Count > 0)
                    {
                        jbo.code = 0;
                        jbo.data = giftList;
                        jbo.success = true;
                        jbo.message = "成功获取所有礼物列表。";
                    }
                    else
                    {
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.success = false;
                        jbo.message = "礼物列表为空。";
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

        }
コード例 #18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;
            try
            {
                string ID = context.Request["ID"];
                string region = context.Request["Region"];
                int count = 20;
                string countStr = context.Request["Count"];
                if (!string.IsNullOrEmpty(countStr))
                    int.TryParse(countStr, out count);
                string menberID = context.Request["menberID"];//求助者ID
                string Type = context.Request["Type"];//1求助,2帮助
                string serviceIntention = context.Request["ServiceIntention"];
                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];
                string whereStr = " 1 = 1 ";

                if (!string.IsNullOrEmpty(region))
                    whereStr += "  AND Region Like '%" + region + "%'";
                if (!string.IsNullOrEmpty(serviceIntention))
                {
                    //加入服务意愿查询
                    whereStr += "  AND ServiceIntention Like '%" + serviceIntention + "%'";
                }
                if (!string.IsNullOrEmpty(menberID))
                {
                    if (Type == "1")
                    {
                        whereStr += " AND ((Type=1 AND PromoterID=" + menberID + ") OR (Type=2 AND UnderTakerID=" + menberID + "))";
                    }
                    else if (Type == "2")
                    {
                        whereStr += " AND ((Type=2 AND PromoterID=" + menberID + ") OR (Type=1 AND UnderTakerID=" + menberID + "))";
                    }
                }
                else
                {
                    //不传用用户ID时,选择指定类型即可
                    if (!string.IsNullOrEmpty(Type))
                        whereStr += "AND Type= " + Type;
                }
                whereStr += " ";//加多一个空格,避免sql的语法问题

                //如果传了ID,就只有一条
                if (!string.IsNullOrEmpty(ID))
                {
                    whereStr = " ID=" + ID;
                }


                int recordCount = -1;
                int pageCount = -1;
                // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                IList<WG_HelpRequestEntity> _HelpRequest = DataProvider.GetInstance().GetWG_HelpRequestList(count, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                //如果所有数据分页后的总页数比请求的页数小,则返回空。
                if (int.Parse(PageIndex) > pageCount)
                    _HelpRequest.Clear();


                IList<RequestView> requestList = new List<RequestView>();
                foreach (WG_HelpRequestEntity item in _HelpRequest)
                {
                    RequestView rv = new RequestView();
                    rv.ID = item.ID;
                    rv.HelpRequest = item;
                    requestList.Add(rv);
                }
                if (requestList.Count > 0)
                {
                    for (int i = 0; i < requestList.Count; i++)
                    {

                        WG_MenberEntity author = DataProvider.GetInstance().GetWG_MenberEntity(requestList[i].HelpRequest.PromoterID);
                        if (null != author)
                        {
                            requestList[i].Author = author;
                        }
                        WG_MenberEntity underTaker = DataProvider.GetInstance().GetWG_MenberEntity(requestList[i].HelpRequest.UnderTakerID);
                        if (null != underTaker)
                        {
                            requestList[i].Helper = underTaker;
                        }
                    }

                    //没有任何数据
                    jbo.code = 0;
                    jbo.data = requestList;
                    jbo.message = "成功。";
                    jbo.success = true;

                }
                else
                {
                    //没有任何数据
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "没有找到任何数据。";
                    jbo.success = false;
                }
            }
            catch (Exception ex)
            {
                //没有任何数据
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误。";
                jbo.success = false;
            }


            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

        }
コード例 #19
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            // todo: [KnownType(typeof(List<WG_ActivitiesEntity>))]

            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");

            JsonBaseObject jbo = new JsonBaseObject();
            string resultStr = string.Empty;

            try
            {
                string IDstr = context.Request["ID"];
                int ID = -1;
                int.TryParse(IDstr, out ID);
                if (ID < 0)
                {
                    //参数空
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "ID不合法";
                    jbo.success = false;
                }
                else
                {
                    //当前活动,ae.Status,0等待报名...,1活动正在进行(禁止报名),2,活动已结束
                    NoticeEntity ne = DataProvider.GetInstance().GetNoticeEntity(ID);

                    if (ne != null)
                    {
                        try
                        {
                            ne.AlreadyRead = 1;//已读
                            DataProvider.GetInstance().UpdateNotice(ne);

                            //成功
                            jbo.code = 0;
                            jbo.data = null;
                            jbo.message = "更新消息状态成功";
                            jbo.success = true;
                        }
                        catch (Exception ex)
                        {
                            //失败
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "更新消息状态失败";
                            jbo.success = false;
                        }
                    }
                    else
                    {                            
                        //失败
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "找不到指定id的消息内容";
                        jbo.success = false;
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            resultStr = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(resultStr);

        }
コード例 #20
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";
            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;
            try
            {//giftid,userid,validatecode
                string giftID = context.Request["giftID"];
                string menberID = context.Request["menberID"];
                string giftCount = context.Request["giftCount"];
                string status = context.Request["status"];//0已兑换,1已领取
                int count = 0;
                int.TryParse(giftCount, out count);
                if (string.IsNullOrEmpty(giftID) || string.IsNullOrEmpty(menberID) || string.IsNullOrEmpty(giftCount))
                {
                    //失败
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "礼物或领取人不存在,或兑换礼物的个数不能小于等于0";
                    jbo.success = false;
                }
                else
                {
                    WG_GiftsEntity ge = DataProvider.GetInstance().GetWG_GiftsEntity(int.Parse(giftID));
                    WG_MenberEntity me = DataProvider.GetInstance().GetWG_MenberEntity(int.Parse(menberID));
                    if (null != ge
                        && null != me
                        && me.Scores >= ge.NeedScores * count
                        && ge.Count >= count)
                    {
                        //1.在ongoinggift表中新增一条记录
                        WG_OnGoingGiftsEntity ogge = new WG_OnGoingGiftsEntity();
                        //领取码=年月日时分秒+id后四位(不够四位前补零)
                        string timespan = DateTime.Now.ToString("yyyyMMddhhmmss");
                        string idSub = string.Empty;
                        if (me.ID.ToString().Length < 4)
                            idSub = me.ID.ToString().PadLeft(4, '0');
                        else
                        {
                            idSub = me.ID.ToString().Substring(me.ID.ToString().Length - 4, 4);
                        }
                        ogge.Code = idSub + timespan;
                        ogge.MenberID = int.Parse(menberID);
                        ogge.GiftID = int.Parse(giftID);
                        ogge.Status = int.Parse(status);
                        ogge.Count = count;
                        ogge.CreateDate = DateTime.Now;
                        int addresult = DataProvider.GetInstance().AddWG_OnGoingGifts(ogge);
                        if (addresult >= 0)
                        {
                            //2.扣除兑换者的积分
                            me.Scores = me.Scores - ge.NeedScores * count;
                            if (!DataProvider.GetInstance().UpdateWG_Menber(me))
                            {
                                //失败
                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "扣除兑换者积分异常";
                                jbo.success = false;
                            }
                            else
                            {
                                //3.礼物表中的数量减去相应的数量
                                ge.Count = ge.Count - count;
                                if (!DataProvider.GetInstance().UpdateWG_Gifts(ge))
                                {
                                    //失败
                                    jbo.code = -1;
                                    jbo.data = null;
                                    jbo.message = "减去礼物剩余数量异常";
                                    jbo.success = false;
                                }
                                else
                                {
                                    //成功
                                    jbo.code = 0;
                                    jbo.data = null;
                                    jbo.message = "成功";
                                    jbo.success = true;
                                }
                            }
                        }
                        else
                        {
                            //失败
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "加入领取队列出错";
                            jbo.success = false;
                        }

                    }
                    else
                    {
                        //失败
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "礼物不存在或积分不够";
                        jbo.success = false;
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            #region 返回json

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);

            #endregion
        }
コード例 #21
0
        public void ProcessRequest(HttpContext context)
        {
            //1.承接
            //2.完成操作
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";
            JsonBaseObject jbo = new JsonBaseObject();
            string resultStr = string.Empty;
            try
            {

                string helpRequestStr = context.Request["helpRequestID"];//请求单号
                string underTakerStr = context.Request["underTakerID"]; //接单者ID
                string status = context.Request["status"]; //动作状态
                int helpRequestID = int.Parse(helpRequestStr);
                int underTakerID = int.Parse(underTakerStr);
                WG_HelpRequestEntity currEntity = DataProvider.GetInstance().GetWG_HelpRequestEntity(helpRequestID);
                WG_MenberEntity underTaker = new WG_MenberEntity();
                WG_MenberEntity Requestor = DataProvider.GetInstance().GetWG_MenberEntity(currEntity.PromoterID);
                if (currEntity != null)
                {
                    if (currEntity.Status > 1)
                    {
                        //非法操作
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "单子已完成";
                        jbo.success = false;

                        resultStr = JsonSerializer<JsonBaseObject>(jbo);
                        context.Response.Write(resultStr);
                    }
                    else
                    {
                        if (currEntity.Status == 0 && status == "1")
                        {
                            #region 接单===配对
                            //承接
                            currEntity.Status = 1;
                            if (!string.IsNullOrEmpty(underTakerStr))
                                currEntity.UnderTakerID = underTakerID;

                            currEntity.UpdateDate = DateTime.Now;

                            //统一更新单子
                            bool result = DataProvider.GetInstance().UpdateWG_HelpRequest(currEntity);
                            if (result)
                            {
                                //接单成功
                                jbo.code = 0;
                                jbo.data = null;
                                jbo.message = "接单成功。";
                                jbo.success = true;

                            }
                            else
                            {
                                //接单失败
                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "接单失败。";
                                jbo.success = false;
                            }

                            #region 通知接单人

                            NoticeEntity ne = new NoticeEntity();
                            ne.Title = "您的求助/帮助已被承接";
                            ne.ToUserID = currEntity.PromoterID.ToString();//通知发帖人
                            ne.NoticeType = 1;//1求助帮助,2.活动类型,3.礼物类型
                            ne.LinkId = currEntity.ID;
                            ne.CreateDate = DateTime.Now;
                            ne.NoticeContent = "您的承接的求助单[ " + currEntity.Title + " ]已被承接。";
                            try
                            {
                                DataProvider.GetInstance().AddNotice(ne);
                            }
                            catch (Exception ex)
                            {

                            }
                            #endregion

                            #region respone

                            resultStr = JsonSerializer<JsonBaseObject>(jbo);
                            context.Response.Write(resultStr);

                            #endregion

                            #endregion
                        }
                        else if (currEntity.Status == 1 && status == "2")
                        {
                            #region 完成订单

                            currEntity.Status = 2;
                            currEntity.UpdateDate = DateTime.Now;
                            //完成
                            underTaker = DataProvider.GetInstance().GetWG_MenberEntity(currEntity.UnderTakerID);
                            //2.更新承接人服务时常
                            if (currEntity.Type == 1 && underTaker != null)
                            {
                                underTaker.ServiceHours += currEntity.Duration;
                                underTaker.Scores += currEntity.Duration * 60;
                                //积分明细

                            }
                            else if (currEntity.Type == 2 && Requestor != null)
                            {
                                Requestor.ServiceHours += currEntity.Duration;
                                Requestor.Scores += currEntity.Duration * 60;
                            }
                            else
                            {
                                //接单人不存在
                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "接单人不存在";
                                jbo.success = false;

                                #region respone

                                resultStr = JsonSerializer<JsonBaseObject>(jbo);
                                context.Response.Write(resultStr);

                                #endregion
                            }

                            //统一更新单子
                            bool result = DataProvider.GetInstance().UpdateWG_HelpRequest(currEntity);
                            if (!result)
                            {
                                #region 更新订单出错

                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "更新订单出错";
                                jbo.success = false;

                                #region respone

                                resultStr = JsonSerializer<JsonBaseObject>(jbo);
                                context.Response.Write(resultStr);

                                #endregion

                                #endregion
                            }
                            //3.承接者数据更新
                            bool utakerResult = false;
                            if (currEntity.Type == 1)
                                utakerResult = DataProvider.GetInstance().UpdateWG_Menber(underTaker);
                            else if (currEntity.Type == 2)
                                utakerResult = DataProvider.GetInstance().UpdateWG_Menber(Requestor);
                            if (!result)
                            {
                                #region 更新接单人信息出错

                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "更新接单人信息出错";
                                jbo.success = false;

                                #region respone

                                resultStr = JsonSerializer<JsonBaseObject>(jbo);
                                context.Response.Write(resultStr);

                                #endregion

                                #endregion
                            }
                            else
                            {

                                #region 通知接单人
                                //1.
                                NoticeEntity ne = new NoticeEntity();
                                ne.Title = "您承接的单被发起人标记为完成状态";
                                ne.ToUserID = underTaker.ID.ToString();
                                ne.NoticeType = 1;//1求助帮助,2.活动类型,3.礼物类型
                                ne.LinkId = currEntity.ID;
                                ne.CreateDate = DateTime.Now;
                                ne.NoticeContent = "您的承接的求助单[ " + currEntity.Title + " ]已被发起人完成,您已获得:" + currEntity.Duration + "的积分和服务时常累积。感谢您的爱心奉献与付出。";
                                try
                                {
                                    DataProvider.GetInstance().AddNotice(ne);
                                }
                                catch (Exception ex)
                                {

                                }
                                #endregion
                                #region 完成订单成功
                                //接单成功
                                jbo.code = 0;
                                jbo.data = null;
                                jbo.message = "完成订单成功。";
                                jbo.success = true;

                                #endregion
                                #region respone

                                resultStr = JsonSerializer<JsonBaseObject>(jbo);
                                context.Response.Write(resultStr);

                                #endregion
                            }

                            #endregion
                        }
                        else if (currEntity.Status == 1 && status == "3")
                        {

                            #region 失约重发 20160110


                            #region 通知接单人
                            //1.
                            string noticeMsg = "";
                            NoticeEntity ne = new NoticeEntity();
                            ne.Title = "您承接的单被发起人标记为失约并重新发布了";
                            ne.ToUserID = currEntity.UnderTakerID.ToString();
                            ne.NoticeType = 1;//1求助帮助,2.活动类型,3.礼物类型
                            ne.LinkId = currEntity.ID;
                            ne.CreateDate = DateTime.Now;

                            ne.NoticeContent = "您的承接的求助单[ " + currEntity.Title + " ]已被发起人重新发出,您此次失约了,请注意与发帖人沟通好。";
                            try
                            {
                                DataProvider.GetInstance().AddNotice(ne);
                            }
                            catch (Exception ex)
                            {
                                noticeMsg = ex.ToString();
                            }
                            #endregion

                            try
                            {
                                //1.修改订单的状态,从已配对(1)改回原来的待配对(0)
                                currEntity.Status = 0;
                                //2.清空承接人信息
                                currEntity.UnderTakerID = -1;//表示没有人承接
                                currEntity.UpdateDate = DateTime.Now;

                                DataProvider.GetInstance().UpdateWG_HelpRequest(currEntity);
                                //接单成功
                                jbo.code = 0;
                                jbo.data = null;
                                jbo.message = "失约重发成功。" + noticeMsg;
                                jbo.success = true;
                            }
                            catch (Exception)
                            {
                                jbo.code = -1;
                                jbo.data = null;
                                jbo.message = "失约重发失败。";
                                jbo.success = false;
                                throw;
                            }


                            #region respone

                            resultStr = JsonSerializer<JsonBaseObject>(jbo);
                            context.Response.Write(resultStr);

                            #endregion
                            #endregion
                        }
                        else
                        {
                        }
                    }
                }
                else
                {
                    //失败
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "所更新的记录不存在。";
                    jbo.success = false;
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }


        }
コード例 #22
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                string opc = context.Request["opc"];//1为加入团队,2为退出团队,3解散团队,4获取团队成员,5.创建团队
                string menberid = context.Request["menberid"];
                string teamid = context.Request["teamid"];
                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];
                if (string.IsNullOrEmpty(menberid)
                    || string.IsNullOrEmpty(teamid)
                    || string.IsNullOrEmpty(opc))
                {
                    //失败
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "参数:用户ID,团队ID和操作代码都不能为空";
                    jbo.success = false;
                }
                else
                {
                    string whereStr = " 1=1 ";
                    if ("1".Equals(opc.Trim()))
                    {
                        #region 加入团队

                        whereStr += " and menberid=" + menberid + " AND teamid=" + teamid;
                        IList<WG_OnGoingTeamEntity> ogteList = DataProvider.GetInstance().GetWG_OnGoingTeamList(whereStr);
                        if (ogteList != null && ogteList.Count > 0)
                        {
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.success = false;
                            jbo.message = "你已经加入了团队,无需重复加入";
                        }
                        else
                        {
                            //加入团队
                            WG_OnGoingTeamEntity ogte = new WG_OnGoingTeamEntity();
                            ogte.MenberID = int.Parse(menberid);
                            ogte.TeamID = int.Parse(teamid);
                            ogte.CreateDate = DateTime.Now;
                            DataProvider.GetInstance().AddWG_OnGoingTeam(ogte);

                            #region 通知创建团队的那个人 add by frde 20160130

                            WG_TeamEntity te = DataProvider.GetInstance().GetWG_TeamEntity(ogte.TeamID);
                            if(te!= null)
                            {
                                AddNoticeToWG("新队员加入信息", "您好,ID为: "+ menberid.ToString()+" 的用户加入了您创建的团队:[ "+te.Name+" ]", te.CaptainID.ToString());
                            }


                            #endregion

                            jbo.code = 0;
                            jbo.data = null;
                            jbo.success = true;
                            jbo.message = "成功加入团队";
                        }
                        #endregion
                    }
                    else if ("2".Equals(opc.Trim()))
                    {
                        #region 退出团队

                        whereStr += " and menberid=" + menberid + " AND teamid=" + teamid;
                        IList<WG_OnGoingTeamEntity> ogteList = DataProvider.GetInstance().GetWG_OnGoingTeamList(whereStr);
                        if (ogteList != null && ogteList.Count > 0)
                        {
                            foreach (WG_OnGoingTeamEntity item in ogteList)
                            {
                                DataProvider.GetInstance().DeleteWG_OnGoingTeam(item.ID);
                            }

                            #region 通知创建团队的那个人 add by frde 20160130

                            WG_TeamEntity te = DataProvider.GetInstance().GetWG_TeamEntity(int.Parse(teamid));
                            if (te != null)
                            {
                                AddNoticeToWG("队友退出团队信息", "您好,ID为: " + menberid.ToString() + " 的用户退出了您创建的团队:[ " + te.Name + " ]", te.CaptainID.ToString());
                            }


                            #endregion
                            //成功
                            jbo.code = 0;
                            jbo.data = null;
                            jbo.success = true;
                            jbo.message = "成功退出团队";

                        }
                        else
                        {
                            //还未加入团队
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "你尚未加入团队";
                            jbo.success = false;
                        }
                        #endregion
                    }
                    else if ("3".Equals(opc))
                    {
                        #region 解散团队
                        //1删除团队信息
                        DataProvider.GetInstance().DeleteWG_Team(int.Parse(teamid));

                        //2.删除所有已经加入团队的关系
                        whereStr += " And Teamid=" + teamid;
                        IList<WG_OnGoingTeamEntity> ote = DataProvider.GetInstance().GetWG_OnGoingTeamList(whereStr);
                        if (ote != null && ote.Count > 0)
                        {
                            WG_TeamEntity te = DataProvider.GetInstance().GetWG_TeamEntity(int.Parse(teamid));
                            foreach (WG_OnGoingTeamEntity item in ote)
                            {
                                DataProvider.GetInstance().DeleteWG_OnGoingTeam(item.ID);

                                #region 通知创建团队的那个人 add by frde 20160130

                                if (te != null)
                                {
                                    AddNoticeToWG("团队解散通知","你加入的团队:[ " + te.Name + " ]已 被解散,请知悉。", item.MenberID.ToString());
                                }


                                #endregion
                            }
                        }

                        jbo.code = 0;
                        jbo.data = null;
                        jbo.message = "团队解散成功";
                        jbo.success = true;
                        #endregion
                    }
                    else if ("4".Equals(opc))
                    {
                        #region 获取团队成员列表

                        whereStr += " And Teamid=" + teamid;
                        IList<WG_OnGoingTeamEntity> ote = DataProvider.GetInstance().GetWG_OnGoingTeamList(whereStr);
                        IList<WG_MenberEntity> meList = new List<WG_MenberEntity>();
                        if (ote != null && ote.Count > 0)
                        {
                            foreach (WG_OnGoingTeamEntity item in ote)
                            {
                                WG_MenberEntity me = DataProvider.GetInstance().GetWG_MenberEntity(item.MenberID);
                                meList.Add(me);
                            }
                        }
                        jbo.code = 0;
                        jbo.data = meList;
                        jbo.message = "获取团队成员列表成功";
                        jbo.success = true;

                        #endregion
                    }
                    else if ("5".Equals(opc))
                    {
                        //创建团队。判断权限
                        string name = context.Request["name"];
                        string captainid = context.Request["captainid"];
                        string linkman = context.Request["linkman"];
                        string linkphone = context.Request["linkphone"];
                        string linkaddress = context.Request["linkaddress"];
                        string teamaim = context.Request["teamaim"];
                        string serviceintention = context.Request["serviceintention"];
                        string region = context.Request["region"];


                        if (!string.IsNullOrEmpty(name)
                            && !string.IsNullOrEmpty(linkman)
                            && !string.IsNullOrEmpty(linkphone))
                        {
                            WG_TeamEntity te = new WG_TeamEntity();
                            te.Name = name;
                            te.CaptainID = int.Parse(menberid);
                            te.LinkAddress = linkaddress;
                            te.LinkMan = linkman;
                            te.LinkPhone = linkphone;
                            te.TeamAim = teamaim;
                            te.ServiceIntention = serviceintention;
                            te.Region = region;
                            te.CreateDate = DateTime.Now;
                            te.UpdateDate = DateTime.Now;
                            int newTeamid = DataProvider.GetInstance().AddWG_Team(te);

                            //创建完成,自己立马加入团队

                            WG_OnGoingTeamEntity ogte = new WG_OnGoingTeamEntity();
                            ogte.MenberID = int.Parse(menberid);
                            ogte.TeamID = newTeamid;
                            ogte.CreateDate = DateTime.Now;
                            DataProvider.GetInstance().AddWG_OnGoingTeam(ogte);

                            AddNoticeToWG("团队创建成功", "你的:[ " + te.Name + " ]团队已成功创建,请担当起团队责任。", te.CaptainID.ToString());
                            //创建成功
                            jbo.code = 0;
                            jbo.data = null;
                            jbo.message = "团队创建成功";
                            jbo.success = true;
                        }
                        else
                        {
                            //缺少必要信息,不能创建
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "标题,联系方式,联系人不能为空";
                            jbo.success = false;
                        }
                    }
                    else
                    {
                        #region 非法操作

                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "非法操作";
                        jbo.success = false;

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }
コード例 #23
0
        public void ProcessRequest(HttpContext context)
        {
            //todo:加入跨域允许语句
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;
            try
            {
                string userName = context.Request["menberName"];
                string email = context.Request["email"];
                if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(email))
                {
                    //失败
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "用户名称或邮箱地址不能为空";
                    jbo.success = false;
                }
                else
                {
                    string whereStr = " name='" + userName + "' and Email='" + email + "'";

                    IList<WG_MenberEntity> menberList = DataProvider.GetInstance().GetWG_MenberList(whereStr);
                    if (menberList == null || menberList.Count <= 0)
                    {
                        //账号与邮箱不匹配
                        jbo.code = -1;
                        jbo.data = null;
                        jbo.message = "邮箱与账号不匹配,请确认";
                        jbo.success = false;

                    }
                    else
                    {
                        List<string> emailTo = new List<string>() { email };
                        string fromAddress = DESEncrypt.Decrypt(ConfigurationManager.AppSettings["EmailAccount"].ToString(), "WYGY_BQGZS");
                        string fromName = ConfigurationManager.AppSettings["FromName"].ToString();
                        string subject = ConfigurationManager.AppSettings["Subject"].ToString();
                        string account = DESEncrypt.Decrypt(ConfigurationManager.AppSettings["EmailAccount"].ToString(), "WYGY_BQGZS");
                        string psw = DESEncrypt.Decrypt(ConfigurationManager.AppSettings["EmailPsw"].ToString(), "WYGY_BQGZS"); ;
                        string TimeStr = DateTime.Now.ToString();
                        string keyStrBeforeDec = userName + "|" + TimeStr;
                        string decKey = DESEncrypt.Encrypt(keyStrBeforeDec, "WYGY_BQGZS");
                        string body = ConfigurationManager.AppSettings["GetBackUrl"].ToString() + decKey;
                        string errorStr = "";
                        int count = SendEmail.SendEmailnonAnonymous(fromAddress, fromName, subject, body, emailTo, emailTo, out errorStr, account, psw);
                        if (count > 0)
                        {
                            jbo.code = 0;
                            jbo.data = null;
                            jbo.message = "邮件发送成功,请登陆邮件并根据链接重置密码";
                            jbo.success = true;
                        }
                        else
                        {
                            //失败
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.message = "邮件发送失败";
                            jbo.success = false;
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现异常。";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }
コード例 #24
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST");
            context.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
            context.Response.ContentType = "text/plain";

            JsonBaseObject jbo = new JsonBaseObject();
            string result = string.Empty;

            try
            {
                string menberID = context.Request["menberid"];
                string teamName = context.Request["teamname"];
                string PageIndex = "1";
                if (!string.IsNullOrEmpty(context.Request["PageIndex"]))
                    PageIndex = context.Request["PageIndex"];
                if (string.IsNullOrEmpty(menberID) && string.IsNullOrEmpty(teamName))
                {
                    //失败
                    jbo.code = -1;
                    jbo.data = null;
                    jbo.message = "参数必须有用户ID或者团队名称";
                    jbo.success = false;
                }
                else
                {
                    int recordCount = -1;
                    int pageCount = -1;
                    string whereStr = " 1=1 ";
                    if (!string.IsNullOrEmpty(menberID))
                    {
                        //MenberID不为空,则说明是获取用户已经加入的团队
                        whereStr += " AND MenberID=" + menberID;
                        // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                        IList<WG_OnGoingTeamEntity> OnGoingTeamList = DataProvider.GetInstance().GetWG_OnGoingTeamList(20, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                        //如果所有数据分页后的总页数比请求的页数小,则返回空。
                        if (int.Parse(PageIndex) > pageCount)
                            OnGoingTeamList.Clear();

                        if (OnGoingTeamList != null && OnGoingTeamList.Count > 0)
                        {
                            List<WG_TeamEntity> teList = new List<WG_TeamEntity>();
                            foreach (WG_OnGoingTeamEntity item in OnGoingTeamList)
                            {
                                WG_TeamEntity team = DataProvider.GetInstance().GetWG_TeamEntity(item.TeamID);
                                if (team != null)
                                {
                                    teList.Add(team);
                                }
                            }

                            jbo.code = 0;
                            jbo.data = teList;
                            jbo.success = true;
                            jbo.message = "成功获取用户所加入的团队列表。";
                        }
                        else
                        {
                            //不存在
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.success = false;
                            jbo.message = "你还没有加入任何团队。";
                        }
                    }
                    else if (!string.IsNullOrEmpty(teamName))
                    {
                        //teamName不为空,按团队名称模糊搜索
                        whereStr += " AND name like '%" + teamName + "%' ";
                        // 查找条件:如typeid=1 and promoterid=1 and undertakerid=1
                        IList<WG_TeamEntity> teList = DataProvider.GetInstance().GetWG_TeamList(20, int.Parse(PageIndex), " WHERE " + whereStr, " CreateDate Desc ", out recordCount, out pageCount);

                        //如果所有数据分页后的总页数比请求的页数小,则返回空。
                        if (int.Parse(PageIndex) > pageCount)
                            teList.Clear();

                        if (teList != null && teList.Count > 0)
                        {
                            jbo.code = 0;
                            jbo.data = teList;
                            jbo.success = true;
                            jbo.message = "成功获取查询的团队列表。";
                        }
                        else
                        {
                            //不存在
                            jbo.code = -1;
                            jbo.data = null;
                            jbo.success = false;
                            jbo.message = "查询的团队列表失败。";
                        }
                    }
                    else
                    {

                    }
                }
            }
            catch (Exception ex)
            {
                //失败
                jbo.code = -1;
                jbo.data = null;
                jbo.message = "接口调用过程中出现其他错误";
                jbo.success = false;
            }

            result = JsonSerializer<JsonBaseObject>(jbo);
            context.Response.Write(result);
        }