Example #1
0
        internal void RestoreVersion(ListVersion version)
        {
            if (Subscriber == null)
            {
                return;
            }

            FileInfo fileInfoVersion = new FileInfo(version.Path);

            if (!DirFile.FileExists(fileInfoVersion))
            {
                return;
            }

            FileInfo tempFileVersion = new FileInfo(DirFile.GetTempFile());

            fileInfoVersion.CopyTo(tempFileVersion.FullName);
            tempFileVersion.LastWriteTime = DateTime.Now;

            FileInfo fileInfoRestore = new FileInfo(Subscriber.Path);

            tempFileVersion.CopyTo(fileInfoRestore.FullName, true);

            DirFile.DeleteFile(tempFileVersion);
        }
        private void ButtonRestoreVersion_Click(object sender, RoutedEventArgs e)
        {
            ListVersion itemVersion = null;

            foreach (ListVersion item in _listVersion)
            {
                if (item.Checked &&
                    !string.IsNullOrWhiteSpace(item.Path))
                {
                    itemVersion = item;
                }
            }

            if (itemVersion != null)
            {
                bool?result = Dialog.ShowQuesttion($"Восстановить версию {itemVersion.FileName}?");
                if (result.HasValue && result.Value)
                {
                    _callUpdate.CommentNewVersion = $"Восстановлено. {itemVersion.FileName}.";
                    new Versions()
                    {
                        Subscriber = _fileSubscriberCurrentRow
                    }.RestoreVersion(itemVersion);
                }
            }
        }
Example #3
0
        internal List <ListVersion> GetListVersion()
        {
            List <CommentsVersion> commentsVersions = new Comments(Subscriber, SubscriberInfo).GetListComments();

            List <ListVersion> list = new List <ListVersion>();

            foreach (FileInfo item in GetFilesInDirectoryVersion())
            {
                ListVersion listVersion = new ListVersion(
                    item.FullName,
                    item.Name,
                    item.LastWriteTime,
                    commentsVersions.Find(f => f.FileName == item.Name));

                list.Add(listVersion);
            }

            list.Sort((el1, el2) => el2.DateModified.CompareTo(el1.DateModified));

            return(list);
        }