Esempio n. 1
0
        public static void RewriteWiresFiles(List <WiresFile> wireFiles)
        {
            foreach (WiresFile wierFile in wireFiles)
            {
                string bakFileName = MakeBakFileName(wierFile.FileName);
                File.Delete(bakFileName);
                File.Move(wierFile.FileName, bakFileName);

                var      wiers = wierFile.Wires;
                string[] lines = new string[wiers.Count];

                for (int i = 0; i < wiers.Count; i++)
                {
                    IWire wireTmp = wiers[i];
                    if (wireTmp == null)
                    {
                        lines[i] = string.Empty;
                        continue;
                    }

                    if (wireTmp.GetType() == typeof(WireDelimiter))
                    {
                        lines[i] = ((WireDelimiter)wireTmp).Remark;
                        continue;
                    }

                    Wire wire = (Wire)wireTmp;
                    //lines[i] = $"{wire.Date:00} ! {wire.DebSct,-20} ! {wire.KrdSct,-20} ! {wire.Sum,12:0.00} ! {wire.Remark}";
                    lines[i] = string.Format("{0:00} ! {1,-20} ! {2,-20} ! {3,12:0.00} ! {4}", wire.Date, wire.DebSct,
                                             wire.KrdSct, wire.Sum, wire.Remark);
                }

                File.WriteAllLines(wierFile.FileName, lines, Encoding.UTF8);
            }
        }