Exemplo n.º 1
0
        private void ListAllEndpointView()
        {
            var endpointList = endpointController.ListAll();

            Console.WriteLine(I18nService.GetTranslate("LIST_ALL_ENDPOINT"));
            foreach (var endpoint in endpointList)
            {
                Console.WriteLine(endpoint.ToString());
            }
            PressAnyKeyToContinue();
        }
Exemplo n.º 2
0
        public Endpoint Edit(EndpointVO endpointVo)
        {
            if (string.IsNullOrEmpty(endpointVo.serialNumber))
            {
                throw new AppException(I18nService.GetTranslate("INVALID_SERIAL_NUMBER"));
            }

            var editEndpointService = new EditEndpointService();

            return(editEndpointService.Execute(endpointVo));
        }
Exemplo n.º 3
0
        public Endpoint FindOne(string identifier)
        {
            if (string.IsNullOrEmpty(identifier))
            {
                throw new AppException(I18nService.GetTranslate("INVALID_SERIAL_NUMBER"));
            }

            var findEndpointBySerialNumberService = new FindEndpointBySerialNumberService();

            return(findEndpointBySerialNumberService.Execute(identifier));
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            ModelId     meterModelIdLabel = (ModelId)meterModelId;
            SwitchState switchStateLabel  = (SwitchState)switchState;

            return(string.Format("{0}: {1} | " +
                                 "{2}: {3} | " +
                                 "{4}: {5} | " +
                                 "{6}: {7} | " +
                                 "{8}: {9}",
                                 I18nService.GetTranslate("SERIAL_NUMBER"), serialNumber,
                                 I18nService.GetTranslate("METER_MODEL_ID"), meterModelIdLabel,
                                 I18nService.GetTranslate("METER_NUMBER"), meterNumber,
                                 I18nService.GetTranslate("METER_FIRMWARE_VERSION"), meterFirmwareVersion,
                                 I18nService.GetTranslate("SWITCH_STATE"), switchStateLabel));
        }
Exemplo n.º 5
0
 public static void ValidateSwitchState(string switchState, Endpoint endpoint)
 {
     if (switchState.ToLower() == SwitchState.Disconnected.ToString().ToLower())
     {
         endpoint.switchState = (int)SwitchState.Disconnected;
     }
     else if (switchState.ToLower() == SwitchState.Connected.ToString().ToLower())
     {
         endpoint.switchState = (int)SwitchState.Connected;
     }
     else if (switchState.ToLower() == SwitchState.Armed.ToString().ToLower())
     {
         endpoint.switchState = (int)SwitchState.Armed;
     }
     else
     {
         throw new AppException(I18nService.GetTranslate("INVALID_SWITCH_STATE_INPUT"));
     }
 }
Exemplo n.º 6
0
        private void EditEndpointView()
        {
            Console.WriteLine(I18nService.GetTranslate("EDIT_ENDPOINT"));
            Console.Write(I18nService.GetTranslate("SERIAL_NUMBER") + ": ");
            var serialNumber = Console.ReadLine();

            Console.Write(I18nService.GetTranslate("SWITCH_STATE") + string.Format(" ({0} | {1} | {2}): ", SwitchState.Disconnected, SwitchState.Connected, SwitchState.Armed));
            var switchState = Console.ReadLine();

            var newEndpoint = new EndpointVO()
            {
                serialNumber = serialNumber,
                switchState  = switchState,
            };

            var endpoint = endpointController.Edit(newEndpoint);

            Console.WriteLine(I18nService.GetTranslate("SUCCESSLY_EDITED_ENDPOINT"));
            PressAnyKeyToContinue();
        }
Exemplo n.º 7
0
        public Endpoint Create(EndpointVO endpointVo)
        {
            if (string.IsNullOrEmpty(endpointVo.serialNumber))
            {
                throw new AppException(I18nService.GetTranslate("INVALID_SERIAL_NUMBER"));
            }
            if (string.IsNullOrEmpty(endpointVo.meterFirmwareVersion))
            {
                throw new AppException(I18nService.GetTranslate("INVALID_METER_FIRMWARE_VERSION"));
            }
            int number;

            if (string.IsNullOrEmpty(endpointVo.meterNumber) || !int.TryParse(endpointVo.meterNumber, out number))
            {
                throw new AppException(I18nService.GetTranslate("INVALID_METER_NUMBER"));
            }

            var createEndpointService = new CreateEndpointService();

            return(createEndpointService.Execute(endpointVo));
        }
Exemplo n.º 8
0
 public static void ValidateModelId(string modelId, Endpoint endpoint)
 {
     if (modelId.ToUpper() == ModelId.NSX1P2W.ToString().ToUpper())
     {
         endpoint.meterModelId = (int)ModelId.NSX1P2W;
     }
     else if (modelId.ToUpper() == ModelId.NSX1P3W.ToString().ToUpper())
     {
         endpoint.meterModelId = (int)ModelId.NSX1P3W;
     }
     else if (modelId.ToUpper() == ModelId.NSX1P4W.ToString().ToUpper())
     {
         endpoint.meterModelId = (int)ModelId.NSX1P4W;
     }
     else if (modelId.ToUpper() == ModelId.NSX1P5W.ToString().ToUpper())
     {
         endpoint.meterModelId = (int)ModelId.NSX1P5W;
     }
     else
     {
         throw new AppException(I18nService.GetTranslate("INVALID_METER_MODE_INPUT"));
     }
 }
Exemplo n.º 9
0
        public void StartApp()
        {
            var input = ConsoleKey.NumPad0;

            do
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine(I18nService.GetTranslate("INSERT_NEW_ENDPOINT_MENU"));
                    Console.WriteLine(I18nService.GetTranslate("EDIT_ENDPOINT_MENU"));
                    Console.WriteLine(I18nService.GetTranslate("DELETE_ENDPOINT_MENU"));
                    Console.WriteLine(I18nService.GetTranslate("LIST_ALL_ENDPOINT_MENU"));
                    Console.WriteLine(I18nService.GetTranslate("FIND_ENDPOINT_MENU"));
                    Console.WriteLine(I18nService.GetTranslate("EXIT_MENU"));
                    input = Console.ReadKey().Key;
                    Console.Clear();
                    switch (input)
                    {
                    case ConsoleKey.D1:
                    case ConsoleKey.NumPad1:
                        InsertEndpointView();
                        break;

                    case ConsoleKey.D2:
                    case ConsoleKey.NumPad2:
                        EditEndpointView();
                        break;

                    case ConsoleKey.D3:
                    case ConsoleKey.NumPad3:
                        DeleteEndpointView();
                        break;

                    case ConsoleKey.D4:
                    case ConsoleKey.NumPad4:
                        ListAllEndpointView();
                        break;

                    case ConsoleKey.D5:
                    case ConsoleKey.NumPad5:
                        FindEndpointView();
                        break;

                    case ConsoleKey.D6:
                    case ConsoleKey.NumPad6:
                        break;

                    default:
                        Console.WriteLine(I18nService.GetTranslate("INVALID_INPUT_TRY_AGAIN"));
                        PressAnyKeyToContinue();
                        break;
                    }
                }
                catch (AppException e)
                {
                    Console.WriteLine(e.Message);
                    PressAnyKeyToContinue();
                }
            } while (input != ConsoleKey.NumPad6 && input != ConsoleKey.D6);
        }
Exemplo n.º 10
0
 private void PressAnyKeyToContinue()
 {
     Console.WriteLine(I18nService.GetTranslate("PRESS_ANY_KEY_TO_CONTINUE"));
     Console.ReadKey();
 }