private void OnCopyClick(object sender, EventArgs e)
            {
                var    selectedFiles = SelectedFilesAndDirs.OfType <FileSystemInfo>().ToList();
                string sourceDir     = CurrentDirectory.FullName;
                DestinationDirectoryDialog dialog = new DestinationDirectoryDialog();

                dialog.ShowDialog();
                if (dialog.DialogResult.Equals(DialogResult.OK))
                {
                    DirectoryInfo targetDir = dialog.CurrentDirectory;
                    Copyer.CopyFiles(selectedFiles, sourceDir, targetDir.FullName);
                }
            }
예제 #2
0
        private void Backup(object sender = null, System.Timers.ElapsedEventArgs args = null)
        {
            Copyer myCopyer = new Copyer(ApplicationType.Service);

            serviceLogger.WriteToLogFile("Backup started", Severity.Info);
            foreach (string source in sources)
            {
                try
                {
                    myCopyer.Backup(source, destination);
                }
                catch (Exception Ex)
                {
                    serviceLogger.WriteToLogFile("There was an issue backing up: " + source + "Exception is: " + Ex.Message + "Stack trace is: " + Ex.StackTrace, Severity.Error);
                    serviceLogger.WriteToLogFile("Will attempt to backup at next scheduled time", Severity.Info);
                }
            }
        }
예제 #3
0
 void TrCopy()
 {
     Copyer letscopy = new Copyer(ssl.FocusedItem.SubItems[2].Text,
             selp + @"\" + ssl.FocusedItem.Text);
         curnamen = ssl.SelectedItems[0].Text;
         //letscopy.CopyComplete += new Action<bool>(letscopy_CopyComplete);
         letscopy.CopyIt();
 }
예제 #4
0
        public MainWindow()
        {
            try
            {
                myLogger = new Logger(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), ApplicationType.Client);
            }
            catch
            {
                //fatal if we can't create log file
                PromptUser promptUser = new PromptUser("Fatal error, unable to create logger. Application will terminate");
                promptUser.ShowDialog();
                System.Windows.Application.Current.Shutdown();
            }
            try
            {
                configFile = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\Configuration.bin";
            }
            catch
            {
                try
                {
                    File.Create(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\Configuration.bin");
                }
                catch (Exception Ex)
                {
                    PromptUser("Unable to find nor create configuration file. Will exit. Exception is:" + Ex.Message, Ex.StackTrace, Severity.Warning);
                    System.Windows.Application.Current.Shutdown();
                }
            }

            InitializeComponent();
            InitializaeUIObjects();
            Items      = new List <String>();
            this.Width = 691.2;
            try
            {
                myCopyer = new Copyer(ApplicationType.Client);
            }
            catch (Exception Ex) //This should never get hit. Here just in case...
            {
                PromptUser("Unable to create Copyer and possibly log file. Application will close. Exception is" + Ex.Message);
                System.Windows.Application.Current.Shutdown();
            }
            //Does this if statement need to be in a Try Catch ?
            if (Support.Support.CheckPath(configFile, PathType.File))
            {
                string[] configItems = Support.Support.Deserialize(configFile);
                Destination.Text = configItems[configItems.Length - 2]; //Need to do this before sources to calculate size difference hgb
                string[] configTime = Support.Support.ReturnFrequency(configItems[configItems.Length - 1]);
                Hours.Text     = configTime[0];
                Minutes.Text   = configTime[1];
                AMPM.Text      = configTime[2];
                Frequency.Text = configTime[3];

                for (int i = 0; i < configItems.Length - 2; i++)
                {
                    string        searchString     = @"Source" + (i + 1).ToString();
                    List <Object> _sourceUIObjects = new List <Object>();
                    _sourceUIObjects = (from entry in sourceUIObjects where (entry.Key == searchString) select entry.Value).FirstOrDefault();
                    ((System.Windows.Controls.TextBox)_sourceUIObjects[0]).Text = configItems[i];
                    Items.Add(configItems[i]);
                    ChangeVisibility(_sourceUIObjects, Visibility.Visible);
                    if (i > 0)
                    {
                        screenSize += 0.125;
                    }
                }
                sourceNumber        = configItems.Length - 2;
                destinationPosition = sourceNumber + 1;
                overviewPosition    = destinationPosition + 1;
                Items.Add(configItems[configItems.Length - 2]);

                for (int i = configItems.Length - 2; i < 4; i++)
                {
                    string        searchString     = @"Source" + (i + 1).ToString();
                    List <Object> _sourceUIObjects = new List <Object>();
                    _sourceUIObjects = (from entry in sourceUIObjects where (entry.Key == searchString) select entry.Value).FirstOrDefault();
                    ChangeVisibility(_sourceUIObjects, Visibility.Hidden);
                }

                for (int i = 3; i < 6; i++)
                {
                    string        searchString     = @"Source" + (i - 1).ToString();
                    List <Object> _sourceUIObjects = new List <Object>();
                    _sourceUIObjects = (from entry in sourceUIObjects where (entry.Key == searchString) select entry.Value).FirstOrDefault();
                    if (((System.Windows.Controls.TextBox)_sourceUIObjects[0]).Text == null || ((System.Windows.Controls.TextBox)_sourceUIObjects[0]).Text == string.Empty)
                    {
                        UIGrid.RowDefinitions[i].Height = new GridLength(0);
                    }
                }
                UIGrid.RowDefinitions[6].Height = new GridLength(0);
                SourceUIChange();
            }
            else
            {
                for (int i = 3; i < 7; i++)
                {
                    UIGrid.RowDefinitions[i].Height = new GridLength(0);
                    Source1.Text     = "Sources Folder";
                    Destination.Text = "Destination Folder";
                }
            }

            MoveNonSource();
            SetGreen(SaveConfig);
            SetScreen();
            DisplayRemoveSource();
            RetrieveServiceStatus();
            GetLastBackupTime();
        }