Beispiel #1
0
        public ActionResult Index()
        {
            var settings = new SettingsModel();

            settings.TempDir     = _configProvider.GetValue("TempDir", "download", true);
            settings.CompleteDir = _configProvider.GetValue("CompleteDir", "complete", true);

            return(View(settings));
        }
 public SearchClientProxy(string authorizationHeader, IConfigProvider configProvider)
 {
     _configProvider = configProvider;
     _cotorraUri     = _configProvider.GetValue("CotorraService");
     //var graph = _configProvider.GetValue("GraphqlEndpoint");
     _grapqhlEndpoint     = _cotorraUri + "graphql";
     _authorizationHeader = authorizationHeader;
 }
 /// <summary>
 /// Generates files with the set of URLs.
 /// </summary>
 /// <param name="configProvider">Provides tool configuration.</param>
 /// <param name="prototype">Model of prototype with informations about callable actions.</param>
 public void GenerateBenchmark(IConfigProvider configProvider, Prototype prototype)
 {
     _configProvider   = configProvider;
     _prototype        = prototype;
     _outputPathFolder = _configProvider.GetValue("BenchmarkFileOutput");
     foreach (var api in _prototype.Applications.OfType <RestApiApplication>())
     {
         PrintEndpoints(api);
     }
 }
Beispiel #4
0
        private ImportStatus AddLocalFile(NzbImportModel import)
        {
            //Determine if the file is a RAW NZB (or is zipped, gzipped, rarred) and then Import

            if (!_disk.FileExists(import.Location))
            {
                Logger.Error("NZB: {0} does not exist", import.Location);
                return(ImportStatus.Invalid);
            }

            import.Name   = _disk.SimpleFilename(import.Location); //Get the Filename without path or Extension
            import.Stream = _disk.OpenAsStream(import.Location);   //Get the NZB as a stream

            if (import.Stream == null)
            {
                return(ImportStatus.Failed);
            }

            var nzb = _parse.Process(import);

            if (nzb == null) //If its null return
            {
                return(ImportStatus.Invalid);
            }

            //Run PreQueue if one is set
            if (!String.IsNullOrEmpty(_config.GetValue("PreQueueScript", String.Empty, false)))
            {
                if (!_preQueue.Run(nzb))
                {
                    return(ImportStatus.Rejected);                     //Return rejected status if NZB is not wanted due to PreQueue
                }
            }

            var position = _queue.AllItems().Count(q => (int)q.Priority >= (int)import.Priority); //Find all items with a higher or equal priority and insert it at that point (zero-indexed list mataches perfectly)

            _queue.Insert(nzb, position);                                                         //Do the insert!
            _nntp.Connect();                                                                      //Start Downloading if not already doing so

            return(ImportStatus.Ok);
        }
Beispiel #5
0
 private void CleanOutput()
 {
     System.IO.DirectoryInfo di = new DirectoryInfo(_configProvider.GetValue("OutputFolderPath"));
     if (!di.Exists)
     {
         return;
     }
     foreach (FileInfo file in di.GetFiles())
     {
         file.Delete();
     }
 }
            public int GetInt(string key, int defaultValue = default)
            {
                try
                {
                    var v = _factory.GetValue(_authType, key);

                    return(v.ToInt(defaultValue));
                }
                catch (Exception e)
                {
                    return(defaultValue);
                }
            }
Beispiel #7
0
        public DataLayerManager(IConfigProvider configProvider, Prototype prototype) : base("DotNet46", configProvider.GetValue("OutputFolderPath") + "\\" + "DataLayer", configProvider.GetValue("OutputFolderPath") + "\\" + "DataLayer", configProvider, prototype)
        {
            DataLayer = new ApplicationGenerator(configProvider.GetValue("OutputFolderPath") + "\\" + "DataLayer");
            Container.Kernel.Resolver.AddSubResolver(new CollectionResolver(Container.Kernel, true));

            RegisterDataLayer(prototype, Container);
            var dataLayerHandlers = Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile));
            List <IGenerableFile> dataLayerFiles = ProjectFactory.ResolveHandlers(dataLayerHandlers, Container, NamingConstants.DataLayerProjectName);

            InitDataLayer(dataLayerFiles, Container);
            RegisterSolutionItems();


            var allFiles = ProjectFactory.ResolveHandlers(Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile)), Container);

            DataLayer.Files.AddRange(allFiles);
        }
