Exemple #1
0
        public async Task <bool> SetzeZielFürNummerInformationAsync()
        {
            bool success = false;
            Guid?guid    = StandardRequirement.Instance.BonsaiTransferGuid;


            if (guid.HasValue && StandardRequirement.Instance.ErstellteNummerDefinitionResponse != null)
            {
                long gemasauftragsnummer = Common.Helpers.Random_Helper.GetLong(0, 10000);

                using (var httpClient = new HttpClient())
                {
                    SetzeZielFürNummerInformationRequest setzeZielFürNummerInformationRequest = LieferSetzeZielFürNummerInformation(guid, gemasauftragsnummer);
                    StringContent content = new StringContent(JsonConvert.SerializeObject(setzeZielFürNummerInformationRequest), Encoding.UTF8, "application/json");
                    using (HttpResponseMessage response = await httpClient.PutAsync(BaseAPIURL + "SetzeZielFürNummerInformation/", content))
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            string apiResponse = await response.Content.ReadAsStringAsync();

                            NummerInformation nummerInformation = JsonConvert.DeserializeObject <NummerInformation>(apiResponse);
                            if (nummerInformation != null && nummerInformation.Ziel == gemasauftragsnummer.ToString())
                            {
                                StandardRequirement.Instance.GemasAuftragsnummer = gemasauftragsnummer;
                                success = true;
                            }
                        }
                    }
                }
            }


            return(success);
        }
        private static async Task <bool> SetzeZielFürNummerInformationAsync(SetzeZielFürNummerInformationRequest setzeZielFürNummerInformationRequest)
        {
            bool success = false;


            if (setzeZielFürNummerInformationRequest != null)
            {
                using (var httpClient = new HttpClient())
                {
                    StringContent content = new StringContent(JsonConvert.SerializeObject(setzeZielFürNummerInformationRequest), Encoding.UTF8, "application/json");
                    using (HttpResponseMessage response = await httpClient.PutAsync(BaseAPIURL + "SetzeZielFürNummerInformation/", content))
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            string apiResponse = await response.Content.ReadAsStringAsync();

                            NummerInformation nummerInformation = JsonConvert.DeserializeObject <NummerInformation>(apiResponse);
                            if (nummerInformation != null)
                            {
                                success = true;
                            }
                        }
                    }
                }
            }


            return(success);
        }
        private static SetzeZielFürNummerInformationRequest ErstelleSetzeZielFürNummerInformation(Guid?guid, NummerDefinition nummerDefinition)
        {
            SetzeZielFürNummerInformationRequest setzeZielFürNummerInformationRequest = null;

            if (guid.HasValue && nummerDefinition != null)
            {
                object ziel = null;
                switch ((Datentypwerte)nummerDefinition.ZielDatentypenId)
                {
                case Datentypwerte.String:
                    ziel = Guid.NewGuid().ToString();
                    break;

                case Datentypwerte.Integer:
                    ziel = Random_Helper.GetLong(0L, 100000L);
                    break;

                case Datentypwerte.Guid:
                    ziel = Guid.NewGuid();
                    break;

                default:
                    break;
                }
                setzeZielFürNummerInformationRequest = new SetzeZielFürNummerInformationRequest();
                setzeZielFürNummerInformationRequest.NummerInformationGuid = guid.Value;
                setzeZielFürNummerInformationRequest.Ziel = ziel;
            }

            return(setzeZielFürNummerInformationRequest);
        }
Exemple #4
0
        public static SetzeZielFürNummerInformationRequest LieferSetzeZielFürNummerInformation(Guid?nummerInformationGuid, long auftragsnummer)
        {
            SetzeZielFürNummerInformationRequest setzeZielFürNummerInformationRequest = new SetzeZielFürNummerInformationRequest();

            setzeZielFürNummerInformationRequest.NummerInformationGuid = nummerInformationGuid.Value;
            setzeZielFürNummerInformationRequest.Ziel = auftragsnummer;

            return(setzeZielFürNummerInformationRequest);
        }
