Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
        public ActionResult Update(string followId, string followName)
        {
            Follow follow = new Follow();

            follow            = _followBLL.GetFollow(Guid.Parse(followId));
            follow.FollowItem = followName;

            bool res = false;

            using (DFYW_DbContext db = new DFYW_DbContext())
            {
                using (var trans = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Set <Follow>().Attach(follow);
                        db.Entry <Follow>(follow).State = System.Data.Entity.EntityState.Modified;

                        db.SaveChanges();
                        trans.Commit();

                        res = true;
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Log.Write(ex.Message);
                        LogHelper.Log.Write(ex.StackTrace);

                        trans.Rollback();
                        res = false;
                    }
                }
            }

            var obj = new
            {
                res    = res,
                follow = new
                {
                    Id   = followId,
                    Name = followName
                }
            };

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
        public ActionResult ImportData()
        {
            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 = new Information();

                    #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.CustomerName = kvList.SingleOrDefault(n => n.Key == "customerName").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.Id           = Guid.NewGuid();
                    infor.Income       = kvList.SingleOrDefault(n => n.Key == "income").Value;
                    infor.Industry     = kvList.SingleOrDefault(n => n.Key == "industry").Value;
                    infor.InserTime    = DateTime.Now.ToString("yyyy-MM-dd");
                    infor.IsMarry      = kvList.SingleOrDefault(n => n.Key == "ismarry").Value;
                    infor.MemberId     = _memberBLL.GetMemberByAccount(System.Web.HttpContext.Current.Session["Admin"].ToString(), 1).Id;
                    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.Add(infor))
                    {
                        List <Follow> followList = _followBLL.GetAllFollow().ToList();
                        foreach (var item in followList)
                        {
                            FollowRecord fr = new FollowRecord();
                            fr.FollowId    = _followBLL.GetFollow(item.FollowItem).Id;
                            fr.InforId     = infor.Id;
                            fr.Id          = Guid.NewGuid();
                            fr.FollowValue = kvList.SingleOrDefault(n => n.Key == item.FollowItem).Value;

                            _followRecordBLL.Add(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));
            }
        }