Beispiel #1
0
 protected void SetResult(CyrResult Result)
 {
     txtCase1.Text = Result[1];
     txtCase2.Text = Result[2];
     txtCase3.Text = Result[3];
     txtCase4.Text = Result[4];
     txtCase5.Text = Result[5];
     txtCase6.Text = Result[6];
 }
 public static bool TryDeclinePlural(CyrPhrase decliner, string phrase, out CyrResult result)
 {
     result = DeclinePlural(decliner, phrase);
     return(result != null);
 }
 public static bool TryDecline(CyrPhrase decliner, string phrase, out CyrResult result)
 {
     return
         (TryDeclineSingular(decliner, phrase, out result) ||
          TryDeclinePlural(decliner, phrase, out result));
 }
Beispiel #4
0
        private void ConvertHeadSettings()
        {
            labelHeadWarning.Text = string.Format("{0}, проверьте, правильно ли изменены внесенные вами данные в дательном падеже!", tbUserName.Text.UppercaseFirst());

            labelHeadPosition.Text   = cbHeadPosition.Text;
            labelHeadTitle.Text      = cbHeadTitle.Text;
            labelHeadSurname.Text    = tbHeadSurname.Text;
            labelHeadName.Text       = tbHeadName.Text;
            labelHeadSecondName.Text = tbHeadSecondName.Text;

            try
            {
                SQLiteConnection conn = new SQLiteConnection(dictConnString);
                conn.Open();
                SQLiteCommand comm = conn.CreateCommand();
                comm.CommandText = "SELECT Dative FROM PositionHead WHERE Name = @Name";
                comm.Parameters.AddWithValue("@Name", cbHeadPosition.Text);
                SQLiteDataReader dr = comm.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        linkHeadPosition.Text = dr["Dative"].ToString();
                    }
                }
                else
                {
                    dr.Close();
                }
                conn.Close();
            }
            catch (SQLiteException ex)
            {
                XtraMessageBox.Show(ex.Message.ToString(), "Ошибка SQL", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                SQLiteConnection conn = new SQLiteConnection(dictConnString);
                conn.Open();
                SQLiteCommand comm = conn.CreateCommand();
                comm.CommandText = "SELECT Dative FROM Title WHERE Name = @Name";
                comm.Parameters.AddWithValue("@Name", cbHeadTitle.Text);
                SQLiteDataReader dr = comm.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        linkHeadTitle.Text = dr["Dative"].ToString();
                    }
                }
                else
                {
                    dr.Close();
                }
                conn.Close();
            }
            catch (SQLiteException ex)
            {
                XtraMessageBox.Show(ex.Message.ToString(), "Ошибка SQL", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            string    headFullName      = string.Format("{0} {1} {2}", tbHeadSurname.Text.Trim(), tbHeadName.Text.Trim(), tbHeadSecondName.Text.Trim());
            CyrResult headConvertResult = new CyrResult(convertName.Decline(headFullName, 3, 0));
            String    headDativeResult  = headConvertResult.Дательный.ToString();

            String[] splitHeadResult = headDativeResult.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            linkHeadSurname.Text    = splitHeadResult[0];
            linkHeadName.Text       = splitHeadResult[1];
            linkHeadSecondName.Text = splitHeadResult[2];
        }
Beispiel #5
0
        public ActionResult Number(string w, string a, string i)
        {
            ViewBag.Page = "Decline.Number";

            if (w.IsNullOrEmpty() || a.IsNullOrEmpty())
            {
                ViewBag.Action = "Item";
                return(View());
            }

            List <string> errors = new List <string>();
            CyrResult     result = null;
            decimal       v;

            if (decimal.TryParse(w, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture, out v))
            {
                CyrNumber      cyr = new CyrNumber();
                CyrNumber.Item item;

                switch (a)
                {
                case "Item":
                    CyrNoun noun;

                    try
                    {
                        noun = this.NounCollection.Get(i, out string fw, out CasesEnum c, out NumbersEnum n);
                    }
                    catch (CyrWordNotFoundException ex)
                    {
                        errors.Add(string.Format("Слово \"<strong>{0}</strong>\" не найдено в коллекции. Попбробуйте другое слово.", ex.Word));
                        break;
                    }

                    item   = new CyrNumber.Item(noun);
                    result = cyr.Decline(v, item);

                    if ((long)v == v)
                    {
                        string[] strings = item.GetName(CasesEnum.Nominative, (long)v);
                        ViewBag.ItemText = cyr.Case((long)v, strings[0], strings[1], strings[2]);
                    }
                    else
                    {
                        string[] strings = item.GetName(CasesEnum.Nominative, 2);
                        ViewBag.ItemText = strings[1];
                    }

                    break;

                case "Masculine":
                    result = cyr.Decline(v, Model.GendersEnum.Masculine, Model.AnimatesEnum.Inanimated);
                    break;

                case "Feminine":
                    result = cyr.Decline(v, Model.GendersEnum.Feminine, Model.AnimatesEnum.Inanimated);
                    break;

                case "Rub":
                    result = cyr.Decline(v, new CyrNumber.RurCurrency());
                    ViewBag.CurrencyClass = "fa-ruble";
                    ViewBag.CurrencyText  = "руб.";
                    break;

                case "Usd":
                    result = cyr.Decline(v, new CyrNumber.UsdCurrency());
                    ViewBag.CurrencyClass = "fa-usd";
                    ViewBag.CurrencyText  = "$";
                    break;

                case "Eur":
                    result = cyr.Decline(v, new CyrNumber.EurCurrency());
                    ViewBag.CurrencyClass = "fa-eur";
                    ViewBag.CurrencyText  = "€";
                    break;

                case "Yuan":
                    result = cyr.Decline(v, new CyrNumber.YuanCurrency());
                    ViewBag.CurrencyClass = "fa-yen";
                    ViewBag.CurrencyText  = "¥";
                    break;

                default:
                    errors.Add(string.Format("{0} не является правильной операцией!", a));
                    break;
                }
            }
            else
            {
                errors.Add(string.Format("{0} не является правильным числом!", w));
            }

            ViewBag.Item   = i;
            ViewBag.Text   = w;
            ViewBag.Action = a;
            ViewBag.Result = result;
            ViewBag.Errors = errors;
            ViewBag.Cases  = CyrDeclineCase.GetEnumerable().ToArray();

            return(View());
        }
 public DeclensionResult(CyrResult cyrResult, OriginalData originalData)
 {
     Success      = true;
     Output       = cyrResult.Get((CasesEnum)originalData.CaseEnum);
     OriginalData = originalData;
 }
Beispiel #7
0
        private void btnDecline_Click(object sender, EventArgs e)
        {
            CyrNumber number = new CyrNumber();
            CyrResult result = null;

            switch (ddlAction.SelectedIndex)
            {
            case 0:
                if (txtItem.Text.IsNullOrEmpty())
                {
                    MessageBox.Show("Необходимо ввести единицу измерения!");
                    return;
                }

                CyrNoun noun;

                try
                {
                    noun = cyrCollection.Get(txtItem.Text, Cyriller.Model.GetConditionsEnum.Similar);
                }
                catch (CyrWordNotFoundException ex)
                {
                    MessageBox.Show(string.Format("Слово {0} не найдено в коллекции!", ex.Word));
                    return;
                }

                CyrNumber.Item item = new CyrNumber.Item(noun);

                result = number.Decline(txtNumber.Value, item);

                break;

            case 1:
                result = number.Decline(txtNumber.Value);
                break;

            case 2:
                result = number.Decline(txtNumber.Value, Cyriller.Model.GendersEnum.Feminine, Cyriller.Model.AnimatesEnum.Inanimated);
                break;

            case 3:
                result = number.Decline(txtNumber.Value, new CyrNumber.RurCurrency());
                break;

            case 4:
                result = number.Decline(txtNumber.Value, new CyrNumber.UsdCurrency());
                break;

            case 5:
                result = number.Decline(txtNumber.Value, new CyrNumber.EurCurrency());
                break;

            case 6:
                result = number.Decline(txtNumber.Value, new CyrNumber.YuanCurrency());
                break;

            default:
                MessageBox.Show("Необходимо выбрать тип склонения!");
                return;
            }

            SetResult(result);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            ParserResult <Arguments> parseResult = Parser.Default.ParseArguments <Arguments>(args);

            if (parseResult.Errors.Any())
            {
                return;
            }

            Arguments arguments = parseResult.Value;

            // Создаем коллекцию всех существительных.
            CyrNounCollection nouns = new CyrNounCollection();

            // Создаем коллекцию всех прилагательных.
            CyrAdjectiveCollection adjectives = new CyrAdjectiveCollection();

            // Создаем фразу с использование созданных коллекций.
            CyrPhrase phrase = new CyrPhrase(nouns, adjectives);

            InjectionAnalyzer analyzer = new InjectionAnalyzer();

            HashSet <string> defTypes = new HashSet <string>(arguments.DefsTypes.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));

            HashSet <string> ignoredInjections = new HashSet <string>(File.ReadAllLines(arguments.IgnoreFile));

            HashSet <string> casedLabels = new HashSet <string>(File.ReadAllLines(arguments.Output).Select(line => new string(line.TakeWhile(c => c != ';').ToArray())));

            Injection[] allLabels = analyzer
                                    .ReadInjections(arguments.DefsPath)
                                    .Where(inj => defTypes.Contains(inj.DefType))
                                    .Where(inj => GetLastPart(inj).ToLowerInvariant().Contains("label"))
                                    .Distinct(new InjectionTypeTranslationComparer())
                                    .Where(inj =>
                                           !ignoredInjections.Contains(FormInjectionLine(inj)) &&
                                           !casedLabels.Contains(inj.Translation))
                                    .ToArray();

            Console.WriteLine($"Chack case forms for {allLabels.Length} labels.");

            List <Option> history = new List <Option>();

            string prevDefType = "";

            CyrResult currentDeclination = null;

            for (int labelIndex = 0; labelIndex < allLabels.Length;)
            {
                Injection injection = allLabels[labelIndex];
                string    label     = injection.Translation;

                Console.WriteLine();
                Console.WriteLine($"{labelIndex + 1}/{allLabels.Length} {injection.DefType} <{injection.DefPath}> \"{label}\":");

                if (currentDeclination == null)
                {
                    currentDeclination = DeclineIgnoreSuffix(phrase, label, " (", " из ", " для ", " с ", " в ");
                }

                if (currentDeclination == null)
                {
                    Console.WriteLine($"	Failed to decline");
                }
                else
                {
                    WriteDeclination(currentDeclination);
                }

                Console.Write("<Enter> - accept; <Space> - edit; <Backspace> - back; <Delete> - ignore");
                ConsoleKey key = Console.ReadKey().Key;
                Console.WriteLine();

                switch (key)
                {
                case ConsoleKey.Escape:
                    return;

                case ConsoleKey.Spacebar:
                    if (currentDeclination == null)
                    {
                        currentDeclination = new CyrResult(label, label, label, label, label, label);
                    }

                    ReadDeclination(currentDeclination);

                    if (injection.DefType != prevDefType)
                    {
                        FileUtil.PushLine(arguments.Output, string.Empty);
                        FileUtil.PushLine(arguments.Output, "// " + injection.DefType);
                    }
                    FileUtil.PushLine(arguments.Output, ToLine(currentDeclination));
                    currentDeclination = null;
                    history.Add(Option.Accept);
                    labelIndex++;
                    break;

                case ConsoleKey.Enter:
                    if (currentDeclination != null)
                    {
                        if (injection.DefType != prevDefType)
                        {
                            FileUtil.PushLine(arguments.Output, string.Empty);
                            FileUtil.PushLine(arguments.Output, "// " + injection.DefType);
                        }
                        FileUtil.PushLine(arguments.Output, ToLine(currentDeclination));
                        currentDeclination = null;
                        history.Add(Option.Accept);
                        labelIndex++;
                    }
                    break;

                case ConsoleKey.Delete:
                    FileUtil.PushLine(arguments.IgnoreFile, FormInjectionLine(injection));
                    currentDeclination = null;
                    history.Add(Option.Ignore);
                    labelIndex++;
                    break;

                case ConsoleKey.Backspace:
                    Option prevOption = history[labelIndex - 1];
                    history.RemoveAt(labelIndex - 1);
                    labelIndex--;

                    if (prevOption == Option.Accept)
                    {
                        string prevDeclinationLine = FileUtil.PopLine(arguments.Output);
                        currentDeclination = FromLine(prevDeclinationLine);
                    }
                    else if (prevOption == Option.Ignore)
                    {
                        FileUtil.PopLine(arguments.IgnoreFile);
                        currentDeclination = null;
                    }
                    break;

                default:
                    break;
                }

                prevDefType = injection.DefType;
            }
        }
