Ejemplo n.º 1
0
        private void FillArchives()
        {
            List<CodeITDL.User> UsersFromEntity = new List<CodeITDL.User>();
            List<CodeITDL.File> FilesFromEntity = new List<CodeITDL.File>();

            try
            {
                using (CodeITDL.CodeITDbContext ctx = new CodeITDL.CodeITDbContext(Context.UserId))
                {
                    UsersFromEntity = ctx.Users.ToList();
                    FilesFromEntity = ctx.Files.ToList();
                }

                if (FilesFromEntity.Count > 0)
                {
                    DateTime limit = DateTime.Now.AddDays(6).Date;

                    List<CodeITDL.File> uploadedFiles = new List<CodeITDL.File>();
					bool isCloud = CodeITLicence.Licence.StorageType == CodeITLicence.StorageType.Cloud ? true : false;
                    if (Context.getCurrentUser.RoleId != (int)Role.Administrator)
                    {
                        uploadedFiles = FilesFromEntity.Where(x => x.UserId == Context.UserId && x.OriginalFileDate <= limit && x.IsCloudFileSystem == isCloud).OrderByDescending(x => x.CreatedOn).ToList();
                    }
                    else
                    {
                        uploadedFiles = FilesFromEntity.Where(x => x.OriginalFileDate <= limit && x.IsCloudFileSystem == isCloud && UsersFromEntity.Where(y => y.CustomerId == Context.CustomerId).Select(y => y.Id).Contains(x.UserId)).OrderByDescending(x => x.CreatedOn).ToList();
                    }

                    List<CodeITDL.User> users = UsersFromEntity.Where(x => x.CustomerId == Context.CustomerId).ToList();

                    if (uploadedFiles != null && uploadedFiles.Count > 0)
                    {
                        for (int i = 0; i < uploadedFiles.Count; i++)
                        {
                            FileFromDB file = new FileFromDB(uploadedFiles[i], i);

                            file.UserName = (file.UserId == Context.UserId ?
                                                (Context.getCurrentUser.FirstName + " " + Context.getCurrentUser.LastName) :
                                                UsersFromEntity.Where(u => u.Id == file.UserId).Select(u => (u.FirstName + " " + u.LastName)).FirstOrDefault());

                            files.Add(file);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void FillArchivesFromSearch()
        {
            List<CodeITDL.User> UsersFromEntity = new List<CodeITDL.User>();
            List<CodeITDL.File> FilesFromEntity = new List<CodeITDL.File>();

            try
            {
                ((frmUserMainScreen)this.ParentForm).performResize();
                Cursor.Current = Cursors.WaitCursor;


                List<int> users = new List<int>();
                files = new List<FileFromDB>();

                using (CodeITDL.CodeITDbContext ctx = new CodeITDL.CodeITDbContext(Context.UserId))
                {
                    UsersFromEntity = ctx.Users.ToList();
                    FilesFromEntity = ctx.Files.ToList();
                }
				bool isCloud = CodeITLicence.Licence.StorageType == CodeITLicence.StorageType.Cloud ? true : false;
                if (Context.getCurrentUser.RoleId != (int)Role.Administrator)
                    users.Add(Context.UserId);
                else
                {
                    users = UsersFromEntity.Where(x => x.CustomerId == Context.CustomerId && (x.Id == (int)cbName.SelectedValue || (int)cbName.SelectedValue == -1)).Select(x => x.Id).ToList();
                }
                List<CodeITDL.File> tmpList = new List<CodeITDL.File>();
                DateTime to = dtpTo.Value.Date.AddHours(23).AddMinutes(59);
                if (cbSearchBy.SelectedIndex == 0)
                {
                    tmpList = FilesFromEntity.Where(x => x.OriginalFileDate >= dtpFrom.Value.Date && x.OriginalFileDate <= to && x.IsCloudFileSystem == isCloud && users.Contains(x.UserId)).OrderBy(x => x.NewFileName).ThenBy(x=>x.CreatedOn.Date).ToList();
                }
                else
                {
					tmpList = FilesFromEntity.Where(x => x.CreatedOn >= dtpFrom.Value.Date && x.CreatedOn <= to && x.IsCloudFileSystem == isCloud && users.Contains(x.UserId)).OrderBy(x => x.NewFileName).ThenBy(x => x.CreatedOn.Date).ToList();
                }

                if (tmpList != null && tmpList.Count > 0)
                {
                    for (int i = 0; i < tmpList.Count; i++)
                    {
                        FileFromDB fileDb = new FileFromDB(tmpList[i], i);
                        fileDb.UserName = (fileDb.UserId == Context.UserId ?
                                            (Context.getCurrentUser.FirstName + " " + Context.getCurrentUser.LastName) :
                                            UsersFromEntity.Where(u => u.Id == fileDb.UserId).Select(u => (u.FirstName + " " + u.LastName)).FirstOrDefault());
                        files.Add(fileDb);
                    }
                }
            }
            catch (Exception ex)
            {
                
            }
        }
Ejemplo n.º 3
0
		private void CheckForVideos(List<IDeviceObject> _files, User _uploadUser)
		{
            string lastFilename = "";
            string newfilename = "";

			try
			{
				if (_files != null && _files.Count > 0)
				{
                    GoProVideos = new List<FileFromDB>();
					

                    for (int i = 0; i < _files.Count; i++)
                    {
                        var item = _files[i];
                        VideoInfo info = VideoInfo.GetVideoInfo(item.Id);
                        FileFromDB file = new FileFromDB();

                        FileInfo fileInfo = new FileInfo(item.Id);

                        file.OriginalFileDate = ((Device)_goproDevice).getFileCreationDate(item.Id);

                        file.OriginalFileName = item.Name;
                        file.OriginalFileLocation = item.Name;
						                        
						file.NewFileName = GetFilenameFormat(file.OriginalFileDate, file.OriginalFileName);
						fileNames.Add(file.NewFileName);                       

                        file.CreatedOn = DateTime.Now;
                        file.isFromCard = true;
                        file.UserName = item.Name;

                        if (info != null)
					    {
                            file.Duration = (int)info.Duration;
                            file.Resolution = info.Resolution;
                        }

                        GoProVideos.Add(file);
					}

					ucUserVideos.lvItemsContainer.ContextMenu.Visibility = System.Windows.Visibility.Hidden;
					ucUserVideos.lvItemsContainer.ContextMenu.IsOpen = false;
					ucUserVideos.IsUpload = true;
                    ucUserVideos.lvItemsContainer.ItemsSource = GoProVideos;

					if (ucUserVideos.itemContainer != null)
					{
						ucUserVideos.itemContainer.Width = pnlMain.Width - 21 > 0 ? pnlMain.Width - 21 : pnlMain.Width;
					}

					ucUserVideos.ContextMenuClick -= uv_ContextMenuClick;
					ucUserVideos.ContextMenuClick += uv_ContextMenuClick;
				}
			}
			catch (Exception)
			{

			}
		}