Exemple #1
0
        public JsonResult Upload(HttpPostedFileBase file, IndexViewModel model)
        {
            var result = new XmlViewModel();
            var downloadedFilePath = string.Empty;

            var fileManager = new FileManager();
            var serverPath = Server.MapPath("~/Assert/uploads/");

            if (!string.IsNullOrEmpty(model.SourceFileUrl))
            {
                downloadedFilePath = fileManager.SaveFileByUrl(serverPath, model.SourceFileUrl);
            }

            if (!string.IsNullOrEmpty(model.TargetFileUrl))
            {
                downloadedFilePath = fileManager.SaveFileByUrl(serverPath, model.TargetFileUrl);
            }

            if (downloadedFilePath == string.Empty && file != null && file.ContentLength > 0)
            {
                MemoryStream target = new MemoryStream();
                file.InputStream.CopyTo(target);
                byte[] data = target.ToArray();

                downloadedFilePath = fileManager.SaveFileByByte(serverPath, data, file.FileName);
            }

            var manager = new XmlManager();
            result.SourceFilePath = downloadedFilePath;
            result.XmlNodes = manager.GetXmlNodes(downloadedFilePath);

            return Json(result, JsonRequestBehavior.AllowGet);
        }
Exemple #2
0
        public void File_Must_Extesion_Xml()
        {
            FileManager fileManager = new FileManager();

            var extension = fileManager.ControlExtension("filename.xml");

            Assert.AreEqual(extension, true);
        }