public async Task <IActionResult> DocumentCategoryAccessories([FromForm] DocumentTypeViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile); if (message == "success") { attachPath = fileName; } } DocumentCategoryAccessories documentCategory = new DocumentCategoryAccessories { Id = (int)model.documentcategoryId, documentTypeId = model.documentTypeId, accessoriesName = model.documentCategoryName, accessoriesNameBn = model.documentCategoryNameBn, imagePath = attachPath, shortOrder = model.shortOrder }; await lostAndFoundType.SaveDocumentCategoryAccessories(documentCategory); return(RedirectToAction("DocumentCategoryAccessories", new RouteValueDictionary( new { controller = "MasterInformation", action = "DocumentCategoryAccessories", Id = model.documentTypeId }))); }
public async Task Close() { ISave save = null; switch (_settings.ExtractMethod) { case DataMethods.File: { save = new FileSave(_dataBacklinkRowService, _dataListedInfoService, _dataTagAService, _settings); break; } case DataMethods.GoogleDocs: { save = new SpreadSheetSave(_dataBacklinkRowService, _dataListedInfoService, _dataTagAService, _settings); break; } case DataMethods.Excell: { save = new ExcelSave(_dataBacklinkRowService, _dataListedInfoService, _dataTagAService, _settings); break; } } await save.Save(); }
// <returns>An instance to a <see cref="FileSave"/> class generated from the <see cref="ScintillaTabbedDocument"/> class instance.</returns> /// <summary> /// Creates a <see cref="FileSave"/> entity from a given <see cref="ScintillaTabbedDocument"/> document. /// </summary> /// <param name="document">The document to create a file save from.</param> /// <param name="encoding">The encoding of the file save.</param> /// <param name="fileSession">The file session.</param> /// <param name="isHistory">if set to <c>true</c> the resulting <see cref="FileSave"/> instance is marked as a history file.</param> /// <returns>An instance to a <see cref="FileSave"/> modified class.</returns> public static FileSave CreateFromTabbedDocument(ScintillaTabbedDocument document, Encoding encoding, FileSession fileSession, bool isHistory = false) { var fileSave = new FileSave { ExistsInFileSystem = File.Exists(document.FileName), FileNameFull = document.FileName, FileName = Path.GetFileName(document.FileName), FilePath = Path.GetDirectoryName(document.FileName), FileSystemModified = File.Exists(document.FileName) ? new FileInfo(document.FileName).LastWriteTime : DateTime.MinValue, LexerType = document.LexerType, VisibilityOrder = (int)document.FileTabButton.Tag, Session = ScriptNotepadDbContext.DbContext.FileSessions.FirstOrDefault(f => f.SessionName == fileSession.SessionName), IsActive = document.FileTabButton.IsActive, IsHistory = isHistory, CurrentCaretPosition = document.Scintilla.CurrentPosition, UseSpellChecking = true, EditorZoomPercentage = document.ZoomPercentage, UseFileSystemOnContents = fileSession.UseFileSystemOnContents, }; fileSave.SetDatabaseModified(DateTime.Now); fileSave.SetEncoding(encoding); fileSave.SetFileContents(encoding.GetBytes(document.Scintilla.Text), true, false, true); ScriptNotepadDbContext.DbContext.FileSaves.Add(fileSave); ScriptNotepadDbContext.DbContext.SaveChanges(); return(fileSave); }
/// <summary> /// Sets the contents of the <see cref="FileSave"/> class instance. /// </summary> /// <param name="fileSave">The file save of which contents to set.</param> /// <param name="contents">The contents as a string.</param> /// <param name="commit">A value indicating whether to commit the changes to the /// database or to the file system cache depending on the setting.</param> /// <param name="saveToFileSystem">A value indicating whether to override existing copy of the file in the file system.</param> /// <param name="contentChanged">A value indicating whether the file contents have been changed.</param> /// <returns>An instance to a <see cref="FileSave"/> modified class.</returns> public static FileSave SetContents(this FileSave fileSave, string contents, bool commit, bool saveToFileSystem, bool contentChanged) { fileSave.SetFileContents(fileSave.GetEncoding().GetBytes(contents), commit, saveToFileSystem, contentChanged); return(fileSave); }
/// <summary> /// Updates the file data of the <see cref="FileSave"/> class instance with a given full file name. /// </summary> /// <param name="fileSave">The file save.</param> /// <param name="fileNameFull">The full file name.</param> /// <returns>An instance to a <see cref="FileSave"/> modified class.</returns> public static FileSave UpdateFileData(this FileSave fileSave, string fileNameFull) { fileSave.FileName = Path.GetFileName(fileNameFull); fileSave.FileNameFull = fileNameFull; fileSave.FilePath = Path.GetDirectoryName(fileNameFull); return(fileSave); }
public async Task <IActionResult> DocumentCategory([FromForm] DocumentTypeViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile); if (message == "success") { attachPath = fileName; } } DocumentCategory documentCategory = new DocumentCategory { Id = (int)model.documentcategoryId, documentTypeId = model.documentTypeId, categoryName = model.documentCategoryName, categoryNameBn = model.documentCategoryNameBn, imagePath = attachPath }; await lostAndFoundType.SaveDocumentCategory(documentCategory); return(RedirectToAction(nameof(DocumentCategory))); }
public async Task <IActionResult> ComputerAccessoriesBrand([FromForm] DocumentTypeViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile); if (message == "success") { attachPath = fileName; } } ComputerAccessoriesBrand computerAccessoriesBrand = new ComputerAccessoriesBrand { Id = (int)model.documentcategoryId, brandName = model.documentCategoryName, brandNameBn = model.documentCategoryNameBn, imagePath = attachPath }; await lostAndFoundType.SaveComputerAccessoriesBrand(computerAccessoriesBrand); return(RedirectToAction(nameof(ComputerAccessoriesBrand))); }
public async Task <IActionResult> ProductType([FromForm] ProductTypeViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/ProductType", model.formFile); if (message == "success") { attachPath = fileName; } } ProductType productType = new ProductType { Id = (int)model.productTypeId, productTypeName = model.productTypeName, productTypeNameBn = model.productTypeNameBn, imagePath = attachPath }; await lostAndFoundType.SaveProductType(productType); return(RedirectToAction(nameof(ProductType))); }
public async Task <IActionResult> OccupationInfo([FromForm] OccupationViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/OccupationFile", model.formFile); if (message == "success") { attachPath = fileName; } } Occupation occupation = new Occupation { Id = (int)model.occupationId, name = model.name, nameBn = model.nameBn, imagePath = attachPath }; await lostAndFoundType.SaveOccupation(occupation); return(RedirectToAction(nameof(OccupationInfo))); }
public async Task <IActionResult> UploadUserImage(IFormFile formFile) { try { var userName = User.Claims.FirstOrDefault().Value; string returnResult = "success"; string imagePath = string.Empty; var jwt = new object(); if (formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/GenarelUser", formFile); if (message == "success") { imagePath = fileName; } } ApplicationUser user = await _userManager.FindByNameAsync(userName); user.ImagePath = imagePath; await _userManager.UpdateAsync(user); return(new OkObjectResult(returnResult)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> AnimalInfo([FromForm] AnimalViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile); if (message == "success") { attachPath = fileName; } } Animal animal = new Animal { Id = (int)model.animalId, animalName = model.animalName, animalNameBn = model.animalNameBn, imagePath = attachPath }; await lostAndFoundType.SaveAnimal(animal); return(RedirectToAction(nameof(AnimalInfo))); }
//写取文件内容 private string WriteFileText(string data, string Dir = "") { try { //Dir = Dir == "" ? DateTime.Now.ToString("yyyyMM") : Dir; FileSave f = JsonConvert.DeserializeObject <FileSave>(data); string dirPath = AppDomain.CurrentDomain.BaseDirectory + "CustomFun\\" + (Dir == "" ? "" : Dir + "\\"); dirPath = dirPath + (string.IsNullOrEmpty(f.Dir) ? "" : f.Dir + "\\"); //验证文件路径 if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } string strFilePath = dirPath + f.FileName; using (StreamWriter sw = new StreamWriter(strFilePath, false, Encoding.UTF8)) { byte[] bytes = Convert.FromBase64String(f.Text); sw.Write(HttpContext.Current.Server.UrlDecode(Encoding.UTF8.GetString(bytes))); sw.Flush(); } return("{}"); } catch (Exception ex) { return("{Error: \"" + ex.Message + "\"}"); } }
public async Task <string> AddFileSave(FileSave fileSave) { try { _context.FileSaves.Add(fileSave); var response = await _context.SaveChangesAsync(); if (response < 1) { return("Cannot execute. Plz contact Admin"); } fileSave.Url = fileSave.FileName.Replace(" ", "-") + "-" + fileSave.Id; _context.FileSaves.Update(fileSave); response = await _context.SaveChangesAsync(); if (response < 1) { return("Cannot execute. Plz contact Admin"); } return("OK"); } catch (Exception ex) { throw ex; } }
private void Awake() { //The standard file path in unity Debug.Log("Your files are located here: " + Application.persistentDataPath); //Creates a new FileSave object with the file format XML. FileSave fileSave = new FileSave(FileFormat.Xml); //Writes an XML file to the path. fileSave.WriteToFile(Application.persistentDataPath + "/myFile.xml", new MyClass(42, new List <int> { 1, 2, 3 })); //Changes the file format to Binary file fileSave.fileFormat = FileFormat.Binary; //Writes a binary file fileSave.WriteToFile(Application.persistentDataPath + "/myFile.bin", new MyClass()); //Changes the file format back to XML... fileSave.fileFormat = FileFormat.Xml; //...and loads the data from the Xml file MyClass myClass = fileSave.ReadFromFile <MyClass>(Application.persistentDataPath + "/myFile.xml"); Debug.Log("Loaded data: " + myClass); }
private int SetDeclaracionPrevia( DeclaracionPreviaModel model ) { var db = new ModelServidor(); var declaracionPreviaId = db.DeclaracionPrevia.Consecutivo(x => x.DeclaracionPreviaId); // guardarArchivo if (model.ArchivoRetencion != null) { model.RutaArchivoRetencion = FileSave.GuardarArchivo( model.ArchivoRetencion, $"{AppDomain.CurrentDomain.BaseDirectory}/Uploads/{DateTime.Now:yyyy}/{DateTime.Now:MM}", "ArchivoRetencion" ); } var declaracionPrevia = ToDeclaracionPrevia(model, declaracionPreviaId); var actividadesGravadas = ToActividadesGravadas( model.ActividadesGravadas, declaracionPreviaId ); var deudaCuotas = ToDeudaCuotas(declaracionPrevia); db.DeclaracionPrevia.Add(declaracionPrevia); db.ActividadGravablePorDeclaracion.AddRange(actividadesGravadas); db.DeclaracionDeudaCuota.AddRange(deudaCuotas); db.SaveChanges(); return(declaracionPreviaId); }
public static void Main(string[] args) { IDataSource dataSource = _container.GetInstance <MemoryDataSource>(); IExport export = _container.GetInstance <ExcelExport>(); FileSave save = _container.GetInstance <FileSave>(); ICollection <ContactView> contacts = new List <ContactView>(); ContactViewBuilder builder = new StandartContactViewBuilder(); foreach (var contact in dataSource.GetContacts()) { builder.CreateContactView(); builder.BuildContactView(); builder.BuildContact(contact); builder.BuildFormatProp("AddressProp", "st. {0}"); contacts.Add(builder.BuildContactView()); } contacts = ContactViewSortCollection.Sort(contacts); var file = export.Export(contacts); save.SetPath($"export") .SetFileName("test.xlsx") .Save(file.Result); Console.ReadKey(); }
public static async Task Main(string[] args) { _log = _container.GetInstance <ILog>(); _log.Info("Startup"); FileSave save = _container.GetInstance <FileSave>(); IDataSource dataSource = _container.GetInstance <IDataSource>(); IExportFactory exportFactory = _container.GetInstance <IExportFactory>(); IExport export = exportFactory.Create("csv"); ICollection <ContactView> contacts = GetBuildedContacts(dataSource); _log.Info("Export contacts"); var file = await export.Export(contacts); _log.Debug("Get [OutExportFileName] from config"); var fileName = ConfigurationManager.AppSettings.Get("OutExportFileName"); _log.Info("Save file to export/" + fileName); save.SetPath($"export") .SetFileName(fileName) .Save(file); Console.ReadKey(); _log.Info("Close app"); }
public async Task <IActionResult> MobilePhoneType([FromForm] MDOtherItemViewModel model) { string attachPath = string.Empty; if (model.img != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/MDOtherItem", model.img); if (message == "success") { attachPath = fileName; } } MobilePhoneType type = new MobilePhoneType { Id = (int)model.id, typeName = model.typeName, typeNameBn = model.typeNameBn, shortOrder = model.shortOrder, imagePath = attachPath }; await electronicService.SaveMobilePhoneType(type); return(RedirectToAction(nameof(MobilePhoneType))); }
public async Task <IActionResult> Index([FromForm] DocumentTypeViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentType", model.formFile); if (message == "success") { attachPath = fileName; } } DocumentType documentType = new DocumentType { Id = (int)model.documentTypeId, documentTypeName = model.documentTypeName, documentTypeNameBn = model.documentTypeNameBn, shortOrder = model.shortOrder, imagePath = attachPath }; await lostAndFoundType.SaveDocumentType(documentType); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> VehicleModel([FromForm] VehicleInformationViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/VehicleType", model.formFile); if (message == "success") { attachPath = fileName; } } VehicleModel vehicleModel = new VehicleModel { Id = (int)model.modelId, vehicleTypeId = model.vehicleTypeId, modelName = model.modelName, imagePath = attachPath }; await lostAndFoundType.SaveVehicleModel(vehicleModel); return(RedirectToAction(nameof(VehicleModel))); }
/// <summary> /// Reloads the contents of the document from the disk. /// </summary> /// <param name="fileSave">An instance to a <see cref="FileSave"/> class.</param> /// <param name="document">A ScintillaTabbedDocument to which contents should also be updated.</param> /// <returns>True if the operation was successful; otherwise false.</returns> public static bool ReloadFromDisk(this FileSave fileSave, ScintillaTabbedDocument document) { try { // can't reload what doesn't exist.. if (File.Exists(fileSave.FileNameFull)) { // read the file contents from the file.. using (FileStream fileStream = new FileStream(fileSave.FileNameFull, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { // create a byte buffer the contain all the bytes if the file with an assumption // no one wishes to open massive binary files.. byte[] fileContents = new byte[fileStream.Length]; // read the file contents to the buffer.. fileStream.Read(fileContents, 0, (int)fileStream.Length); // set the file system's modified flag.. fileSave.FileSystemModified = new FileInfo(fileSave.FileNameFull).LastWriteTime; fileSave.SetDatabaseModified(fileSave.FileSystemModified); // set the other DateTime flags to indicate the same.. fileSave.FileSystemSaved = fileSave.FileSystemModified; // set the other DateTime flags to indicate the same.. fileSave.ResetPreviousDbModified(); // create a new memory stream to hold the file contents.. MemoryStream memoryStream = new MemoryStream(fileContents); document.Scintilla.Text = StreamStringHelpers.MemoryStreamToText(memoryStream, fileSave.GetEncoding()); // a reload doesn't need to be undone.. document.Scintilla.EmptyUndoBuffer(); fileSave.SetFileContentsAsMemoryStream(memoryStream); // set the saved position of the document's caret.. if (fileSave.CurrentCaretPosition > 0 && fileSave.CurrentCaretPosition < document.Scintilla.TextLength) { document.Scintilla.CurrentPosition = fileSave.CurrentCaretPosition; document.Scintilla.SelectionStart = fileSave.CurrentCaretPosition; document.Scintilla.SelectionEnd = fileSave.CurrentCaretPosition; document.Scintilla.ScrollCaret(); } } return(true); // success.. } else { return(false); // the file didn't exists, so fail.. } } catch (Exception ex) { // log the exception.. ErrorHandlingBase.ExceptionLogAction?.Invoke(ex); return(false); // an exception occurred, so fail.. } }
/// <summary> /// Load data /// </summary> public void LoadData() { FileSave loader = new FileSave(); /*DEBUG*/ //loader.DeleteSavedData(); _playerData = loader.LoadData(); }
public HttpResponseMessage Post([FromBody] FileSave fileSave) { new LanguageService.LanguageClass(blobConnectionString, containerName).UploadFileToBlob(fileSave.FileName, fileSave.FileContents); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public ViewModel(State state) { State = state; FileOpen = new FileOpen(State); FileSave = new FileSave(State); FileSaveAs = new FileSaveAs(State); FileNew = new FileNew(State); }
static public void test1() { string file = "1.cvs"; FileSave fileSave = new FileSave(); fileSave.SaveMaxAveRageMin(file, 1, 2, 3); fileSave.SaveMaxAveRageMin(file, 1, 2, 3); fileSave.SaveMaxAveRageMin(file, 1, 2, 3); }
public void SimpleSaveNpcs(string savepath) { MyClass mc = Savenpcs(); FileSave fileSave = new FileSave(FileFormat.Xml); //fileSave.WriteToFile(Application.persistentDataPath + "/tryLogsSave.xml", mc); fileSave.WriteToFile(savepath, mc); //Debug.Log("today:"+Timecontroller.today+" Saved npcPosition.Count: " + mc.npcPosition.Count); }
public void SimpleLoadCube(string savepath) { FileSave fileSave = new FileSave(FileFormat.Xml); //MyClass myClass = fileSave.ReadFromFile<MyClass>(Application.persistentDataPath + "/tryCubeSave.xml"); MyClass myClass = fileSave.ReadFromFile <MyClass>(savepath); //Debug.Log("Loaded data: " + myClass.mcPosition[26]); Setcube(myClass); }
public void SimpleLoadNpcs(string savepath) { FileSave fileSave = new FileSave(FileFormat.Xml); //MyClass myClass = fileSave.ReadFromFile<MyClass>(Application.persistentDataPath + "/tryLogsSave.xml"); MyClass myClass = fileSave.ReadFromFile <MyClass>(savepath); //Debug.Log("Loaded data: " + myClass.npcPosition.Count); SetNpcs(myClass); }
//callback of event data public static void call_back_process_eventdata(string msg, object obj) { CommonRet o = (CommonRet)getJsonObj(msg); if (o == null || !o.flag.Equals("1")) { FileSave.saveFile((int)UMSAgent.UMSApi.DataType.EVENTDATA, obj); } DebugTool.Log("call back of event data------" + o.msg); }
private void button2_Click(object sender, EventArgs e) { // File Save DialogResult FileSaveResult = FileSave.ShowDialog(); if (FileSaveResult == DialogResult.OK) { MessageBox.Show(FileSelect.FileName); } }