コード例 #1
0
ファイル: EndpointConsole.cs プロジェクト: CortezzZ007/Landis
        public void CreateEndpoint()
        {
            var endpointDto = new EndpointDto();

            Console.WriteLine("\n-----------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("\nStarting an endpoint registration");
            endpointDto.SerialNumber = customInputValidation.GetString("\nType the serial number of the endpoint and press enter: ", this.error);

            endpointDto.MeterModelId = this.validateSerialNumberOfEndpoint.Execute(endpointDto.SerialNumber);
            if (this.validateSerialNumberOfEndpoint.Error.Count > 0)
            {
                Console.WriteLine(this.validateSerialNumberOfEndpoint.Error.First());
                this.CreateEndpoint();
            }

            if (endpointDto.MeterModelId == 0)
            {
                endpointDto.MeterModelId = customInputValidation.GetInteger("\nType the model meter id and press enter: ", this.error);
            }
            else
            {
                Console.WriteLine("Model Meter ID: " + endpointDto.MeterModelId.ToString());
            }

            endpointDto.MeterNumber          = customInputValidation.GetInteger("\nType the meter number and press enter: ", this.error);
            endpointDto.MeterFirmwareVersion = customInputValidation.GetString("\nType the Meter Firmware version and press enter: ", this.error);
            Console.WriteLine("\nChoose which state the endpoint is in: ");
            Console.WriteLine("1- Disconnected");
            Console.WriteLine("2- Connected");
            Console.WriteLine("3- Armed");

            endpointDto.State = customInputValidation.GetInteger("Type the option of your choice and press enter: ", this.error);

            while (!(endpointDto.State == 1 || endpointDto.State == 2 || endpointDto.State == 3))
            {
                Console.WriteLine("Option invalid.");
                endpointDto.State = customInputValidation.GetInteger("Type the option of your choice and press enter: ", this.error);
            }

            this.createEndpoint.Execute(EndpointFactory.MapEndpoint(endpointDto));
            Console.WriteLine("\nRegistration completed");
            Console.WriteLine(this.sucess);
            this.BackMenuInitial();
        }