public QuartzService()
 {
     InitializeComponent();
     logger = LogManager.GetLogger(GetType());
     ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
     scheduler = schedulerFactory.GetScheduler();
 }
Beispiel #2
1
        /// <summary>
        /// A simpler alternative to the irritatingly useless FileSystemWatcher
        /// </summary>
        /// <param name="file">The file to monitor</param>
        /// <param name="refreshPeriod">The refresh period.</param>
        /// <param name="scheduler">The scheduler.</param>
        /// <returns></returns>
        public static IObservable<FileNotification> WatchFile(this FileInfo file, TimeSpan? refreshPeriod = null,
            IScheduler scheduler = null)
        {
           return Observable.Create<FileNotification>(observer =>
            {
                var refresh = refreshPeriod ?? TimeSpan.FromMilliseconds(250);
                scheduler = scheduler ?? Scheduler.Default;

                FileNotification notification = null;
                return scheduler.ScheduleRecurringAction(refresh, () =>
                {
                    try
                    {
                        notification = notification == null
                            ? new FileNotification(file)
                            : new FileNotification(notification);

                        observer.OnNext(notification);
                    }
                    catch (Exception ex)
                    {
                        notification = new FileNotification(file, ex);
                        observer.OnNext(notification);
                    }
                });

            }).DistinctUntilChanged();
        }
 protected SchedulerTimelineViewBase(SchedulerViewType type, IScheduler scheduler) 
     : base(type, scheduler)
 {
     WorkDayCommand = true;
     Footer = true;
     ShowWorkHours = scheduler.ShowWorkHours;
 }
Beispiel #4
0
 public void OnException(IScheduler scheduler, Exception e)
 {
     // called whenever an exception occurs on Kayak's event loop.
     // this is good place for logging. here's a start:
     Console.WriteLine("Exception on scheduler");
     Console.Out.WriteStackTrace(e);
 }
Beispiel #5
0
 public RepoWatcher(IGithubBrowser browser, Repo repoToWatch, IScheduler backgroundScheduler)
 {
     _timerDisposal = Observable
         .Interval(_defaultRefreshSpan, backgroundScheduler)
         .SelectMany(_ => browser.GetCommits(repoToWatch))
         .Subscribe(OnCommitsArrived);
 }
Beispiel #6
0
 public FaxMessageService(IMessaggisticaService messaggisticaService, IScheduler scheduler, IConfigurationMessageService configurationService, IDaoFactory daoFactory)
 {
     _messaggisticaService = messaggisticaService;
     _scheduler = scheduler;
     _configurationService = configurationService;
     _daoFactory = daoFactory;
 }
        protected override void OnStart(string[] args)
        {
            Logger = LogManager.GetCurrentClassLogger();
            Logger.Info("Service Starting");

            ExporterTriggerList = new List<ITrigger>();
            ExporterDetailList = new List<IJobDetail>();

            if(Settings.Default.InvokeDebugger)
            {
                Logger.Info("Starting Debugger");
                Debugger.Launch();
            }

            try
            {
                Logger.Info("Starting Scheduler");
                Scheduler = StdSchedulerFactory.GetDefaultScheduler();
                Scheduler.Start();

                ConfigBaseDir = "C:\\SFTPExporter\\Configs\\";
                if(!System.IO.Directory.Exists(ConfigBaseDir))
                {
                    System.IO.Directory.CreateDirectory(ConfigBaseDir);
                }
            }
            catch(Exception ex)
            {
               Logger.Fatal("Failed to start service", ex);
               this.Stop();
            }
        }
Beispiel #8
0
 internal TestBlobCache(Action disposer, 
     IScheduler scheduler, 
     IEnumerable<KeyValuePair<string, byte[]>> initialContents)
     : this(scheduler, initialContents)
 {
     inner = Disposable.Create(disposer);
 }
        public JobSchedule()
        {
            var schedFact = new StdSchedulerFactory();

            sched = schedFact.GetScheduler();
            sched.Start();
        }
        public static void Main(string[] args)
        {
            //            XmlConfigurator.Configure();

               var properties = new NameValueCollection();
               properties["quartz.scheduler.instanceName"] = "ServerScheduler";

            // set thread pool info
            properties["quartz.threadPool.threadCount"] = "0";

            // set remoting expoter
            properties["quartz.scheduler.proxy"] = "true";
            properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";

            var scheduleFactory = new StdSchedulerFactory(properties);

            scheduler = scheduleFactory.GetScheduler();
            var md = scheduler.GetMetaData();
            scheduler.Start();

            IJobDetail job = JobBuilder.Create<Jobs.SimpleJob>().Build();

            ITrigger jobTrigger = new SimpleTriggerImpl("TenSecondTrigger", 20, new TimeSpan(0, 0, 0, 5));

            //Periodic scheduling
            scheduler.ScheduleJob(job,jobTrigger);

            //Trigger a job from elsewhere without a trigger for one time
            var jobKey = job.Key;
            var jobDataMap = job.JobDataMap;
            scheduler.TriggerJob(jobKey,jobDataMap);
        }
 public NotificationService(
     PhoneApplicationFrame RootFrame,
     [Dispatcher] IScheduler Dispatcher
     ) {
     RootFrame.Navigated += OnFrameNavigated;
     NotificationScheduler = Dispatcher;
 }
