Ejemplo n.º 1
0
 public void BuildQueries(Query query)
 {
     //serialize query object
     var xmlSerializer= new XmlSerializer();
     var xsltTransformer = new DefaultXslTransformer();
     var fileReaderWriter = new FileReaderWriter();
     var tourInfoFactory = new TourInfoFactory();
     //transform serialized object with accompanying xsl template and set to operator.query
     foreach (var op in _operatorFactory.Operators)
     {
         query.SetCultureInfo(op.CultureInfo);
         var serializedQuery = xmlSerializer.Serialize(query);
         op.SerializedTourDataRequests = xsltTransformer.Transform(serializedQuery, op.QueryTemplateFile, false);
         op.SerializedHotelListRequests = xsltTransformer.Transform(serializedQuery, op.AllHotelsTemplateFile, false);
         if (!string.IsNullOrEmpty(op.TourInfoFile) && File.Exists(op.TourInfoFile))
         {
             op.TourInfo = tourInfoFactory.Deserialize(fileReaderWriter.ReadFile(op.TourInfoFile, true));
         }
         op.QueryObject = query.Clone();
     }
 }
Ejemplo n.º 2
0
        public static string GetFileContent(string filePath)
        {
            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException("File not found: " + filePath);
            }

            var _fileReaderWriter = new FileReaderWriter();
            string fileContent = "";

            try
            {
                fileContent = _fileReaderWriter.ReadFile(filePath, true);

            }
            catch (Exception e)
            {

                throw e;
            }
            return fileContent;
        }
Ejemplo n.º 3
0
        public static void ResetLogFile()
        {
            var data = Environment.NewLine + "DateTime\t\tThreadId\tDescription";

            data += Environment.NewLine + "--------\t\t--------\t-----------";
            data += Environment.NewLine + OneLine("Start") + Environment.NewLine;

            var fileReaderWriter = new FileReaderWriter();

            _logFilePath = Path.GetFullPath(Path.Combine(Helper.AssemblyDirectory,
                                @"..\..\logs\log_" + DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year + "." + DateTime.Now.Hour + "." + DateTime.Now.Minute + "." + DateTime.Now.Second + ".txt"));
            fileReaderWriter.WriteFile(LogFilePath, data);
        }
Ejemplo n.º 4
0
        public static void LogExceptions(Exception exception)
        {
            if (exception == null) return;
            var data = OneLine("EXCEPTION ENCOUNTERED")+Environment.NewLine;

            var webException = exception as WebException;
            if (exception.InnerException !=null && webException == null)
            {
                webException = exception.InnerException as WebException;
            }
            if(webException!=null)
            {
                if (webException.Status == WebExceptionStatus.ProtocolError)
                {
                    using (var resp = webException.Response)
                    {
                        try
                        {
                            using (var sr = new StreamReader(resp.GetResponseStream()))
                            {
                                data += OneLine("Web Exception Details:" + Environment.NewLine + sr.ReadToEnd()) + Environment.NewLine;

                                sr.Close();
                            }

                        }
                        catch (Exception exc)
                        {
                            data += OneLine("Another exception: " + exc.Message) + Environment.NewLine;
                        }
                        resp.Close();
                    }
                }
            }

            data += OneLine(exception.Message + Environment.NewLine + exception.StackTrace);
            if(exception.InnerException!=null)
            {
                data += Environment.NewLine + OneLine(exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace) + Environment.NewLine;
            }
            var fileReaderWriter = new FileReaderWriter();
            fileReaderWriter.WriteFile(LogFilePath, data);
        }
Ejemplo n.º 5
0
 public static void LogProcess(string process)
 {
     if (String.IsNullOrEmpty(process)) return;
     var fileReaderWriter = new FileReaderWriter();
     fileReaderWriter.WriteFile(LogFilePath, OneLine(process));
 }