/// <summary> /// Реакция на отклонение расчета ПЗ /// </summary> /// <param name="calculationId"></param> public bool OnRejectPriceCalculationServiceCallback(Guid calculationId) { var calculation = _container.Resolve <IUnitOfWork>().Repository <PriceCalculation>().GetById(calculationId); if (SyncContainer.PublishWithinAppForCurrentUser <PriceCalculation, AfterRejectPriceCalculationEvent>(calculation)) { var message = $"Отклонен: {calculation.Name}\nКомментарий: {calculation.LastHistoryItem.Comment}"; var title = $"{calculation.Name} с Id {calculation.Id}"; _popupNotificationsService.ShowPopupNotification(calculation, message, title); return(true); } return(false); }
/// <summary> /// Реакция на остановку расчета ПЗ /// </summary> /// <param name="calculationId"></param> public bool OnCancelPriceCalculationServiceCallback(Guid calculationId) { var calculation = _container.Resolve <IUnitOfWork>().Repository <PriceCalculation>().GetById(calculationId); if (SyncContainer.PublishWithinAppForCurrentUser <PriceCalculation, AfterStopPriceCalculationEvent>(calculation)) { var message = $"Остановлен: {calculation.Name}"; var title = $"{calculation.Name} с Id {calculation.Id}"; _popupNotificationsService.ShowPopupNotification(calculation, message, title); return(true); } return(false); }
public AnalyzeForm(SyncContainer cont) { InitializeComponent(); sourceObject = cont.SourceObject; sinkObject = cont.SinkObject; if (sourceObject.GetType() != sinkObject.GetType()) { MessageBox.Show("Incompatible Types!"); this.Close(); } propertyGridRepository.SelectedObject = sourceObject; propertyGridMobileDB.SelectedObject = sinkObject; objectType = sourceObject.GetType(); readType(objectType); editObject = (ISerializableObject)objectType.GetConstructor(new Type[] {}).Invoke(new object[] {});//Konstruktor für unbekanntes Objektt propertyGridEdit.SelectedObject = editObject; }
public AnalyzeForm(SyncContainer cont) { InitializeComponent(); sourceObject = cont.SourceObject; sinkObject = cont.SinkObject; if(sourceObject.GetType() != sinkObject.GetType()) { MessageBox.Show("Incompatible Types!"); this.Close(); } propertyGridRepository.SelectedObject = sourceObject; propertyGridMobileDB.SelectedObject = sinkObject; objectType =sourceObject.GetType(); readType(objectType); editObject= (ISerializableObject) objectType.GetConstructor(new Type[] {}).Invoke(new object[] {});//Konstruktor für unbekanntes Objektt propertyGridEdit.SelectedObject = editObject; }
private void buttonAnalyzeConflict_Click(object sender, EventArgs e) { if (listBoxConflicts.SelectedItem == null) { MessageBox.Show("Select an Item First"); return; } SyncContainer conflict = (SyncContainer)listBoxConflicts.SelectedItem; AnalyzeForm a = new AnalyzeForm(conflict); a.ShowDialog(); ISerializableObject solution = a.solution; if (solution != null) { conflict.Resolve(solution); listBoxConflictResolved.Items.Add(conflict); listBoxConflicts.Items.Remove(conflict); } }
public EventServiceClient(IUnityContainer container) { _container = container; _popupNotificationsService = container.Resolve <IPopupNotificationsService>(); _fileManagerService = container.Resolve <IFileManagerService>(); _filesStorageService = container.Resolve <IFilesStorageService>(); //увеличиваем таймаут бездействия _netTcpBinding = new NetTcpBinding(SecurityMode.None, true) { //SendTimeout = new TimeSpan(7, 0, 0, 0), ReceiveTimeout = new TimeSpan(7, 0, 0, 0), //OpenTimeout = new TimeSpan(7, 0, 0, 0), //CloseTimeout = new TimeSpan(7, 0, 0, 0) }; _endpointAddress = new EndpointAddress(EventServiceAddresses.TcpBaseAddress); SyncContainer = new SyncContainer(_container); SyncContainer.ServiceHostIsDisabled += DisableWaitRestart; }
public void BroadcastRequest(ChatProfile chat) { string message = ""; string sound = ""; string avatar = ""; var broadcastType = BroadcastType.None; if (chat.ProcessChat(ref message, ref sound, ref broadcastType, ref avatar) == false) { Logger.MsgDebug(chat.ProfileSubtypeId + ": Process Chat Fail", DebugTypeEnum.Chat); return; } if (this.LastChatMessageSent == message || string.IsNullOrWhiteSpace(message) == true) { Logger.MsgDebug(chat.ProfileSubtypeId + ": Last Message Same", DebugTypeEnum.Chat); return; } if (chat.IgnoreAntennaRequirement || chat.SendToAllOnlinePlayers) { this.HighestRadius = chat.IgnoredAntennaRangeOverride; this.HighestAntennaRangeName = ""; this.AntennaCoords = this.RemoteControl.GetPosition(); } else { GetHighestAntennaRange(); if (this.HighestRadius == 0) { Logger.MsgDebug(chat.ProfileSubtypeId + ": No Valid Antenna", DebugTypeEnum.Chat); return; } } var playerList = new List <IMyPlayer>(); MyAPIGateway.Players.GetPlayers(playerList); Logger.MsgDebug(chat.ProfileSubtypeId + ": Sending Chat to all Players within distance: " + this.HighestRadius.ToString(), DebugTypeEnum.Chat); if (message.Contains("{AntennaName}")) { message = message.Replace("{AntennaName}", this.HighestAntennaRangeName); } if (this.RemoteControl?.SlimBlock?.CubeGrid?.CustomName != null && message.Contains("{GridName}")) { message = message.Replace("{GridName}", this.RemoteControl.SlimBlock.CubeGrid.CustomName); } if (chat.UseRandomNameGeneratorFromMES && MESApi.MESApiReady) { message = MESApi.ConvertRandomNamePatterns(message); } var authorName = chat.Author; if (authorName.Contains("{AntennaName}")) { authorName = authorName.Replace("{AntennaName}", this.HighestAntennaRangeName); } if (this.RemoteControl?.SlimBlock?.CubeGrid?.CustomName != null && authorName.Contains("{GridName}")) { authorName = authorName.Replace("{GridName}", this.RemoteControl.SlimBlock.CubeGrid.CustomName); } bool sentToAll = false; foreach (var player in playerList) { var playerId = chat.SendToAllOnlinePlayers ? 0 : player.IdentityId; var playerName = chat.SendToAllOnlinePlayers ? "Player" : player.DisplayName; if (!chat.SendToAllOnlinePlayers && (player.IsBot == true || player.Character == null)) { continue; } if (!chat.SendToAllOnlinePlayers && (Vector3D.Distance(player.GetPosition(), this.AntennaCoords) > this.HighestRadius)) { continue; //player too far } var modifiedMsg = message; if (modifiedMsg.Contains("{PlayerName}") == true) { modifiedMsg = modifiedMsg.Replace("{PlayerName}", playerName); } if (modifiedMsg.Contains("{PlayerFactionName}") == true) { var playerFaction = MyAPIGateway.Session.Factions.TryGetPlayerFaction(player.IdentityId); if (playerFaction != null) { modifiedMsg = modifiedMsg.Replace("{PlayerFactionName}", playerFaction.Name); } else { modifiedMsg = modifiedMsg.Replace("{PlayerFactionName}", "Unaffiliated"); } } var authorColor = chat.Color; if (authorColor != "White" && authorColor != "Red" && authorColor != "Green" && authorColor != "Blue") { authorColor = "White"; } if (!sentToAll) { if (broadcastType == BroadcastType.Chat || broadcastType == BroadcastType.Both) { MyVisualScriptLogicProvider.SendChatMessage(modifiedMsg, authorName, playerId, authorColor); } if (broadcastType == BroadcastType.Notify || broadcastType == BroadcastType.Both) { if (playerId == 0) { MyVisualScriptLogicProvider.ShowNotificationToAll(modifiedMsg, 6000, authorColor); } else { MyVisualScriptLogicProvider.ShowNotification(modifiedMsg, 6000, authorColor, playerId); } } } if (string.IsNullOrWhiteSpace(sound) == false && sound != "None") { var effect = new Effects(); effect.Mode = EffectSyncMode.PlayerSound; effect.SoundId = sound; effect.AvatarId = avatar; var sync = new SyncContainer(effect); SyncManager.SendSyncMesage(sync, player.SteamUserId); } if (playerId == 0) { sentToAll = true; } } }
public ConflictState(SyncContainer owner, SyncItem sourceSyncItem) : base(owner) { _sourceSyncItem = sourceSyncItem; }
public DeletedState(SyncContainer owner, SyncItem sourceSyncItem) : base(owner, sourceSyncItem) { }
public WritingStates(SyncContainer owner) : base(owner) { _doSynchronizing = true; }
internal WritingStates(SyncContainer owner, SyncState previous) : base(owner, previous) { _doSynchronizing = true; }
internal ConflictResolvedState(SyncContainer owner, ISerializableObject resolved, SyncItem sourceSyncItem, SyncState previous) : base(owner, sourceSyncItem, previous) { _resolved = resolved; }
internal UpdateState(SyncContainer owner, SyncItem sourceSyncItem, SyncState previous) : base(owner, previous) { _sourceSyncItem = sourceSyncItem; _fieldLock = new FieldLock(_sourceSyncItem.GetType()); }
public IgnoreState(SyncContainer owner) : base(owner) { }
internal TruncateState(SyncContainer owner, SyncState previous) : base(owner, previous) { foreach (SyncContainer sc in StateOwner.Children) { sc.Truncate(); } }
public SyncState(SyncContainer owner) { _StateOwner = owner; _PreviousState = null; }
internal IgnoreState(SyncContainer owner, SyncState previous) : base(owner, previous) { }
internal SynchronizedState(SyncContainer owner, SyncState previous) : base(owner, previous) { }
public PrematureState(SyncContainer owner) : base(owner) { }
public InsertState(SyncContainer owner) : base(owner) { }
public static void ApplyDamageToTarget(long entityId, float amount, string particleEffect, string soundEffect) { if (entityId == 0) { return; } IMyEntity entity = null; if (MyAPIGateway.Entities.TryGetEntityById(entityId, out entity) == false) { return; } if (entity as IMyCubeGrid != null) { return; } var tool = entity as IMyEngineerToolBase; var block = entity as IMyShipToolBase; bool didDamage = false; MatrixD damagePositionMatrix = MatrixD.Identity; Vector3 damagerVelocity = Vector3.Zero; if (tool != null) { IMyEntity characterEntity = null; if (MyAPIGateway.Entities.TryGetEntityById(tool.OwnerId, out characterEntity)) { var character = characterEntity as IMyCharacter; if (character != null) { character.DoDamage(amount, MyStringHash.GetOrCompute("Electrocution"), true); damagePositionMatrix = character.WorldMatrix; if (character.Physics != null) { damagerVelocity = character.Physics.LinearVelocity; } didDamage = true; } } } if (block != null) { block.SlimBlock.DoDamage(amount, MyStringHash.GetOrCompute("Electrocution"), true); damagePositionMatrix = block.WorldMatrix; if (block?.SlimBlock?.CubeGrid?.Physics != null) { damagerVelocity = block.SlimBlock.CubeGrid.Physics.LinearVelocity; } didDamage = true; } if (didDamage == false) { return; } if (!string.IsNullOrWhiteSpace(soundEffect)) { var effect = new Effects(); effect.Mode = EffectSyncMode.PositionSound; effect.SoundId = soundEffect; effect.Coords = damagePositionMatrix.Translation; var syncContainer = new SyncContainer(effect); SyncManager.SendSyncMesage(syncContainer, 0, true, true); } if (!string.IsNullOrWhiteSpace(particleEffect)) { var effect = new Effects(); effect.Mode = EffectSyncMode.Particle; effect.ParticleId = particleEffect; effect.Coords = damagePositionMatrix.Translation; effect.ParticleForwardDir = damagePositionMatrix.Forward; effect.ParticleUpDir = damagePositionMatrix.Up; var syncContainer = new SyncContainer(effect); SyncManager.SendSyncMesage(syncContainer, 0, true, true); } }
public UpdateState(SyncContainer owner, SyncItem sourceSyncItem) : base(owner) { _sourceSyncItem = sourceSyncItem; _fieldLock = new FieldLock(_sourceSyncItem.GetType()); }
internal SyncState(SyncContainer owner, SyncState previousState) { _StateOwner = owner; _PreviousState = previousState; }
public ConflictResolvedState(SyncContainer owner, ISerializableObject resolved, SyncItem sourceSyncItem) : base(owner, sourceSyncItem) { _resolved = resolved; }
public static void ChangePlayerReputationWithFactions(List <int> amounts, List <long> players, List <string> factionTags, bool applyReputationChangeToFactionMembers) { var allPlayerIds = new List <long>(players.ToList()); if (applyReputationChangeToFactionMembers) { foreach (var owner in players) { var ownerFaction = MyAPIGateway.Session.Factions.TryGetPlayerFaction(owner); if (ownerFaction != null) { foreach (var member in ownerFaction.Members.Keys) { if (member != owner && member != 0 && !allPlayerIds.Contains(member)) { allPlayerIds.Add(member); } } } } } for (int i = 0; i < factionTags.Count; i++) { var tag = factionTags[i]; var amount = amounts[i]; var faction = MyAPIGateway.Session.Factions.TryGetFactionByTag(tag); if (faction == null) { continue; } foreach (var playerId in players) { string color = "Red"; string modifier = "Decreased"; var oldRep = MyAPIGateway.Session.Factions.GetReputationBetweenPlayerAndFaction(playerId, faction.FactionId); if (oldRep <= -1500 || oldRep >= 1500) { continue; } if (amount > 0) { color = "Green"; modifier = "Increased"; } var newRep = oldRep + amount; MyAPIGateway.Session.Factions.SetReputationBetweenPlayerAndFaction(playerId, faction.FactionId, newRep); //MyVisualScriptLogicProvider.ShowNotification(string.Format("Reputation With {0} {1} By: {2}", faction.Tag, modifier, amount.ToString()), 2000, color, playerId); var steamId = MyAPIGateway.Players.TryGetSteamId(playerId); if (steamId > 0) { //Logger.MsgDebug("Send Rep Sync Message", DebugTypeEnum.Owner); var message = new ReputationMessage(amount, tag, steamId); var syncContainer = new SyncContainer(message); SyncManager.SendSyncMesage(syncContainer, steamId); } } } }
public TruncateState(SyncContainer owner) : base(owner) { foreach (SyncContainer sc in StateOwner.Children) { sc.Truncate(); } }