Beispiel #12
0
		public ThreadWorker (IScheduler sched, ThreadWorker[] others, IProducerConsumerCollection<Task> sharedWorkQueue,
		                     bool createThread, int maxStackSize, ThreadPriority priority, EventWaitHandle handle)
		{
			this.others          = others;

			this.dDeque = new CyclicDeque<Task> ();
			
			this.sharedWorkQueue = sharedWorkQueue;
			this.workerLength    = others.Length;
			this.isLocal         = !createThread;
			this.waitHandle      = handle;
			
			this.childWorkAdder = delegate (Task t) { 
				dDeque.PushBottom (t);
				sched.PulseAll ();
			};
			
			// Find the stealing start index randomly (then the traversal
			// will be done in Round-Robin fashion)
			do {
				this.stealingStart = r.Next(0, workerLength);
			} while (others[stealingStart] == this);
			
			InitializeUnderlyingThread (maxStackSize, priority);
		}
 public void SetUp()
 {
     _collector = Substitute.For<IItemCollector>();
     _scheduler = Substitute.For<IScheduler>();
     _loginModel = Substitute.For<ILoginModel>();
     _uut = new ScheduledShoppingListModel(_collector, _scheduler, _loginModel);
 }
 public LinkSpiderPipeline(string entityName, IScheduler nextSpiderScheduler, ISpider nextSpider, LinkSpiderPrepareStartUrls prepareStartUrls)
 {
     NextSpiderScheduler = nextSpiderScheduler;
     NextSpider = nextSpider;
     _prepareStartUrls = prepareStartUrls;
     _entityName = entityName;
 }
 public void Dispose()
 {
     scheduler.Shutdown(true);
     scheduler = null;
     hubProxy = null;
     Logger.loggerInternal = (m) => { Console.WriteLine(m); };
 }
 //public void Echo(string message)
 //{
 //    Console.WriteLine(message);
 //    hubProxy.Invoke("commandSent", string.Empty, message);
 //}
 private static void ConfigureScheduledEvents(IScheduler sched)
 {
     foreach (var trigger in GetTriggers())
     {
         sched.ScheduleJob(JobBuilder.Create<PublishEvent>().Build(), trigger);
     }
 }
Beispiel #17
0
		/// <summary>
		/// Create a JobRunShell instance with the given settings.
		/// </summary>
		/// <param name="jobRunShellFactory">A handle to the <see cref="IJobRunShellFactory" /> that produced
		/// this <see cref="JobRunShell" />.</param>
		/// <param name="scheduler">The <see cref="IScheduler" /> instance that should be made
		/// available within the <see cref="JobExecutionContext" />.</param>
		/// <param name="schdCtxt">the <see cref="SchedulingContext" /> that should be used by the
		/// <see cref="JobRunShell" /> when making updates to the <see cref="IJobStore" />.</param>
		public JobRunShell(IJobRunShellFactory jobRunShellFactory, IScheduler scheduler, SchedulingContext schdCtxt)
		{
			this.jobRunShellFactory = jobRunShellFactory;
			this.scheduler = scheduler;
			this.schdCtxt = schdCtxt;
            log = LogManager.GetLogger(GetType());
		}
Beispiel #18
0
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobDetail = bundle.JobDetail;
            var jobType = jobDetail.JobType;

            try
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug(string.Format(
                        CultureInfo.InvariantCulture,
                        "Producing instance of Job '{0}', class={1}", new object[] { jobDetail.Key, jobType.FullName }));
                }

                return typeof(IInterruptableJob).IsAssignableFrom(jobType)
                    ? new InterruptableJobWrapper(bundle, container)
                    : new JobWrapper(bundle, container);
            }
            catch (Exception ex)
            {
                throw new SchedulerException(string.Format(
                    CultureInfo.InvariantCulture,
                    "Problem instantiating class '{0}'", new object[] { jobDetail.JobType.FullName }), ex);
            }
        }
