Пример #1
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            CY.UME.Core.AccountSearchJson json = new CY.UME.Core.AccountSearchJson();
            int universityId = 0;
            //int collegeId = 0;// 2009年11月17日加的学院

            string name = CY.Utility.Common.StringUtility.RemoveIllegalCharacters(FindWithName.Value.Trim());
            int gender = -1;

            if (RBGenderFemale.Checked)
            {
                gender = 0;
            }
            else if (RBGenderMale.Checked)
            {
                gender = 1;
            }
            string Interest = string.Empty;
            if (this.Interest.SelectedValue != "0")
            {
                Interest = this.Interest.SelectedValue;
            }
            json.Gender = gender;

            switch (Age.SelectedIndex)
            {
                case 1: json.MinYear = 2010 - 22;
                    json.MaxYear = 2010 - 16;
                    break;
                case 2: json.MinYear = 2010 - 30;
                    json.MaxYear = 2010 - 23;
                    break;
                case 3: json.MinYear = 1900;
                    json.MaxYear = 2010 - 31;
                    break;
                default: json.MinYear = 0;
                    json.MaxYear = 0;
                    break;
            }
            json.Name = name;
            json.ResideCityId = ProvinceCityReside.CityId;
            json.ResideProvinceId = ProvinceCityReside.ProvinceId;

            json.IsPublic = false;
            if (int.TryParse(selUniversity.Value, out universityId) && universityId != 0)
            {
                json.UniversityID = universityId;
            }

            json.Interest = Interest;
            Session["search"] = json;
            Response.Redirect("~/SearchResult.aspx");
        }
