コード例 #1
0
        public Response GetLog(GetLogRequest request)
        {
            var retval = new Response();

            try
            {
                var logFilePath = @"C:\Logs\" + request.LogName;


                using (StreamReader sr = new StreamReader(logFilePath))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        retval = new GetLogResponseOK(line);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147024894)
                {
                    return(new GetLogNotExistResponse());
                }
                return(new AppResponseError(ex.Message));
            }
        }
コード例 #2
0
 public Response GetLog(GetLogRequest request)
 {
     try
     {
         var ds     = _dal.GetLog(request.LogName);
         var tbl    = ds.Tables[0];
         var retval = new Response();
         if (tbl.Rows.Count == 1)
         {
             retval = new GetLogResponseOK((string)tbl.Rows[0][0]);
         }
         return(retval);
     }
     catch (Exception ex)
     {
         return(new AppResponseError(ex.Message));
     }
 }