// constructor public U2DataReader(UniSession uSession, string fileName) { _uSession = uSession; try { uFile = _uSession.CreateUniFile(fileName); UniCommand uCmd = _uSession.CreateUniCommand(); uCmd.Command = string.Format("SELECT {0} BY @ID SAMPLED 100", uFile.FileName); uCmd.Execute(); usl = _uSession.CreateUniSelectList(0); _keySample = usl.ReadListAsStringArray(); RecordsAffected = 0; } catch (UniSessionException e) // unisession file not exists { if (e.ErrorCode == 14002) { Console.WriteLine("U2 file not found"); } else { // dont know, so rethrow throw; } } }
/// <exception cref="CopeException">Can't open the file as RelicChunky!</exception> public RelicChunkyViewer(UniFile file) : this() { var rcf = new RelicChunkyFile(file); try { rcf.ReadData(); } catch (Exception ex) { throw new CopeException(ex, "Can't open the file as RelicChunky!"); } file.Close(); m_rcf = rcf; _trv_chunks.Nodes.Clear(); foreach (RelicChunk chunk in m_rcf.Chunks) { var tnC = new TreeNode(); string tnName = chunk.ChunkHeader.TypeString + chunk.ChunkHeader.Signature; tnC.Name = tnName; tnC.Text = tnName; chunk.Tag = tnC; tnC.Tag = chunk; if (chunk is FoldChunk) GetChunks(tnC, (FoldChunk)chunk); _trv_chunks.Nodes.Add(tnC); } }
/// <exception cref="CopeException">Can't open the file as RelicChunky!</exception> public RelicChunkyViewer(UniFile file) : this() { var rcf = new RelicChunkyFile(file); try { rcf.ReadData(); } catch (Exception ex) { throw new CopeException(ex, "Can't open the file as RelicChunky!"); } file.Close(); m_rcf = rcf; _trv_chunks.Nodes.Clear(); foreach (RelicChunk chunk in m_rcf.Chunks) { var tnC = new TreeNode(); string tnName = chunk.ChunkHeader.TypeString + chunk.ChunkHeader.Signature; tnC.Name = tnName; tnC.Text = tnName; chunk.Tag = tnC; tnC.Tag = chunk; if (chunk is FoldChunk) { GetChunks(tnC, (FoldChunk)chunk); } _trv_chunks.Nodes.Add(tnC); } }
/// <summary> /// Creates a UniFile based on the information from this FSNodeFile. /// </summary> /// <param name="onlyVirtual">Set to true to only return a UniFile if this file is virtual (otherwise null).</param> /// <param name="onlyLocal">Set to true to only return a UniFile if this file is local (otherwise null).</param> /// <returns></returns> public virtual UniFile GetUniFile(bool onlyVirtual = false, bool onlyLocal = false) { if (onlyVirtual) { return(null); } UniFile uniFile = null; try { // try to open it uniFile = new UniFile(GetPath()); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it still exists! Info: {0}", e.Message); if (uniFile != null) { uniFile.Close(); } LoggingManager.HandleException(e); } return(uniFile); }
private void OpenFile(UniFile file) { m_file = file; try { if (file.FileExtension.ToLowerInvariant() == "dds") { m_image = new FreeImageBitmap(file.Stream, FREE_IMAGE_FORMAT.FIF_DDS); m_format = FREE_IMAGE_FORMAT.FIF_DDS; } else if (file.FileExtension.ToLowerInvariant() == "tga") { m_image = new FreeImageBitmap(file.Stream, FREE_IMAGE_FORMAT.FIF_TARGA); m_format = FREE_IMAGE_FORMAT.FIF_TARGA; } m_picbxImage.Image = (Bitmap)m_image; m_binary = new MemoryStream(); file.Stream.Position = 0; file.Stream.CopyTo(m_binary); } catch (Exception e) { UIHelper.ShowError("Failed to open image! Error: " + e.Message); ModTool.Core.LoggingManager.SendMessage("Failed to open image " + file.FilePath); ModTool.Core.LoggingManager.HandleException(e); } finally { file.Close(); } }
static private void TryToGetKeyProvider() { const string flbPath = "simulation\\attrib\\fieldnames.flb"; if (!ToolSettings.IsInRetributionMode) { LoggingManager.SendMessage("ModManager - not in Retribuion-mode, no need to load KeyProvider"); return; } LoggingManager.SendMessage("ModManager - Trying to load the KeyProvider (FLB-file)"); try { FSNodeFile file = FileManager.AttribTree.RootNode.GetFileByPath(flbPath); if (file == null) { UIHelper.ShowWarning("Unable to find the FLB file! You probably won't be able to open RBFs."); LoggingManager.SendWarning("ModManager - Failed to load FLB-file from path " + flbPath); return; } UniFile uni = file.GetUniFile(); var flbFile = new FieldNameFile(uni); flbFile.ReadData(); RBFKeyProvider = flbFile; } catch (Exception ex) { UIHelper.ShowError("Unable to open or read the FLB file! You probably won't be able to open RBFs."); LoggingManager.SendError("ModManager - Error while loading FLB-file"); LoggingManager.HandleException(ex); return; } LoggingManager.SendMessage("ModManager - Successfully loaded KeyProvider from " + flbPath); }
private UniFile GetUniFileFromNode(TreeNode tn, bool onlyVirtual = false, bool onlyLocal = false) { FSNode node; if (tn.TreeView == m_fitCombined.InnerTreeView) { node = m_fitCombined.GetFSNodeByTreeNode(tn); } else if (tn.TreeView == m_fitVirtual.InnerTreeView) { node = m_fitVirtual.GetFSNodeByTreeNode(tn); } else { return(null); } if (node == null || !(node is FSNodeFile)) { return(null); } UniFile uniFile = ((FSNodeFile)node).GetUniFile(onlyVirtual, onlyLocal); return(uniFile); }
static public FileTool LoadFile(UniFile file, FileTypePlugin plugin) { if (!AllowOpeningFilesTwice && s_openTools.ContainsKey(file.FilePath)) { return(s_openTools[file.FilePath]); } FileTool tool; try { tool = plugin.LoadFile(file); } catch { UIHelper.ShowError("Can't open the selected file " + file.FileName + " using " + plugin.PluginName + ", version: " + plugin.Version + "."); return(null); } tool.OnSaved += FileTool_OnSaved; if (s_openTools.ContainsKey(file.FilePath)) { s_openTools.Add(file.FilePath, tool); } if (FileLoaded != null) { FileLoaded(file, tool); } return(tool); }
static void Main(string[] args) { try { U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder(); conn_str.UserID = "user"; conn_str.Password = "******"; conn_str.Server = "localhost"; conn_str.Database = "HS.SALES"; conn_str.ServerType = "UNIVERSE"; conn_str.AccessMode = "Native"; // FOR UO conn_str.RpcServiceType = "uvcs"; // FOR UO conn_str.Pooling = false; string s = conn_str.ToString(); U2Connection con = new U2Connection(); con.ConnectionString = s; con.Open(); Console.WriteLine("Connected........................."); // get RECID UniSession us1 = con.UniSession; UniSelectList sl = us1.CreateUniSelectList(2); // Select UniFile UniFile fl = us1.CreateUniFile("CUSTOMER"); sl.Select(fl); bool lLastRecord = sl.LastRecordRead; List <string> lRecIdList = new List <string>(); while (!lLastRecord) { string sRecID = sl.Next(); lRecIdList.Add(sRecID); Console.WriteLine("Record ID:" + sRecID); lLastRecord = sl.LastRecordRead; } UniDataSet uSet = fl.ReadRecords(lRecIdList.ToArray()); // use for each statement to print the record foreach (UniRecord item in uSet) { Console.WriteLine(item.ToString()); } con.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } finally { Console.WriteLine("Enter to exit:"); string line = Console.ReadLine(); } }
static void Main(string[] args) { try { U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder(); conn_str.UserID = "user"; conn_str.Password = "******"; conn_str.Server = "localhost"; conn_str.Database = "demo"; conn_str.ServerType = "UNIDATA"; conn_str.AccessMode = "Native"; // FOR UO conn_str.RpcServiceType = "udcs"; // FOR UO conn_str.Pooling = false; string s = conn_str.ToString(); U2Connection con = new U2Connection(); con.ConnectionString = s; con.Open(); Console.WriteLine("Connected........................."); // get RECID UniSession us1 = con.UniSession; UniSelectList sl = us1.CreateUniSelectList(2); // Select UniFile UniFile fl = us1.CreateUniFile("STUDENT"); sl.Select(fl); bool lLastRecord = sl.LastRecordRead; while (!lLastRecord) { string s2 = sl.Next(); Console.WriteLine("Record ID:" + s2); lLastRecord = sl.LastRecordRead; } con.Close(); } catch (Exception e) { string s = e.Message; if (e.InnerException != null) { s += e.InnerException.Message; } Console.WriteLine(s); } finally { Console.WriteLine("Enter to exit:"); string line = Console.ReadLine(); } }
public TextEditor(UniFile file) : this() { m_file = file; var r = new StreamReader(file.Stream, true); m_rtbText.Text = r.ReadToEnd(); r.Close(); m_rtbText.TextChanged += RtbTextTextChanged; }
private void Visit(FSNodeDir startDir) { if (m_stopSearch.WaitOne(0)) { return; } foreach (FSNodeFile file in startDir.Files) { if (m_stopSearch.WaitOne(0)) { return; } if (file.Name.EndsWith(".rbf")) { UniFile uni = file.GetUniFile(); RelicBinaryFile rbf; try { rbf = new RelicBinaryFile(uni) { KeyProvider = ModManager.RBFKeyProvider, UseKeyProvider = RBFSettings.UseKeyProviderForLoading }; rbf.ReadData(); } catch (Exception ex) { if (OnFileOpenFailed != null) { OnFileOpenFailed(ex); } if (m_advanceProgressCallback != null) { m_advanceProgressCallback.Invoke(); } continue; } m_foreachRBF.Invoke(rbf.AttributeStructure, file.PathInTree); } if (m_advanceProgressCallback != null) { m_advanceProgressCallback.Invoke(); } } foreach (FSNodeDir dir in startDir.Directories) { if (m_stopSearch.WaitOne(0)) { return; } Visit(dir); } }
static public FileTool LoadFile(string path, FileTypePlugin plugin) { if (!File.Exists(path)) { return(null); } var file = new UniFile(path); return(LoadFile(file, plugin)); }
/// <summary> /// Loads a file from the specified path and returns the proper FileTool. /// </summary> /// <param name="path"></param> /// <returns></returns> static public FileTool LoadFile(string path) { if (!File.Exists(path)) { return(null); } var file = new UniFile(path, FileAccess.ReadWrite, FileShare.Read); return(LoadFile(file)); }
public ImageViewer(UniFile file) { InitializeComponent(); // set the image-display panel to DoubleBuffered System.Reflection.PropertyInfo dbProp = typeof(Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); dbProp.SetValue(m_pnlImage, true, null); OpenFile(file); }
private void LbxSearchResultsMouseDoubleClick(object sender, MouseEventArgs e) { if (m_lbxSearchResults.SelectedItem == null) { return; } var result = m_lbxSearchResults.SelectedItem as SearchResult; FSNodeFile file = FileManager.AttribTree.RootNode.GetFileByPath(result.RelativeFilePath); UniFile uni = file.GetUniFile(); FileManager.LoadFile(uni); }
/// <summary> /// Returns a UniFile based on the information from this FSNodeVirtualFile. It will first search for a local file and if there's no local file it'll get the virtual file. /// </summary> /// <param name="onlyVirtual">Set to true to ignore local files.</param> /// <param name="onlyLocal">Set to true to ignore virtual files.</param> /// <returns></returns> public override UniFile GetUniFile(bool onlyVirtual = false, bool onlyLocal = false) { UniFile uniFile = null; if (!onlyVirtual && HasLocal) { try { // try to open it uniFile = new UniFile(GetPath()); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it still exists! Info: {0}", e.Message); if (uniFile != null) { uniFile.Close(); } LoggingManager.HandleException(e); } return(uniFile); } // is it stored in a SGA archive? if (!onlyLocal || !HasLocal) { SGAStoredFile sgasfExtract = VirtualFile; try { // try to extract that file for our use into RAM uniFile = new UniFile(sgasfExtract.SGA.ExtractFile(sgasfExtract, (sgasfExtract.SGA.Stream))); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it's SGA archive still exists! Info: {0}", e.Message); if (uniFile != null) { uniFile.Close(); } LoggingManager.HandleException(e); } // set a pseudo path that will be used when saving the file if (uniFile != null) { uniFile.FilePath = GetPath(); } } return(uniFile); }
public ScarEditorControl(UniFile file) { InitializeComponent(); m_btnSave.Click += BtnSaveClick; m_file = file; m_editor = new TextEditor(); m_wpfTextEditor.Child = m_editor; m_editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("LUA Highlighting"); m_editor.ShowLineNumbers = true; m_editor.TextChanged += EditorTextChanged; m_editor.Load(file.Stream); }
private static void DragDropGeneral(DragEventArgs e) { if (e.Effect == DragDropEffects.Move) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var fileNames = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string s in fileNames) { // only one SGA / module at a time (currently)! if (s.EndsWith(".sga")) { if (ModManager.IsAnythingLoaded && UIHelper.ShowYNQuestion("Warning!", "Opening a SGA archive will close all other archives and tabs!") == DialogResult.No) { return; } ModManager.LoadSGAFile(s); return; } if (s.EndsWith(".module")) { if (ModManager.IsAnythingLoaded && UIHelper.ShowYNQuestion("Warning!", "Opening another module will close the current mod with all it's tabs and SGAs! Continue anyway?") == DialogResult.No) { return; } ModManager.LoadModule(s); return; } var tmp = new UniFile(s); try { FileManager.LoadFile(tmp); } catch (Exception ex) { tmp.Close(); UIHelper.ShowError(ex.Message); return; } } } } }
public Boolean openFile(String fileName) { _lastError = String.Empty; if (_openFiles.ContainsKey(fileName)) { return(true); } lock (_syncCall) { try { UniFile f = _sess.CreateUniFile(fileName); _openFiles.Add(fileName, f); } catch (Exception ex) { _lastError = ex.Message; return(false); } } return(true); }
private void TryToOpenFileByValueToolStripMenuItemClick(object sender, EventArgs e) { if (m_dgvValues.SelectedRows.Count <= 0 || (string)m_dgvValues.SelectedRows[0].Cells[2].Value != "string") { return; } if (m_dgvValues.SelectedRows[0].Cells[1].Value == null) { UIHelper.ShowError("The selected value is not a valid path."); return; } string path = (string)m_dgvValues.SelectedRows[0].Cells[1].Value + ".rbf"; if (FileManager.AttribTree != null) { FSNodeFile node = FileManager.AttribTree.RootNode.GetFileByPath("simulation\\attrib\\" + path); if (node == null) { UIHelper.ShowError( "Could not open the selected file. Maybe it does not exist or the tool could not find it."); return; } UniFile file = node.GetUniFile(); if (file == null) { UIHelper.ShowError( "Could not open the selected file. Maybe it does not exist or the tool could not find it."); return; } if (!FileManager.AllowOpeningFilesTwice && FileManager.OpenFiles.Contains(file.FilePath)) { UIHelper.ShowWarning( "You're already editing the file you're trying to load! You cannot reopen it." + " View the options-menu to remove this limitation."); return; } FileManager.LoadFile(file); return; } UIHelper.ShowError( "Could not open the selected file. There's no file-tree available to look the path up." + " This might be because there's no mod loaded."); }
public Boolean releaseRecord(String fileName, string id) { _lastError = String.Empty; UniFile f = getFile(fileName); if (f == null) { return(false); } lock (_syncCall) { try { f.UnlockRecord(id); } catch (Exception ex) { _lastError = ex.Message; return(false); } } return(true); }
public Boolean writeRecord(String fileName, String id, UniDynArray rec) { _lastError = String.Empty; UniFile f = getFile(fileName); if (f == null) { return(false); } lock (_syncCall) { try { f.Write(id, rec.StringValue); } catch (Exception ex) { _lastError = ex.Message; return(false); } } return(true); }
public Boolean readRecord(String fileName, String id, ref UniDynArray rec) { _lastError = String.Empty; UniFile f = getFile(fileName); if (f == null) { return(false); } lock (_syncCall) { try { rec = f.Read(id); } catch (Exception ex) { _lastError = ex.Message; return(false); } } return(true); }
/// <summary> /// Launches an instance of the plugin associated with the extension of the specified file name. /// </summary> /// <param name="fileName"></param> /// <param name="infile"></param> /// <exception cref="CopeException">Will throw an exception if there's no plugin for this file type.</exception> /// <returns></returns> static public FileTool LaunchFromExt(string fileName, UniFile infile) { string ext = fileName.SubstringAfterLast('.').ToLower(); if (!s_fileTypes.ContainsKey(ext)) throw new CopeException("Unknown file extension: " + ext); FileTypePlugin plugin = s_fileTypes[ext]; try { return plugin.LoadFile(infile); } catch (Exception e) { Type t = plugin.GetType(); LoggingManager.SendMessage("FileTypeManager - Error launching plugin " + t.FullName); LoggingManager.HandleException(e); throw new CopeException(e, "Error launching plugin " + t.FullName + ": " + e.Message); } }
/// <summary> /// Creates a UniFile based on the information from this FSNodeFile. /// </summary> /// <param name="onlyVirtual">Set to true to only return a UniFile if this file is virtual (otherwise null).</param> /// <param name="onlyLocal">Set to true to only return a UniFile if this file is local (otherwise null).</param> /// <returns></returns> public virtual UniFile GetUniFile(bool onlyVirtual = false, bool onlyLocal = false) { if (onlyVirtual) return null; UniFile uniFile = null; try { // try to open it uniFile = new UniFile(GetPath()); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it still exists! Info: {0}", e.Message); if (uniFile != null) uniFile.Close(); LoggingManager.HandleException(e); } return uniFile; }
/// <exception cref="CopeDoW2Exception">Failed to load file as RBF! Visit the options and ensure that the settings correspond to the game version you're trying to modify.</exception> protected void LoadFile(UniFile file) { if (file.FileExtension == "rbf") { m_rbf = new RelicBinaryFile(file) { KeyProvider = ModManager.RBFKeyProvider, UseKeyProvider = RBFSettings.UseKeyProviderForLoading }; try { m_rbf.ReadData(); } catch (Exception ex) { throw new CopeDoW2Exception(ex, "Failed to load file as RBF! Visit the plugin's options " + "and ensure that the settings correspond to " + "the game version you're trying to modify."); } } else if (file.FileExtension == "attr_pc") { try { var attribStruct = BAFReader.Read(file.Stream); file.Close(); m_rbf = new RelicBinaryFile(attribStruct) { FilePath = file.FilePath, UseKeyProvider = false }; } catch (Exception ex) { throw new CopeDoW2Exception(ex, "Failed to load file as attr_pc!"); } } file.Close(); m_rbfEditorCore.Analyze(m_rbf.AttributeStructure.Root); }
/// <summary> /// Launches an instance of the plugin associated with the extension of the specified file name. /// </summary> /// <param name="fileName"></param> /// <param name="infile"></param> /// <exception cref="CopeException">Will throw an exception if there's no plugin for this file type.</exception> /// <returns></returns> static public FileTool LaunchFromExt(string fileName, UniFile infile) { string ext = fileName.SubstringAfterLast('.').ToLower(); if (!s_fileTypes.ContainsKey(ext)) { throw new CopeException("Unknown file extension: " + ext); } FileTypePlugin plugin = s_fileTypes[ext]; try { return(plugin.LoadFile(infile)); } catch (Exception e) { Type t = plugin.GetType(); LoggingManager.SendMessage("FileTypeManager - Error launching plugin " + t.FullName); LoggingManager.HandleException(e); throw new CopeException(e, "Error launching plugin " + t.FullName + ": " + e.Message); } }
private void LoadFileFromTreeNode(TreeNode node, bool onlyVirtual = false, bool forceText = false) { UniFile uniFile = GetUniFileFromNode(node, onlyVirtual); if (uniFile == null) { return; } try { var filetool = FileManager.LoadFile(uniFile, forceText); if (filetool != null && filetool.Parent != null && filetool.Parent is TabPage) { m_tbcApps.SelectedTab = filetool.Parent as TabPage; } } catch (Exception ex) { LoggingManager.SendMessage("FE - failed to open file"); LoggingManager.HandleException(ex); UIHelper.ShowError("Error while opening the selected file: " + ex.Message); } }
public static CssFileResult GetData(AccountList list, CssAccountFile file, CssCredentials cssCredentials) { var lHostName = cssCredentials.Hostname; var lAccount = cssCredentials.Account; var lUser = cssCredentials.User; var lPassword = cssCredentials.UserPassword; var lServiceType = cssCredentials.ServiceType; var response = new CssFileResult(); var fileResults = new CssFile { FileName = list.AccountListName }; UniSession us = null; try { //get the session object us = UniObjects.OpenSession(lHostName, lUser, lPassword, lAccount, lServiceType); // create select list UniSelectList selectList = us.CreateUniSelectList(2); selectList.GetList(list.AccountListName); // read records using array of records ids var ids = selectList.ReadListAsStringArray(); //open file UniFile cssFile = us.CreateUniFile(file.FileName); var lSet = cssFile.ReadRecords(ids); //var dict = us.CreateUniDictionary(file.FileName); //var field1 = dict.ReadField(1); //use foreach statement to construct data to be displayed foreach (UniRecord item in lSet) { var record = new CssRecord(item.RecordID, ""); var numFields = item.Record.Dcount(); for (int i = 0; i < numFields; i++) { var field = item.Record.Extract(i); var valuesCount = field.Dcount(); if (valuesCount > 1) { throw new Exception("This field has sub-values" + field); } record.Fields.Add(new CssField(i.ToString(), field.ToString())); } fileResults.Records.Add(record); } response.FileContents = fileResults; return(response); } catch (Exception ex) { response.CssResponses.Results.Add(new CommandResponse("Exception", ex.ToString())); } finally { if (us != null && us.IsActive) { UniObjects.CloseSession(us); } } response.CssResponses.Results.Add(new CommandResponse("Error", "There was an error procesing your request.")); return(response); }
/// <summary> /// Loads the specified file and returns a FileTool control or NULL if it fails. /// </summary> /// <param name="file">File to load.</param> /// <returns></returns> public abstract FileTool LoadFile(UniFile file);
/// <summary> /// Returns a UniFile based on the information from this FSNodeVirtualFile. It will first search for a local file and if there's no local file it'll get the virtual file. /// </summary> /// <param name="onlyVirtual">Set to true to ignore local files.</param> /// <param name="onlyLocal">Set to true to ignore virtual files.</param> /// <returns></returns> public override UniFile GetUniFile(bool onlyVirtual = false, bool onlyLocal = false) { UniFile uniFile = null; if (!onlyVirtual && HasLocal) { try { // try to open it uniFile = new UniFile(GetPath()); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it still exists! Info: {0}", e.Message); if (uniFile != null) uniFile.Close(); LoggingManager.HandleException(e); } return uniFile; } // is it stored in a SGA archive? if (!onlyLocal || !HasLocal) { SGAStoredFile sgasfExtract = VirtualFile; try { // try to extract that file for our use into RAM uniFile = new UniFile(sgasfExtract.SGA.ExtractFile(sgasfExtract, (sgasfExtract.SGA.Stream))); } catch (Exception e) { UIHelper.ShowError( "An error occured while trying to load the file! Please ensure that it's SGA archive still exists! Info: {0}", e.Message); if (uniFile != null) uniFile.Close(); LoggingManager.HandleException(e); } // set a pseudo path that will be used when saving the file if (uniFile != null) uniFile.FilePath = GetPath(); } return uniFile; }
static public FileTool LoadFile(string path, FileTypePlugin plugin) { if (!File.Exists(path)) return null; var file = new UniFile(path); return LoadFile(file, plugin); }
public FileActionEventArgs(FileActionType action, UniFile file, object tag = null) { Action = action; File = file; Tag = tag; }
static public FileTool LoadFile(UniFile file, FileTypePlugin plugin) { if (!AllowOpeningFilesTwice && s_openTools.ContainsKey(file.FilePath)) return s_openTools[file.FilePath]; FileTool tool; try { tool = plugin.LoadFile(file); } catch { UIHelper.ShowError("Can't open the selected file " + file.FileName + " using " + plugin.PluginName + ", version: " + plugin.Version + "."); return null; } tool.OnSaved += FileTool_OnSaved; if (s_openTools.ContainsKey(file.FilePath)) s_openTools.Add(file.FilePath, tool); if (FileLoaded != null) FileLoaded(file, tool); return tool; }
public override FileTool LoadFile(UniFile file) { return new ImageViewer(file); }
private void FileManagerFileLoaded(UniFile file, FileTool plugin) { SetupNewTab(plugin, file.FileName); }
static void Main(string[] args) { try { U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder(); conn_str.UserID = "user"; conn_str.Password = "******"; conn_str.Server = "localhost"; conn_str.Database = "demo"; conn_str.ServerType = "UNIDATA"; conn_str.AccessMode = "Native"; // FOR UO conn_str.RpcServiceType = "udcs"; // FOR UO conn_str.Pooling = false; string s = conn_str.ToString(); U2Connection con = new U2Connection(); con.ConnectionString = s; con.Open(); Console.WriteLine("Connected........................."); UniSession us1 = con.UniSession; UniSelectList sl = us1.CreateUniSelectList(2); // Select UniFile UniFile fl = us1.CreateUniFile("STUDENT"); sl.Select(fl); // read records as unidataset string[] sArray = { "291222021", "521814564", "424325656" }; UniDataSet uSet = fl.ReadRecords(sArray); // use for each statement to print the record foreach (UniRecord item in uSet) { Console.WriteLine(item.ToString()); } // use index to print the record int lCount = uSet.RowCount; for (int ii = 0; ii < lCount; ii++) { UniRecord ee = uSet[ii]; Console.WriteLine(ee.ToString()); } // print one by one record UniRecord q2 = uSet["291222021"]; string sq2 = q2.ToString(); Console.WriteLine(" Record data for rec id 291222021:" + sq2); UniRecord q3 = uSet["521814564"]; string sq3 = q3.ToString(); Console.WriteLine(" Record data for rec id 521814564:" + sq3); UniRecord q4 = uSet["424325656"]; string sq4 = q4.ToString(); Console.WriteLine(" Record data for rec id 424325656:" + sq4); //create UniDataSet in the Client Side UniDataSet uSet3 = us1.CreateUniDataSet(); uSet3.Insert("3", "aaa"); uSet3.Insert("4", "bbb"); uSet3.Insert("5", "vvv"); uSet3.Insert(2, "8", "www"); con.Close(); } catch (Exception e) { string s = e.Message; if (e.InnerException != null) { s += e.InnerException.Message; } Console.WriteLine(s); } finally { Console.WriteLine("Enter to exit:"); string line = Console.ReadLine(); } }
public RBFEditor(UniFile file) : this() { LoadFile(file); }
/// <summary> /// Loads a file from the specified path and returns the proper FileTool. /// </summary> /// <param name="path"></param> /// <returns></returns> static public FileTool LoadFile(string path) { if (!File.Exists(path)) return null; var file = new UniFile(path, FileAccess.ReadWrite, FileShare.Read); return LoadFile(file); }
private static void DragDropGeneral(DragEventArgs e) { if (e.Effect == DragDropEffects.Move) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var fileNames = (string[]) e.Data.GetData(DataFormats.FileDrop); foreach (string s in fileNames) { // only one SGA / module at a time (currently)! if (s.EndsWith(".sga")) { if (ModManager.IsAnythingLoaded && UIHelper.ShowYNQuestion("Warning!", "Opening a SGA archive will close all other archives and tabs!") == DialogResult.No) return; ModManager.LoadSGAFile(s); return; } if (s.EndsWith(".module")) { if (ModManager.IsAnythingLoaded && UIHelper.ShowYNQuestion("Warning!", "Opening another module will close the current mod with all it's tabs and SGAs! Continue anyway?") == DialogResult.No) return; ModManager.LoadModule(s); return; } var tmp = new UniFile(s); try { FileManager.LoadFile(tmp); } catch (Exception ex) { tmp.Close(); UIHelper.ShowError(ex.Message); return; } } } } }
/// <exception cref="CopeDoW2Exception">Failed to load file as RBF! Visit the options and ensure that the settings correspond to the game version you're trying to modify.</exception> protected void LoadFile(UniFile file) { if (file.FileExtension == "rbf") { m_rbf = new RelicBinaryFile(file) { KeyProvider = ModManager.RBFKeyProvider, UseKeyProvider = RBFSettings.UseKeyProviderForLoading }; try { m_rbf.ReadData(); } catch (Exception ex) { throw new CopeDoW2Exception(ex, "Failed to load file as RBF! Visit the plugin's options " + "and ensure that the settings correspond to " + "the game version you're trying to modify."); } } else if (file.FileExtension == "attr_pc") { try { var attribStruct = BAFReader.Read(file.Stream); file.Close(); m_rbf = new RelicBinaryFile(attribStruct) {FilePath = file.FilePath, UseKeyProvider = false}; } catch (Exception ex) { throw new CopeDoW2Exception(ex, "Failed to load file as attr_pc!"); } } file.Close(); m_rbfEditorCore.Analyze(m_rbf.AttributeStructure.Root); }
public override FileTool LoadFile(UniFile file) { return new ScarEditorControl(file); }
static void Main(string[] args) { try { U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder(); conn_str.UserID = "user"; conn_str.Password = "******"; conn_str.Server = "localhost"; conn_str.Database = "HS.SALES"; conn_str.ServerType = "UNIVERSE"; conn_str.AccessMode = "Native"; // FOR UO conn_str.RpcServiceType = "uvcs"; // FOR UO conn_str.Pooling = false; string s = conn_str.ToString(); U2Connection con = new U2Connection(); con.ConnectionString = s; con.Open(); Console.WriteLine("Connected........................."); // get RECID UniSession us1 = con.UniSession; // open customer file UniFile fl = us1.CreateUniFile("CUSTOMER"); // read records as unidataset string[] sArray = { "2", "12", "3", "4" }; UniDataSet uSet = fl.ReadRecords(sArray); // use for each statement to print the record foreach (UniRecord item in uSet) { Console.WriteLine(item.ToString()); } // use index to print the record int lCount = uSet.RowCount; for (int ii = 0; ii < lCount; ii++) { UniRecord ee = uSet[ii]; Console.WriteLine(ee.ToString()); } // print one by one record UniRecord q2 = uSet["2"]; string sq2 = q2.ToString(); Console.WriteLine(" Record data for rec id 2:" + sq2); UniRecord q3 = uSet["3"]; string sq3 = q3.ToString(); Console.WriteLine(" Record data for rec id 3:" + sq3); UniRecord q4 = uSet["4"]; string sq4 = q4.ToString(); Console.WriteLine(" Record data for rec id 4:" + sq4); // create UniDataSet in the Client Side UniDataSet uSet3 = us1.CreateUniDataSet(); uSet3.Insert("3", "aaa"); uSet3.Insert("4", "bbb"); uSet3.Insert("5", "vvv"); uSet3.Insert(2, "8", "www"); con.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } finally { Console.WriteLine("Enter to exit:"); string line = Console.ReadLine(); } }
public override FileTool LoadFile(UniFile file) { return new RBFEditor(file); }
/// <summary> /// Tries to load the specified UniFile and returns the proper FileTool. /// </summary> /// <param name="file"></param> /// <param name="forceText">Set this to true to always use the Text-editor.</param> /// <returns></returns> static public FileTool LoadFile(UniFile file, bool forceText = false) { if (!AllowOpeningFilesTwice && s_openTools.ContainsKey(file.FilePath)) return s_openTools[file.FilePath]; FileTool tmp; byte[] stream = file.ConsumeStream(); UniFile filecopy = new UniFile(stream); filecopy.FilePath = file.FilePath; if (forceText) { try { tmp = new TextEditor(filecopy); } catch (Exception e) { UIHelper.ShowError("Can't open the selected file " + file.FileName +" as Text: " + e.Message); return null; } } else if (FileTypeManager.FileTypes.ContainsKey(filecopy.FileExtension)) tmp = FileTypeManager.LaunchFromExt(filecopy.FileName, filecopy); else { try { tmp = new RelicChunkyViewer(filecopy); } catch { try { filecopy = new UniFile(stream); file.Stream.Position = 0; tmp = new TextEditor(filecopy); } catch(Exception ex) { LoggingManager.SendError("Failed to open file"); LoggingManager.HandleException(ex); file.Close(); UIHelper.ShowError("Can't open the selected file " + file.FileName + ", no suitable plugin found!"); return null; } } } tmp.OnSaved += FileTool_OnSaved; if (!s_openTools.ContainsKey(file.FilePath)) s_openTools.Add(file.FilePath, tmp); if (FileLoaded != null) FileLoaded(file, tmp); return tmp; }