private Constructor CreateConstructor(Envoy typeDiagramEnvoy) { var constructor = Constructor.CreateConstructor(new ElementCreateInfo(Host)); constructor.TypeName = typeDiagramEnvoy.MakeRelativeDependencyName(); return(constructor); }
internal void Create(EMap m) { // Name ve Root bilgileri Before üzerinden yükleniyor. // Güncelleme bu bilgiler Instruction kısmı için düzenleniyor. // Kullandığımız entity'in Name ve Root bilgileri alınmalı. DEntity d = new DEntity(); Envoy e = new Envoy(); d.TargetLocation = m.ExternalLocation; d = e.Before(new EMap(), d); e.CreateIfNotThere(d); UpdateList(d.TargetLocation); if (!IsThereAny(m.Entity)) { if (l.Count > 0) { m.Id = l[l.Count - 1].Id + 1; } else { m.Id = 1; } DataAccess.Insert insert = new DataAccess.Insert (m, d); } }
protected override void OnStart(string[] args) { //if (!EventLog.SourceExists(this.ServiceName)) //{ // EventSourceCreationData source = new EventSourceCreationData(this.ServiceName, "Application"); // EventLog.CreateEventSource(source); //} //EventLog log = new EventLog("Application"); //log.WriteEntry(this.ServiceName + " starting."); try { Trace.TraceInformation("Starting " + this.ServiceName); Trace.TraceInformation(Properties.Settings.Default.EnvoyHostname); Trace.TraceInformation(Properties.Settings.Default.EnvoyUsername); Trace.TraceInformation(Properties.Settings.Default.EnvoyPassword); Trace.TraceInformation(Properties.Settings.Default.ConnectString); envoy = new Envoy(Properties.Settings.Default.EnvoyHostname, Properties.Settings.Default.EnvoyUsername, Properties.Settings.Default.EnvoyPassword, Properties.Settings.Default.ConnectString); Trace.TraceInformation("new envoy done"); timer = new Timer(onTimer, null, 0, Properties.Settings.Default.PollPeriod * 1000); Trace.TraceInformation("Going " + this.ServiceName); } catch (Exception e) { Trace.TraceError("Exception: " + e.ToString()); } }
private static async Task <DfirRoot> GenerateDfirAsync( ICompositionHost host, Envoy documentEnvoy, ProgressToken progressToken, CompileCancellationToken compileCancellationToken) { ExtendedQualifiedName topLevelDocumentName = documentEnvoy.CreateExtendedQualifiedName(); TargetCompiler targetCompiler = documentEnvoy.QueryInheritedService <ITargetCompilerServices>().First().Compiler; AnyMocCompiler compiler = host.GetSharedExportedValue <AnyMocCompiler>(); IReadOnlySymbolTable symbolTable = documentEnvoy.ComputeSymbolTable(); // A specAndQName is used by the compiler to identify the document for which we're asking for DFIR. var specAndQName = new SpecAndQName(targetCompiler.CreateDefaultBuildSpec(topLevelDocumentName, symbolTable), topLevelDocumentName); try { DfirRoot sourceDfirRoot = await compiler.GetTargetDfirAsync(specAndQName, compileCancellationToken, progressToken); if (sourceDfirRoot == null) { await ShowErrorMessageBoxAsync(host, WaitForCompileErrorMessageBoxText); } return(sourceDfirRoot); } catch { await ShowErrorMessageBoxAsync(host, DfirGenerationErrorMessageBoxText); return(null); } }
async Task IDependencyTargetExportChanged.OnExportsChangedAsync(Envoy envoy, ExportsChangedData data) { NIType type = await envoy.GetTypeDiagramSignatureAsync(); if (ShouldUpdateDataTypeFromChange(data)) { UpdateStructType(type); } }
/// <summary> /// Base constructor of <see cref="ApplicationComponentMocReflector"/> /// </summary> /// <param name="source">An interface allowing the reflector to talk to the source model</param> /// <param name="reflectionCancellationToken">A token to poll for whether to do reflection or not</param> /// <param name="scheduledActivityManager">The activity used to flip over into the UI thread as needed to do reflections</param> /// <param name="additionalErrorTexts">Supplies third-party message descriptions for this MoC</param> /// <param name="buildSpecSource">Source of the BuildSpec for which to reflect messages</param> /// <param name="compileSpecification">The <see cref="CompileSpecification"/> for which to reflect messages</param> internal ApplicationComponentMocReflector( IReflectableModel source, ReflectionCancellationToken reflectionCancellationToken, IScheduledActivityManager scheduledActivityManager, IMessageDescriptorTranslator additionalErrorTexts, Envoy buildSpecSource, CompileSpecification compileSpecification) : base(source, reflectionCancellationToken, scheduledActivityManager, additionalErrorTexts, buildSpecSource, compileSpecification) { }
protected override void OnStop() { Trace.TraceInformation("Stopping " + this.ServiceName); //EventLog log = new EventLog("Application"); //log.WriteEntry(this.ServiceName + " stopping."); timer.Change(Timeout.Infinite, Timeout.Infinite); timer.Dispose(); timer = null; envoy = null; }
private void UpdateList(string ExternalLocation) { l.Clear(); DEntity d = new DEntity(); Envoy e = new Envoy(); d.TargetLocation = ExternalLocation; d = e.Before(new EMap(), d); l = e.DataToList <EMap>(d); }
public Form1() { InitializeComponent(); re = new Envoy("10.0.0.201", "envoy", "056704", @"Persist Security Info=False;Integrated Security=SSPI; database = Electricity; server = Server\SqlExpress"); re.ReadInverters(); t = new Timer(); t.Interval = 5 * 60 * 1000; // 5 minutes t.Tick += T_Tick; t.Start(); }
public FunctionMocReflector( IReflectableModel source, ReflectionCancellationToken reflectionCancellationToken, IScheduledActivityManager scheduledActivityManager, IMessageDescriptorTranslator additionalErrorTexts, Envoy buildSpecSource, SpecAndQName specAndQName, DfirModelMap map) : base(source, reflectionCancellationToken, scheduledActivityManager, additionalErrorTexts, buildSpecSource, specAndQName) { _map = map; }
public static async Task <NIType> GetTypeDiagramSignatureAsync(this Envoy typeDiagramEnvoy) { IProvideDataType typeDiagramCacheService = typeDiagramEnvoy.GetBasicCacheServices() .OfType <IProvideDataType>() .FirstOrDefault(); if (typeDiagramCacheService != null) { return(await typeDiagramCacheService.GetDataTypeAsync()); } return(NIType.Unset); }
private async Task <bool> IsComponentForDisplayAsync(Envoy envoy) { if ((envoy.ModelDefinitionType == ComponentDefinition.ModelDefinitionTypeKeyword || envoy.BindingKeywords.Contains(ComponentDefinition.ModelDefinitionTypeKeyword)) && envoy.OverridingModelDefinitionType != ComponentDefinition.ReferencedModelDefinitionTypeKeyword) { using (await envoy.LoadAsync()) { IComponentSubtype subtype = envoy.GetOwningComponentConfigurationReference().Configuration.ComponentSubtype; return(CanBuildSubtype(subtype)); } } return(false); }
private static async Task <bool> TrySaveEnvoyAsync(Envoy envoy) { try { await envoy.SaveAsync(); return(true); } catch (Exception e) when(ExceptionHelper.ShouldExceptionBeCaught(e)) { CommandLineInterfaceApplication.WriteError(DocumentExtensions.GetUserVisibleSaveFailureMessage(envoy.FileName(), e)); return(false); } }
public override MocReflector CreateMocReflector( ICompilableModel source, ReflectionCancellationToken reflectionCancellationToken, Envoy buildSpecSource, CompileSpecification compileSpecification) { return(new ApplicationComponentMocReflector( source, reflectionCancellationToken, ScheduledActivityManager, AdditionalErrorTexts, buildSpecSource, compileSpecification)); }
public List <TEntity> GetAll() { if (WorkOnTheMap == true) { BringInstruction(); } if (CategoryMapOption == true) { ca.UpdateList(ExternalLocation); DEntity d = new DEntity(); Envoy envoy = new Envoy(); d.Name = SetName; d.Root = SetRoot; d.TargetLocation = ExternalLocation; TEntity t = new TEntity(); List <TEntity> allList = new List <TEntity>(); if (ca.s.Count > 0) { foreach (var item in ca.s) { d.CategorizeName = item.Name; d = envoy.Before(t, d); foreach (var item2 in envoy.DataToList <TEntity>(d)) { allList.Add(item2); } } } else // Tekil dosyalar için önemli { d = envoy.Before(t, d); foreach (var item2 in envoy.DataToList <TEntity>(d)) { allList.Add(item2); } } return(allList); } else { return(null); } }
/// <inheritdoc /> public Task OnExportsChangedAsync(Envoy envoy, ExportsChangedData data) { // This is called when something about the "exported" attributes of the item we are linked to changes. if (!(Rooted && envoy.Rooted)) { return(AsyncHelpers.CompletedTask); } this.TransactUpdateFromDependency(envoy, data, "Update From Dependency", () => { if (!(Rooted && envoy.Rooted)) { return; } IMethodCallTarget target = envoy?.QueryService <IMethodCallTarget>().FirstOrDefault(); if (target != null) { var name = target.Name; var icon = target.GetIcon(ViewElementTemplate.Icon); bool envoyChanged = data.Reason == ExportsChangeReason.Resolve || data.Reason == ExportsChangeReason.Unresolve; bool propertyChanged = data.Reason == ExportsChangeReason.PropertyChange; if (envoyChanged || (propertyChanged && data.ChangedProperties.Any(n => n == "Icon"))) { // Notify that the icon changed TransactionRecruiter.EnlistPropertyChanged(this, "Icon"); } if (envoyChanged || (propertyChanged && data.ChangedProperties.Any(n => n == "CacheSignature"))) { TransactionRecruiter.EnlistPropertyChanged(this, "Signature"); // You can look at the signature to gather connector pane information var signature = target.Signature; var allParameters = signature.GetParameters(); foreach (var parameter in allParameters) { var terminalName = parameter.GetAttributeValue("NI.UserDefinedName").Value ?? "Unknown"; var index = parameter.GetName(); var usage = parameter.GetParameterTerminalUsage(); var input = parameter.GetInputParameterPassingRule() != NIParameterPassingRule.NotAllowed; var output = parameter.GetOutputParameterPassingRule() != NIParameterPassingRule.NotAllowed; Log.WriteLine($"Parameter: {terminalName}, Type: {parameter.GetDataType()}"); } } } }); return(AsyncHelpers.CompletedTask); }
protected override void ModifyNewDocument(Envoy envoy) { var diagramDefinition = envoy.ReferenceDefinition as ExampleDiagramDefinition; if (diagramDefinition != null) { using (var transaction = diagramDefinition.TransactionManager.BeginTransaction("Drop Some Nodes", TransactionPurpose.NonUser)) { for (int i = 0; i < 4; i++) { var node = GrowableNode.Create(new ElementCreateInfo()); node.Bounds = new SMRect(i * 75 + 100, i * 75 + 100, 50, 50); diagramDefinition.RootDiagram.AddNode(node); } transaction.Commit(); } } }
public async Task OnExportsChangedAsync(Envoy envoy, ExportsChangedData data) { if (ShouldUpdateDataTypeFromChange(data)) { NIType oldType = Type; NIType type = await envoy.GetTypeDiagramSignatureAsync(); if (type.IsUnset() || type == oldType) { return; } this.TransactUpdateFromDependency(envoy, data, TransactionManager, "Set variant type", () => { Type = type; TransactionRecruiter.EnlistPropertyItem(this, nameof(Type), oldType, type, (t, __) => { Type = t; }, TransactionHints.Semantic); UpdateCasesFromDataType(type); }); } }
private async Task <Envoy> ResolveComponentOnTargetAsync(string componentName, ITargetScopeService targetScope) { ITargetScopeService targetbuildBuildSpecScope = targetScope.GetDefaultBuildSpecScope(); IEnumerable <Envoy> matchingComponents = await targetbuildBuildSpecScope.TargetScope.ResolveAsync(new QualifiedName(componentName)); if (matchingComponents.HasMoreThan(1)) { throw new CommandLineOperationException("Multiple components matching the provided name were found. This likely indicates a corrupt project file."); } Envoy componentEnvoy = matchingComponents.SingleOrDefault(); if (componentEnvoy == null) { CommandLineInterfaceApplication.WriteError(await CreateResolveComponentErrorMessageAsync(componentName, targetScope.GetScopeDisplayName(), targetScope)); } return(componentEnvoy); }
private async Task <bool> LoadAndBuildComponentEnvoyAsync(Envoy componentEnvoy) { CommandLineInterfaceApplication.WriteLineVerbose($"Resolved to {componentEnvoy.Name.Last}"); ILockedSourceFile componentFileLock; try { componentFileLock = await componentEnvoy.LoadAsync(); } catch (Exception e) when(ExceptionHelper.ShouldExceptionBeCaught(e)) { string loadErrorMessage = DocumentExtensions.GetLoadErrorMessageForException(e, componentEnvoy.FileName()); throw new CommandLineOperationException(loadErrorMessage, e); } using (componentFileLock) { CommandLineInterfaceApplication.WriteLineVerbose($"Loaded {componentEnvoy.Name.Last}"); var configurationReference = componentEnvoy.GetOwningComponentConfigurationReference(); if (ShowErrorIfSubTypeNotSupported(configurationReference)) { return(false); } bool buildSucceeded = await BuildComponentAsync(configurationReference); bool saveFailed = Save && !await TrySaveProjectFilesAsync(componentEnvoy.Project); if (!buildSucceeded || saveFailed) { CommandLineInterfaceApplication.WriteError( string.Format( CultureInfo.CurrentCulture, LocalizedStrings.BuildComponentTool_BuildFailed, componentEnvoy.Name.Last)); return(false); } WriteSuccessMessage(componentEnvoy.Name.Last, configurationReference.Configuration.GetOutputDirectory()); return(true); } }
public async Task OnExportsChangedAsync(Envoy envoy, ExportsChangedData data) { if (ShouldUpdateDataTypeFromChange(data)) { NIType oldType = Type; NIType type = await envoy.GetTypeDiagramSignatureAsync(); if (type.IsUnset() || type == oldType) { return; } using (var transaction = TransactionManager.BeginTransactionIfNecessary("Set type", TransactionPurpose.NonUser)) { Type = type; TransactionRecruiter.EnlistPropertyItem(this, nameof(Type), oldType, type, (t, __) => { Type = t; }, TransactionHints.Semantic); UpdateTerminalsFromDataType(type); transaction?.Commit(); } } }
public List <TEntity> GetCategorized(string categorizedName) { if (WorkOnTheMap == true) { BringInstruction(); } DEntity d = new DEntity(); Envoy envoy = new Envoy(); d.Name = SetName; d.Root = SetRoot; d.CategorizeName = categorizedName; d.TargetLocation = ExternalLocation; TEntity t = new TEntity(); d = envoy.Before(t, d); return(envoy.DataToList <TEntity>(d)); }
/// <summary> /// Command handler which adds a new VI to the project (under the default target) /// </summary> public static void OnAddNewVI(ICommandParameter parameter, ICompositionHost host, DocumentEditSite site) { var project = host.GetSharedExportedValue <IDocumentManager>().ActiveProject; var createInfo = EnvoyCreateInfo.CreateForNew(VirtualInstrument.VIModelDefinitionType, new QualifiedName("New VI.gvi")); Envoy createdItem = null; ILockedSourceFile createdFile = null; // Always perform modifications from within a transaction // Here we are creating a user transaction which means it is undoable using (var transaction = project.TransactionManager.BeginTransaction("Add A VI", TransactionPurpose.User)) { createdFile = project.CreateNewFile(null, createInfo); createdItem = createdFile?.Envoy; transaction.Commit(); } // edit the newly created VI createdItem?.Edit(); // After editing dispose our lock in the file createdFile?.Dispose(); }
public void Delete(TEntity e) { if (WorkOnTheMap == true) { BringInstruction(); } DEntity d = new DEntity(); Envoy envoy = new Envoy(); if (!(_categoryProperty is null)) { d.CategorizeName = CategoryProperty; } d.Name = SetName; d.Root = SetRoot; d.TargetLocation = ExternalLocation; d = envoy.Before(e, d); envoy.DataDelete(e, d); }
/// <inheritdoc /> protected override async Task <int> RunAsync(IEnumerable <string> extraArguments, ProjectAndHostCreator projectAndHostCreator) { if (!LongPath.IsPathRooted(ProjectPath)) { ProjectPath = LongPath.GetFullPath(LongPath.Combine(Environment.CurrentDirectory, ProjectPath)); } Project project = await projectAndHostCreator.OpenProjectAsync(ProjectPath); CommandLineInterfaceApplication.WriteLineVerbose($"Opened project at {ProjectPath}"); Envoy componentEnvoy = await ResolveComponentToBuildAsync(project); if (componentEnvoy == null) { return(1); } bool buildSucceeded = await LoadAndBuildComponentEnvoyAsync(componentEnvoy); return(buildSucceeded ? 0 : 1); }
internal void Delete(EMap map) { // Name ve Root bilgileri Before üzerinden yükleniyor. // Güncelleme bu bilgiler Instruction kısmı için düzenleniyor. // Kullandığımız entity'in Name ve Root bilgileri alınmalı. DEntity d = new DEntity(); Envoy e = new Envoy(); d.TargetLocation = map.ExternalLocation; d = e.Before(new EMap(), d); UpdateList(d.TargetLocation); EMap m = new EMap(); if (IsThereAny(map.Entity)) { m = l.FirstOrDefault(x => x.Entity == map.Entity); } DataAccess.Reduce delete = new DataAccess.Reduce(m, d); }
private NIType CreateType() { QualifiedName targetRelativeName = Envoy != null?Envoy.MakeRelativeDependencyName().BeginningSegment : QualifiedName.Empty; NIAttributedBaseBuilder builder; if (UnderlyingType.IsClass()) { builder = UnderlyingType.DefineClassFromExisting(); } else if (UnderlyingType.IsUnion()) { string name = Name.Last; builder = UnderlyingType.DefineTypedef(name); } else { string name = Name.Last; builder = UnderlyingType.DefineTypedef(name); } builder.DefineNamespaceName(targetRelativeName); return(builder.CreateType()); }
/// <inheritdoc /> public override Document CreateDocument(Envoy envoy) { return(Host.CreateInstance <TypeDiagramDocument>()); }
/// <summary> /// Command handler which adds a new member VI to the gtype that is currently being edited /// </summary> public static void OnAddNewMemberVI(ICommandParameter parameter, ICompositionHost host, DocumentEditSite site) { // Check to see that the user is currently editing a type and if not do nothing. var gTypeEnvoy = site?.ActiveDocument?.Envoy; var gType = (GTypeDefinition)gTypeEnvoy?.ReferenceDefinition; if (gType == null) { return; } var project = host.GetSharedExportedValue <IDocumentManager>().ActiveProject; var createInfo = EnvoyCreateInfo.CreateForNew(VirtualInstrument.VIModelDefinitionType, "New Member VI.gvi"); Envoy createdItem = null; ILockedSourceFile createdFile = null; // Always perform modifications from within a transaction // Here we are creating a user transaction which means it is undoable using (var transaction = gType.TransactionManager.BeginTransaction("Add A VI", TransactionPurpose.User)) { createdFile = project.CreateNewFile(gType.Scope, createInfo); createdFile.Envoy.UpdateStoragePath("Members\\New Member VI.gvi"); createdItem = createdFile.Envoy; transaction.Commit(); } // Lets add a terminal to the member data // First we query for the merge script provider from our gtype. Merge scripts are snippets of code that can be // merged into diagrams / panels / ... // The gtype will provide a merge script that can be used to add data item (control / terminal) to a VI and // many other things string mergeScriptText = string.Empty; var dataProviders = gTypeEnvoy.QueryService <IProvideMergeScriptData>(); foreach (var dataProvider in dataProviders) { foreach (var script in dataProvider.MergeScriptData) { if (script.ClipboardDataFormat == VIDiagramControl.ClipboardDataFormat) { // Found the merge script for a VI diagram, we are done mergeScriptText = script.MergeText; break; } } } // Now merge the script onto the diagram of the VI we just created if (!string.IsNullOrEmpty(mergeScriptText)) { var vi = (VirtualInstrument)createdItem.ReferenceDefinition; // Always perform modifications from within a transaction // We are making this transaction a non user so that it cannot be undone it is just the initial state of the VI using (var transaction = vi.TransactionManager.BeginTransaction("Add A VI", TransactionPurpose.NonUser)) { var mergeScript = MergeScript.FromString(mergeScriptText, host); var resolver = new MergeScriptResolver(mergeScript, host); resolver.Merge(vi.BlockDiagram); // Don't forget to commit the transaction or it will cancel. transaction.Commit(); } } // Now edit the memeber VI that was just created, and this time let's edit starting on the diagram EditDocumentInfo editInfo = new EditDocumentInfo(); editInfo.EditorType = typeof(VIDiagramControl); createdItem?.Edit(editInfo); // After editing dispose our lock in the file createdFile?.Dispose(); }
protected override void OnAttached(Envoy associatedEnvoy) { base.OnAttached(associatedEnvoy); associatedEnvoy.TransactionManager.TransactionStateChanged += HandleTransactionStateChanged; }