Example #1
0
        public Task <bool> AuthenticateWithEmailAsync(string email, string password, MobileInfo mobileInfo, out UserAccountAuthentication accountAuthentication)
        {
            UserAccount account;
            var         isAuthenticate = AuthenticateWithEmail(email, password, out account);

            accountAuthentication = new UserAccountAuthentication {
                Status = _accountStatus
            };
            if (!isAuthenticate)
            {
                return(Task.FromResult(false));
            }

            accountAuthentication.InjectFrom(account);
            accountAuthentication.Profile.InjectFrom(account.Profile);
            accountAuthentication.Claims = account.ClaimCollection.Select(uc => new Claim(uc.Type, uc.Value)).ToList();

            if (mobileInfo == null)
            {
                return(Task.FromResult(true));
            }

            isAuthenticate = RegisterMobile(account.UserId, account.Username, mobileInfo);

            return(Task.FromResult(isAuthenticate));
        }
Example #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);
            }
        }
Example #3
0
        // POST api/MobileInfo
        public HttpResponseMessage Post([FromBody] MobileInfo data)
        {
            bool result = false;

            try
            {
                if (data.Mobile != null || data.Phone != null || data.Tablet != null)
                {
                    // Encolamos si tiene distinto de null la info
                    data.Ip = HttpContext.Current != null ? HttpContext.Current.Request.UserHostAddress : "";

                    string QueueName  = ConfigurationManager.AppSettings["MobiInfoQueue"];
                    string dataString = JsonConvert.SerializeObject(data);
                    QueueManager.InsertMessage(dataString, QueueName);
                }
                result = true;
            }
            catch (Exception e)
            {
                var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(messageException);
            }


            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, result));
            }
        }
Example #4
0
 public PathSearch(World world, MobileInfo mobileInfo, Player owner)
 {
     this.world = world;
     cellInfo = InitCellInfo();
     this.mobileInfo = mobileInfo;
     this.owner = owner;
     queue = new PriorityQueue<PathDistance>();
 }
Example #5
0
 public PathSearch(World world, MobileInfo mobileInfo)
 {
     this.world = world;
     uim = world.WorldActor.Trait<UnitInfluence>();
     cellInfo = InitCellInfo();
     this.mobileInfo = mobileInfo;
     queue = new PriorityQueue<PathDistance>();
 }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            MobileInfo mobileInfo = db.MobileInfoes.Find(id);

            db.MobileInfoes.Remove(mobileInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
 public PathSearch(World world, MobileInfo mobileInfo, Actor self)
 {
     this.world = world;
     cellInfo = InitCellInfo();
     this.mobileInfo = mobileInfo;
     this.self = self;
     customCost = null;
     queue = new PriorityQueue<PathDistance>();
 }
Example #8
0
        public static PathSearch FromPoint( World world, MobileInfo mi, int2 from, int2 target, bool checkForBlocked )
        {
            var search = new PathSearch(world, mi) {
                heuristic = DefaultEstimator( target ),
                checkForBlocked = checkForBlocked };

            search.AddInitialCell( from );
            return search;
        }
Example #9
0
        public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked, Func <CPos, bool> goalCondition)
        {
            var graph  = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph);

            search.isGoal    = goalCondition;
            search.heuristic = loc => 0;
            return(search);
        }
Example #10
0
        public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked, Func <CPos, bool> goalCondition)
        {
            var graph  = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph);

            search.isGoal    = goalCondition;
            search.heuristic = loc => 0;
            return(search);
        }
Example #11
0
 public PathGraph(CellLayer <CellInfo> cellInfo, MobileInfo mobileInfo, Actor actor, World world, bool checkForBlocked)
 {
     this.cellInfo   = cellInfo;
     World           = world;
     this.mobileInfo = mobileInfo;
     Actor           = actor;
     LaneBias        = 1;
     checkConditions = checkForBlocked ? CellConditions.TransientActors : CellConditions.None;
 }
