Example #1
0
 public static string ExecuteTransformPlugins(FileItem item, AutoExportPluginConfig configData, string outfile,
                                              bool preview = false)
 {
     File.Copy(preview ? item.LargeThumb : item.FileName, outfile, true);
     if (configData.ConfigDataCollection == null || configData.ConfigDataCollection.Count == 0)
     {
         return(outfile);
     }
     foreach (var enumerator in configData.ConfigDataCollection)
     {
         try
         {
             var plugin = enumerator["TransformPlugin"];
             var tp     = ServiceProvider.PluginManager.GetImageTransformPlugin(plugin);
             if (tp != null)
             {
                 outfile = tp.Execute(item, outfile, outfile, enumerator);
             }
         }
         catch (Exception exception)
         {
             Log.Error("Error execute transform olugin ", exception);
         }
     }
     return(outfile);
 }
        public void Send(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                var filename = item.FileName;
                configData.IsRedy = false;
                configData.IsError = false;
                var conf = new DropboxViewModel(configData);

                var outfile = PhotoUtils.ReplaceExtension(Path.GetTempFileName(), Path.GetExtension(item.Name));
                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                conf.Upload(outfile, ServiceProvider.Settings.DefaultSession.Name, item.Name);

                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error send dropbox file", exception);
                configData.IsError = true;
                configData.Error = exception.Message;
            }
            configData.IsRedy = true;
        }
        public void Send(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                var filename = item.FileName;
                configData.IsRedy = false;
                configData.IsError = false;
                var conf = new FacebookPluginViewModel(configData, false);

                var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(filename));
                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                conf.UploadFile(outfile);

                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error send facebook file", exception);
                configData.IsError = true;
                configData.Error = exception.Message;
            }
            configData.IsRedy = true;
        }
        public bool Execute(FileItem item, AutoExportPluginConfig configData)
        {
            configData.IsRedy = false;
            configData.IsError = false;
            var filename = item.FileName;
            var conf = new CopyFilePluginViewModel(configData);
            if (string.IsNullOrEmpty(conf.Path))
            {
                configData.IsRedy = true;
                configData.IsError = true;
                configData.Error = "No export path was set";
                return false;
            }
            if (!Directory.Exists(conf.Path))
                Directory.CreateDirectory(conf.Path);
            string name = item.Name;

            if (!string.IsNullOrEmpty(conf.FileName))
            {
                name = conf.FileName;
                if (name.Contains("%1"))
                    name = name.Replace("%1", Path.GetFileNameWithoutExtension(item.Name));
                if (!name.Contains("."))
                    name = name + Path.GetExtension(item.Name);
            }

            var outfile = Path.Combine(conf.Path, name);
            AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

            configData.IsRedy = true;
            return true;
        }
 public bool Execute(FileItem item, AutoExportPluginConfig configData)
 {
     Thread thread = new Thread(() => Send(item, configData));
     thread.Start();
     return true;
     return true;
 }
        public bool Execute(FileItem item, AutoExportPluginConfig configData)
        {
            configData.IsRedy = false;
            configData.IsError = false;
            var filename = item.FileName;
            var conf = new ExecuteFilePluginViewModel(configData);
            if (string.IsNullOrEmpty(conf.PathToExe) || !File.Exists(conf.PathToExe))
            {
                configData.IsRedy = true;
                configData.IsError = true;
                configData.Error = "No executable path was set or executable not found";
                return false;
            }
            var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(filename));

            outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

            if (File.Exists(outfile))
            {
                PhotoUtils.Run(conf.PathToExe,
                    string.IsNullOrEmpty(conf.Params) ? outfile : conf.Params.Replace("%1", outfile), ProcessWindowStyle.Normal);
            }
            else
            {
                configData.IsError = true;
                configData.Error = "Output file not found !";
            }

            configData.IsRedy = true;
            return true;  
        }
        public AutoExportPluginConfig AddPlugin(IAutoExportPlugin plugin)
        {
            var res = new AutoExportPluginConfig(plugin);

            AutoExportPluginConfigs.Add(res);
            return(res);
        }
Example #8
0
 public PluginSetting()
 {
     Values = new List <ValuePair>();
     AutoExportPluginConfig = new AutoExportPluginConfig()
     {
         Name = "Plugin"
     };
 }
 public UserControl GetConfig(AutoExportPluginConfig configData)
 {
     var cnt = new DropboxConfig()
     {
         DataContext = new DropboxViewModel(configData)
     };
     return cnt;
 }
 public UserControl GetConfig(AutoExportPluginConfig configData)
 {
     var cnt = new SendEmailPluginConfig()
     {
         DataContext = new SendEmailPluginViewModel(configData)
     };
     return cnt;
 }
 public DropboxViewModel(AutoExportPluginConfig configData)
 {
     _config = configData;
     LoginCommand = new RelayCommand(Login);
     LogoutCommand = new RelayCommand(LogOut);
     ShowFolderCommand = new RelayCommand(ShowFolder);
     LoadData();
 }
 public UserControl GetConfig(AutoExportPluginConfig configData)
 {
     var cntr = new CopyFilePluginConfig()
     {
         DataContext = new CopyFilePluginViewModel(configData)
     };
     return cntr;
 }
 public AutoExportPluginEditViewModel(AutoExportPluginConfig config)
 {
     Config = config;
     AddTransforPluginCommand = new GalaSoft.MvvmLight.Command.RelayCommand<string>(AddTransforPlugin);
     RemoveTransforPluginCommand =
         new GalaSoft.MvvmLight.Command.RelayCommand<TransformPluginItem>(RemoveTransforPlugin);
     PreviewCommand = new RelayCommand(Preview);
 }
Example #14
0
 public UserControl GetConfig(AutoExportPluginConfig configData)
 {
     var cnt = new TransformPluginConfig
     {
         DataContext = new TransformPluginViewModel(configData)
     };
     return cnt;
 }
Example #15
0
        private void ConfigurePlugin(AutoExportPluginConfig plugin)
        {
            var pl = ServiceProvider.PluginManager.GetAutoExportPlugin(plugin.Type);

            if (pl != null)
            {
                pl.Configure(plugin);
            }
        }
 public FacebookPluginViewModel(AutoExportPluginConfig config, bool loadData = true)
 {
     _config = config;
     Init();
     if (!string.IsNullOrEmpty(AccessToken) && loadData)
     {
         LoadData();
         LoadAlbums();
     }
 }
