Ejemplo n.º 1
0
        private async Task BalanceNamesAsync(List <string> namesList)
        {
            await Task.Factory.StartNew(() =>
            {
                foreach (string CurAddedName in namesList)//(int index = 0; index < NamesList.Length; index++)
                {
                    UserInfo CurUser = new UserInfo();

                    //gcCounter = gcCounter + 1;

                    string finalCurAddedName = CurAddedName.Trim();

                    if (finalCurAddedName.Contains("'"))
                    {
                        finalCurAddedName = finalCurAddedName.Replace("'", "");
                    }

                    if (finalCurAddedName.Contains("-"))
                    {
                        finalCurAddedName = finalCurAddedName.Replace("-", "");
                    }

                    finalCurAddedName = mCalc.ChangeFinalChars(finalCurAddedName);

                    if (rbtnFamily.Checked == false)        // Private Names Testings
                    {
                        if (cbAddOrReplace.Checked == true) // add a first name
                        {
                            string fName       = OriginalUser.mFirstName;
                            CurUser.mFirstName = fName + finalCurAddedName;
                        }
                        else// replace a first name
                        {
                            CurUser.mFirstName = finalCurAddedName;
                        }
                    }
                    else // Last Names Testings
                    {
                        string fName = OriginalUser.mFirstName;

                        if (cbAddOrReplace.Checked == true) // add a family name
                        {
                            CurUser.mLastName = fName + finalCurAddedName;
                        }
                        else// replace family name
                        {
                            CurUser.mLastName = finalCurAddedName;
                        }
                    }

                    //UpdateMainForm(CurUser);
                    CurUser.ApplyUserInfo2ProgData(mParentForm);

                    //RunProgram();

                    ChakraResult curRes = CollectResults(CurAddedName);
                    if (isFilterPassed(curRes))
                    {
                        chkrResList.Add(curRes);
                    }

                    //if (gcCounter > 5)
                    //{
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.WaitForFullGCComplete();

                    //gcCounter = 0;
                    //}
                }
            });
        }
Ejemplo n.º 2
0
        private async void btnCalc_Click(object sender, EventArgs e)
        {
            if (groupBox7.Visible && !cbIndepended.Checked && !cbIndependedFuture.Checked && !cbEmployee.Checked)
            {
                string s1 = "", s2 = "";
                if (BLL.AppSettings.Instance.ProgramLanguage == AppSettings.Language.Hebrew)
                {
                    s1 = "חובה לסמן את 1 או יותר משלושת השדות הראשונים";
                    s2 = "נתונים חסרים : ";
                }
                if (BLL.AppSettings.Instance.ProgramLanguage == AppSettings.Language.English)
                {
                    s1 = "You must mark 1 or more of the first three fields";
                    s2 = "Missing data...";
                }
                MessageBox.Show(s2 + System.Environment.NewLine + s1, "טעות הכנסת נתונים", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                OriginalUser = new UserInfo();

                bool repres = OriginalUser.ProgData2UserInfo(mParentForm);

                chkrResList.Clear();

                UserInfo CurUser = new UserInfo();

                #region Duplicate

                CurUser = OriginalUser;

                #endregion Duplicate

                string fName = OriginalUser.mFirstName;
                string lName = OriginalUser.mLastName;

                #region GetNames

                string sFilePath = mParentForm.AppMainDir + "\\Names";
                if (AppSettings.Instance.ProgramLanguage == AppSettings.Language.Hebrew)
                {
                    if (rbtnFamily.Checked == true)
                    {
                        sFilePath += "\\Heb_JusidhLastNames";
                    }
                    else
                    {
                        if (rbtnJuish.Checked == true)
                        {
                            sFilePath += "\\Juish";
                        }
                        if (rbtnJuishBible.Checked == true)
                        {
                            sFilePath += "\\JuishBible";
                        }
                        if (rbtnArab.Checked == true)
                        {
                            sFilePath += "\\Arab";
                        }
                        if (rbtnMale.Checked == true)
                        {
                            sFilePath += "Male";
                        }
                        else
                        {
                            sFilePath += "Female";
                        }
                    }
                }

                if (AppSettings.Instance.ProgramLanguage == AppSettings.Language.English)
                {
                    // only male / female / family
                    sFilePath += "\\Eng_";
                    if (rbtnMale.Checked == true)
                    {
                        sFilePath += "MaleNames";
                    }
                    if (rbtnFemale.Checked == true)
                    {
                        sFilePath += "FemaleNames";
                    }
                    if (rbtnFamily.Checked == true)
                    {
                        sFilePath += "LastNames";
                    }
                }

                sFilePath += ".txt";

                #endregion

                List <string> NamesList = ReadNamesFile(sFilePath);

                //MessageBox.Show($"Not Implemented Yet !", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                //return;

                // await BalanceNamesAsync(NamesList);

                //int iii = 0;
                foreach (string CurAddedName in NamesList)//(int index = 0; index < NamesList.Length; index++)
                {
                    //gcCounter = gcCounter + 1;

                    string finalCurAddedName = CurAddedName.Trim();

                    if (finalCurAddedName.Contains("'"))
                    {
                        finalCurAddedName = finalCurAddedName.Replace("'", "");
                    }

                    if (finalCurAddedName.Contains("-"))
                    {
                        finalCurAddedName = finalCurAddedName.Replace("-", "");
                    }

                    finalCurAddedName = mCalc.ChangeFinalChars(finalCurAddedName);

                    if (rbtnFamily.Checked == false)        // Private Names Testings
                    {
                        if (cbAddOrReplace.Checked == true) // add a first name
                        {
                            CurUser.mFirstName = fName + finalCurAddedName;
                        }
                        else// replace a first name
                        {
                            CurUser.mFirstName = finalCurAddedName;
                        }
                    }
                    else // Last Names Testings
                    {
                        if (cbAddOrReplace.Checked == true) // add a family name
                        {
                            CurUser.mLastName = lName + finalCurAddedName;
                        }
                        else// replace family name
                        {
                            CurUser.mLastName = finalCurAddedName;
                        }
                    }

                    //UpdateMainForm(CurUser);
                    CurUser.ApplyUserInfo2ProgData(mParentForm);

                    RunProgram();

                    ChakraResult curRes = CollectResults(CurAddedName);
                    if (isFilterPassed(curRes))
                    {
                        chkrResList.Add(curRes);
                    }

                    //if (gcCounter > 5)
                    //{
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.WaitForFullGCComplete();

                    //gcCounter = 0;
                    //}
                }

                dgvRes.Rows.Clear();
                dgvRes.Update();
                UpdateDataGrid();

                #region Restore Initial Value
                mParentForm.ClearForm();

                //UpdateMainForm(OriginalUser);
                OriginalUser.mFirstName = fName;
                OriginalUser.mLastName  = lName;
                repres = OriginalUser.ApplyUserInfo2ProgData(mParentForm);

                //OriginalUser.mFirstName = fName;
                //OriginalUser.ApplyUserInfo2ProgData(mParentForm);
                RunProgram();
                #endregion

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.WaitForFullGCComplete();

                if (groupBox7.Visible && rbtnFilterAdvanced.Checked)
                {
                    if (chkrResList.Count == 0 && round <= getNumberOfRound())
                    {
                        round++;
                        btnCalc.PerformClick();
                        //return;
                    }
                    else
                    {
                        MessageBox.Show("אם יש צורך צור קשר עם יעקובי", "הודעה", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }