Beispiel #1
0
        /// <summary>
        /// 履歴データ保存
        /// </summary>
        /// <param name="saveDirectoryPath">保存先パス</param>
        /// <param name="historyDataList">履歴データ</param>
        /// <returns></returns>
        public static bool SaveHistoryData(string saveDirectoryPath, SortableBindingList <HistoryData> historyDataList)
        {
            string settingDirectory = $"{saveDirectoryPath}\\{SETTING_FOLDER_NAME}";
            string filePath         = $"{settingDirectory}\\{HISTORY_DATA_FILE_NAME}";

            try
            {
                // フォルダ生成
                if (!Directory.Exists(settingDirectory))
                {
                    Directory.CreateDirectory(settingDirectory);
                }


                using (var fs = new FileStream(filePath, FileMode.Create))
                    using (var jw = JsonReaderWriterFactory.CreateJsonWriter(fs, Encoding.UTF8, true, true, "    "))
                    {
                        DataContractJsonSerializerSettings serSetting = new DataContractJsonSerializerSettings
                        {
                            UseSimpleDictionaryFormat = true,
                            DateTimeFormat            = new DateTimeFormat("yyyy-MM-dd HH:mm:ss")
                        };
                        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SortableBindingList <HistoryData>), serSetting);

                        ser.WriteObject(jw, historyDataList);
                        jw.Flush();
                    }
            }
            catch
            {
                // TODO: 例外処理
                // 報告しやすい(してもらいやすい)形式で出力する

                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="host">プラグインホスト</param>
        public MainForm(IPluginHost host)
        {
            InitializeComponent();

            _Host = host;

            // フォームデータ読み込み
            FormConfig formConfig = AppConfigIO.LoadFormData(_Host.DirectoryPathAppSetting);

            if (formConfig != null)
            {
                excludeOwnerComment.Checked = formConfig.excludeOwnerComment;
                No2AsNo1Comment.Checked     = formConfig.No2AsNo1Comment;
                ReplyCommentToggle.Checked  = formConfig.ReplyCommentToggle;
                ReplyCommentTextBox.Text    = formConfig.ReplyCommentText;
            }
            // 履歴データ読み込み
            _HistoryDataList       = AppConfigIO.LoadHistoryData(_Host.DirectoryPathAppSetting);
            HistoryView.DataSource = _HistoryDataList;

            // イベント設定
            _Host.ReceivedComment += new ReceivedCommentEventHandler(_Host_ReceivedComment);
        }