Example #12
0
 public FindResources(Actor self)
 {
     harv        = self.Trait <Harvester>();
     harvInfo    = self.Info.TraitInfo <HarvesterInfo>();
     mobile      = self.Trait <Mobile>();
     mobileInfo  = self.Info.TraitInfo <MobileInfo>();
     claimLayer  = self.World.WorldActor.Trait <ResourceClaimLayer>();
     pathFinder  = self.World.WorldActor.Trait <IPathFinder>();
     domainIndex = self.World.WorldActor.Trait <DomainIndex>();
 }
Example #13
0
 public FindResources(Actor self)
 {
     harv       = self.Trait <Harvester>();
     harvInfo   = self.Info.Traits.Get <HarvesterInfo>();
     mobile     = self.Trait <Mobile>();
     mobileInfo = self.Info.Traits.Get <MobileInfo>();
     resLayer   = self.World.WorldActor.Trait <ResourceLayer>();
     territory  = self.World.WorldActor.TraitOrDefault <ResourceClaimLayer>();
     pathFinder = self.World.WorldActor.Trait <IPathFinder>();
 }
Example #14
0
 public ActionResult Edit([Bind(Include = "ID,BrandName,MobileName,ProcessorName,AndroidOsName,AndroidOsVersion,RearCameraPrimary,RearCameraSecondary,RearCameraTertiary,FrontCameraPrimary,FrontCameraSecondary,RAM,BatterySize,ScreenSize,ReleaseDate,Price,ScreenResolution,ImageURL")] MobileInfo mobileInfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mobileInfo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mobileInfo));
 }
Example #15
0
 public PathGraph(CellInfoLayerPool layerPool, MobileInfo mobileInfo, Actor actor, World world, bool checkForBlocked)
 {
     pooledLayer       = layerPool.Get();
     cellInfo          = pooledLayer.Layer;
     World             = world;
     this.mobileInfo   = mobileInfo;
     worldMovementInfo = mobileInfo.GetWorldMovementInfo(world);
     Actor             = actor;
     LaneBias          = 1;
     checkConditions   = checkForBlocked ? CellConditions.TransientActors : CellConditions.None;
 }
Example #16
0
 public PathSearch(World world, MobileInfo mobileInfo, Actor self)
 {
     this.world = world;
     cellInfo = InitCellInfo();
     this.mobileInfo = mobileInfo;
     this.self = self;
     customCost = null;
     queue = new PriorityQueue<PathDistance>();
     considered = new HashSet<CPos>();
     maxCost = 0;
     nextDirections = directions.Select(d => new Pair<CVec, int>(d, 0)).ToArray();
 }
Example #17
0
 public SpawnerHarvesterHarvest(Actor self)
 {
     harv        = self.Trait <SpawnerHarvesterMaster>();
     harvInfo    = self.Info.TraitInfo <SpawnerHarvesterMasterInfo>();
     mobile      = self.Trait <Mobile>();
     mobileInfo  = self.Info.TraitInfo <MobileInfo>();
     deploy      = self.Trait <GrantConditionOnDeploy>();
     claimLayer  = self.World.WorldActor.TraitOrDefault <ResourceClaimLayer>();
     pathFinder  = self.World.WorldActor.Trait <IPathFinder>();
     domainIndex = self.World.WorldActor.Trait <DomainIndex>();
     tranforms   = self.Trait <Transforms>();
 }
Example #18
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);
            }
        }
Example #19
0
        public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            if (world.Map.Contains(from))
                search.AddInitialCell(from);

            return search;
        }
Example #20
0
        public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable<CPos> froms, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            foreach (var sl in froms.Where(sl => world.Map.Contains(sl)))
                search.AddInitialCell(sl);

            return search;
        }
Example #21
0
        // GET: Mobile/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MobileInfo mobileInfo = db.MobileInfoes.Find(id);

            if (mobileInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(mobileInfo));
        }
Example #22
0
        public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var graph  = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            if (world.Map.Contains(from))
            {
                search.AddInitialCell(from);
            }

            return(search);
        }
