/// <summary> /// Get the list, returns array of AssayIDs /// </summary> /// <returns></returns> /// public IList GetUnpivotedAssayResultsDataSource() { StreamReader sr; bool changed; int i1; if (AssayId != null) { return(AssayId); } // Read cache parameters changed = ServerFile.GetIfChanged(ServerCacheDir + "CacheParms.txt", ClientCacheDir + "CacheParms.txt"); sr = new StreamReader(ClientCacheDir + "CacheParms.txt"); string txt = sr.ReadLine(); ResultsRowCount = int.Parse(txt); sr.Close(); // Init Vo position tables TarFieldPositionMap = UnpivotedAssayResultFieldPositionMap.NewOriginalMap(); // used for fast indexing of value by col name QueryTable qt = Query.GetQueryTableByName(MultiDbAssayDataNames.CombinedNonSumTableName); if (qt != null) { TarFieldPositionMap.InitializeFromQueryTableVoPositions(qt, 0); } // Read in list of assay Ids AssayId = ReadUShortArray("AssayId.bin"); // read in the list of assay ids for starters return(AssayId); }
public async Task <ActionResult <ServerFile> > PostServerFile(IList <IFormFile> files) { ServerFile serverFile = JsonConvert.DeserializeObject <ServerFile>(HttpContext.Request.Form["serverFile"]); if (files.Count == 0) { return(BadRequest()); } serverFile.Name = files[0].FileName; FileBody fileBody; using (var streamReader = new MemoryStream()) { IFormFile file = files[0]; if (file.ContentType != "text/plain" && file.ContentType != "text/html" && file.ContentType != "text/richtext" && file.ContentType != "text/xml") { files[0].OpenReadStream().CopyTo(streamReader); } fileBody = new FileBody() { Body = streamReader.ToArray(), ContentType = file.ContentType }; } serverFile.FileBody = fileBody; serverFile.Size = files[0].Length; _context.Files.Add(serverFile); await _context.SaveChangesAsync(); serverFile.FileBody = null; return(CreatedAtAction("GetServerFile", new { id = serverFile.Id }, serverFile)); }
/// <summary> /// If the file is a UNC name check to see if the services can write to it /// </summary> /// <param name="fileName"></param> public static DialogResult CanWriteFileFromServiceAccount( string fileName) { //if (DisplayedUncWarningMessage) return DialogResult.OK; if (!fileName.StartsWith(@"\\")) { return(DialogResult.OK); } ; Progress.Show("Checking Mobius background write privileges...", UmlautMobius.String, false); bool canWrite = ServerFile.CanWriteFileFromServiceAccount(fileName); Progress.Hide(); //canWrite = false; // debug if (canWrite) { return(DialogResult.OK); } DialogResult dr = MessageBoxMx.Show( "The specified file is in a shared Windows network folder.\n" + "Mobius can't currently perform a background export directly to this file.\n" + "However, if write access to this shared folder is granted to the <mobiusAccount>\n" + "account then Mobius will be able to export directly to the specified file.", "Mobius", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); DisplayedUncWarningMessage = true; return(dr); }
public ActionResult CreateFreight(FreightModel FreightModel1) { if (ModelState.IsValid) { FreightModel1.UserId = User1.Id; FreightModel1.CreateDate = DateTime.Now.ToString("dd/MM/yyyy"); FreightModel1.UpdateDate = DateTime.Now.ToString("dd/MM/yyyy"); if (FreightModel.FreightTypes.OceanFreight.ToString().Equals(FreightModel1.Type)) { FreightModel1.ServiceName = ShipmentModel.Services.SeaInbound.ToString(); } else if (FreightModel.FreightTypes.AirFreight.ToString().Equals(FreightModel1.Type)) { FreightModel1.ServiceName = ShipmentModel.Services.AirInbound.ToString(); } else if (FreightModel.FreightTypes.InlandRates.ToString().Equals(FreightModel1.Type)) { FreightModel1.ServiceName = ShipmentModel.Services.InlandService.ToString(); } else { FreightModel1.ServiceName = ShipmentModel.Services.Other.ToString(); } FreightModel1.ServiceId = servicesType.GetId(FreightModel1.ServiceName); Freight Freight1 = _freightService.CreateFreight(FreightModel1); if (Freight1 != null) { foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[inputTagName]; if (file.ContentLength > 0) { string filePath = Path.Combine(Server.MapPath("~/" + FREIGHT_PATH) , Path.GetFileName(file.FileName)); file.SaveAs(filePath); //save file to db ServerFile ServerFile1 = new ServerFile(); ServerFile1.ObjectId = Freight1.Id; ServerFile1.ObjectType = Freight1.GetType().ToString(); ServerFile1.Path = FREIGHT_PATH + "/" + file.FileName; ServerFile1.FileName = file.FileName; ServerFile1.FileSize = file.ContentLength; ServerFile1.FileMimeType = file.ContentType; _freightService.insertServerFile(ServerFile1); } } } return(RedirectToAction("ListFreight", new { Id = 0, FreightType = FreightModel1.Type })); } else { IEnumerable <Area> AreaListDep = _shipmentService.getAllAreaByCountry(FreightModel1.CountryNameDep); IEnumerable <Area> AreaListDes = _shipmentService.getAllAreaByCountry(FreightModel1.CountryNameDes); ViewData["AreaListDep"] = new SelectList(AreaListDep, "Id", "AreaAddress"); ViewData["AreaListDes"] = new SelectList(AreaListDes, "Id", "AreaAddress"); ViewData["FreightTypes"] = FreightTypes; } return(View(FreightModel1)); }
private void InsertScriptButton_Click(object sender, EventArgs e) { string fileName = @"<MiscConfigDir>\MobiusSpotfireApi.IronPythonScript.txt"; string script = new ServerFile().ReadAll(fileName); string args = ""; Api.ConfigureAnalysisForMobiusUse(args); Clipboard.SetText(script); // put script on clipboard string msg = @"The necessary Document Properties have been created. You must manually create a script named MobiusSpotfireApi, insert the text currently on the clipboard into the script and save it. Then, associate this script with the MobiusSpotfireApiCall so that the script is called whenever the the property is changed. Finally, save the analysis to the Spotfire Libary. You can then add this Spotfire analysis to any Mobius query from the Query Results page using the Add View > Select Spotfire analysis from library command."; MessageBoxMx.Show(msg); return; }
public void InitializeTable(Dictionary <int, string> dirFiles) { files = new DownloadableFiles(); foreach (var file in dirFiles) { string[] values = file.Value.Split(':'); string filename = values[0]; string size = values[1]; ServerFile serverfile = new ServerFile { id = file.Key, name = filename, size = long.Parse(size) }; files.Add(serverfile); string[] row = { file.Key + "", serverfile.name, ServerFile.GetReadableSize(serverfile.size) }; filesDataGridView.Rows.Add(row); } AdjustDataGridViewHeight(); AdjustDataGridViewWidth(); }
internal void ShowRunQueryUrl() { if (Query == null || Query.UserObject == null || Query.UserObject.Id <= 0) { MessageBoxMx.ShowError("The query must first be saved."); return; } string folder = ServicesIniFile.Read("QueryLinksNetworkFolder"); // get unc form of folder string fileName = "Run_Query_" + Query.UserObject.Id + ".bat"; // file name string uncPath = folder + '\\' + fileName; // unc file to write now and read later string tempFile = TempFile.GetTempFileName(); StreamWriter sw = new StreamWriter(tempFile); string cmd = // batch command to start the Mobius client and run the specified query Lex.AddDoubleQuotes(ClientDirs.ExecutablePath) + // path to executable in quotes " Mobius:Command='Run Query " + Query.UserObject.Id + "'"; // the mobius command to run sw.WriteLine(cmd); sw.Close(); ServerFile.CopyToServer(tempFile, uncPath); FileUtil.DeleteFile(tempFile); string url = "file:///" + folder.Replace('\\', '/') + "/" + fileName; // put in "file:" schema & switch slashes to get URL from UNC name InputBoxMx.Show( "The following URL can be used from a web page " + "to start Mobius and run the current query:", "Run Query URL", url); //"Mobius:Command='Run Query " + Query.UserObject.Id + "'"); // this is better but isn't accepted by SharePoint return; }
public ActionResult DeleteServerFile(long id) { ServerFile file = _freightService.getServerFile(id); long freightId = file.ObjectId.Value; _freightService.deleteServerFile(id); return(RedirectToAction("EditFreight", new { id = freightId })); }
public ActionResult Edit([Bind(Include = "FileId,FileName,Path,LastModified,CreatedOn,UserModified")] ServerFile serverFile) { if (ModelState.IsValid) { db.Entry(serverFile).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(serverFile)); }
void LoadClientServerFile() { // load the self server file if it doesn't already exist if (SelfServerFile == null) { SelfServerFile = ServerFile.Load(clientSFLoc, updatePathVar, customUrlArgs); } updateFrom = SelfServerFile.GetVersionChoice(VersionTools.FromExecutingAssembly()); }
BinaryReader OpenBinaryReader(string fileName) { bool changed = ServerFile.GetIfChanged(ServerCacheDir + fileName, ClientCacheDir + fileName); FileStream fs = File.Open(ClientCacheDir + fileName, FileMode.Open); BinaryReader br = new BinaryReader(fs); return(br); }
public ActionResult About(CompanyInfo CompanyInfo1) { foreach (string inputTagName in Request.Files) { HttpPostedFileBase file = Request.Files[inputTagName]; if (file.ContentLength > 0) { string filePath = Path.Combine(Server.MapPath("~/" + FREIGHT_PATH) , Path.GetFileName(file.FileName)); file.SaveAs(filePath); UsersServices1.UpdateComSetting(CompanyInfo.COMPANY_LOGO, FREIGHT_PATH + "/" + file.FileName); CompanyInfo1.CompanyLogo = FREIGHT_PATH + "/" + file.FileName; Setting Setting1 = UsersServices1.getComLogoSetting(CompanyInfo.COMPANY_LOGO); long ObjectId = Setting1 != null ? Setting1.Id : 0; //save file to db ServerFile ServerFile1 = getServerFiles(ObjectId, "SSM.Models.Setting"); if (ServerFile1 != null) { ServerFile1 = _freightService.getServerFile(ServerFile1.Id); ServerFile1.Path = FREIGHT_PATH + "/" + file.FileName; ServerFile1.FileName = file.FileName; ServerFile1.FileSize = file.ContentLength; ServerFile1.FileMimeType = file.ContentType; UsersServices1.updateAny(); } else { ServerFile1 = new ServerFile(); ServerFile1.ObjectId = ObjectId; ServerFile1.ObjectType = "SSM.Models.Setting"; ServerFile1.Path = FREIGHT_PATH + "/" + file.FileName; ServerFile1.FileName = file.FileName; ServerFile1.FileSize = file.ContentLength; ServerFile1.FileMimeType = file.ContentType; _freightService.insertServerFile(ServerFile1); } } } if (CompanyInfo1.CompanyHeader != null && !CompanyInfo1.CompanyHeader.Equals("")) { UsersServices1.UpdateComSetting(CompanyInfo.COMPANY_HEADER, CompanyInfo1.CompanyHeader); } if (CompanyInfo1.CompanyFooter != null && !CompanyInfo1.CompanyFooter.Equals("")) { UsersServices1.UpdateComSetting(CompanyInfo.COMPANY_FOOTER, CompanyInfo1.CompanyFooter); } if (CompanyInfo1.AccountInfor != null && !CompanyInfo1.AccountInfor.Equals("")) { UsersServices1.UpdateComSetting(CompanyInfo.ACCOUNT_INFO, CompanyInfo1.AccountInfor); } return(View(CompanyInfo1)); }
public ActionResult Create([Bind(Include = "FileId,FileName,Path,LastModified,CreatedOn,UserModified")] ServerFile serverFile) { if (ModelState.IsValid) { db.ServerFiles.Add(serverFile); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(serverFile)); }
// GET: ServerFiles/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServerFile serverFile = db.ServerFiles.Find(id); if (serverFile == null) { return(HttpNotFound()); } return(View(serverFile)); }
private void ServerFilesRefresh() { ServerFiles.Items.Clear(); foreach (String s in SFiles) { if (s.Contains(".")) { ServerFile serverFile = new ServerFile(s); serverFile.fileSelection += ServerFile_fileSelection; ServerFiles.Items.Add(serverFile); } } }
public void Add(ServerFile file) { if (files != null && files.Count > 0) { files.Add(files.Count + 1, file); } else { // files dictionary is empty files = new Dictionary <int, ServerFile> { { 1, file } }; } }
protected FileViewModel CreateFileViewModel(ServerFile serverFile, bool returnFile = false) { var file = new FileViewModel() { Name = serverFile.Name, ContentType = serverFile.ContentType, StoragePath = serverFile.StoragePath }; if (returnFile == true) { file.Content = new FileStream(serverFile?.StoragePath, FileMode.Open, FileAccess.Read); } return(file); }
private void btnIniciar_Click(object sender, EventArgs e) { try { server = new ServerFile(txtServer.Text, Convert.ToInt32(txtPort.Text), rutaArchivo); server.subject = this; server.Start(); /*Thread ServidorThread = new Thread(DoSomething); * ServidorThread.Start();*/ } catch (Exception ex) { MessageBox.Show("Ocurrió un problema: \n" + ex.Message); } }
public List <UpdaterFileInfo> GetNewUpdaterFile(List <UpdaterFileInfo> LocalUpdaterFile) { List <UpdaterFileInfo> ServerUpdaterFile = GetExistingFile(); List <UpdaterFileInfo> NewUpdaterFile = new List <UpdaterFileInfo>(); foreach (UpdaterFileInfo ServerFile in ServerUpdaterFile) { int index = LocalUpdaterFile.IndexOf(ServerFile); if (index == -1 || (index != -1 && ServerFile.CompareTo(LocalUpdaterFile[index]) == 1)) { NewUpdaterFile.Add(ServerFile); } } return(NewUpdaterFile); }
private void UploadFile(CrmCusDocumentModel model, List <HttpPostedFileBase> filesUpdoad) { if (filesUpdoad == null || !filesUpdoad.Any()) { return; } var type = model.GetType().ToString(); foreach (var file in filesUpdoad.Where(file => file != null && file.ContentLength > 0)) { try { var pathfoder = Path.Combine(Server.MapPath(@"~/" + DOCUMENT_PATH), model.CrmCusId.ToString("D6"), type, model.Id.ToString("D4")); if (!Directory.Exists(pathfoder)) { Directory.CreateDirectory(pathfoder); } var filePath = Path.Combine(pathfoder, Path.GetFileName(file.FileName)); file.SaveAs(filePath); var fileName = file.FileName; if (file.FileName.Length > 100) { var fileList = file.FileName.Split('.'); var typeDoc = fileList[fileList.Length - 1]; fileName = file.FileName.Substring(0, 95) + "." + typeDoc; } //save file to db var fileSave = new ServerFile { ObjectId = model.Id, ObjectType = type, // Path = string.Format("{0}/{1}", pathfoder, file.FileName), Path = string.Format("{0}/{1}/{2}/{3}/{4}", DOCUMENT_PATH, model.CrmCusId.ToString("D6"), type, model.Id.ToString("D4"), file.FileName), FileName = fileName, FileSize = file.ContentLength, FileMimeType = file.ContentType }; fileService.Insert(fileSave); } catch (Exception ex) { Logger.LogError(ex); } } }
public void InsertOrUpdate(ServerFile serverFile, string currentUser) { if (serverFile.FileId == default(int)) { // New entity UpdateAutoGeneratedFields(serverFile, currentUser, true); context.ServerFiles.Add(serverFile); string folderName = String.Empty; if (serverFile is CommitteeFile) { var committeeFile = serverFile as CommitteeFile; folderName = Path.Combine("CommitteeFiles", committeeFile.CommitteeId.ToString()); } else if (serverFile is PostFile) { var postFile = serverFile as PostFile; folderName = Path.Combine("PostFiles", postFile.PostId.ToString()); } serverFile.FileName = serverFile.PostedFile.FileName; serverFile.Path = Path.Combine( "~/Content/files/", folderName, serverFile.FileName); var serverpath = HttpContext.Current.Server.MapPath(serverFile.Path); if (!Directory.Exists(Path.GetDirectoryName(serverpath))) { Directory.CreateDirectory(Path.GetDirectoryName(serverpath)); } serverFile.PostedFile.SaveAs(serverpath); } else { // We have no reason to update a server file record. // Existing entity //serverFile.LastModified = DateTime.Now; //UpdateAutoGeneratedFields(serverFile, currentUser, false); //context.Entry(serverFile).State = System.Data.Entity.EntityState.Modified; } }
/// <summary> /// Get the latest version of a saved DataTable file /// </summary> /// <param name="fileName">Basic file name without directory</param> /// <param name="clientFileName">Full path to file on client</param> /// <param name="clientFileDate">Last write date for file</param> /// <returns></returns> public static bool GetSavedDataTableFile( string fileName, out string clientFileName, out DateTime clientFileDate) { clientFileDate = DateTime.MinValue; string serverFileName = @"<BackgroundExportDir>\" + fileName; clientFileName = ClientDirs.CacheDir + @"\" + fileName; ServerFile.GetIfChanged(serverFileName, clientFileName); // get file from server if client file doesn't exist or is older if (!File.Exists(clientFileName)) { return(false); } clientFileDate = FileUtil.GetFileLastWriteTime(clientFileName); return(true); }
public ActionResult DeleteConfirmed(int id, string PreviousUrl) { ServerFile serverFile = db.ServerFiles.Find(id); db.ServerFiles.Remove(serverFile); var serverpath = Server.MapPath(serverFile.Path); System.IO.File.Delete(serverpath); db.SaveChanges(); if (String.IsNullOrEmpty(PreviousUrl)) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(PreviousUrl)); } }
private async Task ProcessFile(ServerFile file) { _controller.FileDownloadStarted?.Invoke(this, EventArgs.Empty); await _controller.DownloadFile(new Uri(file.Uri), Path.Combine(_controller.Settings.Values.UltimaPath, file.Name)); _controller.FileDownloadFinished?.Invoke(this, EventArgs.Empty); if (file.RequiresUnzip) { _controller.FileDecompressionStarted(this, new FileDecompressionStartedEventArgs(file.Name)); using (ZipFile zip = ZipFile.Read(Path.Combine(_controller.Settings.Values.UltimaPath, file.Name))) { zip.ExtractAll(_controller.Settings.Values.UltimaPath, ExtractExistingFileAction.OverwriteSilently); } _controller.FileDecompressionEnded?.Invoke(this, new FileDecompressionEndedEventArgs(file.Name)); } }
public FileFolderViewModel Map(ServerFile entity, string path) { FileFolderViewModel fileFolderView = new FileFolderViewModel { Id = entity.Id, Name = entity.Name, ContentType = entity.ContentType, CreatedBy = entity.CreatedBy, CreatedOn = entity.CreatedOn, UpdatedOn = entity.UpdatedOn, FullStoragePath = entity.StoragePath, HasChild = false, IsFile = true, ParentId = entity.StorageFolderId, StoragePath = path, Size = entity.SizeInBytes, StorageDriveId = entity.ServerDriveId, Hash = entity.HashCode }; return(fileFolderView); }
/// <summary> /// Called when the self-update server files has downloaded successfully. /// </summary> void DownloadClientSFSuccess() { // load the wyUpdate server file, and see if a new version is availiable ServerFile clientSF = ServerFile.Load(clientSFLoc, updatePathVar, customUrlArgs); // check if the wyUpdate is new enough. if (VersionTools.Compare(VersionTools.FromExecutingAssembly(), clientSF.NewVersion) < 0) { SelfUpdateState = SelfUpdateState.WillUpdate; // autoupdate will need this SF if (isAutoUpdateMode) { SelfServerFile = clientSF; LoadClientServerFile(); } } // Show update info page (or just start downloading & installing) if (SkipUpdateInfo) { // check if elevation is needed needElevation = NeedElevationToUpdate(); if (needElevation || SelfUpdateState == SelfUpdateState.WillUpdate) { StartSelfElevated(); } else { ShowFrame(Frame.InstallUpdates); } } else { ShowFrame(Frame.UpdateInfo); } }
private async Task ServeFileFromStream(ServerFile file, StreamWriter writer) { using var stream = file.Stream(); await writer.WriteLineAsync("HTTP/1.1 200 OK"); await writer.WriteLineAsync($"Content-Type: {file.Type}"); if (file.FileName != null) { await writer.WriteLineAsync($"Content-Length: {stream.Length}"); await writer.WriteLineAsync($"Content-Disposition: attachment; filename={file.FileName}"); } await writer.WriteLineAsync(""); await writer.FlushAsync(); await stream.CopyToAsync(writer.BaseStream); await writer.FlushAsync(); }
private void UploadFile(NewsModel model, List <HttpPostedFileBase> filesUpdoad) { if (filesUpdoad != null && filesUpdoad.Any()) { foreach (HttpPostedFileBase file in filesUpdoad) { if (file != null && file.ContentLength > 0) { try { var pathfoder = Path.Combine(Server.MapPath(@"~/" + DOCUMENT_PATH), model.Type.ToString()); if (!Directory.Exists(pathfoder)) { Directory.CreateDirectory(pathfoder); } string filePath = Path.Combine(pathfoder, Path.GetFileName(file.FileName)); file.SaveAs(filePath); //save file to db var fileSave = new ServerFile { ObjectId = model.Id, ObjectType = model.GetType().ToString(), Path = string.Format("{0}/{1}/{2}", DOCUMENT_PATH, model.Type.ToString(), file.FileName), FileName = file.FileName, FileSize = file.ContentLength, FileMimeType = file.ContentType }; freightServices.insertServerFile(fileSave); } catch (Exception ex) { Logger.LogError(ex); } } } } }
/// <summary> /// Deserialize a DataTable from a file /// </summary> /// <param name="tr"></param> /// <returns></returns> public IDataTableMx DeserializeXml( string fileName) { StreamReader sr = null; string tempFile = null; if (fileName.StartsWith("<")) // get from server if server file name { string serverFile = fileName; // must be a server file name tempFile = TempFile.GetTempFileName(); ServerFile.CopyToClient(serverFile, tempFile); sr = new StreamReader(tempFile); } else { if (!File.Exists(fileName)) { throw new FileNotFoundException("File not found: " + fileName); } sr = new StreamReader(fileName); } XmlTextReader tr = new XmlTextReader(sr); DataTableMx dt = Deserialize(tr) as DataTableMx; sr.Close(); if (tempFile != null) { try { File.Delete(tempFile); } catch { } } return(dt); }
private void InsertOrUpdateLocalFile(ServerFile file) { var clientFile = _controller.Files.Info.Files.FirstOrDefault(f => f.Name == file.Name); if (clientFile == null) { _controller.Files.Info.Files.Add(new ClientFile() { Name = file.Name, Version = file.Version }); _controller.Files.Info.LastUpdated = DateTime.Now; _controller.Files.Save(); return; } if (clientFile.Version < file.Version) { clientFile.Version = file.Version; _controller.Files.Info.LastUpdated = DateTime.Now; _controller.Files.Save(); } }