Example #1
0
        public new void Add(string key, WordInfoOnce value)
        {
            if (ContainsKey(key))
            {
                //$"{name}已存在键:{key}。".WriteWarningLine();
                return;//已有
            }

            if (name == "默认")
            {
                var w = value;
                if (w.p?.StartsWith("i", StringComparison.OrdinalIgnoreCase) == true)
                {
                    Idioms.Add(w.w, w);                                                                  //成语词典
                }
                else if (w.p?.StartsWith("nr", StringComparison.OrdinalIgnoreCase) == true)
                {
                    PersonNames.Add(w.w, w);                                                                        //人名词典
                }
                else if (w.p?.StartsWith("ns", StringComparison.OrdinalIgnoreCase) == true)
                {
                    PlaceNames.Add(w.w, w);                                                                        //地
                }
                else
                {
                    TempWords.Add(key, value);
                }
            }
            else
            {
                base.Add(key, value);
            }
        }
Example #2
0
        public void NamesAreUnique()
        {
            var personNames = new PersonNames();

            foreach (string manName in personNames.MaleNames)
            {
                Assert.That(personNames.FemaleNames.Contains(manName), Is.False, $"Имя {manName} присутствует в обоих списках");
            }
        }
Example #3
0
        public void CreatePerson()
        {
            // such a person already exists: there should be some validation message, but  it is not so important in a demo
            if (PersonNames.Any(x => x == NewPersonName))
            {
                return;
            }

            Graph.AddVertex(new Person(Graph)
            {
                Name = NewPersonName
            });
        }
    public void CalculatePersonNamesGrammars()
    {
      Grammars.Include(i => i.Names).Include(i => i.GrammarCases).Load();
      Grammars.ToList().ForEach(gr =>
      {
        var nomcase = gr.GrammarCases.FirstOrDefault(f => f.Case == Case.NOM);
        var names = PersonNames.AsEnumerable().Where(w => Regex.IsMatch(w.Name, $".?{gr.Suffix}{(w.Gender == Gender.M ? nomcase.MForm : nomcase.FForm)}$") && gr.BaseEnding == (w.Gender == Gender.M ? nomcase.MForm : nomcase.FForm) && gr.For == w.Part);
        foreach (var n in names)
        {
          n.Grammar = gr;
          n.GrammarId = gr.Id;
        };
      });

      SaveChanges();
    }
        public override object Get()
        {
            var personNames     = new PersonNames();
            var familyNameindex = Context.Random.Next(1, personNames.FamilyNames.Length);
            var surNameIndex    = Context.Random.Next(1, personNames.SurNames.Length);

            var middleName = " ";

            if (Context.Random.Next(0, 1) > 0)
            {
                var middleNameIndex = Context.Random.Next(1, personNames.SurNames.Length);
                middleName = $" {personNames.SurNames[middleNameIndex]} ";
            }

            var name = $"{personNames.SurNames[surNameIndex]}{middleName}{personNames.FamilyNames[familyNameindex]}";

            return(name);
        }
Example #6
0
    public void StartNewGame()
    {
        SaveManager.Instance.ActiveSave = null;

        DateTime birthday = ConstructDateFromInput();

        var new_character = new Character {
            Name = string.IsNullOrEmpty(CharacterNameInput.text) ? PersonNames.GetRandomName() : CharacterNameInput.text,
            Age  = DateTime.Today.Month > birthday.Month ||
                   (DateTime.Today.Month == birthday.Month && DateTime.Today.Day > birthday.Day)
                      ? DateTime.Today.Year - birthday.Year
                      : DateTime.Today.Year - birthday.Year - 1,
            Birthday        = birthday.ToString("dd-MM-yyyy"),
            CurrentLocation = Location.Locations[currentLocationIndex],
            IsMale          = NewCharacterAvatar.AvatarMaleBody.gameObject.activeSelf
        };

        new_character.SetHeadColor(NewCharacterAvatar.AvatarHead.color);
        new_character.SetBodyColor(NewCharacterAvatar.AvatarMaleBody.color);
        new_character.SetLegsColor(NewCharacterAvatar.AvatarLegs.color);

        new_character.Skills[Skill.Programming].Level    = ProgrammingSkillAllocator.CurrentSkillLevel;
        new_character.Skills[Skill.UserInterfaces].Level = UserInterfacesSkillAllocator.CurrentSkillLevel;
        new_character.Skills[Skill.Databases].Level      = DatabasesSkillAllocator.CurrentSkillLevel;
        new_character.Skills[Skill.Networking].Level     = NetworkingSkillAllocator.CurrentSkillLevel;
        new_character.Skills[Skill.WebDevelopment].Level = WebDevelopmentSkillAllocator.CurrentSkillLevel;

        new_character.Funds      = 5000;
        new_character.Reputation = 50;

        new_character.SetupEvents();

        CanvasGroup mm_canvas = SDTUIController.Instance.MainMenuCanvas.GetComponent <CanvasGroup>();
        CanvasGroup ig_canvas = SDTUIController.Instance.InGameCanvas.GetComponent <CanvasGroup>();

        mm_canvas.alpha = 0; mm_canvas.interactable = false; mm_canvas.blocksRaycasts = false;
        ig_canvas.alpha = 1; ig_canvas.interactable = true; ig_canvas.blocksRaycasts = true;

        TimeManager.Unlock();
        TimeManager.Unpause();
    }
