Esempio n. 1
0
        /// <summary>
        /// カレンダー情報を読み込む
        /// </summary>
        private void LoadCalendarData()
        {
            try
            {
                CalendarGrid.Rows.Clear();

                foreach (var data in CalendarInfos.GetInstance().CalendarInfoDic)
                {
                    int row = CalendarGrid.Rows.Add(data.Key, (CalendarType)data.Value[3], "" + data.Value[0]);

                    DataGridViewButtonCell cell1 = new DataGridViewButtonCell();
                    cell1.FlatStyle                                  = FlatStyle.Flat;
                    cell1.Style.BackColor                            = Color.FromArgb(255, 0, 64, 64);
                    cell1.Style.SelectionBackColor                   = Color.FromArgb(255, 0, 64, 64);
                    cell1.Style.ForeColor                            = Color.White;
                    cell1.Style.SelectionForeColor                   = Color.White;
                    CalendarGrid.Rows[row].Cells[COL_修正.Index]       = cell1;
                    CalendarGrid.Rows[row].Cells[COL_修正.Index].Value = "修正";

                    cell1                                            = new DataGridViewButtonCell();
                    cell1.FlatStyle                                  = FlatStyle.Flat;
                    cell1.Style.BackColor                            = Color.FromArgb(255, 0, 64, 64);
                    cell1.Style.SelectionBackColor                   = Color.FromArgb(255, 0, 64, 64);
                    cell1.Style.ForeColor                            = Color.White;
                    cell1.Style.SelectionForeColor                   = Color.White;
                    CalendarGrid.Rows[row].Cells[COL_削除.Index]       = cell1;
                    CalendarGrid.Rows[row].Cells[COL_削除.Index].Value = "削除";
                }
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// カレンダーをDBに保存する
        /// </summary>
        /// <param name="dialog">保存確認ダイアログ表示フラグ</param>
        private bool SaveCalendarData(bool dialog)
        {
            try
            {
                if (string.IsNullOrEmpty(DescriptionTextBox.Text.Trim()))
                {
                    this.ShowWarningDialog("カレンダー名未入力", "カレンダー名を入力してください。");
                    return(false);
                }
                if (dialog)
                {
                    DialogResult result = this.ShowInfoDialog("カレンダーの保存", "カレンダーを保存しますか?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.No)
                    {
                        return(false);
                    }
                }

                SetCalendarModel();
                CalendarInfos.GetInstance().CreateCalendarValue(_calendarModel.CalendarId, _calendarModel.Description, _calendarModel, _calendarModel.CalendarType);
                if (dialog)
                {
                    this.ShowDialog("カレンダーの保存", "カレンダーを保存しました。");
                }
                _isDataChanged = false;
                return(true);
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// カレンダーのインポート処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ImportButton_Click(object sender, EventArgs e)
        {
            try
            {
                string kana  = "カレンダー";
                string file1 = "mcrc";
                string file2 = "MCRC";

                var dialog = new CommonOpenFileDialog(kana + "ファイルの選択");
                // ファイル選択モード
                dialog.IsFolderPicker = false;
                dialog.Multiselect    = false;
                dialog.Filters.Add(new CommonFileDialogFilter(file2 + "ファイル(*." + file1 + ")", "*." + file1));
                if (dialog.ShowDialog(this.Handle) == CommonFileDialogResult.Ok)
                {
                    CalendarModel model = null;
                    //新取込
                    using (StreamReader sr = new StreamReader(dialog.FileName, Encoding.Default))
                    {
                        string jsonString = sr.ReadToEnd();

                        try
                        {
                            model = JsonConvert.DeserializeObject <CalendarModel>(jsonString);
                        }
                        catch (Exception) {}
                    }
                    if (model == null)
                    {
                        using (FileStream fs = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read))
                        {
                            BinaryFormatter f          = new BinaryFormatter();
                            string          jsonString = (string)f.Deserialize(fs);
                            jsonString = CryptUtil.DecryptString(jsonString, StringValue.CRYPT_PASSWORD);
                            model      = JsonConvert.DeserializeObject <CalendarModel>(jsonString);
                        }
                    }

                    //IDを更新する
                    model.CalendarId = CalendarInfos.GetNewCalendarModel().CalendarId;

                    DialogResult result = this.ShowInfoDialog("保存確認", kana + "をインポートしますか?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.No)
                    {
                        return;
                    }

                    CalendarInfos.GetInstance().CreateCalendarValue(model.CalendarId, model.Description, model, model.CalendarType);
                    LoadCalendarData();
                }
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// カレンダーセルのクリックイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CalendarGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                //修正
                if (e.RowIndex >= 0 && e.ColumnIndex == COL_修正.Index)
                {
                    switch (CalendarGrid.Rows[e.RowIndex].Cells[COL_CALENDARTYPE.Index].Value)
                    {
                    case CalendarType.固定カレンダー:
                    {
                        CalendarEditForm form = new CalendarEditForm();
                        //nullは新規作成
                        form.Init(int.Parse("" + CalendarGrid.Rows[e.RowIndex].Cells[COL_ID.Index].Value));
                        form.ShowDialog(this);
                    }
                    break;

                    default:
                    {
                        WebCalendarEditForm form = new WebCalendarEditForm();
                        //nullは新規作成
                        form.Init(int.Parse("" + CalendarGrid.Rows[e.RowIndex].Cells[COL_ID.Index].Value));
                        form.ShowDialog(this);
                    }
                    break;
                    }

                    LoadCalendarData();
                }
                //削除
                if (e.RowIndex >= 0 && e.ColumnIndex == COL_削除.Index)
                {
                    DialogResult result = this.ShowWarningDialog("カレンダーの削除の確認", "カレンダーを削除すると、利用中のプロジェクトに障害が発生する可能性がありますが、続行しますか?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);

                    if (result == DialogResult.No)
                    {
                        return;
                    }

                    CalendarInfos.GetInstance().RemoveByKey(int.Parse("" + CalendarGrid.Rows[e.RowIndex].Cells[COL_ID.Index].Value));


                    this.ShowDialog("カレンダーの削除", "カレンダーを削除しました。");

                    LoadCalendarData();
                }
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Exportボタンのクリックイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExportButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (CalendarGrid.Rows.Count == 0)
                {
                    return;
                }
                if (CalendarGrid.SelectedRows.Count == 0)
                {
                    return;
                }
                string         id  = "" + CalendarGrid.SelectedRows[0].Cells[COL_ID.Index].Value;
                SaveFileDialog sfd = new SaveFileDialog();

                string ftype1 = "mcrc";
                string ftype2 = "MCRC";

                sfd.FileName         = DateTime.Now.ToString("yyyyMMddHHmmss") + "_CALENDAR_" + id + "." + ftype1;
                sfd.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                sfd.Filter           = ftype2 + "ファイル(*." + ftype1 + ")| *." + ftype1;
                sfd.FilterIndex      = 2;
                sfd.Title            = "保存先のフォルダを選択してください";
                sfd.RestoreDirectory = true;
                sfd.OverwritePrompt  = true;
                sfd.CheckPathExists  = true;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string jsonString = JsonConvert.SerializeObject((CalendarModel)CalendarInfos.GetInstance().CalendarInfoDic[int.Parse(id)][1], new JsonSerializerSettings()
                    {
                        Formatting = Formatting.Indented
                    });
                    using (StreamWriter sw = new StreamWriter(sfd.FileName, false, Encoding.Default))
                    {
                        sw.WriteLine(jsonString);
                    }
                    this.ShowDialog("ファイルエクスポート実行", "ファイルをエクスポートしました。");
                }
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// カレンダーをコンボボックスへ読み込む
 /// </summary>
 /// <param name="calendarComboBox"></param>
 public static void LoadCalendarToComboBox(BaseComboBox calendarComboBox)
 {
     try
     {
         DbUtil        util  = DbUtil.GetInstance();
         CalendarModel model = new CalendarModel();
         model.CalendarId  = 0;
         model.Description = "--未設定--";
         calendarComboBox.Items.Add(model);
         foreach (KeyValuePair <int, object[]> pair in CalendarInfos.GetInstance().CalendarInfoDic)
         {
             calendarComboBox.Items.Add((CalendarModel)pair.Value[1]);
         }
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 初期化処理
 /// </summary>
 public void Init(int id)
 {
     try
     {
         if (id == 0)
         {
             _calendarModel = CalendarInfos.GetNewCalendarModel();
         }
         else
         {
             _calendarModel = (CalendarModel)CalendarInfos.GetInstance().CalendarInfoDic[id][1];
         }
         LoadCalendarForm();
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 保存ボタンのクリックイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(DescriptionTextBox.Text.Trim()))
                {
                    this.ShowWarningDialog("カレンダー名未入力", "カレンダー名を入力してください。");
                    return;
                }
                if (string.IsNullOrEmpty(UrlTextBox.Text.Trim()))
                {
                    this.ShowWarningDialog("URL未入力", "カレンダーデータ取得元URLを入力してください。");
                    return;
                }

                var dic = GetCalendarData();

                if (dic == null)
                {
                    return;
                }

                DialogResult result = this.ShowInfoDialog("カレンダーの保存", "カレンダーを保存しますか?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.No)
                {
                    return;
                }

                _calendarModel.Description            = DescriptionTextBox.Text.Trim();
                _calendarModel.Url                    = UrlTextBox.Text.Trim();
                _calendarModel.UrlParams              = GetParameter();
                _calendarModel.Value                  = dic;
                _calendarModel.CalendarDataFormatType = (CsvTypeRadio.Checked) ? Models.Enums.CalendarDataFormatType.CSV : Models.Enums.CalendarDataFormatType.TXT;
                CalendarInfos.GetInstance().CreateCalendarValue(_calendarModel.CalendarId, _calendarModel.Description, _calendarModel, _calendarModel.CalendarType);
                this.ShowDialog("カレンダーの保存", "カレンダーを保存しました。");
                _isDataChanged = false;
                return;
            }
            catch (Exception ex)
            {
                throw Program.ThrowException(ex);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// カレンダーを初期化する
 /// </summary>
 /// <param name="id"></param>
 internal void Init(int id)
 {
     try
     {
         if (id == 0)
         {
             //新規カレンダー
             _calendarModel = CalendarInfos.GetNewCalendarModel();
             _calendarModel.CalendarType = Models.Enums.CalendarType.外部カレンダー;
         }
         else
         {
             //DBより読み込み
             _calendarModel = (CalendarModel)CalendarInfos.GetInstance().CalendarInfoDic[id][1];
         }
         LoadCalendarForm();
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }