Пример #1
0
		public static void ProcessGoProCameraForUser()
		{

			if (IsUploadFromGoProStarted) return;

			IDeviceManager manager = new DeviceManager();
			IEnumerable<IDevice> devices = manager.GetAllDevices();

			IDevice gopro = null;

			CodeITDL.User uploadUser = null;

			List<IDeviceObject> mp4Files = new List<IDeviceObject>();
			List<CodeITBL.FileFromDB> mp4DbFiles = new List<CodeITBL.FileFromDB>();

			bool shouldProceed = false;

			bool shouldDelete = false;

			#region CHECK FOR DEVICE ID AND USER
			if (devices.Count() > 0)
				using (CodeITDL.CodeITDbContext ctx = new CodeITDL.CodeITDbContext(UserId))
				{
					foreach (var device in devices)
					{
                        string deviceID = string.Format("{0}||{1}", device.Id, device.Serial);
                        //string deviceID = "\\\\?\\usb#vid_2672&pid_000d#c3131124781379#{6ac27878-a6fa-4155-ba85-f98f491d4f33}||C3131124781379";
                        var item = ctx.Users.Where(x => x.CustomerId == CustomerId && x.DeviceId == device.Id);
                        if (ctx.Users.Where(x => x.CustomerId == CustomerId && x.DeviceId == deviceID) != null)
                        {
                            if (ctx.Users.Where(x => x.CustomerId.ToString().ToUpper() == CustomerId.ToString().ToUpper() && x.DeviceId == deviceID && x.Id == UserId).Count() > 0)
                            {
                                uploadUser = ctx.Users.Where(x => x.CustomerId == CustomerId && x.DeviceId == deviceID && x.Id == UserId).FirstOrDefault();
                                shouldProceed = true;
                                gopro = device;
                                IsUploadFromGoProStarted = true;
                                break;
                            }
                            else
                            {
								System.Windows.MessageBox.Show("This camera is not mapped to your user. Please contact the administrator!", "Info", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                            }
                        }
					}
				}
			#endregion CHECK FOR DEVICE ID AND USER

			if (!shouldProceed) return;

			#region CHECK FOR ACTIVE UPLOAD AND USER
			if (!progressForm.hasUploadCompleted)
				if (progressForm.getOwnerOfUploadProcess != uploadUser)
				{
					System.Windows.MessageBox.Show("There is active upload in progress, please wait until it is complete", "Info", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
					shouldProceed = false;
				}
			#endregion CHECK FOR ACTIVE UPLOAD AND USER

			if (!shouldProceed) return;

			#region CHECK FOR VIDEO FILES


			if (gopro != null)
			{
				foreach (var rootFolder in gopro.GetDeviceRootStorageObjects())
					mp4Files.AddRange(rootFolder.GetFiles("*.mp4"));
			}

			if (mp4Files.Count > 0)
				shouldProceed = true;

			#endregion CHECK FOR VIDEO FILES

			if (!shouldProceed) return;

			#region CONFIRMATION BOX
			if (!Context.IsUploadMessageBoxVisible)
			{
				filesForUpload = new List<IDeviceObject>();
				getFilesRecursive(gopro.GetDeviceRootStorageObjects().ToList(), "*.mp4");


				frmUploadMessageBox msgBox = new frmUploadMessageBox("message", "GoPro Upload Confirmation", filesForUpload, uploadUser, gopro);
				msgBox.StartPosition = FormStartPosition.CenterScreen;
				msgBox.TopMost = true;
				msgBox.TopLevel = true;

				msgBox.Show();
				//on form closing, check if some file is selected for upload
				//this is because of posibility to minimize upload form
				msgBox.FormClosing += (sender, args) =>
				{
					mp4Files = msgBox.SelectedFiles;
					mp4DbFiles = msgBox.SelectedDbFiles;
					Context.IsUploadMessageBoxVisible = false;
					shouldDelete = msgBox.Response == CustomMessageBoxResult.UploadAndDeleteSuccesfullyCompleted;
					if (msgBox.Response == CustomMessageBoxResult.Cancel)
						shouldProceed = false;
					else if (mp4Files.Count() == 0)
					{
						shouldProceed = false;
					}
					else
						shouldProceed = true;

					if (!shouldProceed)
					{
						IsUploadFromGoProStarted = false;
						return;
					}

					progressForm.StartUploadProcessFromGoPro(uploadUser, gopro, mp4Files, mp4DbFiles, shouldDelete);
					progressForm.Show();
				};
			}
			#endregion CONFIRMATION BOX
		}
Пример #2
0
		public static bool CheckForGoProDevice()
		{
			bool result = false;
			IDeviceManager manager = new DeviceManager();
			IEnumerable<IDevice> devices = manager.GetAllDevices();

			IDevice gopro = null;
			foreach (var device in devices)
			{
				if (device.Name.ToLower().Contains("hero"))
				{
                    gopro = device;
                    result = true;
                }
			}

			if (gopro != null)
			{
				for (int i = 0; i < System.Windows.Forms.Application.OpenForms.Count; i++)
				{
					System.Windows.Forms.Form frm = System.Windows.Forms.Application.OpenForms[i];
					if (frm is IFormWithGoProDetector)
					{
						((IFormWithGoProDetector)frm).GoProMTPDeviceDetected();
					}
				}
			}
			return result;
		}