Ejemplo n.º 1
0
        T ReadObject <T>(string table, string id)
        {
            T obj = default(T);
            SqliteConnection conn = new SqliteConnection("URI=file:" + dbFile);

            using (var cmd = conn.CreateCommand())
            {
                conn.Open();
                cmd.CommandText = String.Format("SELECT Data FROM {0} WHERE ID= '{1}'", table, id);
                using (var reader = cmd.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        byte[] data = GetBytes(reader);
                        using (MemoryStream stream = new MemoryStream(data)) {
                            obj = SerializableObject.Load <T>(stream);
                        }
                    }
                    else
                    {
                        Log.Error("Project with ID " + id + "not found in table " + table);
                    }
                }
            }
            conn.Close();
            return(obj);
        }
Ejemplo n.º 2
0
        public static void ConvertTeamTemplate(string inputPath, string outputPath)
        {
            TeamTemplate team = SerializableObject.Load <TeamTemplate> (inputPath,
                                                                        SerializationType.Binary);
            var newteam = ConvertTeamTemplate(team, null);

            outputPath = FixPath(outputPath);
            LongoMatch.Core.Common.Serializer.Save(newteam, outputPath);
        }
Ejemplo n.º 3
0
        public Project GetProject(Guid id)
        {
            string path = Path.Combine(project_path, id.ToString());

            if (File.Exists(path))
            {
                return(SerializableObject.Load <Project>(path));
            }
            return(null);
        }
Ejemplo n.º 4
0
 public static Project Import(string file)
 {
     try {
         return(SerializableObject.Load <Project>(file));
     }
     catch (Exception e) {
         Log.Exception(e);
         throw new Exception(Catalog.GetString("The file you are trying to load " +
                                               "is not a valid project"));
     }
 }
Ejemplo n.º 5
0
        public static void ConvertCategories(string inputPath, string outputPath)
        {
            Categories cats = SerializableObject.Load <Categories> (inputPath,
                                                                    SerializationType.Binary);
            Dictionary <TagSubCategory, List <LongoMatch.Core.Store.Tag> > ignore1;
            Dictionary <Category, LongoMatch.Core.Store.EventType>         ignore2;
            var dashboard = ConvertCategories(cats, out ignore1, out ignore2);

            outputPath = FixPath(outputPath);
            LongoMatch.Core.Common.Serializer.Save(dashboard, outputPath);
        }
Ejemplo n.º 6
0
        public List <ProjectDescription> GetAllProjects()
        {
            List <ProjectDescription> list = new List <ProjectDescription>();

            foreach (string path in Directory.GetFiles(desc_path))
            {
                if (File.Exists(Path.Combine(project_path, Path.GetFileName(path))))
                {
                    list.Add(SerializableObject.Load <ProjectDescription>(path));
                }
            }
            return(list);
        }
Ejemplo n.º 7
0
        public void TestCase()
        {
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "default.ltt";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName)) {
                TeamTemplate template = SerializableObject.Load <TeamTemplate> (stream, SerializationType.Binary);
                var          cstream  = new MemoryStream();
                SerializableObject.Save(template, cstream, SerializationType.Json);
                cstream.Seek(0, SeekOrigin.Begin);
                var jsonString = new StreamReader(cstream).ReadToEnd();
                Console.WriteLine(jsonString);
            }
        }
Ejemplo n.º 8
0
        public static void Load()
        {
            if (File.Exists(Config.ConfigFile))
            {
                Log.Information("Loading config from " + Config.ConfigFile);
                try {
                    state = SerializableObject.Load <ConfigState>(Config.ConfigFile, SerializableObject.SerializationType.Xml);
                } catch (Exception ex) {
                    Log.Error("Error loading config");
                    Log.Exception(ex);
                }
            }

            if (state == null)
            {
                Log.Information("Creating new config at " + Config.ConfigFile);
                state = new ConfigState();
                Save();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Retrieve all the projects from the database. This method don't return the
        /// the whole <see cref="LongoMatch.DB.Project"/> but the projects fields to
        /// create a <see cref="LongoMatch.DB.ProjectDescription"/> to make the seek
        /// faster.
        /// </summary>
        /// <returns>
        /// A <see cref="List"/>
        /// </returns>
        public List <ProjectDescription> GetAllProjects()
        {
            List <ProjectDescription> list = new List <ProjectDescription>();
            SqliteConnection          conn = new SqliteConnection("URI=file:" + dbFile);

            using (var cmd = conn.CreateCommand())
            {
                conn.Open();
                cmd.CommandText = "SELECT * FROM projects_desc";
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        byte[] data = GetBytes(reader);
                        using (MemoryStream stream = new MemoryStream(data)) {
                            list.Add(SerializableObject.Load <ProjectDescription>(stream));
                        }
                    }
                }
            }
            conn.Close();
            return(list);
        }
Ejemplo n.º 10
0
 public static TeamTemplate Load(string filePath)
 {
     return(SerializableObject.Load <TeamTemplate>(filePath));
 }
Ejemplo n.º 11
0
 public static Categories Load(string filePath)
 {
     return(SerializableObject.Load <Categories>(filePath));
 }
Ejemplo n.º 12
0
 public static SubCategoryTemplate Load(string filePath)
 {
     return(SerializableObject.Load <SubCategoryTemplate>(filePath));
 }