Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Reflection.Emit;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace OP2_LB5_WEB
- {
- public partial class WebForm1 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Label1.Visible = false;
- Label2.Visible = false;
- Label3.Visible = false;
- Label4.Visible = false;
- if(File.Exists(Server.MapPath("Rezultatai/Rezultatai.txt")))
- {
- File.Delete(Server.MapPath("Rezultatai/Rezultatai.txt"));
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- List<EmailRegister> emailRegister = InOut.ReadEmailData(Server.MapPath("App_Data/email"));
- Session["emailRegister"] = emailRegister;
- Label1.Visible = true;
- PrintEmailData(Table1, emailRegister);
- List<Server> servers = InOut.ReadServerData(Server.MapPath("App_Data/server"));
- Session["servers"] = servers;
- Label2.Visible = true;
- PrintServerData(Table2, servers);
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- if (Session["emailRegister"] == null || Session["servers"] == null)
- {
- Label3.Visible = true;
- Label3.Text = "Pradiniai duomenys nebuvo nuskaityti";
- }
- else
- {
- try
- {
- List<EmailRegister> emailRegister = (List<EmailRegister>)Session["emailRegister"];
- List<Server> servers = (List<Server>)Session["servers"];
- InOut.PrintStartEmailData(Server.MapPath("Rezultatai/Rezultatai.txt"), "El. pašto pradiniai duomenys", emailRegister);
- InOut.PrintStartServerData(Server.MapPath("Rezultatai/Rezultatai.txt"), "Serverių pradiniai duomenys", servers);
- List <Server> filteredServer = TaskUtils.FilterServers(servers, emailRegister);
- Label3.Visible = true;
- if (filteredServer.Count > 0)
- {
- filteredServer = TaskUtils.Sort(filteredServer);
- PrintFilteredServerData(Table3, filteredServer);
- InOut.PrintFilteredServerData(Server.MapPath("Rezultatai/Rezultatai.txt"), "Rezultatai", filteredServer);
- }
- else
- {
- Label3.Text = "Nera serverių.";
- }
- }
- catch (Exception ex)
- {
- Label4.Visible = true;
- Label4.Text = ex.Message;
- StreamWriter sw = new StreamWriter(Server.MapPath("Rezultatai/Rezultatai.txt"));
- sw.WriteLine(ex.Message);
- sw.WriteLine();
- sw.Close();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement