Ejemplo n.º 1
0
        public MultiNetworkServiceCore()
        {
            var ip4networks = NetworkInterface.GetAllNetworkInterfaces()
                              .Where(x => x.SupportsMulticast && !x.IsReceiveOnly && x.OperationalStatus == OperationalStatus.Up)
                              .Where(x => (x.GetIPProperties().UnicastAddresses.Count > 0))
                              .Where(x => x.GetIPProperties().UnicastAddresses
                                     .Select(y => y.Address)
                                     .Where(y => (y.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) || (y.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6))
                                     .Count() > 0)
                              .ToList();

            foreach (var nic in ip4networks)
            {
                var core = new ServiceCore(nic);
                core.PacketReceived += (p, e) =>
                {
                    PacketReceived(p, e);
                };
                core.MalformedPacketReceived += (d, r, e) =>
                {
                    MalformedPacketReceived(d, r, e);
                };
                _cores.Add(core);
            }
        }
Ejemplo n.º 2
0
        public void kickUser(string username, int chatId, string adminUsername)
        {
            if (username == adminUsername)
            {
                return;
            }

            var userByChat = ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().getUserByChat(username, chatId);

            foreach (Messages message in ServiceCore.getInstance().Container.GetInstance <MessagesServices>().getMessagesFromChat(userByChat))
            {
                ServiceCore.getInstance().Container.GetInstance <MessagesServices>().Delete(new Messages()
                {
                    ID = message.ID
                });
            }

            ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().Delete(new UsersByChat()
            {
                ID = userByChat.ID
            });

            Clients.All.sendChatMessage(chatId, username + " foi expulso por " + adminUsername, string.Empty);
            Clients.All.kickedUser(chatId, username);
        }
Ejemplo n.º 3
0
        public void EnterChat(int chatId, string username)
        {
            var userByChat = ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().GetAll().Where(x => x.ID_Chat == chatId);

            var test = userByChat.Where(x => x.Username == username).FirstOrDefault();

            if (test != null)
            {
                this.userInteraction(test);
            }
            else
            {
                ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().Insert(
                    new UsersByChat()
                {
                    ID_Chat  = chatId,
                    Username = username,
                    Users    = new Users()
                    {
                        Username = username
                    },
                    Connected       = true,
                    LastInteraction = DateTime.Now,
                    EntryDate       = DateTime.Now
                });
            }

            Clients.Caller.chatEntered(true);
            Clients.All.sendChatMessage(chatId, username + " entrou no chat...", string.Empty);
        }
        internal MultiNetworkServicePublisher()
        {
            var ip4networks = NetworkInterface.GetAllNetworkInterfaces()
                              .Where(x => x.SupportsMulticast && !x.IsReceiveOnly && x.OperationalStatus == OperationalStatus.Up)
                              .Where(x => (x.GetIPProperties().UnicastAddresses.Count > 0))
                              .Where(x => x.GetIPProperties().UnicastAddresses
                                     .Select(y => y.Address)
                                     .Where(y => (y.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) || (y.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6))
                                     .Count() > 0)
                              .ToList();

            foreach (var nic in ip4networks)
            {
                var core      = new ServiceCore(nic);
                var publisher = new ServicePublisher(core);
                _publishers[nic]       = publisher;
                publisher.NameUpdated += newName =>
                {
                    _localName = newName;
                    DoForAll(pub =>
                    {
                        if (pub != publisher)
                        {
                            pub.LocalName = newName;
                        }
                    });
                };
            }
        }
