コード例 #1
0
ファイル: Program.cs プロジェクト: luiz-diniz/ObjectCSV
        static void Main(string[] args)
        {
            var csvConfig = new CSVConfig();

            var person = new List <Person>
            {
                new Person {
                    Id = 1, Name = "Joaquim", BirthDate = DateTime.Parse("05/10/1984 12:00:30 PM"), Size = 1.50
                },
                new Person {
                    Id = 2, Name = "Joker", BirthDate = DateTime.Parse("6/11/1964 2:20:34 AM"), Size = 1.50
                },
                new Person {
                    Id = 3, Name = "Phoenix", BirthDate = DateTime.Parse("9/2/1999 10:54:45 AM"), Size = 1.50
                }
            };

            Console.WriteLine("Path with file name: ");
            string pathPerson = Console.ReadLine();

            csvConfig.WriteOnCSV(person, pathPerson);

            Console.WriteLine("\n\nData exported sucessfuly.");
            Console.ReadKey();
        }
コード例 #2
0
        public override IConfig GetConfig()
        {
            if (csvConfig == null)
            {
                csvConfig = new CSVConfig();
            }

            return(csvConfig);
        }
コード例 #3
0
        private void cmdAddCSVStorage_Click(object sender, RoutedEventArgs e)
        {
            string val = "Storage_" + (grdStorages.Items.Count + 1);

            if (DotNetSiemensPLCToolBoxLibrary.General.InputBox.Show("Storage-Name", "Name of the Storage", ref val) == DialogResult.OK)
            {
                foreach (var tmp in ProtokollerConfiguration.ActualConfigInstance.Storages)
                {
                    if (tmp.Name.ToLower().Trim() == val.ToLower().Trim())
                    {
                        MessageBox.Show("A Storage with this Name already Exists!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }
                CSVConfig storage = new CSVConfig()
                {
                    Name = val
                };
                ProtokollerConfiguration.ActualConfigInstance.Storages.Add(storage);
            }
        }
コード例 #4
0
        public override void Connect_To_Database(StorageConfig config)
        {
            myConfig = config as CSVConfig;
            if (myConfig == null)
            {
                throw new Exception("Database Config is NULL");
            }

            if (!string.IsNullOrEmpty(myConfig.NetworkUserName))
            {
                try
                {
                    networkShare = new NetworkShare(Path.GetDirectoryName(myConfig.Textfile), myConfig.NetworkUserName, myConfig.NetworkPassword);
                }
                catch (Exception ex)
                {
                    if (!RaiseThreadExceptionOccured(this, ex))
                    {
                        Logging.LogText("Exception: ", ex, Logging.LogLevel.Error);
                    }
                }
            }
        }
コード例 #5
0
 public CSVConfigBuilder()
 {
     _element = new CSVConfig();
 }