Пример #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!allowUserInteraction) return;
            allowUserInteraction = false;
            try
            {
                List<SaveColorObjectModel> saveColorOfferedCourses;
                List<SaveColorObjectModel> saveColorOfferedCourseRows;

                saveColorOfferedCourses = new List<SaveColorObjectModel>();
                saveColorOfferedCourseRows = new List<SaveColorObjectModel>();

                offeredCourses.ForEach(oc =>
                {
                    saveColorOfferedCourses.Add(new SaveColorObjectModel { CorrespondingIdInSourceList = oc.CourseId, Color = oc.Color });
                });
                offeredCourseRows.ForEach(ocr =>
                {
                    saveColorOfferedCourseRows.Add(new SaveColorObjectModel { CorrespondingIdInSourceList = ocr.RowId, Color = ocr.Color });
                });

                FileServiceProvider.SerializeToXmlFile(DirectoryManager.ReductionStep2SavedStatus + DirectoryManager.SaveColorOfferedCourses, saveColorOfferedCourses);
                FileServiceProvider.SerializeToXmlFile(DirectoryManager.ReductionStep2SavedStatus + DirectoryManager.SaveColorOfferedCourseRows, saveColorOfferedCourseRows);

                Properties.Settings.Default.ReductionStep2MustBeLoad = true;
                Properties.Settings.Default.Save();
            }
            catch
            {

            }

            allowUserInteraction = true;
        }
Пример #2
0
        private async void btnRunAlgorithm_Click(object sender, RoutedEventArgs e)
        {

            btnRunAlgorithm.IsEnabled = false;
            if (!allowUserInteraction) return;
            allowUserInteraction = false;

            try
            {


                AnimateStatusObjectModel model = new AnimateStatusObjectModel();

                Infrastructures.Algorithm.MainAlgorithm mainAlgorithm = new Infrastructures.Algorithm.MainAlgorithm(maxCntSuggestion);

                Task.Run(() => { mainAlgorithm.Run(offeredCourses, mainCurriculum, minUnits, maxUnits, exampCollideChecking, Properties.Settings.Default.AlgorithmMaxProcessingTimeMS, model); });


                await AlgorithmAnimation.Animate(this, canvasAlgorithmMsg, Properties.Settings.Default.AlgorithmAnimationEffectStatus, model);

                Directory.EnumerateFiles(DirectoryManager.LastAlgorithmExeOutputs).ToList().ForEach(c =>
                {
                    File.Delete(c);
                });

                mainAlgorithm.ChoosedWeeklyProgram.Sort();
                for (int i = 0; i < mainAlgorithm.ChoosedWeeklyProgram.Count; i++)
                {
                    var p = mainAlgorithm.ChoosedWeeklyProgram[i];

                    OfferedWeeklyProgram newProgram = new OfferedWeeklyProgram();
                    newProgram.DataSource = new List<GoalVersionOfferedCoursesRow>();
                    int units = 0;
                    DfsTopologicalSortAlgorithm.DfsTopologicalSort(p.WeeklyProgram.Columns).ForEach(c =>
                    {
                        newProgram.DataSource.Add(c.GoalVersionOfferedCourseRow);
                        units += c.OfferedCourse.Course.Units;
                    });
                    newProgram.Description = "";
                    newProgram.NumberOfUnits = units;
                    newProgram.UserScore = 0;
                    newProgram.TermNumber = termNumber;
                    newProgram.Score = p.WeeklyProgramScore;

                    string name = Guid.NewGuid().ToString();
                    FileServiceProvider.SerializeToXmlFile(DirectoryManager.LastAlgorithmExeOutputs + name + ".xml", newProgram);
                    Thread.Sleep(10);
                }
            }
            catch { }

            allowUserInteraction = true;
            btnRunAlgorithm.IsEnabled = true;
        }
