public SettingsExplorer(ApplicationSettingsBase settings) : base(new Guid("B760CC2A-F836-403E-9BD5-17807A387A8E")) { _settings = settings; Functions = ExplorerFunctions.GetContent | ExplorerFunctions.SetText; var type = _settings.GetType(); Location = Far.Api.GetModuleManager(type).ModuleName + "\\" + type.Name; foreach (SettingsProperty property in _settings.Properties) { // skip not browsable var browsable = (BrowsableAttribute)property.Attributes[typeof(BrowsableAttribute)]; if (browsable != null && !browsable.Browsable) continue; // ensure the property value exists var dummy = _settings[property.Name]; var value = _settings.PropertyValues[property.Name]; var file = new SetFile(); _files.Add(file); file.Data = value; file.Name = property.Name; file.Description = GetPropertyValueText(value); CompleteFileData(file, value); } }
/// <summary> /// start Transfer /// </summary> /// <param name="dateTime"></param> public void startTransfer(string dateTime) { logPath = log.txtLocation(type); startTime = DateTime.Now; if (dateTime.Length != 8 || !DateTime.TryParseExact(dateTime, "yyyyMMdd", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out reportDateDt)) { log.txtLog( type, false, startTime, logPath, MessageType.DateTime_Format_Fail.GetDescription() ); } else { reportDateStr = dateTime; setFile = new SetFile(tableType, dateTime); createA07File(); } }
public SettingsExplorer(ApplicationSettingsBase settings) : base(new Guid("B760CC2A-F836-403E-9BD5-17807A387A8E")) { _settings = settings; Functions = ExplorerFunctions.GetContent | ExplorerFunctions.SetText; var type = _settings.GetType(); Location = Far.Api.GetModuleManager(type).ModuleName + "\\" + type.Name; foreach (SettingsProperty property in _settings.Properties) { // skip not browsable var browsable = (BrowsableAttribute)property.Attributes[typeof(BrowsableAttribute)]; if (browsable != null && !browsable.Browsable) { continue; } // ensure the property value exists var dummy = _settings[property.Name]; var value = _settings.PropertyValues[property.Name]; var file = new SetFile(); _files.Add(file); file.Data = value; file.Name = property.Name; file.Description = GetPropertyValueText(value); CompleteFileData(file, value); } }
// _101125_173951 Out-GridView approach: // show Index (##), Value, Type columns for mixed types and the only 'TypeName' column for the same type. internal static string BuildFilesMixed(IList<FarFile> files, Collection<PSObject> values) { files.Clear(); int index = -1; string sameType = null; foreach (PSObject value in values) { ++index; // new file SetFile file = new SetFile() { Data = value, Length = index }; // description: watch the same type to choose the panel columns and to reuse same type string string newType = value.BaseObject.GetType().FullName; if (index == 0) { sameType = newType; file.Description = newType; } else if (sameType == null) { file.Description = newType; } else if (sameType == newType) { // use the same reference file.Description = sameType; } else { sameType = null; file.Description = newType; } // discover name // _100309_121508 Linear type case IEnumerable asIEnumerable; PSPropertyInfo pi; if (Converter.IsLinearType(value.BaseObject.GetType())) file.Name = value.ToString(); else if ((asIEnumerable = value.BaseObject as IEnumerable) != null) file.Name = Converter.FormatEnumerable(asIEnumerable, Settings.Default.FormatEnumerationLimit); else if ((pi = A.FindDisplayProperty(value)) != null) file.Name = A.SafeToString(A.SafePropertyValue(pi)); //_131106_104220 else file.Name = A.SafeToString(value); //_131106_105605 // add files.Add(file); } return sameType; }
/// <summary> /// Get FarFile wrapper for FSItem /// </summary> /// <param name="item"></param> /// <returns></returns> public FarFile GetFarFileFromFSItem(FSItem item) { SetFile file = new SetFile() { Name = item.Name, Description = item.Id, IsDirectory = item.IsDir, LastAccessTime = item.LastAccessTime, LastWriteTime = item.LastWriteTime, Length = item.Length, CreationTime = item.CreationTime, Data = new Hashtable(), }; //((Hashtable)file.Data).Add("fsitem", item); //CacheStorage.AddItem(item); return(file); }
public DemoExplorer(string fileName) : base(new Guid("83c6c606-e8fb-4fbb-87ab-e41e617589bd")) { FileName = fileName; Files = new List <FarFile>(); // Read the .resources file, create and cache the panels files using (var reader = new ResourceReader(fileName)) { var it = reader.GetEnumerator(); while (it.MoveNext()) { SetFile file = new SetFile(); file.Name = it.Key.ToString(); file.Description = Convert.ToString(it.Value); Files.Add(file); } } }
public DemoExplorer(string fileName) : base(new Guid("83c6c606-e8fb-4fbb-87ab-e41e617589bd")) { FileName = fileName; Files = new List<FarFile>(); // Read the .resources file, create and cache the panels files using (var reader = new ResourceReader(fileName)) { var it = reader.GetEnumerator(); while (it.MoveNext()) { SetFile file = new SetFile(); file.Name = it.Key.ToString(); file.Description = Convert.ToString(it.Value); Files.Add(file); } } }
public static async Task OnDownloadRequest(Microsoft.AspNetCore.Http.HttpContext e) { //We'll actually download the archive. Get the stream string token = e.Request.Query["token"]; if (!files.ContainsKey(token)) { throw new StandardError("Token invalid", StandardErrorCode.AuthFailed); } //Copy stream SetFile file = files[token]; Stream ms = file.file; ms.Position = 0; e.Response.Headers.Add("Content-Disposition", $"attachment; filename=\"{file.name}\""); e.Response.ContentType = "application/octet-stream"; e.Response.ContentLength = ms.Length; await ms.CopyToAsync(e.Response.Body); }
public override IList<FarFile> GetFiles(GetFilesEventArgs args) { IList<FarFile> realList = new List<FarFile>(); realList.Add(createParentElement()); foreach (var track in CurrentPlayList.Tracks) { FarFile ff = new SetFile(); ff.Name = IPodTrackFormatter.Get(track, FarPodSetting.Default.TrackNameFormatForPanel, true) + Path.GetExtension(track.FilePath); ff.Data = track; ff.Length = track.FileSize.ByteCount; realList.Add(ff); } return realList; }
protected override void ProcessRecord() { // system file if (File != null) { var ff = new SetFile(File, FullName) { Description = Description, Owner = Owner, Columns = Columns }; if (Data == null) { ff.Data = File; } else { ff.Data = Data; } WriteObject(ff); return; } // user file WriteObject(new SetFile() { Name = Name, Description = Description, Owner = Owner, Length = Length, CreationTime = CreationTime, LastAccessTime = LastAccessTime, LastWriteTime = LastWriteTime, Attributes = Attributes, Columns = Columns, Data = Data, }); }
/// <inheritdoc/> public override IList<FarFile> GetFiles(GetFilesEventArgs args) { var result = new List<FarFile>(); if (args == null) return result; try { //! get properties // - Using -LiteralPath is a problem, e.g. Registry: returns nothing. // - Script is used for PS conversion of property values to string. // - Script has to ignore a property with empty name (if any, can be in Registry). // - If PS* included then they can't be found by `gp <path> <name>`; // so, don't add, they are noisy anyway (even if marked system or hidden). // get property bag 090409 Collection<PSObject> bag = A.Psf.Engine.InvokeProvider.Property.Get(Kit.EscapeWildcard(ItemPath), null); // filter var filter = new List<string>(5); filter.Add("PSChildName"); filter.Add("PSDrive"); filter.Add("PSParentPath"); filter.Add("PSPath"); filter.Add("PSProvider"); // add foreach (PSObject o in bag) { foreach (PSPropertyInfo pi in o.Properties) { // skip empty ?? still needed? string name = pi.Name; if (string.IsNullOrEmpty(name)) continue; // filter and shrink filter int i = filter.IndexOf(name); if (i >= 0) { filter.RemoveAt(i); continue; } // create file SetFile file = new SetFile() { Name = name, IsReadOnly = !pi.IsSettable, Data = pi, // set its value Description = Converter.FormatValue(pi.Value, Settings.Default.FormatEnumerationLimit) }; // add result.Add(file); } } } catch (RuntimeException error) { if (args.UI) A.Message(error.Message); } return result; }
// _101125_173951 Out-GridView approach: // show Index (##), Value, Type columns for mixed types and the only 'TypeName' column for the same type. internal static string BuildFilesMixed(IList <FarFile> files, Collection <PSObject> values) { files.Clear(); int index = -1; string sameType = null; foreach (PSObject value in values) { ++index; // new file SetFile file = new SetFile() { Data = value, Length = index }; // description: watch the same type to choose the panel columns and to reuse same type string string newType = value.BaseObject.GetType().FullName; if (index == 0) { sameType = newType; file.Description = newType; } else if (sameType == null) { file.Description = newType; } else if (sameType == newType) { // use the same reference file.Description = sameType; } else { sameType = null; file.Description = newType; } // discover name // _100309_121508 Linear type case IEnumerable asIEnumerable; PSPropertyInfo pi; if (Converter.IsLinearType(value.BaseObject.GetType())) { file.Name = value.ToString(); } else if ((asIEnumerable = value.BaseObject as IEnumerable) != null) { file.Name = Converter.FormatEnumerable(asIEnumerable, Settings.Default.FormatEnumerationLimit); } else if ((pi = A.FindDisplayProperty(value)) != null) { file.Name = A.SafeToString(A.SafePropertyValue(pi)); //_131106_104220 } else { file.Name = A.SafeToString(value); //_131106_105605 } // add files.Add(file); } return(sameType); }
public override IList <FarFile> GetFiles(GetFilesEventArgs args) { if (args == null) { return(null); } var result = new List <FarFile>(); try { if (MemberMode == 0) { //! _100426_034702 //! Get actual members to show: //! _Value.Properties contains too much, i.e. for DataRow: HasErrors, ItemArray, RowError, RowState; //! use Get-Member at first (don't use it itself, because it returns sorted data, we want unsorted). //! Idea to cache them is not good: //! price: high (have to sync on exclude, add, delete, etc.) //! value: low (it is UI and member number is normally small) var membersToShow = new List <string>(); { //_131002_111804 in a DictionaryEntry avoid Name (same as Key) if (Value.BaseObject.GetType() == typeof(DictionaryEntry)) { membersToShow.Add("Key"); membersToShow.Add("Value"); } else { string code = "Get-Member -InputObject $args[0] -MemberType Properties -ErrorAction 0"; foreach (PSObject o in A.InvokeCode(code, Value)) { string name = o.Properties[Word.Name].Value.ToString(); if (_ExcludeMemberRegex == null || !_ExcludeMemberRegex.IsMatch(name)) { membersToShow.Add(name); } } } } // to check hidden columns var datarow = Value.BaseObject as DataRow; // now we are ready to process properties in their original order foreach (PSPropertyInfo pi in Value.Properties) { if (!membersToShow.Contains(pi.Name)) { continue; } var value = A.SafePropertyValue(pi); SetFile file = new SetFile() { Name = pi.Name, Data = pi }; // base object PSObject asPSObject = value as PSObject; if (asPSObject != null) { value = asPSObject.BaseObject; } // value file.Description = Converter.FormatValue(value, Settings.Default.FormatEnumerationLimit); // hidden by user if (_HideMemberRegex != null && _HideMemberRegex.IsMatch(file.Name)) { file.IsHidden = true; } // hidden due to column features if (!file.IsHidden && datarow != null) { var column = datarow.Table.Columns[file.Name]; if (column.AutoIncrement) { file.IsHidden = true; } } result.Add(file); } } else { string code; if (MemberMode == 1) { code = "Get-Member -InputObject $args[0] -ErrorAction 0 -View All"; } else { code = "Get-Member -InputObject $args[0] -ErrorAction 0 -View All -Static"; } foreach (PSObject o in A.InvokeCode(code, Value)) { SetFile f = new SetFile(); f.Name = o.Properties[Word.Name].Value.ToString(); PSPropertyInfo pi; pi = o.Properties["MemberType"]; f.Description = pi.Value.ToString(); pi = o.Properties["Definition"]; f.Description += " " + pi.Value.ToString(); f.Data = o; result.Add(f); } } } catch (RuntimeException exception) { if (args.UI) { A.Message(exception.Message); } } return(result); }
public override IList<FarFile> GetFiles(GetFilesEventArgs args) { if (args == null) return null; var result = new List<FarFile>(); try { if (MemberMode == 0) { //! _100426_034702 //! Get actual members to show: //! _Value.Properties contains too much, i.e. for DataRow: HasErrors, ItemArray, RowError, RowState; //! use Get-Member at first (don't use it itself, because it returns sorted data, we want unsorted). //! Idea to cache them is not good: //! price: high (have to sync on exclude, add, delete, etc.) //! value: low (it is UI and member number is normally small) var membersToShow = new List<string>(); { //_131002_111804 in a DictionaryEntry avoid Name (same as Key) if (Value.BaseObject.GetType() == typeof(DictionaryEntry)) { membersToShow.Add("Key"); membersToShow.Add("Value"); } else { string code = "Get-Member -InputObject $args[0] -MemberType Properties -ErrorAction 0"; foreach (PSObject o in A.InvokeCode(code, Value)) { string name = o.Properties[Word.Name].Value.ToString(); if (_ExcludeMemberRegex == null || !_ExcludeMemberRegex.IsMatch(name)) membersToShow.Add(name); } } } // to check hidden columns var datarow = Value.BaseObject as DataRow; // now we are ready to process properties in their original order foreach (PSPropertyInfo pi in Value.Properties) { if (!membersToShow.Contains(pi.Name)) continue; var value = A.SafePropertyValue(pi); SetFile file = new SetFile() { Name = pi.Name, Data = pi }; // base object PSObject asPSObject = value as PSObject; if (asPSObject != null) value = asPSObject.BaseObject; // value file.Description = Converter.FormatValue(value, Settings.Default.FormatEnumerationLimit); // hidden by user if (_HideMemberRegex != null && _HideMemberRegex.IsMatch(file.Name)) file.IsHidden = true; // hidden due to column features if (!file.IsHidden && datarow != null) { var column = datarow.Table.Columns[file.Name]; if (column.AutoIncrement || column.ColumnMapping == MappingType.Hidden || column.Expression.Length > 0) file.IsHidden = true; } result.Add(file); } } else { string code; if (MemberMode == 1) code = "Get-Member -InputObject $args[0] -ErrorAction 0 -View All"; else code = "Get-Member -InputObject $args[0] -ErrorAction 0 -View All -Static"; foreach (PSObject o in A.InvokeCode(code, Value)) { SetFile f = new SetFile(); f.Name = o.Properties[Word.Name].Value.ToString(); PSPropertyInfo pi; pi = o.Properties["MemberType"]; f.Description = pi.Value.ToString(); pi = o.Properties["Definition"]; f.Description += " " + pi.Value.ToString(); f.Data = o; result.Add(f); } } } catch (RuntimeException exception) { if (args.UI) A.Message(exception.Message); } return result; }
protected FarFile createParentElement() { FarFile parentLevel = new SetFile(); parentLevel.IsDirectory = true; parentLevel.Name = Dots; return parentLevel; }
protected FarFile createDirectory(string name, object data) { FarFile dir = new SetFile(); dir.Name = name; dir.Data = data; dir.IsDirectory = true; return dir; }
/// <inheritdoc/> public override IEnumerable <FarFile> GetFiles(GetFilesEventArgs args) { var result = new List <FarFile>(); if (args == null) { return(result); } try { //! get properties // - Using -LiteralPath is a problem, e.g. Registry: returns nothing. // - Script is used for PS conversion of property values to string. // - Script has to ignore a property with empty name (if any, can be in Registry). // - If PS* included then they can't be found by `gp <path> <name>`; // so, don't add, they are noisy anyway (even if marked system or hidden). // get property bag 090409 Collection <PSObject> bag = A.Psf.Engine.InvokeProvider.Property.Get(Kit.EscapeWildcard(ItemPath), null); // filter var filter = new List <string>(5); filter.Add("PSChildName"); filter.Add("PSDrive"); filter.Add("PSParentPath"); filter.Add("PSPath"); filter.Add("PSProvider"); // add foreach (PSObject o in bag) { foreach (PSPropertyInfo pi in o.Properties) { // skip empty ?? still needed? string name = pi.Name; if (string.IsNullOrEmpty(name)) { continue; } // filter and shrink filter int i = filter.IndexOf(name); if (i >= 0) { filter.RemoveAt(i); continue; } // create file SetFile file = new SetFile() { Name = name, IsReadOnly = !pi.IsSettable, Data = pi, // set its value Description = Converter.FormatValue(pi.Value, Settings.Default.FormatEnumerationLimit) }; // add result.Add(file); } } } catch (RuntimeException error) { if (args.UI) { A.Message(error.Message); } } return(result); }
/// <summary> /// start Transfer /// </summary> /// <param name="dateTime"></param> public override void startTransfer(string dateTime) { IFRS9Entities db = new IFRS9Entities(); startTime = DateTime.Now; if (dateTime.Length != 8 || !DateTime.TryParseExact(dateTime, "yyyyMMdd", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out reportDateDt)) { db.Dispose(); log.txtLog( type, false, startTime, logPath, MessageType.DateTime_Format_Fail.GetDescription() ); log.saveTransferCheck( type, false, reportDateDt, 1, //A53無版本 (default為1) startTime, DateTime.Now); } var A41 = db.Bond_Account_Info .Any(x => x.Report_Date == reportDateDt); verInt = db.Bond_Account_Info .Where(x => x.Report_Date == reportDateDt && x.Version != null) .DefaultIfEmpty().Max(x => x.Version == null ? 0 : x.Version.Value); var check = log.checkTransferCheck(TableType.A53.ToString(), "A41", reportDateDt, verInt); logPath = log.txtLocation(type); if (!A41 || !check || verInt == 0) { db.Dispose(); log.saveTransferCheck( type, false, reportDateDt, 1, //A53只有一版 (default為1) startTime, DateTime.Now); List <string> errs = new List <string>(); if (!A41) { errs.Add(MessageType.not_Find_Any.GetDescription()); } if (!check || verInt == 0) { errs.Add(MessageType.transferError.GetDescription()); } log.txtLog( type, false, startTime, logPath, string.Join(",", errs) ); } else { db.Dispose(); reportDateStr = dateTime; setFile = new SetFile(tableType, dateTime); createSampleFile(); } }
protected override void ProcessRecord() { // system file if (File != null) { var ff = new SetFile(File, FullName); ff.Description = Description; ff.Owner = Owner; ff.Columns = Columns; if (Data == null) ff.Data = File; else ff.Data = Data; WriteObject(ff); return; } // user file WriteObject(new SetFile() { Name = Name, Description = Description, Owner = Owner, Length = Length, CreationTime = CreationTime, LastAccessTime = LastAccessTime, LastWriteTime = LastWriteTime, Attributes = Attributes, Columns = Columns, Data = Data, }); }