Ejemplo n.º 5
0
        public bool IdentifyGesture(ServiceCore.UserSkeletonState userSkeletonState)
        {
            rotated = this.rotationIdentifier.IdentifyGesture(userSkeletonState);
            hadRotated = (this.rotationIdentifier.State == 0) ? false : hadRotated;
            if (Math.Abs(rotationIdentifier.CurrentAngleDelta) > AngleControl && !hadZoomed)
            {
                //Output.Debug("ZoomAndRotation","Can rotate. angle:" + rotationIdentifier.CurrentAngleDelta);
                if (rotated)
                {
                    Output.Debug("ZoomAndRotation", "ROTATED");
                    hadRotated = true;
                    Name = this.rotationIdentifier.Name;
                    return true;
                }

                return false;
            }

            if (!hadRotated)
            {
                zoomed = this.zoomIdentifier.IdentifyGesture(userSkeletonState);
                hadZoomed = (this.zoomIdentifier.State == 0) ? false : hadZoomed;
                if (zoomed)
                {
                    Output.Debug("ZoomAndRotation", "Zommed");
                    Output.Debug("ZoomAndRotation", "Rotation angle was :" + rotationIdentifier.CurrentAngleDelta + " || rotation state : " + rotationIdentifier.State);
                    hadZoomed = true;
                    Name = this.zoomIdentifier.Name;
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            if (Environment.UserInteractive)
            {
                logger.Info("Iniciando programa en modo consola...");

                Console.CancelKeyPress += Console_CancelKeyPress;

                ServiceCore.Start();

                Thread.Sleep(Timeout.Infinite);
            }
            else
            {
                logger.Info("Iniciando programa en modo servicio...");

                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new Daemon()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// The CoreBySketch function.
 /// </summary>
 /// <param name="model">The input model.</param>
 /// <param name="input">The arguments to the execution.</param>
 /// <returns>A CoreBySketchOutputs instance containing computed results and the model with any new elements.</returns>
 public static CoreBySketchOutputs Execute(Dictionary <string, Model> inputModels, CoreBySketchInputs input)
 {
     {
         //Extract the Levels from the model.
         var levels = new List <Level>();
         inputModels.TryGetValue("Levels", out var model);
         if (model == null || model.AllElementsOfType <Level>().Count() == 0)
         {
             throw new ArgumentException("No Levels found.");
         }
         levels.AddRange(model.AllElementsOfType <Level>());
         var top       = levels.OrderByDescending(l => l.Elevation).First().Elevation + input.CoreHeightAboveRoof;
         var elevation = levels.OrderBy(l => l.Elevation).First().Elevation;
         var height    = top - elevation;
         // Create the Core extrusion.
         var extrude = new Elements.Geometry.Solids.Extrude(input.Perimeter, height, Vector3.ZAxis, false);
         var geomRep = new Representation(new List <Elements.Geometry.Solids.SolidOperation>()
         {
             extrude
         });
         var corMatl = new Material("core", new Color(1.0, 1.0, 1.0, 0.6), 0.0f, 0.0f);
         var svcCore = new ServiceCore(input.Perimeter, Vector3.ZAxis, elevation, height, 0.0, new Transform(0.0, 0.0, elevation), corMatl, geomRep, false, Guid.NewGuid(), "serviceCore");
         var output  = new CoreBySketchOutputs(height);
         output.Model.AddElement(svcCore);
         return(output);
     }
 }
Ejemplo n.º 8
0
        public async Task Given_A_City_Request_Validate_City_Mapped()
        {
            //Arrange
            var expectedCities = new List <City>  {
                new CityBuilder().WithId(1)
                .WithName("CityA")
                .WithCountry("CounterA")
                .WithTouristRating(1)
                .WithEstimatedPopulation(100)
                .WithDateEstablished(new DateTime(1800, 1, 1))
                .Build()
            };

            var service = new ServiceCore(_cityRepository.Object, _weatherService.Object, _countryService.Object, _mapper);

            _cityRepository.Setup(x => x.GetCityByNameAsync(It.IsAny <string>())).ReturnsAsync(expectedCities);

            //Act
            var cities = (List <CityTransferModel>) await service.GetCityByNameAsync("CityName");

            //Assert
            Assert.IsInstanceOfType(cities[0], typeof(CityTransferModel));

            Assert.AreEqual(expectedCities[0].Id, cities[0].Id);
            Assert.AreEqual(expectedCities[0].Name, cities[0].Name);
            Assert.AreEqual(expectedCities[0].TouristRating, cities[0].TouristRating);
            Assert.AreEqual(expectedCities[0].EstimatedPopulation, cities[0].EstimatedPopulation);
            Assert.AreEqual(expectedCities[0].DateEstablished, cities[0].DateEstablished);
        }
Ejemplo n.º 9
0
        private void ExecuteSaveClaimCommand()
        {
            bool isNew = Claim.RN == 0;

            Claim = _visingCore.Save(Claim);
            if (Claim != null && Claim.RN != 0)
            {
                OnPropertyChanged(ClaimPropertyName);
                string message = "Заявка №" + Claim.DepartmentOrder.ORDPREF.Replace(" ", "") + "-" +
                                 Claim.DepartmentOrder.ORDNUMB.Replace(" ", "") + " сохранена успешно!";
                //отправим всем сообщение что была сохранена заявка

#if Release
                if (isNew)
                {
                    ServiceCore.MakeMail(claim);
                    ServiceCore.MakeRss(claim);
                }
#endif
                var msg = new ClaimChangedMessage
                {
                    Action  = isNew ? ClaimChangedMessage.Create : ClaimChangedMessage.Update,
                    Caption = "Сохранение",
                    Claim   = Claim,
                    Message = message
                };
                _mainEventAggregator.GetEvent <ClaimChangedEvent>().Publish(msg);

                OnClaimChanged(msg);
                Unload();
            }
        }
Ejemplo n.º 10
0
        public async Task Given_A_City_Update_Request_Validate_City_Mapped()
        {
            //Arrange
            var cityUpdate = new CityUpdateTransferModel()
            {
                TouristRating       = 1,
                DateEstablished     = new DateTime(2000, 1, 1),
                EstimatedPopulation = 500
            };

            var mappedCity = new City();
            var service    = new ServiceCore(_cityRepository.Object, _weatherService.Object, _countryService.Object, _mapper);

            _cityRepository.Setup(x => x.UpdateCityAsync(It.IsAny <int>(), It.IsAny <City>()))
            .Callback <int, City>((id, city) =>
            {
                mappedCity = city;
            }).ReturnsAsync(true);

            //Act
            var cities = await service.UpdateCityAsync(1, cityUpdate);

            //Assert
            Assert.AreEqual(cityUpdate.TouristRating, mappedCity.TouristRating);
            Assert.AreEqual(cityUpdate.EstimatedPopulation, mappedCity.EstimatedPopulation);
            Assert.AreEqual(cityUpdate.DateEstablished, mappedCity.DateEstablished);
        }
Ejemplo n.º 11
0
        public void getLastMessages(int chatId)
        {
            var messages = ServiceCore.getInstance().Container.GetInstance <MessagesServices>().getLastFifty(new Chat()
            {
                ID = chatId
            });

            Clients.Caller.lastMessages(messages.OrderBy(x => x.ID));
        }
Ejemplo n.º 12
0
        public void RefreshOnlineUsers(int chatId)
        {
            var users = ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().getUsersInChat(new Chat()
            {
                ID = chatId
            }).Where(x => x.Connected);

            Clients.Caller.refreshOnlineUsersList(users);
        }
Ejemplo n.º 13
0
        public async Task <User> Get([FromQuery] string username)
        {
            var optionsBuilder = new DbContextOptionsBuilder <MarbleContext>();

            optionsBuilder.UseSqlite(this.Configuration.GetConnectionString(ApplicationConfigurationKeys.MarbleDatabaseConnectionString));

            var svc = new ServiceCore(optionsBuilder.Options, User.Identity.Name);

            return(await svc.GetUser(username));
        }
Ejemplo n.º 14
0
 public IServicePublisher CreatePublisher()
 {
     if (_nic == null)
     {
         return(new MultiNetworkServicePublisher());
     }
     else
     {
         var core = new ServiceCore(_nic);
         return(new ServicePublisher(core));
     }
 }
Ejemplo n.º 15
0
 protected override void OnStop()
 {
     Core.ServiceCore.Log("Service stopping");
     core.Stop();
     core = null;
     // stop rpc
     if (serviceHost != null)
     {
         serviceHost.Close();
         serviceHost = null;
     }
     Core.ServiceCore.Log("Service stopped");
 }
Ejemplo n.º 16
0
        /// <summary>
        ///     Initializes this instance.
        /// </summary>
        internal static void Initialize(string[] args)
        {
            ServiceCore.Initialize(2, new NetAccountMessageManager(), args);

            ServiceAccount.InitLogic();
            ServiceAccount.InitGame();
            ServiceAccount.InitNetwork();

            ServiceAccount._titleTimer          = new Timer(200);
            ServiceAccount._titleTimer.Elapsed += (sender, eventArgs) => Program.UpdateConsoleTitle();
            ServiceAccount._titleTimer.Start();

            ServiceAccount.Start();
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     Initializes this instance.
        /// </summary>
        internal static void Initialize(string[] args)
        {
            ServiceCore.Initialize(NetUtils.SERVICE_NODE_TYPE_GLOBAL_CHAT_CONTAINER, new NetChatMessageManager(), args);

            ServiceChat.InitLogic();
            ServiceChat.InitNetwork();

            ServiceChat._titleTimer          = new Timer(200);
            ServiceChat._titleTimer.Elapsed += (sender, eventArgs) => Program.UpdateConsoleTitle();
            ServiceChat._titleTimer.Start();

            ServiceChat.Regex = new Regex(@"\s+", RegexOptions.Compiled);

            ServiceChat.Start();
        }
Ejemplo n.º 18
0
        private async Task _InitializeServices()
        {
            ZoneGuardConfigContextFactory factory = new ZoneGuardConfigContextFactory();

            using (ZoneGuardConfigContext context = factory.CreateDbContext())
            {
                /***************************************************************
                *
                *  Load Services
                *
                ***************************************************************/
                List <ThingDAL> services = await context.Thing
                                           .Where <ThingDAL>(t => t.ThingType == ThingType.Service)
                                           .Include(p => p.Parameters)
                                           .ToListAsync <ThingDAL>();

                foreach (ThingDAL serviceDAL in services)
                {
                    Console.WriteLine(serviceDAL.Name);
                    ConfigService configService = ZoneGuardConfigContextFactory.CreateThingFromDAL <ConfigService>(serviceDAL);

                    Console.WriteLine(configService.toJSON());

#if warning
#endif
                    //TODO:: MUST
                    //TODOO:: MIGRATE                    addSensor(new SensorProxy(configSensor, this), false);
                    ServiceCore service = null;
                    String      s       = configService.ConfigClass;
                    if (configService.ConfigClass == "ConfigServiceMQTT")
                    {
                        service = new ServiceMQTT((ConfigServiceMQTT)configService, this);
                    }
                    else if (configService.ConfigClass == "ConfigServiceMQ")
                    {
                        service = new ServiceMQ((ConfigServiceMQ)configService, this);
                    }
                    if (service != null)
                    {
                        addService(service);
                    }
                    else
                    {
                        Logger.LogWarning("Service '{0}' not created.", configService.Id);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public Tray()
        {
            InitializeComponent();

            try
            {
                General.Initialize();
            }
            catch { }

            _core = new ServiceCore();
            _core.StartService();

            _rest = new ServiceRest();
            _rest.OpenHost();
        }
Ejemplo n.º 20
0
        public void LeaveChat(int chatId, string username)
        {
            var userByChat = ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().getUsersInChat(
                new Chat()
            {
                ID = chatId
            }).Where(x => x.Username == username).FirstOrDefault();

            if (userByChat != null)
            {
                userByChat.Connected = false;
                ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().Update(userByChat);
            }

            Clients.All.sendChatMessage(chatId, username + " saiu do chat...", string.Empty);
        }
        internal MultiNetworkServiceWatcher()
        {
            var ip4networks = NetworkInterface.GetAllNetworkInterfaces()
                              .Where(x => x.SupportsMulticast && !x.IsReceiveOnly && x.OperationalStatus == OperationalStatus.Up)
                              .Where(x => (x.GetIPProperties().UnicastAddresses.Count > 0))
                              .Where(x => x.GetIPProperties().UnicastAddresses
                                     .Select(y => y.Address)
                                     .Where(y => (y.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) || (y.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6))
                                     .Count() > 0)
                              .ToList();

            foreach (var nic in ip4networks)
            {
                var core    = new ServiceCore(nic);
                var watcher = new ServiceWatchManager(core);
                _watchers.Add(watcher);
            }
        }
Ejemplo n.º 22
0
        public void closeChat(int chatId)
        {
            UsersByChatServices UbCservice = ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>();
            var usersByChat = UbCservice.getUsersInChat(new Chat()
            {
                ID = chatId
            });

            var chatService = ServiceCore.getInstance().Container.GetInstance <ChatServices>();
            var chat        = chatService.Get(chatId);

            chat.EndDate = DateTime.Now;
            chatService.Update(chat);

            foreach (UsersByChat userByChat in usersByChat)
            {
                Clients.All.kickedUser(chatId, userByChat.Username);
            }
        }
Ejemplo n.º 23
0
        public void Login(string username, string password, bool admin)
        {
            bool   authentication = true;
            string returnMessage  = string.Empty;
            var    container      = ServiceCore.getInstance().Container;

            var user = container.GetInstance <UsersServices>().Get(username);

            if (admin)
            {
                if (user == null)
                {
                    authentication = false;
                    returnMessage  = "Não existe nenhum usuário administrador com este nome!";
                }
                if (Encryption.decrypt(user.Password, Encryption.SYSTEM_KEY) != password)
                {
                    authentication = false;
                    returnMessage  = "Senha incorreta!";
                }
            }
            else
            {
                if (user == null)
                {
                    user = container.GetInstance <UsersServices>().Insert(new Users()
                    {
                        Username     = username,
                        Admin        = admin,
                        CreationDate = DateTime.Now
                    });
                }
                else
                if (container.GetInstance <UsersByChatServices>().getUserEnteredChats(user).Where(x => x.LastInteraction > DateTime.Now.AddMinutes(-15)).ToList().Count > 0)
                {
                    authentication = false;
                    returnMessage  = "Este nome de usuário já está sendo usado!";
                }
            }

            Clients.Caller.loginAuthentication(authentication, returnMessage);
        }
Ejemplo n.º 24
0
        protected override void OnStart(string[] args)
        {
            //Thread.Sleep(10000);
            Core.ServiceCore.Log("Service starting");
            // fire up the service core
            if (core == null)
            {
                core = new ServiceCore(Settings.Default.isDebug);
            }
            uint sessionId = WTSGetActiveConsoleSessionId();

            if (sessionId == uint.MaxValue)
            {
                Core.ServiceCore.SystemStatus.SessionStatus = SessionState.LoggedOff;
                Core.ServiceCore.SystemStatus.User          = "";
            }
            else
            {
                // how do we check if someone is logged in already?
                Core.ServiceCore.SystemStatus.User = GetUsername((int)sessionId, false);
                if (Core.ServiceCore.SystemStatus.User == "SYSTEM" || Core.ServiceCore.SystemStatus.User == "")
                {
                    Core.ServiceCore.SystemStatus.SessionStatus = SessionState.LoggedOff;
                    Core.ServiceCore.SystemStatus.User          = "";
                }
                else
                {
                    Core.ServiceCore.SystemStatus.SessionStatus = SessionState.Active;
                }
            }
            Core.ServiceCore.Log("User " + Core.ServiceCore.SystemStatus.User + " is " + Core.ServiceCore.SystemStatus.SessionStatus.ToString());
            core.Start(); // dont do this until they logon // need to check if they're already logged on and starting it manually
            core.LoadPlugins();
            //// wanna listen for IPC - Named pipes using WCF
            //if (serviceHost != null)
            //{
            //    serviceHost.Close();
            //}
            //serviceHost = new ServiceHost(typeof(RPCService));
            //serviceHost.Open();
            Core.ServiceCore.Log("Service started");
        }
Ejemplo n.º 25
0
        public void createChat(string creator, string chatName, int capacity)
        {
            var  chatService = ServiceCore.getInstance().Container.GetInstance <ChatServices>();
            var  chat        = chatService.GetAll().Where(x => x.Name == chatName);
            bool created     = false;

            if (chat.Count() == 0)
            {
                chatService.Insert(new Chat()
                {
                    ID              = chatService.GetAll().OrderBy(x => x.ID).Last().ID + 1,
                    Name            = chatName,
                    CreatorUsername = creator,
                    CreationDate    = DateTime.Now,
                    Capacity        = capacity
                });
                created = true;
            }

            Clients.Caller.chatCreated(created);
        }
Ejemplo n.º 26
0
        public async Task Given_A_City_Request_Validate_WeatherInformation_Returned()
        {
            var mockCities = new List <City>  {
                new CityBuilder().WithId(1)
                .WithName("CityA")
                .WithCountry("CounterA")
                .WithTouristRating(1)
                .WithEstimatedPopulation(100)
                .WithDateEstablished(new DateTime(1800, 1, 1))
                .Build()
            };

            var expectedWeatherInfo = new WeatherBuilder()
                                      .WithDescription("Cloudy")
                                      .WithTemperature(15.6F)
                                      .WithMaximumTemperature(16)
                                      .WithMinimumTemperature(15)
                                      .WithPressure(1012)
                                      .WithHimidity(75)
                                      .Build();

            _weatherService.Setup(x => x.GetWeatherAsync(It.IsAny <string>())).ReturnsAsync(expectedWeatherInfo);

            var service = new ServiceCore(_cityRepository.Object, _weatherService.Object, _countryService.Object, _mapper);

            _cityRepository.Setup(x => x.GetCityByNameAsync(It.IsAny <string>())).ReturnsAsync(mockCities);

            //Act
            var cities = await service.GetCityByNameAsync("CityName");

            var actualWeatherInfo = cities.FirstOrDefault().Weather;

            //Assert
            Assert.AreEqual(actualWeatherInfo.Description, "Cloudy");
            Assert.AreEqual(actualWeatherInfo.Temperature, 15.6M);
            Assert.AreEqual(actualWeatherInfo.TemperatureMaximum, 16);
            Assert.AreEqual(actualWeatherInfo.TemperatureMinimum, 15);
            Assert.AreEqual(actualWeatherInfo.Humidity, 75);
            Assert.AreEqual(actualWeatherInfo.Pressure, 1012);
        }
Ejemplo n.º 27
0
 public ServiceWatcher FindService(string serviceName, Action <NetworkInterface, ServiceInfo> callback)
 {
     if (_watchManager == null)
     {
         lock (_watchLock)
         {
             if (_watchManager == null)
             {
                 if (_nic == null)
                 {
                     _watchManager = new MultiNetworkServiceWatcher();
                 }
                 else
                 {
                     var core = new ServiceCore(_nic);
                     _watchManager = new ServiceWatchManager(core);
                 }
             }
         }
     }
     return(_watchManager.WatchService(serviceName, callback));
 }
Ejemplo n.º 28
0
        public async Task Given_A_City_Request_Validate_CountryInformation_Returned()
        {
            var mockCities = new List <City>  {
                new CityBuilder().WithId(1)
                .WithName("CityA")
                .WithCountry("CounterA")
                .WithTouristRating(1)
                .WithEstimatedPopulation(100)
                .WithDateEstablished(new DateTime(1800, 1, 1))
                .Build()
            };

            var expectedCountryInfo = new List <CountryModel>  {
                new CountryBuilder()
                .WithAlpha2Code("AA")
                .WithAlpha3Code("AAA")
                .WithCurrency("GBP", "British Pound", "£")
                .Build()
            };

            _countryService.Setup(x => x.GetCountryAsync(It.IsAny <string>())).ReturnsAsync(expectedCountryInfo);

            var service = new ServiceCore(_cityRepository.Object, _weatherService.Object, _countryService.Object, _mapper);

            _cityRepository.Setup(x => x.GetCityByNameAsync(It.IsAny <string>())).ReturnsAsync(mockCities);

            //Act
            var cities = await service.GetCityByNameAsync("CityName");

            var actualCountryInfo = cities.FirstOrDefault().CountryInformation.FirstOrDefault();

            //Assert
            Assert.AreEqual(actualCountryInfo.Alpha2Code, "AA");
            Assert.AreEqual(actualCountryInfo.Alpha3Code, "AAA");
            Assert.AreEqual(actualCountryInfo.Currencies.FirstOrDefault().Code, "GBP");
            Assert.AreEqual(actualCountryInfo.Currencies.FirstOrDefault().Name, "British Pound");
            Assert.AreEqual(actualCountryInfo.Currencies.FirstOrDefault().Symbol, "£");
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 构造玩家
        /// </summary>
        /// <param name="aGame">游戏对象</param>
        /// <param name="aCallback">玩家所对应的服务回调</param>
        /// <param name="aUID">玩家UID</param>
        /// <param name="aUName">玩家名称</param>
        public Player(GameBase aGame, ICallback aCallback, string aUID, string aUName)
        {
            if (aGame == null)
            {
                throw new Exception("Game is null");
            }
            if (aCallback == null)
            {
                throw new Exception("Service Or Callback is null");
            }
            Messages = new List <string>();
            Hands    = new List <Card>();
            Debuff   = new Stack <Card>();
            Callback = aCallback;
            ServiceCore svr = new ServiceCore(this, aGame);

            Service         = svr;
            HorizontalSet   = false;
            TurnSet         = false;
            AvailableChiefs = new ChiefBase[0] {
            };
            UID             = aUID;
            PlayerName      = aUName;
        }
Ejemplo n.º 30
0
        public void SendMessage(int chatId, string user, string msg)
        {
            try
            {
                var userByChat = ServiceCore.getInstance().Container.GetInstance <UsersByChatServices>().getUserByChat(user, chatId);
                this.userInteraction(userByChat);

                var message = new Messages()
                {
                    UsersByChatID = userByChat.ID,
                    Message       = msg,
                    Type          = Messages.Types.STRING,
                    InsertedDate  = DateTime.Now
                };

                ServiceCore.getInstance().Container.GetInstance <MessagesServices>().Insert(message);
            }
            catch (Exception ex)
            {
                //log
            }

            Clients.All.sendChatMessage(chatId, user, msg);
        }
Ejemplo n.º 31
0
 public void SendTheData(string s)
 {
     ServiceCore.DataArrived(s);
 }