//public IList<ColFile> GetFileStat_OLD(IList<StatFileTreeLeaf> StatTreeLeafs, IList<Int32> UsersIds, Int32 CurrentUserId) //{ // //Recupero i dati sui file dagli ID appena recuperati // //INFO SUI DOWNLOAD: // //IList<FileDownloadInfo> SinglePermFDIs = (from f in Manager.GetIQ<FileDownloadInfo>() // // where SinglePermFileIds.Contains(f.File.Id) && UsersIds.Contains(f.Downloader.Id) // // select f).ToList(); // //IList<FileDownloadInfo> NoPermFDIs = (from f in Manager.GetIQ<FileDownloadInfo>() // // where NoPermFileIds.Contains(f.File.Id) && UsersIds.Contains(f.Downloader.Id) // // select f).ToList(); // //Definizione di alcune "variabili interne": // //Permessi per tutti gli utenti // IList<ColFile> AllPermFiles = new List<ColFile>(); // IList<Guid> AllPermGuids = new List<Guid>(); // //Permessi solo per l'utente corrente // IList<ColFile> SinglePermFiles = new List<ColFile>(); // IList<Guid> SinglePermGuids = new List<Guid>(); // IList<Int32> SingleUserId = new List<Int32>(); // if (CurrentUserId != null || CurrentUserId != 0) // { // SingleUserId.Add(CurrentUserId); // } // //No permessi // IList<ColFile> NoPermFiles = new List<ColFile>(); // //"Trasformo" le info raccolte da COMOL, nel DTO per le statistiche SCORM // //foreach (FileDownloadInfo fdi in AllPermFDIs) // //{ // // AllPermFiles.Add(FileDownloadInfo_to_ColFile(fdi,2)); // // if (fdi.File.isSCORM) // // { // // AllPermGuids.Add(fdi.UniqueID); // // } // //} // //foreach (FileDownloadInfo fdi in SinglePermFDIs) // //{ // // SinglePermFiles.Add(FileDownloadInfo_to_ColFile(fdi,1)); // // if (fdi.File.isSCORM) // // { // // SinglePermGuids.Add(fdi.UniqueID); // // } // //} // //foreach (FileDownloadInfo fdi in NoPermFDIs) // //{ // // ColFile file = new ColFile(); // // file.Id = fdi.File.Id; // // file.Guid = Guid.Empty; // // file.Name = fdi.File.DisplayName; // // file.Permission = 0; // // NoPermFiles.Add(file); // //} // //Recupero le statistiche per i file di cui ho tutti i permessi // IList<ColFile> AllFiles = this.ColScormManager.GetStatGenericFile(AllPermFiles, AllPermGuids, UsersIds); // //Recupero le statistiche per i file di cui posso visualizzare solo l'utente corrente // IList<ColFile> SingleFiles = new List<ColFile>(); // if (SingleUserId.Count >= 0) // { // SingleFiles = this.ColScormManager.GetStatGenericFile(SinglePermFiles, SinglePermGuids, SingleUserId); // } // //I file di cui non ho permessi, non vado a raccogliere nulla... // //Ritorno la UNION delle 3 precedenti, ordinata per nome file... // return (from ColFile file // in AllFiles.Union(SingleFiles.Union(NoPermFiles)) // orderby file.Name select file).ToList(); //} private ColFile FileDownloadInfo_to_ColFile(FileDownloadInfo fdi, long Permission) { ColFile file = new ColFile(); file.Id = fdi.Id; file.Guid = fdi.UniqueID; file.Name = fdi.File.DisplayName; file.Permission = Permission; //fdi.Link.Permission; //file.Package //file.PlayCount //file.TotActivity file.UploadDate = fdi.File.CreatedOn; ColPerson person = new ColPerson(); person.Id = fdi.File.Owner.Id; person.Name = fdi.File.Owner.Name; person.SecondName = fdi.File.Owner.Surname; file.UploadedBy = person; return(file); }
public ObservableCollection <DataGridResult> Execute() { var ColResult = new ObservableCollection <DataGridResult>(); // 対局情報の編集 foreach (var oneGame in ColGame) { if (oneGame.GameDate >= FindFrom && oneGame.GameDate <= FindTo) { var oneSetting = ColRule.Where(item => item.ID == oneGame.SettingID).First(); var oneData = new DataGridResult(); // 対局者を一人ずつ確認 // これまでに登場していなければオブジェクトを新規作成 #region 東家 if (ColResult.Where(item => item.ID == oneGame.East).Count() == 0) { oneData = new DataGridResult() { ID = oneGame.East, Name = ColPerson.Where(item => item.ID == oneGame.East).First().Name, GameCount = 0, TotalScore = 0, TotalScoreRate = 0.0 }; // コレクションに追加 ColResult.Add(oneData); } oneData = ColResult.Where(item => item.ID == oneGame.East).First(); oneData.GameCount += 1; oneData.TotalScore += oneGame.EastScore; oneData.TotalScoreRate += oneGame.EastScore * oneSetting.Rate * 1000; #endregion #region 南家 if (ColResult.Where(item => item.ID == oneGame.South).Count() == 0) { oneData = new DataGridResult() { ID = oneGame.South, Name = ColPerson.Where(item => item.ID == oneGame.South).First().Name, GameCount = 0, TotalScore = 0, TotalScoreRate = 0.0 }; // コレクションに追加 ColResult.Add(oneData); } oneData = ColResult.Where(item => item.ID == oneGame.South).First(); oneData.GameCount += 1; oneData.TotalScore += oneGame.SouthScore; oneData.TotalScoreRate += oneGame.SouthScore * oneSetting.Rate * 1000; #endregion #region 西家 if (ColResult.Where(item => item.ID == oneGame.West).Count() == 0) { oneData = new DataGridResult() { ID = oneGame.West, Name = ColPerson.Where(item => item.ID == oneGame.West).First().Name, GameCount = 0, TotalScore = 0, TotalScoreRate = 0.0 }; // コレクションに追加 ColResult.Add(oneData); } oneData = ColResult.Where(item => item.ID == oneGame.West).First(); oneData.GameCount += 1; oneData.TotalScore += oneGame.WestScore; oneData.TotalScoreRate += oneGame.WestScore * oneSetting.Rate * 1000; #endregion #region 北家 if (ColResult.Where(item => item.ID == oneGame.North).Count() == 0) { oneData = new DataGridResult() { ID = oneGame.North, Name = ColPerson.Where(item => item.ID == oneGame.North).First().Name, GameCount = 0, TotalScore = 0, TotalScoreRate = 0.0 }; // コレクションに追加 ColResult.Add(oneData); } oneData = ColResult.Where(item => item.ID == oneGame.North).First(); oneData.GameCount += 1; oneData.TotalScore += oneGame.NorthScore; oneData.TotalScoreRate += oneGame.NorthScore * oneSetting.Rate * 1000; #endregion } } // 総得点の降順でソート ColResult = new ObservableCollection <DataGridResult>(ColResult.OrderByDescending(item => item.TotalScore)); return(ColResult); }