public override List <ServiceObject> DescribeServiceObjects() { List <ServiceObject> soList = new List <ServiceObject>(); ServiceObject so = Helper.CreateServiceObject("FilestoZip", "Files To Zip"); //so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.FilesToZip.ZipFile, SoType.File, "Zip File")); FileProperty zipFile = new FileProperty(Constants.SOProperties.FilesToZip.ZipFile, new MetaData(), String.Empty, String.Empty); zipFile.MetaData.DisplayName = Constants.SOProperties.FilesToZip.ZipFile; zipFile.MetaData.Description = "Zip File"; so.Properties.Add(zipFile); so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.FilesToZip.FileName, SoType.Text, "Zip File Name.")); so.Properties.Add(Helper.CreateProperty(Constants.SOProperties.FilesToZip.ADOSMOQuery, SoType.Text, "Query to get the Files. File in the first column")); //FilesToZip Method mFilesToZipSmartObject = Helper.CreateMethod(Constants.Methods.FilesToZip.FilesToZipMethod, "Compress Files to Zip", MethodType.Read); mFilesToZipSmartObject.InputProperties.Add(Constants.SOProperties.FilesToZip.ADOSMOQuery); mFilesToZipSmartObject.Validation.RequiredProperties.Add(Constants.SOProperties.FilesToZip.ADOSMOQuery); mFilesToZipSmartObject.InputProperties.Add(Constants.SOProperties.FilesToZip.FileName); mFilesToZipSmartObject.Validation.RequiredProperties.Add(Constants.SOProperties.FilesToZip.FileName); mFilesToZipSmartObject.ReturnProperties.Add(Constants.SOProperties.FilesToZip.ZipFile); so.Methods.Add(mFilesToZipSmartObject); soList.Add(so); return(soList); }
private UnitSearch ToNewSetting(FileProperty property) { var reference = this.GetReference(property); if (reference == null) { return(null); } var newSetting = new UnitSearch() { Property = property, Reference = reference, }; if (property.IsComperable()) { newSetting.Mode = this.CompareOperator[this.CompareOperatorSelectedIndex.Value].Value; } else { newSetting.Mode = (this.EqualitySelectedIndex.Value == this.GetEqualitySelectorIndex(true)) ? CompareMode.NotEqual : CompareMode.Equal; } return(newSetting); }
public void GetMultipleCellValuesList() { //Get input properties FileProperty excelFile = GetFileProperty(Constants.SOProperties.ExcelDocumentServices.ExcelFile, true); string worksheetName = GetStringProperty(Constants.SOProperties.ExcelDocumentServices.WorksheetName, true); string multipleCellCoordinates = GetStringProperty(Constants.SOProperties.ExcelDocumentServices.MultipleCellCoordinates, true); ServiceObject serviceObject = ServiceBroker.Service.ServiceObjects[0]; serviceObject.Properties.InitResultTable(); DataTable results = ServiceBroker.ServicePackage.ResultTable; string smoCellValues = ExcelServiceHelper.GetMultipleCellValueFromFile(excelFile, worksheetName, multipleCellCoordinates); string[] cellNames = multipleCellCoordinates.Split(';'); string[] cellValues = smoCellValues.Split(';'); for (int i = 0; i < cellNames.Length; i++) { DataRow dr = results.NewRow(); dr[Constants.SOProperties.ExcelDocumentServices.CellName] = cellNames[i]; dr[Constants.SOProperties.ExcelDocumentServices.CellValue] = cellValues[i]; results.Rows.Add(dr); } }
public static FilePropertyVisibility FromXML(XmlReader reader) { FilePropertyVisibility fpv = new FilePropertyVisibility(); try { reader.ReadStartElement(); while (reader.NodeType == XmlNodeType.Element) { FileProperty prop = (FileProperty)Enum.Parse(typeof(FileProperty), reader.Name); if (!fpv.visible.ContainsKey(prop)) { reader.ReadOuterXml(); continue; } bool value = reader.ReadElementContentAsBoolean(); fpv.Visible[prop] = value; } reader.ReadEndElement(); } catch { log.ErrorFormat("Error while parsing file property visiblity."); } return(fpv); }
private void BuildContextMenus() { foreach (FileProperty prop in Enum.GetValues(typeof(FileProperty))) { if (!PreferencesManager.FileExplorerPreferences.FilePropertyVisibility.Visible.ContainsKey(prop)) { continue; } ToolStripMenuItem mnu = new ToolStripMenuItem(); string resourceName = "FileProperty_" + prop.ToString(); string text = ScreenManagerLang.ResourceManager.GetString(resourceName); mnu.Text = text; mnu.Tag = prop; bool value = PreferencesManager.FileExplorerPreferences.FilePropertyVisibility.Visible[prop]; mnu.Checked = value; FileProperty closureProp = prop; mnu.Click += (s, e) => { bool v = PreferencesManager.FileExplorerPreferences.FilePropertyVisibility.Visible[closureProp]; PreferencesManager.FileExplorerPreferences.FilePropertyVisibility.Visible[closureProp] = !v; mnu.Checked = !v; InvalidateThumbnails(); }; popMenu.Items.Add(mnu); } }
public static FileProperty SaveCellValueToFile(FileProperty file, string worksheetName, string cellCoordinates, string cellValue) { using (MemoryStream fileStream = new MemoryStream()) { fileStream.Write(System.Convert.FromBase64String(file.Content), 0, int.Parse(System.Convert.FromBase64String(file.Content).Length.ToString())); using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileStream, true)) { WorkbookPart wbPart = document.WorkbookPart; Sheet theSheet = wbPart.Workbook.Descendants <Sheet>().Where(s => s.Name == worksheetName).FirstOrDefault(); if (theSheet == null) { throw new ArgumentException(Resources.WorksheetNotExist); } WorksheetPart wsPart = (WorksheetPart)(wbPart.GetPartById(theSheet.Id)); Cell theCell = wsPart.Worksheet.Descendants <Cell>().Where(c => c.CellReference == cellCoordinates).FirstOrDefault(); if (theCell == null) { theCell = InsertCellInWorksheet(GetColumnName(cellCoordinates), GetRowIndex(cellCoordinates), wsPart); } theCell.CellValue = new CellValue(cellValue); theCell.DataType = DefineCellDataType(cellValue); wsPart.Worksheet.Save(); wbPart.Workbook.Save(); byte[] fileByte = fileStream.ToArray(); file.Content = System.Convert.ToBase64String(fileByte).ToString(); } } return(file); }
public FilePropertyDTO(FileProperty fileProperty) { Id = fileProperty.Id; FileId = fileProperty.FileId; PropertyId = fileProperty.PropertyId; Value = fileProperty.Value; }
public static string GetShellDisplayName(this FileProperty shellProperty) { var propertyKey = new PropertyKey(shellProperty.FormatId.Value, shellProperty.PropertyId.Value); var guid = new Guid("6F79D558-3E96-4549-A1D1-7D75D2288814"); NativeMethods.PSGetPropertyDescription(ref propertyKey, ref guid, out var nativePropertyDescription); if (nativePropertyDescription != null) { try { var hr = nativePropertyDescription.GetDisplayName(out var dispNamePtr); if (hr >= 0 && dispNamePtr != IntPtr.Zero) { var name = Marshal.PtrToStringUni(dispNamePtr); // Free the string Marshal.FreeCoTaskMem(dispNamePtr); return(name); } } finally { Marshal.ReleaseComObject(nativePropertyDescription); } } return(FormatString(shellProperty.Name)); }
/// <summary> /// 比較検索が可能か /// </summary> /// <param name="property"></param> /// <returns></returns> public static bool IsComperable(this FileProperty property) { if (searchDictionary.TryGetValue((int)property, out var result)) { return(result.IsComparable); } return(false); }
public static FileProperty CreateFileProperty(string name, string description) { FileProperty fileProperty = new FileProperty(name, new MetaData(), String.Empty, String.Empty); fileProperty.MetaData.DisplayName = AddSpaceBeforeCaptialLetter(name); fileProperty.MetaData.Description = description; return(fileProperty); }
/// <summary> /// 検索閾値を取得 /// </summary> /// <param name="property"></param> /// <returns></returns> private object GetReference(FileProperty property) { if (property == FileProperty.DirectoryPathStartsWith) { return(this.DirectoryList .Select(x => x.GetSelectedLabel()) .Join()); } else if (property == FileProperty.ContainsTag) { if (this.TagListSelectedIndex.Value >= 0 && this.TagListSelectedIndex.Value < this.RegisteredTags.Count) { var item = this.RegisteredTags[this.TagListSelectedIndex.Value]; return(item.Key); } } if (property.IsInteger()) { var num = this.NumericText.Value ?? 0; if (property == FileProperty.Size) { return((long)num); } else { return(num); } } if (property.IsFloat()) { return(this.FloatText.Value ?? 0.0); } if (property.IsText()) { return(this.TextBoxContent.Value); } if (property.IsDate()) { //case FileProperty.DateCreated: //case FileProperty.DateModified: var date = this.DateContent.Value; var fixedDate = new DateTimeOffset(date.Date, DateTimeOffset.Now.Offset); return(fixedDate); } return(null); }
public static string GetCellValueFromFile(FileProperty file, string worksheetName, string cellCoordinates) { string value = null; using (MemoryStream fileStream = new MemoryStream(System.Convert.FromBase64String(file.Content), true)) { // Open the spreadsheet document for read-only access. using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileStream, false)) { WorkbookPart wbPart = document.WorkbookPart; Sheet theSheet = wbPart.Workbook.Descendants <Sheet>().Where(s => s.Name == worksheetName).FirstOrDefault(); if (theSheet == null) { throw new ArgumentException(Resources.WorksheetNotExist); } WorksheetPart wsPart = (WorksheetPart)(wbPart.GetPartById(theSheet.Id)); Cell theCell = wsPart.Worksheet.Descendants <Cell>().Where(c => c.CellReference == cellCoordinates).FirstOrDefault(); if (theCell != null) { value = theCell.CellValue.InnerText; if (theCell.DataType != null) { switch (theCell.DataType.Value) { case CellValues.Boolean: if (string.Compare(value, "0") == 0) { value = "FALSE"; } else { value = "TRUE"; } break; default: var stringTable = wbPart.GetPartsOfType <SharedStringTablePart>() .FirstOrDefault(); if (stringTable != null) { value = stringTable.SharedStringTable .ElementAt(int.Parse(value)).InnerText; } break; } } } } } return(value); }
private void StartPathOrTagSearch(FileProperty property, object reference) { if (this.Client.StartNewSearch(property, reference, CompareMode.Equal)) { if (this.IsPaneOpen.Value && !this.IsPaneFixed.Value) { this.IsPaneOpen.Value = false; } } }
/* List Directory Contents in Detail (Name, Size, Created, etc.) */ public async Task <List <FileProperty> > DirectoryListDetails(string directory) { var filePropertyList = new List <FileProperty>(); try { _ftpRequest = (FtpWebRequest)WebRequest.Create(_host + directory); _ftpRequest.Credentials = new NetworkCredential(_user, _pass); _ftpRequest.UseBinary = true; _ftpRequest.UsePassive = true; _ftpRequest.KeepAlive = true; _ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails; using (_ftpResponse = (FtpWebResponse)await _ftpRequest.GetResponseAsync()) { using (_ftpStream = _ftpResponse.GetResponseStream()) { if (_ftpStream != null) { _streamReader = new StreamReader(_ftpStream); } string line; while ((line = _streamReader.ReadLine()) != null) { var fileListArr = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (fileListArr.Count() >= 4) { FileProperty fileProperty = new FileProperty() { ModifiedDate = fileListArr[0] != null?DateTime.ParseExact(Convert.ToString(fileListArr[0]), "MM-dd-yy", null) : DateTime.MinValue, FileName = fileListArr[3] != null?Convert.ToString(fileListArr[3]) : string.Empty, FileSize = fileListArr[2] != null && fileListArr[2] != "<DIR>" ? long.Parse(fileListArr[2]) : 0 }; filePropertyList.Add(fileProperty); } } } } } finally { _streamReader?.Close(); _ftpStream?.Close(); _ftpResponse?.Close(); _ftpRequest = null; } if (filePropertyList.Any()) { filePropertyList = filePropertyList.OrderByDescending(x => x.ModifiedDate).ToList(); } return(filePropertyList); }
public static string GetEqualityLabel(this FileProperty property, bool isNot) { if (property.IsContainer()) { return(isNot ? notContainsLabel : containsLabel); } else { return(isNot ? isNotLabel : isLabel); } }
public static string GetCompareLabel(this FileProperty property, CompareMode mode) { if (property.IsComperable()) { return(mode.GetLabel()); } else { return(property.GetEqualityLabel(!mode.ContainsEqual())); } }
public static FileProperty CreateFileProperty(string name, string description) { var metadata = new MetaData() { DisplayName = name, Description = description }; var fileProperty = new FileProperty(name, metadata, string.Empty, string.Empty); return(fileProperty); }
/// <summary> /// 単一条件の検索を開始 /// </summary> /// <param name="property"></param> /// <param name="reference"></param> /// <param name="mode"></param> public bool StartNewSearch(FileProperty property, object reference, CompareMode mode) { return(this.StartNewSearch( new UnitSearch() { Property = property, Reference = reference, Mode = mode, } )); }
public static bool IsFloat(this FileProperty property) { switch (property) { case FileProperty.AspectRatio: return(true); default: return(false); } }
public override Stream ReadOpen(string path, out FileProperty stat) { stat = null; var prop = GetObjectProperty(path); if (!prop.IsFile) { throw new IOException(); } stat = ToObjectInfo(prop); return(rest.Download(prop.ID)); }
private void AddPropertyButton_Click(object sender, EventArgs e) { string propertyValue = ValueTextBox.Text; Property selectedProperty = propertyController.GetPropertyByTitle(currentlySelectedItem.Text); if (propertyController.ValidateDataType(selectedProperty.Type, propertyValue)) { FileProperty newFileProperty = filePropertyController.CreateFileProperty(workingFile.Id, selectedProperty.Id, propertyValue); filePropertyController.AddFilePropertyToFile(newFileProperty); parent.UpdateData(); } }
private void GetListItemById() { ServiceObject serviceObject = ServiceBroker.Service.ServiceObjects[0]; serviceObject.Properties.InitResultTable(); DataTable results = base.ServiceBroker.ServicePackage.ResultTable; int id = base.GetIntProperty(Constants.SOProperties.ID, true); string listTitle = serviceObject.GetListTitle(); string siteURL = GetSiteURL(); using (ClientContext context = InitializeContext(siteURL)) { Web spWeb = context.Web; List list = spWeb.Lists.GetByTitle(listTitle); ListItem listItem = list.GetItemById(id); context.Load(list); context.Load(listItem); context.Load(listItem, i => i.File); context.ExecuteQuery(); DataRow dataRow = results.NewRow(); foreach (Property prop in serviceObject.Properties) { if (listItem.FieldValues.ContainsKey(prop.Name) && !prop.IsFile()) { Helpers.SPHelper.AddFieldValue(dataRow, prop, listItem); } if (prop.IsFile()) { var fileRef = listItem.File.ServerRelativeUrl; context.ExecuteQuery(); var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(context, fileRef); var fileName = (string)listItem.File.Name; using (var fileStream = new System.IO.MemoryStream()) { fileInfo.Stream.CopyTo(fileStream); byte[] fileByte = fileStream.ToArray(); FileProperty propFile = new FileProperty(prop.Name, new MetaData(), fileName, System.Convert.ToBase64String(fileByte)); dataRow[prop.Name] = propFile.Value;//fileString.ToString(); dataRow[string.Format("{0}{1}", prop.Name, Constants.SOProperties.FileNameSuffix)] = fileName; dataRow[string.Format("{0}{1}", prop.Name, Constants.SOProperties.FileURLSuffix)] = new StringBuilder(siteURL).Append(fileRef).ToString(); } } } results.Rows.Add(dataRow); } }
public IActionResult Index(FileProperty model) { //if (model.AllowedExtensions == null) //{ // model = new FileProperty() // { // AllowedExtensions = new string[] { "jpg", "pdf", "docx", "xlsx", "zip" }, // IsLimited = false // }; //} return(View(model)); }
public static bool IsContainer(this FileProperty property) { switch (property) { case FileProperty.DirectoryPathContains: case FileProperty.FileNameContains: case FileProperty.ContainsTag: return(true); default: return(false); } }
private async Task <List <FileProperty> > GetSystemFileProperties() { if (Item.IsShortcutItem) { return(null); } var list = await FileProperty.RetrieveAndInitializePropertiesAsync(Item.ItemFile, Constants.ResourceFilePaths.PreviewPaneDetailsPropertiesJsonPath); list.Find(x => x.ID == "address").Value = await FileProperties.GetAddressFromCoordinatesAsync((double?)list.Find(x => x.Property == "System.GPS.LatitudeDecimal").Value, (double?)list.Find(x => x.Property == "System.GPS.LongitudeDecimal").Value); return(list.Where(i => i.Value != null).ToList()); }
public void RefreshUICulture() { foreach (ThumbnailFile tlvi in thumbnails) { tlvi.RefreshUICulture(); } foreach (ToolStripMenuItem mnu in popMenu.Items) { FileProperty prop = (FileProperty)mnu.Tag; string resourceName = "FileProperty_" + prop.ToString(); string text = ScreenManagerLang.ResourceManager.GetString(resourceName); mnu.Text = text; } }
public static bool IsInteger(this FileProperty property) { switch (property) { case FileProperty.Width: case FileProperty.Height: case FileProperty.Rating: case FileProperty.Size: //case FileProperty.AspectRatio: return(true); default: return(false); } }
public static List <FileProperty> CreateMockFileProperties() { List <FileProperty> mockFileProperties = new List <FileProperty>(); for (int i = 0; i < 5; i++) { FileProperty fp = new FileProperty(); fp.Id = Guid.Parse(FilePropertyIds[i]); fp.FileId = Guid.Parse(FileGuids[fpFileIdIndices[i]]); fp.PropertyId = Guid.Parse(PropertyGuids[fpPropertyIndices[i]]); fp.Value = FilePropertyValues[i]; mockFileProperties.Add(fp); } return(mockFileProperties); }
public static bool IsDate(this FileProperty property) { switch (property) { case FileProperty.DateTimeCreated: case FileProperty.DateTimeModified: case FileProperty.DateTimeRegistered: case FileProperty.DateCreated: case FileProperty.DateModified: case FileProperty.DateRegistered: return(true); default: return(false); } }
public static string[] GetSheetNamesFromFile(FileProperty file) { Sheets theSheets = null; using (MemoryStream fileStream = new MemoryStream(System.Convert.FromBase64String(file.Content), true)) { using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileStream, false)) { WorkbookPart wbPart = document.WorkbookPart; theSheets = wbPart.Workbook.Sheets; } } string[] sheetNames = theSheets.Select(s => (s as Sheet).Name.Value).ToArray <string>(); return(sheetNames); }
/// <summary> /// Create language data file. /// </summary> /// <param name="fileName">Language data file name.</param> /// <param name="domain">Domain.</param> /// <returns>Errors.</returns> public ErrorSet CombineDataFile(string fileName, string domain) { if (string.IsNullOrEmpty(domain) || string.IsNullOrEmpty(domain.Trim())) { domain = DomainItem.GeneralDomain; } ErrorSet errorSet = new ErrorSet(); if (domain.Equals(DomainItem.GeneralDomain, StringComparison.OrdinalIgnoreCase)) { errorSet = EnsureNecessaryData(this._moduleDataSet); } else if (this._moduleDataSet.Count == 0) { errorSet.Add(new Error(DataCompilerError.DomainDataMissing, domain)); } if (!errorSet.Contains(ErrorSeverity.MustFix)) { using (LangDataFile langDataFile = new LangDataFile()) { // Set file property FileProperty fileProperty = new FileProperty(); fileProperty.Version = 1; fileProperty.Build = 0; fileProperty.LangID = (uint)_language; langDataFile.FileProperties = fileProperty; ArrayList sortedDataObjects = new ArrayList(); foreach (KeyValuePair<string, LangDataObject> obj in _moduleDataSet) { sortedDataObjects.Add(obj); } sortedDataObjects.Sort(new CompareLangDataObject()); // Set data objects foreach (KeyValuePair<string, LangDataObject> obj in sortedDataObjects) { if (obj.Value.Data == null) { continue; } langDataFile.AddDataObject(obj.Value); string message = Helper.NeutralFormat("Added {{{0}}} ({1}) data.", obj.Value.Token.ToString(), obj.Key); errorSet.Add(new Error(DataCompilerError.CompilingLog, message)); } // Save as binary file Helper.EnsureFolderExistForFile(fileName); langDataFile.Save(fileName); } } return errorSet; }
public Product() { Id = -1; Name = string.Empty; ProductType = ProductType.FamilyCar; ProductVideo = new FileProperty { AcceptableTypes = new FileContentType[] { new FileContentType { ContentType = "video", Subtype = "*"} }, Value = new FileValue() }; Pictures = new MultiFileProperty { AcceptableTypes = new FileContentType[] { new FileContentType {ContentType = "image", Subtype = "*"} }, Files = new FileValue[0] }; }