public string ExportBim360Projects()
        {
            string       retu   = new string("");
            MemoryStream stream = new MemoryStream();

            using (var streamWriter = new StreamWriter(stream))
            {
                //maybe the CultureInfo needs to be changed
                //change that everything should get written
                //CsvConfiguration test = new CsvConfiguration()
                using (var csv = new CsvWriter(streamWriter, CultureInfo.InvariantCulture))
                {
                    //Maps the Header of the CSV Data to the class attributes
                    var tmp = SerializationParser.ExportBim360ToCSV(projects);
                    if (tmp == null)
                    {
                        return(retu);
                    }
                    //this is really dirty but it works for now
                    for (int i = 0; i < 50; i++)
                    {
                        tmp.Add(new UserData());
                    }
                    csv.Context.RegisterClassMap <UserDataExport>();
                    //csv.WriteHeader<UserData>();
                    csv.WriteRecords(tmp);
                    // convert stream to string
                    stream.Position = 0;
                    StreamReader reader = new StreamReader(stream);
                    retu = reader.ReadToEnd().ToString();
                }
            }

            return(retu);
        }
        //Export / Import of Projects
        /// <summary>
        /// Export currently only supports 10 Subfolder
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public Boolean LoadBim360Projects(string filepath)
        {
            if (File.Exists(filepath))
            {
                for (int i = 0; i < 2; i++)
                {
                    using (var streamReader = new StreamReader(filepath))
                    {
                        //try different configs
                        CsvConfiguration csvconfig;
                        if (i == 0)
                        {
                            //CSV with current date config
                            csvconfig = new CsvConfiguration(CultureInfo.CurrentCulture)
                            {
                                HeaderValidated   = null,
                                MissingFieldFound = null,
                            };
                        }
                        else
                        {
                            //CSV with Invariant Config
                            csvconfig = new CsvConfiguration(CultureInfo.InvariantCulture)
                            {
                                HeaderValidated   = null,
                                MissingFieldFound = null,
                            };
                        }

                        //try each configuration
                        using (var csv = new CsvReader(streamReader, csvconfig))
                        {
                            //Maps the Header of the CSV Data to the class attributes
                            csv.Context.RegisterClassMap <UserDataMap>();

                            List <Bim360Project> output = new List <Bim360Project>();
                            //call the import
                            try
                            {
                                output = SerializationParser.LoadBim360ProjectsFromCsv(csv);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("Failed to import last template.");
                            }

                            //Sort in Data if read was successful
                            if (output != null)
                            {
                                projects = output;
                                ProjectsView.ItemsSource = projects;
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
 public void ExportBim360ProjectsToJson(string filepath)
 {
     using (var streamWriter = new StreamWriter(filepath))
     {
         //Maps the Header of the CSV Data to the class attributes
         var tmp = SerializationParser.ExportBim360ToJson(projects);
         if (tmp != null)
         {
             streamWriter.Write(tmp);
         }
     }
 }
 public void ExportBim360Projects(string filepath)
 {
     using (var streamWriter = new StreamWriter(filepath))
     {
         //maybe the CultureInfo needs to be changed
         using (var csv = new CsvWriter(streamWriter, CultureInfo.InvariantCulture))
         {
             //Maps the Header of the CSV Data to the class attributes
             var tmp = SerializationParser.ExportBim360ToCSV(projects);
             csv.Context.RegisterClassMap <UserDataExport>();
             if (tmp != null)
             {
                 csv.WriteRecords(tmp);
             }
         }
     }
 }
        /// <summary>
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public Boolean LoadBim360Projectsfromjson(string filepath)
        {
            if (File.Exists(filepath))
            {
                using (StreamReader r = new StreamReader(filepath))
                {
                    string json   = r.ReadToEnd();
                    var    output = SerializationParser.LoadBim360ProjectsFromJson(json);
                    //Sort in Data if read was successful
                    if (output != null)
                    {
                        projects = output;
                        ProjectsView.ItemsSource = projects;
                        return(true);
                    }
                }
            }

            return(false);
        }