Example #1
0
        private static void ReadWritePersonnelDataFile(string inputPathFile)
        {
            string[] columnValue;
            string   textLine = null;
            DateTime dateTime;

            using (StreamReader reader = new StreamReader(inputPathFile))
            {
                while (!reader.EndOfStream)
                {
                    try
                    {
                        textLine = reader.ReadLine();
                    }
                    catch (Exception e)
                    {
                        // Let the user know what went wrong.
                        Console.WriteLine("The " + inputPathFile + " file could not be read:");
                        Console.WriteLine(e.Message);
                        Console.ReadLine();
                    }

                    // skip the header record in the input file
                    if (textLine.IndexOf("ref_data_type") == -1)
                    {
                        columnValue = textLine.Split('|');
                        PersonnelDTO personnelDTO = new PersonnelDTO();

                        personnelDTO.RecordID  = Guid.NewGuid();
                        personnelDTO.LastName  = columnValue[0];
                        personnelDTO.FirstName = columnValue[1];
                        personnelDTO.PersonID  = columnValue[2];

                        if (DateTime.TryParse(columnValue[3], out dateTime))
                        {
                            personnelDTO.CareerDate = dateTime;
                        }
                        else
                        {
                            personnelDTO.CareerDate = DateTime.MaxValue;;
                        }

                        if (columnValue[4] == "8")
                        {
                            personnelDTO.Role = "M";                              // manager
                        }
                        else if (columnValue[4] == "9")
                        {
                            personnelDTO.Role = "U";                             // umpire
                        }
                        else
                        {
                            personnelDTO.Role = null;                             // unknown
                        }

                        PersonnelPersist.CreatePersonnel(personnelDTO);
                    }
                }
            }
        }
Example #2
0
        private static Personnel convertToEntity(PersonnelDTO personnelDTO)
        {
            var personnel = new Personnel();

            personnel.record_id   = personnelDTO.RecordID;
            personnel.person_id   = personnelDTO.PersonID;
            personnel.last_name   = personnelDTO.LastName;
            personnel.first_name  = personnelDTO.FirstName;
            personnel.career_date = personnelDTO.CareerDate;
            personnel.role        = personnelDTO.Role;

            return(personnel);
        }
Example #3
0
        public static void CreatePersonnel(PersonnelDTO personnelDTO)
        {
            // ballpark instance of Player class in Retrosheet_Persist.Retrosheet
            var personnel = convertToEntity(personnelDTO);

            // entity data model
            var dbCtx = new retrosheetDB();

            dbCtx.Personnels.Add(personnel);
            try
            {
                dbCtx.SaveChanges();
            }
            catch (Exception e)
            {
                string text;
                text = e.Message;
            }
        }
Example #4
0
 private async void BindCrewList(PersonnelDTO foreman)
 {
     if (foreman != null)
     {
         var crewList = await _projectSM.GetFiwpManonsiteByForeman(foreman.CurDepartStructureID, DateTime.Now);
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             lvCrewList.Items.Clear();
             _crewList.Clear();
             foreach (var item in crewList)
             {
                 _crewList.Add(item);
                 lvCrewList.Items.Add(item);
             }
         });
     };
 }