void OnRegister(NetConnection <NetSession> sender, UserRegisterRequest request) { Log.InfoFormat("UserRegisterRequest: User:{0} Pass:{1}", request.User, request.Passward); NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.userRegister = new UserRegisterResponse(); TUser user = DBService.Instance.Entities.Users.Where(u => u.Username == request.User).FirstOrDefault(); if (user != null) { message.Response.userRegister.Result = Result.Failed; message.Response.userRegister.Errormsg = "用户已存在."; } else { TPlayer player = DBService.Instance.Entities.Players.Add(new TPlayer()); DBService.Instance.Entities.Users.Add(new TUser() { Username = request.User, Password = request.Passward, Player = player }); DBService.Instance.Entities.SaveChanges(); message.Response.userRegister.Result = Result.Success; message.Response.userRegister.Errormsg = "None"; } byte[] data = PackageHandler.PackMessage(message); sender.SendData(data, 0, data.Length); }
internal PackageNodeHandler(TreeNode node, PackageHandler package) { this.Package = package; this.Node = node; this.Reload(); }
public async Task InsertPackagesAsync_Must_Insert_Package() { var correctTrackingCode = "PT-1revile-310899-250321-59"; var command = new List <InsertPackageCommand> { getInsertPackage() }; mockCountryService.Setup(x => x.GetCountryData("Portugal")).ReturnsAsync(new CountryDto { Alpha2Code = "PT", NumericCode = "620" }); mockLastCheckpointRepository.Setup(x => x.InsertLastCheckpoint("Portugal", "City1", 0, 2)).ReturnsAsync(10); mockPackagesRepository.Setup(x => x.InsertPackagesAsync(It.IsAny <string>(), command.FirstOrDefault(), 10)); var handler = new PackageHandler(mockPackagesRepository.Object, mockLastCheckpointRepository.Object, mockUnitOfWork.Object, mockCountryService.Object); var result = await handler.InsertPackagesAsync(command); Assert.NotNull(result); Assert.Single(result); Assert.Equal(correctTrackingCode.Substring(0, 11), result[0].Substring(0, 11)); Assert.Equal(correctTrackingCode.Substring(17, 10), result[0].Substring(17, 10)); mockCountryService.VerifyAll(); mockLastCheckpointRepository.VerifyAll(); mockPackagesRepository.VerifyAll(); mockUnitOfWork.VerifyAll(); }
public async Task InsertPackagesAsync_Must_Return_Country_Not_Found() { var command = new List <InsertPackageCommand> { new InsertPackageCommand { Country = "COUNTRYTEST" } }; mockUnitOfWork.Setup(x => x.Rollback()); mockCountryService.Setup(x => x.GetCountryData("COUNTRYTEST")).ReturnsAsync(new CountryDto()); var handler = new PackageHandler(mockPackagesRepository.Object, mockLastCheckpointRepository.Object, mockUnitOfWork.Object, mockCountryService.Object); var exception = await Record.ExceptionAsync(() => handler.InsertPackagesAsync(command)); Assert.NotNull(exception); Assert.Equal("Country COUNTRYTEST not found", exception.Message); Assert.IsType <Exception>(exception); mockCountryService.VerifyAll(); mockUnitOfWork.VerifyAll(); }
public IEnumerable <IPackage> Get(string packageId) { var packageSources = WebSettings.GetNugetPackageSources(); var packageHandler = new PackageHandler(packageSources); return(packageHandler.GetAllPackageVersions(packageId)); }
private void OnCreateCharacter(NetConnection <NetSession> sender, UserCreateCharacterRequest request) { Log.InfoFormat("UserCreateCharacterRequest: Name:{0} Class:{1}", request.Name, request.Class); TCharacter character = new TCharacter() { Name = request.Name, Class = (int)request.Class, TID = (int)request.Class, MapID = 1, MapPosX = 5000, MapPosY = 4000, MapPosZ = 820, }; DBService.Instance.Entities.Characters.Add(character); sender.Session.User.Player.Characters.Add(character); DBService.Instance.Entities.SaveChanges(); NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.createChar = new UserCreateCharacterResponse(); message.Response.createChar.Result = Result.Success; message.Response.createChar.Errormsg = "None"; byte[] data = PackageHandler.PackMessage(message); sender.SendData(data, 0, data.Length); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(StatusViewModel status, IEnumerable <ILightManager> managers, PackageHandler packageHandler) { if (IsInDesignMode) { _availableManagers = new List <ILightManager> { }; } else { _availableManagers = managers.ToList(); _packageHandler = packageHandler; SystemEvents.PowerModeChanged += PowerModeChanged; SystemEvents.SessionSwitch += SessionSwitched; SystemEvents.SessionEnded += SessionEnded; var manager = _availableManagers.FirstOrDefault(m => m.Name == Settings.Default.Main_CurrentManager); _selectedManager = manager ?? _availableManagers.First(); if (_selectedManager is IAutomaticLightManager activeLightManager) { activeLightManager.Start(); } Status = status; } }
void w_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (MainForm.IsClosing) { return; } //Application.DoEvents(); XmlHelper rsp = e.Result as XmlHelper; if (rsp == null) { return; } _packages = new List <PackageHandler>(); this.Definition = rsp.GetElement("Definition"); foreach (XmlElement each in rsp.GetElements("Package")) { PackageHandler ph = new PackageHandler(this, each); _packages.Add(ph); } Ready = true; if (Reloaded != null) { Reloaded.Invoke(this, EventArgs.Empty); } }
public string SendPackageV3(DataTransferObjects.BusinessObjects.Mail mailItem, Guid requestId) { LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.BusinessLayer.BusinessManager: incoming SendPackageV3 with RequestId: {0}", requestId)); //Transform MailItem to object of type specified by MinaMeddelandens Message webservice. var secureDelivery = GetSecureDeliveryV3(mailItem, requestId); //Create SignedDelivery and sign xmldocument and create a secureDelivery object specified in Mina meddelanden Message webservice. var signedDeliveryHandler = new SignedDeliveryHandler(); var signedDelivery = signedDeliveryHandler.GetSignedDeliveryV3(secureDelivery, ConfigHelper.SignDelivery, ConfigHelper.DefaultNamespaceV3, ConfigHelper.SigningCertificateSubjectName, requestId); //LOG to database before sending a message. var packageHandler = new PackageHandler(); //Save message in database // var databaseId = packageHandler.SavePackage(mailItem.Recipient.To, mailItem.Sender, PackageStatus.Pending, requestId); var dataManager = new DataManager(); var distributionId = dataManager.SendPackageV3(signedDelivery, requestId); //Log to database result of sending a message. DateTime?deliveryDate = null; packageHandler.UpdatePackage(distributionId, 0, PackageStatus.Pending, deliveryDate, requestId); LogManager.LogTrace(string.Format("SE.GOV.MM.Integration.Package.BusinessLayer.BusinessManager: leaving SendPackageV3 with RequestId: {0}", requestId)); return(distributionId); }
/// <summary> /// 角色进入地图 /// </summary> /// <param name="character"></param> internal void CharacterEnter(NetConnection <NetSession> conn, Character character) { Log.InfoFormat("CharacterEnter: Map:{0} characterId:{1}", this.Define.ID, character.Id); character.Info.mapId = this.ID; NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.mapCharacterEnter = new MapCharacterEnterResponse(); message.Response.mapCharacterEnter.mapId = this.Define.ID; message.Response.mapCharacterEnter.Characters.Add(character.Info); foreach (var kv in this.MapCharacters) { message.Response.mapCharacterEnter.Characters.Add(kv.Value.character.Info); this.SendCharacterEnterMap(kv.Value.connection, character.Info); } this.MapCharacters[character.Id] = new MapCharacter(conn, character); byte[] data = PackageHandler.PackMessage(message); conn.SendData(data, 0, data.Length); }
public void Package_String_Handling_Damage() { int counter = 0; DummyCard[] cards = new DummyCard[5]; string str = "[{\"Id\":\"845f0dc7-37d0-426e-994e-43fc3ac83c08\", \"Name\":\"WaterGoblin\", \"Damage\": 10.0}, " + "{\"Id\":\"99f8f8dc-e25e-4a95-aa2c-782823f36e2a\", \"Name\":\"Dragon\", \"Damage\": 50.0}, " + "{\"Id\":\"e85e3976-7c86-4d06-9a80-641c2019a79f\", \"Name\":\"WaterSpell\", \"Damage\": 20.0}, " + "{\"Id\":\"1cb6ab86-bdb2-47e5-b6e4-68c5ab389334\", \"Name\":\"Ork\", \"Damage\": 45.0}, " + "{\"Id\":\"dfdd758f-649c-40f9-ba3a-8657f4b3439f\", \"Name\":\"FireSpell\", \"Damage\": 25.0}]"; string[] jsonStrings = PackageHandler.PrepareJsonStrings(str); foreach (string s in jsonStrings) { cards[counter] = JsonConvert.DeserializeObject <DummyCard>(jsonStrings[counter]); counter++; } Assert.AreEqual(cards[0].damage, 10); Assert.AreEqual(cards[1].damage, 50); Assert.AreEqual(cards[2].damage, 20); Assert.AreEqual(cards[3].damage, 45); Assert.AreEqual(cards[4].damage, 25); }
public IPackage Get(string packageId, bool includePrerelease = false) { var packageSources = WebSettings.GetNugetPackageSources(); var packageHandler = new PackageHandler(packageSources); return(packageHandler.GetLatestPackage(packageId, includePrerelease)); }
public void TestCalls() { // TODO test "will retry later" PackageHandler.FinishedTrackingActivity(null); Assert.Test("ActivityHandler FinishedTrackingActivity, Null"); }
private void OnCreateCharacter(NetConnection <NetSession> sender, UserCreateCharacterRequest request) { Log.InfoFormat(" UserCreateCharacterRequest: name:{0} class:{1}", request.Name, request.Class); NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.createChar = new UserCreateCharacterResponse(); TCharacter character = new TCharacter() { Name = request.Name, Class = (int)request.Class, TID = (int)request.Class, MapID = 1, MapPosX = 5000, MapPosY = 4000, MapPosZ = 820, Gold = 100000, Equips = new byte[28], }; var bag = new TCharacterBag(); bag.Owner = character; bag.Items = new byte[0]; bag.Unlocked = 20; character.Bag = DBService.Instance.Entities.TCharacterBags.Add(bag); character.Items.Add(new TCharacterItem() { Owner = character, IteamID = 1, ItemCount = 20, }); character.Items.Add(new TCharacterItem() { Owner = character, IteamID = 2, ItemCount = 20, }); character = DBService.Instance.Entities.Characters.Add(character); sender.Session.User.Player.Characters.Add(character); DBService.Instance.Entities.SaveChanges(); foreach (var c in sender.Session.User.Player.Characters) { NCharacterInfo info = new NCharacterInfo(); info.Id = 0; info.Name = c.Name; info.Type = CharacterType.Player; info.Class = (CharacterClass)c.Class; info.Tid = c.ID; message.Response.createChar.Characters.Add(info); } message.Response.createChar.Result = Result.Success; message.Response.createChar.Errormsg = "None"; byte[] data = PackageHandler.PackMessage(message); sender.SendData(data, 0, data.Length); }
public StatusViewModel(IStatus status, PackageHandler packageHandler) { _status = status; _status.AvailabilityChanged += (sender, e) => RaisePropertyChanged(nameof(Availability)); _status.LogLevelChanged += (sender, e) => RaisePropertyChanged(nameof(LogLevel)); _packageHandler = packageHandler; _availableLogLevels = Enum.GetValues(typeof(LogLevel)) .Cast <LogLevel>().Where(l => l != LogLevel.Unknown).ToList(); }
public SingleColorViewModel(PackageHandler packageHandler) { _packageHandler = packageHandler; var settingsColor = Settings.Default.SingleColor_Color; _color = settingsColor != null ? settingsColor.ToMedia() : Colors.Red; }
public void ChangeVersionExceptions() { // Callbacks bool configCalled = false; void Handler_OnConfigVersionChanged(PackageHandler arg1, Config config, SemVer.Version arg2) { configCalled = true; } bool called = false; void Handler_OnVersionChanged(PackageHandler arg1, SemVer.Version arg2) { called = true; } var config = new Config { Info = new PackageInfo("N", "ID", new SemVer.Version("0.0.1")) }; var configProvider = Utils.GetConfigProvider(config, failToGet: true); var handler = new PackageHandler(configProvider.Object); handler.OnConfigVersionChanged += Handler_OnConfigVersionChanged; handler.OnVersionChanged += Handler_OnVersionChanged; // Should throw an ANE for a null version Assert.Throws <ArgumentNullException>(() => handler.ChangeVersion(null)); // Should throw a failure if the config could not be found var newVersion = new SemVer.Version("0.1.0"); Assert.Throws <ConfigException>(() => handler.ChangeVersion(newVersion)); // Config should never have been committed or changed configProvider.Verify(mocks => mocks.Commit(), Times.Never); Assert.False(config.Info.Version == newVersion); // Callbacks should never have been called Assert.False(configCalled); Assert.False(called); config = new Config(); configProvider = Utils.GetConfigProvider(config); handler = new PackageHandler(configProvider.Object); handler.OnConfigVersionChanged += Handler_OnConfigVersionChanged; handler.OnVersionChanged += Handler_OnVersionChanged; // Should throw a failure if the config.Info property is null Assert.Throws <ConfigException>(() => handler.ChangeVersion(newVersion)); // Config should never have been committed configProvider.Verify(mocks => mocks.Commit(), Times.Never); // Callbacks should never have been called Assert.False(configCalled); Assert.False(called); }
internal void SendEntitySync(NetConnection <NetSession> connection, NEntitySync entitySync) { NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.mapEntitySync = new MapEntitySyncResponse(); message.Response.mapEntitySync.entitySyncs.Add(entitySync); byte[] data = PackageHandler.PackMessage(message); connection.SendData(data, 0, data.Length); }
public IPackage Get(string packageId, string version) { if (!string.IsNullOrWhiteSpace(version)) { version = version.Replace('_', '.'); } var packageSources = WebSettings.GetNugetPackageSources(); var packageHandler = new PackageHandler(packageSources); return(packageHandler.GetPackage(packageId, version)); }
private static void PackageHandler_OnNameChanged(PackageHandler handler, string name) { // Perform bmbfmod.json edits to name var mod = bmbfmodProvider.GetMod(); if (mod != null) { mod.UpdateName(name); bmbfmodProvider.SerializeMod(mod); } }
private void SendCharacterLeaveMap(NetConnection <NetSession> connection, Character info) { NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.mapCharacterLeave = new MapCharacterLeaveResponse(); message.Response.mapCharacterLeave.characterId = info.Id; byte[] data = PackageHandler.PackMessage(message); connection.SendData(data, 0, data.Length); }
private static void PackageHandler_OnVersionChanged(PackageHandler handler, SemVer.Version version) { // Perform Android.mk, c_cpp_properties.json, bmbfmod.json edits to version var props = propertiesProvider.GetProperties(); if (props != null) { props.UpdateVersion(version); propertiesProvider.SerializeProperties(props); } var mod = bmbfmodProvider.GetMod(); if (mod != null) { mod.UpdateVersion(version); bmbfmodProvider.SerializeMod(mod); } var conf = configProvider.GetConfig(); if (conf is null) { throw new ConfigException("Config is null!"); } if (conf.Info is null) { throw new ConfigException("Config info is null!"); } if (conf.Info.Id is null) { throw new ConfigException("Config ID is null!"); } bool overrodeName = conf.Info.AdditionalData.TryGetValue(SupportedPropertiesCommand.OverrideSoName, out var overridenName); var mk = androidMkProvider.GetFile(); if (mk != null) { var module = mk.Modules.LastOrDefault(); if (module != null) { module.AddDefine("VERSION", version.ToString()); if (overrodeName) { module.Id = overridenName.GetString().ReplaceFirst("lib", "").ReplaceLast(".so", ""); } else { module.EnsureIdIs(conf.Info.Id, version); } androidMkProvider.SerializeFile(mk); } } }
internal PackageHandler AddPackage(string packageName) { XmlHelper req = new XmlHelper("<Request/>"); req.AddElement(".", "ContractName", this.Name); req.AddElement(".", "PackageName", packageName); MainForm.CurrentProject.SendRequest("UDSManagerService.CreatePackage", new Envelope(req)); PackageHandler ph = PackageHandler.CreateNew(this, packageName); _packages.Add(ph); return(ph); }
void SendCharacterEnterMap(NetConnection <NetSession> conn, NCharacterInfo character) { NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.mapCharacterEnter = new MapCharacterEnterResponse(); message.Response.mapCharacterEnter.mapId = this.Define.ID; message.Response.mapCharacterEnter.Characters.Add(character); byte[] data = PackageHandler.PackMessage(message); conn.SendData(data, 0, data.Length); }
private void OnCreatCharacter(NetConnection <NetSession> sender, UserCreateCharacterRequest message) { NetMessage rsp = new NetMessage(); rsp.Response = new NetMessageResponse(); rsp.Response.createChar = new UserCreateCharacterResponse(); if (sender.Session.User == null) { rsp.Response.createChar.Result = Result.Failed; rsp.Response.createChar.Errormsg = "未登录,请重新登录"; } else { if (/*Illegal(message.Class)*/ false) { rsp.Response.createChar.Result = Result.Failed; rsp.Response.createChar.Errormsg = $"职业错误,不含职业Id{message.Class}"; } else if (/*illegal(message.Name)*/ false) { rsp.Response.createChar.Result = Result.Failed; rsp.Response.createChar.Errormsg = $"命名非法"; } else { rsp.Response.createChar.Result = Result.Success; TCharacter character = new TCharacter(); character.Name = message.Name; character.Class = (int)message.Class; character.TID = (int)message.Class; character.MapID = 1; character.MapPosX = 5000; character.MapPosY = 5000; character.MapPosZ = 5000; sender.Session.User.Player.Characters.Add(character); DBService.Instance.Entities.SaveChanges(); foreach (var c in sender.Session.User.Player.Characters) { NCharacterInfo info = new NCharacterInfo(); info.Id = c.ID; info.Name = c.Name; info.Class = (CharacterClass)c.Class; rsp.Response.createChar.Characters.Add(info); } } byte[] mes = PackageHandler.PackMessage(rsp); sender.SendData(mes, 0, mes.Length); } }
private void OnGameEnter(NetConnection <NetSession> sender, UserGameEnterRequest message) { TCharacter chooseChar = sender.Session.User.Player.Characters.ElementAt(message.characterIdx); Log.InfoFormat("UserGameEnterRequest: Name:{0} index:{1} CharacterName:{2}", sender.Session.User.ID, message.characterIdx, chooseChar.Name); sender.Session.Character = Managers.CharacterManager.Instance.AddCharacter(chooseChar); Managers.MapManager.Instance[chooseChar.MapID].CharacterEnter(sender, sender.Session.Character); SkillBridge.Message.NetMessage rsp = new NetMessage(); rsp.Response = new NetMessageResponse(); rsp.Response.gameEnter = new UserGameEnterResponse(); rsp.Response.gameEnter.Result = Result.Success; byte[] data = PackageHandler.PackMessage(rsp); //sender.SendData(data, 0, data.Length); }
public void Finding_nested_dossier_returns_correct_item() { // Arrange var sut = new PackageHandler(null, null, null); var dip = (PaketDIP)Paket.LoadFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "dipTestdata1.xml")); // Act var value = sut.FindDossierInPackage(new FolderInfo { Id = "EkYg" }, dip); // Assert value.Id.Should().Be("EkYg"); }
private void AddAndSendFirstPackageTest(PackageHandler packageHandler) { // add a package ActivityPackage activityPackage = CreateUnknowPackage("FirstPackage"); // send the first package packageHandler.AddPackage(activityPackage); packageHandler.SendFirstPackage(); DeviceUtil.Sleep(2000); AddPackageTests(1, "unknownFirstPackage"); SendFirstTests(SendFirstState.SEND, "unknownFirstPackage"); }
private void Update() { if (_packages.Any()) { var package = _packages.Dequeue(); var packageHandler = PackageHandler.GetPackageHandler(this, package); if (packageHandler != null) { packageHandler.HandlePackage(); } else { Debug.LogWarning("Package handler are not found for package " + package.Type); } } }
void OnLogin(NetConnection <NetSession> sender, UserLoginRequest request) { Log.InfoFormat("UserLoginRequest: User:{0} Pass:{1}", request.User, request.Passward); NetMessage message = new NetMessage(); message.Response = new NetMessageResponse(); message.Response.userLogin = new UserLoginResponse(); TUser user = DBService.Instance.Entities.Users.Where(u => u.Username == request.User).FirstOrDefault(); if (user == null) { message.Response.userLogin.Result = Result.Failed; message.Response.userLogin.Errormsg = "用户不存在,请进行注册!"; } else if (user.Password != request.Passward) { message.Response.userLogin.Result = Result.Failed; message.Response.userLogin.Errormsg = "密码错误,请重新输入!"; } else { sender.Session.User = user; message.Response.userLogin.Result = Result.Success; message.Response.userLogin.Errormsg = "登录成功"; message.Response.userLogin.Userinfo = new NUserInfo(); message.Response.userLogin.Userinfo.Id = 1; message.Response.userLogin.Userinfo.Player = new NPlayerInfo(); message.Response.userLogin.Userinfo.Player.Id = user.Player.ID; foreach (var CharacterInfo in user.Player.Characters) { NCharacterInfo info = new NCharacterInfo(); info.Id = CharacterInfo.ID; info.Name = CharacterInfo.Name; info.Class = (CharacterClass)CharacterInfo.Class; message.Response.userLogin.Userinfo.Player.Characters.Add(info); } } byte[] data = PackageHandler.PackMessage(message); sender.SendData(data, 0, data.Length); }
static void Main(string[] args) { var command = Args.Configuration.Configure<CommandObject>().CreateAndBind(args); string TempFolder = @"c:\temp"; string JobWrapper = @"C:\Dev\BlueMetal\CloudAbstractions\CloudMorph\CloudMorphToolsPackage\JobHostWrapper\bin\Debug\JobHostWrapper.zip"; Action<string, string> deploy = (from, to) => new DeployJobHandler().Handle(new DeployJobMessage() {PackagePath = from, ToUri = to}); Func<string, IEnumerable<PackageCompressor.FileMapInfo>, string, string, string> package = (from, mp, to, packageName) => { var ph = new PackageHandler(); ph.Handle(new PackageMessage {PackageName = from, SourceMap = mp, PackageFolderDestination = to, UniquePackageName = packageName}); return ph.PackagePath; }; Func<string, string, IEnumerable<PackageCompressor.FileMapInfo>> map = (from, packageName) => { var fm = new PackageMetadataHandler(); fm.Handle(new FileMapMessage() {SourcePath = from, PackageName = packageName}); return fm.Map; }; switch (command.Command.ToLower()) { case "deploy": var uniquPackageName = new PackageNameCreator().GetUniquePackageName(command.Source); var fileMap = map(command.Source, uniquPackageName); string path = package(command.Source, fileMap, TempFolder, uniquPackageName); deploy(path, command.Destination); break; case "package": var uniquPackageName1 = new PackageNameCreator().GetUniquePackageName(command.Source); var fileMap1 = map(command.Source, uniquPackageName1); string path1 = package(command.Source, fileMap1, TempFolder, uniquPackageName1); new PackageHandler().MergePackages(path1, JobWrapper, uniquPackageName1); deploy(path1, command.Destination); break; } }