Example #1
0
        static void save(StockSplitInfo[] infos, splitType filename)
        {
            var data = tryGet(a => true, filename);
            var ex   = infos.Except(data);

            if (!ex.Any())
            {
                StockPriceManager.SetMessage(DataSource.KabuDotCom, "新規データが存在しなかったため書き込み処理をスキップしました。");
                return;
            }

            if (!Directory.Exists(localPath))
            {
                Directory.CreateDirectory(localPath);
            }
            string tgtPath = localPath + filename.toFileName();

            try {
                using (FileStream f = new FileStream(tgtPath, FileMode.Create)) {
                    var seri = new XmlSerializer(typeof(StockSplitInfo[]));
                    seri.Serialize(f, data.Union(infos).ToArray());
                    StockPriceManager.SetMessage(DataSource.KabuDotCom, filename.toDisplayName() + "データを保存しました。");
                }
            } catch (Exception e) {
                StockPriceManager.SetMessage(new ManagementMessage()
                {
                    Sender  = DataSource.KabuDotCom,
                    Signal  = MessageSignal.Error,
                    Message = "書き込み処理に失敗しました。",
                    Detail  = e.Message,
                });
            }
        }