JobDocuments.xaml.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.ComponentModel;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Media.Imaging;
  10. using System.Windows.Threading;
  11. using Comal.Classes;
  12. using InABox.Clients;
  13. using InABox.Configuration;
  14. using InABox.Core;
  15. using InABox.DynamicGrid;
  16. using InABox.WPF;
  17. using Syncfusion.UI.Xaml.Grid;
  18. using Syncfusion.UI.Xaml.TreeGrid;
  19. namespace PRSDesktop
  20. {
  21. public enum SVNFileStatus
  22. {
  23. Unknown,
  24. RemoteAddition,
  25. LocalAddition,
  26. RemoteModified,
  27. LocalModified,
  28. UpToDate
  29. }
  30. public class SVNObject : INotifyPropertyChanged
  31. {
  32. private static readonly Dictionary<SVNFileStatus, BitmapImage> _images = new()
  33. {
  34. { SVNFileStatus.Unknown, Resources.warning.AsBitmapImage() },
  35. { SVNFileStatus.UpToDate, Resources.tick.AsBitmapImage() },
  36. { SVNFileStatus.RemoteAddition, Resources.download.AsBitmapImage() },
  37. { SVNFileStatus.LocalAddition, Resources.upload.AsBitmapImage() },
  38. { SVNFileStatus.RemoteModified, Resources.remotefile.AsBitmapImage() },
  39. { SVNFileStatus.LocalModified, Resources.lightbulb.AsBitmapImage() }
  40. };
  41. private long _localsize;
  42. private DateTime _localtime = DateTime.MinValue;
  43. private readonly SVNObject _parent;
  44. private long _remotesize;
  45. private DateTime _remotetime = DateTime.MinValue;
  46. private SVNFileStatus _status = SVNFileStatus.Unknown;
  47. public SVNObject(string[] path, string name, SVNObject parent = null)
  48. {
  49. ID = Guid.NewGuid();
  50. _status = SVNFileStatus.Unknown;
  51. Path = path;
  52. Name = name;
  53. _parent = parent;
  54. }
  55. public SVNFileStatus Status
  56. {
  57. get => _status;
  58. set
  59. {
  60. _status = value;
  61. NotifyPropertyChanged("Status");
  62. }
  63. }
  64. public BitmapImage Image => _images[Status];
  65. public Guid ID { get; }
  66. public Guid ParentID => _parent != null ? _parent.ID : Guid.Empty;
  67. public string[] Path { get; }
  68. public string Name { get; }
  69. public long RemoteSize
  70. {
  71. get => _remotesize;
  72. set
  73. {
  74. _remotesize = value;
  75. Status = CheckStatus();
  76. NotifyPropertyChanged("RemoteSize");
  77. }
  78. }
  79. public DateTime RemoteTime
  80. {
  81. get => _remotetime;
  82. set
  83. {
  84. _remotetime = value;
  85. Status = CheckStatus();
  86. NotifyPropertyChanged("RemoteTime");
  87. }
  88. }
  89. public long LocalSize
  90. {
  91. get => _localsize;
  92. set
  93. {
  94. _localsize = value;
  95. Status = CheckStatus();
  96. NotifyPropertyChanged("LocalSize");
  97. }
  98. }
  99. public DateTime LocalTime
  100. {
  101. get => _localtime;
  102. set
  103. {
  104. _localtime = value;
  105. Status = CheckStatus();
  106. NotifyPropertyChanged("LocalTime");
  107. }
  108. }
  109. public string DisplayName => Uri.UnescapeDataString(Name).TrimEnd('/');
  110. public event PropertyChangedEventHandler PropertyChanged;
  111. public bool Equals(string[] segments)
  112. {
  113. if (segments.Length != Path.Length + 1)
  114. return false;
  115. for (var i = 0; i < Path.Length; i++)
  116. if (!string.Equals(Path[i], segments[i]))
  117. return false;
  118. if (!string.Equals(Name, segments.Last()))
  119. return false;
  120. return true;
  121. }
  122. public override string ToString()
  123. {
  124. return string.Format("[{0}].[{1}]", string.Join("].[", Path), Name);
  125. }
  126. private SVNFileStatus CheckStatus()
  127. {
  128. if (_localtime.IsEmpty())
  129. return SVNFileStatus.RemoteAddition;
  130. if (_remotetime.IsEmpty())
  131. return SVNFileStatus.LocalAddition;
  132. if (_remotetime > _localtime)
  133. return SVNFileStatus.RemoteModified;
  134. if (_localtime > _remotetime)
  135. return SVNFileStatus.LocalModified;
  136. return SVNFileStatus.UpToDate;
  137. }
  138. public void NotifyPropertyChanged(string propName)
  139. {
  140. if (PropertyChanged != null)
  141. PropertyChanged(this, new PropertyChangedEventArgs(propName));
  142. }
  143. }
  144. public class SVNFolder : SVNObject
  145. {
  146. public SVNFolder(string[] path, string name, SVNObject parent = null) : base(path, name, parent)
  147. {
  148. }
  149. }
  150. public class SVNFile : SVNObject
  151. {
  152. public SVNFile(string[] path, string name, SVNObject parent = null) : base(path, name, parent)
  153. {
  154. }
  155. }
  156. public abstract class SyncEntry
  157. {
  158. public Uri Parent { get; set; }
  159. public Uri Path { get; set; }
  160. public long Size { get; set; }
  161. public DateTime Modified { get; set; }
  162. }
  163. public class LocalSyncEntry : SyncEntry
  164. {
  165. }
  166. public class RemoteSyncEntry : SyncEntry
  167. {
  168. }
  169. /// <summary>
  170. /// Interaction logic for JobDocuments.xaml
  171. /// </summary>
  172. public partial class JobDocuments : UserControl, IPanel<Job>, IJobControl
  173. {
  174. private readonly ObservableCollection<SVNFile> _files = new();
  175. private readonly ObservableCollection<SVNFolder> _folders = new();
  176. private readonly string _localroot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "test");
  177. private Uri _serverroot = new("https://MacOSW10/svn/test/");
  178. private WaitCursor _waitcursor;
  179. //private SvnClient svnclient = null;
  180. private readonly DispatcherTimer _waitcursortimer;
  181. private string jobnumber = "";
  182. private Guid lastjobid = Guid.Empty;
  183. private readonly BackgroundWorker localfiles;
  184. private readonly BackgroundWorker localfolders;
  185. private readonly BackgroundWorker remotefiles;
  186. private readonly BackgroundWorker remotefolders;
  187. private JobDocumentsScreenSettings settings;
  188. public JobDocuments()
  189. {
  190. InitializeComponent();
  191. remotefolders = new BackgroundWorker();
  192. remotefolders.WorkerReportsProgress = true;
  193. remotefolders.WorkerSupportsCancellation = false;
  194. //remotefolders.DoWork += RemoteFoldersRefresh;
  195. remotefolders.ProgressChanged += (o, e) => HandleProgress(e, _folders);
  196. localfolders = new BackgroundWorker();
  197. localfolders.WorkerReportsProgress = true;
  198. localfolders.WorkerSupportsCancellation = false;
  199. //localfolders.DoWork += LocalFoldersRefresh;
  200. localfolders.ProgressChanged += (o, e) => HandleProgress(e, _folders);
  201. remotefiles = new BackgroundWorker();
  202. remotefiles.WorkerReportsProgress = true;
  203. remotefiles.WorkerSupportsCancellation = false;
  204. //remotefiles.DoWork += RemoteFilesRefresh;
  205. remotefiles.ProgressChanged += (o, e) => HandleProgress(e, _files);
  206. localfiles = new BackgroundWorker();
  207. localfiles.WorkerReportsProgress = true;
  208. localfiles.WorkerSupportsCancellation = false;
  209. localfiles.DoWork += LocalFilesRefresh;
  210. localfiles.ProgressChanged += (o, e) => HandleProgress(e, _files);
  211. _waitcursortimer = new DispatcherTimer();
  212. _waitcursortimer.Interval = TimeSpan.FromMilliseconds(50F);
  213. _waitcursortimer.Tick += CheckWaitCursor;
  214. _waitcursortimer.IsEnabled = true;
  215. }
  216. public Guid ParentID { get; set; }
  217. public JobPanelSettings Settings { get; set; }
  218. public bool IsReady { get; set; }
  219. public event DataModelUpdateEvent OnUpdateDataModel;
  220. public void CreateToolbarButtons(IPanelHost host)
  221. {
  222. }
  223. public string SectionName => "Job Documents";
  224. public DataModel DataModel(Selection selection)
  225. {
  226. return new JobDetailsDataModel(new Filter<Job>(x => x.ID).IsEqualTo(ParentID));
  227. }
  228. public void Heartbeat(TimeSpan time)
  229. {
  230. }
  231. public void Refresh()
  232. {
  233. if (ParentID == Guid.Empty || ParentID == CoreUtils.FullGuid)
  234. return;
  235. // using (SvnClient svnClient = new SvnClient())
  236. // {
  237. // svnClient.Authentication.Clear();
  238. // svnClient.Authentication.DefaultCredentials = new System.Net.NetworkCredential("admin", "admin");
  239. // svnClient.Authentication.SslServerTrustHandlers += (o, e) =>
  240. // {
  241. // e.AcceptedFailures = e.Failures;
  242. // e.Save = true;
  243. // };
  244. //
  245. // //var statusArgs = new SvnStatusArgs();
  246. // //statusArgs.Depth = SvnDepth.Infinity;
  247. // //statusArgs.RetrieveAllEntries = true;
  248. // //Collection<SvnStatusEventArgs> statuses;
  249. // //bool bResult = svnClient.GetStatus(Path.Combine(_localroot, GetFolderPath("\\")), statusArgs, out statuses);
  250. // //foreach (SvnStatusEventArgs statusEventArgs in statuses)
  251. // //{
  252. // // if (statusEventArgs.LocalContentStatus == SvnStatus.Modified)
  253. // // System.Console.WriteLine("Modified file: " + statusEventArgs.Path);
  254. // //}
  255. // }
  256. _folders.Clear();
  257. ;
  258. _files.Clear();
  259. CheckAndRunWorkers(remotefolders, localfolders, GetFolderPath("/"), GetFolderPath("\\"));
  260. }
  261. public Dictionary<string, object[]> Selected()
  262. {
  263. return new Dictionary<string, object[]>();
  264. }
  265. public void Setup()
  266. {
  267. settings = new UserConfiguration<JobDocumentsScreenSettings>().Load();
  268. SplitPanel.View = settings.ViewType == ScreenViewType.Register ? DynamicSplitPanelView.Master :
  269. settings.ViewType == ScreenViewType.Details ? DynamicSplitPanelView.Detail : DynamicSplitPanelView.Combined;
  270. SplitPanel.AnchorWidth = settings.AnchorWidth;
  271. Folders.ParentPropertyName = "ID";
  272. Folders.ChildPropertyName = "ParentID";
  273. Folders.SelfRelationRootValue = Guid.Empty;
  274. Folders.AutoExpandMode = AutoExpandMode.RootNodesExpanded;
  275. Folders.ItemsSource = _folders;
  276. Files.ItemsSource = _files;
  277. }
  278. public void Shutdown()
  279. {
  280. }
  281. private void SplitPanel_OnChanged(object sender, DynamicSplitPanelSettings e)
  282. {
  283. settings.ViewType = SplitPanel.View == DynamicSplitPanelView.Master ? ScreenViewType.Register :
  284. SplitPanel.View == DynamicSplitPanelView.Detail ? ScreenViewType.Details : ScreenViewType.Combined;
  285. settings.AnchorWidth = SplitPanel.AnchorWidth;
  286. new UserConfiguration<JobDocumentsScreenSettings>().Save(settings);
  287. }
  288. private void Folders_AutoGeneratingColumn(object sender, TreeGridAutoGeneratingColumnEventArgs e)
  289. {
  290. if (e.Column.MappingName == "DisplayName")
  291. e.Column.ColumnSizer = TreeColumnSizer.Star;
  292. else if (e.Column.MappingName.Equals("RemoteSize") || e.Column.MappingName.Equals("RemoteTime") ||
  293. e.Column.MappingName.Equals("LocalSize") ||
  294. e.Column.MappingName.Equals("LocalTime"))
  295. //e.Column.ColumnSizer = TreeColumnSizer.Auto;
  296. e.Cancel = true;
  297. else
  298. e.Cancel = true;
  299. }
  300. private void Folders_SizeChanged(object sender, SizeChangedEventArgs e)
  301. {
  302. }
  303. private void Folders_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
  304. {
  305. _files.Clear();
  306. var folder = (e.AddedItems.FirstOrDefault() as TreeGridRowInfo)?.RowData as SVNFolder;
  307. if (folder != null)
  308. CheckAndRunWorkers(remotefiles, localfiles, folder, folder);
  309. }
  310. private void Files_AutoGeneratingColumn(object sender, AutoGeneratingColumnArgs e)
  311. {
  312. e.Column.HeaderStyle = Resources["FileHeaderStyle"] as Style;
  313. if (e.Column.MappingName == "Status")
  314. {
  315. e.Column = new GridTemplateColumn { CellTemplate = Resources["ImageTemplate"] as DataTemplate };
  316. e.Column.Width = 30;
  317. }
  318. else if (e.Column.MappingName == "DisplayName")
  319. {
  320. e.Column.ColumnSizer = GridLengthUnitType.Star;
  321. e.Column.HeaderText = "File Name";
  322. }
  323. else if (e.Column.MappingName.Equals("RemoteSize") || e.Column.MappingName.Equals("RemoteTime") ||
  324. e.Column.MappingName.Equals("LocalSize") ||
  325. e.Column.MappingName.Equals("LocalTime"))
  326. // e.Column.ColumnSizer = GridLengthUnitType.Auto;
  327. {
  328. e.Cancel = true;
  329. }
  330. else
  331. {
  332. e.Cancel = true;
  333. }
  334. }
  335. #region Background Worker Support Functions
  336. private void CheckWaitCursor(object sender, EventArgs args)
  337. {
  338. if (!remotefolders.IsBusy && !remotefiles.IsBusy && !localfolders.IsBusy && !localfiles.IsBusy)
  339. {
  340. _waitcursortimer.IsEnabled = false;
  341. if (_waitcursor != null)
  342. {
  343. _waitcursor.Dispose();
  344. _waitcursor = null;
  345. }
  346. }
  347. }
  348. private void CheckAndRunWorkers(BackgroundWorker remote, BackgroundWorker local, object remoteparameter, object localparameter)
  349. {
  350. if (remote.IsBusy)
  351. {
  352. MessageBox.Show(string.Format("{0} is Busy!", remote.GetType()));
  353. return;
  354. }
  355. if (localfiles.IsBusy)
  356. {
  357. MessageBox.Show(string.Format("{0} is Busy!", local.GetType()));
  358. return;
  359. }
  360. _waitcursor = new WaitCursor();
  361. remote.RunWorkerAsync(remoteparameter);
  362. local.RunWorkerAsync(localparameter);
  363. _waitcursortimer.IsEnabled = true;
  364. }
  365. private string GetFolderPath(string separator)
  366. {
  367. if (lastjobid != ParentID)
  368. {
  369. jobnumber = new Client<Job>().Query(
  370. new Filter<Job>(x => x.ID).IsEqualTo(ParentID),
  371. new Columns<Job>(x => x.JobNumber)
  372. ).Rows.Select(r => r.Get<Job, string>(c => c.JobNumber)).FirstOrDefault();
  373. lastjobid = ParentID;
  374. }
  375. return string.Join(separator, "Jobs", jobnumber);
  376. }
  377. private static Uri GetRelativeUri(string segment)
  378. {
  379. var sSeg = string.Format("./{0}/", segment.TrimStart('/').TrimEnd('/'));
  380. var uSeg = new Uri(sSeg, UriKind.Relative);
  381. return uSeg;
  382. }
  383. private void HandleProgress<T>(ProgressChangedEventArgs e, ObservableCollection<T> collection, Action<T, Uri> action = null)
  384. where T : SVNObject
  385. {
  386. if (e.UserState is Exception)
  387. {
  388. var err = e.UserState as Exception;
  389. var messages = new List<string>();
  390. messages.Add("===============================================");
  391. messages.Add(string.Format("{0} Exception Caught!", err.GetType()));
  392. while (err != null)
  393. {
  394. messages.Add("===============================================");
  395. messages.Add(err.Message);
  396. messages.Add(err.StackTrace);
  397. err = err.InnerException;
  398. }
  399. messages.Add("===============================================");
  400. MessageBox.Show(string.Join("\n", messages));
  401. }
  402. else if (e.UserState is SyncEntry)
  403. {
  404. UpdateCollection(e.UserState as SyncEntry, collection, action);
  405. }
  406. }
  407. private void UpdateCollection<T>(SyncEntry entry, ObservableCollection<T> items, Action<T, Uri> action) where T : SVNObject
  408. {
  409. if (entry == null)
  410. return;
  411. var segments = entry.Path.Segments.Skip(entry.Parent.Segments.Length)
  412. .Select(x => x.TrimStart('/').TrimEnd('/').TrimStart('\\').TrimEnd('\\'))
  413. .ToArray();
  414. if (!segments.Any())
  415. return;
  416. var path = segments.Reverse().Skip(1).Reverse().ToArray();
  417. var name = segments.LastOrDefault();
  418. var existing = items.FirstOrDefault(x => x.Equals(segments));
  419. if (existing == null)
  420. {
  421. var parent = items.FirstOrDefault(x => x.Equals(path));
  422. existing = Activator.CreateInstance(typeof(T), path, name, parent) as T;
  423. items.Add(existing);
  424. }
  425. if (entry is LocalSyncEntry)
  426. {
  427. existing.LocalSize = entry.Size;
  428. existing.LocalTime = entry.Modified;
  429. }
  430. else if (entry is RemoteSyncEntry)
  431. {
  432. existing.RemoteSize = entry.Size;
  433. existing.RemoteTime = entry.Modified;
  434. }
  435. }
  436. #endregion
  437. #region Local File Processing
  438. private void LocalFilesRefresh(object sender, DoWorkEventArgs args)
  439. {
  440. var folder = args.Argument as SVNFolder;
  441. if (folder == null)
  442. return;
  443. var root = Path.Combine(_localroot, GetFolderPath("\\"));
  444. foreach (var segment in folder.Path)
  445. root = Path.Combine(root, segment);
  446. root = Path.Combine(root, folder.Name);
  447. root = Uri.UnescapeDataString(root);
  448. if (!Directory.Exists(root))
  449. return;
  450. try
  451. {
  452. var files = Directory.EnumerateFiles(root);
  453. foreach (var file in files)
  454. {
  455. var info = new FileInfo(file);
  456. localfiles.ReportProgress(0,
  457. new LocalSyncEntry { Parent = new Uri(root), Path = new Uri(file), Modified = info.LastWriteTime, Size = info.Length });
  458. }
  459. }
  460. catch (Exception e)
  461. {
  462. localfiles.ReportProgress(100, e);
  463. }
  464. }
  465. private void LocalFoldersRefresh(object sender, DoWorkEventArgs args)
  466. {
  467. var folderroot = args.Argument as string;
  468. if (string.IsNullOrWhiteSpace(folderroot))
  469. return;
  470. try
  471. {
  472. var root = Path.Combine(_localroot, folderroot.TrimStart('\\'));
  473. root = Uri.UnescapeDataString(root);
  474. var folders = new List<string> { root };
  475. while (folders.Any())
  476. {
  477. var folder = folders.First();
  478. folders.Remove(folder);
  479. if (Directory.Exists(folder))
  480. {
  481. var items = Directory.EnumerateDirectories(folder);
  482. foreach (var item in items)
  483. {
  484. var info = new FileInfo(item);
  485. if (!string.IsNullOrEmpty(item) && !string.Equals(item, folder) && !string.Equals(item, root) &&
  486. !info.Attributes.HasFlag(FileAttributes.Hidden))
  487. {
  488. folders.Add(item);
  489. localfolders.ReportProgress(0,
  490. new LocalSyncEntry { Parent = new Uri(root), Path = new Uri(item), Modified = info.LastWriteTime, Size = 0L });
  491. }
  492. }
  493. }
  494. }
  495. }
  496. catch (Exception e)
  497. {
  498. localfolders.ReportProgress(100, e);
  499. }
  500. }
  501. #endregion
  502. #region Remote File Processing
  503. // private static bool ListRemoteDirectory(SvnClient svnClient, Uri uri, out Collection<SvnListEventArgs> items, bool create)
  504. // {
  505. // try
  506. // {
  507. // return svnClient.GetList(uri, out items);
  508. // }
  509. // catch
  510. // {
  511. // if (create)
  512. // {
  513. // svnClient.RemoteCreateDirectory(uri, new SvnCreateDirectoryArgs() { LogMessage = "Auto Created Folder" });
  514. // return svnClient.GetList(uri, out items);
  515. // }
  516. // else
  517. // {
  518. // items = new Collection<SvnListEventArgs>();
  519. // return false;
  520. // }
  521. // }
  522. // }
  523. // private void RemoteFilesRefresh(object sender, DoWorkEventArgs args)
  524. // {
  525. //
  526. // var folder = args.Argument as SVNFolder;
  527. // if (folder == null)
  528. // return;
  529. //
  530. // Uri uri = new Uri(_serverroot, GetRelativeUri(GetFolderPath("/")));
  531. // foreach (var segment in folder.Path)
  532. // {
  533. // Uri uSeg = GetRelativeUri(segment);
  534. // uri = new Uri(uri, uSeg);
  535. // }
  536. // uri = new Uri(uri, GetRelativeUri(folder.Name));
  537. //
  538. // try
  539. // {
  540. // using (SvnClient svnClient = new SvnClient())
  541. // {
  542. // svnClient.Authentication.Clear();
  543. // svnClient.Authentication.DefaultCredentials = new System.Net.NetworkCredential("admin", "admin");
  544. // svnClient.Authentication.SslServerTrustHandlers += (o, e) =>
  545. // {
  546. // e.AcceptedFailures = e.Failures;
  547. // e.Save = true;
  548. // };
  549. //
  550. // Collection<SvnListEventArgs> items;
  551. // if (ListRemoteDirectory(svnClient, uri, out items, false))
  552. // {
  553. // foreach (SvnListEventArgs item in items)
  554. // {
  555. // bool bInfo = svnClient.GetInfo(item.Uri, out SvnInfoEventArgs info);
  556. //
  557. // if ((!String.IsNullOrEmpty(item.Name)) && (item.Entry.NodeKind == SvnNodeKind.File))
  558. // {
  559. // //bool bStatus = svnClient.GetStatus(item.Uri.AbsoluteUri, out Collection<SvnStatusEventArgs> statuses);
  560. // remotefiles.ReportProgress(0, new RemoteSyncEntry() { Parent = uri, Path = item.Uri, Modified = item.Entry.Time, Size = info.RepositorySize });
  561. // }
  562. // }
  563. // }
  564. // }
  565. // }
  566. // catch (Exception e)
  567. // {
  568. // remotefiles.ReportProgress(100, e);
  569. // }
  570. // }
  571. //
  572. // private void RemoteFoldersRefresh(object sender, DoWorkEventArgs args)
  573. // {
  574. //
  575. // String folderroot = args.Argument as String;
  576. // if (String.IsNullOrWhiteSpace(folderroot))
  577. // return;
  578. //
  579. // try
  580. // {
  581. // using (SvnClient svnClient = new SvnClient())
  582. // {
  583. // svnClient.Authentication.Clear();
  584. // svnClient.Authentication.DefaultCredentials = new System.Net.NetworkCredential("admin", "admin");
  585. // svnClient.Authentication.SslServerTrustHandlers += (o,e) =>
  586. // {
  587. // e.AcceptedFailures = e.Failures;
  588. // e.Save = true;
  589. // };
  590. //
  591. // Uri root = new Uri(_serverroot, GetRelativeUri(folderroot));
  592. // List<Uri> uris = new List<Uri>() { root };
  593. // while (uris.Any())
  594. // {
  595. // var uri = uris.First();
  596. // uris.Remove(uri);
  597. // Collection<SvnListEventArgs> items;
  598. // if (ListRemoteDirectory(svnClient, uri, out items, true))
  599. // {
  600. // foreach (SvnListEventArgs item in items)
  601. // {
  602. // if ((!String.IsNullOrEmpty(item.Name)) && (!Uri.Equals(root, item.Uri)) && (!Uri.Equals(uri, item.Uri)) && (item.Entry.NodeKind == SvnNodeKind.Directory))
  603. // {
  604. // uris.Add(item.Uri);
  605. // remotefolders.ReportProgress(0, new RemoteSyncEntry() { Parent = root, Path = item.Uri, Modified = item.Entry.Time, Size = item.Entry.FileSize });
  606. // }
  607. // }
  608. // }
  609. // }
  610. // }
  611. // }
  612. // catch (Exception e)
  613. // {
  614. // remotefolders.ReportProgress(100, e);
  615. // }
  616. // }
  617. #endregion
  618. }
  619. }