Exemplo n.º 1
0
        public CommonRtnEntity GetInfoByStatusAndUpdateDoing(string clientName, string projectName, string status, bool isUseNextOperationTime = false)
        {
            lock (GetInfoByStatusAndUpdateDoingLockStr)
            {
                IMobileInfoServices advertisementServices = new MobileInfoServices();

                List <MobileInfo> list = new List <MobileInfo>();
                if (isUseNextOperationTime)
                {
                    list = advertisementServices.Query(d => d.Status == status && d.ProjectName == projectName && d.ClientName == clientName && d.NextOperationTime < DateTime.Now);
                }
                else
                {
                    list = advertisementServices.Query(d => d.Status == status && d.ProjectName == projectName && d.ClientName == clientName);
                }
                MobileInfo info = null;
                if (list != null && list.Count > 0)
                {
                    info        = list[(new Random()).Next(0, list.Count - 1)];
                    info.Status = "占用";
                    if (info.CreateTime < DateTime.Now.AddYears(-5))
                    {
                        info.CreateTime = DateTime.Now;
                    }
                    if (info.NextOperationTime < DateTime.Now.AddYears(-5))
                    {
                        info.NextOperationTime = DateTime.Now.AddHours(3);
                    }
                    info.UpdateTime = DateTime.Now;
                    advertisementServices.Update(info);
                }

                string errorMsg = "暂未获取到!";

                if (isUseNextOperationTime)
                {
                    MobileInfo nextOperationInfo = advertisementServices.Query(d => d.Status == status && d.ProjectName == projectName && d.ClientName == clientName).OrderBy(x => x.NextOperationTime).FirstOrDefault();
                    if (nextOperationInfo != null)
                    {
                        errorMsg = "成熟时间:" + nextOperationInfo.NextOperationTime.ToString("yyyy-MM-dd HH:mm:ss");
                    }
                }

                CommonRtnEntity rtnInfo = new CommonRtnEntity()
                {
                    Success = info != null,
                    Data    = info,
                    Message = info != null ? "获取成功!" : errorMsg
                };
                return(rtnInfo);
            }
        }
Exemplo n.º 2
0
        public CommonRtnEntity GetInfoByLessThanInviteCountAndUpdateDoing(string clientName, string projectName, int inviteCount, string status = "0")
        {
            lock (GetInfoByLessThanInviteCountAndUpdateDoingLockStr)
            {
                IMobileInfoServices advertisementServices = new MobileInfoServices();

                List <MobileInfo> list = new List <MobileInfo>();

                list = advertisementServices.Query(d => d.ProjectName == projectName && d.ClientName == clientName && d.Status == status && !SqlFunc.IsNullOrEmpty(d.InviteCode)).Take(5).ToList();
                list = list.Where(x => x.InviteCount < inviteCount).ToList();

                MobileInfo info = null;
                if (list != null && list.Count > 0)
                {
                    info        = list[(new Random()).Next(0, list.Count - 1)];
                    info.Status = "占用";
                    if (info.CreateTime < DateTime.Now.AddYears(-5))
                    {
                        info.CreateTime = DateTime.Now;
                    }
                    info.UpdateTime = DateTime.Now;
                    advertisementServices.Update(info);
                }

                string errorMsg = "暂未获取到!";

                CommonRtnEntity rtnInfo = new CommonRtnEntity()
                {
                    Success = info != null,
                    Data    = info,
                    Message = info != null ? "获取成功!" : errorMsg
                };
                return(rtnInfo);
            }
        }
Exemplo n.º 3
0
        public CommonRtnEntity Get(string clientName, string projectName, string mobileNum)
        {
            IMobileInfoServices advertisementServices = new MobileInfoServices();
            MobileInfo          info = advertisementServices.Query(d => d.MobileNum == mobileNum && d.ProjectName == projectName && d.ClientName == clientName).FirstOrDefault();

            //((MobileInfoServices)advertisementServices).MyTest();

            CommonRtnEntity rtnInfo = new CommonRtnEntity()
            {
                Success = info != null,
                Data    = info,
                Message = "查询成功!"
            };

            return(rtnInfo);
        }
Exemplo n.º 4
0
        public CommonRtnEntity CheckIsMyMobile(string clientName, string projectName, string mobileNum)
        {
            bool isMy = false;
            //先查是否在自己号码库中
            IMobileInfoServices advertisementServices = new MobileInfoServices();
            MobileInfo          info = advertisementServices.Query(d => d.MobileNum == mobileNum && d.ProjectName == projectName && d.ClientName == clientName).FirstOrDefault();
            string msg = "";

            if (info != null)
            {
                msg  = "已使用!";
                isMy = true;
            }
            else
            {
                //如果不在自己号码库中,再查是否作废
                IAbandonedMobileServices abandonedMobileServices = new AbandonedMobileServices();
                AbandonedMobile          abandonedMobile         = abandonedMobileServices.Query(d => d.MobileNum == mobileNum && d.ProjectName == projectName).FirstOrDefault();
                if (abandonedMobile != null)
                {
                    abandonedMobile.Count++;
                    abandonedMobileServices.Update(abandonedMobile);
                    isMy = true;
                    msg  = "已作废!";
                }
            }

            CommonRtnEntity rtnInfo = new CommonRtnEntity()
            {
                Success = isMy,
                Data    = msg,
                Message = "检查完毕!"
            };

            return(rtnInfo);
        }
Exemplo n.º 5
0
        public CommonRtnEntity UpdateInfoByMobile([FromBody] Dictionary <string, string> valueDir)
        {
            IMobileInfoServices advertisementServices = new MobileInfoServices();
            MobileInfo          info = advertisementServices.Query(d => d.MobileNum == valueDir["MobileNum"] && d.ProjectName == valueDir["ProjectName"] && d.ClientName == valueDir["ClientName"]).FirstOrDefault();

            bool success = false;

            if (info != null)
            {
                foreach (var item in valueDir)
                {
                    Type type = info.GetType();                                               //获取类型
                    System.Reflection.PropertyInfo propertyInfo = type.GetProperty(item.Key); //获取指定名称的属性
                    if (propertyInfo != null)
                    {
                        object value = Convert.ChangeType(item.Value, propertyInfo.PropertyType);
                        propertyInfo.SetValue(info, value, null); //给对应属性赋值
                    }
                }
                if (info.CreateTime < DateTime.Now.AddYears(-5))
                {
                    info.CreateTime = DateTime.Now;
                }
                info.UpdateTime = DateTime.Now;
                success         = advertisementServices.Update(info);
            }

            CommonRtnEntity rtnInfo = new CommonRtnEntity()
            {
                Success = success,
                Data    = success ? info:null,
                Message = success ? "修改成功!" : "修改失败!",
            };

            return(rtnInfo);
        }