public IList <T_FileInfo> GetAll()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_FileInfo.ToList());
     }
 }
 public int Insert(T_FileInfo entity)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         try
         {
             dbContext.T_FileInfo.Add(entity);
             return(dbContext.SaveChanges());
         }
         catch (DbEntityValidationException dbEx)
         {
             var sbMessage = new StringBuilder("【EF错误】:\r\n");
             if (dbEx.EntityValidationErrors != null)
             {
                 foreach (var error in dbEx.EntityValidationErrors)
                 {
                     foreach (var errorChild in error.ValidationErrors)
                     {
                         sbMessage.AppendLine(string.Format("{0}:{1}", errorChild.PropertyName, errorChild.ErrorMessage));
                     }
                 }
             }
             throw new Exception(sbMessage.ToString());
         }
     }
 }
 public QQUser GetUserBy(string socialId)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.QQUsers.Where(u => u.OpenId == socialId).FirstOrDefault());
     }
 }
        /// <summary>
        /// 保存上传的app信息
        /// </summary>
        /// <param name="entity">app信息实体</param>
        /// <returns></returns>
        public bool SaveAppFile(T_APP_VERSION entity)
        {
            bool result = true;

            using (var dbContext = new DuPont_TestContext())
            {
                var existEntity = dbContext.T_APP_VERSION.Where(a => a.Platform == entity.Platform).FirstOrDefault();
                int saveRes     = 0;
                if (existEntity != null)
                {
                    entity.CREATE_DATE = existEntity.CREATE_DATE;
                    entity.Id          = existEntity.Id;
                    ClassValueCopyHelper.Copy(existEntity, entity);
                    saveRes = dbContext.SaveChanges();
                }
                else
                {
                    entity.UPDATE_DATE = null;
                    dbContext.T_APP_VERSION.Add(entity);
                    saveRes = dbContext.SaveChanges();
                }
            }

            return(result);
        }
 public T_SYS_SETTING GetSetting(string settingId)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_SYS_SETTING.Where(set => set.SETTING_ID == settingId).FirstOrDefault());
     }
 }
 public T_FARMER_PUBLISHED_DEMAND GetByKey(object key)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_FARMER_PUBLISHED_DEMAND.Find(key));
     }
 }
Beispiel #7
0
 public IList <T_AREA> GetAll()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_AREA.ToList());
     }
 }
Beispiel #8
0
 public IList <T_AREA> GetAll(System.Linq.Expressions.Expression <Func <T_AREA, bool> > predicate)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_AREA.Where(predicate).ToList());
     }
 }
Beispiel #9
0
 public T_AREA GetByKey(object key)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_AREA.Find(key));
     }
 }
Beispiel #10
0
 public IEnumerable <VM_GET_PENDING_AUDIT_LIST> vmgetpendingauitlist()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(this.vmgetpendingauitlist().ToList());
     }
 }
Beispiel #11
0
 public IEnumerable <TEntity> GetAll()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.Set <TEntity>().ToList());
     }
 }
 public IList <T_FARMER_PUBLISHED_DEMAND> GetAll()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_FARMER_PUBLISHED_DEMAND.ToList());
     }
 }
Beispiel #13
0
 public WeChatUser GetUserBy(string socialId)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.WeChatUsers.Where(u => u.UnionId != null && u.UnionId == socialId).FirstOrDefault());
     }
 }
Beispiel #14
0
 public T GetById <T>(Expression <Func <T, bool> > wherelambda) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.Set <T>().Where(wherelambda).FirstOrDefault());
     }
 }
 public IList <T_MENU_ROLE_RELATION> GetAll()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_MENU_ROLE_RELATION.ToList());
     }
 }
Beispiel #16
0
 /// <summary>
 /// 获取登陆者的经纬度
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public string GetCoordinate(long userId)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         string coordinate = "0|0";
         var    usermodel  = dbContext.T_USER.FirstOrDefault(u => u.Id == userId);
         if (usermodel != null)
         {
             string   code = "";
             string[] area = { usermodel.Province, usermodel.City, usermodel.Region, usermodel.Township, usermodel.Village };
             for (int i = 0; i < area.Length; i++)
             {
                 if (!string.IsNullOrEmpty(area[i]))
                 {
                     code = area[i];
                 }
             }
             var areamodel = dbContext.T_AREA.FirstOrDefault(a => a.AID == code);
             if (areamodel != null)
             {
                 if (!string.IsNullOrEmpty(areamodel.Lat) && !string.IsNullOrEmpty(areamodel.Lng))
                 {
                     coordinate = areamodel.Lat + "|" + areamodel.Lng;
                 }
                 else
                 {
                     coordinate = "0|0";
                 }
             }
         }
         return(coordinate);
     }
 }
