Exemplo n.º 1
0
        public void ConvertSesionToXML(Sesions sesion, StringWriter stream)
        {
            IRepository repository = new Repository(SessionFactoryProvider);
            XmlWriterSettings setings = new XmlWriterSettings();
            setings.Indent = true;
            setings.IndentChars = "    ";
            using (XmlWriter writer = XmlWriter.Create(stream, setings)) {
                writer.WriteStartDocument();
                writer.WriteStartElement("Sesion");
                writer.WriteElementString("StatupTime", sesion.CreationTime.ToString());
                writer.WriteStartElement("URLs");

                List<URLs> q1 = (from url in repository.AsQueryable<URLs>() where url.sesion == sesion select url).ToList<URLs>();
                foreach (URLs url in q1) {
                    writer.WriteStartElement("URL");
                    writer.WriteElementString("url", url.url.ToString());
                    writer.WriteStartElement("Responses");
                    List<Responses> q2 = (from response in repository.AsQueryable<Responses>() where response.URL == url select response).ToList<Responses>();
                    foreach (Responses response in q2) {
                        writer.WriteStartElement("Response");
                        var q3 = (from code in repository.AsQueryable<ResponseCodes>() where code == response.ResponseCode select code.ResponseCode).Single();
                        writer.WriteElementString("ResponseCode", q3.ToString());
                        writer.WriteElementString("RequestTime", response.RequestStartTime.ToLongTimeString() + ":" + response.RequestStartTime.Millisecond);
                        writer.WriteElementString("ResponseTime", response.ResponseTime.ToString());
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
Exemplo n.º 2
0
        private static void CreateUrl()
        {
            IRepository repository = new Repository(SessionFactoryProvider);
            var q = (from code in repository.AsQueryable<ResponseCodes>() where code.ResponseCode == 501 select code).Single();

            using (var transaction = new TransactionScope()){
            var ses = new Sesions {
                ExecutionTime = 4525,
                CreationTime = DateTime.Now,
                userIP = "asad"
            };
            repository.Save(ses);
            var url = new URLs {
                url = new Uri("http://www.google.lt"),
                sesion = ses,
            };
            repository.Save(url);
            var response = new Responses {
                ResponseTime = 12345,
                URL = url,
                ResponseCode = q,
                RequestStartTime = DateTime.Now
            };
            repository.Save(response);
            repository.Commit();
            transaction.Complete();
            }
            Sesions q2 = (from ses in repository.AsQueryable<Sesions>() where ses.userIP == "asad" select ses).Single();
            //ISesionToXML s2x = new SesionToXML();
            //s2x.ConvertSesionToXML(q2, "C:/hugas.xml");
        }
Exemplo n.º 3
0
 public ProgramManager(Uri uri, Sesions sesion)
 {
     responsesGotten = 0;
     url = new URLs();
     url.sesion = sesion;
     url.url = uri;
     IRepository repository = new Repository(SessionFactoryProvider);
     repository.Save(url);
     repository.Commit();
 }