Beispiel #19
0
 private static void ScheduleJob(IScheduler scheduler)
 {
     const int INTERVAL_IN_SECONDS = 5;
     scheduler.ScheduleJob(
         JobBuilder.Create<YhdArchiveJob>().WithIdentity("YhdArchiveJob").Build(),
         TriggerBuilder.Create().WithIdentity("YhdArchiveTrigger").StartNow().WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(INTERVAL_IN_SECONDS)).Build());
 }
Beispiel #20
0
 public static void Build(IXpandJobTrigger trigger, IScheduler scheduler) {
     if (trigger.Calendar != null) {
         var calendar = (ICalendar)XafTypesInfo.Instance.FindTypeInfo(trigger.Calendar.CalendarTypeFullName).Type.CreateInstance();
         Initialize(calendar, trigger);
         scheduler.AddCalendar(trigger.Calendar.Name, calendar, true, true);
     }
 }
 public void Promoted(IServiceBus bus)
 {
     if (_scheduler != null && !_scheduler.IsShutdown) _scheduler.Shutdown();
     _scheduler = _schedulerFactory();
     _scheduler.JobFactory = new ServiceBusJobFactory(bus);
     _scheduler.Start();
 }
Beispiel #22
0
		public ThreadWorker (IScheduler sched, ThreadWorker[] others, IProducerConsumerCollection<Task> sharedWorkQueue,
		                     bool createThread, int maxStackSize, ThreadPriority priority)
		{
			this.others          = others;

//			if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("USE_CYCLIC"))) {
//				Console.WriteLine ("Using cyclic deque");
//				this.dDeque = new CyclicDeque<Task> ();
//			} else {
//				this.dDeque = new DynamicDeque<Task> ();
//			}
			this.dDeque = new CyclicDeque<Task> ();
			
			this.sharedWorkQueue = sharedWorkQueue;
			this.workerLength    = others.Length;
			this.isLocal         = !createThread;
			
			this.childWorkAdder = delegate (Task t) { 
				dDeque.PushBottom (t);
				sched.PulseAll ();
			};
			
			// Find the stealing start index randomly (then the traversal
			// will be done in Round-Robin fashion)
			do {
				this.stealingStart = r.Next(0, workerLength);
			} while (others[stealingStart] == this);
			
			InitializeUnderlyingThread (maxStackSize, priority);
		}
Beispiel #23
0
        static void Main(string[] args)
        {
            try
            {
                Console.Title = "QMail";
                Console.ForegroundColor = ConsoleColor.White;
                ISchedulerFactory sf = new StdSchedulerFactory();
                Scheduler = sf.GetScheduler();
                new TskInspectDetailJobTrigger();
                Scheduler.Start();

                for (var i = 0; i < 10; i++) {
                    Console.WriteLine();
                }

                Console.ForegroundColor = ConsoleColor.Yellow;

                Console.WriteLine("       ---------------------------------------------------");
                Console.WriteLine("       ...................QMail已启动......................");
                Console.WriteLine("       ...................请不要关闭此窗口.................");
                Console.WriteLine("       ---------------------------------------------------");
                for (var i = 0; i < 10; i++)
                {
                    Console.WriteLine();
                }
                Console.ReadLine();
            }
            catch (Exception e) {
                LogUtil.Logger.Error(e.Message);
            }
        }
 public void RemoveScheduler(IScheduler scheduler)
 {
     lock (_listLock)
     {
         _scheduleList.Remove(scheduler);
     }
 }
		public NotifyPropertyChangedBase(IScheduler scheduler) {
			if (scheduler != null) {
				this.scheduler = scheduler;
			} else {
				this.scheduler = Scheduler.Immediate;
			}
		}
Beispiel #26
0
 static TaskPool()
 {
     _taskpool = new TaskPool();
     ISchedulerFactory sf = new StdSchedulerFactory();
     _ische = sf.GetScheduler();
     _ische.Start();
 }
 public void AddScheduler(IScheduler scheduler)
 {
     lock (_listLock)
     {
         _scheduleList.Add(scheduler);
     }
 }