Пример #2
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            CY.UME.Core.AccountSearchJson json = new CY.UME.Core.AccountSearchJson();
            int universityId = 0;
            int collegeId = 0;// 2009年11月17日加的学院

            string name = CY.Utility.Common.StringUtility.RemoveIllegalCharacters(TxtName.Text.Trim());
            int gender = -1;

            if (RBGenderFemale.Checked)
            {
                gender = 0;
            }
            else if (RBGenderMale.Checked)
            {
                gender = 1;
            }

            json.Gender = gender;
            json.HometownCityId = ProvinceCityHometown.CityId;
            json.HometownProvinceId = ProvinceCityHometown.ProvinceId;
            json.Name = name;
            json.ResideCityId = ProvinceCityReside.CityId;
            json.ResideProvinceId = ProvinceCityReside.ProvinceId;
            json.BirthDate = Utility.Common.ConvertUtility.ConvertToByte(DayHF.Value.Trim(), 0);
            json.BirthMonth = Utility.Common.ConvertUtility.ConvertToByte(MonthHF.Value.Trim(), 0);
            json.BirthYear = Utility.Common.ConvertUtility.ConvertToByte(YearHF.Value.Trim(), 0);
            json.IsPublic = false;
            if (int.TryParse(selUniversity.Value, out universityId) && universityId != 0)
            {
                json.UniversityID = universityId;
            }
            if (int.TryParse(selCollege.Value, out collegeId) && collegeId != 0)
            {
                json.CollegeId = collegeId;
            }
            Session["search"] = json;
            Response.Redirect("~/SearchResult.aspx");
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            CY.UME.Core.Business.Account account;
            int pageSize;
            int pageNum;
            long spaceAccountId = 0;
            CY.UME.Core.AccountSearchJson searchJson = new CY.UME.Core.AccountSearchJson();

            #region -Validateion and Get Data -

            account = CY.UME.Core.Global.GetCurrentAccount();
            if (account == null)
            {
                context.Response.Write("{success: false, msg: '用户登录超时,请重新登录!'}");
                return;
            }

            CY.Utility.Common.ParseUtility.TryParseInt64(context.Request.Form["uid"], out spaceAccountId);

            if (!CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageSize"], out pageSize) ||
                !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageNum"], out pageNum))
            {
                context.Response.Write("{success: false, msg: '搜索参数错误!'}");
                return;
            }

            try
            {
                searchJson = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(context.Request.Form["search"].ToString(),
                    typeof(CY.UME.Core.AccountSearchJson))
                    as CY.UME.Core.AccountSearchJson;
            }
            catch
            {
                context.Response.Write("{success: false, msg: '搜索参数错误!'}");
                return;
            }

            #endregion

            try
            {
                StringBuilder sb = new StringBuilder();
                searchJson.Name = CY.Utility.Common.StringUtility.RemoveIllegalCharacters(searchJson.Name);
                List<CY.UME.Core.Business.Account> accounts = new List<CY.UME.Core.Business.Account>();

                if (spaceAccountId > 0) // 获取好友
                {
                    CY.UME.Core.Business.Account spaceAccount;

                    if (spaceAccountId == account.Id)
                    {
                        spaceAccount = account;
                    }
                    else
                    {
                        spaceAccount = CY.UME.Core.Business.Account.Load(spaceAccountId);

                        if (spaceAccount == null)
                        {
                            context.Response.Write("{success: false, msg: '参数错误!'}");
                            return;
                        }
                    }

                    List<CY.UME.Core.Business.Friendship> fsList = spaceAccount.GetFriendships(new CY.UME.Core.PagingInfo { CurrentPage = pageNum, PageSize = pageSize });
                    foreach (CY.UME.Core.Business.Friendship fs in fsList)
                    {
                        accounts.Add(fs.Friend);
                    }
                }
                else // 普通搜索
                {
                    accounts = CY.UME.Core.Business.Account.GetAccounts(searchJson,
                        new CY.UME.Core.PagingInfo { CurrentPage = pageNum, PageSize = pageSize });
                }

                sb.Append("{success: true,Id:'" + account.Id.ToString() + "', accounts: [");

                CY.UME.Core.Business.University university;
                string universityName = "暂无";
                foreach (CY.UME.Core.Business.Account a in accounts)
                {
                    if (a.ExtendInfo != null && a.ExtendInfo.UniversityId > 0)
                    {
                        university = CY.UME.Core.Business.University.Load(a.ExtendInfo.UniversityId);
                        if (university != null)
                        {
                            universityName = university.Name;
                        }

                    }

                    sb.Append("{Id: ");
                    sb.Append(a.Id);
                    sb.Append(", Name: '");
                    sb.Append(a.Name);
                    sb.Append("', fs: ");
                    if (account.HasFriendshipWith(a))
                    {
                        sb.Append("true");
                    }
                    else
                    {
                        sb.Append("false");
                    }
                    sb.Append(", follow: ");
                    if (account.HasFollowedWith(a))
                    {
                        sb.Append("true");
                    }
                    else
                    {
                        sb.Append("false");
                    }
                    sb.Append(", univeristyName: '");
                    sb.Append(CY.Utility.Common.StringUtility.EscapeString(universityName));
                    sb.Append("'");

                    sb.Append("},");

                }
                if (accounts.Count > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                }
                sb.Append("]}");

                context.Response.Write(sb.ToString());
            }
            catch
            {
                context.Response.Clear();
                context.Response.Write("{success: false, msg: '服务器忙,请稍后再试!'}");
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CY.UME.Core.AccountSearchJson json = new CY.UME.Core.AccountSearchJson();
            CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = pageSize };
            List<CY.UME.Core.Business.Account> results = new List<CY.UME.Core.Business.Account>();

            if (CY.Utility.Common.ParseUtility.TryParseInt64(Request.QueryString["uid"], out accountId)) // 搜好友
            {
                CY.UME.Core.Business.Account spaceAccount;

                if (accountId != CurrentAccount.Id)
                {
                    spaceAccount = CY.UME.Core.Business.Account.Load(accountId);
                }
                else
                {
                    spaceAccount = CurrentAccount;
                }

                count = spaceAccount.GetFriendsCount();
                List<CY.UME.Core.Business.Friendship> fslist = spaceAccount.GetFriendships(pagingInfo);

                foreach (CY.UME.Core.Business.Friendship fs in fslist)
                {
                    if (fs.Friend != null)
                    {
                        results.Add(fs.Friend);
                    }
                }

                HF_UId.Value = accountId.ToString();

                SetTitle("好友列表");
            }
            else
            {
                if (!string.IsNullOrEmpty(Request.QueryString["n"])) // 按名称搜索
                {
                    string name = Request.QueryString["n"];
                    json = new CY.UME.Core.AccountSearchJson { Name = Server.UrlDecode(name) };
                    SetTitle("用户搜索");
                }
                else if (Session["search"] != null)// 高级搜索
                {
                    json = Session["search"] as CY.UME.Core.AccountSearchJson;

                    if (json == null)
                    {
                        json = new CY.UME.Core.AccountSearchJson();
                    }
                    SetTitle("用户搜索");
                }
                else // 其它
                {
                }

                count = CY.UME.Core.Business.Account.GetAccountsCount(json);
                results = CY.UME.Core.Business.Account.GetAccounts(json, pagingInfo);

                LblSearchNum.Text = "共" + (count <= 500 ? count.ToString() : "500+") + "个搜索结果";
                LblOverRecordNum.Text = "共" + (count > 0 ? count.ToString() : "0") + "条记录";
                LblUnderRecordNum.Text = "共" + (count > 0 ? count.ToString() : "0") + "条记录";
                HF_TotalSearchResult.Value = count.ToString();
                HF_SiteUrl.Value = SiteUrl;
                HF_CurrentAccount_Id.Value = CurrentAccount.Id.ToString();
            }

            AccountList1.Accounts = results;
            AccountList1.CurrentAccount = CurrentAccount;

            searchCondition = Newtonsoft.Json.JavaScriptConvert.SerializeObject(json);
            HF_SearchName.Value = searchCondition;
        }
