Exemplo n.º 1
0
 public static Profile LoadSelectedProfile(this Profile profile, PData pData)
 {
     try
     {
         TicketManagement tm = new TicketManagement();
         profile = new Profile();
         string   reader = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Profiles\\" + pData.PName + ".csv");
         string[] lines  = reader.Split('\n');
         string[] pr     = null;
         foreach (var prop in lines)
         {
             if (prop == "")
             {
                 break;
             }
             pr    = prop.Split(',');
             pr[0] = pr[0].Substring(pr[0].IndexOf(':') + 1);
             tm.tickets.Add(new Ticket(int.Parse(pr[0]), pr[1], bool.Parse(pr[2]), bool.Parse(pr[3])));
         }
         profile = new Profile(tm, pData.PName);
         return(profile);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 public static List <Profile> LoadAllProfile(this List <Profile> profiles)
 {
     try
     {
         profiles = new List <Profile>();
         TicketManagement tm = new TicketManagement();
         if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\Profiles"))
         {
             Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\Profiles");
         }
         string[] allProfiles = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Profiles");
         string   readFile    = null;
         string[] streamLine  = null;
         string[] rows        = null;
         string   name        = null;
         for (int i = 0; i < allProfiles.Length; i++)
         {
             if (allProfiles[i].Contains(".csv"))
             {
                 readFile   = File.ReadAllText(allProfiles[i]);
                 name       = readFile.Substring(0, readFile.IndexOf(':'));
                 readFile   = readFile.Substring(readFile.IndexOf(':') + 1);
                 streamLine = readFile.Split('\n');
                 foreach (var prop in streamLine)
                 {
                     if (prop == "")
                     {
                         break;
                     }
                     rows = prop.Split(',');
                     tm.tickets.Add(new Ticket(int.Parse(rows[0]), rows[1], bool.Parse(rows[2]), bool.Parse(rows[3])));
                 }
                 profiles.Add(new Profile(tm, name));
             }
         }
         return(profiles);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
         return(null);
     }
 }
Exemplo n.º 3
0
        public static Profile LoadFirstProfile(this Profile profile)
        {
            try
            {
                profile = new Profile();
                TicketManagement tm = new TicketManagement();
                if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\Profiles"))
                {
                    Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\Profiles");
                }
                string[] allProfile = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Profiles");
                string   readFile   = null;
                string[] streamLine = null;
                string[] rows       = null;
                string   name       = null;
                if (allProfile[0].Contains(".csv"))
                {
                    readFile   = File.ReadAllText(allProfile[0]);
                    name       = readFile.Substring(0, readFile.IndexOf(':'));
                    readFile   = readFile.Substring(readFile.IndexOf(':') + 1);
                    streamLine = readFile.Split('\n');

                    if (streamLine[0] == "")
                    {
                        return(null);
                    }
                    rows = streamLine[0].Split(',');
                    tm.tickets.Add(new Ticket(int.Parse(rows[0]), rows[1], bool.Parse(rows[2]), bool.Parse(rows[3])));
                    profile = new Profile(tm, name);
                    return(profile);
                }
                return(null);
            }
            catch (Exception)
            {
                MessageBox.Show("The \"Tickets\" folder is empty or the containing files is not readable.\n Try runing the program as administrator.");
                return(null);
            }
        }
Exemplo n.º 4
0
 public Profile(string name, int type, int length)
 {
     ProfileName = name;
     _tm         = new TicketManagement(type, length);
 }
Exemplo n.º 5
0
 /// <summary>
 /// creates a profile manager for TicketManagement type
 /// </summary>
 /// <param name="tm"></param>
 public Profile(TicketManagement tm, string name)
 {
     ProfileName = name;
     _tm         = tm;
 }
Exemplo n.º 6
0
 /// <summary>
 /// creates a profile manager for TicketManagement type
 /// </summary>
 public Profile()
 {
     _tm = new TicketManagement();
 }