Esempio n. 1
0
        private void FilterAdvandedStart_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AcynsUser1 TexTo = new AcynsUser1();
                Dictionary <string, dynamic> mapEx = new Dictionary <string, dynamic>();
                string        path1                 = appPath + @"\LuuFile" + strfile + "]ex.tex";
                List <string> listend               = new List <string>();
                List <SortId> listcodeId            = new List <SortId>();
                DataGridCollectionViewSource source = GridTotal.FindResource("cvsDataGrid") as DataGridCollectionViewSource;
                foreach (var item in DataGrid.Items)
                {
                    DataGrid.CurrentItem = item;
                    Xceed.Wpf.DataGrid.DataRow row = DataGrid.GetContainerFromItem(DataGrid.CurrentItem) as Xceed.Wpf.DataGrid.DataRow;
                    if (row != null)
                    {
                        int    numberExerciseselect = 0;
                        string codeId = row.Cells[0].Content.ToString();
                        var    itit   = row.Cells[3].Content;
                        if (row.Cells[2].Content != null)
                        {
                            numberExerciseselect = (int)row.Cells[3].Content;
                        }
                        int numberExercise = (int)row.Cells[2].Content;
                        if (numberExerciseselect > numberExercise)
                        {
                            listend = null;
                            break;
                        }
                        else
                        {
                            bool isCheck = (bool)row.Cells[4].Content;
                            if (isCheck == true && numberExerciseselect > 0)
                            {
                                List <string> list      = new List <string>();
                                List <string> listItem  = Dic[codeId];
                                int           itemCount = listItem.Count;
                                Random        random    = new Random();
                                if (sortoder.IsChecked == false)
                                {
                                    for (int i = 0; i < numberExerciseselect; i++)
                                    {
                                        list.Add(listItem[random.Next(0, itemCount)]);
                                    }
                                    listend.AddRange(list);
                                }
                                else
                                {
                                    for (int i = 0; i < numberExerciseselect; i++)
                                    {
                                        list.Add(listItem[random.Next(0, itemCount)]);
                                    }
                                    mapEx.Add(codeId, list);
                                }
                            }
                        }
                    }
                }

                if (sortoder.IsChecked == true)
                {
                    List <SortId> listsort = Dic["listid"];
                    if (Sort1.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ThenBy(m => m.LevelId).ToList <SortId>();
                    }
                    if (Sort2.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.ObjectId).ThenBy(m => m.ClassId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ThenBy(m => m.LevelId).ToList <SortId>();
                    }
                    if (Sort3.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.LevelId).ThenBy(m => m.SectionId).ToList <SortId>();
                    }
                    if (Sort4.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.LevelId).ThenBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ToList <SortId>();
                    }
                    foreach (SortId item in listsort)
                    {
                        string codeId = item.CodeId;
                        if (mapEx.ContainsKey(codeId))
                        {
                            List <string> list = mapEx[codeId];
                            listend.AddRange(list);
                            listcodeId.Add(item);
                        }
                    }
                }
                mapEx.Add("listid", listcodeId);
                string strHeader = "";
                string strFooter = "";
                if (Form.IsChecked == true)
                {
                    strHeader = File.ReadAllText(fileForm.Text);
                    string FooterPath = app + @"\MauFile\Footer.tex";
                    strFooter = File.ReadAllText(FooterPath);
                }
                if (listend != null && listend.Count > 0 && DevideFile.IsChecked == true)
                {
                    TexTo.DevideFile2("ex", mapEx, appPath, strHeader, strFooter, Boxbt.IsChecked, AutoWord.IsChecked, Devide1.IsChecked, Devide2.IsChecked, Devide3.IsChecked, Devide4.IsChecked);
                }
                if (listend != null && listend.Count > 0)
                {
                    if (commentorder.IsChecked == true)
                    {
                        User1Before classBefore = new User1Before();
                        listend = classBefore.CommentOrder(listend);
                    }
                    if (Boxex.IsChecked == true)
                    {
                        string pathnew = appPath + @"\LuuFile[" + strfile + "]ex.tex";
                        classlist.newFileTex(listend, pathnew, strHeader, strFooter);
                        FileTexEx.Text = path1;
                        NumberEx.Text  = listend.Count.ToString();
                        if (AutoWord.IsChecked == true)
                        {
                            List <string> listExNew = new List <string>();
                            foreach (string item in listend)
                            {
                                string itemnew = "e" + item.Remove(item.Length - 8, 8).Remove(0, 11);
                                listExNew.Add(itemnew);
                            }
                            string path2nem = appPath + @"\LuuFile[" + strfile + "]ex";
                            if (DevideFile.IsChecked == false)
                            {
                                TexTo.startListTexToWord1(listExNew, path2nem);
                            }
                        }
                    }
                    System.Windows.Forms.MessageBoxEx.Show("Các chức năng BankEx sẽ ko sử dụng khi lọc nâng cao,chức năng tách file, tex to word sẽ chạy bất đồng bộ, các file sẽ được lưu trong folder lọc file hoặc folder LuuFile,sẽ có thông báo khi thành công", 4000);
                }
                else
                {
                    System.Windows.MessageBox.Show("Tạo file không thành công", "Thoát");
                }
            }
            catch (Exception a)
            {
                System.Windows.MessageBox.Show(a.Message, "Thoát");
            }
        }