Пример #3
0
        private void LoadData(string titleBar, Tuple <string, int>[] arr, RoutedEventHandler method, Visibility btnNextVisibility, Visibility btnPrevVisibility)
        {
            try
            {
                CreditDeterminer creditDeterminer = null;
                if (File.Exists(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CreditDeterminerSavedName))
                {
                    FileServiceProvider.DeserializeFromXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CreditDeterminerSavedName, out creditDeterminer);
                }
                else
                {
                    creditDeterminer = new CreditDeterminer
                    {
                        Level1 = CurriculumWpfClientMiddleware.DefaultLevel1Value,
                        Level2 = CurriculumWpfClientMiddleware.DefaultLevel2Value,
                    };
                    FileServiceProvider.SerializeToXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CreditDeterminerSavedName, creditDeterminer);
                }

                wrapPanelList.Children.Clear();
                txtblockTitleBar.Text = titleBar;

                for (int i = 0; i < arr.Length; i++)
                {
                    Badged badged = new Badged();
                    badged.Badge  = (i + 1).ToString();
                    badged.Margin = new Thickness(15);
                    badged.Name   = "bdg" + arr[i].Item2;

                    Button button = new Button();
                    button.Content = arr[i].Item1;
                    button.Name    = "btn" + arr[i].Item2;

                    if (creditDeterminer.Level1 == arr[i].Item2 || creditDeterminer.Level2 == arr[i].Item2)
                    {
                        button.SetResourceReference(Button.BackgroundProperty, "PrimaryHueMidBrush");
                    }
                    else
                    {
                        button.Background = Brushes.Transparent;
                    }


                    button.Click  += method;
                    badged.Content = button;

                    wrapPanelList.Children.Add(badged);
                }

                btnNext.Visibility = btnNextVisibility;
                btnPrev.Visibility = btnPrevVisibility;
            }
            catch { }
        }
Пример #4
0
        private async void btnOk_Click(object sender, RoutedEventArgs e)
        {
            btnOk.IsEnabled = false;
            await Task.Run(() => {
                CourseInformation[] cfs;
                try
                {
                    FileServiceProvider.DeserializeFromXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName, out cfs);

                    for (int i = 0; i < collection.Count; i++)
                    {
                        var c = cfs[collection[i].Id];
                        if (collection[i].StatusColor == WpfApplicationUtilityClasses.Enums.StudentHistoryGridRowColors.WHITE)
                        {
                            c.IsPassed       = false;
                            c.NumberOfFailed = 0;
                        }
                        else if (collection[i].StatusColor == WpfApplicationUtilityClasses.Enums.StudentHistoryGridRowColors.GREEN)
                        {
                            c.IsPassed = true;
                        }
                        else if (collection[i].StatusColor == WpfApplicationUtilityClasses.Enums.StudentHistoryGridRowColors.YELLOW)
                        {
                            c.IsPassed       = false;
                            c.NumberOfFailed = 2;
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }

                    FileServiceProvider.SerializeToXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName, cfs);

                    Properties.Settings.Default.ReductionStep2MustBeLoad = false;
                    Properties.Settings.Default.Save();

                    Dispatcher.Invoke(() => {
                        MessageBox.Show("تغییرات با موفقیت اعمال شد");
                    });
                }
                catch
                {
                    Dispatcher.Invoke(() => {
                        MessageBox.Show("عدم موفقیت");
                    });
                }
            });

            btnOk.IsEnabled = true;
        }
Пример #5
0
 public async Task RunAfterCreateAsync()
 {
     try
     {
         await Task.Run(() =>
         {
             CourseInformation[] cfs = null;
             if (!File.Exists(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName))
             {
                 CreateCourseInformationArrayAndFillItWithAppropriateData(out cfs);
                 FileServiceProvider.SerializeToXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName, cfs);
             }
             else
             {
                 FileServiceProvider.DeserializeFromXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName, out cfs);
             }
             RiFillDataGrid(cfs);
         });
     }
     catch { }
 }
Пример #6
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CourseInformation[] cfs;

                if (File.Exists(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName))
                {
                    FileServiceProvider.DeserializeFromXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName, out cfs);
                }
                else
                {
                    CreateCourseInformationArrayAndFillItWithAppropriateData(out cfs);
                }

                for (int i = 0; i < cfs.Length; i++)
                {
                    var current = cfs[i];

                    if (current.CorrespondingTitleInDesUni != collection[current.Id].TitleInDesUni)
                    {
                        current.CorrespondingTitleInDesUni = collection[current.Id].TitleInDesUni;
                    }

                    if (current.CodeInDesUni != collection[current.Id].CodeInDesUni)
                    {
                        current.CodeInDesUni = collection[current.Id].CodeInDesUni.ChangeFarsiNumberInStringToEnglishNumber();
                    }
                }

                FileServiceProvider.SerializeToXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CourseInformationSavedName, cfs);

                Properties.Settings.Default.ReductionStep2MustBeLoad = false;
                Properties.Settings.Default.Save();

                MessageBox.Show("تغییرات با موفقیت اعمال شد");
            }
            catch { }
        }