Example #23
0
        public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable <CPos> froms, CPos target, bool checkForBlocked)
        {
            var graph  = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            foreach (var sl in froms.Where(sl => world.Map.Contains(sl)))
            {
                search.AddInitialCell(sl);
            }

            return(search);
        }
Example #24
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);
        }
Example #25
0
        public Mobile(ActorInitializer init, MobileInfo info)
        {
            this.self = init.self;
            this.Info = info;

            uim = self.World.WorldActor.Trait<UnitInfluence>();

            if (init.Contains<LocationInit>())
            {
                this.__fromCell = this.__toCell = init.Get<LocationInit, int2>();
                this.PxPosition = Util.CenterOfCell(fromCell);
            }

            this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
            this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit, int>() : 0;
        }
Example #26
0
        public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var graph  = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target),
            };

            search.isGoal = loc => {
                var locInfo = search.Graph[loc];
                return(locInfo.EstimatedTotal - locInfo.CostSoFar == 0);
            };
            if (world.Map.Contains(from))
            {
                search.AddInitialCell(from);
            }
            return(search);
        }
Example #27
0
        public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            search.isGoal = loc =>
            {
                var locInfo = search.Graph[loc];
                return locInfo.EstimatedTotal - locInfo.CostSoFar == 0;
            };

            if (world.Map.Contains(from))
                search.AddInitialCell(from);

            return search;
        }
Example #28
0
        public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable<CPos> froms, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            search.isGoal = loc =>
            {
                var locInfo = search.Graph[loc];
                return locInfo.EstimatedTotal - locInfo.CostSoFar == 0;
            };

            foreach (var sl in froms.Where(sl => world.Map.Contains(sl)))
                search.AddInitialCell(sl);

            return search;
        }
Example #29
0
        public PathGraph(CellInfoLayerPool layerPool, MobileInfo mobileInfo, Actor actor, World world, bool checkForBlocked)
        {
            pooledLayer = layerPool.Get();
            groundInfo  = pooledLayer.GetLayer();

            var layers = world.GetCustomMovementLayers().Values.Where(cml => cml.EnabledForActor(actor.Info, mobileInfo));

            foreach (var cml in layers)
            {
                customLayerInfo[cml.Index] = Pair.New(cml, pooledLayer.GetLayer());
            }

            World              = world;
            this.mobileInfo    = mobileInfo;
            worldMovementInfo  = mobileInfo.GetWorldMovementInfo(world);
            Actor              = actor;
            LaneBias           = 1;
            checkConditions    = checkForBlocked ? CellConditions.TransientActors:CellConditions.None;
            checkTerrainHeight = world.Map.Grid.MaximumTerrainHeight > 0;
        }
Example #30
0
        public Mobile(ActorInitializer init, MobileInfo info)
        {
            this.self = init.self;
            this.Info = info;

            toSubCell = fromSubCell = info.SharesCell ? SubCell.Center : SubCell.FullCell;
            if (init.Contains<SubCellInit>())
            {
                this.fromSubCell = this.toSubCell = init.Get<SubCellInit, SubCell>();
            }

            if (init.Contains<LocationInit>())
            {
                this.__fromCell = this.__toCell = init.Get<LocationInit, int2>();
                this.PxPosition = Util.CenterOfCell(fromCell) + info.SubCellOffsets[fromSubCell];
            }

            this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
            this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit, int>() : 0;
        }
Example #31
0
        public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable <CPos> froms, CPos target, bool checkForBlocked)
        {
            var graph  = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            search.isGoal = loc =>
            {
                var locInfo = search.Graph[loc];
                return(locInfo.EstimatedTotal - locInfo.CostSoFar == 0);
            };

            foreach (var sl in froms.Where(sl => world.Map.Contains(sl)))
            {
                search.AddInitialCell(sl);
            }

            return(search);
        }