Beispiel #28
0
        public TaskCoordinator(IScheduler scheduler, Logger logger)
        {
            _logger = logger;
            _scheduler = scheduler;

            _logger.Info("TaskCoordincator started with scheduler: {0}", scheduler.SchedulerInstanceId);
        }
		public JobScheduler(IScheduler quartzScheduler, Logger logger, ISystemSettings systemSettings)
		{
			this._quartzScheduler = DIHelper.VerifyParameter(quartzScheduler);
			this._logger = DIHelper.VerifyParameter(logger);
			this._systemSettings = DIHelper.VerifyParameter(systemSettings);

		}
Beispiel #30
0
 internal DefaultKayakSocket(Socket socket, IScheduler scheduler)
 {
     this.id = nextId++;
     this.socket = new SocketWrapper(socket);
     this.scheduler = scheduler;
     state = new KayakSocketState(false);
 }
Beispiel #31
0
        /// <summary>
        /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
        /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
        /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
        /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="scheduler"/> is null.</exception>
        /// <remarks>This operator requires the source's <see cref="IQueryProvider"/> object (see <see cref="IQueryable.Provider"/>) to implement <see cref="IQbservableProvider"/>.</remarks>
        public static IQbservable <TSource> ToQbservable <TSource>(this IQueryable <TSource> source, IScheduler scheduler)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }

            return(((IQbservableProvider)source.Provider).CreateQuery <TSource>(
                       Expression.Call(
                           null,
#if CRIPPLED_REFLECTION
                           InfoOf(() => Qbservable.ToQbservable <TSource>(default(IQueryable <TSource>))),
#else
                           ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
#endif
                           source.Expression,
                           Expression.Constant(scheduler)
                           )
                       ));
        }
Beispiel #32
0
        public async Task <IActionResult> ExecutePyAsync(string id)
        {
            string zmkResponse = "";
            string filePath    = "";
            string reqBody     = "";

            try
            {
                //read cron information from the request body
                using (var reader = new StreamReader(Request.Body))
                {
                    var body = reader.ReadToEnd();
                    reqBody = body.ToString();
                }

                //
                foreach (var record in codeResponse)
                {
                    if (record.Id.ToString() == id)
                    {
                        filePath = record.FilePath;
                        break;
                    }
                }
                //
                if (!string.IsNullOrEmpty(filePath))
                {
                    zmkResponse = await pyCompileClient.ExecutePy(filePath, "");

                    var jsonObj = JsonConvert.DeserializeObject <ExecuteCodeResponse>(zmkResponse);
                    jsonObj.executedAt = DateTime.Now;
                    List <ExecuteCodeResponse> tresp = new List <ExecuteCodeResponse>();
                    tresp.Add(jsonObj);

                    JObject cronjson = JObject.Parse(reqBody);
                    if (cronjson["recurrence"].ToString() == "REPEAT")
                    {
                        //check if same job is scheduled
                        ISchedulerFactory schfack   = new StdSchedulerFactory();
                        IScheduler        scheduler = await schfack.GetScheduler();

                        var jobKey = new JobKey(filePath);
                        if (await scheduler.CheckExists(jobKey))
                        {
                            await scheduler.ResumeJob(jobKey);
                        }
                        else
                        {
                            #region create quartz job for execute code
                            ITrigger trigger = TriggerBuilder.Create()
                                               .WithIdentity($"Execute Code Job-{DateTime.Now}")
                                               .WithCronSchedule(cronjson["cronExpression"].ToString())
                                               .WithPriority(1)
                                               .Build();

                            IJobDetail job = JobBuilder.Create <ExecuteCodeJob>()
                                             .WithIdentity(filePath)
                                             .Build();

                            job.JobDataMap["id"]       = id;
                            job.JobDataMap["filePath"] = filePath;
                            job.JobDataMap["baseurl"]  = Configuration["PyServiceLocation:srvurl"];

                            await _scheduler.ScheduleJob(job, trigger);

                            //add to scheduler payload
                            SchedulerResponse schJob = new SchedulerResponse()
                            {
                                CreatedOn      = DateTime.Now.ToString(),
                                CronExpression = cronjson["cronExpression"].ToString(),
                                DateCreated    = DateTime.Now,
                                EditedOn       = DateTime.Now.ToString(),
                                FilePath       = filePath,
                                Id             = id,
                                Name           = id,
                                Type           = "PYTHON",
                                Url            = "",
                                Recurrence     = cronjson["recurrence"].ToString(),
                                StartDate      = (cronjson["startDate"] == null) ? "" : cronjson["startDate"].ToString(),
                                //cronjson["startDate"].ToString(),
                                StartTimeH = (cronjson["startTimeH"] == null) ? "" : cronjson["startTimeH"].ToString(),
                                StartTimeM = (cronjson["startTimeM"] == null) ? "" : cronjson["startTimeM"].ToString(),
                                // ZMKResponse = tresp.ToList<object>(),
                                History = tresp.ToList <object>()
                            };
                            SchedulerPayload.Create(schJob);
                            #endregion
                        }
                    }
                    else
                    {
                        //add history
                        JArray jHist = new JArray();
                        foreach (var r in tresp)
                        {
                            jHist.Add(new JObject()
                            {
                                { "idforData", r.idforData },
                                { "status", r.status },
                                { "executedAt", r.executedAt }
                            });
                        }
                        //add to scheduler payload
                        SchedulerResponse schJob = new SchedulerResponse()
                        {
                            CreatedOn      = DateTime.Now.ToString(),
                            CronExpression = "",
                            DateCreated    = DateTime.Now,
                            EditedOn       = DateTime.Now.ToString(),
                            FilePath       = filePath,
                            Id             = id,
                            Name           = id,
                            Type           = "PYTHON",
                            Url            = "",
                            Recurrence     = "ONE_TIME",
                            StartDate      = "",
                            StartTimeH     = "",
                            StartTimeM     = "",
                            // ZMKResponse = tresp.ToList<object>(),
                            Status  = "",
                            History = jHist.ToList <object>()
                        };


                        SchedulerPayload.Create(schJob);
                    }


                    return(Json(jsonObj));
                }
                else
                {
                    return(BadRequest(new { message = "File execution failed." }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = "File execution failed.", exception = ex.StackTrace }));
            }
        }
