Example #1
0
        public override byte[] GetBlobData(DataCompareItem item, int index)
        {
            string fileName = item.GetSourceIdentifier <string>(0);
            string tmpFile  = System.IO.Path.Combine(Utility.GetTempPath(), $"{Guid.NewGuid()}.tmp");

            try
            {
                //TODO: Need a change here to Data Sync so we can terminate the session and stop WinSCP.exe after the sync is finished rather than on each file.

                using (Session session = GetSession())
                {
                    var result = session.GetFiles(fileName, tmpFile, false, new TransferOptions {
                        TransferMode = TransferMode.Binary
                    });

                    if (result.IsSuccess)
                    {
                        return(System.IO.File.ReadAllBytes(tmpFile));
                    }

                    throw new Exception($"ERROR: Downloading File ({fileName})");
                }
            }
            catch (OverflowException)
            {
                throw new ArgumentException($"ERROR: File ({fileName}) is too large to synchronise");
            }
            finally
            {
                if (System.IO.File.Exists(tmpFile))
                {
                    try
                    {
                        System.IO.File.Delete(tmpFile);
                    }
                    catch (System.IO.IOException)
                    {
                        // Ignore ...
                    }
                }
            }
        }
Example #2
0
 public override string GetFilePath(DataCompareItem item, int index) => Utility.StripStartSlash(System.IO.Path.GetDirectoryName(item.GetSourceIdentifier <string>(0)).Substring(Path.Length));
Example #3
0
 public override string GetFileName(DataCompareItem item, int index) => System.IO.Path.GetFileName(item.GetSourceIdentifier <string>(0));