/// <summary> /// Create a Settings xml file to save the entered URL to load them with the start of the program /// </summary> private void SaveUrlToXml() { XmlDocument doc = new XmlDocument(); XmlNode myRoot, myNode; myRoot = doc.CreateElement("URL"); doc.AppendChild(myRoot); myNode = doc.CreateElement("SourcePath"); myNode.InnerText = SourceFilePath.ToString(); myRoot.AppendChild(myNode); myNode = doc.CreateElement("TargetPath"); myNode.InnerText = TargetFilePath.ToString(); myRoot.AppendChild(myNode); try { string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString(); path += "\\FileWatcherSettings"; Directory.CreateDirectory(path); doc.Save(path + "\\Settings.xml"); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void SetDefaults() { buttonArchive.Enabled = false; FileInfo fi = null; if (!string.IsNullOrEmpty(SourceFilePath)) { fi = new FileInfo(SourceFilePath); } if (fi != null && fi.Exists) { string baseDir = fi.DirectoryName; int idx = SourceFilePath.LastIndexOf("."); string archiveFilename = SourceFilePath.Substring(0, idx) + ".zip"; textBoxBaseFrom.Text = baseDir; textBoxArchiveName.Text = archiveFilename; buttonArchive.Enabled = true; } else { MessageBox.Show(this, "Save the file first", "Source file list not found", MessageBoxButtons.OK); buttonArchive.Enabled = false; } }
public override LauncherCommand ToCommand(string resolvedRootPath) { return(new FileCopierCommand() { SourceFilePath = SourceFilePath.Replace(RootToken, resolvedRootPath), TargetFilePath = TargetFilePath.Replace(RootToken, resolvedRootPath) }); }
public override bool Equals(object obj) { var other = obj as FileFormatMessage; return(other != null && StartLine == other.StartLine && StartColumn == other.StartColumn && Message.Equals(other.Message, StringComparison.Ordinal) && SourceFilePath.Equals(other.SourceFilePath, StringComparison.OrdinalIgnoreCase)); }
public override int GetHashCode() { unchecked { var hashCode = (int)Type; hashCode = (hashCode * 397) ^ (SourceFilePath != null ? SourceFilePath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DestinationPathFile != null ? DestinationPathFile.GetHashCode() : 0); return(hashCode); } }
///-------------------------------------------------------------------------------- /// <summary>This method determines whether or not any metadata is /// different between the input instance and the current instance.</summary> /// /// <param name="inputXmlSource">The xmlsource to compare metadata.</param> ///-------------------------------------------------------------------------------- public bool IsIdenticalMetadata(XmlSource inputXmlSource) { if (SourceFileName.GetString() != inputXmlSource.SourceFileName.GetString()) { return(false); } if (SourceFilePath.GetString() != inputXmlSource.SourceFilePath.GetString()) { return(false); } #region protected #endregion protected return(true); }
public Formatter[] GetDefaultFormatter(DateTime time) { var timestampColor = Color.LightGray; var typeName = TypeHelper.GetName(Type); var sourcePath = "Cake." + SourceFilePath.Split(new[] { "Cake." }, StringSplitOptions.RemoveEmptyEntries).Last(); Formatter[] formatter = { new Formatter(typeName, DefaultColor), new Formatter(time.ToString(CultureInfo.InvariantCulture), timestampColor), new Formatter(Text, DefaultColor), new Formatter(sourcePath, Color.DarkSlateBlue), new Formatter(SourceLine, Color.DarkViolet) }; return(formatter); }
public override string DrawJobInspectorAndGetEnabledParams(string CurrentParams) { string EnabledParams = CurrentParams; IgorConfigWindow ConfigurationWindow = IgorConfigWindow.OpenOrGetConfigWindow(); IgorPersistentJobConfig CurrentJob = ConfigurationWindow.CurrentJobInst; string CurrentJobAsString = CurrentJob != null ? CurrentJob.JobName : string.Empty; string TargetDirectory = kPlayerSettingsFolder + "/" + CurrentJobAsString; GUILayout.BeginHorizontal(); { string SelectedProjectSettingsAsString = IgorRuntimeUtils.GetStringParam(EnabledParams, PlayerSettingFilesToOverrideFlag).Trim('"'); if (!string.IsNullOrEmpty(SelectedProjectSettingsAsString)) { int OutResult = 0; if (Int32.TryParse(SelectedProjectSettingsAsString, out OutResult)) { SelectedProjectSettingsAsInt = OutResult; } } int newValue = EditorGUILayout.MaskField(SelectedProjectSettingsAsInt, kProjectSettingFiles); if (newValue != SelectedProjectSettingsAsInt) { SelectedProjectSettingsAsInt = newValue; if (newValue != 0) { EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, PlayerSettingFilesToOverrideFlag, SelectedProjectSettingsAsInt.ToString()); EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, PlayerSettingsPathFlag, '"' + TargetDirectory + '"'); } else { EnabledParams = IgorRuntimeUtils.ClearParam(EnabledParams, PlayerSettingFilesToOverrideFlag); EnabledParams = IgorRuntimeUtils.ClearParam(EnabledParams, PlayerSettingsPathFlag); } } } GUILayout.EndHorizontal(); string FilesToSave = string.Empty; for (int i = 0; i < kProjectSettingFiles.Length; ++i) { if (((1 << i) & SelectedProjectSettingsAsInt) != 0) { FilesToSave += ((string.IsNullOrEmpty(FilesToSave) ? string.Empty : ", ") + kProjectSettingFiles[i].Replace(".asset", string.Empty)); } } GUILayout.Space(5f); GUILayout.Label("Files to save: " + FilesToSave); if (Directory.Exists(TargetDirectory)) { GUILayout.Space(5f); string[] SourceFilesPaths = Directory.GetFiles(TargetDirectory); string ExistingOverrides = string.Empty; foreach (string SourceFilePath in SourceFilesPaths) { ExistingOverrides += ((string.IsNullOrEmpty(ExistingOverrides) ? string.Empty : ", ") + Path.GetFileName(SourceFilePath).Replace(kIgorProjectSettingExtension, string.Empty)); } GUILayout.Label("Existing overrides on disk: " + ExistingOverrides); GUILayout.Space(5f); } GUILayout.BeginHorizontal(); { GUI.enabled = CurrentJob != null && SelectedProjectSettingsAsInt != 0; if (GUILayout.Button("Save", GUILayout.ExpandWidth(false))) { if (!Directory.Exists(kPlayerSettingsFolder)) { Directory.CreateDirectory(kPlayerSettingsFolder); } IgorRuntimeUtils.DeleteDirectory(TargetDirectory); Directory.CreateDirectory(TargetDirectory); string[] SourceFilesPaths = Directory.GetFiles("ProjectSettings"); foreach (string SourceFilePath in SourceFilesPaths) { if (!SourceFilePath.EndsWith(".meta")) { string FileName = Path.GetFileName(SourceFilePath); int IndexInKnownAssetList = Array.IndexOf(kProjectSettingFiles, FileName, 0, kProjectSettingFiles.Length); if (IndexInKnownAssetList != -1) { if ((((1 << IndexInKnownAssetList) & SelectedProjectSettingsAsInt) != 0) || SelectedProjectSettingsAsInt == -1) { string DestFilePath = SourceFilePath.Replace("ProjectSettings\\", string.Empty); DestFilePath = TargetDirectory + "/" + Path.ChangeExtension(DestFilePath, kIgorProjectSettingExtension); IgorRuntimeUtils.CopyFile(SourceFilePath, DestFilePath); } } } } AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } string Tooltip = Directory.Exists(TargetDirectory) ? string.Empty : "Expected PlayerSettings directory " + " doesn't exist."; GUI.enabled &= Directory.Exists(TargetDirectory); if (GUILayout.Button(new GUIContent("Load saved settings file", Tooltip), GUILayout.ExpandWidth(false))) { CopyStoredPlayerSettingsOverCurrent(TargetDirectory); } GUI.enabled = true; } GUILayout.EndHorizontal(); return(EnabledParams); }
private static void CopyStoredPlayerSettingsOverCurrent(string TargetDirectory) { string[] SourceFilesPaths = Directory.GetFiles(TargetDirectory); if (SourceFilesPaths.Length > 0) { Debug.Log("Overriding player settings with data from " + TargetDirectory + "..."); foreach (string SourceFilePath in SourceFilesPaths) { string DestFilePath = SourceFilePath.Replace(TargetDirectory, "ProjectSettings"); DestFilePath = Path.ChangeExtension(DestFilePath, ".asset"); IgorRuntimeUtils.CopyFile(SourceFilePath, DestFilePath, true); Debug.Log("Replaced " + Path.GetFileName(DestFilePath)); // We need to find the ProjectSettings file and locate the defines text manually because otherwise // the recompile (if it even triggers; it's inconsistent) won't use the new defines. const string ScriptingDefineSymbolsTag = "scriptingDefineSymbols:\n"; if (DestFilePath.Contains("ProjectSettings.asset")) { string ProjectSettingsText = File.ReadAllText(SourceFilePath); int StartIndex = ProjectSettingsText.IndexOf(ScriptingDefineSymbolsTag) + ScriptingDefineSymbolsTag.Length; string StartOfDefinesBlock = ProjectSettingsText.Substring(StartIndex); HashSet <BuildTargetGroup> MatchedBuildTargetGroups = new HashSet <BuildTargetGroup>(); string NextLine; StringReader StringReader = new StringReader(StartOfDefinesBlock); bool bContinue = true; do { NextLine = StringReader.ReadLine(); if (NextLine != null) { NextLine = NextLine.Trim(); if (NextLine.Length > 0 && char.IsNumber(NextLine[0])) { int IndexOfColon = NextLine.IndexOf(':'); string BuildGroupText = NextLine.Substring(0, IndexOfColon); string Define = NextLine.Substring(IndexOfColon + 1); int BuildGroupAsInt = 0; Int32.TryParse(BuildGroupText, out BuildGroupAsInt); BuildTargetGroup TargetGroup = (BuildTargetGroup)BuildGroupAsInt; if (TargetGroup != BuildTargetGroup.Unknown) { PlayerSettings.SetScriptingDefineSymbolsForGroup(TargetGroup, Define); MatchedBuildTargetGroups.Add(TargetGroup); } } else { bContinue = false; } } }while(bContinue); // Make sure we wipe out defines on any other build targets. BuildTargetGroup[] AllTargetGroups = System.Enum.GetValues(typeof(BuildTargetGroup)) as BuildTargetGroup[]; foreach (BuildTargetGroup Group in AllTargetGroups) { if (!MatchedBuildTargetGroups.Contains(Group)) { PlayerSettings.SetScriptingDefineSymbolsForGroup(Group, string.Empty); } } } } AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); } }
protected override void Execute(NativeActivityContext context) { WorkflowDataContext dataContext = context.DataContext; PropertyDescriptorCollection propertyDescriptorCollection = dataContext.GetProperties(); string sessionId = string.Empty; int fileSystemItemId = 0; foreach (PropertyDescriptor propertyDesc in propertyDescriptorCollection) { if (propertyDesc.Name == "ArgSessionId") { sessionId = propertyDesc.GetValue(dataContext) as string; break; } } foreach (PropertyDescriptor propertyDesc in propertyDescriptorCollection) { if (propertyDesc.Name == "ArgFileSystemItemId") { fileSystemItemId = (int)propertyDesc.GetValue(dataContext); break; } } if (string.IsNullOrWhiteSpace(sessionId)) { LogHelper.AddGeneralLog(GeneralLogTypeEnum.ActivityError, $"SessionId is null."); return; } if (fileSystemItemId == 0) { LogHelper.AddSessionLog(SessionLogTypeEnum.ActivityError, sessionId, $"FileSystemItemId is null."); return; } FileSystemItemDto fileSystemItem = null; try { using (var sqlDbContext = new SqlDbContext()) { fileSystemItem = sqlDbContext.FileSystemItems.FirstOrDefault(x => x.Id == fileSystemItemId); } } catch (Exception ex) { LogHelper.AddSessionLog(SessionLogTypeEnum.ActivityError, sessionId, $"Exception has been thrown when getting fileSystemItem. FileSystemItemId: {fileSystemItemId}", ex); return; } if (File.Exists(SourceFilePath.Get(context)) == false) { LogHelper.AddFileSystemItemLog(fileSystemItem.Id, fileSystemItem.SourceId, sessionId, FileSystemItemLogTypeEnum.SaveTextDataFileNotFound, $"File path: {SourceFilePath.Get(context)}."); return; } var content = File.ReadAllText(SourceFilePath.Get(context)); try { using (var sqlDbContext = new SqlDbContext()) { var saveResult1 = sqlDbContext.SaveChanges(); var oldItemCount = sqlDbContext.ClearTexts.Count(x => x.FileSystemItemId == fileSystemItemId); if (oldItemCount == 0) { var clearTextDto = new ClearTextDto { FileSystemItemId = fileSystemItemId, TextInFile = content, }; sqlDbContext.ClearTexts.Add(clearTextDto); var saveResult2 = sqlDbContext.SaveChanges(); } else { var oldClearText = sqlDbContext.ClearTexts.FirstOrDefault(x => x.FileSystemItemId == fileSystemItemId); var sql = "UPDATE ClearText SET TextInFile = @TextInFile WHERE Id = @Id"; var executeCount = sqlDbContext.Database.ExecuteSqlCommand(sql, content, oldClearText.Id); } } LogHelper.AddFileSystemItemLog(fileSystemItem.Id, fileSystemItem.SourceId, sessionId, FileSystemItemLogTypeEnum.SaveTextDataOk); } catch (Exception ex) { LogHelper.AddSessionLog(SessionLogTypeEnum.ActivityError, sessionId, $"Exception has been thrown when getting fileSystemItem. FileSystemItemId: {fileSystemItemId}", ex); return; } }
public override bool ProcessContentLinks() { string fname = Path.GetFileName(SourceFilePath); bool yml = string.Equals(fname, "toc.yml", StringComparison.InvariantCultureIgnoreCase); bool result = string.Equals(fname, "toc.md", StringComparison.InvariantCultureIgnoreCase) || yml || ContentHasAudienceApplicationUser(_content); if (result) { FoundLink[] links = FindAllLinks(yml, _content); Links.AddRange(links.Select(l => l.FullMatch)); foreach (FoundLink link in links.GroupBy(k => k).Select(k => k.Key)) { if (String.IsNullOrEmpty(link.Link.Trim())) { continue; } string linkClear = CleanLinkOfQueryAndHash(link.Link); if (linkClear.StartsWith("http", StringComparison.InvariantCultureIgnoreCase) || linkClear.EndsWith("toc.md", StringComparison.InvariantCultureIgnoreCase) || linkClear.EndsWith("toc.yml", StringComparison.InvariantCultureIgnoreCase) || linkClear.StartsWith("mailto", StringComparison.InvariantCultureIgnoreCase)) { continue; } try { string href = BuildFullUrl("/" + SourceFilePath, linkClear); ProcessLink(href, link.Link, new ConceptualItemParameter(ref _content, link, href)); } catch (Exception ex) { Logger.LogWarning($"Message: \"{ex.Message}\", File: \"{fname}\", Href: \"{link.Link}\""); } } FoundPicture[] pictures = FindAllPictures(_content); Pictures.AddRange(pictures.Select(p => p.FullMatch)); foreach (FoundPicture picture in pictures) { try { string href = BuildFullUrl("/" + SourceFilePath, GetOnlyLink(picture.Link1)); ProcessLink(href, picture.Link1, null); if (!String.IsNullOrEmpty(picture.Link2) && !picture.Link1.Equals(picture.Link2)) { string link2 = CleanLinkOfQueryAndHash(GetOnlyLink(picture.Link2)); href = BuildFullUrl("/" + SourceFilePath, link2); ProcessLink(href, picture.Link2, null); } } catch (Exception ex) { Logger.LogWarning($"Message: \"{ex.Message}\", File: \"{fname}\", Link1: \"{picture.Link1}\", Link2: \"{picture.Link2}\""); } } FoundLink[] includes = FindIncludedLinks(_content); foreach (FoundLink link in includes.GroupBy(k => k).Select(k => k.Key)) { if (String.IsNullOrEmpty(link.Link.Trim())) { continue; } string linkClear = CleanLinkOfQueryAndHash(link.Link); if (linkClear.StartsWith("http", StringComparison.InvariantCultureIgnoreCase) || linkClear.EndsWith("toc.md", StringComparison.InvariantCultureIgnoreCase) || linkClear.EndsWith("toc.yml", StringComparison.InvariantCultureIgnoreCase)) { continue; } try { string href = BuildFullUrl("/" + SourceFilePath, linkClear); if (!FilesToIgnore.Contains(href.TrimStart('\\'))) { FilesToIgnore.Add(href.TrimStart('\\')); } } catch (Exception ex) { Logger.LogWarning($"Message: \"{ex.Message}\", File: \"{fname}\", Href: \"{link.Link}\""); } } return(HasModified); } if (!(fname != null && fname.Equals("toc.md", StringComparison.InvariantCultureIgnoreCase))) { FilesToRemove.Add(SourceFilePath.TrimStart('\\')); } return(false); }