Пример #1
0
 public ActionRequest(IPlayer player, IMeeple meeple, ActionRequestType requestType, string prompt = null)
 {
     Player      = player;
     Meeple      = meeple;
     RequestType = requestType;
     _prompt     = prompt;
 }
Пример #2
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (this.DataObject == null)
            {
                return;
            }
            if (base.ExchangeRunspaceConfig == null)
            {
                base.WriteError(new MailboxSearchTaskException(Strings.UnableToDetermineExecutingUser), ErrorCategory.InvalidOperation, null);
            }
            Utils.CheckSearchRunningStatus(this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError), Strings.CannotStartRunningSearch(this.DataObject.Name));
            this.DataObject.Resume = this.Resume;
            if (this.StatisticsStartIndex != -1)
            {
                this.DataObject.StatisticsStartIndex = this.StatisticsStartIndex;
            }
            ActionRequestType requestType = ActionRequestType.Start;

            if (this.Resume)
            {
                if (this.DataObject.Status == SearchState.Succeeded || this.DataObject.Status == SearchState.EstimateSucceeded)
                {
                    this.WriteWarning(Strings.SearchCompletedCannotBeResumed(this.DataObject.Name));
                    return;
                }
                if (this.DataObject.Status == SearchState.Stopped || this.DataObject.Status == SearchState.EstimateStopped)
                {
                    this.WriteWarning(Strings.SearchStoppedCannotBeResumed(this.DataObject.Name));
                    return;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(this.DataObject.Query) && (this.DataObject.Senders == null || this.DataObject.Senders.Count == 0) && (this.DataObject.Recipients == null || this.DataObject.Recipients.Count == 0) && (this.DataObject.MessageTypes == null || this.DataObject.MessageTypes.Count == 0) && this.DataObject.StartDate == null && this.DataObject.EndDate == null && !this.Force && !base.ShouldContinue(Strings.ContinueOnEmptySearchQuery))
                {
                    return;
                }
                if (!string.IsNullOrEmpty(this.DataObject.ResultsPath))
                {
                    if (!this.DataObject.StatisticsOnly && !this.Force && !base.ShouldContinue(Strings.ContinueOnRemoveSearchResults))
                    {
                        return;
                    }
                    requestType = ActionRequestType.Restart;
                }
                Utils.ResetSearchResults(this.DataObject);
            }
            Utils.CheckDiscoveryEnabled(this.recipientSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            this.DataObject.UpdateState(SearchStateTransition.StartSearch);
            ((DiscoverySearchDataProvider)base.DataSession).CreateOrUpdate <MailboxDiscoverySearch>(this.DataObject);
            Utils.CreateMailboxDiscoverySearchRequest((DiscoverySearchDataProvider)base.DataSession, this.DataObject.Name, requestType, base.ExchangeRunspaceConfig.GetRbacContext().ToString());
            SearchEventLogger.Instance.LogDiscoverySearchStartRequestedEvent(this.DataObject, base.ExchangeRunspaceConfig.GetRbacContext().ToString());
            TaskLogger.LogExit();
        }
Пример #3
0
        public async Task ProcessSelectOptionsActionResponse(int gameId, ActionRequestType actionRequestType, IEnumerable <ActionResponse> options)
        {
            var gameState = await _context.GameState.Where(x => x.GameId == gameId).FirstAsync();

            var game = Game.Game.Load(gameState.State);

            game.Submit(Context.UserIdentifier, actionRequestType, options);

            gameState.State = game.GetGameState();
            _context.GameState.Update(gameState);
            await _context.SaveChangesAsync();

            //await Clients.User(Context.UserIdentifier).SendAsync("Player", game.Players.Single(x => x.PlayerName == Context.UserIdentifier));
            foreach (var player in game.Players)
            {
                await Clients.User(player.PlayerName).SendAsync("Player", player);
            }
            await Clients.All.SendAsync("Send", game.Supply);
        }