Beispiel #33
0
 public Lazy(IConnectableObservable <TSource> source, TimeSpan disconnectTime, IScheduler scheduler, int minObservers)
 {
     _source         = source;
     _gate           = new object();
     _disconnectTime = disconnectTime;
     _scheduler      = scheduler;
     _minObservers   = minObservers;
 }
Beispiel #34
0
 public TransactionTraceAggregator(IDataTransportService dataTransportService, IScheduler scheduler, IProcessStatic processStatic, IEnumerable <ITransactionCollector> transactionCollectors)
     : base(dataTransportService, scheduler, processStatic)
 {
     _transactionCollectors = transactionCollectors;
 }
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     return((IJob)this.resolutionRoot.Get(bundle.JobDetail.JobType));
 }
Beispiel #36
0
 protected AbstractSampler(IScheduler scheduler, TimeSpan frequency)
 {
     _scheduler = scheduler;
     _frequency = frequency;
 }
Beispiel #37
0
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     return(Container.GetService(bundle.JobDetail.JobType) as IJob);
 }
Beispiel #38
0
        public async Task <IActionResult> Post(List <IFormFile> file)
        {
            List <CodeResponse> response         = new List <CodeResponse>();
            List <CodeResponse> existingCodeData = new List <CodeResponse>();
            long   size = file.Sum(f => f.Length);
            bool   IsFileExists = false;
            string type, dirFullpath, nbPath, _url = string.Empty;
            // full path to file in temp location
            var filePath = Path.GetTempFileName();

            foreach (var formFile in file)
            {
                dirFullpath = DirectoryHelper.GetCodeDirectoryPath();
                #region type
                var fileExt = System.IO.Path.GetExtension(formFile.FileName).Substring(1);
                // upload file edn and start creating payload
                switch (fileExt.ToLower())
                {
                case "py":
                    type = "PYTHON";
                    break;

                case "ipynb":
                    type = "JUPYTER_NOTEBOOK";
                    break;

                case "r":
                    type = "R";
                    break;

                default:
                    type = "UNRECOGNIZED";
                    break;
                }
                #endregion
                if (formFile.Length > 0)
                {
                    //check if the file with the same name exists
                    existingCodeData = CodePayload.Get();
                    if (existingCodeData.Count > 0)
                    {
                        //
                        foreach (var record in existingCodeData)
                        {
                            if (record.Name == formFile.FileName)
                            {
                                IsFileExists = true;
                            }
                        }
                    }
                    existingCodeData.Clear();
                    //
                    if (!FilePathHelper.IsFileNameValid(formFile.FileName))
                    {
                        return(BadRequest("File name not valid."));
                    }
                    if (!IsFileExists)
                    {
                        #region upload large file > 400MB
                        if (size > 40000000)
                        {
                            Console.WriteLine(">>>>>>>>>>>>>>>>>>>>UPLOADING LARGE CODE FILE................................");
                            #region add to uploading
                            //
                            FilesInProgress wip = new FilesInProgress()
                            {
                                Id           = formFile.FileName,
                                CreatedAt    = DateTime.Now,
                                Name         = formFile.FileName,
                                Type         = type,
                                Module       = "CODE",
                                UploadStatus = "INPROGRESS"
                            };

                            FilesUploadingPayload.Create(wip);

                            #endregion
                            //check if same job is scheduled
                            ISchedulerFactory schfack   = new StdSchedulerFactory();
                            IScheduler        scheduler = await schfack.GetScheduler();

                            var jobKey = new JobKey(filePath);
                            if (await scheduler.CheckExists(jobKey))
                            {
                                await scheduler.ResumeJob(jobKey);
                            }
                            else
                            {
                                #region create quartz job for training model
                                ITrigger trigger = TriggerBuilder.Create()
                                                   .WithIdentity($"Uploading Code file-{DateTime.Now}")
                                                   .WithPriority(1)
                                                   .Build();

                                IJobDetail job = JobBuilder.Create <UploadJob>()
                                                 .WithIdentity(filePath)
                                                 .Build();

                                job.JobDataMap["id"]       = formFile.FileName.Replace($".{fileExt}", "");
                                job.JobDataMap["filePath"] = filePath;
                                await _scheduler.ScheduleJob(job, trigger);

                                #endregion
                            }
                        }
                        #endregion
                        if (fileExt.ToLower() == "ipynb")
                        {
                            dirFullpath = dirFullpath + formFile.FileName.Replace(".ipynb", "/");
                            _url        = DirectoryHelper.GetCodeUrl(formFile.FileName.Replace(".ipynb", string.Empty) + "/" + formFile.FileName);
                        }
                        else
                        {
                            _url = DirectoryHelper.GetCodeUrl(formFile.FileName);
                        }
                        nbPath = dirFullpath + formFile.FileName;

                        //check if folder path exists...if not then create folder
                        if (!Directory.Exists(dirFullpath))
                        {
                            Directory.CreateDirectory(dirFullpath);
                        }
                        // upload file start
                        using (var fileStream = new FileStream(Path.Combine(dirFullpath, formFile.FileName), FileMode.Create))
                        {
                            //check file allowed extensions
                            if (!extensions.Contains(fileExt.ToString().ToLower()))
                            {
                                return(BadRequest("File type not allowed"));
                            }

                            //file copy
                            await formFile.CopyToAsync(fileStream);

                            CodeResponse newRecord = new CodeResponse()
                            {
                                Id          = formFile.FileName.Replace("." + fileExt, ""),
                                Name        = formFile.FileName,
                                User        = "",
                                Created_on  = DateTime.Now.ToString(),
                                Edited_on   = DateTime.Now.ToString(),
                                Extension   = fileExt,
                                MimeType    = formFile.ContentType,
                                Size        = formFile.Length,
                                Type        = type,
                                Url         = _url,
                                FilePath    = nbPath,
                                DateCreated = DateTime.Now
                            };
                            CodePayload.Create(newRecord);
                            response.Add(newRecord);
                        }
                    }
                    else
                    {
                        return(Conflict(new { message = "File already exists.", error = "File already exists." }));
                    }
                }
                IsFileExists = false;
            }

            if (response.Count > 0)
            {
                return(Ok(response));
            }
            else
            {
                return(BadRequest("File already exists."));
            }
        }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            var jobDetail = bundle.JobDetail;

            return((IJob)_service.GetService(jobDetail.JobType));
        }
