예제 #1
0
        private void OnConnection(RemoteDevice dev, bool connected)
        {
            if (connected)
            {
                lvFolders.Items.Clear();
                try
                {
                    Dev = mgr.Devices.FirstConnectedDevice;
                    //dev = mgr.Devices.FirstConnectedDevice;
                    statusLabel.Text = Dev.Name + " está conectado";
                    var dirs = RemoteDirectory.GetDirectories(Dev, Dev.GetFolderPath(SpecialFolder.MyDocuments));

                    foreach (var dir in dirs)
                    {
                        lvFolders.Items.Add(dir);
                    }
                }
                catch (Exception ex)
                {
                    lvFolders.Items.Clear();
                }
                this.Visible = true;
            }
            else
            {
                statusLabel.Text = "No hay dispositivos conectados.";
                this.Visible     = false;
                lvFiles.Items.Clear();
                lvFolders.Items.Clear();
            }
        }
예제 #2
0
 private void lvFolders_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvFiles.SelectedItems.Count < 1)
     {
         btCopy.Enabled   = false;
         btUpload.Enabled = false;
     }
     try
     {
         //var dev = mgr.Devices.FirstConnectedDevice;
         //Dev = mgr.Devices.FirstConnectedDevice;
         string selected = lvFolders.SelectedItems[0].Text;
         Path = Dev.GetFolderPath(SpecialFolder.MyDocuments) + "\\" + selected;
         var files = RemoteDirectory.GetFiles(Dev, Path);
         lvFiles.Items.Clear();
         foreach (var file in files)
         {
             RemoteFileInfo info = new RemoteFileInfo(Dev, Path + "\\" + file);
             ListViewItem   item = new ListViewItem(file);
             item.SubItems.Add(info.LastWriteTime.ToString());
             lvFiles.Items.Add(item);
         }
     }
     catch (Exception)
     {
         lvFiles.Items.Clear();
     }
 }
예제 #3
0
        internal SftpSynchronizer(string username, string password, SecurityIdentifier userSid)
        {
            ConnectionInfo connectionInfo = new ConnectionInfo(Settings.ProfileServerAddress, Settings.ProfileServerPort, username, new PasswordAuthenticationMethod(username, password));

            if (Settings.HostKey == string.Empty)
            {
                remote = new RemoteContext(connectionInfo);
            }
            else
            {
                byte[] expectedHostKey = Convert.FromBase64String(Settings.HostKey);
                remote = new RemoteContext(connectionInfo, expectedHostKey);
            }
            remote.Connect();

            this.username       = username;
            this.userSid        = userSid.Value;
            serverBaseDirectory = Settings.ProfileServerBaseDirectory;

            SyncInformation syncInformation    = GetSyncInformation();
            bool            remoteProfileExist = syncInformation.Status != SyncInformation.SyncStatus.DoesNotExist;
            string          localProfilePath   = GetLocalProfilePath(username, password, userSid, remoteProfileExist);
            string          remoteProfilePath  = string.Format("{0}/{1}", serverBaseDirectory, username);

            uploadExclusionList = CreateUploadExclusionList(localProfilePath);
            localProfile        = new LocalDirectory(localProfilePath, uploadExclusionList, username);
            remoteProfile       = new RemoteDirectory(remote, remoteProfilePath, syncInformation.SidInLastHost, this.userSid);
        }
예제 #4
0
        public MatrixAgent()
        {
            Registry = new RemoteRegistry();

            Configuration = new RemoteConfigurator();

            Directory = new RemoteDirectory();

            Logger = new RemoteLogger();

            Gateway = new RemoteGateway();
        }
예제 #5
0
        //todo: make that as background task. Need input from someone how to handle that correctly as now it is as sync task to avoid issues, but need be change
        public override void RebuildCache()
        {
            lock (RebuildLock)
            {
                //Needs locking
                LoggingService.Log(new LogEntry(LogLevel.Info, null, $"Rebuilding cache"));

                var tempDir = new DirectoryInfo(
                    Path.Combine(_cacheDirectoryPath,
                                 _cacheDirectoryName, DateTimeOffset.UtcNow.ToString("yyyyMMddTHHmmssfffffff")));
                if (tempDir.Exists == false)
                {
                    tempDir.Create();
                }
                Lucene.Net.Store.Directory newIndex = new SimpleFSDirectory(tempDir);
                foreach (string file in GetAllBlobFiles())
                {
                    //   newIndex.TouchFile(file);
                    if (file.EndsWith(".lock"))
                    {
                        continue;
                    }
                    var status = RemoteDirectory.SyncFile(newIndex, file, CompressBlobs);
                    if (!status)
                    {
                        LoggingService.Log(new LogEntry(LogLevel.Error, null, $"Rebuilding cache failed"));
                        newIndex.Dispose();
                    }
                }

                var oldIndex = CacheDirectory;
                newIndex.Dispose();
                newIndex = new SimpleFSDirectory(tempDir);

                CacheDirectory = newIndex;
                _lockFactory   = newIndex.LockFactory;
                if (oldIndex != null)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(LockFactory.LockPrefix))
                        {
                            oldIndex.ClearLock(LockFactory.LockPrefix + "-write.lock");
                        }
                        else
                        {
                            oldIndex.ClearLock("write.lock");
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggingService.Log(new LogEntry(LogLevel.Error, ex, $"Exception on unlocking old cache index folder"));
                    }


                    oldIndex.Dispose();
                    try
                    {
                        DirectoryInfo oldindexDir = new DirectoryInfo(Path.Combine(_cacheDirectoryPath,
                                                                                   _cacheDirectoryName, _oldIndexFolderName));
                        foreach (var file in oldindexDir.GetFiles())
                        {
                            file.Delete();
                        }


                        oldindexDir.Delete();
                    }
                    catch (Exception ex)
                    {
                        LoggingService.Log(new LogEntry(LogLevel.Error, ex, $"Cleaning of old directory failed."));
                    }
                }

                _oldIndexFolderName = tempDir.Name;
            }
        }
예제 #6
0
        public RemoteDirectories GetLMDDirectories()
        {
            string path = @"\\Ypiibldoc1\Documents\FlowCytometry\Analysis\BillingsClinic\LMD";
            RemoteDirectories lmdDirectories = new RemoteDirectories();
            string[] directories = System.IO.Directory.GetDirectories(path);
            foreach (string directoryName in directories)
            {
                RemoteDirectory lmdDirectory = new RemoteDirectory(directoryName);
                lmdDirectories.Items.Add(lmdDirectory);

                string[] files = System.IO.Directory.GetFiles(directoryName);
                foreach (string file in files)
                {
                    RemoteFile lmdFile = new RemoteFile(file);
                    lmdDirectory.Files.Items.Add(lmdFile);
                }
            }
            return lmdDirectories;
        }