Exemple #5
0
        public async Task <ActionResult <Data.Models.NummerInformation> > SetzeZielFürNummerInformation(SetzeZielFürNummerInformationRequest setzeZielFürNummerInformationRequest)
        {
            Data.Models.NummerInformation nummerInformation = null;

            if (setzeZielFürNummerInformationRequest == null)
            {
                throw new ArgumentNullException(nameof(setzeZielFürNummerInformationRequest));
            }

            if (setzeZielFürNummerInformationRequest.NummerInformationGuid == null)
            {
                throw new ArgumentNullException(nameof(setzeZielFürNummerInformationRequest.NummerInformationGuid));
            }

            if (setzeZielFürNummerInformationRequest.Ziel == null)
            {
                throw new ArgumentNullException(nameof(setzeZielFürNummerInformationRequest.Ziel));
            }
            //TODO BK Ziel muss für jede Definition eindeutig sein.
            else
            {
                Guid guid = (Guid)setzeZielFürNummerInformationRequest.NummerInformationGuid;
                nummerInformation = await this._context.Nummerinformationen.Where(e => (e.Guid != null && e.Guid.ToString() == guid.ToString())).FirstOrDefaultAsync();

                if (nummerInformation == null)
                {
                    return(NotFound());
                }
                else
                {
                    string ziel = setzeZielFürNummerInformationRequest.Ziel.ToString();
                    nummerInformation.Ziel = ziel;
                    _context.Entry(nummerInformation).State = EntityState.Modified;
                    try
                    {
                        await this._context.SaveChangesAsync();

                        return(Ok(nummerInformation));
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        return(StatusCode((int)HttpStatusCode.InternalServerError));
                    }
                }
            }
        }
        public async Task <MassTestResult> RunAsync(long max)
        {
            MassTestResult          massTestResult     = new MassTestResult();
            List <NummerDefinition> nummerDefinitionen = new List <NummerDefinition>();
            List <ErstelleNummerInformationRequest> erstelleNummerInformationRequests = new List <ErstelleNummerInformationRequest>();
            long countOfDefinitions = Random_Helper.GetLong(1L, max);

            massTestResult.CountOfDefinitions = countOfDefinitions;
            for (long i = 0; i < countOfDefinitions; i++)
            {
                NummerDefinition nummerDefinition = CreateRandomNummerDefinition();
                ErstellteNummerDefinitionResponse ErstellteNummerDefinitionResponse = await ErstelleNummerDefinitionAsync(nummerDefinition);

                if (ErstellteNummerDefinitionResponse != null)
                {
                    nummerDefinition.Guid = ErstellteNummerDefinitionResponse.Guid;
                    nummerDefinition.Id   = ErstellteNummerDefinitionResponse.Id;
                    nummerDefinitionen.Add(nummerDefinition);
                }
                else
                {
                    WriteRedTextToConsole("NummerDefinition konnte nicht erstellt werden.");
                }
            }
            long countOfInformations = Random_Helper.GetLong(1L, max);

            massTestResult.CountOfInformations = countOfInformations;
            foreach (var nummerDefinition in nummerDefinitionen)
            {
                for (int i = 0; i < countOfInformations; i++)
                {
                    ErstelleNummerInformationRequest erstelleNummerInformationRequest = CreateRandomErstelleNummerInformation(nummerDefinition);
                    Guid?guid = await ErstelleNummerInformationAsync(erstelleNummerInformationRequest);

                    if (guid.HasValue)
                    {
                        erstelleNummerInformationRequests.Add(erstelleNummerInformationRequest);
                        SetzeZielFürNummerInformationRequest setzeZielFürNummerInformationRequest = ErstelleSetzeZielFürNummerInformation(guid, nummerDefinition);
                        bool success = await SetzeZielFürNummerInformationAsync(setzeZielFürNummerInformationRequest);

                        if (success)
                        {
                            MassTestMeasure massTestMeasure = new MassTestMeasure();
                            massTestMeasure.CountOfInformations = await this._context.Nummerinformationen.CountAsync();

                            massTestMeasure.Start = DateTime.Now;
                            NummerInformation nummerInformation = await HoleNummerInformationAsync(nummerDefinition, erstelleNummerInformationRequest);

                            if (nummerInformation != null && nummerInformation.Ziel.ToString() == setzeZielFürNummerInformationRequest.Ziel.ToString())
                            {
                                massTestMeasure.End          = DateTime.Now;
                                massTestMeasure.Milliseconds = (massTestMeasure.End - massTestMeasure.Start).TotalMilliseconds;
                                massTestResult.MassTestMeasures.Add(massTestMeasure);
                            }
                            else
                            {
                                WriteRedTextToConsole("NummerInformation konnte nicht geholt werden.");
                            }
                        }
                    }
                    else
                    {
                        WriteRedTextToConsole("NummerInformation konnte nicht erstellt werden.");
                    }
                }
            }
            massTestResult.CountOfErstelleNummerInformationen = erstelleNummerInformationRequests.Count;


            return(massTestResult);
        }