Inheritance: System.Web.UI.Page
        public override void Execute()
        {
            GetFile getFile   = new GetFile(Comm);
            var     fileBytes = getFile.GetFileBytes();

            fileBytes.SendDataArray(Comm.Client_Socket);
        }
        public void Arrange()
        {
            this.mockFileManager = new Mock <IFileManager>();

            Mock <ILoggerProvider> mockLoggerProvider = new Mock <ILoggerProvider>();

            this.getFile = new GetFile(
                this.mockFileManager.Object,
                mockLoggerProvider.Object);
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor to fetch the json file as a string
        /// from GetFile class
        /// </summary>
        public CurrencyParser()
        {
            var jsonFile = GetFile.Get();

            if (string.IsNullOrEmpty(jsonFile) || string.IsNullOrWhiteSpace(jsonFile))
            {
                throw new FileLoadException(Messages.LoadUnsuccessful);
            }
            JsonFile = jsonFile;
        }
Esempio n. 4
0
 public IActionResult GetImageShopCard(string image, [FromServices] GetFile getFile)
 {
     try
     {
         return(new FileStreamResult(getFile.GetShopCardImage(image), $"image/{image.Substring(image.LastIndexOf('.') + 1)}"));
     }
     catch (Exception)
     {
         return(new FileStreamResult(getFile.GetShopCardImage("Placeholder.jpg"), $"image/{"Placeholder.jpg".Substring("Placeholder.jpg".LastIndexOf('.') + 1)}"));
     }
 }
Esempio n. 5
0
 public IActionResult Image(string image, [FromServices] GetFile getFile)
 {
     try
     {
         FileStreamResult result = new FileStreamResult(getFile.Do(image), $"image/{image.Substring(image.LastIndexOf('.') + 1)}");
         return(result);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 6
0
 public async Task<IActionResult> GetFileAsync(Guid id, string fileType)
 {
     var command = new GetFile
     {
         OrderId = id,
         FileType = fileType,
         CacheId = Guid.NewGuid()
     };
     await DispatchAsync(command);
     var result = Cache.Get(command.CacheId);
     if(result is MemoryStream fileStream)
         return new FileContentResult(fileStream.ToArray(),"application/pdf");
     throw new InvalidCastException();
 }
Esempio n. 7
0
        public object Get(GetFile request)
        {
            var file = VirtualFileSources.GetFile(request.Path);

            if (file == null)
            {
                throw HttpError.NotFound("File does not exist");
            }

            var bytes = file.GetBytesContentsAsBytes();
            var to    = new FileContent {
                Name   = file.Name,
                Type   = MimeTypes.GetMimeType(file.Extension),
                Body   = bytes,
                Length = bytes.Length,
            };

            return(to);
        }
Esempio n. 8
0
        private void listView2_DoubleClick(object sender, EventArgs e)
        {
            if (listView2.SelectedItems.Count > 0 && CurrentClient != null)
            {
                ListViewItem item    = listView2.SelectedItems[listView2.SelectedItems.Count - 1];
                string       DirName = "";

                FileSystem dirinfo = item.Tag as FileSystem;
                if (dirinfo.FileType == FileType.Dir)
                {
                    DirName = dirinfo.FullName;
                }
                else
                {
                    if (MessageBox.Show("是否下载文件:" + dirinfo.Name + "?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        FileSystem downFile = (this.listView2.SelectedItems[this.listView2.SelectedItems.Count - 1].Tag as FileSystem);

                        if (downFile != null)
                        {
                            Down down = new Down()
                            {
                                FullName = downFile.FullName
                            };

                            CurrentClient.SendData(BufferFormatV2.FormatFCA(down));
                        }
                    }
                    return;
                }

                GetFile tmp = new GetFile()
                {
                    DirName        = DirName,
                    FileSystemList = new List <FileSystem>(),
                    IsSuccess      = false,
                    Msg            = ""
                };

                CurrentClient.SendData(BufferFormatV2.FormatFCA(tmp));
            }
        }
Esempio n. 9
0
        private void listView1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem item = listView1.SelectedItems[0];

                if (item.Tag != null)
                {
                    UserInfo tmp = item.Tag as UserInfo;

                    if (tmp != null)
                    {
                        CurrentClient = tmp;

                        if (!tmp.IsValidate)
                        {
                            LogOn tmpwin = new LogOn();
                            tmpwin.ShowDialog();

                            string password = tmpwin.PassWrod;

                            Success logon = new Success()
                            {
                                Key = password
                            };

                            tmp.SendData(BufferFormatV2.FormatFCA(logon));
                        }
                        else
                        {
                            GetFile getfile = new GetFile();

                            tmp.SendData(BufferFormatV2.FormatFCA(getfile));
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        private static void handle_sendFile(GetFile cmd)
        {
            FileInfo f = new FileInfo(fileManager.clean_path(cmd.file));

            if (f.Length < IBfileTrans.chunk_size)
            {
                send_byte(resTObyte(new SendFile(cmd.file,
                                                 File.ReadAllBytes(cmd.file),
                                                 0,
                                                 0,
                                                 (int)f.Length
                                                 )));
                return;
            }

            fileManager.start(cmd.file);
            send_byte(resTObyte(new SendFile(fileManager.clean_path(cmd.file),
                                             fileManager.tobe_sent,
                                             fileManager.get_chunk_num(cmd.file),
                                             fileManager.calc_num_chunks((int)f.Length),
                                             (int)f.Length
                                             )));
        }
Esempio n. 11
0
    void OnGUI()
    {
        style.fontSize       = Screen.height / 25;
        buttonStyle.fontSize = Screen.height / 30;
        string name = Path.GetFileName(path);

        GUI.Label(settingsLabel, "Settings", style);
        GUI.Label(shuffleLabel, "shuffle cards", style);
        GUI.Label(flipLabel, "flip cards", style);
        GUI.Label(chooseLabel, "choose character:", style);
        GUI.Label(loadLabel, name, style);

        if (GUI.Button(shuffle, shufflebox, avatarStyle))
        {
            isShuffle = !isShuffle;
        }
        if (GUI.Button(flip, flipbox, avatarStyle))
        {
            isFlip = !isFlip;
        }

        if (GUI.Button(ethan, ethanTexture, avatarStyle))
        {
            isEthan = !isEthan;
            if (isEthan)
            {
                isShizuku = false;
            }
        }

        if (GUI.Button(shizuku, shizukuTexture, avatarStyle))
        {
            isShizuku = !isShizuku;
            if (isShizuku)
            {
                isEthan = false;
            }
        }

        if (GUI.Button(load, "load deck", buttonStyle))
        {
            Debug.Log("opening file dialogue");
            path = GetFile.OpenFileDialog();
            Debug.Log("file path: " + path);
        }

        if (GUI.Button(back, "back", buttonStyle))
        {
            Application.LoadLevel("splash");
        }

        if (GUI.Button(next, "next", buttonStyle))
        {
            PlayerPrefs.SetString("isShuffle", isShuffle ? "true":"false");
            PlayerPrefs.SetString("isFlipCard", isFlip ? "true":"false");
            PlayerPrefs.SetString("deckLocation", path);

            Debug.Log("isShuffle: " + PlayerPrefs.GetString("isShuffle") + " isFlipCard: " + PlayerPrefs.GetString("isFlipCard"));

            if (isEthan)
            {
                PlayerPrefs.SetString("avatar", "ethan");
            }
            if (isShizuku)
            {
                PlayerPrefs.SetString("avatar", "shizuku");
            }
            if (!isEthan && !isShizuku)
            {
                Debug.Log("there is a problem");
            }

            if (isEthan)
            {
                Application.LoadLevel("ethan");
            }
            if (isShizuku)
            {
                Application.LoadLevel("shizuku");
            }
        }
    }
Esempio n. 12
0
 public async Task <FileModel> GetFileAsync([FromBody] GetFile getFile)
 {
     return(await _mediator.Send(getFile));
 }
Esempio n. 13
0
        /// <summary>
        /// Gets the files for a directory
        /// </summary>
        /// <param name="directoryName">The directory name</param>
        /// <param name="fileNamePrefix">The name prefixing the file</param>
        /// <param name="fileNameSuffix">The name sufixing the file</param>
        /// <param name="fileProducer">The delegate to get the file</param>
        /// <returns>A list of files</returns>
        public static List <FileSystemItem> GetFiles(string directoryName, string fileNamePrefix, string fileNameSuffix, GetFile fileProducer)
        {
            List <FileSystemItem> files = new List <FileSystemItem>();

            if (string.IsNullOrEmpty(directoryName) || !Directory.Exists(directoryName))
            {
                return(files);
            }
            foreach (string fileName in Directory.GetFiles(directoryName))
            {
                FileSystemItem file = null;
                if (fileProducer(Path.Combine(directoryName, fileName), fileNamePrefix, fileNameSuffix, out file))
                {
                    bool found = false;
                    foreach (FileSystemItem checkFile in files)
                    {
                        if (checkFile.Name == file.Name)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        files.Add(file);
                    }
                }
            }
            return(files);
        }
Esempio n. 14
0
        private static void ExtractGame(RvGame tGame, string outDir)
        {
            if (buffer == null)
            {
                buffer = new byte[BufferSize];
            }

            ZipReturn zr;
            bool      romGot = false;

            for (int rIndex = 0; rIndex < tGame.Roms.Count; rIndex++)
            {
                if (tGame.Roms[rIndex].FileId != null)
                {
                    romGot = true;
                    break;
                }
            }

            if (!romGot)
            {
                return;
            }

            // export the rom;

            ZipFile zipOut   = new ZipFile();
            string  filename = Path.Combine(outDir, tGame.Name + ".zip");

            filename = filename.Replace(@"/", @"\");
            if (!Directory.Exists(filename))
            {
                string dir = Path.GetDirectoryName(filename);
                Directory.CreateDirectory(dir);
            }
            zr = zipOut.ZipFileCreate(filename);
            if (zr != ZipReturn.ZipGood)
            {
                MessageBox.Show("Error creating " + Path.Combine(outDir, tGame.Name + ".zip") + " " + zr);
                return;
            }

            for (int rIndex = 0; rIndex < tGame.Roms.Count; rIndex++)
            {
                RvRom tRom = tGame.Roms[rIndex];
                if (tRom.FileId != null)
                {
                    GZip sourceGZip = new GZip();

                    string sha1 = Getfilename(GetFile.Execute((uint)tRom.FileId));

                    zr = sourceGZip.ReadGZip(sha1, false);

                    if (zr != ZipReturn.ZipGood)
                    {
                        sourceGZip.Close();
                        continue;
                    }

                    Stream outStream;
                    zipOut.ZipFileOpenWriteStream(true, true, tRom.Name, sourceGZip.uncompressedSize, 8, out outStream);

                    Stream gZipStream;
                    zr = sourceGZip.GetRawStream(out gZipStream);
                    if (zr == ZipReturn.ZipGood)
                    {
                        // write the gzip stream to the zipstream
                        ulong sizetogo = sourceGZip.compressedSize;

                        while (sizetogo > 0)
                        {
                            int sizenow = sizetogo > BufferSize ? (int)BufferSize : (int)sizetogo;

                            gZipStream.Read(buffer, 0, sizenow);
                            outStream.Write(buffer, 0, sizenow);

                            sizetogo = sizetogo - (ulong)sizenow;
                        }
                    }
                    sourceGZip.Close();

                    zipOut.ZipFileCloseWriteStream(sourceGZip.crc);
                }
            }
            zipOut.ZipFileClose();
        }
Esempio n. 15
0
        public override void Execute()
        {
            GetFile GetFileComm = new GetFile();

            GetFileComm.GetFileBytes(Comm);
        }