コード例 #1
0
ファイル: WorkContent.cs プロジェクト: watame/study
 /// <summary>
 /// クローン用コンストラクタ
 /// </summary>
 public WorkContent(WorkContent workContent)
 {
     this.Id                = workContent.Id;
     this.UserId            = workContent.UserId;
     this.Content           = workContent.Content;
     this.Weather           = workContent.Weather;
     this.PesticideContents = new ObservableCollection <PesticideContent>();
     foreach (PesticideContent pestcide in workContent.PesticideContents)
     {
         this.PesticideContents.Add(new PesticideContent(pestcide));
     }
     this.StartWorkTime = workContent.StartWorkTime;
     this.EndWorkTime   = workContent.EndWorkTime;
     this.WorkerMaster  = workContent.WorkerMaster;
 }
コード例 #2
0
        /// <summary>
        /// 作業内容リスト取得
        /// </summary>
        /// <returns></returns>
        public List <WorkContent> GetWorkContents()
        {
            List <WorkContent> result = new List <WorkContent>();

            try
            {
                this.command.CommandText = "SELECT * FROM T_WorkContent";
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        WorkContent tmp = new WorkContent()
                        {
                            Id            = int.Parse(reader["id"].ToString()),
                            Content       = reader["content"].ToString(),
                            Weather       = reader["weather"].ToString(),
                            StartWorkTime = DateTime.Parse(reader["start_datetime"].ToString()),
                            EndWorkTime   = DateTime.Parse(reader["end_datetime"].ToString()),
                            UserId        = int.Parse(reader["user_id"].ToString()),
                        };

                        result.Add(tmp);
                    }
                }

                // 農薬内容リストは問い合わせが発生するので、リストが出来た後に農薬内容リストを取得する
                foreach (WorkContent wc in result)
                {
                    List <WorkerMaster> master_list = GetWorkerMasters(wc.UserId);
                    wc.WorkerMaster      = new WorkerMaster(master_list[0]);
                    wc.PesticideContents = new ObservableCollection <PesticideContent>(GetPesticideContents(wc.Id));
                }
            }
            catch (Exception ex)
            {
                throw new SQLiteException(ex.ToString());
            }
            return(result);
        }