private void btLoadTask_Click(object sender, EventArgs e) { ///*Load and test cutting class*/ OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Ajouter fichier découpeur"; ofd.Filter = "Class files (.cs)|*.cs"; ofd.InitialDirectory = Environment.CurrentDirectory; OpenFileDialog ofd2 = new OpenFileDialog(); ofd2.Title = "Ajouter fichier de calcul"; ofd2.Filter = "Class files (.cs)|*.cs"; ofd2.InitialDirectory = Environment.CurrentDirectory; if (ofd.ShowDialog() == DialogResult.OK) //File selected? { string tmpCuttingClass = ofd.FileName; if (ofd2.ShowDialog() == DialogResult.OK) //File selected? { string tmpCalculatorClass = ofd2.FileName; Cutting c = new Cutting(); Calculation calc = new Calculation(); bool cuttingClassCompilable = c.LoadSource(File.ReadAllText(tmpCuttingClass)); bool calculateClassCompilable = calc.LoadSource(File.ReadAllText(tmpCalculatorClass)); if (cuttingClassCompilable) //Compilable class? { if (calculateClassCompilable) //Compilable class? { cuttingClass = tmpCuttingClass; calculatorClass = tmpCalculatorClass; enableButtons(); //Enable all buttons } else { listBoxWorkInfo.Items.Add(string.Format("La classe {0} ne respecte pas les conditions requises", ofd2.SafeFileName)); } } else { listBoxWorkInfo.Items.Add(string.Format("La classe {0} ne respecte pas les conditions requises", ofd.SafeFileName)); } } else { listBoxWorkInfo.Items.Add("Please load a calcul file"); } } else { listBoxWorkInfo.Items.Add("Please load a cutting file"); } }
/// <summary> /// Start the distribution of the task /// </summary> public void initDistributedWork(bool savePacketsToFile) { this.savePacketsToFile = savePacketsToFile; if (issueNumber < int.MaxValue) //Max? { issueNumber++; } else { issueNumber = 0; } addIssueNumberToFile(); /*Launch timer to display time remaining*/ timer = new System.Windows.Forms.Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = 1000; timer.Start(); /*New scan of clients*/ //startServer(); //listClient.Clear(); SortedList <string, Client> tmpListClient = new SortedList <string, Client>(listClient); foreach (string item in tmpListClient.Keys) { listClient[item].currentWork.Clear(); listClient[item].interval = 7000; } RemoveFilesFromFolder.Remove(Environment.CurrentDirectory + "\\" + "tmp"); //Remove previous temporary data listResults.Clear(); /*Create a task cut with class file*/ Cutting cutting = new Cutting(); cutting.LoadSource(File.ReadAllText(cuttingClass)); /*Cut task on x packets*/ cuttedTask = cutting.CuttingTask(nbrPacket); dataWork = new DataWork(cuttedTask); listClient = new SortedList <string, Client>(sendFirstWorkAllClient(listClient)); fractale = new Fractal(); }
private void btLoadTask_Click(object sender, EventArgs e) { ///*Load and test cutting class*/ OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Ajouter fichier découpeur"; ofd.Filter = "Class files (.cs)|*.cs"; ofd.InitialDirectory = Environment.CurrentDirectory; OpenFileDialog ofd2 = new OpenFileDialog(); ofd2.Title = "Ajouter fichier de calcul"; ofd2.Filter = "Class files (.cs)|*.cs"; ofd2.InitialDirectory = Environment.CurrentDirectory; if (ofd.ShowDialog() == DialogResult.OK) //File selected? { string tmpCuttingClass = ofd.FileName; if (ofd2.ShowDialog() == DialogResult.OK) //File selected? { string tmpCalculatorClass = ofd2.FileName; Cutting c = new Cutting(); Calculation calc = new Calculation(); bool cuttingClassCompilable = c.LoadSource(File.ReadAllText(tmpCuttingClass)); bool calculateClassCompilable = calc.LoadSource(File.ReadAllText(tmpCalculatorClass)); if (cuttingClassCompilable) //Compilable class? { if (calculateClassCompilable) //Compilable class? { cuttingClass = tmpCuttingClass; calculatorClass = tmpCalculatorClass; enableButtons(); //Enable all buttons } else listBoxWorkInfo.Items.Add(string.Format("La classe {0} ne respecte pas les conditions requises", ofd2.SafeFileName)); } else listBoxWorkInfo.Items.Add(string.Format("La classe {0} ne respecte pas les conditions requises", ofd.SafeFileName)); } else { listBoxWorkInfo.Items.Add("Please load a calcul file"); } } else { listBoxWorkInfo.Items.Add("Please load a cutting file"); } }
/// <summary> /// Start the distribution of the task /// </summary> public void initDistributedWork(bool savePacketsToFile) { this.savePacketsToFile = savePacketsToFile; if (issueNumber < int.MaxValue) //Max? issueNumber++; else { issueNumber = 0; } addIssueNumberToFile(); /*Launch timer to display time remaining*/ timer = new System.Windows.Forms.Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = 1000; timer.Start(); /*New scan of clients*/ //startServer(); //listClient.Clear(); SortedList<string, Client> tmpListClient = new SortedList<string, Client>(listClient); foreach (string item in tmpListClient.Keys) { listClient[item].currentWork.Clear(); listClient[item].interval = 7000; } RemoveFilesFromFolder.Remove(Environment.CurrentDirectory + "\\" + "tmp"); //Remove previous temporary data listResults.Clear(); /*Create a task cut with class file*/ Cutting cutting = new Cutting(); cutting.LoadSource(File.ReadAllText(cuttingClass)); /*Cut task on x packets*/ cuttedTask = cutting.CuttingTask(nbrPacket); dataWork = new DataWork(cuttedTask); listClient = new SortedList<string, Client>(sendFirstWorkAllClient(listClient)); fractale = new Fractal(); }