Beispiel #8
0
        public bool Send(NzbModel nzb)
        {
            //Get the Template
            //Get SMTP Server Information, To/From Address, etc

            var  toAddress      = _config.GetValue("EmailToAddress", String.Empty, false);
            var  fromAddress    = _config.GetValue("EmailFromAddress", String.Empty, false);
            var  host           = _config.GetValue("SmtpServerHost", String.Empty, false);
            int  port           = Convert.ToInt32(_config.GetValue("SmtpServerPort", "25", true));
            bool ssl            = Convert.ToBoolean(_config.GetValue("SmtpServerSsl", "0", true));
            bool authentication = Convert.ToBoolean(_config.GetValue("SmtpServerAthentication", "0", true));
            var  username       = _config.GetValue("SmtpServerUsername", String.Empty, false);
            var  password       = _config.GetValue("SmtpServerPassword", String.Empty, false);

            MailMessage email = new MailMessage(); //Create a new MailMessage named email

            email.To.Add(toAddress);
            email.From = new MailAddress(fromAddress); //Create a new MailAddress for the senders address;

            //Todo: Need to Build these from a template
            email.Subject = String.Empty;         //Set the subject of the email
            email.Body    = String.Empty;         //set the body of the email

            SmtpClient client = new SmtpClient(); //Create a new SMTP client

            client.Host = host;                   //Set the host for the client
            client.Port = port;                   //Set the port for the client

            try
            {
                client.Send(email); //Try to send the message
            }

            catch (Exception ex)
            {
                Logger.DebugException(ex.Message, ex);
                return(false);
            }

            //return true;
            throw new NotImplementedException("Email Provider - Send");
        }
Beispiel #9
0
        public static ClientAdapter GetAdapterFromConfig(IConfigProvider iConfigProvider)
        {
            try
            {
                if (null == _clientProvider)
                {
                    string configAdapterValue = iConfigProvider.GetValue("clientCotorraAdapter");
                    ClientConfiguration.ClientAdapter adapter;
                    Enum.TryParse(configAdapterValue, out adapter);
                    _clientProvider = adapter;
                }

                return((ClientAdapter)_clientProvider);
            }
            catch
            {
                //Retorna adapter default si falla lectura de archivo de configuración
                return(ClientConfiguration.ClientAdapter.Proxy);
            }
        }
 public static TValue GetValue <TValue>(this IConfigProvider config, string path,
                                        TValue defaultValue = default(TValue))
 {
     return(config.GetValue(new Uri(path, UriKind.RelativeOrAbsolute), defaultValue));
 }
 public OverdraftDTOClientProxy(string authorizationHeader, IConfigProvider configProvider)
 {
     _configProvider      = configProvider;
     _cotorraUri          = $"{_configProvider.GetValue("CotorraService")}api/Overdraft";
     _authorizationHeader = authorizationHeader;
 }
Beispiel #12
0
 public List <string> AllScripts()
 {
     //Return All Files located in Script Dir (Found in Config)
     return(_disk.GetFiles(_config.GetValue("ScriptDir", "scripts", true), "", SearchOption.TopDirectoryOnly).ToList());
 }
