private void Button_NoPassTo1_Click(object sender, EventArgs e)
        {
            //不通过

            WG_MenberEntity _entity = DataProvider.GetInstance().GetWG_MenberEntity(int.Parse(ctrID));
            //当前身份
            string flagStr = _WG_MenberEntity.Flag == 1 ? "求助者" : _WG_MenberEntity.Flag == 2 ? "自愿者" : "游客";
            int flag = int.Parse(ddl_Flag.SelectedValue);
            _entity.Flag = flag;
            _entity.Status = 0;

            string flagStr2 = flag == 1 ? "求助者" : flag == 2 ? "自愿者" : "游客";
            DataProvider.GetInstance().UpdateWG_Menber(_entity);


            NoticeEntity ne = new NoticeEntity();
            ne.FromUserID = 0;
            ne.ToUserID = ctrID;
            ne.Title = "系统审核消息";
            ne.CreateDate = DateTime.Now;
            ne.NoticeContent = "您申请成为 [ " + flagStr + " ] 身份不通过,并贬为 ["+ flagStr2 + " ],请注意完善您个人的真实信息。";

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

            Alert("授权完成");

        }
        protected void init_form(string ctrID)
        {
            if (!string.IsNullOrEmpty(ctrID))
            {
                _NoticeEntity = DataProvider.GetInstance().GetNoticeEntity(int.Parse(ctrID));

               				                				                   TextBox_Title.Text = _NoticeEntity.Title.ToString();
                                				                   TextBox_NoticeContent.Text = _NoticeEntity.NoticeContent.ToString();
                                				                   TextBox_FromUserID.Text = _NoticeEntity.FromUserID.ToString();
                                				                   TextBox_ToUserID.Text = _NoticeEntity.ToUserID.ToString();
                                				                            }
        }
        protected void WG_MenberEditFunc(string ctrID)
        {
            //通过授权
            _WG_MenberEntity.Status = 0;
            try
            {
                //当前身份
                string flagStr = _WG_MenberEntity.Flag == 1 ? "求助者" : _WG_MenberEntity.Flag == 2 ? "自愿者" : "游客";
                DataProvider.GetInstance().UpdateWG_Menber(_WG_MenberEntity);

                NoticeEntity ne = new NoticeEntity();
                ne.FromUserID = 0;
                ne.ToUserID = ctrID;
                ne.Title = "系统审核消息";
                ne.CreateDate = DateTime.Now;
                ne.NoticeContent = "恭喜您,您申请成为 [ " + flagStr + " ] 身份已通过管理员审核。";

                //给用户一条消息
                DataProvider.GetInstance().AddNotice(ne);
            }
            catch
            {
                WriteLog("WG_MenberEditFunc", "用户授权", "用户授权时出错", Common.DailyUtility.MideSmsType.LogType.SystemLog);
                Alert("用户授权时出错,请重试");
                return;
            }
            Alert("用户授权成功", "");
        }
        protected void NoticeAdd()
        {
            #region 判断是否可空
		 
                                                                          
                  var _Title = Request.Form["TextBox_Title"];
                 if (string.IsNullOrEmpty(_Title))
                   {
                        Alert("[ 标题 ]不能为空");
                        return;
                  }
				                                           
                  var _NoticeContent = Request.Form["TextBox_NoticeContent"];
                 if (string.IsNullOrEmpty(_NoticeContent))
                   {
                        Alert("[ 通知正文 ]不能为空");
                        return;
                  }
				                                           
                  var _FromUserID = Request.Form["TextBox_FromUserID"];
                 if (string.IsNullOrEmpty(_FromUserID))
                   {
                        Alert("[ 发起人 ]不能为空");
                        return;
                  }
				                                           
                  var _ToUserID = Request.Form["TextBox_ToUserID"];
                 if (string.IsNullOrEmpty(_ToUserID))
                   {
                        Alert("[ 接收者ID ]不能为空");
                        return;
                  }
				                                                
	        #endregion
           
            #region 获取数据

            NoticeEntity  _NoticeEntity = new NoticeEntity();
            
               		                               	  		                            
                 	                 	                
                    _NoticeEntity.Title =Convert.ToString(_Title.ToString());
               		                        	  		                            
                 	                 	                
                    _NoticeEntity.NoticeContent =Convert.ToString(_NoticeContent.ToString());
               		                        	  		                            
                 	                 	                     _NoticeEntity.FromUserID =Convert.ToInt32(_FromUserID.ToString());
                	                        	  		                            
                 	                 	                
                    _NoticeEntity.ToUserID =Convert.ToString(_ToUserID.ToString());
               		                        	  		        
		       	_NoticeEntity.CreateDate =DateTime.Now;
		               	              try
            {
                DataProvider.GetInstance().AddNotice(_NoticeEntity);
            }
            catch
            {
                WriteLog("NoticeAdd", "添加Notice", "插入数据库时出错", Common.DailyUtility.MideSmsType.LogType.SystemLog);
                Alert("添加数据时出错,请重试");
                return;
            }
            Alert("添加Notice成功");
        }
Пример #5
0
        private MideFrameWork.Data.Entity.NoticeEntity GetNotice(DataRow dr)
        {
            MideFrameWork.Data.Entity.NoticeEntity info = new MideFrameWork.Data.Entity.NoticeEntity();
										if(DBNull.Value==dr["ID"])
					info.ID=0;
				else
					info.ID=int.Parse(dr["ID"].ToString());
									
																								
						if(DBNull.Value==dr["Title"])
				info.Title= string.Empty;
			else	
				info.Title= dr["Title"].ToString();
																								
						if(DBNull.Value==dr["NoticeContent"])
				info.NoticeContent= string.Empty;
			else	
				info.NoticeContent= dr["NoticeContent"].ToString();
																						if(DBNull.Value==dr["FromUserID"])
					info.FromUserID=0;
				else
					info.FromUserID=int.Parse(dr["FromUserID"].ToString());
									
																						if(DBNull.Value==dr["NoticeType"])
					info.NoticeType=0;
				else
					info.NoticeType=int.Parse(dr["NoticeType"].ToString());
									
																						if(DBNull.Value==dr["LinkId"])
					info.LinkId=0;
				else
					info.LinkId=int.Parse(dr["LinkId"].ToString());
									
																						if(DBNull.Value==dr["AlreadyRead"])
					info.AlreadyRead=0;
				else
					info.AlreadyRead=int.Parse(dr["AlreadyRead"].ToString());
									
																								
						if(DBNull.Value==dr["ToUserID"])
				info.ToUserID= string.Empty;
			else	
				info.ToUserID= dr["ToUserID"].ToString();
																									if(DBNull.Value==dr["CreateDate"])
					info.CreateDate=DateTime.Now;
				else
					info.CreateDate=DateTime.Parse(dr["CreateDate"].ToString());
						
															            return info;
        }
        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
        }
        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;
            }


        }