+ private void EnsurePithosContainers()
+ {
+ CloudClient.UsePithos = this.UsePithos;
+ CloudClient.AuthenticationUrl = this.AuthenticationUrl;
+ CloudClient.Authenticate(UserName, ApiKey);
+
+ var pithosContainers = new[] {PithosContainer, TrashContainer};
+ foreach (var container in pithosContainers)
+ {
+ if (!CloudClient.ContainerExists(container))
+ CloudClient.CreateContainer(container);
+ }
+ }
+
+ public string AuthenticationUrl { get; set; }
+
+ private Uri ProxyFromSettings()
+ {
+ if (Settings.UseManualProxy)
+ {
+ var proxyUri = new UriBuilder
+ {
+ Host = Settings.ProxyServer,
+ Port = Settings.ProxyPort
+ };
+ if (Settings.ProxyAuthentication)
+ {
+ proxyUri.UserName = Settings.ProxyUsername;
+ proxyUri.Password = Settings.ProxyPassword;
+ }
+ return proxyUri.Uri;
+ }
+ return null;
+ }
+
+ private void IndexLocalFiles(string path)
+ {
+ Trace.TraceInformation("[START] Inxed Local");
+ try
+ {
+ var files =
+ from filePath in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories).AsParallel()
+ select filePath;
+ StatusKeeper.StoreUnversionedFiles(files);
+
+ RestartInterruptedFiles();
+ }
+ catch (Exception exc)
+ {
+ Trace.TraceError("[ERROR] Index Local - {0}", exc);
+ }
+ finally
+ {
+ Trace.TraceInformation("[END] Inxed Local");
+ }
+ }
+
+ private void RestartInterruptedFiles()
+ {
+ var interruptedStates = new[] { FileOverlayStatus.Unversioned, FileOverlayStatus.Modified };
+ var filesQuery = from state in FileState.Queryable
+ where interruptedStates.Contains(state.OverlayStatus)
+ select new WorkflowState
+ {
+ Path = state.FilePath.ToLower(),
+ FileName = Path.GetFileName(state.FilePath).ToLower(),
+ Status=state.OverlayStatus==FileOverlayStatus.Unversioned?
+ FileStatus.Created:
+ FileStatus.Modified,
+ TriggeringChange = state.OverlayStatus==FileOverlayStatus.Unversioned?
+ WatcherChangeTypes.Created:
+ WatcherChangeTypes.Changed
+ };
+ _uploadEvents.AddFromEnumerable(filesQuery,false);
+
+ }
+
+ private void StartStatusService()
+ {
+ // Create a ServiceHost for the CalculatorService type and provide the base address.
+ var baseAddress = new Uri("net.pipe://localhost/pithos");
+ _statusService = new ServiceHost(typeof(StatusService), baseAddress);
+
+ var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
+
+ _statusService.AddServiceEndpoint(typeof(IStatusService), binding, "net.pipe://localhost/pithos/statuscache");
+ _statusService.AddServiceEndpoint(typeof (ISettingsService), binding, "net.pipe://localhost/pithos/settings");
+
+
+ //// Add a mex endpoint
+ var smb = new ServiceMetadataBehavior
+ {
+ HttpGetEnabled = true,
+ HttpGetUrl = new Uri("http://localhost:30000/pithos/mex")
+ };
+ _statusService.Description.Behaviors.Add(smb);
+
+
+ _statusService.Open();
+ }
+
+ private void StopStatusService()
+ {
+ if (_statusService == null)
+ return;
+
+ if (_statusService.State == CommunicationState.Faulted)
+ _statusService.Abort();
+ else if (_statusService.State != CommunicationState.Closed)
+ _statusService.Close();
+ _statusService = null;
+
+ }
+
+