Beispiel #13
0
        public bool Run(NzbModel nzb)
        {
            //Run The Pre-Queue Script

            var script    = _config.GetValue("PreQueueScript", String.Empty, false);
            var scriptDir = _config.GetValue("ScriptDir", "scripts", true);

            //CHeck if the script dir contains / or \ if not it is a relevant path

            var scriptPath = scriptDir + Path.DirectorySeparatorChar + script;

            //If the script isn't on disk, then return true (Better to Accept than reject)
            if (!_disk.FileExists(scriptPath))
            {
                return(true);
            }

            //1 : Name of the NZB (no path, no ".nzb")
            //2 : PP (0, 1, 2 or 3)
            //3 : Category
            //4 : Script (no path)
            //5 : Priority (-100, -1, 0 or 1 meaning Default, Low, Normal, High)
            //6 : Size of the download (in bytes)
            //7 : Group list (separated by spaces)
            //8 : Show name
            //9 : Season (1..99)
            //10 : Episode (1..99)
            //11: Episode name

            string groups = String.Join(" ", nzb.Files[0].Groups.ToArray());

            var arguments = String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}", GetStringForArgument(nzb.Name), nzb.PostProcessing, nzb.Category, nzb.Script, nzb.Priority, nzb.Size,
                                          groups, nzb.ShowName, nzb.SeasonNumber, nzb.EpisodeNumber, nzb.EpisodeName);

            var process = new Process();

            process.StartInfo.UseShellExecute        = false; //Must be false to redirect the output
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.FileName  = scriptPath;
            process.StartInfo.Arguments = arguments;
            process.Start();       //Start the Process
            process.WaitForExit(); //Wait for the Process to Exit

            int    lineNumber = 0;
            string line;

            while ((line = process.StandardOutput.ReadLine()) != null)
            {
                if (lineNumber == 0)
                {
                    if (!Convert.ToBoolean(line))
                    {
                        return(false);                          //If set to Refuse then return false
                    }
                }

                if (lineNumber == 1)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        nzb.Name = line;
                    }
                }

                if (lineNumber == 2)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        nzb.PostProcessing = (PostProcessing)Convert.ToInt32(line);
                    }
                }

                if (lineNumber == 3)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        nzb.Category = line;
                    }
                }

                if (lineNumber == 4)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        nzb.Script = line;
                    }
                }

                if (lineNumber == 5)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        nzb.Priority = (Priority)Convert.ToInt32(line);
                    }
                }

                if (lineNumber == 6)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        //Set each File for this NZB to have the group set to line
                        foreach (var file in nzb.Files)
                        {
                            file.Groups.Clear();
                            file.Groups.Add(line);
                        }
                    }
                }

                if (lineNumber > 6)
                {
                    break;
                }

                lineNumber++;
            }
            return(true);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="application">Application to be managed.</param>
        /// <param name="prototype">Whole prototype with entities and resources.</param>
        /// <param name="configProvider">Configuration provider.</param>
        public WebApiManager(RestApiApplication application, Prototype prototype, IConfigProvider configProvider) : base(new ApplicationGenerator <RestApiApplication>(application, configProvider.GetValue("OutputFolderPath") + "\\" + application.Name), prototype, "DotNet46", configProvider.GetValue("OutputFolderPath") + "\\" + application.Name, configProvider.GetValue("OutputFolderPath") + "\\" + application.Name
                                                                                                                         , configProvider)
        {
            Container.Kernel.Resolver.AddSubResolver(new CollectionResolver(Container.Kernel, true));

            var operations = Utils.FindAllInstances <Operation>(application);
            var actions    = Utils.FindAllInstances <Action>(application);


            RegisterDataLayer(application, prototype, operations, Container);
            var dataLayerHandlers = Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile));

            RegisterBusinessLayer(actions, Container);
            var businessLayerHandlers = Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile)).Except(dataLayerHandlers).ToArray();

            RegisterApiLayer(actions);
            var apiLayerHandlers = Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile)).Except(dataLayerHandlers).Except(businessLayerHandlers).ToArray();

            RegisterSolutionItems(application);

            List <IGenerableFile> dataLayerFiles     = ProjectFactory.ResolveHandlers(dataLayerHandlers, Container, NamingConstants.DataLayerProjectName);
            List <IGenerableFile> businessLayerFiles = ProjectFactory.ResolveHandlers(businessLayerHandlers, Container, NamingConstants.BusinessLayerProjectName);
            List <IGenerableFile> apiLayerFiles      = ProjectFactory.ResolveHandlers(apiLayerHandlers, Container, NamingConstants.ApiLayerProjectName);

            InitDataLayer(dataLayerFiles, Container);
            InitBusinessLayer(businessLayerFiles, Container);
            InitApiLayer(apiLayerFiles, Container);

            var allFiles = ProjectFactory.ResolveHandlers(Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile)), Container);

            ApplicationGenerator.Files.AddRange(allFiles);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="application">Application to be managed.</param>
        /// <param name="prototype">Whole prototype with entities and resources.</param>
        /// <param name="configProvider">Configuration provider.</param>
        public WebJobManager(WorkerApplication application, Prototype prototype, IConfigProvider configProvider) : base(new ApplicationGenerator <WorkerApplication>(application, configProvider.GetValue("OutputFolderPath") + "\\" + application.Name), prototype, "DotNet46", configProvider.GetValue("OutputFolderPath") + "\\" + application.Name, configProvider.GetValue("OutputFolderPath") + "\\" + application.Name
                                                                                                                        , configProvider)
        {
            Container.Kernel.Resolver.AddSubResolver(new CollectionResolver(Container.Kernel, true));


            var operations = Utils.FindAllInstances <Operation>(application);
            var actions    = Utils.FindAllInstances <Action>(application);

            ProjectFactory.RegisterOperations(NamingConstants.WorkerName, actions, Container);
            ProjectFactory.RegisterEntities(NamingConstants.WorkerName, application, prototype, Container);
            ProjectFactory.RegisterResources(NamingConstants.WorkerName, application, prototype, operations, Container);

            RegisterWorkerComponents(application, prototype);
            var handlers = Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile));

            List <IGenerableFile> consoleProjectFiles = ProjectFactory.ResolveHandlers(handlers, Container, NamingConstants.WorkerName);

            InitConsoleProject(consoleProjectFiles, Container);

            RegisterSolutionFiles(application);

            var allFiles = ProjectFactory.ResolveHandlers(Container.Kernel.GetAssignableHandlers(typeof(IGenerableFile)), Container);

            ApplicationGenerator.Files.AddRange(allFiles);
        }
 public PreviewerClientProxy(string authorizationHeader, IConfigProvider configProvider)
 {
     _configProvider      = configProvider;
     _cotorraUri          = $"{_configProvider.GetValue("CotorraService")}api/Preview";
     _authorizationHeader = authorizationHeader;
 }
Beispiel #17
0
 public EmployeeDTOClientProxy(string authorizationHeader, IConfigProvider configProvider)
 {
     _configProvider      = configProvider;
     _cotorraUri          = $"{_configProvider.GetValue("CotorraService")}api/payroll/Employee";
     _authorizationHeader = authorizationHeader;
 }