Beispiel #40
0
 public CodeController(IWebHostEnvironment environment, IConfiguration configuration, ILogger <CodeController> log, IPyJupyterServiceClient _jupyterClient, IPyCompile _pyCodeCompile, IScheduler factory)
 {
     //update
     _environment         = environment ?? throw new ArgumentNullException(nameof(environment));
     this.Configuration   = configuration;
     this.jupyterClient   = _jupyterClient;
     this.pyCompileClient = _pyCodeCompile;
     _scheduler           = factory;
     this.Logger          = log;
     this.BASEURLJUP      = Configuration["JupyterServer:srvurl"];
     try
     {
         codeResponse = CodePayload.Get().Where(c => c.Name.Contains("-checkpoint.ipynb") == false).ToList <CodeResponse>();
     }
     catch (Exception ex)
     {
         Logger.LogCritical(ex, ex.StackTrace);
     }
 }
Beispiel #41
0
 public SchedulerHost(IScheduler scheduler)
 {
     this._scheduler = scheduler as Scheduler;
 }
Beispiel #42
0
 public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
 {
     return(_serviceProvider.GetRequiredService(bundle.JobDetail.JobType) as IJob);
 }
Beispiel #43
0
 public QuartzService(ILogger <QuartzService> logger, IScheduler scheduler, OpenJobApp openJobApp)
 {
     _logger     = logger;
     _scheduler  = scheduler;
     _openJobApp = openJobApp;
 }
 public ModifyScheduleCommand(IScheduler schedule) : base(schedule)
 {
 }