Example #17
0
 public bool Execute(FileItem item, AutoExportPluginConfig configData)
 {
     //if (!configData.IsRedy)
     //    return false;
     //Print(filename, configData);
     Thread thread = new Thread(() => Print(item, configData));
     thread.SetApartmentState(ApartmentState.STA);
     thread.Start();
     return true;
 }
        public bool Execute(FileItem item, AutoExportPluginConfig configData)
        {
            configData.IsRedy = false;
            configData.IsError = false;
            var filename = item.FileName;
            var conf = new TransformPluginViewModel(configData);
            var outfile = Path.GetTempFileName();
            outfile = PhotoUtils.ReplaceExtension(outfile, Path.GetExtension(filename));
            outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);
            if (conf.CreateNew)
            {
                string newFile = Path.Combine(Path.GetDirectoryName(filename),
                    Path.GetFileNameWithoutExtension(filename) + "_transformed" + ".jpg");
                newFile = PhotoUtils.GetNextFileName(newFile);

                File.Copy(outfile, newFile, true);

                if (ServiceProvider.Settings.DefaultSession.GetFile(newFile) == null)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        FileItem im = new FileItem(newFile);
                        im.Transformed = true;
                        var i = ServiceProvider.Settings.DefaultSession.Files.IndexOf(item);
                        if (ServiceProvider.Settings.DefaultSession.Files.Count - 1 == i)
                        {
                            ServiceProvider.Settings.DefaultSession.Files.Add(im);
                        }
                        else
                        {
                            ServiceProvider.Settings.DefaultSession.Files.Insert(i + 1, im);
                        }
                    }));
                }
            }
            else
            {
                // wait for file to be not locked
                PhotoUtils.WaitForFile(filename);
                File.Copy(outfile, filename, true);
                item.IsLoaded = false;
                item.RemoveThumbs();
                item.Transformed = true;
            }
            // remove unused file
            if (outfile != item.FileName)
            {
                PhotoUtils.WaitForFile(outfile);
                File.Delete(outfile);
            }
            configData.IsRedy = true;
            return true;
        }
 public AutoExportPluginEditViewModel(AutoExportPluginConfig config)
 {
     Config = config;
     AddTransforPluginCommand = new GalaSoft.MvvmLight.Command.RelayCommand<string>(AddTransforPlugin);
     RemoveTransforPluginCommand =
         new GalaSoft.MvvmLight.Command.RelayCommand<TransformPluginItem>(RemoveTransforPlugin);
     PreviewCommand = new RelayCommand(Preview);
     ApplyCommand = new RelayCommand(Apply);
     RemoveConditionCommand = new GalaSoft.MvvmLight.Command.RelayCommand<PluginCondition>(RemoveCondition);
     AddConditionCommand = new RelayCommand(AddCondition);
     CheckConditionCommand = new RelayCommand(CheckCondition);
     GetValueCommand = new GalaSoft.MvvmLight.Command.RelayCommand<PluginCondition>(GetValue);
 }
Example #20
0
        private void Send(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                var filename = item.FileName;
                configData.IsRedy = false;
                configData.IsError = false;
                var conf = new FtpPluginViewModel(configData);

                var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(filename));
                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                using (FtpClient conn = new FtpClient())
                {
                    conn.Host = conf.Server;
                    conn.Credentials = new NetworkCredential(conf.User, conf.Pass);
                    if (!string.IsNullOrWhiteSpace(conf.ServerPath))
                        conn.SetWorkingDirectory(conf.ServerPath);
                    using (Stream ostream = conn.OpenWrite(Path.GetFileName(outfile)))
                    {
                        try
                        {
                            var data = File.ReadAllBytes(outfile);
                            ostream.Write(data, 0, data.Length);
                        }
                        finally
                        {
                            ostream.Close();
                        }
                    }
                }
                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error senf ftp file", exception);
                configData.IsError = true;
                configData.Error = exception.Message;
            }
            configData.IsRedy = true;   
        }