Esempio n. 2
0
 private void FilterBasic_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (System.Windows.MessageBox.Show("Tiến hành lọc Id", "Xác nhận lọc Id", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             AcynsUser1 TexTo = new AcynsUser1();
             Dic = new Dictionary <string, dynamic>();
             string str  = "";
             string type = "ex";
             if (Boxbt.IsChecked == true)
             {
                 type = "bt";
             }
             ;
             List <string> listex    = new List <string>();
             List <string> listregex = CreatRegex();
             str     = listregex[0];
             strfile = listregex[1];
             Regex rx = new Regex(str);
             if (BankExcer.IsChecked == true)
             {
                 AcynsUser1 bank = new AcynsUser1();
                 bank.BankEcer(app, selectId5.IsChecked, selectId6.IsChecked, listPath, rx, type);
             }
             Dictionary <string, dynamic> mapEx = new Dictionary <string, dynamic>();
             List <dynamic> listMapEx           = classlist.mapNewFile(rx, type, listPath);
             string         strHeader           = "";
             string         strFooter           = "";
             if (Form.IsChecked == true)
             {
                 strHeader = File.ReadAllText(fileForm.Text);
                 string FooterPath = app + @"\MauFile\Footer.tex";
                 strFooter = File.ReadAllText(FooterPath);
             }
             if (sortoder.IsChecked == true)
             {
                 mapEx = classlist.mapSort(listMapEx, type);
                 List <SortId> listsort = mapEx["listid"];
                 if (Sort1.IsChecked == true)
                 {
                     listsort = listsort.OrderBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ThenBy(m => m.LevelId).ToList <SortId>();
                 }
                 if (Sort2.IsChecked == true)
                 {
                     listsort = listsort.OrderBy(m => m.ObjectId).ThenBy(m => m.ClassId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ThenBy(m => m.LevelId).ToList <SortId>();
                 }
                 if (Sort3.IsChecked == true)
                 {
                     listsort = listsort.OrderBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.LevelId).ThenBy(m => m.SectionId).ToList <SortId>();
                 }
                 if (Sort4.IsChecked == true)
                 {
                     listsort = listsort.OrderBy(m => m.LevelId).ThenBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ToList <SortId>();
                 }
                 foreach (SortId item in listsort)
                 {
                     string        codeId = item.CodeId;
                     List <string> list   = mapEx[codeId];
                     listex.AddRange(list);
                 }
             }
             else
             {
                 foreach (Dictionary <string, string> item in listMapEx)
                 {
                     string strthu = item["exersice"];
                     listex.Add(strthu);
                 }
             }
             if (DevideFile.IsChecked == true)
             {
                 TexTo.DevideFile(type, listMapEx, appPath, strHeader, strFooter, Boxbt.IsChecked, AutoWord.IsChecked, Devide1.IsChecked, Devide2.IsChecked, Devide3.IsChecked, Devide4.IsChecked);
             }
             if (listex != null && listex.Count > 0)
             {
                 if (commentorder.IsChecked == true)
                 {
                     User1Before classBefore = new User1Before();
                     listex = classBefore.CommentOrder(listex);
                 }
                 ;
                 string path1 = appPath + @"\LuuFile[" + strfile + "]" + type + ".tex";
                 classlist.newFileTex(listex, path1, strHeader, strFooter);
                 FileTexEx.Text = path1; NumberEx.Text = listex.Count.ToString();
                 if (AutoWord.IsChecked == true)
                 {
                     List <string> listExNew = new List <string>();
                     char          typechar  = 'e';
                     if (Boxbt.IsChecked == true)
                     {
                         typechar = 'b';
                     }
                     foreach (string item in listex)
                     {
                         string itemnew = typechar + item.Remove(item.Length - 8, 8).Remove(0, 11);
                         listExNew.Add(itemnew);
                     }
                     string pathnem = appPath + @"\LuuFile[" + strfile + "]" + type;
                     if (DevideFile.IsChecked == false)
                     {
                         TexTo.startListTexToWord1(listExNew, pathnem);
                     }
                 }
                 else
                 {
                 }
                 System.Windows.Forms.MessageBoxEx.Show("Các chức năng BankEx, tách file, tex to word sẽ chạy bất đồng bộ, các file sẽ được lưu trong folder lọc file hoặc folder LuuFile, sẽ có thông báo khi thành công", 4000);
             }
             else
             {
                 System.Windows.MessageBox.Show("Tạo file không thành công", "Thoát");
             }
         }
     }
     catch (Exception a)
     {
         System.Windows.MessageBox.Show(a.Message, "Thoát");
     }
 }