public IEnumerable <IFileData> HandleNewScreenshots(ISourcePort sourcePort, IGameFile gameFile, string[] files)
        {
            List <IFileData> ret = new List <IFileData>();

            if (gameFile != null && gameFile.GameFileID.HasValue)
            {
                foreach (string file in files)
                {
                    try
                    {
                        FileInfo fi       = new FileInfo(file);
                        string   fileName = Guid.NewGuid().ToString() + fi.Extension;
                        fi.CopyTo(Path.Combine(ScreenshotDirectory.GetFullPath(), fileName));
                        FileData fileData = new FileData();
                        fileData.FileName     = fileName;
                        fileData.GameFileID   = gameFile.GameFileID.Value;
                        fileData.SourcePortID = sourcePort.SourcePortID;
                        fileData.FileTypeID   = FileType.Screenshot;

                        DataSourceAdapter.InsertFile(fileData);
                        ret.Add(fileData);
                    }
                    catch
                    {
                        //failed, nothing to do
                    }
                }
            }

            return(ret);
        }
示例#2
0
        public IEnumerable <IFileData> HandleNewSaveGames(ISourcePortData sourcePort, IGameFile gameFile, string[] files)
        {
            List <IFileData> ret = new List <IFileData>();

            if (gameFile != null && gameFile.GameFileID.HasValue)
            {
                foreach (string file in files)
                {
                    try
                    {
                        FileInfo fi       = new FileInfo(file);
                        string   fileName = Guid.NewGuid().ToString() + fi.Extension;
                        fi.CopyTo(Path.Combine(SaveGameDirectory.GetFullPath(), fileName));

                        FileData fileData = new FileData
                        {
                            Description      = GetSaveGameName(sourcePort, fi),
                            OriginalFileName = fi.Name,
                            FileName         = fileName,
                            GameFileID       = gameFile.GameFileID.Value,
                            SourcePortID     = sourcePort.SourcePortID,
                            FileTypeID       = FileType.SaveGame
                        };

                        DataSourceAdapter.InsertFile(fileData);
                        ret.Add(fileData);
                    }
                    catch
                    {
                        //failed, nothing to do
                    }
                }
            }

            return(ret);
        }