Пример #4
0
        ///<summary>
        /// Handle action request.
        ///</summary>
        public static void HandleMethodRequest(GXDLMSSettings settings, GXDLMSServer server, GXByteBuffer data, GXDLMSConnectionEventArgs connectionInfo, GXByteBuffer replyData, GXDLMSTranslatorStructure xml)
        {
            ErrorCode    error = ErrorCode.Ok;
            GXByteBuffer bb    = new GXByteBuffer();
            // Get type.
            ActionRequestType type = (ActionRequestType)data.GetUInt8();
            // Get invoke ID and priority.
            byte invokeId = data.GetUInt8();

            settings.UpdateInvokeId(invokeId);
            // CI
            ObjectType ci = (ObjectType)data.GetUInt16();

            byte[] ln = new byte[6];
            data.Get(ln);
            // Attribute Id
            byte id = data.GetUInt8();
            // Get parameters.
            object parameters = null;
            byte   selection  = data.GetUInt8();

            if (xml != null)
            {
                xml.AppendStartTag(Command.MethodRequest);
                if (type == ActionRequestType.Normal)
                {
                    xml.AppendStartTag(Command.MethodRequest, ActionRequestType.Normal);
                    xml.AppendLine(TranslatorTags.InvokeId, "Value", xml.IntegerToHex(invokeId, 2));
                    AppendMethodDescriptor(xml, (int)ci, ln, id);
                    if (selection != 0)
                    {
                        //MethodInvocationParameters
                        xml.AppendStartTag(TranslatorTags.MethodInvocationParameters);
                        GXDataInfo di = new GXDataInfo();
                        di.xml = xml;
                        GXCommon.GetData(settings, data, di);
                        xml.AppendEndTag(TranslatorTags.MethodInvocationParameters);
                    }
                    xml.AppendEndTag(Command.MethodRequest, ActionRequestType.Normal);
                }
                xml.AppendEndTag(Command.MethodRequest);
                return;
            }
            if (selection != 0)
            {
                GXDataInfo info = new GXDataInfo();
                parameters = GXCommon.GetData(settings, data, info);
            }

            GXDLMSObject obj = settings.Objects.FindByLN(ci, GXCommon.ToLogicalName(ln));

            if (settings.Connected == ConnectionState.None && !settings.CanAccess() && (ci != ObjectType.AssociationLogicalName || id != 1))
            {
                replyData.Set(GXDLMSServer.GenerateConfirmedServiceError(ConfirmedServiceError.InitiateError,
                                                                         ServiceError.Service, (byte)Service.Unsupported));
                return;
            }

            if (obj == null)
            {
                obj = server.NotifyFindObject(ci, 0, GXCommon.ToLogicalName(ln));
            }
            if (obj == null)
            {
                // Device reports a undefined object.
                error = ErrorCode.UndefinedObject;
            }
            else
            {
                ValueEventArgs e = new ValueEventArgs(server, obj, id, 0, parameters);
                e.InvokeId = invokeId;
                if (server.NotifyGetMethodAccess(e) == MethodAccessMode.NoAccess)
                {
                    error = ErrorCode.ReadWriteDenied;
                }
                else
                {
                    server.NotifyAction(new ValueEventArgs[] { e });
                    byte[] actionReply;
                    if (e.Handled)
                    {
                        actionReply = (byte[])e.Value;
                    }
                    else
                    {
                        actionReply = (obj as IGXDLMSBase).Invoke(settings, e);
                        server.NotifyPostAction(new ValueEventArgs[] { e });
                    }
                    //Set default action reply if not given.
                    if (actionReply != null && e.Error == 0)
                    {
                        //Add return parameters
                        bb.SetUInt8(1);
                        //Add parameters error code.
                        bb.SetUInt8(0);
                        GXCommon.SetData(settings, bb, GXDLMSConverter.GetDLMSDataType(actionReply), actionReply);
                    }
                    else
                    {
                        error = e.Error;
                        //Add return parameters
                        bb.SetUInt8(0);
                    }
                }
                invokeId = (byte)e.InvokeId;
            }

            GXDLMSLNParameters p = new GXDLMSLNParameters(null, settings, invokeId, Command.MethodResponse, 1, null, bb, (byte)error);

            GXDLMS.GetLNPdu(p, replyData);
            //If High level authentication fails.
            if (obj is GXDLMSAssociationLogicalName && id == 1)
            {
                if ((obj as GXDLMSAssociationLogicalName).AssociationStatus == Objects.Enums.AssociationStatus.Associated)
                {
                    server.NotifyConnected(connectionInfo);
                    settings.Connected |= ConnectionState.Dlms;
                }
                else
                {
                    server.NotifyInvalidConnection(connectionInfo);
                    settings.Connected &= ~ConnectionState.Dlms;
                }
            }
        }
