Ejemplo n.º 1
0
 public IActionResult FormMatrixMultiplication(Models.MatrixMultiplication matrixMultiplication)
 {
     if (matrixMultiplication.MatrixA != null && matrixMultiplication.MatrixB != null)
     {
         try
         {
             LinearAlgebraNumMethods.MatrixMultiplication multiplication = new LinearAlgebraNumMethods.MatrixMultiplication();
             _multiplicationCPP.Result = multiplication.multiply(matrixMultiplication.MatrixA, matrixMultiplication.MatrixB);
         }
         catch (Exception) { }
     }
     return(View(_multiplicationCPP));
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> FileMatrixMultiplicationDownload(Models.MatrixMultiplication matrixMultiplication, IFormFileCollection inputFiles)
        {
            uint id = _options.FileId;

            lock (_options) _options.FileId++;

            List <string> markers = new List <string> {
                "A", "B"
            };
            int i = 0;

            string fileResult = _hostingEnvironment.WebRootPath + "\\output_files\\";
            string files      = Path.Combine(_hostingEnvironment.WebRootPath, "input_files");

            foreach (var file in inputFiles)
            {
                if (file != null)
                {
                    string filePath = Path.Combine(files, id.ToString() + markers[i] + ".txt");

                    await using FileStream stream = System.IO.File.Create(filePath);
                    await file.CopyToAsync(stream);

                    stream.Close();
                }

                i++;
            }

            try
            {
                LinearAlgebraNumMethods.MatrixMultiplication multiplication = new LinearAlgebraNumMethods.MatrixMultiplication();
                if (multiplication.multiply(id))
                {
                    fileResult += id.ToString() + ".txt";
                }
                else
                {
                    fileResult += "empty.txt";
                }
            }
            catch (Exception) { }

            Stream newStream = new FileStream(fileResult, FileMode.Open);

            return(File(newStream, "text/plain"));
        }