public HttpResponseMessage UploadData() { UploadFactory _downloadFactory = new UploadFactory(); var _response = _downloadFactory.Upload(); HttpResponseMessage response; response = Request.CreateResponse(HttpStatusCode.OK, _response); return(response); }
public async Task <HttpResponseMessage> PostUpload([FromBody] DownloadResponse request) { UploadFactory uploadFactory = new UploadFactory(); var retValue = await uploadFactory.PostData(request).ConfigureAwait(false); HttpResponseMessage response; response = Request.CreateResponse(HttpStatusCode.OK, retValue); return(response); }
public FileResult DownloadPAMUploadInstruction(int customerId) { //var fileName = "PAMConfig.txt"; //var fullFilePath = Path.Combine(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["pems.asset.samples"]), fileName); //return File(fullFilePath, "text/txt", fileName); // Make a copy of the appropriate instrunction template file. var fileName = "PAMConfig.txt"; var sourcePath = Path.Combine(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["pems.asset.samples"]), fileName); var uniqueFileName = Guid.NewGuid().ToString() + ".txt"; var destinationPath = Path.Combine(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["pems.asset.upload"]), uniqueFileName); System.IO.File.Copy(sourcePath, destinationPath, true); // Open the new file using (StreamWriter sw = System.IO.File.AppendText(destinationPath)) { // Append the date to it. sw.WriteLine(); sw.WriteLine("Created: " + DateTime.Now.ToShortDateString()); sw.WriteLine(); // Add appropriate constraints. var connStringName = (new SettingsFactory()).GetCustomerConnectionStringName(customerId); var uploadFactory = new UploadFactory(connStringName, CurrentCity.LocalTime); sw.WriteLine(uploadFactory.ConstraintsListForPAMConfig(customerId)); sw.WriteLine(); // Add appropriate field notes sw.WriteLine(); sw.WriteLine(uploadFactory.FieldsListForPAMConfig()); // Save file. sw.Close(); } return(File(destinationPath, "text/txt", fileName)); }
public FileResult DownloadInstructions(int customerId) { // Make a copy of the appropriate instrunction template file. const string fileName = "eventcodes.txt"; var sourcePath = Path.Combine(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["pems.eventcodes.samples"]), fileName); var uniqueFileName = Guid.NewGuid().ToString() + ".txt"; var destinationPath = Path.Combine(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["pems.eventcodes.upload"]), uniqueFileName); System.IO.File.Copy(sourcePath, destinationPath, true); // Open the new file using (StreamWriter sw = System.IO.File.AppendText(destinationPath)) { // Append the date to it. sw.WriteLine(); sw.WriteLine("Created: " + DateTime.Now.ToShortDateString()); sw.WriteLine(); // Add appropriate constraints. var uploadFactory = new UploadFactory(Session[Constants.Security.ConnectionStringSessionVariableName].ToString()); sw.WriteLine(uploadFactory.ConstraintsList(customerId)); sw.WriteLine(); // Add appropriate field notes sw.WriteLine(); sw.WriteLine(uploadFactory.FieldsList(customerId)); // Save file. sw.Close(); } return(File(destinationPath, "text/txt", fileName)); }