/// <summary> /// <see cref="Field.ExportAsJsonSensorData"/> /// </summary> public override void ExportAsJsonSensorData(JsonWriter w) { w.BeginObject(); w.WriteName("fieldType"); w.WriteValue("duration"); this.ExportAsJsonSensorDataCommonAttributes(w); w.WriteName("days"); w.WriteValue(this.value.Days); w.WriteName("hours"); w.WriteValue(this.value.Hours); w.WriteName("minutes"); w.WriteValue(this.value.Minutes); w.WriteName("seconds"); w.WriteValue(this.value.Seconds); w.WriteName("milliseconds"); w.WriteValue(this.value.Milliseconds); w.EndObject(); }
/// <summary> /// Returns the JSON string representation of the current resources allocated /// over time /// </summary> /// <returns> /// the JSON string representation of the current resources allocated /// over time /// </returns> public virtual string ToMemJSONString() { StringWriter json = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(json); readLock.Lock(); try { jsonWriter.BeginObject(); // jsonWriter.name("timestamp").value("resource"); foreach (KeyValuePair <long, Org.Apache.Hadoop.Yarn.Api.Records.Resource> r in cumulativeCapacity) { jsonWriter.Name(r.Key.ToString()).Value(r.Value.ToString()); } jsonWriter.EndObject(); jsonWriter.Close(); return(json.ToString()); } catch (IOException) { // This should not happen return(string.Empty); } finally { readLock.Unlock(); } }
private static void WriteTerm(JsonWriter writer, Spec.Term term) { if (term.type == Term.TermType.DATUM) { WriteDatum(writer, term.datum); return; } writer.BeginArray(); writer.WriteNumber((int)term.type); if (term.args.Count > 0 || term.optargs.Count > 0) { writer.BeginArray(); foreach (var arg in term.args) { WriteTerm(writer, arg); } writer.EndArray(); writer.BeginObject(); foreach (var opt in term.optargs) { writer.WriteMember(opt.key); WriteTerm(writer, opt.val); } writer.EndObject(); } writer.EndArray(); }
/// <summary> /// <see cref="Field.ExportAsJsonSensorData"/> /// </summary> public override void ExportAsJsonSensorData(JsonWriter w) { w.BeginObject(); w.WriteName("fieldType"); w.WriteValue("dateTime"); this.ExportAsJsonSensorDataCommonAttributes(w); w.WriteName("year"); w.WriteValue(this.value.Year); w.WriteName("month"); w.WriteValue(this.value.Month); w.WriteName("day"); w.WriteValue(this.value.Day); w.WriteName("hour"); w.WriteValue(this.value.Hour); w.WriteName("minute"); w.WriteValue(this.value.Minute); w.WriteName("second"); w.WriteValue(this.value.Second); w.EndObject(); }
public static void NewConfigure() { try { CheckConfigureFile(); FileStream ConfigureStream = File.Open(FileName, FileMode.OpenOrCreate); JsonWriter jWriter = new JsonWriter(new Java.IO.OutputStreamWriter(ConfigureStream)); jWriter.BeginObject(); jWriter.Name("CSIWebServerName").Value(string.Empty); jWriter.Name("Theme").Value(string.Empty); jWriter.Name("Configuration").Value(string.Empty); jWriter.Name("EnableHTTPS").Value(false); jWriter.Name("UseRESTForRequest").Value(false); jWriter.Name("SaveUser").Value(false); jWriter.Name("SavePassword").Value(false); jWriter.Name("SavedUser").Value(string.Empty); jWriter.Name("SavedPassword").Value(string.Empty); jWriter.Name("LoadPicture").Value(false); jWriter.Name("RecordCap").Value(10); jWriter.Name("ConfigurationList"); jWriter.BeginArray(); jWriter.Value(string.Empty); jWriter.EndArray(); jWriter.EndObject(); jWriter.Close(); ConfigureStream.Close(); } catch (Exception Ex) { WriteErrorLog(Ex); } }
public static string BuildQtyMoveJson(string Item, string UM, string Qty, string Loc1, string Lot1, string Loc2, string Lot2) { string Output = ""; try { MemoryStream QtyMoveStream = new MemoryStream(); JsonWriter jWriter = new JsonWriter(new Java.IO.OutputStreamWriter(QtyMoveStream)); jWriter.BeginObject(); jWriter.Name("Item").Value(Item); jWriter.Name("UM").Value(UM); jWriter.Name("Qty").Value(Qty); jWriter.Name("Loc1").Value(Loc1); jWriter.Name("Lot1").Value(Loc1); jWriter.Name("Loc2").Value(Loc2); jWriter.Name("Lot2").Value(Lot2); jWriter.EndObject(); jWriter.Close(); // convert stream to string QtyMoveStream.Position = 0; StreamReader reader = new StreamReader(QtyMoveStream); Output = reader.ReadToEnd(); QtyMoveStream.Close(); }catch (Exception Ex) { WriteErrorLog(Ex); } return(Output); }
/// <summary> /// <see cref="Field.ExportAsJsonSensorData"/> /// </summary> public override void ExportAsJsonSensorData(JsonWriter w) { w.BeginObject(); w.WriteName("fieldType"); w.WriteValue("boolean"); this.ExportAsJsonSensorDataCommonAttributes(w); w.WriteName("value"); w.WriteValue(this.value); w.EndObject(); }
private static void WriteQuery(JsonWriter writer, Spec.Query query) { writer.BeginArray(); writer.WriteNumber((int)query.type); if (query.type == Spec.Query.QueryType.START) { WriteTerm(writer, query.query); writer.BeginObject(); foreach (var opt in query.global_optargs) { writer.WriteMember(opt.key); WriteTerm(writer, opt.val); } writer.EndObject(); } writer.EndArray(); }
void FilterList(WebData webData, ITable table, string nameField, string guidField, string text) { var ids = new Set <long>(); if (text == null) { ids.IncludeRange(table.FindRows(Search.None, ResultOption.Limit(20))); } else { ids.AddRange(table.FindRows(Search.FieldLike(nameField, MDBSearch.Text(text + "%")) & Search.FieldNotEquals(guidField, null), ResultOption.SortAscending(nameField) + ResultOption.Group(nameField) + ResultOption.Group(guidField) + ResultOption.Limit(20))); if (ids.Count < 20) { ids.IncludeRange(table.FindRows(Search.FieldLike(nameField, MDBSearch.Text("% " + text + "%")) & Search.FieldNotEquals(guidField, null), ResultOption.SortAscending(nameField) + ResultOption.Group(nameField) + ResultOption.Group(guidField) + ResultOption.Limit(20))); } if (ids.Count < 20) { ids.IncludeRange(table.FindRows(Search.FieldLike(nameField, MDBSearch.Text(text + "%")) & Search.FieldEquals(guidField, null), ResultOption.SortAscending(nameField) + ResultOption.Group(nameField) + ResultOption.Limit(20 - ids.Count))); } if (ids.Count < 20) { ids.IncludeRange(table.FindRows(Search.FieldLike(nameField, MDBSearch.Text("% " + text + "%")) & Search.FieldEquals(guidField, null), ResultOption.SortAscending(nameField) + ResultOption.Group(nameField) + ResultOption.Limit(20 - ids.Count))); } } var json = new JsonWriter(); json.BeginArray("results"); if (ids.Count > 0) { //get items var values = table.GetValues <string>(nameField, false, ids.SubRange(0, Math.Min(20, ids.Count))); foreach (var value in values) { json.BeginObject(); json.String("id", value); json.String("text", value); json.EndObject(); } } json.EndArray(); var message = WebMessage.Create(webData.Method, $"Filter {nameField} {text}"); webData.Answer = WebAnswer.Json(webData.Request, message, json.ToString()); }
/// <summary>Serialize the metadata to a set of bytes.</summary> /// <returns>the serialized bytes</returns> /// <exception cref="System.IO.IOException"/> protected internal virtual byte[] Serialize() { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); JsonWriter writer = new JsonWriter(new OutputStreamWriter(buffer, Charsets.Utf8)); try { writer.BeginObject(); if (cipher != null) { writer.Name(CipherField).Value(cipher); } if (bitLength != 0) { writer.Name(BitLengthField).Value(bitLength); } if (created != null) { writer.Name(CreatedField).Value(created.GetTime()); } if (description != null) { writer.Name(DescriptionField).Value(description); } if (attributes != null && attributes.Count > 0) { writer.Name(AttributesField).BeginObject(); foreach (KeyValuePair <string, string> attribute in attributes) { writer.Name(attribute.Key).Value(attribute.Value); } writer.EndObject(); } writer.Name(VersionsField).Value(versions); writer.EndObject(); writer.Flush(); } finally { writer.Close(); } return(buffer.ToByteArray()); }
private void WriteJsonStream(FileStream output) { JsonWriter jWriter = new JsonWriter(new OutputStreamWriter(output)); jWriter.BeginObject(); jWriter.Name("CSIWebServerName").Value(CSIWebServer); jWriter.Name("Configuration").Value(Configuration); jWriter.Name("EnableHTTPS").Value(EnableHTTPS); jWriter.Name("UseRESTForRequest").Value(UseRESTForRequest); jWriter.Name("SaveUser").Value(SaveUser); jWriter.Name("SavePassword").Value(SavePassword); jWriter.Name("User").Value(SaveUser ? User : ""); jWriter.Name("Password").Value(SaveUser && SavePassword ? Password : ""); jWriter.Name("LoadPicture").Value(LoadPicture); jWriter.Name("RecordCap").Value(RecordCap); jWriter.EndObject(); jWriter.Close(); output.Close(); }
public static void WriteConfigure(CSIContext c) { try { File.Delete(FileName); FileStream ConfigureStream = File.Open(FileName, FileMode.OpenOrCreate); JsonWriter jWriter = new JsonWriter(new Java.IO.OutputStreamWriter(ConfigureStream)); jWriter.BeginObject(); jWriter.Name("CSIWebServerName").Value(c.CSIWebServerName ?? string.Empty); jWriter.Name("Configuration").Value(c.Configuration ?? string.Empty); jWriter.Name("ConfigurationList"); jWriter.BeginArray(); foreach (string config in c.ConfigurationList) { jWriter.Value(config ?? string.Empty); } jWriter.EndArray(); jWriter.Name("Theme").Value(c.Theme); jWriter.Name("EnableHTTPS").Value(c.EnableHTTPS); jWriter.Name("UseRESTForRequest").Value(c.UseRESTForRequest); jWriter.Name("SaveUser").Value(c.SaveUser); jWriter.Name("SavePassword").Value(c.SavePassword); jWriter.Name("SavedUser").Value(c.SaveUser ? c.SavedUser : string.Empty); jWriter.Name("SavedPassword").Value(c.SaveUser && c.SavePassword ? c.SavedPassword : string.Empty); jWriter.Name("LoadPicture").Value(c.LoadPicture); jWriter.Name("RecordCap").Value(c.RecordCap ?? "10"); jWriter.Name("ForceAutoPost").Value(c.ForceAutoPost); jWriter.Name("ShowSuccessMessage").Value(c.ShowSuccessMessage); jWriter.Name("LicenseString").Value(c.LicenseString); jWriter.Name("ExpDate").Value(c.ExpDate); jWriter.EndObject(); jWriter.Close(); ConfigureStream.Close(); } catch (Exception Ex) { WriteErrorLog(Ex); } }
/// <summary> /// Exports common Field attributes, similar to XEP-0323 Sensor data, but using JSON. /// </summary> /// <param name="w">JSON Output</param> protected void ExportAsJsonSensorDataCommonAttributes (JsonWriter w) { w.WriteName ("name"); w.WriteValue (this.fieldName); if ((this.type & ReadoutType.MomentaryValues) != 0) { w.WriteName ("momentary"); w.WriteValue (true); } if ((this.type & ReadoutType.PeakValues) != 0) { w.WriteName ("peak"); w.WriteValue (true); } if ((this.type & ReadoutType.StatusValues) != 0) { w.WriteName ("status"); w.WriteValue (true); } if ((this.type & ReadoutType.Computed) != 0) { w.WriteName ("computed"); w.WriteValue (true); } if ((this.type & ReadoutType.Identity) != 0) { w.WriteName ("identity"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesSecond) != 0) { w.WriteName ("historicalSecond"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesMinute) != 0) { w.WriteName ("historicalMinute"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesHour) != 0) { w.WriteName ("historicalHour"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesDay) != 0) { w.WriteName ("historicalDay"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesWeek) != 0) { w.WriteName ("historicalWeek"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesMonth) != 0) { w.WriteName ("historicalMonth"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesQuarter) != 0) { w.WriteName ("historicalQuarter"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesYear) != 0) { w.WriteName ("historicalYear"); w.WriteValue (true); } if ((this.type & ReadoutType.HistoricalValuesOther) != 0) { w.WriteName ("historicalOther"); w.WriteValue (true); } if ((this.status & FieldStatus.Missing) != 0) { w.WriteName ("missing"); w.WriteValue (true); } if ((this.status & FieldStatus.AutomaticEstimate) != 0) { w.WriteName ("automaticEstimate"); w.WriteValue (true); } if ((this.status & FieldStatus.ManualEstimate) != 0) { w.WriteName ("manualEstimate"); w.WriteValue (true); } if ((this.status & FieldStatus.ManualReadout) != 0) { w.WriteName ("manualReadout"); w.WriteValue (true); } if ((this.status & FieldStatus.AutomaticReadout) != 0) { w.WriteName ("automaticReadout"); w.WriteValue (true); } if ((this.status & FieldStatus.TimeOffset) != 0) { w.WriteName ("timeOffset"); w.WriteValue (true); } if ((this.status & FieldStatus.Warning) != 0) { w.WriteName ("warning"); w.WriteValue (true); } if ((this.status & FieldStatus.Error) != 0) { w.WriteName ("error"); w.WriteValue (true); } if ((this.status & FieldStatus.Signed) != 0) { w.WriteName ("signed"); w.WriteValue (true); } if ((this.status & FieldStatus.Invoiced) != 0) { w.WriteName ("invoiced"); w.WriteValue (true); } if ((this.status & FieldStatus.EndOfSeries) != 0) { w.WriteName ("endOfSeries"); w.WriteValue (true); } if ((this.status & FieldStatus.PowerFailure) != 0) { w.WriteName ("powerFailure"); w.WriteValue (true); } if ((this.status & FieldStatus.InvoicedConfirmed) != 0) { w.WriteName ("invoiceConfirmed"); w.WriteValue (true); } if (this.stringIds != null && this.stringIds.Length > 0) { if (!string.IsNullOrEmpty (this.languageModule)) { w.WriteName ("module"); w.WriteValue (this.languageModule); } w.WriteName ("stringIds"); w.BeginArray (); foreach (FieldLanguageStep Step in this.stringIds) { w.BeginObject (); w.WriteName ("stringId"); w.WriteValue (Step.StringId); if (Step.Seed != null) { w.WriteName ("seed"); w.WriteValue (Step.Seed); } if (!string.IsNullOrEmpty (Step.LanguageModule)) { w.WriteName ("module"); w.WriteValue (Step.LanguageModule); } w.EndObject (); } w.EndArray (); } }
/// <summary> /// <see cref="Field.ExportAsJsonSensorData"/> /// </summary> public override void ExportAsJsonSensorData(JsonWriter w) { w.BeginObject (); w.WriteName ("fieldType"); w.WriteValue ("boolean"); this.ExportAsJsonSensorDataCommonAttributes(w); w.WriteName ("value"); w.WriteValue (this.value); w.WriteName ("datatype"); w.WriteValue (this.dataType); w.EndObject (); }
/// <inheritdoc /> public override void GenerateSolution(Solution solution) { // Setup directory for Visual Studio Code files var vsCodeFolder = Path.Combine(solution.WorkspaceRootPath, ".vscode"); if (!Directory.Exists(vsCodeFolder)) { Directory.CreateDirectory(vsCodeFolder); } // Prepare var buildToolWorkspace = Environment.CurrentDirectory; var buildToolPath = Utilities.MakePathRelativeTo(typeof(Builder).Assembly.Location, solution.WorkspaceRootPath); var rules = Builder.GenerateRulesAssembly(); // Create tasks file using (var json = new JsonWriter()) { json.BeginRootObject(); { json.AddField("version", "2.0.0"); json.BeginArray("tasks"); { foreach (var project in solution.Projects) { // C++ project if (project.Type == TargetType.NativeCpp) { bool defaultTask = project == solution.MainProject; foreach (var configuration in project.Configurations) { var target = configuration.Target; var name = project.Name + '|' + configuration.Name; json.BeginObject(); json.AddField("label", name); if (defaultTask && configuration.Configuration == TargetConfiguration.Development && configuration.Platform == Platform.BuildPlatform.Target) { defaultTask = false; json.BeginObject("group"); { json.AddField("kind", "build"); json.AddField("isDefault", true); } json.EndObject(); } else { json.AddField("group", "build"); } switch (Platform.BuildPlatform.Target) { case TargetPlatform.Windows: { json.AddField("command", buildToolPath); json.BeginArray("args"); { json.AddUnnamedField("-build"); json.AddUnnamedField("-log"); json.AddUnnamedField("-mutex"); json.AddUnnamedField(string.Format("\\\"-workspace={0}\\\"", buildToolWorkspace)); json.AddUnnamedField(string.Format("-arch={0}", configuration.ArchitectureName)); json.AddUnnamedField(string.Format("-configuration={0}", configuration.ConfigurationName)); json.AddUnnamedField(string.Format("-platform={0}", configuration.PlatformName)); json.AddUnnamedField(string.Format("-buildTargets={0}", target.Name)); if (!string.IsNullOrEmpty(Configuration.Compiler)) { json.AddUnnamedField(string.Format("-compiler={0}", Configuration.Compiler)); } } json.EndArray(); json.AddField("type", "shell"); json.BeginObject("options"); { json.AddField("cwd", buildToolWorkspace); } json.EndObject(); break; } case TargetPlatform.Linux: { json.AddField("command", Path.Combine(Globals.EngineRoot, "Source/Platforms/Editor/Linux/Mono/bin/mono")); json.BeginArray("args"); { json.AddUnnamedField(buildToolPath); json.AddUnnamedField("--build"); json.AddUnnamedField("--log"); json.AddUnnamedField("--mutex"); json.AddUnnamedField(string.Format("--workspace=\\\"{0}\\\"", buildToolWorkspace)); json.AddUnnamedField(string.Format("--arch={0}", configuration.Architecture)); json.AddUnnamedField(string.Format("--configuration={0}", configuration.ConfigurationName)); json.AddUnnamedField(string.Format("--platform={0}", configuration.PlatformName)); json.AddUnnamedField(string.Format("--buildTargets={0}", target.Name)); if (!string.IsNullOrEmpty(Configuration.Compiler)) { json.AddUnnamedField(string.Format("--compiler={0}", Configuration.Compiler)); } } json.EndArray(); json.AddField("type", "shell"); json.BeginObject("options"); { json.AddField("cwd", buildToolWorkspace); } json.EndObject(); break; } default: throw new Exception("Visual Code project generator does not support current platform."); } json.EndObject(); } } } } json.EndArray(); } json.EndRootObject(); json.Save(Path.Combine(vsCodeFolder, "tasks.json")); } // Create launch file using (var json = new JsonWriter()) { json.BeginRootObject(); { json.AddField("version", "0.2.0"); json.BeginArray("configurations"); { foreach (var project in solution.Projects) { // C++ project if (project.Type == TargetType.NativeCpp) { foreach (var configuration in project.Configurations) { var name = project.Name + '|' + configuration.Name; var target = configuration.Target; var outputType = project.OutputType ?? target.OutputType; var outputTargetFilePath = target.GetOutputFilePath(configuration.TargetBuildOptions, project.OutputType); json.BeginObject(); { if (configuration.Platform == TargetPlatform.Windows) { json.AddField("type", "cppvsdbg"); } else { json.AddField("type", "cppdbg"); } json.AddField("name", name); json.AddField("request", "launch"); json.AddField("preLaunchTask", name); json.AddField("cwd", buildToolWorkspace); switch (Platform.BuildPlatform.Target) { case TargetPlatform.Windows: if (configuration.Platform == TargetPlatform.Windows && outputType != TargetOutputType.Executable && configuration.Name.StartsWith("Editor.")) { var editorFolder = configuration.Architecture == TargetArchitecture.x64 ? "Win64" : "Win32"; json.AddField("program", Path.Combine(Globals.EngineRoot, "Binaries", "Editor", editorFolder, configuration.ConfigurationName, "FlaxEditor.exe")); json.BeginArray("args"); { json.AddUnnamedField("-project"); json.AddUnnamedField(buildToolWorkspace); json.AddUnnamedField("-skipCompile"); json.AddUnnamedField("-debug"); json.AddUnnamedField("127.0.0.1:55555"); } json.EndArray(); } else { json.AddField("program", outputTargetFilePath); } break; case TargetPlatform.Linux: if (configuration.Platform == TargetPlatform.Linux && (outputType != TargetOutputType.Executable || project.Name == "Flax") && configuration.Name.StartsWith("Editor.")) { json.AddField("program", Path.Combine(Globals.EngineRoot, "Binaries", "Editor", "Linux", configuration.ConfigurationName, "FlaxEditor")); } else { json.AddField("program", outputTargetFilePath); } if (configuration.Platform == TargetPlatform.Linux) { json.AddField("MIMode", "gdb"); json.BeginArray("setupCommands"); { json.BeginObject(); json.AddField("description", "Enable pretty-printing for gdb"); json.AddField("text", "-enable-pretty-printing"); json.AddField("ignoreFailures", true); json.EndObject(); // Ignore signals used by Mono json.BeginObject(); json.AddField("description", "ignore SIG35 signal"); json.AddField("text", "handle SIG35 nostop noprint pass"); json.EndObject(); json.BeginObject(); json.AddField("description", "ignore SIG36 signal"); json.AddField("text", "handle SIG36 nostop noprint pass"); json.EndObject(); json.BeginObject(); json.AddField("description", "ignore SIG357 signal"); json.AddField("text", "handle SIG37 nostop noprint pass"); json.EndObject(); } json.EndArray(); json.BeginArray("args"); { json.AddUnnamedField("--std"); if (outputType != TargetOutputType.Executable && configuration.Name.StartsWith("Editor.")) { json.AddUnnamedField("--project"); json.AddUnnamedField(buildToolWorkspace); json.AddUnnamedField("--skipCompile"); } } json.EndArray(); } break; } switch (configuration.Platform) { case TargetPlatform.Windows: json.AddField("stopAtEntry", false); json.AddField("externalConsole", true); break; case TargetPlatform.Linux: break; } json.AddField("visualizerFile", Path.Combine(Globals.EngineRoot, "Source", "flax.natvis")); } json.EndObject(); } } // C# project else if (project.Type == TargetType.DotNet) { foreach (var configuration in project.Configurations) { json.BeginObject(); { json.AddField("type", "mono"); json.AddField("name", project.Name + " (C# attach)" + '|' + configuration.Name); json.AddField("request", "attach"); json.AddField("address", "localhost"); json.AddField("port", 55555); } json.EndObject(); } } } } json.EndArray(); } json.EndRootObject(); json.Save(Path.Combine(vsCodeFolder, "launch.json")); } // Create C++ properties file using (var json = new JsonWriter()) { json.BeginRootObject(); json.BeginArray("configurations"); json.BeginObject(); var project = solution.MainProject ?? solution.Projects.FirstOrDefault(x => x.Name == Globals.Project.Name); if (project != null) { json.AddField("name", project.Name); var targetPlatform = Platform.BuildPlatform.Target; var configuration = TargetConfiguration.Development; var architecture = TargetArchitecture.x64; var includePaths = new HashSet <string>(); var preprocessorDefinitions = new HashSet <string>(); foreach (var e in project.Defines) { preprocessorDefinitions.Add(e); } foreach (var target in project.Targets) { var platform = Platform.GetPlatform(targetPlatform); if (platform.HasRequiredSDKsInstalled && target.Platforms.Contains(targetPlatform)) { var toolchain = platform.GetToolchain(architecture); var targetBuildOptions = Builder.GetBuildOptions(target, platform, toolchain, architecture, configuration, Globals.Root); var modules = Builder.CollectModules(rules, platform, target, targetBuildOptions, toolchain, architecture, configuration); foreach (var module in modules) { // This merges private module build options into global target - not the best option but helps with syntax highlighting and references collecting module.Key.Setup(targetBuildOptions); module.Key.SetupEnvironment(targetBuildOptions); } foreach (var e in targetBuildOptions.CompileEnv.PreprocessorDefinitions) { preprocessorDefinitions.Add(e); } foreach (var e in targetBuildOptions.CompileEnv.IncludePaths) { includePaths.Add(e); } } } json.BeginArray("includePath"); { foreach (var path in includePaths) { json.AddUnnamedField(path.Replace('\\', '/')); } } json.EndArray(); if (targetPlatform == TargetPlatform.Windows) { json.AddField("intelliSenseMode", "msvc-x64"); } else { json.AddField("intelliSenseMode", "clang-x64"); } json.BeginArray("defines"); { foreach (string definition in preprocessorDefinitions) { json.AddUnnamedField(definition); } } json.EndArray(); } json.EndObject(); json.EndArray(); json.EndRootObject(); json.Save(Path.Combine(vsCodeFolder, "c_cpp_properties.json")); } // Create settings file using (var json = new JsonWriter()) { json.BeginRootObject(); // File and folders excludes json.BeginObject("files.exclude"); json.AddField("**/.git", true); json.AddField("**/.svn", true); json.AddField("**/.hg", true); json.AddField("**/.vs", true); json.AddField("**/Binaries", true); json.AddField("**/Cache", true); json.AddField("**/packages", true); json.AddField("**/Logs", true); json.AddField("**/Screenshots", true); json.AddField("**/Output", true); json.AddField("**/*.flax", true); json.EndObject(); json.EndRootObject(); json.Save(Path.Combine(vsCodeFolder, "settings.json")); } // Create workspace file using (var json = new JsonWriter()) { json.BeginRootObject(); // Settings json.BeginObject("settings"); json.AddField("typescript.tsc.autoDetect", "off"); json.AddField("npm.autoDetect", "off"); json.AddField("gulp.autoDetect", "off"); json.AddField("jake.autoDetect", "off"); json.AddField("grunt.autoDetect", "off"); json.AddField("omnisharp.defaultLaunchSolution", solution.Name + ".sln"); json.EndObject(); // Folders json.BeginArray("folders"); { // This project json.BeginObject(); json.AddField("name", solution.Name); json.AddField("path", "."); json.EndObject(); // Referenced projects outside the current project (including engine too) foreach (var project in Globals.Project.GetAllProjects()) { if (!project.ProjectFolderPath.Contains(Globals.Project.ProjectFolderPath)) { json.BeginObject(); { json.AddField("name", project.Name); json.AddField("path", project.ProjectFolderPath); } json.EndObject(); } } } json.EndArray(); json.EndRootObject(); json.Save(Path.Combine(solution.WorkspaceRootPath, solution.Name + ".code-workspace")); } // Create extensions recommendations file using (var json = new JsonWriter()) { json.BeginRootObject(); json.BeginArray("recommendations"); { json.AddUnnamedField("ms-dotnettools.csharp"); json.AddUnnamedField("ms-vscode.mono-debug"); if (!Globals.Project.IsCSharpOnlyProject) { json.AddUnnamedField("ms-vscode.cpptools"); } } json.EndArray(); json.EndRootObject(); json.Save(Path.Combine(vsCodeFolder, "extensions.json")); } }
public void WriteJson(JsonWriter output, string key) { using (output.BeginObject(key)) { output.WriteValue("x", X); output.WriteValue("y", Y); output.WriteValue("w", Width); output.WriteValue("h", Height); if (paddingLeft != 0) { output.WriteValue("l", paddingLeft); } if (paddingRight != 0) { output.WriteValue("r", paddingRight); } if (paddingTop != 0) { output.WriteValue("t", paddingTop); } if (paddingBottom != 0) { output.WriteValue("b", paddingBottom); } } }
public override string BuildJson(int indicator = 0) { /* { * "Action":1/2/4, * "ItemId":"PBT=[Usernames]", "ItemId": "PBT=[MCBCustomers] mcb.ID=[70c0b27f-8151-4f3a-8fcf-a8a8381823b4] mcb.DT=[2015-01-07 13:13:04.660]", * "Properties": * [ * {"IsNull":false,"Modified":true/false,"Name":"Username","Value":"newuser54"}, * {"IsNull":false,"Modified":true/false,"Name":"EditLevel","Value":"2"}, * {"IsNull":false,"Modified":true/false,"Name":"UserDesc","Value":"user description"}, * {"IsNull":false,"Modified":true/false,"Name":"SuperUserFlag","Value":"1"} * ] * } */ string output = ""; StringWriter writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); if (string.IsNullOrEmpty(iResult.IDOName)) { return(""); } jsonWriter.BeginObject(); jsonWriter.Name("Action").Value(indicator); switch (indicator) { case 1: jsonWriter.Name("ItemId").Value(string.Format("PBT=[{0}]", iResult.IDOName)); break; case 2: case 4: string.Format("PBT=[{0}] {0}.DT=[{1}] {0}.ID=[{2}]", iResult.IDOName, "", ""); break; default: break; } jsonWriter.Name("Properties"); jsonWriter.BeginArray(); foreach (BaseIDOObject obj in iResult.Objects) { if (((indicator == 1) && (!obj.Inserted)) || ((indicator == 2) && (obj.Inserted || obj.Deleted)) || ((indicator == 4) && (!obj.Deleted))) { continue; } foreach (BaseIDOObjectItem objitem in obj.ObjectItems) { jsonWriter.BeginObject(); jsonWriter.Name("IsNull").Value((string.IsNullOrEmpty(objitem.ItemValue) ? true : false)); jsonWriter.Name("Modified").Value(objitem.Updated); jsonWriter.Name("Name").Value(objitem.ItemName); jsonWriter.Name("Value").Value(objitem.ItemValue); jsonWriter.EndObject(); } } jsonWriter.EndObject(); jsonWriter.EndArray(); jsonWriter.EndObject(); jsonWriter.Flush(); jsonWriter.Close(); output = writer.ToString(); return(output); }
public override string BuildJson(int indicator = 0) { /* { * "IDOName": "UserNames", * "Items": [{ * "EditStatus": 0, * "ID": "PBT=[UserNames] UserNames.DT=[20171223 20:19:13.103] UserNames.ID=[4c0a3eb1-5492-4785-bb2b-db0522a92a6e]", * "Properties": [{ * "Property": "2", * "Updated": false * }, { * "Property": "sa", * "Updated": false * }, { * "Property": "", * "Updated": false * } * ] * } * ], * "PropertyList": ["UserId", "Username", "UserDesc"] * } */ string output = ""; StringWriter writer = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(writer); if (string.IsNullOrEmpty(iResult.IDOName)) { return(""); } jsonWriter.BeginObject(); jsonWriter.Name("IDOName").Value(iResult.IDOName); jsonWriter.Name("Items"); jsonWriter.BeginArray(); foreach (BaseIDOObject obj in iResult.Objects) { jsonWriter.BeginObject(); if (obj.Inserted) { jsonWriter.Name("EditStatus").Value(1); } else if (obj.Updated) { jsonWriter.Name("EditStatus").Value(2); } else if (obj.Deleted) { jsonWriter.Name("EditStatus").Value(4); } else { jsonWriter.Name("EditStatus").Value(0); } jsonWriter.Name("ID").Value(string.Format("PBT=[{0}] {0}.DT=[{1}] {0}.ID=[{2}]", iResult.IDOName, "", "")); jsonWriter.Name("Properties"); jsonWriter.BeginArray(); foreach (BaseIDOObjectItem objitem in obj.ObjectItems) { jsonWriter.BeginObject(); jsonWriter.Name("Property").Value(objitem.ItemValue); jsonWriter.Name("Updated").Value(objitem.Updated); jsonWriter.EndObject(); } jsonWriter.EndArray(); jsonWriter.EndObject(); } jsonWriter.EndArray(); jsonWriter.Name("PropertyList"); jsonWriter.BeginArray(); foreach (string propertyName in iResult.ObjectNames) { jsonWriter.Value(propertyName); } jsonWriter.EndArray(); jsonWriter.EndObject(); jsonWriter.Flush(); jsonWriter.Close(); output = writer.ToString(); return(output); }
/// <summary> /// <see cref="Field.ExportAsJsonSensorData"/> /// </summary> public override void ExportAsJsonSensorData(JsonWriter w) { w.BeginObject (); w.WriteName ("fieldType"); w.WriteValue ("duration"); this.ExportAsJsonSensorDataCommonAttributes(w); w.WriteName ("days"); w.WriteValue (this.value.Days); w.WriteName ("hours"); w.WriteValue (this.value.Hours); w.WriteName ("minutes"); w.WriteValue (this.value.Minutes); w.WriteName ("seconds"); w.WriteValue (this.value.Seconds); w.WriteName ("milliseconds"); w.WriteValue (this.value.Milliseconds); w.EndObject (); }
/// <summary> /// <see cref="Field.ExportAsJsonSensorData"/> /// </summary> public override void ExportAsJsonSensorData(JsonWriter w) { w.BeginObject (); w.WriteName ("fieldType"); w.WriteValue ("dateTime"); this.ExportAsJsonSensorDataCommonAttributes(w); w.WriteName ("year"); w.WriteValue (this.value.Year); w.WriteName ("month"); w.WriteValue (this.value.Month); w.WriteName ("day"); w.WriteValue (this.value.Day); w.WriteName ("hour"); w.WriteValue (this.value.Hour); w.WriteName ("minute"); w.WriteValue (this.value.Minute); w.WriteName ("second"); w.WriteValue (this.value.Second); w.EndObject (); }
/// <summary> /// Starts the export of sensor data values for a particular point in time. This call must be followed by a call to <see cref="EndExportTimestamp"/>. /// Use <see cref="ExportField"/> to export field information to the Sensor Data JSON document. /// </summary> /// <param name="Json">JSON Output</param> /// <param name="Timestamp">Timestamp</param> public static void StartExportTimestamp (JsonWriter Json, DateTime Timestamp) { Timestamp = Timestamp.ToUniversalTime (); Json.BeginObject (); Json.WriteName ("timestampUtc"); Json.BeginObject (); Json.WriteName ("year"); Json.WriteValue (Timestamp.Year); Json.WriteName ("month"); Json.WriteValue (Timestamp.Month); Json.WriteName ("day"); Json.WriteValue (Timestamp.Day); Json.WriteName ("hour"); Json.WriteValue (Timestamp.Hour); Json.WriteName ("minute"); Json.WriteValue (Timestamp.Minute); Json.WriteName ("second"); Json.WriteValue (Timestamp.Second); Json.EndObject (); Json.WriteName ("fields"); Json.BeginArray (); }
/// <summary> /// Starts the export of sensor data values for a particular node. This call must be followed by a call to <see cref="EndExportNode"/>. /// Use <see cref="StartExportTimestamp"/> to export node information pertaining to a given point in time to the Sensor Data JSON document. /// </summary> /// <param name="Json">JSON Output</param> /// <param name="NodeId">Node ID.</param> /// <param name="CacheType">Cache Type</param> /// <param name="SourceId">Source ID.</param> public static void StartExportNode (JsonWriter Json, string NodeId, string CacheType, string SourceId) { Json.BeginObject (); Json.WriteName ("nodeId"); Json.WriteValue (NodeId); if (!string.IsNullOrEmpty (CacheType)) { Json.WriteName ("cacheType"); Json.WriteValue (CacheType); } if (!string.IsNullOrEmpty (SourceId)) { Json.WriteName ("sourceId"); Json.WriteValue (SourceId); } Json.WriteName ("timestamps"); Json.BeginArray (); }
/// <summary> /// <see cref="Field.ExportAsJsonSensorData"/> /// </summary> public override void ExportAsJsonSensorData(JsonWriter w) { w.BeginObject (); w.WriteName ("fieldType"); w.WriteValue ("numeric"); this.ExportAsJsonSensorDataCommonAttributes(w); w.WriteName ("value"); w.WriteValue (this.value); w.WriteName ("unit"); w.WriteValue (this.unit); w.WriteName ("nrDec"); w.WriteValue (this.nrDecimals); w.EndObject (); }