Example #21
0
        private void ApplyPlugin(AutoExportPluginConfig plugin)
        {
            var pl = ServiceProvider.PluginManager.GetAutoExportPlugin(plugin.Type);

            try
            {
                pl.Execute(ServiceProvider.Settings.SelectedBitmap.FileItem, plugin);
                ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.Refresh_Image);
            }
            catch (Exception ex)
            {
                plugin.IsError = true;
                plugin.Error   = ex.Message;
                plugin.IsRedy  = true;
                Log.Error("Error to apply plugin", ex);
            }
        }
 public static string ExecuteTransformPlugins(FileItem item, AutoExportPluginConfig configData, string outfile)
 {
     File.Copy(item.FileName, outfile, true);
     if (configData.ConfigDataCollection == null || configData.ConfigDataCollection.Count == 0)
     {
         return(outfile);
     }
     foreach (var enumerator in configData.ConfigDataCollection)
     {
         var plugin = enumerator["TransformPlugin"];
         var tp     = ServiceProvider.PluginManager.GetImageTransformPlugin(plugin);
         if (tp != null)
         {
             outfile = tp.Execute(item, outfile, outfile, enumerator);
         }
     }
     return(outfile);
 }
 public static string ExecuteTransformPlugins(FileItem item, AutoExportPluginConfig configData, string infile,
     string outfile)
 {
     if (infile != outfile)
         File.Copy(infile, outfile, true);
     if (configData.ConfigDataCollection == null || configData.ConfigDataCollection.Count == 0)
         return outfile;
     foreach (var enumerator in configData.ConfigDataCollection)
     {
         var plugin = enumerator["TransformPlugin"];
         var tp = ServiceProvider.PluginManager.GetImageTransformPlugin(plugin);
         if (tp != null)
         {
             outfile = tp.Execute(item, outfile, outfile, enumerator);
             ServiceProvider.Analytics.TransformPluginExecute(plugin);
             Log.Debug("TransformPlugin executed " + plugin);
         }
     }
     return outfile;
 }
        public void Send(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                configData.IsRedy = false;
                configData.IsError = false;
                var conf = new SendEmailPluginViewModel(configData);

                var outfile = PhotoUtils.ReplaceExtension(Path.GetTempFileName(),Path.GetExtension(item.Name));
                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                var client = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82",3);
                var message = new MailMessage(conf.From, conf.To)
                {
                    Subject = (string.IsNullOrEmpty(conf.Subject) ? "Your photo":conf.TransformTemplate(item,conf.Subject)),
                    Body = (string.IsNullOrEmpty(conf.Message) ? "." : conf.TransformTemplate(item, conf.Message)),
                    IsBodyHtml = true
                };
                using (MemoryStream stream = new MemoryStream(File.ReadAllBytes(outfile)))
                {
                    message.Attachments.Add(new Attachment(stream, item.Name));

                    client.SendMail(message);
                    message.Dispose();
                }
                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error send facebook file", exception);
                configData.IsError = true;
                configData.Error = exception.Message;
            }
            configData.IsRedy = true;
        }
 public static string ExecuteTransformPlugins(FileItem item, AutoExportPluginConfig configData, string outfile,
     bool preview = false)
 {
     File.Copy(preview ? item.LargeThumb : item.FileName, outfile, true);
     if (configData.ConfigDataCollection == null || configData.ConfigDataCollection.Count == 0)
         return outfile;
     foreach (var enumerator in configData.ConfigDataCollection)
     {
         try
         {
             var plugin = enumerator["TransformPlugin"];
             var tp = ServiceProvider.PluginManager.GetImageTransformPlugin(plugin);
             if (tp != null)
                 outfile = tp.Execute(item, outfile, outfile, enumerator);
         }
         catch (Exception exception)
         {
             Log.Error("Error execute transform olugin ", exception);
         }
     }
     return outfile;
 }
Example #26
0
        public bool Execute(FileItem item, AutoExportPluginConfig configData)
        {
            configData.IsRedy = false;
            configData.IsError = false;
            var filename = item.FileName;

            var outfile = Path.GetTempFileName();
            AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);
            // wait for file to be not locked
            PhotoUtils.WaitForFile(filename);
            File.Copy(outfile, filename, true);
            File.Delete(outfile);
            item.IsLoaded = false;
            item.RemoveThumbs();
            // remove unused file
            if (outfile != item.FileName)
            {
                PhotoUtils.WaitForFile(outfile);
                File.Delete(outfile);
            }
            configData.IsRedy = true;
            return true;
        }
 public static string ExecuteTransformPlugins(FileItem item, AutoExportPluginConfig configData, string outfile,
     bool preview = false)
 {
     return ExecuteTransformPlugins(item, configData, preview ? item.LargeThumb : item.FileName, outfile);
 }
Example #28
0
 public static string ExecuteTransformPlugins(FileItem item, AutoExportPluginConfig configData, string outfile,
                                              bool preview = false)
 {
     return(ExecuteTransformPlugins(item, configData, preview ? item.LargeThumb : item.FileName, outfile));
 }
