public async Task Populate <T>(IEnumerable <T> fileDatas, CancellationToken cancellationToken) where T : IFileData { Logger.Write(this, LogLevel.Debug, "Begin populating meta data."); if (this.ReportProgress) { await this.SetName("Populating meta data").ConfigureAwait(false); await this.SetPosition(0).ConfigureAwait(false); await this.SetCount(fileDatas.Count()).ConfigureAwait(false); if (this.Count <= 100) { this.Timer.Interval = FAST_INTERVAL; } else if (this.Count < 1000) { this.Timer.Interval = NORMAL_INTERVAL; } else { this.Timer.Interval = LONG_INTERVAL; } this.Timer.Start(); } var metaDataSource = this.MetaDataSourceFactory.Create(); await AsyncParallel.ForEach(fileDatas, async fileData => { Logger.Write(this, LogLevel.Debug, "Populating meta data for file: {0} => {1}", fileData.Id, fileData.FileName); var metaData = await metaDataSource.GetMetaData(fileData.FileName).ConfigureAwait(false); #if NET40 this.Semaphore.Wait(); #else await this.Semaphore.WaitAsync().ConfigureAwait(false); #endif try { foreach (var metaDataItem in metaData) { await this.Writer.Write(fileData.Id, metaDataItem).ConfigureAwait(false); } } finally { this.Semaphore.Release(); } if (this.ReportProgress) { this.Current = fileData; Interlocked.Increment(ref this.position); } }, cancellationToken, this.ParallelOptions).ConfigureAwait(false); }
public static byte[] GetBytes(this IFileData fileData) { var memoryStream = new MemoryStream(); fileData?.SaveToStream(memoryStream); return(memoryStream.ToArray()); }
public static ScannerItem FromFileData(IFileData fileData, ReplayGainMode mode) { var scannerItem = new ScannerItem() { FileName = fileData.FileName, Mode = mode }; if (mode == ReplayGainMode.Album) { var parts = new List <string>(); lock (fileData.MetaDatas) { var metaDatas = fileData.MetaDatas.ToDictionary( element => element.Name, StringComparer.OrdinalIgnoreCase ); var metaDataItem = default(MetaDataItem); if (metaDatas.TryGetValue(CommonMetaData.Year, out metaDataItem)) { parts.Add(metaDataItem.Value); } if (metaDatas.TryGetValue(CommonMetaData.Album, out metaDataItem)) { parts.Add(metaDataItem.Value); } } scannerItem.GroupName = string.Join(" - ", parts); } return(scannerItem); }
public bool SetFileOrderFirst() { List <IFileData> selectedFiles = GetSelectedFiles(); if (selectedFiles.Count > 0) { IFileData file = selectedFiles.First(); if (!file.IsUrl) { List <IFileData> files = Files.ToList(); files.Remove(file); files.Insert(0, file); SetFilePriorities(files); foreach (IFileData fileUpdate in files) { DataSourceAdapter.UpdateFile(fileUpdate); } return(true); } } return(false); }
public void LoadFile(string relativePath) { if (!Files.ContainsKey(relativePath)) { return; } try { string fullPath = NormalizeCombine(RootPath, relativePath); IFileData content = null; switch (Path.GetExtension(fullPath)) { case ".cs": content = new CodeFile(relativePath, DefaultPriority, fullPath); break; default: content = new TextFile(relativePath, DefaultPriority, fullPath); break; } AddFile(relativePath, content); } catch (FileNotFoundException) { throw; } }
public override async Task <LyricsResult> Lookup(IFileData fileData) { Logger.Write(this, LogLevel.Debug, "Getting track information for file \"{0}\"..", fileData.FileName); var artist = default(string); var song = default(string); if (!this.TryGetLookup(fileData, out artist, out song)) { Logger.Write(this, LogLevel.Warn, "Failed to get track information: The required meta data was not found."); return(LyricsResult.Fail); } Logger.Write(this, LogLevel.Debug, "Got track information: Artist = \"{0}\", Song = \"{1}\".", artist, song); try { Logger.Write(this, LogLevel.Debug, "Searching for match.."); var searchResult = await this.Lookup(artist, song).ConfigureAwait(false); if (searchResult != null) { Logger.Write(this, LogLevel.Debug, "Got match, fetching lyrics.."); var lyricsResult = await this.Lookup(searchResult).ConfigureAwait(false); if (lyricsResult != null && !string.IsNullOrEmpty(lyricsResult.Lyric)) { Logger.Write(this, LogLevel.Debug, "Success."); return(new LyricsResult(lyricsResult.Lyric)); } } } catch (Exception e) { Logger.Write(this, LogLevel.Warn, "Failed to fetch lyrics: {0}", e.Message); } return(LyricsResult.Fail); }
/// <summary> /// Adds a file index to ES /// </summary> /// <param name="fileData">The file to add</param> private void AddNew(IFileData fileData) { string requestUrl = GetRequestUrl(fileData); var elasticSearchNetwork=new ElasticSearchNetwork(requestUrl,"PUT",fileData.ToString()); elasticSearchNetwork.SendAndGetResponse(); }
public void InsertFile(IFileData file) { List <DbParameter> parameters; string insert = InsertStatement("Files", file, new string[] { "FileID" }, out parameters); DataAccess.ExecuteNonQuery(insert, parameters); }
/// <summary> /// Adds a file index to ES /// </summary> /// <param name="fileData">The file to add</param> private void AddNew(IFileData fileData) { string requestUrl = GetRequestUrl(fileData); var elasticSearchNetwork = new ElasticSearchNetwork(requestUrl, "PUT", fileData.ToString()); elasticSearchNetwork.SendAndGetResponse(); }
public bool CanGetValue(IFileData fileData, OnDemandMetaDataRequest request) { var provider = request.State as LyricsProvider ?? this.GetAutoLookupProvider(); if (provider == null) { return(false); } if (request.User) { //User requests are always processed. return(true); } lock (fileData.MetaDatas) { var metaDataItem = fileData.MetaDatas.FirstOrDefault( element => string.Equals(element.Name, CustomMetaData.LyricsRelease, StringComparison.OrdinalIgnoreCase) && element.Type == MetaDataItemType.Tag ); if (metaDataItem != null && string.Equals(metaDataItem.Value, provider.None, StringComparison.OrdinalIgnoreCase)) { //We have previously attempted a lookup and it failed, don't try again (automatically). return(false); } } return(true); }
public bool Edit() { List <IFileData> selectedFiles = GetSelectedFiles(); if (selectedFiles.Count > 0) { IFileData file = selectedFiles.First(); FileDetailsEditForm form = new FileDetailsEditForm(); form.Initialize(DataSourceAdapter, file); form.StartPosition = FormStartPosition.CenterParent; if (form.ShowDialog(this) == DialogResult.OK && form.SourcePort != null && !file.IsUrl) { file.SourcePortID = form.SourcePort.SourcePortID; file.Description = form.Description; DataSourceAdapter.UpdateFile(file); return(true); } else if (form.SourcePort == null) { MessageBox.Show(this, "A source port must be selected.", "Error", MessageBoxButtons.OK); } } return(false); }
/// <summary> /// Deletes a specific file index from ES /// </summary> /// <param name="fileData">The file to delete</param> public void Delete(IFileData fileData) { string requestUrl = GetRequestUrl(fileData); var elasticSearchNetwork = new ElasticSearchNetwork(requestUrl, "DELETE"); elasticSearchNetwork.Send(); }
private string GetNiceFileName(IFileData file, List <ISourcePortData> sourcePorts) { string prefix; if (file.FileTypeID == FileType.Demo && file.Description.Length > 0) { prefix = file.Description; } else { prefix = Path.GetFileNameWithoutExtension(file.OriginalFileName); } if (string.IsNullOrEmpty(prefix)) { prefix = file.FileTypeID.ToString().ToLower(); } string sourcePortName = "N/A"; var sourcePort = sourcePorts.FirstOrDefault(x => x.SourcePortID == file.SourcePortID); if (sourcePort != null) { sourcePortName = sourcePort.Name; } return($"{prefix}_{sourcePortName}_{Path.GetFileNameWithoutExtension(GameFile.FileNameNoPath)}{Path.GetExtension(file.FileName)}"); }
/// <summary> /// Конвертер информации о файле из локальной модели в трансферную /// </summary> private async Task <IResultValue <FileDataRequestClient> > ToFileDataRequest(IFileData fileData) => await _fileSystemOperations.FileToByteAndZip(fileData.FilePath). ResultValueOkBindAsync(fileSource => AdditionalFileExtensions.FileExtensions. Select(extension => FilePathOperations.ChangeFileName(fileData.FilePath, fileData.FileName, extension)). FirstOrDefault(filePath => _filePathOperations.IsFileExist(filePath)). Map(fileAdditionalPath => ToFileDataRequest(fileData, fileSource, fileAdditionalPath)));
public virtual void View() { List <IFileData> selectedFiles = GetSelectedFiles(); try { if (selectedFiles.Count > 0) { IFileData file = selectedFiles.First(); if (file.IsUrl) { Process.Start(file.FileName); } else { if (File.Exists(Path.Combine(DataDirectory.GetFullPath(), file.FileName))) { Process.Start(Path.Combine(DataDirectory.GetFullPath(), file.FileName)); } } } } catch (Exception ex) { // This happens when windows doesn't recognize the file extension MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void CompileFile(IFileData file) { if (file is CodeFile) { CompileFile(file as CodeFile); } }
public FilesChange(IReadOnlyCollection <IFileData> filesDataProject, IFileData fileData, ActionType actionType, bool isStatusProcessingProjectChanged) : this(filesDataProject, new List <IFileData> { fileData }, actionType, isStatusProcessingProjectChanged) { }
static void Main(string[] args) { IFileData file = Factory.CreateFileData(); IListSorter sorter = Factory.CreateListSorter(); // Validate file bool fileValidation = file.IsValidFile(args); if (fileValidation == false) { file.ErrorMessage(); return; } //Get data from file string[] records = file.ReadRecords(args[0]); //Create list people var peopleList = sorter.CreateList(records); //Sort list people var sortedPeopleList = sorter.SortByLastName(peopleList); //Covert list people to string array records = sorter.ConvertModelToString(sortedPeopleList); //Display data file.DisplayRecords(records); //Create file with sorted data file.WriteRecords(records); }
protected virtual void AddSource(IFileData source, MetaDataItem metaDataItem) { this.Sources.Add(source); if (metaDataItem != null) { this.MetaDataItems.Add(source, metaDataItem); } }
public FileController(IFileData fileData, IImageResizer imageResizer, UserManager <NexulIdentityUser> userManager) { _fileData = fileData; _imageResizer = imageResizer; _userManager = userManager; }
private void CopyFile(IFileData file, string to) { FileInfo fi = new FileInfo(Path.Combine(DataDirectory.GetFullPath(), file.FileName)); if (fi.Exists) { fi.CopyTo(to, true); } }
protected virtual void AddSource(IFileData source) { this.AddSource( source, source.MetaDatas.FirstOrDefault( metaDataItem => string.Equals(metaDataItem.Name, this.Name, StringComparison.OrdinalIgnoreCase) ) ); }
protected virtual Discogs.TrackDetails GetTrackDetails(IFileData fileData, IDictionary <string, MetaDataItem> metaData, Discogs.ReleaseDetails releaseDetails) { return(this.GetTrackDetails( fileData, this.GetTrackNumber(fileData, metaData), this.GetTrackTitle(fileData, metaData), releaseDetails )); }
/// <summary> /// Конвертер информации о файле из локальной модели в трансферную /// </summary> private async Task <IResultValue <FileDataRequestClient> > ToFileDataRequest(IFileData fileData, byte[] fileSource, string fileAdditionalPath) => await fileAdditionalPath. WhereContinueAsyncBind(filePath => !String.IsNullOrWhiteSpace(filePath), filePath => _fileSystemOperations.FileToByteAndZip(filePath), filePath => Task.FromResult((IResultValue <byte[]>) new ResultValue <byte[]>(new byte[0]))). ResultValueOkAsync(fileAdditionalSource => new FileDataRequestClient(fileData.FilePath, fileData.ColorPrintType, fileData.StatusProcessing, fileSource, FilePathOperations.ExtensionWithoutPointFromPath(fileAdditionalPath), fileAdditionalSource));
public static T GetValueOrDefault <T>(this IFileData fileData, string name, MetaDataItemType type, T value = default(T)) { var text = fileData.GetValueOrDefault(name, type); if (string.IsNullOrEmpty(text)) { return(value); } return((T)Convert.ChangeType(text, typeof(T))); }
public HomeController(IFileData fileData, IGreeter greeter, ILogger <HomeController> logger, IBlobService blobService, UserManager <User> userManager, IConnectionManager connectionManager) : base(userManager) { _fileData = fileData; _greeter = greeter; _logger = logger; _blobService = blobService; _connectionManager = connectionManager; }
public void SetUp() { _fileData = new FileDataTest() { Checksum = "123", Content = "test", Path = new List <string> { @"c:\test\test.txt" } }; _elasticSearchClient = new ElasticSearchClient(new ServerInfo("localhost", 9200)); }
public TextFileParser(FileProfile fileToProcess, IFileData fileData, IDslScriptRunner scriptRunner, string[] headerFields, int startAtLineNumber = -1) { _table = new Table(); _scriptRunner = scriptRunner; _fileToStreamConverter = new FileToStreamConverter(); _fileToProcess = fileToProcess; _fileData = fileData; _headerFields = headerFields; _headerLines = startAtLineNumber; }
public static List <IFileData> CreateFileAssociation(IWin32Window parent, IDataSourceAdapter adapter, LauncherPath directory, FileType type, IGameFile gameFile, ISourcePortData sourcePort, bool multiSelect = false) { List <IFileData> fileDataList = new List <IFileData>(); OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = multiSelect; if (dialog.ShowDialog(parent) == DialogResult.OK) { bool isMultiImport = dialog.FileNames.Length > 1; FileDetailsEditForm detailsForm = new FileDetailsEditForm(); detailsForm.Initialize(adapter); detailsForm.StartPosition = FormStartPosition.CenterParent; detailsForm.ShowDescription(!isMultiImport); if (sourcePort != null) { detailsForm.SourcePort = sourcePort; } if (!isMultiImport) { detailsForm.Description = Path.GetFileName(dialog.FileNames[0]); } if (detailsForm.ShowDialog(parent) == DialogResult.OK && detailsForm.SourcePort != null) { foreach (string file in dialog.FileNames) { FileInfo fi = new FileInfo(file); IFileData fileData = CreateNewFileDataSource(detailsForm, fi, type, gameFile); if (isMultiImport) { fileData.Description = Path.GetFileName(file); } fi.CopyTo(Path.Combine(directory.GetFullPath(), fileData.FileName)); adapter.InsertFile(fileData); var fileSearch = adapter.GetFiles(gameFile, type).FirstOrDefault(x => x.FileName == fileData.FileName); if (fileSearch != null) { fileData = fileSearch; } fileDataList.Add(fileData); } } else if (detailsForm.SourcePort == null) { MessageBox.Show(parent, "A source port must be selected.", "Error", MessageBoxButtons.OK); } } return(fileDataList); }
public static string GetValueOrDefault(this IFileData fileData, string name, MetaDataItemType type, string value = null) { foreach (var metaDataItem in fileData.MetaDatas) { if (string.Equals(metaDataItem.Name, name, StringComparison.OrdinalIgnoreCase) && metaDataItem.Type == type) { return(metaDataItem.Value); } } return(value); }
public IFileData CreateFileDataObject() { IFileData fileData = CreateFileData(this.objectSpace, this.memberInfo); CreateCustomFileDataObjectEventArgs createCustomFileDataObjectEventArgs = new CreateCustomFileDataObjectEventArgs(fileData); if (createCustomFileDataObject != null) { createCustomFileDataObject(this, createCustomFileDataObjectEventArgs); } return(createCustomFileDataObjectEventArgs.FileData); }
/// <summary> /// Adds a file on ES,if the file exists it's path is updated to include the new location /// </summary> /// <param name="fileData">The file to index</param> public void Index(IFileData fileData) { if (CheckExists(fileData)) { UpdatePath(fileData); } else { AddNew(fileData); } }
/// <summary> /// Deletes a specific file index from ES /// </summary> /// <param name="fileData">The file to delete</param> public void Delete(IFileData fileData) { string requestUrl = GetRequestUrl(fileData); var elasticSearchNetwork = new ElasticSearchNetwork(requestUrl, "DELETE"); elasticSearchNetwork.Send(); }
/// <summary> /// Checks if a certain file exists on ES /// </summary> /// <param name="fileData">The file to check</param> /// <returns>True if the file exists, otherwise False</returns> public bool CheckExists(IFileData fileData) { string requestUrl = GetRequestUrl(fileData); var elasticSearchNetwork = new ElasticSearchNetwork(requestUrl, "GET"); try { elasticSearchNetwork.Send(); return true; } catch (System.Exception) { return false; } }
public CreateCustomFileDataObjectEventArgs(IFileData fileData) { this.fileData = fileData; }
private bool OpenFile(IModuleExchange parent, IFileData fileData, Guid contextID, XafApplication app) { bool result = false; switch (System.IO.Path.GetExtension(fileData.FileName)) { case ".eeg": { result = true; string tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("B")); System.IO.Directory.CreateDirectory(tempDirectory); string tempFileName = Path.Combine(tempDirectory, fileData.FileName); try { using (FileStream stream = new FileStream(tempFileName, FileMode.CreateNew)) { fileData.SaveToStream(stream); } RegistryKey key = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, ""); RegistryKey target_key = key.OpenSubKey(keyPath); if (target_key != null ? target_key.GetValueNames().Contains(keyName) : false) { String path = Convert.ToString(target_key.GetValue(keyName)) + appName; Process process = new Process(); ProcessStartInfo ps = new ProcessStartInfo(path); ps.Arguments = String.Format(@"""{0}""", tempFileName); process.StartInfo = ps; process.Exited += (object sender, EventArgs args) => { parent.ProcessMessage(contextID, "Stop"); }; process.Start(); process.EnableRaisingEvents = true; } } catch { Tracing.Tracer.LogValue("tempFileName", tempFileName); throw; } } break; case ".mef": { result = true; string tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("B")); System.IO.Directory.CreateDirectory(tempDirectory); string tempFileName = Path.Combine(tempDirectory, fileData.FileName); try { using (FileStream stream = new FileStream(tempFileName, FileMode.CreateNew)) { fileData.SaveToStream(stream); } RegistryKey key = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, ""); RegistryKey target_key = key.OpenSubKey(keyPath); if (target_key != null ? target_key.GetValueNames().Contains("MainEegPath") : false) { String path = Convert.ToString(target_key.GetValue("MainEegPath")) + "eeg.exe"; Process process = new Process(); ProcessStartInfo ps = new ProcessStartInfo(path); ps.Arguments = String.Format(@"""{0}""", tempFileName); process.StartInfo = ps; process.Exited += (object sender, EventArgs args) => { parent.ProcessMessage(contextID, "Stop"); }; process.Start(); process.EnableRaisingEvents = true; } } catch { Tracing.Tracer.LogValue("tempFileName", tempFileName); throw; } } break; } return result; }
public void SetUp() { _fileData = new FileDataTest() {Checksum = "123",Content = "test",Path = new List<string>{@"c:\test\test.txt"}}; _elasticSearchClient = new ElasticSearchClient(new ServerInfo("localhost", 9200)); }
public void Save(IFileData fileData) { using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { saveFileDialog.CreatePrompt = false; saveFileDialog.OverwritePrompt = true; string text = Path.GetExtension(fileData.FileName).TrimStart(new char[] { '.' }); string localizedText = CaptionHelper.GetLocalizedText("FileAttachments", "WordAll"); string localizedText2 = CaptionHelper.GetLocalizedText("FileAttachments", "WordFiles"); saveFileDialog.Filter = string.Concat(new string[] { text.ToUpper(), " ", localizedText2, " (*.", text, ")|*.", text, "|", localizedText, " ", localizedText2, " (*.*)|*.*" }); //IModelOptionsFileAttachments modelOptionsFileAttachments = base.Application.Model.Options as IModelOptionsFileAttachments; //saveFileDialog.InitialDirectory = modelOptionsFileAttachments.Attachments.DefaultDirectory; saveFileDialog.FileName = fileData.FileName; saveFileDialog.Title = CaptionHelper.GetLocalizedText("FileAttachments", "OverwritePromptCaption"); if (saveFileDialog.ShowDialog(Form.ActiveForm) == DialogResult.OK) { //modelOptionsFileAttachments.Attachments.DefaultDirectory = Path.GetDirectoryName(saveFileDialog.FileName); using (FileStream fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create)) { fileData.SaveToStream(fileStream); } } } }
public void Open(IFileData fileData) { DevExpress.ExpressApp.Utils.Guard.ArgumentNotNull(fileData, "fileData"); if (!FileDataHelper.IsFileDataEmpty(fileData)) { CustomFileOperationEventArgs customFileOperationEventArgs = new CustomFileOperationEventArgs(fileData); this.OnCustomOpenFileWithDefaultProgram(customFileOperationEventArgs); if (!customFileOperationEventArgs.Handled) { string text = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("B")); try { Directory.CreateDirectory(text); } catch { Tracing.Tracer.LogValue("tempDirectory", text); throw; } string text2 = Path.Combine(text, fileData.FileName); try { using (FileStream fileStream = new FileStream(text2, FileMode.CreateNew)) { fileData.SaveToStream(fileStream); } Process.Start(text2); } catch { Tracing.Tracer.LogValue("tempFileName", text2); throw; } } } }
private ListViewItem CreateListViewItem(IFileData fileData) { ListViewItem listViewItem = new ListViewItem(fileData.FileName, 0); if (fileData is ExaminationFile) { listViewItem.Name = fileData.FileName; listViewItem.Text = CaptionHelper.GetLocalizedText("FileAttachments", "ExaminationListViewItem_Text"); } else if (fileData is ConclusionFile) { listViewItem.Name = fileData.FileName; listViewItem.Text = CaptionHelper.GetLocalizedText("FileAttachments", "ConclusionListViewItem_Text"); } return listViewItem; }
public LoadFileForm(IFileData file, FileDataOperateType type = FileDataOperateType.Insert) { InitializeComponent(); this.file = file; this.type = type; }
private void ListViewControlRefresh(IFileData fileData, ListViewItem listViewItem) { String extension = System.IO.Path.GetExtension(fileData.FileName); if (Converters.AllowedImageExtension.Contains(extension)) { listViewItem.ImageIndex = 1; } else { if (XAttachmentImageListControl.Images.ContainsKey(extension) == false) { Object fp = Configuration.Config.Data.Variables.GlobalIconsInfo[extension]; if (fp != null) { String fileAndParam = Configuration.Config.Data.Variables.GlobalIconsInfo[extension].ToString(); Icon associatedIcon = RegisteredFileType.ExtractIconFromFile(fileAndParam, true); if (associatedIcon != null) { XAttachmentImageListControl.Images.Add(extension, associatedIcon); listViewItem.ImageKey = extension; } else { Icon fileIcon = Icon.ExtractAssociatedIcon((fileData as FileSystemStoreObject).RealFileName); XAttachmentImageListControl.Images.Add((fileData as FileSystemStoreObject).RealFileName, fileIcon); listViewItem.ImageKey = (fileData as FileSystemStoreObject).RealFileName; } } } else { listViewItem.ImageKey = extension; } } listViewItem.Tag = fileData; XAttachmentListViewControl.Items.Add(listViewItem); }
public FileParameterDescriptorEx(string id, string alias, int maxSize, FileTypeOptions fileType, IFileData fileData) : base(id, alias, maxSize, fileType) { FileData = fileData; }
private bool OpenFile(IFileData fileData) { bool result = false; // Перехватываем открытие файла со специфичным расширением !!! АХТУНГ if (Converters.ConvertToXtraDocumentFormat(fileData.FileName) == DocumentFormat.Undefined) result = true; return result; }
/// <summary> /// Adds the new path to the indexed path of a file /// </summary> /// <param name="fileData">The file to update</param> private void UpdatePath(IFileData fileData) { string requestUrl = GetRequestUrl(fileData) + "/_update"; var paths = GetCurrentPath(fileData); paths.AddRange(fileData.Path); var pathsString = JsonConvert.SerializeObject(paths.Distinct()); var requestText = String.Format("{{\"doc\":{{\"Path\":{0}}}}}",pathsString); var elasticSearchNetwork = new ElasticSearchNetwork(requestUrl, "POST", requestText); elasticSearchNetwork.SendAndGetResponse(); }
private string GetRequestUrl(IFileData fileData) { return "http://" + ServerInfo + "/" + fileData.FileType.Index + "/" + fileData.FileType.Category + "/" + fileData.Checksum; }
/// <summary> /// <para>Creates a new instance of the CustomFileOperationEventArgs class. /// </para> /// </summary> /// <param name="fileData"> /// An <b>IFileData</b> object, representing a file about to be opened via its associated program. This parameter value is assigned to the <see cref="P:DevExpress.ExpressApp.FileAttachments.Win.CustomFileOperationEventArgs.FileData" /> property. /// /// /// </param> public CustomFileOperationEventArgs(IFileData fileData) { this.fileData = fileData; }
/// <summary> /// Gets the current path of an indexed file /// </summary> /// <param name="fileData">The file to get the current path of</param> /// <returns>A list of the Current paths</returns> private List<string> GetCurrentPath(IFileData fileData) { string requestUrl = GetRequestUrl(fileData); var elasticSearchNetwork = new ElasticSearchNetwork(requestUrl, "GET"); var responseText = elasticSearchNetwork.SendAndGetResponse(); dynamic responseJson = JObject.Parse(responseText); var paths = new List<string>(); foreach (var path in responseJson._source.Path) { paths.Add(path.Value); } return paths; }