/// <summary> /// 添加一条赛事记录 /// </summary> /// <param name="aobjAddCompetition">赛事设定实体信息</param> /// <returns></returns> public ActionResult InsertComprtition(CompetitionEntity aobjAddCompetition) { aobjAddCompetition.StartDate = DateTime.Now; bool isSuccess = mobjCompetitionBLL.InsertCompetition(aobjAddCompetition); return(Content(isSuccess.ToString())); }
private CompetitionDTO MapEntityToDTO(CompetitionEntity entity) { return(new CompetitionDTO { CompetitionId = entity.CompetitionId, Name = entity.Name, Season = entity.Season }); }
static void Main(string[] args) { CompetitionBLL competitionBLL = new CompetitionBLL(); CompetitionEntity entity = new CompetitionEntity() { GameName = "DZK" }; competitionBLL.InsertCompetition(entity); }
public static CompetitionEntity GetCompetition(String fileName) { SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["AODB"].ConnectionString); string selectStatement = "SELECT * " + "FROM Competitions " + "WHERE CompName=@CompName"; SqlCommand selectCommand = new SqlCommand(selectStatement, connection); selectCommand.Parameters.AddWithValue( "@CompName", fileName.Replace(".mdb", "")); try { connection.Open(); SqlDataReader proReader = selectCommand.ExecuteReader( System.Data.CommandBehavior.SingleRow); if (proReader.Read()) { CompetitionEntity comp = new CompetitionEntity(); comp.CompId = Convert.ToInt32(proReader["CompId"]); comp.CompName = proReader["CompName"].ToString(); comp.CompSubName = proReader["CompSubName"].ToString(); comp.CompSubType = proReader["CompSubType"].ToString(); comp.CompType = proReader["CompType"].ToString(); comp.EndDate = DateTime.Parse(proReader["EndDate"].ToString()); comp.Facility = proReader["Facility"].ToString(); comp.Location = proReader["Location"].ToString(); comp.Season = proReader["Season"].ToString(); comp.StartDate = DateTime.Parse(proReader["StartDate"].ToString()); return(comp); } else { return(null); } } catch (SqlException ex) { logger.Error("Exception : " + ex.Message); return(null); } finally { connection.Close(); } }
private CompetitionEntity SaveCompetition(CompetitionExt data) { var namesPart = ParseCompetitionName(data.Caption); CompetitionEntity ent = new CompetitionEntity { Name = namesPart.Item1, Season = namesPart.Item2, NationalityId = null, CompetitionId = ExtractIdFromLinks(data._links) }; _context.Competitions.Add(ent); _context.SaveChanges(); return(ent); }
/// <summary> /// 修改赛事设定 /// </summary> /// <param name="aEditComprtition">赛事信息实体记录</param> /// <returns></returns> public bool UpdateCompetition(CompetitionEntity aEditComprtition) { return(mobjCompetitionDAL.Update(aEditComprtition)); }
/// <summary> /// 添加一条赛事设定记录 /// </summary> /// <param name="aAddCompetition">赛事信息实体记录</param> /// <returns></returns> public bool InsertCompetition(CompetitionEntity aAddCompetition) { return(mobjCompetitionDAL.Insert(aAddCompetition)); }
public static void ProcessResultsData(OdbcDataReader reader, string fileName, string resultType) { CompetitionEntity comp = new CompetitionEntity(); comp = CompetitionRepo.GetCompetition(fileName); int resultsCount = 0, resultsInserted = 0; logger.Info($"Started Processing : {resultType}"); while (reader.Read()) { resultsCount++; try { //Console.WriteLine(reader["Full_Eventname"].ToString() + reader["Rnd_ltr"].ToString() + reader["First_name"].ToString() + reader["Last_name"].ToString() + reader["Team_Abbr"].ToString() + reader["Reg_no"].ToString() + reader["Res_markDisplay"].ToString() + reader["Res_wind"].ToString() + reader["Res_place"].ToString()); String division = reader["Div_name"].ToString(); string eventGender = reader["Event_gender"].ToString(); string eventName = ""; DateTime Birth_date; if (reader["Birth_date"].ToString() == "") { Birth_date = DateTime.Parse("1900-01-01 00:00:00"); } else { Birth_date = DateTime.Parse(reader["Birth_date"].ToString()); } if (division.Contains("AMB")) { division = division.Replace("AMB", "Ambulatory"); } if (division.Contains("WC")) { division = division.Replace("WC", "Wheelchair"); } string[] div_categories = { "U6", "U8", "U10", "U12", "U14", "U16", "U18" }; if (div_categories.Contains(division)) { if (eventGender.Equals("M")) { eventGender = "Boys"; } else if (eventGender.Equals("F")) { eventGender = "Girls"; } else { eventGender = "Mixed"; } } else if (eventGender.Equals("M")) { eventGender = "Men"; } else if (eventGender.Equals("F")) { eventGender = "Women"; } else { eventGender = "Mixed"; } //for masters if (division.Equals("Masters")) { DateTime sdate = comp.StartDate; int Years = new DateTime(sdate.Subtract(Birth_date).Ticks).Year - 1; if (Years < 30) { division = "29 & Under Masters"; } else if (Years < 35) { division = "30 Masters"; } else if (Years < 40) { division = "35 Masters"; } else if (Years < 45) { division = "40 Masters"; } else if (Years < 50) { division = "45 Masters"; } else if (Years < 55) { division = "50 Masters"; } else if (Years < 60) { division = "55 Masters"; } else if (Years < 65) { division = "60 Masters"; } else if (Years < 70) { division = "65 Masters"; } else if (Years < 75) { division = "70 Masters"; } else if (Years < 80) { division = "75 Masters"; } else { division = "80 Masters"; } } if (reader["Event_name"].ToString().Contains("athlon"))//combined events { if (!reader["Event_dist"].ToString().Equals("0")) { if (!reader["Event_note"].ToString().Equals("")) { eventName = reader["Event_dist"].ToString() + " Meters " + reader["MultiSubEvent_name"].ToString() + " " + reader["Event_name"].ToString() + " " + reader["Event_note"].ToString(); } else { eventName = reader["Event_dist"].ToString() + " Meters " + " " + reader["MultiSubEvent_name"].ToString() + " " + reader["Event_name"].ToString(); } } else if (!reader["Event_note"].ToString().Equals("")) { eventName = reader["MultiSubEvent_name"].ToString() + " " + reader["Event_name"].ToString() + " " + reader["Event_note"].ToString(); } else { eventName = reader["MultiSubEvent_name"].ToString() + " " + reader["Event_name"].ToString(); } } else { if (!reader["Event_dist"].ToString().Equals("0")) { if (!reader["Event_note"].ToString().Equals("")) { eventName = reader["Event_dist"].ToString() + " Meters " + reader["Event_name"].ToString() + " " + reader["Event_note"].ToString(); } else { eventName = reader["Event_dist"].ToString() + " Meters " + reader["Event_name"].ToString(); } } else if (!reader["Event_note"].ToString().Equals("")) { eventName = reader["Event_name"].ToString() + " " + reader["Event_note"].ToString(); } else { eventName = reader["Event_name"].ToString(); } } eventName = eventName.Trim(); String Rnd_ltr = reader["Rnd_ltr"].ToString(); String First_name = reader["First_name"].ToString(); String Last_name = reader["Last_name"].ToString(); String Team_Abbr = reader["Team_Abbr"].ToString(); String Reg_no = reader["Reg_no"].ToString(); String Ath_Sex = reader["Ath_Sex"].ToString(); String Res_markDisplay = reader["Res_markDisplay"].ToString(); String Res_wind = reader["Res_wind"].ToString(); String Res_place = reader["Res_place"].ToString(); ResultEntity result = new ResultEntity(); int eventId = AthleteEventRepo.GetAthleteEventId(eventGender + " " + eventName + " " + division, Rnd_ltr); if (eventId == 0) { AthleteEventEntity athleteEvent = new AthleteEventEntity(); athleteEvent.EventGender = eventGender; athleteEvent.EventRound = Rnd_ltr; athleteEvent.EventDivision = division; athleteEvent.EventName = eventName; AthleteEventRepo.AddAthleteEvent(athleteEvent); eventId = AthleteEventRepo.GetAthleteEventId(eventGender + " " + eventName + " " + division, Rnd_ltr); } int athleteid = 0; athleteid = AthleteRepo.GetAthleteIdByACNum(Reg_no); if (athleteid == 0) { athleteid = AthleteRepo.GetAthleteIdByName(First_name, Last_name, Birth_date); if (athleteid == 0) { AthleteEntity athlete = new AthleteEntity(); athlete.ACNum = Reg_no; athlete.ClubAffiliationSince = comp.StartDate; athlete.ClubCode = Team_Abbr; athlete.DOB = Birth_date; athlete.FirstName = First_name; athlete.LastName = Last_name; athlete.AthleteGender = Ath_Sex; athlete.Address = ""; athlete.City = ""; athlete.AthleteEmail = ""; athlete.Phone = ""; athlete.HeadShot = ""; athlete.AthleteSpecialNoteId = 0; AthleteRepo.AddAthlete(athlete); if (String.IsNullOrWhiteSpace(Reg_no)) { result.AthleteId = AthleteRepo.GetAthleteIdByName(First_name, Last_name, Birth_date); } else { result.AthleteId = AthleteRepo.GetAthleteIdByACNum(Reg_no); } } else { result.AthleteId = athleteid; } } else { result.AthleteId = athleteid; } result.CompId = GetCompId(fileName); result.EventId = eventId; result.Mark = Res_markDisplay; if (reader["Event_name"].ToString().Contains("athlon")) { result.Position = Convert.ToInt32(reader["Event_score"].ToString()); } else { result.Position = Convert.ToInt32(Res_place); } result.Wind = Res_wind; if (ResultRepo.CheckDuplicate(result) == 0) { ResultRepo.AddResult(result); resultsInserted++; } else { logger.Error("Duplicate Result: " + fileName.Replace(".mdb", "") + "->" + eventGender + " " + eventName + " " + division + " " + Rnd_ltr + "->" + First_name + " " + Last_name + " DOB: " + Birth_date.ToString("dd-MM-yyyy")); } } catch (Exception e) { logger.Error("Exception : " + e.Message); } finally { } } logger.Info($"Total lines read by application : {resultsCount}"); logger.Info($"Total results synced to database : {resultsInserted}"); logger.Info($"Completed Processing : {resultType}"); }
/// <summary> /// 修改一条赛事记录 /// </summary> /// <param name="aobjUpdateComprtition">修改赛事设定信息</param> /// <returns></returns> public ActionResult UpdateComprtition(CompetitionEntity aobjUpdateComprtition) { bool isSuccess = mobjCompetitionBLL.UpdateCompetition(aobjUpdateComprtition); return(Content(isSuccess.ToString())); }