Example #7
0
    public static Employee GenerateEmployee()
    {
        var title        = JobTitle.GetRandomTitle();
        var new_employee = new Employee();

        new_employee.CurrentTitle = title;
        new_employee.Salary       = Mathf.CeilToInt(title.SkillRequirements.Sum() * salary_skill_factor)
                                    * Random.Range(50, 60) * 1000;
        new_employee.HireCost        = Mathf.CeilToInt(Random.Range(0.05f, 1.0f) * new_employee.Salary);
        new_employee.Name            = PersonNames.GetRandomName();
        new_employee.Age             = Random.Range(18, 50);
        new_employee.CurrentLocation = Location.GetRandomLocation();
        new_employee.Skills          = new SkillList();
        for (int i = 0; i < SkillInfo.COUNT; i++)
        {
            new_employee.Skills[(Skill)i] = title.SkillRequirements[(Skill)i] + Random.Range(2, 5);
        }
        new_employee.Morale = 50.0f;

        return(new_employee);
    }
Example #8
0
    /// <summary>
    /// Return a random person name.
    /// Specify type of name with <see cref="PersonNames"/> enum.
    /// </summary>
    /// <param name="personName">Type of name.</param>
    /// <returns></returns>
    public virtual string PersonName(PersonNames personName)
    {
        switch (personName)
        {
        case PersonNames.LastName:
            return(LastName());

        case PersonNames.FemaleFirstName:
            return(FemaleFirstName());

        case PersonNames.MaleFirstName:
            return(MaleFirstName());

        case PersonNames.UndecidedFullName:
            var    gender = UnityEngine.Random.Range(0, 1);
            string firstName;
            if (gender < 1)
            {
                firstName = FemaleFirstName();
            }
            else
            {
                firstName = MaleFirstName();
            }
            return(firstName + " " + LastName());

        case PersonNames.MaleFullName:
            return(MaleFirstName() + " " + LastName());

        case PersonNames.FemaleFullName:
            return(FemaleFirstName() + " " + LastName());

        default:
            return("Unexpected behaviour");
        }
    }
 public DataParserEmployee(
     PersonNames personNames,
     SizeService sizeService,
     PhoneFormatter phoneFormatter,
     IUserService userService = null)
 {
     AddColumnName(DataTypeEmployee.Fio,
                   "ФИО",
                   "Ф.И.О.",
                   "Фамилия Имя Отчество",
                   "Сотрудник",
                   "Наименование"      //Встречается при выгрузке из 1C
                   );
     AddColumnName(DataTypeEmployee.CardKey,
                   "CARD_KEY",
                   "card",
                   "uid"
                   );
     AddColumnName(DataTypeEmployee.FirstName,
                   "FIRST_NAME",
                   "имя",
                   "FIRST NAME"
                   );
     AddColumnName(DataTypeEmployee.LastName,
                   "LAST_NAME",
                   "фамилия",
                   "LAST NAME"
                   );
     AddColumnName(DataTypeEmployee.Patronymic,
                   "SECOND_NAME",
                   "SECOND NAME",
                   "Patronymic",
                   "Отчество"
                   );
     AddColumnName(DataTypeEmployee.Sex,
                   "Sex",
                   "Gender",
                   "Пол"
                   );
     AddColumnName(DataTypeEmployee.PersonnelNumber,
                   "TN",
                   "Табельный",
                   "Таб. №",
                   "Таб."      //Если такой вариант будет пересекаться с другими полями его можно удалить.
                   );
     AddColumnName(DataTypeEmployee.Phone,
                   "Телефон",
                   "Номер телефона",
                   "Тел"
                   );
     AddColumnName(DataTypeEmployee.HireDate,
                   "Дата приема",
                   "Дата приёма",
                   "Принят"
                   );
     AddColumnName(DataTypeEmployee.DismissDate,
                   "Дата увольнения",
                   "Уволен"
                   );
     AddColumnName(DataTypeEmployee.BirthDate,
                   "Дата рождения",
                   "День рождения",
                   "BirthDay"
                   );
     AddColumnName(DataTypeEmployee.Subdivision,
                   "Подразделение"
                   );
     AddColumnName(DataTypeEmployee.Department,
                   "Отдел",
                   "Бригада",
                   "Бригады"
                   );
     AddColumnName(DataTypeEmployee.Post,
                   "Должность"
                   );
     AddColumnName(DataTypeEmployee.Growth,
                   "Рост"
                   );
     AddColumnName(DataTypeEmployee.ShoesSize,
                   "Обувь"
                   );
     //Разместил ближе к концу чтобы слово "размер", срабатывало только в том случае если другого не нашли.
     AddColumnName(DataTypeEmployee.WearSize,
                   "Размер",
                   "Одежда"
                   );
     this.personNames    = personNames ?? throw new ArgumentNullException(nameof(personNames));
     this.phoneFormatter = phoneFormatter ?? throw new ArgumentException(nameof(phoneFormatter));
     this.userService    = userService;
     this.sizeService    = sizeService;
 }
        public EmployeeViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            INavigationManager navigation,
            IValidator validator,
            IUserService userService,
            ILifetimeScope autofacScope,
            PersonNames personNames,
            IInteractiveService interactive,
            FeaturesService featuresService,
            EmployeeRepository employeeRepository,
            NormRepository normRepository,
            LkUserManagerService lkUserManagerService,
            BaseParameters baseParameters,
            SizeService sizeService,
            CommonMessages messages) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
        {
            AutofacScope              = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            this.personNames          = personNames ?? throw new ArgumentNullException(nameof(personNames));
            this.interactive          = interactive ?? throw new ArgumentNullException(nameof(interactive));
            this.featuresService      = featuresService ?? throw new ArgumentNullException(nameof(featuresService));
            this.employeeRepository   = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            NormRepository            = normRepository ?? throw new ArgumentNullException(nameof(normRepository));
            this.lkUserManagerService = lkUserManagerService ?? throw new ArgumentNullException(nameof(lkUserManagerService));
            this.baseParameters       = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            this.messages             = messages ?? throw new ArgumentNullException(nameof(messages));
            var builder = new CommonEEVMBuilderFactory <EmployeeCard>(this, Entity, UoW, NavigationManager, AutofacScope);

            SizeService = sizeService;

            EntryLeaderViewModel = builder.ForProperty(x => x.Leader)
                                   .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>()
                                   .UseViewModelDialog <LeadersViewModel>()
                                   .Finish();

            EntrySubdivisionViewModel = builder.ForProperty(x => x.Subdivision)
                                        .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>()
                                        .UseViewModelDialog <SubdivisionViewModel>()
                                        .Finish();

            EntryDepartmentViewModel = builder.ForProperty(x => x.Department)
                                       .UseViewModelDialog <DepartmentViewModel>()
                                       .Finish();

            EntryDepartmentViewModel.EntitySelector = new DepartmentJournalViewModelSelector(
                this, NavigationManager, EntrySubdivisionViewModel);

            EntryPostViewModel = builder.ForProperty(x => x.Post)
                                 .UseViewModelJournalAndAutocompleter <PostJournalViewModel>()
                                 .UseViewModelDialog <PostViewModel>()
                                 .Finish();

            Entity.PropertyChanged += Entity_PropertyChanged;
            Entity.PropertyChanged += PostChangedCheck;

            if (UoW.IsNew)
            {
                Entity.CreatedbyUser = userService.GetCurrentUser(UoW);
                logger.Info("Создание карточки для нового сотрудника");
            }
            else
            {
                AutoCardNumber = String.IsNullOrWhiteSpace(Entity.CardNumber);
            }

            lastSubdivision = Entity.Subdivision;
            lastPost        = Entity.Post;

            //Создаем вкладки
            var parameter = new TypedParameter(typeof(EmployeeViewModel), this);

            NormsViewModel       = AutofacScope.Resolve <EmployeeNormsViewModel>(parameter);
            WearItemsViewModel   = AutofacScope.Resolve <EmployeeWearItemsViewModel>(parameter);
            ListedItemsViewModel = AutofacScope.Resolve <EmployeeListedItemsViewModel>(parameter);
            MovementsViewModel   = AutofacScope.Resolve <EmployeeMovementsViewModel>(parameter);
            VacationsViewModel   = AutofacScope.Resolve <EmployeeVacationsViewModel>(parameter);
            //Панели
            EmployeePhotoViewModel = AutofacScope.Resolve <EmployeePhotoViewModel>(parameter);

            VisiblePhoto = Entity.Photo != null;
            lkLastPhone  = Entity.PhoneNumber;
            LkPassword   = Entity.LkRegistered ? unknownPassword : String.Empty;

            Validations.Add(new ValidationRequest(this));
        }
    private PersonData ParseSinglePersonData(string text)
    {
      var result = new PersonData();
      string firstName = "";
      string midName = "";
      string lastName = "";
      Gender gender = Gender.N;

      var list = text.ToLower().Trim(' ').Split(' ').Select(s => s.CapitalizeFirstChar()).ToList();

      string foundName = PersonNames.AsEnumerable().Select(s => s.Name).Intersect(list).FirstOrDefault();
      PersonName foundPersonName = FindPersonName(foundName);


      if (foundPersonName != null)
      {
        switch (foundPersonName.Part)
        {
          case NamePart.FIRST:
            firstName = foundName;
            result.FirstName = foundName;
            result.FirstNameGrammar = foundPersonName.Grammar;
            break;
          case NamePart.MID:
            midName = foundName;
            result.MidName = foundName;
            result.MidNameGrammar = foundPersonName.Grammar;
            break;

          default:
            break;
        };

        gender = foundPersonName.Gender;
        result.Gender = foundPersonName.Gender;
        list.Remove(foundName);
      };


      foundName = PersonNames.AsEnumerable().Select(s => s.Name).Intersect(list).FirstOrDefault();
      foundPersonName = FindPersonName(foundName);


      if (foundPersonName != null)
      {
        switch (foundPersonName.Part)
        {
          case NamePart.FIRST:
            firstName = foundName;
            result.FirstName = foundName;
            result.FirstNameGrammar = foundPersonName.Grammar;
            break;
          case NamePart.MID:
            midName = foundName;
            result.MidName = foundName;
            result.MidNameGrammar = foundPersonName.Grammar;
            break;

          default:
            break;
        };

        list.Remove(foundName);
      };


      if (list.Count > 0)
      {
        for (var i = 0; i < list.Count; i++)
        {
          var found = Grammars.AsEnumerable().FirstOrDefault(f => f.For == NamePart.LAST && Regex.IsMatch(list[i], @$".?{(gender.Equals(Gender.M) ? f.MForm : f.FForm)}$"));
          if (found != null)
          {
            lastName = list[i];
            result.LastName = list[i];
            result.LastNameGrammar = found;
          }
        };
      };


      if (string.IsNullOrWhiteSpace(lastName))
      {
        lastName = String.Join(" ", list).Trim(' ');
        var found = Grammars.AsEnumerable().FirstOrDefault(f => f.For == NamePart.LAST && Regex.IsMatch(lastName, @$".?{(gender.Equals(Gender.M) ? f.MForm : f.FForm)}$"));
        if (found != null)
        {
          result.LastName = lastName;
          result.LastNameGrammar = found;
        }
      };


      return result;
    }
 public void LoadPersonNamesFromXML(XDocument xdoc)
 {
   var pnames = ReadPersonNamesFromXML(xdoc);
   PersonNames.AddRange(pnames.Where(w => !PersonNames.Any(a => a.Name == w.Name)));
   SaveChanges();
 }
 /// <summary>
 /// Загружает коллекцию объектов <see cref="PersonName"/>, созданную 
 /// из определений частей имен, найденных в xml-файле по указанному пути,
 /// и сохраняет ее в базу данных.
 /// </summary>
 /// <param name="xmlpath">Путь к xml-файлу, содержащему определения частей имен.</param>
 public void LoadPersonNamesFromXML(string xmlpath)
 {
   var pnames = ReadPersonNamesFromXML(xmlpath);
   PersonNames.AddRange(pnames.Where(w => !PersonNames.Any(a => a.Name == w.Name)));
   SaveChanges();
 }
 public bool PersonNameExists(string name) => PersonNames.Any(a => a.Name == name);
 public PersonName FindPersonName(string name) => PersonNames.FirstOrDefault(f => f.Name == name);