Example #32
0
        public CommonRtnEntity Add([FromBody] MobileInfo info)
        {
            CommonRtnEntity rtnInfo = new CommonRtnEntity();

            try
            {
                IMobileInfoServices advertisementServices = new MobileInfoServices();
                info.CreateTime = DateTime.Now;
                info.UpdateTime = DateTime.Now;
                int result = advertisementServices.Add(info);
                rtnInfo.Success = result > 0;
                rtnInfo.Data    = result;
                rtnInfo.Message = "添加成功!";
            }
            catch (Exception ex)
            {
                rtnInfo.Success = false;
                rtnInfo.Data    = ex.Message;
                rtnInfo.Message = ex.Message;
            }

            return(rtnInfo);
        }
Example #33
0
        private bool RegisterMobile(int userId, string username, MobileInfo currentMobile)
        {
            if (currentMobile.Os == MobileOS.iOS && string.IsNullOrEmpty(currentMobile.Token))
            {
                _accountStatus = UserAccountMessages.MissingDeviceToken;
                return(false);
            }

            if (currentMobile.Os == MobileOS.Android && string.IsNullOrEmpty(currentMobile.InstallationId))
            {
                _accountStatus = UserAccountMessages.MissingInstallationId;
                return(false);
            }

            if (currentMobile.Os == MobileOS.Android)
            {
                return(true);
            }

            var mobile = new UserMobileDevice
            {
                UserId         = userId,
                Active         = true,
                Token          = currentMobile.Token,
                InstallationId = currentMobile.InstallationId,
                OS             = currentMobile.Os.ToString(),
                Version        = currentMobile.Version,
                Device         = currentMobile.Device,
                Created        = UtcNow
            };

            Console.Write($"Subscribe to a push notification service {username}");
            //TODO: Subscribe to a push notification service
            //_parseService.SubscribeAsync(mobile, username);
            return(true);
        }
Example #34
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);
        }
Example #35
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);
        }
Example #36
0
        CPos?ChooseBestDestinationCell(MobileInfo mobileInfo, CPos destination)
        {
            if (chronosphere == null)
            {
                return(null);
            }

            if (mobileInfo.CanEnterCell(self.World, null, destination))
            {
                return(destination);
            }

            var max = chronosphere.World.Map.Grid.MaximumTileSearchRange;

            foreach (var tile in self.World.Map.FindTilesInCircle(destination, max))
            {
                if (chronosphere.Owner.Shroud.IsExplored(tile) && mobileInfo.CanEnterCell(self.World, null, tile))
                {
                    return(tile);
                }
            }

            return(null);
        }