Beispiel #17
0
 public bool CheckTypeid <T>(Expression <Func <T, bool> > wherelambda) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.Set <T>().Where(wherelambda).Count() > 0);
     }
 }
Beispiel #18
0
 public T_USER GetByWhere(Expression <Func <T_USER, bool> > wherelambda)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_USER.Where(wherelambda).FirstOrDefault());
     }
 }
Beispiel #19
0
        public List <CommentDetailModel> GetOperatorCommentDetail(long userid, int pageindex, int pagesize, out long TotalNums)
        {
            using (var dbContext = new DuPont_TestContext())
            {
                List <CommentDetailModel> list = new List <CommentDetailModel>();
                TotalNums = dbContext.T_FARMER_PUBLISHED_DEMAND
                            .Join(dbContext.T_FARMER_DEMAND_RESPONSE_RELATION, f => f.Id, a => a.DemandId, (f, a) => new { f = f, a = a })
                            .Join(dbContext.T_SYS_DICTIONARY, temp0 => temp0.f.DemandTypeId, b => b.Code, (temp0, b) => new { temp0 = temp0, b = b })
                            .Where(temp1 => ((temp1.temp0.a.UserId == userid) && (temp1.b.ParentCode == 100100) && (temp1.temp0.a.Score > 0 || (temp1.temp0.a.Comments != null && temp1.temp0.a.Comments.Length > 0)))).Count();
                if (TotalNums != 0)
                {
                    list = dbContext.T_FARMER_PUBLISHED_DEMAND
                           .Join(dbContext.T_FARMER_DEMAND_RESPONSE_RELATION, f => f.Id, a => a.DemandId, (f, a) => new { f = f, a = a })
                           .Join(dbContext.T_SYS_DICTIONARY, temp0 => temp0.f.DemandTypeId, b => b.Code, (temp0, b) => new { temp0 = temp0, b = b })
                           .Where(temp1 => ((temp1.temp0.a.UserId == userid) && (temp1.b.ParentCode == 100100) && (temp1.temp0.a.Score > 0 || (temp1.temp0.a.Comments != null && temp1.temp0.a.Comments.Length > 0))))
                           .OrderByDescending(temp1 => temp1.temp0.a.ReplyTime)
                           .Skip((pageindex - 1) * pagesize).Take(pagesize).ToList().Select(
                        temp1 => new CommentDetailModel
                    {
                        ExcuteUserName  = getUserName(dbContext.T_USER.Where(u => u.Id == temp1.temp0.f.CreateUserId).FirstOrDefault()),
                        Comments        = temp1.temp0.a.Comments ?? "",
                        Score           = temp1.temp0.a.Score,
                        CommentsTime    = Utility.TimeHelper.GetMilliSeconds(temp1.temp0.a.ReplyTime),
                        ExecuteUserId   = temp1.temp0.f.CreateUserId,
                        ExecuteRoleId   = (int)RoleType.Farmer,
                        ExecuteRoleName = RoleType.Farmer.GetDescription()
                    }).ToList();
                }



                return(list);
            }
        }
Beispiel #20
0
        public int GetUserCredit(Int64 userId, Entity.Enum.RoleType roleType)
        {
            using (var dbContext = new DuPont_TestContext())
            {
                switch (roleType)
                {
                case Entity.Enum.RoleType.Farmer:

                    //我发布的需求(产业商响应)
                    var creditFromSelfDemand = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION
                                                join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id
                                                where fpd.DemandTypeId > 100800 && fpd.DemandTypeId < 100900 && fpd.CreateUserId == userId && drr.Score >= 3
                                                select drr.Id).Count();

                    //产业商发布的需求(大农户响应)
                    var creditFromBusinessDemand = (from drr in dbContext.T_BUSINESS_DEMAND_RESPONSE_RELATION
                                                    join bpd in dbContext.T_BUSINESS_PUBLISHED_DEMAND on drr.DemandId equals bpd.Id
                                                    where bpd.DemandTypeId > 100200 && bpd.DemandTypeId < 100300 && drr.UserId == userId && drr.Score >= 3
                                                    select drr.Id).Count();
                    return(creditFromSelfDemand + creditFromBusinessDemand);

                case Entity.Enum.RoleType.MachineryOperator:
                    return(dbContext.T_FARMER_DEMAND_RESPONSE_RELATION.Count(c => c.UserId == userId && c.Score >= 3));
                }

                return(0);
            }
        }