Beispiel #9
0
        public ActionResult CreateContract(Guid callID)
        {
            var callData    = db.Calls.ToList();
            var itemsData   = db.Items.ToList();
            var custData    = db.Customers.ToList();
            var repData     = db.Representatives.ToList();
            var callDetails = db.CallDetails.ToList();
            //var progdata = db.Programs.ToList();

            var callData2 = (from c in db.CallDetails
                             join item in itemsData on c.ItemID equals item.ItemID
                             join calcdet in db.CalcDetails.ToList() on item.CalcDetailsID equals calcdet.CalcID
                             where (c.CallID == callID)
                             select new ContractViewModel.Itm {
                itemname = item.ItemName, Qty = c.ItemQty.ToString(), itemsubtype = item.ItemSubtype.ItemSubtype1, additionals = item.Additional, calcDate = calcdet.CalcDate.ToString(), calcNum = calcdet.CalcNum
            }).ToList();


            ContractViewModel contract = new ContractViewModel();

            CultureInfo ci = new CultureInfo("RU-ru");

            contract = (from cd in callData
                        join cust in custData on cd.CustomerID equals cust.CustomerID
                        join rep in repData on cust.RepresentativeID equals rep.RepresentativeID
                        join calldet in callDetails on cd.CallID equals calldet.CallID
                        join item in itemsData on calldet.ItemID equals item.ItemID

                        where (cd.CallID == (Guid)callID)
                        select new ContractViewModel {
                CallID = cd.CallID,
                callDate = cd.CallDate.ToString("dd MMMM yyyy г.", ci),
                sampleActDate = cd.SampleActDate.ToString("dd MMMM yyyy г.", ci),
                callNumber = cd.DocNumber.ToString(),
                expAffNum = cd.AffidavitNum.ToString(),
                expAffDate = cd.AffidavitDate.ToString("dd MMMM yyyy г.", ci),
                contractDate = cd.ContractDate,
                repdoc = rep.RepDoc.ToString(),
                repFName = rep.FirstName.ToString(),
                repMName = rep.MidName.ToString(),
                repFamName = rep.FamilyName.ToString(),
                repPosition = rep.Position.ToString(),
                repPhone = rep.PhoneNumber.ToString(),
                custName = cust.Name.ToString(),
                custAddress = cust.Address.ToString(),
                custTaxID = cust.TaxID.ToString(),
                custBIC = cust.BIC.ToString(),
                custPhoneNumber = cust.PhoneNumber.ToString(),
                custOKPO = cust.OKPO.ToString(),
                custAccount = cust.Account.ToString(),
                custBankBranch = cust.BankBranch.ToString(),
                custBranchAddress = cust.BranchAddress.ToString(),
                custBankCode = cust.BankCode.ToString(),
                custMPhoneNumber = cust.MPhoneNumber.ToString()
            }

                        ).FirstOrDefault();

            contract.itmList = callData2;

            ////////////////////////////////////////////////////////////////////////////////////////////////////////

            //                              ВВОД ДАННЫХ В ШАБЛОН ДОГОВОРА                                        //

            ///////////////////////////////////////////////////////////////////////////////////////////////////////


            List <string> expertData = callexp.Split(' ').Reverse().ToList();

            string expName = expertData[0] + expertData[1] + expertData[2];

            int nameIndex = callexp.IndexOf(expName);

            string expertPosition = callexp.Remove(nameIndex, expName.Length);

            string firstWordInPosition = callexp.Split(' ').First();

            int firstWordIndex = expertPosition.IndexOf(firstWordInPosition);

            string expPositionTail = expertPosition.Remove(firstWordIndex, firstWordInPosition.Length);

            CyrNounCollection      nouns = new CyrNounCollection();
            CyrAdjectiveCollection adj   = new CyrAdjectiveCollection();
            CyrPhrase phrase             = new CyrPhrase(nouns, adj);
            CyrResult expname            = phrase.Decline(expName, GetConditionsEnum.Strict);

            expName = expname.Genitive;

            CyrNoun   strict        = nouns.Get(firstWordInPosition, GetConditionsEnum.Strict);
            CyrResult expPosition   = strict.Decline();
            string    firstWordDecl = expPosition.Genitive;

            expertPosition = string.Concat(firstWordDecl, expPositionTail);

            firstWordInPosition = contract.repPosition.Split(' ').First();

            firstWordIndex = contract.repPosition.IndexOf(firstWordInPosition);

            string repPositionTail = contract.repPosition.Remove(firstWordIndex, firstWordInPosition.Length);

            CyrResult repname = phrase.Decline((contract.repFamName + contract.repFName + contract.repMName), GetConditionsEnum.Strict);
            string    repName = repname.Genitive;

            strict = nouns.Get(firstWordInPosition, GetConditionsEnum.Strict);
            CyrResult repPosition = strict.Decline();

            firstWordDecl = repPosition.Genitive;
            string representativePosition = string.Concat(firstWordDecl, expPositionTail);


            try
            {
                Document document = new Document();
                document.LoadFromFile("~/Content/FileTemplates/ContractTemplateCorporate.docx");
                BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
                bookmarkNavigator.MoveToBookmark("ContractNum");
                bookmarkNavigator.ReplaceBookmarkContent(contract.callNumber, true);

                bookmarkNavigator.MoveToBookmark("ContractDay");
                if (contract.contractDate.HasValue)
                {
                    bookmarkNavigator.ReplaceBookmarkContent((contract.contractDate?.ToString("dd", new CultureInfo("ru-RU"))), true);

                    bookmarkNavigator.MoveToBookmark("ContractMonth");
                    bookmarkNavigator.ReplaceBookmarkContent(contract.contractDate?.ToString(" MMMM ", new CultureInfo("ru-RU")), true);

                    bookmarkNavigator.MoveToBookmark("ContractYear");
                    bookmarkNavigator.ReplaceBookmarkContent(contract.contractDate?.ToString(" yyyy г.", new CultureInfo("ru-RU")), true);
                }

                else
                {
                    bookmarkNavigator.ReplaceBookmarkContent((DateTime.Today.ToString("dd", new CultureInfo("ru-RU"))), true);

                    bookmarkNavigator.MoveToBookmark("ContractMonth");
                    bookmarkNavigator.ReplaceBookmarkContent(DateTime.Today.ToString(" MMMM ", new CultureInfo("ru-RU")), true);

                    bookmarkNavigator.MoveToBookmark("ContractYear");
                    bookmarkNavigator.ReplaceBookmarkContent(DateTime.Today.ToString(" yyyy г.", new CultureInfo("ru-RU")), true);
                }

                bookmarkNavigator.MoveToBookmark("ContractExpertPosition");
                bookmarkNavigator.ReplaceBookmarkContent(expertPosition, true);

                bookmarkNavigator.MoveToBookmark("ContractExpertFullName");
                bookmarkNavigator.ReplaceBookmarkContent(expName, true);

                bookmarkNavigator.MoveToBookmark("AffidavitNum");
                bookmarkNavigator.ReplaceBookmarkContent(contract.expAffNum, true);

                bookmarkNavigator.MoveToBookmark("AffidavitDate");
                bookmarkNavigator.ReplaceBookmarkContent(contract.expAffDate, true);

                bookmarkNavigator.MoveToBookmark("CustomerName");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custName, true);

                bookmarkNavigator.MoveToBookmark("CustomerDoc");
                bookmarkNavigator.ReplaceBookmarkContent(" ", true);

                bookmarkNavigator.MoveToBookmark("RepresentativePosition");
                bookmarkNavigator.ReplaceBookmarkContent(representativePosition, true);

                bookmarkNavigator.MoveToBookmark("RepresentativeName");
                bookmarkNavigator.ReplaceBookmarkContent(repName, true);

                bookmarkNavigator.MoveToBookmark("CustomerCompanyDoc");
                bookmarkNavigator.ReplaceBookmarkContent(contract.repdoc, true);

                foreach (ContractViewModel.Itm i in contract.itmList)
                {
                    CyrResult it_name = phrase.Decline(i.itemsubtype, GetConditionsEnum.Strict);
                    i.itemsubtype = it_name.Genitive;

                    bookmarkNavigator.MoveToBookmark("ItemName");
                    bookmarkNavigator.ReplaceBookmarkContent(i.itemsubtype + i.itemname, true);

                    string progname = (from prog in db.Programs.ToList()
                                       join t in db.ItemTypes.ToList() on prog.ItemTypeID equals t.ItemTypeID
                                       join st in db.ItemSubtypes.ToList() on t.ItemTypeID equals st.ItemTypeID
                                       join item in db.Items.ToList() on st.ItemSubtypeID equals item.ItemSubtypeID
                                       where item.ItemName == i.itemname
                                       select prog.ProgramNameShort).FirstOrDefault();


                    bookmarkNavigator.MoveToBookmark("ProgramShortName");
                    bookmarkNavigator.ReplaceBookmarkContent(progname, true);

                    bookmarkNavigator.MoveToBookmark("ItemsNum");
                    bookmarkNavigator.ReplaceBookmarkContent(i.Qty, true);


                    string [] stringarr       = i.additionals.Split(' ');
                    CyrResult addCyr          = phrase.Decline(stringarr[0], GetConditionsEnum.Strict);
                    string    additionals     = addCyr.Genitive;
                    int       index           = i.additionals.IndexOf(additionals);
                    string    additionalsTail = i.additionals.Remove(index, stringarr[0].Length);

                    bookmarkNavigator.MoveToBookmark("Additionals");
                    bookmarkNavigator.ReplaceBookmarkContent(additionals + additionalsTail, true);

                    bookmarkNavigator.MoveToBookmark("CalculationOrderDate");
                    bookmarkNavigator.ReplaceBookmarkContent(i.calcDate, true);

                    bookmarkNavigator.MoveToBookmark("CalculationOrderNum");
                    bookmarkNavigator.ReplaceBookmarkContent(i.calcNum, true);
                }

                decimal TotalSum = 0;
                var     costs    = from callitem in callDetails
                                   where (callitem.CallID == callID)
                                   select callitem.ItemTestCost;
                TotalSum = costs.Sum(c => Convert.ToDecimal(c));

                bookmarkNavigator.MoveToBookmark("TotalSum");
                bookmarkNavigator.ReplaceBookmarkContent(TotalSum.ToString(), true);

                bookmarkNavigator.MoveToBookmark("TestingDurationCalDays");
                bookmarkNavigator.ReplaceBookmarkContent("30", true);

                bookmarkNavigator.MoveToBookmark("ExpertFIO");
                bookmarkNavigator.ReplaceBookmarkContent(expName, true);

                bookmarkNavigator.MoveToBookmark("RepresentativeFIO");
                bookmarkNavigator.ReplaceBookmarkContent(repName, true);

                bookmarkNavigator.MoveToBookmark("CustomerName2");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custName, true);

                bookmarkNavigator.MoveToBookmark("TaxID");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custTaxID, true);

                bookmarkNavigator.MoveToBookmark("OKPO");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custOKPO, true);

                bookmarkNavigator.MoveToBookmark("CustomerAddress");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custAddress, true);

                bookmarkNavigator.MoveToBookmark("CustomerPhoneNum");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custPhoneNumber, true);

                bookmarkNavigator.MoveToBookmark("CustomerMphoneNum");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custMPhoneNumber, true);

                bookmarkNavigator.MoveToBookmark("BankAccount");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custAccount, true);

                bookmarkNavigator.MoveToBookmark("BankBranch");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custBankBranch, true);

                bookmarkNavigator.MoveToBookmark("BankAddress");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custBranchAddress, true);

                bookmarkNavigator.MoveToBookmark("BankCode");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custBankCode, true);

                bookmarkNavigator.MoveToBookmark("BIC");
                bookmarkNavigator.ReplaceBookmarkContent(contract.custBIC, true);

                //Save doc file.

                if (document != null)
                {
                    string path = Server.MapPath(@"~\Area\Manager\Files\Contracts\");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    document.SaveToFile(path + @"docx\" + contract.CallID.ToString() + ".docx", Spire.Doc.FileFormat.Docx);
                    document.SaveToFile(path + @"pdf\" + contract.CallID.ToString() + ".pdf", Spire.Doc.FileFormat.PDF);
                    ViewBag.pdf = (path + @"pdf\" + contract.CallID.ToString() + ".pdf");
                }
            }

            catch (Exception e)
            {
                return(new HttpNotFoundResult(e.ToString()));
            }



            return(View());
        }
Beispiel #10
0
        private string GetDeclensionInCase(CyrResult cyrResult, string caseName = "Nominative")
        {
            var res = cyrResult.GetType().GetProperty(caseName).GetValue(cyrResult);

            return(res.ToString());
        }
Beispiel #11
0
        public void MasculineFullNameIsCorrectlyDeclined()
        {
            {
                CyrResult result = this.CyrName.Decline("Иванов Иван Иванович", Cyriller.Model.GendersEnum.Masculine, false);

                Assert.Equal("Иванова Ивана Ивановича", result.Get(Cyriller.Model.CasesEnum.Genitive));
                Assert.Equal("Иванову Ивану Ивановичу", result.Get(Cyriller.Model.CasesEnum.Dative));
                Assert.Equal("Иванова Ивана Ивановича", result.Get(Cyriller.Model.CasesEnum.Accusative));
                Assert.Equal("Ивановым Иваном Ивановичем", result.Get(Cyriller.Model.CasesEnum.Instrumental));
                Assert.Equal("Иванове Иване Ивановиче", result.Get(Cyriller.Model.CasesEnum.Prepositional));
            }

            {
                CyrResult result = this.CyrName.Decline("Карим Куржов Салим Оглы", Cyriller.Model.GendersEnum.Masculine, false);

                Assert.Equal("Карима Куржова Салим Оглы", result.Get(Cyriller.Model.CasesEnum.Genitive));
                Assert.Equal("Кариму Куржову Салим Оглы", result.Get(Cyriller.Model.CasesEnum.Dative));
                Assert.Equal("Карима Куржова Салим Оглы", result.Get(Cyriller.Model.CasesEnum.Accusative));
                Assert.Equal("Каримом Куржовом Салим Оглы", result.Get(Cyriller.Model.CasesEnum.Instrumental));
                Assert.Equal("Кариме Куржове Салим Оглы", result.Get(Cyriller.Model.CasesEnum.Prepositional));
            }

            {
                CyrResult result = this.CyrName.Decline("Карим Куржов Салим-Оглы", Cyriller.Model.GendersEnum.Masculine, false);

                Assert.Equal("Карима Куржова Салим-Оглы", result.Get(Cyriller.Model.CasesEnum.Genitive));
                Assert.Equal("Кариму Куржову Салим-Оглы", result.Get(Cyriller.Model.CasesEnum.Dative));
                Assert.Equal("Карима Куржова Салим-Оглы", result.Get(Cyriller.Model.CasesEnum.Accusative));
                Assert.Equal("Каримом Куржовом Салим-Оглы", result.Get(Cyriller.Model.CasesEnum.Instrumental));
                Assert.Equal("Кариме Куржове Салим-Оглы", result.Get(Cyriller.Model.CasesEnum.Prepositional));
            }

            {
                CyrResult result = this.CyrName.Decline("Иванов Иван Иванович", Cyriller.Model.GendersEnum.Masculine, true);

                Assert.Equal("Иванова И. И.", result.Get(Cyriller.Model.CasesEnum.Genitive));
                Assert.Equal("Иванову И. И.", result.Get(Cyriller.Model.CasesEnum.Dative));
                Assert.Equal("Иванова И. И.", result.Get(Cyriller.Model.CasesEnum.Accusative));
                Assert.Equal("Ивановым И. И.", result.Get(Cyriller.Model.CasesEnum.Instrumental));
                Assert.Equal("Иванове И. И.", result.Get(Cyriller.Model.CasesEnum.Prepositional));
            }

            {
                CyrResult result = this.CyrName.Decline("Карим Куржов Салим Оглы", Cyriller.Model.GendersEnum.Masculine, true);

                Assert.Equal("Карима К. С.", result.Get(Cyriller.Model.CasesEnum.Genitive));
                Assert.Equal("Кариму К. С.", result.Get(Cyriller.Model.CasesEnum.Dative));
                Assert.Equal("Карима К. С.", result.Get(Cyriller.Model.CasesEnum.Accusative));
                Assert.Equal("Каримом К. С.", result.Get(Cyriller.Model.CasesEnum.Instrumental));
                Assert.Equal("Кариме К. С.", result.Get(Cyriller.Model.CasesEnum.Prepositional));
            }

            {
                CyrResult result = this.CyrName.Decline("Илон МакФерсон", Cyriller.Model.GendersEnum.Masculine, false);

                Assert.Equal("Илона МакФерсона", result.Get(Cyriller.Model.CasesEnum.Genitive));
                Assert.Equal("Илону МакФерсону", result.Get(Cyriller.Model.CasesEnum.Dative));
                Assert.Equal("Илона МакФерсона", result.Get(Cyriller.Model.CasesEnum.Accusative));
                Assert.Equal("Илоном МакФерсоном", result.Get(Cyriller.Model.CasesEnum.Instrumental));
                Assert.Equal("Илоне МакФерсоне", result.Get(Cyriller.Model.CasesEnum.Prepositional));
            }

            {
                CyrResult result = this.CyrName.Decline("Ахмед Гафуров ибн Мухаммад", Cyriller.Model.GendersEnum.Masculine, false);

                Assert.Equal("Ахмеда Гафурова ибн Мухаммада", result.Get(Cyriller.Model.CasesEnum.Genitive));
                Assert.Equal("Ахмеду Гафурову ибн Мухаммаду", result.Get(Cyriller.Model.CasesEnum.Dative));
                Assert.Equal("Ахмеда Гафурова ибн Мухаммада", result.Get(Cyriller.Model.CasesEnum.Accusative));
                Assert.Equal("Ахмедом Гафуровом ибн Мухаммадом", result.Get(Cyriller.Model.CasesEnum.Instrumental));
                Assert.Equal("Ахмеде Гафурове ибн Мухаммаде", result.Get(Cyriller.Model.CasesEnum.Prepositional));
            }
        }
Beispiel #12
0
        public void Nouns()
        {
            int speechPartNountID            = 1;
            CyrNounCollection nounCollection = new CyrNounCollection();
            CyrillerEntities  mainDB         = new CyrillerEntities();
            int         count = mainDB.Words.Where(x => x.SpeechPartID == speechPartNountID).Count();
            int         step  = 1000;
            List <Task> tasks = new List <Task>();

            mainDB.Dispose();

            for (int i = 0; i < count; i += step)
            {
                int skip = i;

                tasks.Add(Task.Run(() =>
                {
                    CyrillerEntities db     = new CyrillerEntities();
                    IQueryable <Word> words = db.Words.Where(x => x.SpeechPartID == speechPartNountID).OrderBy(x => x.ID).Skip(skip).Take(step);

                    foreach (Word iterator in words)
                    {
                        CyrNoun noun = nounCollection.Get(iterator.Name, (GendersEnum)(iterator.GenderID ?? 0), CasesEnum.Nominative, NumbersEnum.Singular);

                        Assert.NotNull(noun);

                        // There might be multiple the same words in the database, one animated, another one not.
                        int animateID = (int)noun.Animate;
                        int genderID  = (int)noun.Gender;
                        Word word     = db.Words.FirstOrDefault(x =>
                                                                x.Name == noun.Name &&
                                                                x.AnimateID == animateID &&
                                                                (x.GenderID ?? 0) == genderID
                                                                );

                        Assert.NotNull(word);
                        Assert.True((word.GenderID ?? 0) == ((int?)noun.Gender ?? 0), $"{word.ID}|{word.Name} - wrong gender [{noun.Gender}], expected [{word.Gender?.Name}].");
                        Assert.True((word.AnimateID ?? 0) == ((int?)noun.Animate ?? 0), $"{word.ID}|{word.Name} - wrong animate [{noun.Animate}], expected [{word.Animate?.Name}].");
                        Assert.True((word.TypeID ?? 0) == ((int?)noun.WordType ?? 0), $"{word.ID}|{word.Name} - wrong type [{noun.WordType}], expected [{word.WordType?.Name}].");

                        CyrResult result = noun.Decline();

                        Assert.NotNull(result);

                        for (int caseID = 1; caseID < 7; caseID++)
                        {
                            WordCase[] wordCases = word.WordCases.Where(x => x.CaseID == caseID && x.NumberID == 1).ToArray();
                            string errorMessage  = $"{word.ID}|{caseID} - wrong case [{result[caseID]}], expected [{word.Name}].";

                            if (!wordCases.Any())
                            {
                                Assert.True(caseID == 1 || string.IsNullOrEmpty(result[caseID]), errorMessage);
                            }
                            else
                            {
                                Assert.True(wordCases.Any(x => string.Compare(x.Name, result[caseID], true) == 0), errorMessage);
                            }
                        }
                    }

                    db.Dispose();
                }));
            }

            Task.WaitAll(tasks.ToArray());
        }