Example #37
0
        public ChannelResult QueryChannel(string imsi, string mobile, ServiceType serviceType, float?amount, string userNo)
        {
            ChannelResult result = null;
            List <ShortMessageService> services = new List <ShortMessageService>();
            var mobileInfo = this.GetMobileInfoByPhoneNumber(mobile);
            IList <ShortMessageService> smsServices;

            if (serviceType == ServiceType.SMS)
            {
                smsServices = this.Find <ShortMessageService>(s => s.Type == serviceType);
            }
            else
            {
                if (mobileInfo == null)
                {
                    result = new ChannelResult {
                        Status = ChannelRequestStatus.MissingMobileInfo
                    };
                    return(result);
                }
                // filter by operator
                switch (mobileInfo.OperatorId)
                {
                case 1:
                    smsServices = this.Find <ShortMessageService>(s => s.Type == serviceType && s.IsMobile == true);
                    break;

                case 2:
                    smsServices = this.Find <ShortMessageService>(s => s.Type == serviceType && s.IsUnicom == true);
                    break;

                case 3:
                    smsServices = this.Find <ShortMessageService>(s => s.Type == serviceType && s.IsTelcom == true);
                    break;

                default:
                    smsServices = this.Find <ShortMessageService>(s => s.Type == serviceType);
                    break;
                }
            }


            if (smsServices != null && smsServices.Count > 0)
            {
                services = smsServices.ToList();
                ShortMessageService service             = new ShortMessageService();
                Instruction         selectedInstruction = new Instruction();
                SMSChannel          channel             = new SMSChannel();
                ServiceProvider     sp = new ServiceProvider();
                for (int i = 0; i < services.Count; i++)
                {
                    service = services[i];
                    sp      = this.Single <ServiceProvider>(x => x.Id == service.SpId);

                    // TODO: check channel restriction here

                    if (!service.IsManully)
                    {
                        var instructions = this.Find <Instruction>(s => s.ServiceId == service.Id);
                        channel = this.Single <SMSChannel>(x => x.ServiceId == service.Id);
                        // TODO: check instruction restriction here

                        if (instructions != null && instructions.Count > 0)
                        {
                            selectedInstruction = instructions[0];
                            result = new ChannelResult();
                            result.ServiceNumber = service.ServiceNumber;
                            result.Code          = instructions[0].Code;
                            break;
                        }
                    }
                    else
                    {
                        switch (sp.DynamicSP)
                        {
                        case DynamicSP.CTU:
                            return(CTUSMSPayRequest(amount.GetValueOrDefault(), userNo, mobileInfo, service.Id, sp.Id, mobile));
                        }
                    }
                }

                if (serviceType == ServiceType.SMSCharge && selectedInstruction != null && channel != null && result != null)
                {
                    // create order
                    var orderNo = PaymentsService.CreateOrder("[短代]", selectedInstruction.Amount, "短信充值:" + selectedInstruction.Amount.ToString(), mobile);
                    result.OrderNo = orderNo;

                    // initial channel log
                    if (mobileInfo == null)
                    {
                        mobileInfo = new MobileInfo();
                    }
                    SMSChannelLog log = new SMSChannelLog
                    {
                        Amount        = selectedInstruction.Amount,
                        ChargeStatus  = SMSChargeStatus.Initial,
                        CityId        = mobileInfo.CityId,
                        OpId          = mobileInfo.OperatorId,
                        ProvinceId    = mobileInfo.ProvinceId,
                        ServiceNumber = result.ServiceNumber,
                        Instruction   = result.Code,
                        Mobile        = mobile,
                        IMSI          = GetIMSI(mobile),
                        OrderNo       = orderNo
                    };
                    this.AddLog <SMSChannelLog>(log);
                    result.LogId = log.ID;

                    // set channel setting
                    if (channel != null)
                    {
                        var settings = this.Find <SMSChannelSetting>(x => x.ChannelId == channel.Id);
                        if (settings != null && settings.Count > 0)
                        {
                            result.SMSChannelSetting = settings[0];
                        }
                    }
                }
            }
            return(result);
        }
Example #38
0
 public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked, Func<CPos, bool> goalCondition)
 {
     var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
     var search = new PathSearch(graph);
     search.isGoal = goalCondition;
     search.heuristic = loc => 0;
     return search;
 }
    void LogIpAddressAndMobileIP()
    {
        if (string.IsNullOrEmpty(networkUrl))
        {
            return;
        }

        string wwwUrl = "";

        try
        {
            wwwUrl = networkUrl.Replace("http://", "");
            wwwUrl = wwwUrl.Substring(0, wwwUrl.IndexOf("/"));

            Logger.Info("networkIpv4 " + NetInfo.GetIPAddress(wwwUrl) + " playerIp: " + MobileInfo.GetMobileCurrentIPv4());
        }
        catch (Exception e)
        {
            Logger.Error("解析url ip地址失败或获取玩家ip信息失败! wwwUrl为:" + wwwUrl + " 错误信息:" + e.Message);
        }
    }
Example #40
0
        public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked)
        {
            var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);

            return(new PathSearch(graph));
        }
Example #41
0
 public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked, Func<CPos, bool> goalCondition)
 {
     var graph = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
     var search = new PathSearch(graph);
     search.isGoal = goalCondition;
     search.heuristic = loc => 0;
     return search;
 }
