Esempio n. 1
0
        /// <summary>
        /// Upload the captured image, file path found in CapturedImage.LocalPath
        /// </summary>
        public static async Task UploadImage(CapturedImage image)
        {
            Log.Write(l.Client, $"Uploading {image.Name} to {image.RemotePath}");

            if (FTP)
            {
                await ftpc.UploadFileAsync(image.LocalPath, image.RemotePath);
            }
            else
            {
                using (var localStream = File.OpenRead(image.LocalPath))
                {
                    await sftpc.UploadAsync(localStream, image.RemotePath);
                }
            }
        }
Esempio n. 2
0
        public static void SaveImage(string localPath)
        {
            var image       = Image.FromFile(localPath);
            var captureName = Common.RandomString(Common.Profile.FileLenght) + Common.GetFormat(image.RawFormat);

            var info = new CapturedImage
            {
                Name       = captureName,
                LocalPath  = Path.Combine(Settings.TempImageFolder, captureName),
                RemotePath = Common.Combine(Common.Profile.RemoteFolder, captureName)
            };

            Log.Write(l.Info, $"Saving image as: {info.LocalPath}");

            image.Save(info.LocalPath);
            CapturedImages.Add(info);
        }
Esempio n. 3
0
        public static void SaveImage(Image image)
        {
            var captureName = Common.RandomString(Common.Profile.FileLenght) + Common.GetFormat();

            var info = new CapturedImage
            {
                Name       = captureName,
                LocalPath  = Path.Combine(Settings.TempImageFolder, captureName),
                RemotePath = Common.Combine(Common.Profile.RemoteFolder, captureName)
            };

            Log.Write(l.Info, $"Saving image as: {info.LocalPath}");

            image.Save(info.LocalPath);
            CapturedImages.Add(info);

            // raise CaptureComplete to start uploading
            CaptureComplete(null, EventArgs.Empty);
        }