Beispiel #45
0
 public Relative(TState initialState, Func <TState, bool> condition, Func <TState, TState> iterate, Func <TState, TResult> resultSelector, Func <TState, TimeSpan> timeSelector, IScheduler scheduler)
 {
     _initialState   = initialState;
     _condition      = condition;
     _iterate        = iterate;
     _resultSelector = resultSelector;
     _timeSelector   = timeSelector;
     _scheduler      = scheduler;
 }
Beispiel #46
0
 public SchedulerHost(IScheduler scheduler, ILogger <SchedulerHost> logger)
 {
     this._scheduler = scheduler as Scheduler;
     this._logger    = logger;
 }
Beispiel #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReplaySubject{T}" /> class with the specified window and scheduler.
 /// </summary>
 /// <param name="window">Maximum time length of the replay buffer.</param>
 /// <param name="scheduler">Scheduler the observers are invoked on.</param>
 /// <exception cref="ArgumentNullException"><paramref name="scheduler"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="window"/> is less than <see cref="TimeSpan.Zero"/>.</exception>
 public ReplaySubject(TimeSpan window, IScheduler scheduler)
 {
     _implementation = new ReplayByTime(window, scheduler);
 }
Beispiel #48
0
 public Absolute(TState initialState, Func <TState, bool> condition, Func <TState, TState> iterate, Func <TState, TResult> resultSelector, Func <TState, DateTimeOffset> timeSelector, IScheduler scheduler)
 {
     _initialState   = initialState;
     _condition      = condition;
     _iterate        = iterate;
     _resultSelector = resultSelector;
     _timeSelector   = timeSelector;
     _scheduler      = scheduler;
 }
Beispiel #49
0
        public static void RegisterNavigation <TView, TViewModel>(IScheduler mainThreadScheduler = null, IScheduler backgroundScheduler = null, IViewLocator viewLocator = null)
            where TView : IViewFor
            where TViewModel : class, IPageViewModel
        {
            var bgScheduler = mainThreadScheduler ?? RxApp.TaskpoolScheduler;
            var mScheduler  = backgroundScheduler ?? RxApp.MainThreadScheduler;
            var vLocator    = viewLocator ?? Locator.Current.GetService <IViewLocator>();

            Locator.CurrentMutable.Register(
                () => Activator.CreateInstance(typeof(TView), mScheduler, bgScheduler, vLocator),
                typeof(IViewFor <TViewModel>),
                "NavigationView");
        }
Beispiel #50
0
 public static IObservable <T> Sleep <T>(float duration, T value, IScheduler scheduler)
 {
     return(SleepInternal(duration, scheduler).Select(_ => default(T)).Stay(value));
 }
 public MyService(IScheduler scheduler) =>
Beispiel #52
0
 public static IObservable <T> Sleep <T>(this IObservable <T> self, float duration, IScheduler scheduler)
 {
     return(self.Concat(Sleep <T>(duration, scheduler)));
 }
 public CommandCompletionClient(ICommandCompletionClient commandCompletionClient, IScheduler scheduler = null)
 {
     _commandCompletionClient = commandCompletionClient;
     _scheduler = scheduler;
 }
Beispiel #54
0
 public static IObservable <Unit> Sleep(float duration, IScheduler scheduler)
 {
     return(SleepInternal(duration, scheduler));
 }
Beispiel #55
0
 public static NavigationView Initialise <TViewModel>(IScheduler mainThreadScheduler = null, IScheduler backgroundScheduler = null, IViewLocator viewLocator = null)
     where TViewModel : class, IPageViewModel
 {
     return(Initialize <TViewModel>(mainThreadScheduler, backgroundScheduler, viewLocator));
 }