Example #42
0
        public static bool CanEnterCell( MobileInfo mobileInfo, World world, UnitInfluence uim, int2 cell, Actor ignoreActor, bool checkTransientActors )
        {
            if (MovementCostForCell(mobileInfo, world, cell) == int.MaxValue)
                return false;

            var blockingActors = uim.GetUnitsAt( cell ).Where( x => x != ignoreActor ).ToList();
            if (checkTransientActors && blockingActors.Count > 0)
            {
                // We can enter a cell with nonshareable units only if we can crush all of them
                if (mobileInfo.Crushes == null)
                    return false;

                if (blockingActors.Any(a => !(a.HasTrait<ICrushable>() &&
                                             a.TraitsImplementing<ICrushable>().Any(b => b.CrushClasses.Intersect(mobileInfo.Crushes).Any()))))
                    return false;
            }

            return true;
        }
Example #43
0
 public static bool CanEnterCell( World world, MobileInfo mi, int2 cell, Actor ignoreActor, bool checkTransientActors )
 {
     var uim = world.WorldActor.Trait<UnitInfluence>();
     return Mobile.CanEnterCell( mi, world, uim, cell, ignoreActor, checkTransientActors );
 }
Example #44
0
        public static int MovementCostForCell(MobileInfo info, World world, int2 cell)
        {
            if (!world.Map.IsInMap(cell.X,cell.Y))
                return int.MaxValue;

            var type = world.GetTerrainType(cell);
            if (!info.TerrainSpeeds.ContainsKey(type))
                return int.MaxValue;

            return info.TerrainSpeeds[type].Cost;
        }
Example #45
0
        public static PathSearch FromPoints(World world, MobileInfo mi, IEnumerable<int2> froms, int2 target, bool checkForBlocked)
        {
            var search = new PathSearch(world, mi)
            {
                heuristic = DefaultEstimator(target),
                checkForBlocked = checkForBlocked
            };

            foreach( var sl in froms )
                search.AddInitialCell( sl );

            return search;
        }
Example #46
0
 public Mobile(string manufacturer, MobileInfo mobileInfo1)
 {
     Manufacturer = manufacturer;
     MobileInfo1  = mobileInfo1;
 }
Example #47
0
 public static PathSearch Search( World world, MobileInfo mi, bool checkForBlocked )
 {
     var search = new PathSearch(world, mi) {
         checkForBlocked = checkForBlocked };
     return search;
 }