Example #16
0
        private void StreamReaderAll(StreamReader sr)
        {
            //$"{name}数据量比较大{sr.BaseStream.Length}BS,初始化数据需要一些时间,请耐心等待".WriteInfoLine(ConsoleColor.Cyan);
            long lineCount = 0;
            var  dt0       = DateTime.Now;

            while (!sr.EndOfStream)
            {
                var line = sr.ReadLine();
                if (line == "")
                {
                    continue;            //空行
                }
                lineCount++;

                WordInfoOnce w    = null;
                string[]     keys = new string[0];

                if (line.StartsWith("{"))
                {
                    w = JsonConvert.DeserializeObject <WordInfoOnce>(line);
                }
                else
                {
                    if (line.IndexOf('\t') > 0)
                    {
                        keys = line.Split('\t');
                    }
                    else
                    {
                        keys = line.Split(' ');
                    }

                    if (keys.Length >= 8)
                    {
                        //sw.WriteLine($"{w.w}\t{w.f}\t{w.p}\t{w.l}\t{w.o}\t{w.py}\t{w.isp}\t{w.pt}");
                        w = new WordInfoOnce()
                        {
                            w   = keys[0],
                            f   = string.IsNullOrEmpty(keys[1]) ? 0 : double.Parse(keys[1]),
                            p   = keys[2],
                            l   = keys[3],
                            o   = string.IsNullOrEmpty(keys[4]) ? null : (byte?)byte.Parse(keys[4]),
                            py  = keys[5],
                            isp = string.IsNullOrEmpty(keys[4]) ? null : (bool?)bool.Parse(keys[6]),
                            pt  = keys[7],
                        };
                    }
                    else if (keys.Length > 3)
                    {
                        w = new WordInfoOnce()
                        {
                            w = string.Join(" ", keys.Take(keys.Length - 2)),
                            p = keys[keys.Length - 1],
                        };
                        double d = 0;
                        var    b = double.TryParse(keys[keys.Length - 2], out d);
                        if (!b)
                        {
                            b = double.TryParse(keys[1], out d);
                        }
                        w.f = d;
                    }
                    else if (keys.Length == 3)
                    {
                        w = new WordInfoOnce()
                        {
                            w = keys[0],
                            p = keys[2],
                        };
                        double d = 0;
                        var    b = double.TryParse(keys[1], out d);
                        w.f = d;
                    }
                    else if (keys.Length == 2)
                    {
                        w = new WordInfoOnce()
                        {
                            w = keys[0],
                        };
                        double d = 0;
                        var    b = double.TryParse(keys[1], out d);
                        w.f = d;
                    }
                    else
                    {
                        w = new WordInfoOnce()
                        {
                            w = keys[0],
                        };
                    }
                }

                //分文件
                if (name == "词典" || name == "临时")
                {
                    //Console.Write($"{name}.");
                    if (name != ("成语") && w.p?.StartsWith("i", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        Idioms.AddNew(w.w, w);                                                                                    //成语词典
                    }
                    else if (name != ("人名") && w.p?.StartsWith("nr", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        PersonNames.AddNew(w.w, w);                                                                                          //人名词典
                    }
                    else if (name != ("地名") && w.p?.StartsWith("ns", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        PlaceNames.AddNew(w.w, w);                                                                                          //地名词典
                    }
                    else//词典或临时
                    {
                        if (!base.ContainsKey(w.w))
                        {
                            base.Add(w.w, w);
                        }
                        else if (!base.ContainsKey(w.Key))
                        {
                            var item = base[w.w];
                            if (item.p != w.p)
                            {
                                base.Add(w.Key, w.SetKeyType(KeyType.Key));
                            }
                        }
                    }
                }
                else
                {
                    if (!base.ContainsKey(w.w))
                    {
                        base.Add(w.w, w);
                    }
                    else if (!base.ContainsKey(w.Key))
                    {
                        var item = base[w.w];
                        if (item.p != w.p)
                        {
                            base.Add(w.Key, w.SetKeyType(KeyType.Key));
                        }
                    }
                }

                //3秒提醒
                if (lineCount % 1000 == 0 && DateTime.Now.AddSeconds(-3) > dt0)
                {
                    dt0 = DateTime.Now;
                    $"{name}已完成{lineCount}".WriteInfoLine(ConsoleColor.Cyan);
                }
            }

            if (this.Count != lineCount)
            {
                savetimes++;                         //保存
            }
        }