Пример #7
0
        private void UpdateCreditDeterminerFile(Button sender)
        {
            try
            {
                if (File.Exists(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CreditDeterminerSavedName))
                {
                    CreditDeterminer creditDeterminer;
                    FileServiceProvider.DeserializeFromXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CreditDeterminerSavedName, out creditDeterminer);

                    if (stateLevel1 == txtblockTitleBar.Text)
                    {
                        int x = int.Parse(sender.Name.Substring(3));

                        if (creditDeterminer.Level1 != x)
                        {
                            creditDeterminer.Level1 = x;

                            creditDeterminer.Level2 = CurriculumWpfClientMiddleware.DefaultLevel2Value;
                        }
                    }
                    else if (stateLevel2 == txtblockTitleBar.Text)
                    {
                        creditDeterminer.Level2 = int.Parse(sender.Name.Substring(3));
                    }
                    else
                    {
                        throw new Exception();
                    }

                    FileServiceProvider.SerializeToXmlFile(DirectoryManager.EssentialInforamtion1Directory + DirectoryManager.CreditDeterminerSavedName, creditDeterminer);

                    Properties.Settings.Default.ReductionStep2MustBeLoad = false;
                    Properties.Settings.Default.Save();
                }
            }
            catch { }
        }
Пример #8
0
        private async void btnGenerateGoalVersionXmlFile_Click(object sender, RoutedEventArgs e)
        {
            string red   = "#f0513c";
            string green = "#5c9444";

            //specify appropriate color for user notification
            string color = red;

            try
            {
                //if 'files' does not have any items , no need to start the proccess
                if (files.Count == 0)
                {
                    throw new Exception();
                }

                //disable button before the start of the process to prevent user from the requesting again.
                btnGenerateGoalVersionXmlFile.IsEnabled = false;

                await Task.Run(() =>
                {
                    //create an empty list 'lst' that represents goal version object that must be generated and then saved.
                    List <GoalVersionOfferedCoursesRow> lst = new List <GoalVersionOfferedCoursesRow>();

                    if (!Directory.Exists(DirectoryManager.GoalVersionOfferedCoursesRowDirectory))
                    {
                        Directory.CreateDirectory(DirectoryManager.GoalVersionOfferedCoursesRowDirectory);
                    }

                    //for every selected files (droped files) insert items where item's id does not exist in the 'lst'.
                    files.ForEach(f =>
                    {
                        //create object model from the specific file 'f' to insert it's items.
                        var glst = FileServiceProvider.ConvertFromOfferedCoursesBasicFormToGoalVersionXmlFormat(f, DirectoryManager.GoalVersionOfferedCoursesRowDirectory + DirectoryManager.GoalVersionOfferedCoursesRowSavedName, false);

                        #region Add Distinct

                        //add 'glst' items in the 'lst' list where its 'id' does not exist in the 'lst'.

                        for (int i = 0; i < glst.Count; i++)
                        {
                            var p     = glst[i];
                            bool find = false;
                            for (int j = 0; j < lst.Count; j++)
                            {
                                var q = lst[j];
                                if (p.Id == q.Id)
                                {
                                    find = true;
                                    break;
                                }
                            }
                            if (!find)
                            {
                                lst.Add(p);
                            }
                        }

                        #endregion
                    });

                    //save goal version generated in appropriate directory with the specific name.
                    FileServiceProvider.SerializeToXmlFile(DirectoryManager.GoalVersionOfferedCoursesRowDirectory + DirectoryManager.GoalVersionOfferedCoursesRowSavedName, lst);

                    Properties.Settings.Default.ReductionStep2MustBeLoad = false;
                    Properties.Settings.Default.Save();

                    //specify appropriate color for user notification
                    color = green;
                });
            }
            catch
            {
                //set null to notify user that 'files' does not have any items.
                color = null;
            }
            finally
            {
                //set the background color to notify user about result of the proccess that completed.
                SetBackgroundColor(color);

                //remove all of the 'files' items for the next 'drag and drop'.
                files.Clear();

                //enable button after the proccess finished.
                btnGenerateGoalVersionXmlFile.IsEnabled = true;
            }
        }