Example #48
0
        public ChannelResult CTUSMSPayRequest(float amount, string userNo, MobileInfo mobileInfo, int serviceId, int spId, string phoneNo)
        {
            ChannelResult result = new ChannelResult();

            if (!CTUSMSChargeProducts.ContainsKey(amount))
            {
                result.CTURequestStatus = CTURequestStatus.AmountError;
                return(result);
            }

            var CTUProductInfo = CTUSMSChargeProducts[amount];

            var orderNo = PaymentsService.CreateOrder("[畅天游]产品ID_" + CTUProductInfo.SID, amount, "短信充值:" + amount.ToString(), userNo, (int)PaymentType.SMS);

            result.OrderNo = orderNo;

            #region Get MD5 key
            string key         = orderNo + mobileInfo.Mobile + amount.ToString() + CTUProductInfo.RequestKey;
            byte[] hashedBytes = null;
            using (MD5 md5Hash = MD5.Create())
            {
                hashedBytes = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(key));
            }

            var hashedKey = new StringBuilder();
            for (int i = 0; i < hashedBytes.Length; i++)
            {
                hashedKey.Append(hashedBytes[i].ToString("x2"));
            }
            #endregion

            var url = string.Format(CHARGE_URL, CTUProductInfo.SID, orderNo, mobileInfo.Mobile, amount, hashedKey.ToString());

            var response = this.RESTfulCient.Get(url, 5000);
            if (!string.IsNullOrEmpty(response))
            {
                XmlDocument resultDoc = new XmlDocument();
                try
                {
                    resultDoc.LoadXml(response);
                }
                catch (XmlException ex)
                {
                    LogManager.GetLogger("ErrorLogger").Error(ex.Message);
                    return(result);
                }

                var resultNode = resultDoc.SelectSingleNode("/Root/Result");
                var msgNode    = resultDoc.SelectSingleNode("/Root/Msg");


                var resultCode = -1;
                int.TryParse(resultNode.InnerText, out resultCode);
                result.CTURequestStatus = (CTURequestStatus)resultCode;
                if (resultCode == 0)
                {
                    result.Code          = RegexHelper.GetMatchedGroupValue(msgNode.InnerText, CTUChargeRequestRegex, "instruction");
                    result.ServiceNumber = RegexHelper.GetMatchedGroupValue(msgNode.InnerText, CTUChargeRequestRegex, "serviceNo");

                    SMSChannelLog log = new SMSChannelLog
                    {
                        Amount        = amount,
                        ChargeStatus  = SMSChargeStatus.Initial,
                        CityId        = mobileInfo.CityId,
                        OpId          = mobileInfo.OperatorId,
                        ProvinceId    = mobileInfo.ProvinceId,
                        ServiceNumber = result.ServiceNumber,
                        Instruction   = result.Code,
                        Mobile        = phoneNo,
                        IMSI          = GetIMSI(phoneNo),
                        OrderNo       = orderNo,
                    };

                    if (string.IsNullOrEmpty(result.Code) || string.IsNullOrEmpty(result.ServiceNumber))
                    {
                        result.Status    = ChannelRequestStatus.NoChannelFound;
                        log.ChargeStatus = SMSChargeStatus.NotFound;
                    }
                    else  // CTU returned a valid channel
                    {
                        var channel = this.Single <SMSChannel>(x => x.ServiceId == serviceId);
                        if (channel != null)
                        {
                            var smsChannelSetting = this.Single <SMSChannelSetting>(x => x.ChannelId == channel.Id);
                            if (smsChannelSetting != null)
                            {
                                result.SMSChannelSetting = smsChannelSetting;
                            }
                        }
                        log.ChargeStatus = SMSChargeStatus.Initial;
                        // find saved channel
                        //var savedChannel = this.Single<SMSChannel>(x => x.ServiceId == serviceId && x.ServiceNumber == result.ServiceNumber);

                        //// channel not found, just save it
                        //if (savedChannel == null)
                        //{
                        //    ShortMessageService service = new ShortMessageService
                        //    {
                        //        SpId = spId,
                        //        Type = ServiceType.SMSCharge,
                        //        ServiceNumber = result.ServiceNumber,
                        //        Name = string.Format("[Auto]Province[{0}]City[{1}]Op[{2}]",  mobileInfo.ProvinceId, mobileInfo.CityId, mobileInfo.OperatorId),
                        //        IsUnicom = mobileInfo.OperatorId == 2,
                        //        IsMobile = mobileInfo.OperatorId == 1,
                        //        IsTelcom = mobileInfo.OperatorId == 3,


                        //    };
                        //}
                        //else // found saved channel, read and apply its setting and restrictions
                        //{

                        //}

                        // send channel setting info
                        //if (channel != null)
                        //{
                        //    result.SMSChannelSetting = new SMSChannelSetting
                        //    {
                        //        ChannelId = channel.Id,
                        //        ChargeMessageRegex = channel.ChargeMessageRegex,
                        //        ChargeMessageTemplate = channel.ChargeMessageTemplate,
                        //        FinalConfirmMessage = channel.FinalConfirmMessage,
                        //        ConfirmMessage = channel.ConfirmMessage,
                        //        ConfirmMessageTemplate = channel.ConfirmMessageTemplate
                        //    };
                        //}
                    }

                    this.AddLog <SMSChannelLog>(log);
                    result.LogId = log.ID;
                }
                else
                {
                    LogManager.GetLogger("ErrorLogger").Error(CHARGE_URL + "  response:" + response);
                }
            }

            return(result);
        }
Example #49
0
 public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked)
 {
     var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
     return new PathSearch(graph);
 }
Example #50
0
 public MoveOrderTargeter(MobileInfo unitType)
 {
     this.unitType = unitType;
 }