Beispiel #21
0
 /// <summary>
 /// 获取所有角色的技能列表
 /// </summary>
 /// <returns></returns>
 public IList <SkillModel> GetSkill()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         List <T_SYS_DICTIONARY> list1 = dbContext.T_SYS_DICTIONARY.Where(s => s.ParentCode == 100100).ToList();
         list1 = list1 != null ? list1 : new List <T_SYS_DICTIONARY>();
         List <T_SYS_DICTIONARY> list2 = dbContext.T_SYS_DICTIONARY.Where(s => s.ParentCode == 100200).ToList();
         list2 = list2 != null ? list2 : new List <T_SYS_DICTIONARY>();
         List <SkillModel> skilllist = new List <SkillModel>()
         {
             new SkillModel {
                 RoleId = (int)RoleType.Farmer, RoleName = RoleType.Farmer.GetDescription(), Skill = new  List <T_SYS_DICTIONARY> ()
             },
             new SkillModel {
                 RoleId = (int)RoleType.MachineryOperator, RoleName = RoleType.MachineryOperator.GetDescription(), Skill = list1
             },
             new SkillModel {
                 RoleId = (int)RoleType.Business, RoleName = RoleType.Business.GetDescription(), Skill = list2
             },
             new SkillModel {
                 RoleId = (int)RoleType.Dealer, RoleName = RoleType.Dealer.GetDescription(), Skill = new  List <T_SYS_DICTIONARY> ()
             },
             new SkillModel {
                 RoleId = (int)RoleType.Admin, RoleName = RoleType.Admin.GetDescription(), Skill = new  List <T_SYS_DICTIONARY> ()
             }
         };
         return(skilllist);
     }
 }
Beispiel #22
0
 /// <summary>
 /// 获取最新版本信息
 /// </summary>
 /// <param name="platform">ios/android</param>
 /// <returns>T_APP_VERSION.</returns>
 public T_APP_VERSION GetLastVersion(string platform)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.T_APP_VERSION.Where(app => app.Platform == platform).OrderByDescending(p => p.CREATE_DATE).FirstOrDefault());
     }
 }
Beispiel #23
0
 public T_SMS_MESSAGE GetByKey(object key)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         var keyString = Convert.ToString(key);
         return(dbContext.T_SMS_MESSAGE.Where(m => m.PhoneNumber == keyString).FirstOrDefault());
     }
 }
 public int Delete(IEnumerable <T_FileInfo> entities)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         dbContext.T_FileInfo.RemoveRange(entities);
         return(dbContext.SaveChanges());
     }
 }
Beispiel #25
0
 public int Add <T>(List <T> entity) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         dbContext.Set <T>().AddRange(entity);
         return(dbContext.SaveChanges());
     }
 }
        public readonly int[] farmerDemandOffline = { 100503, 100504, 100505, 100506 }; //已评价、已取消、系统关闭、已关闭


        public int Insert(T_FARMER_PUBLISHED_DEMAND entity)
        {
            using (var dbContext = new DuPont_TestContext())
            {
                dbContext.T_FARMER_PUBLISHED_DEMAND.Add(entity);
                return(dbContext.SaveChanges());
            }
        }
Beispiel #27
0
 /// <summary>
 /// 检测数据库的部署(100表示成功)
 /// </summary>
 /// <returns>System.Int32.</returns>
 public int CheckDatabaseDeployment()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         var result = dbContext.Database.SqlQuery <int>("select count(1) from sys.tables where name='T_USER'").Count();
         return(result);
     }
 }
Beispiel #28
0
 public int Insert(T_SMS_MESSAGE entity)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         dbContext.T_SMS_MESSAGE.Add(entity);
         return(dbContext.SaveChanges());
     }
 }
 public int Insert(IEnumerable <T_FARMER_PUBLISHED_DEMAND> entities)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         dbContext.T_FARMER_PUBLISHED_DEMAND.AddRange(entities);
         return(dbContext.SaveChanges());
     }
 }
 public int Insert(IEnumerable <T_FileInfo> entities)
 {
     using (var dbContext = new DuPont_TestContext())
     {
         dbContext.T_FileInfo.AddRange(entities);
         return(dbContext.SaveChanges());
     }
 }