Ejemplo n.º 1
0
        public Task Execute(IJobExecutionContext context)
        {
            if (!ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy)
            {
                try
                {
                    if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.Capture)
                    {
                        if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.Bracketing)
                        {
                            var _bracketingViewModel = new BracketingViewModel();
                            Task.Factory.StartNew(new Action(_bracketingViewModel.Start));
                            StaticHelper.Instance.SystemMessage = _bracketingViewModel.Error;
                        }
                        else
                        {
                            ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.Capture);
                        }
                    }
                    if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.CaptureAll)
                    {
                        ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.CaptureAll);
                    }
                    if (ServiceProvider.Settings.DefaultSession.TimeLapseSettings.CaptureScript)
                    {
                        if (Path.GetExtension(ServiceProvider.Settings.DefaultSession.TimeLapseSettings.ScriptFile.ToLower()) == ".tcl")
                        {
                            try
                            {
                                var manager = new TclScripManager();
                                manager.Execute(File.ReadAllText(ServiceProvider.Settings.DefaultSession.TimeLapseSettings.ScriptFile));
                            }
                            catch (Exception exception)
                            {
                                Log.Error("Script error", exception);
                                StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                            }
                        }
                        else
                        {
                            var script = ServiceProvider.ScriptManager.Load(ServiceProvider.Settings.DefaultSession.TimeLapseSettings.ScriptFile);
                            script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                            ServiceProvider.ScriptManager.Execute(script);
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Timelapse error ", exception);
                    StaticHelper.Instance.SystemMessage = "Capture error";
                }
            }

            //throw new NotImplementedException();
            Console.WriteLine("Hello, JOb executed");
            return(Task.FromResult(0));
        }
Ejemplo n.º 2
0
        private void CheckForUpdate()
        {
            var scriptFile = ServiceProvider.Settings.StartupScript;

            if (scriptFile != null && File.Exists(scriptFile))
            {
                if (Path.GetExtension(scriptFile.ToLower()) == ".tcl")
                {
                    try
                    {
                        var manager = new TclScripManager();
                        manager.Execute(File.ReadAllText(scriptFile));
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Script error", exception);
                        StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                    }
                }
                else
                {
                    var script = ServiceProvider.ScriptManager.Load(scriptFile);
                    script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                    ServiceProvider.ScriptManager.Execute(script);
                }
            }
            if ((DateTime.Now - ServiceProvider.Settings.LastUpdateCheckDate).TotalDays > 7)
            {
                if (!ServiceProvider.Branding.CheckForUpdate)
                {
                    return;
                }

                Thread.Sleep(2000);
                ServiceProvider.Settings.LastUpdateCheckDate = DateTime.Now;
                ServiceProvider.Settings.Save();
                Dispatcher.Invoke(new Action(() => NewVersionWnd.CheckForUpdate(false)));
            }
            else
            {
                if (!ServiceProvider.Branding.ShowWelcomeScreen || !ServiceProvider.Branding.OnlineReference)
                {
                    return;
                }

                // show welcome screen only if not start minimized
                if (!ServiceProvider.Settings.StartMinimized)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        var wnd = new Welcome();
                        wnd.ShowDialog();
                    }));
                }
            }
        }