Пример #5
0
 public ActionCommand(string appId, byte key, ActionRequestType actionRequestType) :
     base(CommandType.ActionRequest, appId, key)
 {
     this.actionRequestType = actionRequestType;
 }
Пример #6
0
 internal static void CreateMailboxDiscoverySearchRequest(DiscoverySearchDataProvider dataProvider, string name, ActionRequestType requestType, string rbacContext)
 {
     dataProvider.CreateOrUpdate <MailboxDiscoverySearchRequest>(new MailboxDiscoverySearchRequest
     {
         Name = name,
         AsynchronousActionRequest     = requestType,
         AsynchronousActionRbacContext = rbacContext
     });
 }
        // Token: 0x06001393 RID: 5011 RVA: 0x0007258C File Offset: 0x0007078C
        protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog)
        {
            if (ObjectClass.IsMailboxDiscoverySearchRequest(mapiEvent.ObjectClass) && (mapiEvent.EventMask & MapiEventTypeFlags.ObjectCreated) == MapiEventTypeFlags.ObjectCreated && itemStore != null && item != null)
            {
                DiscoverySearchEventBasedAssistant.< > c__DisplayClassf CS$ < > 8__locals2 = new DiscoverySearchEventBasedAssistant.< > c__DisplayClassf();
                DiscoverySearchEventBasedAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Processing discovery search arbitration mailbox: {0}", itemStore.MailboxOwnerLegacyDN);
                CS$ < > 8__locals2.name = item.GetValueOrDefault <string>(DiscoverySearchEventBasedAssistant.AlternativeId, null);
                if (string.IsNullOrEmpty(CS$ < > 8__locals2.name))
                {
                    return;
                }
                ActionRequestType valueOrDefault = item.GetValueOrDefault <ActionRequestType>(DiscoverySearchEventBasedAssistant.AsynchronousActionRequest, ActionRequestType.None);
                string            rbacContext    = null;
                try
                {
                    rbacContext = item.GetValueOrDefault <string>(DiscoverySearchEventBasedAssistant.AsynchronousActionRbacContext, null);
                }
                catch (PropertyTooBigException)
                {
                    using (Stream stream = item.PropertyBag.OpenPropertyStream(DiscoverySearchEventBasedAssistant.AsynchronousActionRbacContext, PropertyOpenMode.ReadOnly))
                    {
                        using (StreamReader streamReader = new StreamReader(stream, Encoding.Unicode))
                        {
                            rbacContext = streamReader.ReadToEnd();
                        }
                    }
                }
                SearchEventLogger.Instance.LogDiscoverySearchRequestPickedUpEvent(CS$ < > 8__locals2.name, valueOrDefault.ToString(), rbacContext, itemStore.MailboxOwner.MailboxInfo.OrganizationId.ToString());
                switch (valueOrDefault)
                {
                case ActionRequestType.Start:
                    this.CallSearchService(itemStore, CS$ < > 8__locals2.name, (Item)item, delegate(MailboxSearchClient client, SearchId searchId)
                    {
                        DiscoverySearchEventBasedAssistant.RpcCallWithRetry(delegate()
                        {
                            client.StartEx(searchId, rbacContext);
                        });
                    });
                    SearchEventLogger.Instance.LogDiscoverySearchStartRequestProcessedEvent(CS$ < > 8__locals2.name, rbacContext, itemStore.MailboxOwner.MailboxInfo.OrganizationId.ToString());
                    break;

                case ActionRequestType.Stop:
                    this.CallSearchService(itemStore, CS$ < > 8__locals2.name, (Item)item, delegate(MailboxSearchClient client, SearchId searchId)
                    {
                        DiscoverySearchEventBasedAssistant.RpcCallWithRetry(delegate()
                        {
                            client.AbortEx(searchId, rbacContext);
                        });
                    });
                    SearchEventLogger.Instance.LogDiscoverySearchStopRequestProcessedEvent(CS$ < > 8__locals2.name, rbacContext, itemStore.MailboxOwner.MailboxInfo.OrganizationId.ToString());
                    break;

                case ActionRequestType.Restart:
                    this.CallSearchService(itemStore, CS$ < > 8__locals2.name, (Item)item, delegate(MailboxSearchClient client, SearchId searchId)
                    {
                        DiscoverySearchEventBasedAssistant.RpcCallWithRetry(delegate()
                        {
                            client.Remove(searchId, false);
                        });
                        SearchEventLogger.Instance.LogDiscoverySearchRemoveRequestProcessedEvent(CS$ < > 8__locals2.name, rbacContext, itemStore.MailboxOwner.MailboxInfo.OrganizationId.ToString());
                        DiscoverySearchEventBasedAssistant.RpcCallWithRetry(delegate()
                        {
                            client.StartEx(searchId, rbacContext);
                        });
                        SearchEventLogger.Instance.LogDiscoverySearchStartRequestProcessedEvent(CS$ < > 8__locals2.name, rbacContext, itemStore.MailboxOwner.MailboxInfo.OrganizationId.ToString());
                    });
                    break;

                case ActionRequestType.Delete:
                    this.CallSearchService(itemStore, CS$ < > 8__locals2.name, null, delegate(MailboxSearchClient client, SearchId searchId)
                    {
                        DiscoverySearchEventBasedAssistant.RpcCallWithRetry(delegate()
                        {
                            client.Remove(searchId, true);
                        });
                    });
                    SearchEventLogger.Instance.LogDiscoverySearchRemoveRequestProcessedEvent(CS$ < > 8__locals2.name, rbacContext, itemStore.MailboxOwner.MailboxInfo.OrganizationId.ToString());
                    break;

                case ActionRequestType.UpdateStatus:
                    this.CallSearchService(itemStore, CS$ < > 8__locals2.name, null, delegate(MailboxSearchClient client, SearchId searchId)
                    {
                        DiscoverySearchEventBasedAssistant.RpcCallWithRetry(delegate()
                        {
                            client.UpdateStatus(searchId);
                        });
                    });
                    break;
                }
                try
                {
                    itemStore.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                    {
                        item.Id
                    });
                    return;
                }
                catch (StoragePermanentException ex)
                {
                    DiscoverySearchEventBasedAssistant.Tracer.TraceError <string, StoragePermanentException>((long)this.GetHashCode(), "Failed to remove mailbox discovery search request item. Name: '{0}'. Exception: '{1}'", CS$ < > 8__locals2.name, ex);
                    SearchEventLogger.Instance.LogDiscoverySearchServerErrorEvent("Failed to remove mailbox discovery search request item", CS$ < > 8__locals2.name, itemStore.ServerFullyQualifiedDomainName, ex);
                    return;
                }
                catch (StorageTransientException ex2)
                {
                    DiscoverySearchEventBasedAssistant.Tracer.TraceError <string, StorageTransientException>((long)this.GetHashCode(), "Failed to remove mailbox discovery search request item. Name: '{0}'. Exception: '{1}'", CS$ < > 8__locals2.name, ex2);
                    SearchEventLogger.Instance.LogDiscoverySearchServerErrorEvent("Failed to remove mailbox discovery search request item", CS$ < > 8__locals2.name, itemStore.ServerFullyQualifiedDomainName, ex2);
                    return;
                }
            }
            DiscoverySearchEventBasedAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Skipping discovery search object from non-arbitration mailbox: {0}", itemStore.MailboxOwnerLegacyDN);
        }