Пример #1
0
 public string GetFix(SunFixAttributes sunFixAttributes)
 {
     try
     {
         SunFixContext sunFix = new SunFixContext(sunFixAttributes.SunFixType,container);
         return sunFix.GenerateFix(sunFixAttributes);
     }
     catch (Exception ex)
     {
         return new StringBuilder("XML/Script Cannot be formed. Please Investigate.\n\nException:\n").Append(ex.Message).ToString();
     }
 }
Пример #2
0
 public abstract string GenerateFix(SunFixAttributes sunFixAttributes);
Пример #3
0
 public string GenerateXMLFromScript(string scriptToBeExecuted,SunFixAttributes sunFixAttributes)
 {
     SunFixContext sunFixContext = new SunFixContext(SunFixType.Sun, container);
     return sunFixContext.ProcessGeneratedScript(scriptToBeExecuted, sunFixAttributes);
 }
Пример #4
0
 public string GenerateFix(SunFixAttributes sunFixAttributes)
 {
     StructureMap.Container container = new Container();
     return _sunFixStrategy.GenerateFix(sunFixAttributes);
 }
 public SunChangedPremiumsTemplate(SunFixAttributes sunFixAttr)
 {
     this.sunFixAttributes = sunFixAttr;
 }
        //public JsonResult Upload(HttpPostedFileBase collection)
        //{
        //    string fileName = Request.Headers["X-File-Name"];
        //    string fileType = Request.Headers["X-File-Type"];
        //    int fileSize = int.Parse(Request.Headers["X-File-Size"]);
        //    System.IO.Stream fileContent = Request.InputStream;
        //    System.IO.FileStream fileStream = System.IO.File.Create(Server.MapPath("~/") + fileName);
        //    fileContent.Seek(0, System.IO.SeekOrigin.Begin);
        //    fileContent.CopyTo(fileStream);
        //    fileStream.Dispose();
        //    return Json("Uploaded files");
        //}
        public string Upload2(FormCollection files)
        {
            string rootPath = Path.Combine(Server.MapPath("~/"), "Temp");
            string tempFolderFixPath = Path.Combine(rootPath, DateTime.Now.ToString("yyyyMMddHHmmss"));
            Directory.CreateDirectory(tempFolderFixPath);
            for (int counter = 0; counter < Request.Files.Count;counter++)
                //foreach (HttpPostedFileBase file in Request.Files) -- cant use this :(
                {
                    using (Stream fileContentStream = new MemoryStream())
                    {
                        Request.Files[counter].InputStream.CopyTo(fileContentStream);

                        SunFixAttributes sunFixAttributes = new SunFixAttributes() {SunFixType = Model.SunFixType.Sun, BusinessUnit = "PPL" };
                        string liveXML = sunService.ProcessXMLFromStream(fileContentStream, sunFixAttributes);

                        using(StreamWriter fileStream = System.IO.File.CreateText(Path.Combine(tempFolderFixPath,Request.Files[counter].FileName))){
                            fileStream.Write(liveXML);

                        }
                    }
                }
            if (System.IO.File.Exists(Path.Combine(rootPath, zipFileName)))
            {
                System.IO.File.Delete(Path.Combine(rootPath, zipFileName));
            }

            ZipFile.CreateFromDirectory(tempFolderFixPath, Path.Combine(rootPath, zipFileName));

            Directory.Delete(tempFolderFixPath,true);

            return (zipFileName);

            //var cd = new System.Net.Mime.ContentDisposition
            //{
            //    FileName = "avais.zip",
            //    // always prompt the user for downloading, set to true if you want
            //    // the browser to try to show the file inline
            //    Inline = false,
            //};
            //Response.AppendHeader("Content-Disposition", cd.ToString());
            //return File(Path.Combine(rootPath, "AccountsFix.zip"), "application/octet-stream");
            //return null;
        }
 public ActionResult GenerateXMLFromScript(String scriptToBeExecuted, SunFixAttributes sunFixAttributes)
 {
     string generatedXml = sunService.GenerateXMLFromScript(scriptToBeExecuted,sunFixAttributes);
     return Json(generatedXml);
 }
        public ActionResult GenerateFix(SunFixAttributes sunFixAttributes)
        {
            CCTransaction ccTransaction = sunService.GetTransactionByCCTransactionId(sunFixAttributes.CCTransactionId);

            if (!ModelState.IsValid)
            {
                List<String> errorMessages = new List<String>();
                ModelState.Values.ToList().ForEach(modelStateValues =>
                {
                    if (modelStateValues.Errors.Count > 0)
                    {
                        errorMessages.AddRange(modelStateValues.Errors.Select(error => error.ErrorMessage));
                    }
                });

                @ViewBag.Error = errorMessages.Select(e => e);
                @ViewBag.SearchText = ccTransaction.BrokerReference;
                return View("SearchResults", sunService.GetCreditControlTransaction(ccTransaction.BrokerReference));
            }

            string generatedFix = sunService.GetFix(sunFixAttributes);

            GeneratedXMLModel viewModel = new GeneratedXMLModel();
            viewModel.GeneratedFix = generatedFix;
            viewModel.SunFixType = sunFixAttributes.SunFixType;
            viewModel.PPReference = ccTransaction.Reference;
            viewModel.transactionType = sunFixAttributes.TransactionType;

            return View("GeneratedFix",viewModel);
        }