Example #29
0
 private void RemovePlugin(AutoExportPluginConfig plugin)
 {
     AutoExportPluginConfigs.Remove(plugin);
 }
 private void ConfigurePlugin(AutoExportPluginConfig plugin)
 {
     var pluginEdit = new AutoExportPluginEdit
     {
         DataContext = new AutoExportPluginEditViewModel(plugin),
         Owner = this
     };
     pluginEdit.ShowDialog();
 }
 public DropboxViewModel()
 {
     _config = new AutoExportPluginConfig();
 }
 public CopyFilePluginViewModel(AutoExportPluginConfig config)
 {
     _config = config;
     BrowseCommand = new RelayCommand(Browse);
 }
Example #33
0
 private void RemovePlugin(AutoExportPluginConfig plugin)
 {
     AutoExportPluginConfigs.Remove(plugin);
 }
Example #34
0
 public AutoExportPluginConfig AddPlugin(IAutoExportPlugin plugin)
 {
     var res = new AutoExportPluginConfig(plugin);
     AutoExportPluginConfigs.Add(res);
     return res;
 }
Example #35
0
 public static void ApplyPlugin(AutoExportPluginConfig plugin)
 {
     plugin.IsError = true;
     plugin.Error = "";
     plugin.IsRedy = true;
     var pl = ServiceProvider.PluginManager.GetAutoExportPlugin(plugin.Type);
     try
     {
         pl.Execute(ServiceProvider.Settings.SelectedBitmap.FileItem, plugin);
         ServiceProvider.WindowsManager.ExecuteCommand(WindowsCmdConsts.Refresh_Image);
     }
     catch (Exception ex)
     {
         plugin.IsError = true;
         plugin.Error = ex.Message;
         plugin.IsRedy = true;
         Log.Error("Error to apply plugin", ex);
     }
 }
 public SendEmailPluginViewModel(AutoExportPluginConfig config)
 {
     _config = config;
 }
 public AutoExportPluginEditViewModel()
 {
     Config = new AutoExportPluginConfig() {Name = "Test"};
 }
Example #38
-1
        private void Print(FileItem item, AutoExportPluginConfig configData)
        {
            try
            {
                PrintDialog dlg = new PrintDialog();
                configData.IsRedy = false;
                configData.IsError = false;
                var conf = new PrintPluginViewModel(configData);
                var outfile = Path.Combine(Path.GetTempPath(), Path.GetFileName(item.FileName));

                outfile = AutoExportPluginHelper.ExecuteTransformPlugins(item, configData, outfile);

                System.Printing.PrintCapabilities capabilities = dlg.PrintQueue.GetPrintCapabilities(dlg.PrintTicket);
                var PageWidth = (int)capabilities.PageImageableArea.ExtentWidth;
                var PageHeight = (int)capabilities.PageImageableArea.ExtentHeight;

                var panel = new StackPanel
                {
                    Margin = new Thickness(conf.Margin),
                };

                var image = new Image
                {
                    Source = BitmapLoader.Instance.LoadImage(outfile, PageWidth > PageHeight ? PageWidth : PageHeight, conf.Rotate ? 90 : 0),
                    Width = PageWidth ,
                    Height = PageHeight,
                    Stretch = Stretch.Uniform,
                };

               
                panel.Children.Add(image);
                panel.UpdateLayout();
                panel.Measure(new Size(PageWidth, PageHeight));
                panel.Arrange(new Rect(new Point(0, 0), panel.DesiredSize));
                panel.UpdateLayout();
                dlg.PrintVisual(panel, item.Name);
                image.Source = null;
                panel.Children.Clear();
                // remove unused file
                if (outfile != item.FileName)
                {
                    PhotoUtils.WaitForFile(outfile);
                    File.Delete(outfile);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error print file", exception);
                configData.IsError = true;
                configData.Error = exception.Message;
            }

            configData.IsRedy = true;            
        }