Пример #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            CY.UME.Core.Business.Account account;
            int pageSize;
            int pageNum;

            CY.UME.Core.AccountSearchJson searchJson = new CY.UME.Core.AccountSearchJson();

            #region -Validateion and Get Data -

            account = CY.UME.Core.Global.GetCurrentAccount();

            if (account==null)
            {
                context.Response.Write("{success: false, msg: '用户登录超时,请重新登录!'}");
                return;
            }

            if (!CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageSize"], out pageSize) ||
                !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageNum"], out pageNum))
            {
                context.Response.Write("{success: false, msg: '搜索参数错误!'}");
                return;
            }

            #endregion

            try
            {
                StringBuilder sb = new StringBuilder();
                List<CY.UME.Core.Business.Account> accounts = new List<CY.UME.Core.Business.Account>();

                CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo();
                pagingInfo.CurrentPage = pageNum;
                pagingInfo.PageSize = pageSize;

                IList<CY.UME.Core.Business.Friendship> friendShipList = CY.UME.Core.Business.Friendship.GetRequestFriendList(account,pagingInfo);

                foreach (CY.UME.Core.Business.Friendship fs in friendShipList)
                {
                    CY.UME.Core.Business.Account accountfriend = CY.UME.Core.Business.Account.Load(fs.AccountId);

                    accounts.Add(accountfriend);
                }

                sb.Append("{success: true, accounts: [");

                int i=0;
                foreach (CY.UME.Core.Business.Account a in accounts)
                {
                    sb.Append("{Id: ");
                    sb.Append(a.Id);
                    sb.Append(", Name: '");
                    sb.Append(a.Name);
                    sb.Append("', ResideAddress: '");

                    if (a.ExtendInfo != null && account.ExtendInfo.ResideProvinceId != 0 && a.ExtendInfo.ResideCityId != 0)
                    {
                        sb.Append(a.ExtendInfo.ResideProvinceId == 0 ? "" : a.ExtendInfo.ResideProvince.Name + " ");
                        sb.Append(a.ExtendInfo.ResideCityId == 0 ? "" : a.ExtendInfo.ResideCity.Name);
                    }

                    sb.Append("',Remark:'");
                    sb.Append(friendShipList[i].Remark.Trim());
                    sb.Append("'},");
                    i++;
                }
                if (accounts.Count > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                }
                sb.Append("]}");

                context.Response.Write(sb.ToString());
            }
            catch
            {
                context.Response.Clear();
                context.Response.Write("{success: false, msg: '服务器忙,请稍后再试!'}");
            }
        }