コード例 #1
0
 public void Edit(string id, string val, string file)
 {
     if (Input.ValidateInput(val, "edit") == false)
     {
         Console.WriteLine("Values are incorrect!");
         return;
     }
     String[] arr = val.Split(';');
     if (arr[0] != id)
     {
         Console.WriteLine("You can't change id!");
         return;
     }
     for (int i = 0; i < size; i++)
     {
         if (li[i].Get("id") == id)
         {
             OnlineMeeting a = new OnlineMeeting(val);
             li[i] = a;
             RewriteFile(file);
             return;
         }
     }
     Console.WriteLine("No such id");
 }
コード例 #2
0
        public bool Compare(string param, OnlineMeeting a, OnlineMeeting b)
        {
            string x = a.Get(param);
            string y = b.Get(param);

            if (param == "owner" || param == "participant")
            {
                x = x.ToLower(new CultureInfo("en-US", false));
                y = y.ToLower(new CultureInfo("en-US", false));
                return(String.Compare(x, y) > 0);
            }
            else if (param == "start_time" || param == "end_time" || param == "date")
            {
                DateTime d  = DateTime.Parse(x);
                DateTime d1 = DateTime.Parse(y);
                return(DateTime.Compare(d, d1) > 0);
            }
            else if (param == "id")
            {
                return(Int32.Parse(x) > Int32.Parse(y));
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
        public void AddTo(string val, string file)
        {
            if (Input.ValidateInput(val, "add") == false)
            {
                Console.WriteLine("Values are incorrect!");
                return;
            }
            OnlineMeeting m = new OnlineMeeting(val);

            li.Add(m);
            size++;
            RewriteFile(file);
        }
コード例 #4
0
 public void FillCollectionFile(string file)
 {
     string[] lines = File.ReadAllLines(file);
     File.WriteAllText(file, string.Empty);
     foreach (string line in lines)
     {
         Validation v = new Validation(line);
         if (v.ValidateAll("add") == true)
         {
             using (StreamWriter sw = File.AppendText(file))
             {
                 sw.WriteLine(line);
                 OnlineMeeting obj = new OnlineMeeting(line);
                 li.Add(obj);
                 size++;
             }
         }
     }
 }
コード例 #5
0
 public void Sort(string param)
 {
     if (Sorting.fields.Contains(param) == false)
     {
         Console.WriteLine("Can't sort by this parametr");
         return;
     }
     for (int i = 0; i < size - 1; i++)
     {
         for (int j = 0; j < size - i - 1; j++)
         {
             if (Compare(param, li[j], li[j + 1]))
             {
                 OnlineMeeting tmp = li[j];
                 li[j]     = li[j + 1];
                 li[j + 1] = tmp;
             }
         }
     }
 }