Ejemplo n.º 1
0
        public static int Update(UpdateScriptOptions opts)
        {
            try
            {
                Console.WriteLine("Reading script {0}", opts.ScriptPath);

                var scriptSource = File.ReadAllText(opts.ScriptPath);

                //Console.WriteLine(scriptSource);

                using (var directory = new Data.DirectoryContext())
                {
                    var source = directory.OpenDataSources.First(s => s.ID == opts.ID);

                    Console.WriteLine("Saving script to OpenDataSource: '{0}'", source.Name);

                    source.ImportScript = scriptSource;

                    return(directory.SaveChanges());
                }
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine("File not found");
                return(1);
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine("Invalid OpenDataSource ({0})", opts.ID);
                return(2);
            }
        }
Ejemplo n.º 2
0
        public static int Info(InfoOptions opts)
        {
            using (var directory = new Data.DirectoryContext())
            {
                var source = directory.OpenDataSources.First(s => s.ID == opts.ID);
                var json   = JsonConvert.SerializeObject(source, Formatting.Indented);

                Console.WriteLine(json);
            }

            return(0);
        }
Ejemplo n.º 3
0
        public static int List(ListOptions opts)
        {
            using (var directory = new Data.DirectoryContext())
            {
                var sources = from s in directory.OpenDataSources
                              select s;

                foreach (var s in sources)
                {
                    Console.WriteLine("{0}: {1} - {2}", s.ID, s.Name, s.Description);
                }
            }

            return(0);
        }