Beispiel #1
0
        public void LoginTime(object source, ElapsedEventArgs elapsedEventArgs)
        {
            try
            {
                Logger.LogEvent("Authenticating");

                RefreshServiceTicket();

                myResponse myResponse = CredentialSoap.myAsync(new my()).GetAwaiter().GetResult();
                if (myResponse is null || myResponse.@return is null)
                {
                    Logger.LogEvent("Could not authenticate !", EventLogEntryType.Error);
                    return;
                }

                Org.Visiontech.CredentialGrouping.simpleCriteriaDTO criteria = new Org.Visiontech.CredentialGrouping.simpleCriteriaDTO
                {
                    criteria = new Org.Visiontech.CredentialGrouping.credentialGroupingDTO
                    {
                        credential = new Org.Visiontech.CredentialGrouping.credentialDTO
                        {
                            id = [email protected]
                        },
                        role = new Org.Visiontech.CredentialGrouping.roleDTO
                        {
                            code = "FACTORY"
                        },
                        group = new Org.Visiontech.CredentialGrouping.groupDTO
                        {
                        },
                        validSpecified   = true,
                        valid            = true,
                        deletedSpecified = true,
                        deleted          = false
                    }
                };

                Org.Visiontech.CredentialGrouping.findResponse findResponse = CredentialGroupingSoap.findAsync(new Org.Visiontech.CredentialGrouping.find(new[] { criteria }, Array.Empty <Org.Visiontech.CredentialGrouping.findOrderDTO>(), 1, 0)).GetAwaiter().GetResult();

                if (findResponse is null || [email protected] <= 0 || [email protected] is null)
                {
                    Logger.LogEvent("Could not find the factory grant !", EventLogEntryType.Error);
                    return;
                }

                Logger.LogEvent("Authenticated as " + [email protected]);
                if ([email protected]() is Org.Visiontech.CredentialGrouping.credentialGroupingDTO credentialGroupingDTO)
                {
                    Logger.LogEvent("Grant from group " + credentialGroupingDTO.group.code);
                }

                XGrant = [email protected]().id;

                SharedServiceProvider.ServiceProvider.GetRequiredService <IAuthenticatingMessageInspector>().HttpRequestMessageProperty.Headers.Set("X-Grant", XGrant);

                LoginTimer.Stop();
                Callback.Invoke();
            } catch (Exception e) {
                Logger.LogEvent("Error " + e.Message);
                Logger.LogEvent("StackTrace " + e.StackTrace);
            }
        }