Пример #1
0
        public List <InformationModel> GetInformation(string condition, Guid adminId)
        {
            // InformationModel List 最终提交到页面的数据集
            // InformationModel 继承至 Information
            // 目的是为了包含FollowModel List
            List <InformationModel> InformationModelList = new List <InformationModel>();
            List <Information>      InformationList      = new List <Information>();

            if (string.IsNullOrEmpty(condition))
            {
                // 如果condition没有值
                // 首先获取前50条数据记录到 InformationList
                InformationList = _informationBLL.GetInformationByAnythingswithGroupLeader(50, adminId).ToList();
            }
            else
            {
                // 如果condition有值 就按条件查询
                InformationList = _informationBLL.GetInformationByAnythingswithGroupLeader(condition, adminId).ToList();
            }

            List <Information> InfoList = new List <Information>();

            InfoList = InformationList.ToList();

            // 然后循环InformationList

            // 构造 InformationModelList

            foreach (Information item in InformationList)
            {
                InformationModel info = new InformationModel(item);

                List <FollowModel> followModelList = new List <FollowModel>();

                List <FollowRecord> followRecordList = new List <FollowRecord>();
                followRecordList = _followRecordBLL.GetFollowRecordByInformationId(info.Id).ToList();

                foreach (FollowRecord fr in followRecordList)
                {
                    FollowModel fm = new FollowModel();
                    fm.FollowName  = _followBLL.GetFollow(fr.FollowId).FollowItem;
                    fm.FollowValue = fr.FollowValue;

                    followModelList.Add(fm);
                }

                info.FollowList = followModelList.AsEnumerable();
                // 获取收集员的账号

                var m = _memberBLL.GetMemberById(info.MemberId);

                if (m != null)
                {
                    info.MemberAccount = m.Account;
                    InformationModelList.Add(info);
                }
            }

            return(InformationModelList);
        }
