//******************************************************************************//
// TestInfoService.cs
// 12/4/2023
//
// RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
// PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
// AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
// UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
// RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
// CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
// OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
// COMPANY.
//
// THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S. GOVERNMENT
//
// UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
//
// WARNING: THIS DOCUMENT CONTAINS TECHNICAL DATA AND / OR TECHNOLOGY WHOSE
// EXPORT OR DISCLOSURE TO NON-U.S. PERSONS, WHEREVER LOCATED, IS RESTRICTED
// BY THE INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) (22 C.F.R. SECTION
// 120-130) OR THE EXPORT ADMINISTRATION REGULATIONS (EAR) (15 C.F.R. SECTION
// 730-774). THIS DOCUMENT CANNOT BE EXPORTED (E.G., PROVIDED TO A SUPPLIER
// OUTSIDE OF THE UNITED STATES) OR DISCLOSED TO A NON-U.S. PERSON, WHEREVER
// LOCATED, UNTIL A FINAL JURISDICTION AND CLASSIFICATION DETERMINATION HAS
// BEEN COMPLETED AND APPROVED BY RAYTHEON, AND ANY REQUIRED U.S. GOVERNMENT
// APPROVALS HAVE BEEN OBTAINED. VIOLATIONS ARE SUBJECT TO SEVERE CRIMINAL
// PENALTIES.
//
// DOD 5220.22-M, INDUSTRIAL SECURITY MANUAL, CHAPTER 5, SECTION 1 THROUGH 9 :
// FOR CLASSIFIED DOCUMENTS FOLLOW THE PROCEDURES IN OR DOD 5200.1-R,
// INFORMATION SECURITY PROGRAM, CHAPTER 6. FOR UNCLASSIFIED, LIMITED DOCUMENTS
// DESTROY BY ANY  METHOD THAT WILL PREVENT DISCLOSURE OF CONTENTS OR
// RECONSTRUCTION OF THE DOCUMENT.
// POC: Alex Kravchenko (1118268)
//******************************************************************************//

// Ignore Spelling: Unsubscribe

using System;
using System.Collections.Generic;
using System.ServiceModel;
using GalaSoft.MvvmLight.Messaging;
using NLog;
using Raytheon.LogDashboard.Parsers;

namespace Raytheon.LogDashboard.Service
{
    [ServiceBehavior(Name = "TestInfoService",
        Namespace = "http://epts.data.us.ray.com/EPTS/TRS",
        InstanceContextMode = InstanceContextMode.PerSession,
        ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class TestInfoService : ITestInfoService
    {
        /// <summary>
        /// Logger
        /// </summary>
        private readonly ILogger _log = LogManager.GetCurrentClassLogger();

        /// <summary>
        /// Used to set the parse profile path to be used when parsing scan data
        /// </summary>
        /// <param name="parseProfilePath"></param>
        public void SetParseProfile(string parseProfilePath)
        {
            _log.Debug($"Setting Parse Profile for path: {parseProfilePath}");
        }

        /// <summary>
        /// Used to subscribe to the Data Entry Accept event
        /// The name of the client's pipeServer is provided for Data Entry to be able to call out to it
        /// </summary>
        /// <param name="keyName"></param>
        public void SubscribeToDataEntry(string keyName)
        {
            _log.Debug($"Subscribing to Data Entry with key: {keyName}");
        }

        /// <summary>
        /// Unsubscripted from data entry.
        /// </summary>
        /// <param name="keyName">Name of the key.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void UnsubscribeFromDataEntry(string keyName)
        {
            _log.Debug($"Unsubscribing from Data Entry with key: {keyName}");
        }

        /// <summary>
        /// Used to retrieve accepted data
        /// This will continue to return the previous scan entry until a new scan is accepted in the UI
        /// </summary>
        /// <returns></returns>
        public IDictionary<string, string> GetStoredScanData()
        {
            _log.Debug("Getting Stored Scan Data");
            return null;
        }

        /// <summary>
        /// BCCapture will call this method via WCF
        /// //
        /// Parse the string that BCCapture passes.
        /// Determine if it is DES data scan or RSS scan
        /// If DES data scan
        /// Call Message.Send.Default
        /// Else (RSS scan)
        /// Create a new Test Session
        /// </summary>
        /// <returns></returns>
        public void ProcessScannedData(string scannedData)
        {
            _log.Debug($"Received Scan Data {scannedData}");
        }


        /// <summary>
        /// A call that lets the client end check to see if the endpoint is available.
        /// </summary>
        /// <returns></returns>
        public bool IsAlive()
        {
            return true;
        }

        /// <summary>
        /// Used to move the TRS window to active/ to front
        /// </summary>
        public void MoveWindowToFront()
        {
            _log.Debug("Move Window to the Front call");
        }

        /// <summary>
        /// will process messages submitted by texPrint
        /// </summary>
        /// <param name="message"></param>
        public void ReportMessage(string message)
        {
            _log.Debug("Report Message call");
        }

        /// <summary>
        /// Logs the message via local log4net.
        /// </summary>
        /// <param name="level">The level.</param>
        /// <param name="message">The message.</param>
        public void LogMessage(string level, string message)
        {
            Messenger.Default.Send(new NotificationMessage<Model.LogMessage>(new Model.LogMessage
            {
                Level = WCFPacketsParser.FromNLogLevelToDashboardLevel(level),
                Address = "EPTS",
                Logger = "EPTS",
                Message = message,
                Time = DateTime.Now,
            },
            level), "WCFMessage");
        }

        /// <summary>
        /// Handshake with Common Operator Interface.
        /// </summary>
        /// <param name="caller">The caller.</param>
        /// <exception cref="NotImplementedException"></exception>
        public void Handshake(string caller)
        {
            _log.Debug($"Handshake Message Received from caller: {caller}");
        }

        /// <summary>
        /// Menus the command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <exception cref="NotImplementedException"></exception>
        public void MenuCommand(string command)
        {
            _log.Debug($"Menu Command Received command: {command}");
        }
    }
}