Beispiel #1
0
        public void SearchEndpoint()
        {
            var endpointDto = new EndpointDto();

            Console.WriteLine("\n-----------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("Search for an endpoint");
            endpointDto.SerialNumber = customInputValidation.GetString("\nType the serial number of the endpoint you want to find and press enter: ", this.error);

            endpointDto = EndpointFactory.MapEndpointDto(this.searchBySerialNumber.Execute(endpointDto.SerialNumber));
            if (this.searchBySerialNumber.Error.Count > 0)
            {
                Console.WriteLine(this.searchBySerialNumber.Error.First());
                this.SearchEndpoint();
            }

            Console.WriteLine("\nEndpoint found!");
            var tableData = new List <EndpointDto>();

            tableData.Add(endpointDto);

            var table = ConsoleTable.From(tableData).Configure(y => y.EnableCount = false);

            Console.Write(table);
            this.BackMenuInitial();
        }
 public async Task RegisterEndpoint([FromBody] EndpointDto endpointDto)
 {
     var endpoint = new Endpoint {
         Name = endpointDto.Name, CheckInterval = endpointDto.CheckInterval, CheckType = (CheckType)endpointDto.CheckType, IsActive = endpointDto.IsActive, IsCritical = endpointDto.IsCritical, Tags = endpointDto.Tags, Url = endpointDto.Url
     };
     await _store.StoreEndpointAsync(endpoint);
 }
        public async Task UpdateEndpoint(int id, [FromBody] EndpointDto endpointDto)
        {
            var endpoint = await _store.GetByEndpointIdAsync(id);

            if (!string.IsNullOrEmpty(endpointDto.Name))
            {
                endpoint.Name = endpointDto.Name;
            }

            if (!string.IsNullOrEmpty(endpointDto.Tags))
            {
                endpoint.Tags = endpointDto.Tags;
            }

            if (!string.IsNullOrEmpty(endpointDto.Url))
            {
                endpoint.Url = endpointDto.Url;
            }

            endpoint.CheckInterval = endpointDto.CheckInterval;
            endpoint.CheckType     = (CheckType)endpointDto.CheckType;
            endpoint.IsActive      = endpointDto.IsActive;
            endpoint.IsCritical    = endpointDto.IsCritical;
            endpoint.PublishStats  = endpointDto.PublishStats;

            await _store.UpdateEndpointAsync(endpoint);
        }
Beispiel #4
0
        public static Endpoint MapEndpoint(EndpointDto endpointDto)
        {
            var endpoint = new Endpoint(endpointDto.SerialNumber, endpointDto.MeterModelId, endpointDto.MeterNumber,
                                        endpointDto.MeterFirmwareVersion, endpointDto.State);

            return(endpoint);
        }
 public static AddEndpointRequest MapToRequest(EndpointDto source)
 {
     return(new AddEndpointRequest
     {
         SipAddress = source.Sip,
         DisplayName = source.DisplayName,
         Pin = source.Pin,
         DefenceAdvocate = source.DefenceAdvocateUsername
     });
 }
Beispiel #6
0
        public void Edit()
        {
            var endpointDto = new EndpointDto();

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

            endpointDto = EndpointFactory.MapEndpointDto(this.searchBySerialNumber.Execute(endpointDto.SerialNumber));
            if (this.searchBySerialNumber.Error.Count > 0)
            {
                Console.WriteLine(this.searchBySerialNumber.Error.First());
                this.Edit();
            }
            Console.WriteLine("\nEndpoint found!");
            var tableData = new List <EndpointDto>();

            tableData.Add(endpointDto);

            var table = ConsoleTable.From(tableData).Configure(y => y.EnableCount = false);

            Console.Write(table);

            var chosenItem = customInputValidation.GetInteger("\nDo you want to change the endpoint state?\n1- Yes\n2- No\nType the desired option and press enter:  ", this.error);

            if (chosenItem == 1)
            {
                Console.WriteLine("\nStarting endpoint editing.");
                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.editStateEndpoint.Execute(endpointDto.SerialNumber, endpointDto.State);
                if (editStateEndpoint.Error.Count > 0)
                {
                    Console.WriteLine(editStateEndpoint.Error.First());
                }
                else
                {
                    Console.WriteLine("\nFinished editing");
                    Console.WriteLine(sucess);
                }
            }

            this.BackMenuInitial();
        }
Beispiel #7
0
        public static Kinly.Endpoint MapToEndpoint(EndpointDto source, int index)
        {
            var kinlyDisplayName = $"T{100 + index};{source.DisplayName};{source.Id}";

            return(new Kinly.Endpoint
            {
                Address = source.SipAddress,
                Display_name = kinlyDisplayName,
                Pin = source.Pin
            });
        }
Beispiel #8
0
        public static EndpointDto[] GetEndpointDtosByCustomerAcct(short pCustomerAcctId)
        {
            var _endpoints = new List <EndpointDto>();

            EndPointRow[] _endpointRows = GetEndpointsByCustomerAcct(pCustomerAcctId);
            if (_endpointRows != null && _endpointRows.Length > 0)
            {
                foreach (EndPointRow _endpointRow in _endpointRows)
                {
                    var _endpoint = new EndpointDto(_endpointRow.End_point_id, _endpointRow.DottedIPAddressRange);
                    _endpoints.Add(_endpoint);
                }
            }
            return(_endpoints.ToArray());
        }
Beispiel #9
0
        public static EndpointDto MapEndpointDto(Endpoint endpoint)
        {
            var endpointDto = new EndpointDto();

            if (endpoint != null)
            {
                endpointDto.SerialNumber         = endpoint.SerialNumber;
                endpointDto.MeterFirmwareVersion = endpoint.MeterFirmwareVersion;
                endpointDto.MeterModelId         = endpoint.MeterModelId;
                endpointDto.MeterNumber          = endpoint.MeterNumber;
                endpointDto.State = endpoint.State;
            }
            ;
            return(endpointDto);
        }
Beispiel #10
0
        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();
        }
Beispiel #11
0
        public void Delete()
        {
            var endpointDto = new EndpointDto();

            Console.WriteLine("\n-----------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("\nDelete Endpoint");
            endpointDto.SerialNumber = customInputValidation.GetString("\nType the serial number of the endpoint you want to delete and press enter: ", this.error);

            endpointDto = EndpointFactory.MapEndpointDto(this.searchBySerialNumber.Execute(endpointDto.SerialNumber));
            if (this.searchBySerialNumber.Error.Count > 0)
            {
                Console.WriteLine(this.searchBySerialNumber.Error.First());
                this.Delete();
            }
            Console.WriteLine("\nEndpoint found!");
            var tableData = new List <EndpointDto>();

            tableData.Add(endpointDto);

            var table = ConsoleTable.From(tableData).Configure(y => y.EnableCount = false);

            Console.Write(table);

            var chosenItem = customInputValidation.GetInteger("\nDo you really want to delete this endpoint?\n1- Yes\n2- No\nType the desired option and press enter: ", this.error);

            while (!(chosenItem == 1 || chosenItem == 2))
            {
                chosenItem = customInputValidation.GetInteger("\nDo you really want to delete this endpoint?\n1- Yes\n2- No\nType the desired option and press enter: ", this.error);
            }
            if (chosenItem == 1)
            {
                this.deleteEndpoint.Execute(endpointDto.SerialNumber);
                if (this.deleteEndpoint.Error.Count > 0)
                {
                    Console.WriteLine(this.searchBySerialNumber.Error.First());
                    this.Delete();
                }
                Console.WriteLine("\n" + sucess);
            }
            this.BackMenuInitial();
        }