Пример #2
0
        public List <InformationModel> GetInformation(string condition)
        {
            // InformationModel List 最终提交到页面的数据集
            // InformationModel 继承至 Information
            // 目的是为了包含FollowModel List
            List <InformationModel> InformationModelList = new List <InformationModel>();
            List <Information>      InformationList      = new List <Information>();

            if (string.IsNullOrEmpty(condition))
            {
                // 如果condition没有值
                // 首先获取前50条数据记录到 InformationList
                InformationList = _informationBLL.GetinformationLimitedwithSpecificMember(50, System.Web.HttpContext.Current.Session["member"].ToString()).ToList();
            }
            else
            {
                // 如果condition有值 就按条件查询
                InformationList = _informationBLL.GetInformationByAnythingswithSpecificMember(condition, System.Web.HttpContext.Current.Session["member"].ToString()).ToList();
            }

            List <Information> InfoList = new List <Information>();

            InfoList = InformationList.ToList();

            // 然后循环InformationList
            // 构造 InformationModelList
            foreach (Information item in InformationList)
            {
                InformationModel info = new InformationModel(item);

                List <FollowModel> followModelList = new List <FollowModel>();

                List <FollowRecord> followRecordList = new List <FollowRecord>();
                followRecordList = _followRecordBLL.GetFollowRecordByInformationId(info.Id).ToList();

                foreach (FollowRecord fr in followRecordList)
                {
                    FollowModel fm = new FollowModel();
                    fm.FollowName  = _followBLL.GetFollow(fr.FollowId).FollowItem;
                    fm.FollowValue = fr.FollowValue;

                    followModelList.Add(fm);
                }

                info.FollowList = followModelList.AsEnumerable();
                // 获取收集员的账号
                info.MemberAccount = _memberBLL.GetMemberById(info.MemberId).Account;
                InformationModelList.Add(info);
            }

            return(InformationModelList);
        }
        public ActionResult Update()
        {
            if (Request.IsAjaxRequest())
            {
                var    stream = HttpContext.Request.InputStream;
                string json   = new StreamReader(stream).ReadToEnd();

                try
                {
                    //JArray jarray = (JArray)JsonConvert.DeserializeObject(json);
                    List <KeyValuePair <string, string> > kvList = JsonToList(json);
                    Information infor = _informationBLL.GetInformationById(Guid.Parse(kvList.SingleOrDefault(n => n.Key == "id").Value));

                    #region 给information赋值

                    infor.Address  = kvList.Where(n => n.Key == "address").SingleOrDefault().Value;
                    infor.Age      = kvList.SingleOrDefault(n => n.Key == "age").Value;
                    infor.Children = kvList.SingleOrDefault(n => n.Key == "children").Value;

                    infor.Email    = kvList.SingleOrDefault(n => n.Key == "email").Value;
                    infor.HasCar   = kvList.SingleOrDefault(n => n.Key == "hascar").Value;
                    infor.HasHouse = kvList.SingleOrDefault(n => n.Key == "hashouse").Value;
                    infor.Hobby    = kvList.SingleOrDefault(n => n.Key == "hobby").Value;

                    infor.Income   = kvList.SingleOrDefault(n => n.Key == "income").Value;
                    infor.Industry = kvList.SingleOrDefault(n => n.Key == "industry").Value;

                    infor.IsMarry = kvList.SingleOrDefault(n => n.Key == "ismarry").Value;

                    infor.Occupation = kvList.SingleOrDefault(n => n.Key == "occupation").Value;
                    infor.Phone      = kvList.SingleOrDefault(n => n.Key == "phone").Value;
                    infor.QQ         = kvList.SingleOrDefault(n => n.Key == "qq").Value;
                    infor.Sex        = kvList.SingleOrDefault(n => n.Key == "sex").Value;
                    infor.WebCat     = kvList.SingleOrDefault(n => n.Key == "webcat").Value;
                    infor.Note1      = kvList.SingleOrDefault(n => n.Key == "note1").Value;
                    infor.Note2      = kvList.SingleOrDefault(n => n.Key == "note2").Value;
                    infor.Note3      = kvList.SingleOrDefault(n => n.Key == "note3").Value;
                    #endregion

                    #region 添加FollowRecord
                    if (_informationBLL.Update(infor))
                    {
                        // 修改information 成功后
                        // 获取当前FollowRecord中 inforid == 刚才的infor.id的 跟进项列表
                        List <FollowRecord> frList = _followRecordBLL.GetFollowRecordByInformationId(infor.Id).ToList();

                        // 获取当前所有的跟进项

                        // 由于存在 跟进项表中新添加了跟进项 而 FollowRecord 中没有更新 这样的情况

                        // 所以 有时 frList 的项 会比 followList 的项会少

                        // 所以在更新followrecord时 要先判断 操作的 FollowRecord 是否为空

                        // 如果为空则新添加 followrecord  如果不为空 则更新原来的数据

                        List <Follow> followList = _followBLL.GetAllFollow().ToList();

                        // 开始更新跟进项
                        foreach (var item in followList)
                        {
                            // 这里 keyvaluepair<string,string> 的项数 一定是和 followList的项数相等的
                            // 所以不从这里判断是否有新的跟进项
                            KeyValuePair <string, string> kvp = kvList.SingleOrDefault(n => n.Key == item.FollowItem);

                            FollowRecord fr = frList.SingleOrDefault(n => n.FollowId == item.Id);

                            if (fr == null)
                            {
                                fr             = new FollowRecord();
                                fr.Id          = Guid.NewGuid();
                                fr.FollowId    = item.Id;
                                fr.InforId     = infor.Id;
                                fr.FollowValue = kvp.Value;

                                _followRecordBLL.Add(fr);
                            }
                            else
                            {
                                fr.FollowValue = kvp.Value;
                                _followRecordBLL.Update(fr);
                            }
                        }

                        return(Json("True", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json("False", JsonRequestBehavior.AllowGet));
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    LogHelper.Log.Write(ex.Message);
                    LogHelper.Log.Write(ex.StackTrace);

                    return(Json("False", JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }
        }