Ejemplo n.º 3
0
        private void StartupThread()
        {
            foreach (var cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
            {
                Log.Debug("cameraDevice_CameraInitDone 1");
                var          property = cameraDevice.LoadProperties();
                CameraPreset preset   = ServiceProvider.Settings.GetPreset(property.DefaultPresetName);
                // multiple canon cameras block with this settings

                if ((cameraDevice is CanonSDKBase && ServiceProvider.Settings.LoadCanonTransferMode) || !(cameraDevice is CanonSDKBase))
                {
                    cameraDevice.CaptureInSdRam = property.CaptureInSdRam;
                }

                Log.Debug("cameraDevice_CameraInitDone 1a");
                if (ServiceProvider.Settings.SyncCameraDateTime)
                {
                    try
                    {
                        cameraDevice.DateTime = DateTime.Now;
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Unable to sysnc date time", exception);
                    }
                }
                if (preset != null)
                {
                    try
                    {
                        Thread.Sleep(500);
                        cameraDevice.WaitForCamera(5000);
                        preset.Set(cameraDevice);
                    }
                    catch (Exception e)
                    {
                        Log.Error("Unable to load default preset", e);
                    }
                }
            }
            var scriptFile = ServiceProvider.Settings.StartupScript;

            if (scriptFile != null && File.Exists(scriptFile))
            {
                if (Path.GetExtension(scriptFile.ToLower()) == ".tcl")
                {
                    try
                    {
                        var manager = new TclScripManager();
                        manager.Execute(File.ReadAllText(scriptFile));
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Script error", exception);
                        StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                    }
                }
                else
                {
                    var script = ServiceProvider.ScriptManager.Load(scriptFile);
                    script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                    ServiceProvider.ScriptManager.Execute(script);
                }
            }
            if ((DateTime.Now - ServiceProvider.Settings.LastUpdateCheckDate).TotalDays > 7)
            {
                if (!ServiceProvider.Branding.CheckForUpdate)
                {
                    return;
                }

                Thread.Sleep(2000);
                ServiceProvider.Settings.LastUpdateCheckDate = DateTime.Now;
                ServiceProvider.Settings.Save();
                Dispatcher.Invoke(new Action(() => NewVersionWnd.CheckForUpdate(false)));
            }
            else
            {
                if (!ServiceProvider.Branding.ShowWelcomeScreen || !ServiceProvider.Branding.OnlineReference)
                {
                    return;
                }

                // show welcome screen only if not start minimized
                if (!ServiceProvider.Settings.StartMinimized)
                {
                    Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            var wnd = new Welcome();
                            wnd.ShowDialog();
                        }
                        catch
                        {
                        }
                    });
                }
            }
        }
Ejemplo n.º 4
0
 void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (!IsActive)
     {
         IsActive = CheckStart();
         if (IsActive)
         {
             _firstLapseStartTime = DateTime.Now;
         }
     }
     RaisePropertyChanged(() => StatusText);
     if (!IsActive)
     {
         return;
     }
     if (IsActive)
     {
         if (Math.Round((DateTime.Now - _lastCaptureTime).TotalSeconds) >= TimeBetweenShots || (FullSpeed && !ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy))
         {
             _lastCaptureTime = DateTime.Now;
             _totalCaptures++;
             try
             {
                 if (Capture)
                 {
                     ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.Capture);
                 }
                 if (CaptureAll)
                 {
                     ServiceProvider.WindowsManager.ExecuteCommand(CmdConsts.CaptureAll);
                 }
                 if (CaptureScript)
                 {
                     if (Path.GetExtension(ScriptFile.ToLower()) == ".tcl")
                     {
                         try
                         {
                             var manager = new TclScripManager();
                             manager.Execute(File.ReadAllText(ScriptFile));
                         }
                         catch (Exception exception)
                         {
                             Log.Error("Script error", exception);
                             StaticHelper.Instance.SystemMessage = "Script error :" + exception.Message;
                         }
                     }
                     else
                     {
                         var script = ServiceProvider.ScriptManager.Load(ScriptFile);
                         script.CameraDevice = ServiceProvider.DeviceManager.SelectedCameraDevice;
                         ServiceProvider.ScriptManager.Execute(script);
                     }
                 }
             }
             catch (Exception exception)
             {
                 Log.Error("Timelapse error ", exception);
                 StaticHelper.Instance.SystemMessage = "Capture error";
             }
         }
         if (CheckStop())
         {
             IsActive = false;
             if (!StartDaily)
             {
                 IsRunning = false;
                 _timer.Stop();
             }
         }
     }
 }