Beispiel #56
0
 public ErrorTraceAggregator(IDataTransportService dataTransportService, IScheduler scheduler, IProcessStatic processStatic, IAgentHealthReporter agentHealthReporter)
     : base(dataTransportService, scheduler, processStatic)
 {
     _agentHealthReporter = agentHealthReporter;
     GetAndResetCollection();
 }
 public RescheduleJobUnitTests()
 {
     _jobMaker  = new TestJobMaker();
     _scheduler =
         new JobManagmentSystem.Scheduler.Scheduler(NullLogger <JobManagmentSystem.Scheduler.Scheduler> .Instance);
 }
Beispiel #58
0
 public QuartzService(IScheduler scheduler)
 {
     _logger    = LogManager.GetCurrentClassLogger();
     _scheduler = scheduler;
 }
Beispiel #59
0
        public MeterLogic(
            IDbLocal dbLocal,
            IMeterSrc <Model> srcData,
            ISewinQueue sewinQueue,
            IServiceSettings appInfo,
            IUserAttentions <Model> userAttentions,
            ICriticalStops <Model> criticalStops,
            IProgramState programState,
            IScheduler scheduler)
        {
            this.dbLocal         = dbLocal;
            this.sewinQueue      = sewinQueue;
            this.srcData         = srcData;
            this.appInfo         = appInfo;
            this.UserAttentions  = userAttentions;
            this.CriticalStops   = criticalStops;
            this.programState    = programState;
            programState.Saving += this.SaveState;
            this.Disposables     = new List <IDisposable>
            {
                Observable
                .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                    h => ((INotifyPropertyChanged)this.srcData).PropertyChanged += h,
                    h => ((INotifyPropertyChanged)this.srcData).PropertyChanged -= h)
                .Subscribe(args => this.OpcValueChanged(args.EventArgs.PropertyName)),

                Observable
                .Interval(TimeSpan.FromSeconds(1), scheduler)
                .Subscribe(_ =>
                {
                    this.Recipe       = this.srcData.Recipe;
                    this.IsManualMode = this.srcData.IsAutoMode;
                }),

                Observable
                .FromEvent(
                    h => this.sewinQueue.QueueChanged += h,
                    h => this.sewinQueue.QueueChanged -= h)
                .Subscribe(_ => this.SewinQueueChanged()),

                Observable
                .FromEventPattern <CancelEventHandler, CancelEventArgs>(
                    h => this.sewinQueue.CanRemoveRollQuery += h,
                    h => this.sewinQueue.CanRemoveRollQuery -= h)
                .Subscribe(args => args.EventArgs.Cancel    |= args.Sender == this.currentRoll),

                Observable
                .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                    h => ((INotifyPropertyChanged)this.UserAttentions).PropertyChanged += h,
                    h => ((INotifyPropertyChanged)this.UserAttentions).PropertyChanged -= h)
                .Subscribe(_ =>
                {
                    this.IsMapValid &= this.UserAttentions.Any;
                    this.IsChanged   = true;
                }),

                Observable
                .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                    h => ((INotifyPropertyChanged)this.CriticalStops).PropertyChanged += h,
                    h => ((INotifyPropertyChanged)this.CriticalStops).PropertyChanged -= h)
                .Subscribe(_ =>
                {
                    this.IsMapValid &= this.CriticalStops.Any;
                    this.IsChanged   = true;
                }),

                Observable
                .FromEventPattern <PropertyChangedEventHandler, PropertyChangedEventArgs>(
                    h => ((INotifyPropertyChanged)this.sewinQueue).PropertyChanged += h,
                    h => ((INotifyPropertyChanged)this.sewinQueue).PropertyChanged -= h)
                .Where(args => args.EventArgs.PropertyName == nameof(this.sewinQueue.Message))
                .Subscribe(args => this.QueueMessage = this.sewinQueue.Message),
            };
        }
Beispiel #60
0
        public static NavigationView Initialize <TViewModel>(IScheduler mainThreadScheduler = null, IScheduler backgroundScheduler = null, IViewLocator viewLocator = null)
            where TViewModel : class, IPageViewModel
        {
            var bgScheduler = mainThreadScheduler ?? RxApp.TaskpoolScheduler;
            var mScheduler  = backgroundScheduler ?? RxApp.MainThreadScheduler;
            var vLocator    = viewLocator ?? Locator.Current.GetService <IViewLocator>();

            var navigationView   = new NavigationView(mScheduler, bgScheduler, vLocator);
            var viewStackService = new ViewStackService(navigationView);

            Locator.CurrentMutable.Register <IViewStackService>(() => viewStackService);
            navigationView.PushPage(Activator.CreateInstance(typeof(TViewModel), viewStackService) as TViewModel, null, true, false).Subscribe();

            return(navigationView);
        }