Esempio n. 1
0
        static Logger()
        {
            try
            {
                var logLevels = ConfigurationManager.AppSettings["IPA.DAL.Application.Client.LogLevel"]?.Split('|') ?? new string[0];
                if (logLevels.Length > 0)
                {
                    string   fullName;
                    Assembly assembly = Assembly.GetEntryAssembly();
                    if (assembly != null)
                    {
                        fullName = assembly.Location;
                    }
                    else
                    {
                        fullName = new MainAssemblyInfo().Description;
                    }
                    string logname = System.IO.Path.GetFileNameWithoutExtension(fullName) + ".log";
                    string path    = System.IO.Directory.GetCurrentDirectory();
                    fileLoggerPath = path + "\\" + logname;

                    foreach (var item in logLevels)
                    {
                        foreach (var level in LogLevels.LogLevelsDictonary.Where(x => x.Value.Equals(item)).Select(x => x.Key))
                        {
                            logLevel += (int)level;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Logger: instantiate exception={0}", (object)ex.Message);
            }
        }
Esempio n. 2
0
 public ReportResponse ReportSpeed([FromBody] SpeedData speedData)
 {
     try {
         if (speedData == null)
         {
             return(ResponseBase.InvalidInput <ReportResponse>());
         }
         ClientData clientData = HostRoot.Instance.ClientSet.GetByClientId(speedData.ClientId);
         if (clientData == null)
         {
             clientData = ClientData.Create(speedData, ClientIp);
             HostRoot.Instance.ClientSet.Add(clientData);
         }
         else
         {
             clientData.Update(speedData, ClientIp);
         }
         if (Version.TryParse(speedData.Version, out Version version))
         {
             string jsonVersionKey = MainAssemblyInfo.GetServerJsonVersion(version);
             var    response       = ReportResponse.Ok(HostRoot.GetServerState(jsonVersionKey));
             if (speedData.LocalServerMessageTimestamp.AddSeconds(1) < HostRoot.Instance.ServerMessageTimestamp)
             {
                 var list = HostRoot.Instance.ServerMessageSet.GetServerMessages(speedData.LocalServerMessageTimestamp);
                 if (list.Count < 10)
                 {
                     response.NewServerMessages.AddRange(list);
                 }
             }
             return(response);
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
     return(ResponseBase.InvalidInput <ReportResponse>());
 }
Esempio n. 3
0
        public ReportResponse ReportSpeed([FromBody] SpeedData speedData)
        {
            ReportResponse response;

            try {
                if (speedData == null)
                {
                    response             = ResponseBase.InvalidInput <ReportResponse>();
                    response.ServerState = ServerState.Empty;
                    return(response);
                }
                ClientData clientData = HostRoot.Instance.ClientSet.GetByClientId(speedData.ClientId);
                if (clientData == null)
                {
                    clientData = ClientData.Create(speedData, ClientIp);
                    HostRoot.Instance.ClientSet.Add(clientData);
                }
                else
                {
                    clientData.Update(speedData, ClientIp);
                }
                if (Version.TryParse(speedData.Version, out Version version))
                {
                    string jsonVersionKey = MainAssemblyInfo.GetServerJsonVersion(version);
                    response             = ResponseBase.Ok <ReportResponse>();
                    response.ServerState = HostRoot.GetServerState(jsonVersionKey);
                    return(response);
                }
            }
            catch (Exception e) {
                Logger.ErrorDebugLine(e);
            }
            response             = ResponseBase.InvalidInput <ReportResponse>();
            response.ServerState = ServerState.Empty;
            return(response);
        }