Esempio n. 1
0
        void importTrainingDays(int oldProfileId, Profile newProfile, SqlCeConnection oldConnection)
        {
            Log.WriteInfo("Importing training days for profile id {0}, name{1}", newProfile.Id, newProfile.Name);
            SqlCeCommand cmd = new SqlCeCommand();

            cmd.Connection  = oldConnection;
            cmd.CommandText = "SELECT ID,TrainingDate,StartTime,EndTime,Comment,WymiaryId FROM TrainingDay WHERE ProfileId=" + oldProfileId;
            var reader = cmd.ExecuteReader();

            Log.WriteInfo("TrainingDay reader executed");
            while (reader.Read())
            {
                int      oldTrainingDayId = getInt32(reader, "ID").Value;
                DateTime date             = getDateTime(reader, "TrainingDate").Value;
                Log.WriteInfo("Training day id={0},TrainingDate={1}", oldTrainingDayId, date);
                TrainingDay day = new TrainingDay(date);
                day.ProfileId = newProfile.Id;
                day.Comment   = getString(reader, "Comment");
                int?wymiaryId = getInt32(reader, "WymiaryId");
                if (wymiaryId.HasValue)
                {
                    Log.WriteInfo("TrainingDay has wymiary id={0}", wymiaryId.Value);
                    SizeEntry sizeEntry = new SizeEntry();
                    sizeEntry.Wymiary = importWymiar(oldConnection, wymiaryId.Value);
                    day.AddEntry(sizeEntry);
                    //session.SaveOrUpdate(sizeEntry);
                }
                importStrengthTraining(day, oldTrainingDayId, getDateTime(reader, "StartTime"), getDateTime(reader, "EndTime"), day.Comment, oldConnection);
                day.Save();
                Log.WriteInfo("TrainingDay saved");
            }
            Log.WriteInfo("TrainingDay import complete");
        }