public FileValueContext(NodeContext parent, FileValueNode node) : base(parent, node) { KeyValuePair<string, string> splitName = FileValues.SplitName(((FileValueNode)Node).Value); IFileValues fileValues = null; if(!Root.GetShared<FileValueShared>().FileValues.TryGetValue(splitName.Key, out fileValues)) throw new ApplicationException("FileValues not found: " + splitName.Key); val = fileValues.Get(splitName.Value) ?? new NullNodeValue(); }
public DateContext(NodeContext parent, TerminalNode node) : base(parent, node) { DateTime to = !string.IsNullOrEmpty(Node.Atts["To"]) ? DateTime.Parse(Node.Atts["To"]) : Root.Now; DateTime from = !string.IsNullOrEmpty(Node.Atts["From"]) ? DateTime.Parse(Node.Atts["From"]) : Root.Now; TimeSpan diff = to.Subtract(from); DateTime dt = to.AddMilliseconds(Root.Rand.Next(diff.Milliseconds)); val = new StaticNodeValue(dt.ToString(Node.Atts["Fmt"] ?? string.Empty)); }
public SumNode(NodeContext context) { this.Context = context; this.collectionIndex = context.AvailableCollections[RandomUtil.Random.Next(context.AvailableCollections.Count)]; // Add a variable to this context this.Context.AvailableInputs.Add(this.Context.AvailableInputs.Count); this.sumFunction = NodeFactory.GenerateNode(context); }
public MockServiceContext(NodeContext nodeContext, ICodePackageActivationContext codePackageActivationContext, string serviceTypeName, Uri serviceName, byte[] initializationData, Guid partitionId, long replicaOrInstanceId) : base( nodeContext, codePackageActivationContext, serviceTypeName, serviceName, initializationData, partitionId, replicaOrInstanceId) { }
public void Mutate(ref INode node, NodeContext zeroContext) { // Only do a mutation 1/2 the time int doMutation = RandomUtil.Random.Next(100); if (doMutation < this.mutationRate) return; // Mutate a single node, by replacing one of its children var nodes = node.GetNodes(); if (nodes.Count == 1) { node = NodeFactory.GenerateNode(zeroContext); } else { INode mutationNode = nodes[RandomUtil.Random.Next(nodes.Count)]; INode newNode = NodeFactory.GenerateNode(mutationNode.Context); mutationNode.ReplaceChild(newNode); //Console.WriteLine("Before {0} after {1}", nodes.Count, node.GetNodes().Count); } }
public void TestDBreezeSerialization() { using (NodeContext ctx = NodeContext.Create()) { var genesis = ctx.Network.GetGenesis(); var genesisChainedBlock = new ChainedBlock(genesis.Header, ctx.Network.GenesisHash, 0); var chained = this.MakeNext(genesisChainedBlock, ctx.Network); ctx.PersistentCoinView.SaveChangesAsync(new UnspentOutputs[] { new UnspentOutputs(genesis.Transactions[0].GetHash(), new Coins(genesis.Transactions[0], 0)) }, null, genesisChainedBlock.HashBlock, chained.HashBlock).Wait(); Assert.NotNull(ctx.PersistentCoinView.FetchCoinsAsync(new[] { genesis.Transactions[0].GetHash() }).Result.UnspentOutputs[0]); Assert.Null(ctx.PersistentCoinView.FetchCoinsAsync(new[] { new uint256() }).Result.UnspentOutputs[0]); var previous = chained; chained = this.MakeNext(this.MakeNext(genesisChainedBlock, ctx.Network), ctx.Network); chained = this.MakeNext(this.MakeNext(genesisChainedBlock, ctx.Network), ctx.Network); ctx.PersistentCoinView.SaveChangesAsync(new UnspentOutputs[0], null, previous.HashBlock, chained.HashBlock).Wait(); Assert.Equal(chained.HashBlock, ctx.PersistentCoinView.GetBlockHashAsync().GetAwaiter().GetResult()); ctx.ReloadPersistentCoinView(); Assert.Equal(chained.HashBlock, ctx.PersistentCoinView.GetBlockHashAsync().GetAwaiter().GetResult()); Assert.NotNull(ctx.PersistentCoinView.FetchCoinsAsync(new[] { genesis.Transactions[0].GetHash() }).Result.UnspentOutputs[0]); Assert.Null(ctx.PersistentCoinView.FetchCoinsAsync(new[] { new uint256() }).Result.UnspentOutputs[0]); } }
public ServiceBusConsumer( CommerceCommander commerceCommander, GetEnvironmentCommand getEnvironmentCommand, ImportSellableItemFromContentHubCommand importSellableItemFromContentHubCommand, ImportCategoryFromContentHubCommand importCategoryFromContentHubCommand, IConfiguration configuration, ILogger <ServiceBusConsumer> logger, IServiceProvider serviceProvider, CommerceEnvironment globalEnvironment) { _serviceProvider = serviceProvider; _globalEnvironment = globalEnvironment; _getEnvironmentCommand = getEnvironmentCommand; _commerceCommander = commerceCommander; _logger = logger; _connectionString = configuration.GetConnectionString("AppSettings:ServiceBusConnectionString"); _topicName = configuration.GetValue <string>("AppSettings:ServiceBusTopicName"); _queueClient = new QueueClient(_connectionString, _topicName); this._nodeContext = serviceProvider.GetService <NodeContext>(); _importSellableItemFromContentHubCommand = importSellableItemFromContentHubCommand; _importCategoryFromContentHubCommand = importCategoryFromContentHubCommand; }
public async Task <IActionResult> OnPostAsync(short?organisationTypeCode) { try { if (organisationTypeCode == null) { return(NotFound()); } var tbOrgType = await NodeContext.Org_tbTypes.FindAsync(organisationTypeCode); NodeContext.Org_tbTypes.Remove(tbOrgType); await NodeContext.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
/// <summary> /// Instantiates a new MSBuild process acting as a child node. /// </summary> public bool CreateNode(int nodeId, INodePacketFactory factory, NodeConfiguration configuration) { ErrorUtilities.VerifyThrowArgumentNull(factory, "factory"); if (_nodeContexts.Count == ComponentHost.BuildParameters.MaxNodeCount) { ErrorUtilities.ThrowInternalError("All allowable nodes already created ({0}).", _nodeContexts.Count); return(false); } // Start the new process. We pass in a node mode with a node number of 1, to indicate that we // want to start up just a standard MSBuild out-of-proc node. string commandLineArgs = " /nologo /nodemode:1 "; // Disable node re-use if it is not requested (because no argument means enable reuse). if (!ComponentHost.BuildParameters.EnableNodeReuse) { commandLineArgs += "/nodeReuse:false"; } // Make it here. CommunicationsUtilities.Trace("Starting to acquire a new or existing node to establish node ID {0}...", nodeId); NodeContext context = GetNode(null, commandLineArgs, nodeId, factory, NodeProviderOutOfProc.GetHostHandshake(ComponentHost.BuildParameters.EnableNodeReuse), NodeProviderOutOfProc.GetClientHandshake(), NodeContextTerminated); if (null != context) { _nodeContexts[nodeId] = context; // Start the asynchronous read. context.BeginAsyncPacketRead(); // Configure the node. context.SendData(configuration); return(true); } throw new BuildAbortedException(ResourceUtilities.FormatResourceString("CouldNotConnectToMSBuildExe", ComponentHost.BuildParameters.NodeExeLocation)); }
public bool CreateSystemDatabase(DatabaseConfiguration configuration, NodeContext context) { lock (_databases) { if (!_databases.ContainsKey(configuration.Name)) { IDatabaseStore dbStore = new SystemDatabaseStore(); if (((DatabaseStore)dbStore).Initialize(configuration, context, null)) { _databases.Add(configuration.Name, dbStore); return(true); } } else { return(false); } } return(false); }
public async Task <IActionResult> OnGetAsync(string paymentCode) { try { if (paymentCode == null) { return(NotFound()); } Cash_PaymentsUnposted = await NodeContext.Cash_PaymentsUnposted.FirstOrDefaultAsync(m => m.PaymentCode == paymentCode); if (Cash_PaymentsUnposted == null) { return(NotFound()); } else { if ((User.IsInRole(Constants.ManagersRole) || User.IsInRole(Constants.AdministratorsRole)) == false) { var profile = new Profile(NodeContext); var user = await UserManager.GetUserAsync(User); if (Cash_PaymentsUnposted.UserId != await profile.UserId(user.Id)) { return(Forbid()); } } await SetViewData(); return(Page()); } } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
/// <summary> /// 根据配置文件中的设备ID初始化节点上下文。 /// </summary> private void InitializeNodeContext(long nodeCode) { var deviceContext = new NodeContext(); GlobalServices.NodeContext = deviceContext; var idInAppConfig = nodeCode; // 如果指定的ID小于等于零,则从配置文件中读取ID。 if (idInAppConfig < 0) { var dictLocalSettings = ConfigurationManager.AppSettings; if (!string.IsNullOrWhiteSpace(dictLocalSettings["NodeCode"])) { idInAppConfig = Convert.ToInt32(dictLocalSettings["NodeCode"]); } else { throw new InvalidOperationException("在配置文件中没有找到NodeCode。"); } } if (idInAppConfig < 0) { // 如果ID值无效,则根据IP初始化。 deviceContext.Initialize(); } else if (idInAppConfig > 0) { // 如果ID值有效,则使用指定的ID值初始化。 deviceContext.Initialize((UInt32)idInAppConfig); } else { var customNode = SelectCustomNode(); deviceContext.Initialize(customNode); } }
private Path GetPath(string path) { Contract.Requires <InvalidOperationException>(null != GetPsDriveInfo(), "An instance of PSDriveInfo required to build path."); Contract.Requires <InvalidOperationException>(GetPsDriveInfo() is TfsDriveInfo, "PSDriveInfo must be an instance of CrmDriveInfo."); PathSegment pathSegment = new PathSegment(path); NodeContext nodeContext = new NodeContext((TfsDriveInfo)GetPsDriveInfo()) { Filter = Filter, Force = Force, Include = Include ?? new Collection <string>(), Exclude = Exclude ?? new Collection <string>(), WriteItemObject = WriteItemObject }; nodeContext.SetPath(pathSegment); Path crmPath = new Path(nodeContext); return(crmPath); }
public async Task OnGetAsync(string returnUrl) { try { await SetViewData(); if (!string.IsNullOrEmpty(returnUrl)) { ReturnUrl = returnUrl; } var taxtypes = from tb in NodeContext.App_TaxCodeTypes orderby tb.TaxType select tb.TaxType; TaxTypes = new SelectList(await taxtypes.ToListAsync()); var taxCodes = from tb in NodeContext.App_TaxCodes select tb; if (!string.IsNullOrEmpty(TaxType)) { taxCodes = taxCodes.Where(t => t.TaxType == TaxType); } if (!string.IsNullOrEmpty(SearchString)) { taxCodes = taxCodes.Where(t => t.TaxDescription.Contains(SearchString)); } App_TaxCodes = await taxCodes.ToListAsync(); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnGetAsync(string returnUrl) { try { await SetViewData(); if (!string.IsNullOrEmpty(returnUrl)) { ReturnUrl = returnUrl; } var roundings = NodeContext.App_tbRoundings.OrderBy(r => r.RoundingCode).Select(r => r.Rounding); Roundings = new SelectList(await roundings.ToListAsync()); Rounding = await roundings.FirstOrDefaultAsync(); var taxtypes = NodeContext.App_TaxCodeTypes.OrderBy(t => t.TaxTypeCode).Select(t => t.TaxType); TaxTypes = new SelectList(await taxtypes.ToListAsync()); TaxType = await roundings.FirstOrDefaultAsync(); Profile profile = new(NodeContext); var userName = await profile.UserName(UserManager.GetUserId(User)); App_tbTaxCode = new App_tbTaxCode() { RoundingCode = (short)NodeEnum.RoundingCode.Round, TaxTypeCode = (short)NodeEnum.TaxType.VAT, UpdatedBy = userName, UpdatedOn = DateTime.Now }; return(Page()); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
/// <summary> /// Shuts down all of the managed nodes permanently. /// </summary> /// <param name="nodeReuse">Whether to reuse the node</param> /// <param name="terminateNode">Delegate used to tell the node provider that a context has terminated</param> protected void ShutdownAllNodes(bool nodeReuse, NodeContextTerminateDelegate terminateNode) { // INodePacketFactory INodePacketFactory factory = new NodePacketFactory(); List <Process> nodeProcesses = GetPossibleRunningNodes().nodeProcesses; // Find proper MSBuildTaskHost executable name string msbuildtaskhostExeName = NodeProviderOutOfProcTaskHost.TaskHostNameForClr2TaskHost; // Search for all instances of msbuildtaskhost process and add them to the process list nodeProcesses.AddRange(new List <Process>(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(msbuildtaskhostExeName)))); // For all processes in the list, send signal to terminate if able to connect foreach (Process nodeProcess in nodeProcesses) { // A 2013 comment suggested some nodes take this long to respond, so a smaller timeout would miss nodes. int timeout = 30; // Attempt to connect to the process with the handshake without low priority. Stream nodeStream = TryConnectToProcess(nodeProcess.Id, timeout, NodeProviderOutOfProc.GetHandshake(nodeReuse, false)); if (nodeStream == null) { // If we couldn't connect attempt to connect to the process with the handshake including low priority. nodeStream = TryConnectToProcess(nodeProcess.Id, timeout, NodeProviderOutOfProc.GetHandshake(nodeReuse, true)); } if (nodeStream != null) { // If we're able to connect to such a process, send a packet requesting its termination CommunicationsUtilities.Trace("Shutting down node with pid = {0}", nodeProcess.Id); NodeContext nodeContext = new NodeContext(0, nodeProcess, nodeStream, factory, terminateNode); nodeContext.SendData(new NodeBuildComplete(false /* no node reuse */)); nodeStream.Dispose(); } } }
public async Task OnGetAsync(string returnUrl) { try { await SetViewData(); if (!string.IsNullOrEmpty(returnUrl)) { ReturnUrl = returnUrl; } var orgTypes = from tb in NodeContext.Org_tbTypes orderby tb.OrganisationType select tb.OrganisationType; OrganisationTypes = new SelectList(await orgTypes.ToListAsync()); var accounts = from tb in NodeContext.Org_AccountLookup select tb; if (!string.IsNullOrEmpty(OrganisationType)) { accounts = accounts.Where(a => a.OrganisationType == OrganisationType); } if (!string.IsNullOrEmpty(SearchString)) { accounts = accounts.Where(a => a.AccountName.Contains(SearchString)); } Org_AccountLookup = await accounts.OrderBy(a => a.AccountName).ToListAsync(); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnGetAsync(string cashCode) { try { if (string.IsNullOrEmpty(cashCode)) { return(NotFound()); } Cash_tbCode = await NodeContext.Cash_tbCodes.FindAsync(cashCode); if (Cash_tbCode == null) { return(NotFound()); } IsEnabled = Cash_tbCode.IsEnabled != 0; TaxDescriptions = new SelectList(await NodeContext.App_TaxCodes.OrderBy(t => t.TaxCode).Select(t => t.TaxDescription).ToListAsync()); Categories = new SelectList(await NodeContext.Cash_tbCategories .Where(t => t.CategoryTypeCode == (short)NodeEnum.CategoryType.CashCode) .OrderBy(t => t.Category) .Select(t => t.Category) .ToListAsync()); TaxDescription = await NodeContext.App_tbTaxCodes.Where(t => t.TaxCode == Cash_tbCode.TaxCode).Select(t => t.TaxDescription).FirstAsync(); Category = await NodeContext.Cash_tbCategories.Where(c => c.CategoryCode == Cash_tbCode.CategoryCode).Select(c => c.Category).FirstAsync(); await SetViewData(); return(Page()); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Profile profile = new(NodeContext); Cash_TransfersUnposted.UpdatedBy = await profile.UserName(UserManager.GetUserId(User)); NodeContext.Attach(Cash_TransfersUnposted).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Cash_TransfersUnposted.AnyAsync(e => e.PaymentCode == Cash_TransfersUnposted.PaymentCode)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Org_tbType.CashModeCode = await NodeContext.Cash_tbModes.Where(t => t.CashMode == CashMode).Select(t => t.CashModeCode).FirstAsync(); NodeContext.Attach(Org_tbType).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Org_tbTypes.AnyAsync(e => e.OrganisationTypeCode == Org_tbType.OrganisationTypeCode)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string id) { try { if (id == null) { return(NotFound()); } var user = await UserManager.FindByIdAsync(id); var code = await UserManager.GenerateEmailConfirmationTokenAsync(user); await UserManager.ConfirmEmailAsync(user, code); return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public bool Initialize(DatabaseConfigurations configurations, NodeContext context, IDictionary <String, IDictionary <String, IDistribution> > distributionMaps) { _distributionMap = distributionMaps; foreach (DatabaseConfiguration dbConfig in configurations.Configurations.Values) { lock (_databases) { if (!_databases.ContainsKey(dbConfig.Name)) { IDatabaseStore dbStore = new DatabaseStore(); IDictionary <string, IDistribution> colDistributions; _distributionMap.TryGetValue(dbConfig.Name, out colDistributions); if (((DatabaseStore)dbStore).Initialize(dbConfig, context, colDistributions)) { _databases.Add(dbConfig.Name, dbStore); } } } } return(true); }
static void CreateChildren(List <Node> parents, int hierarchy, NodeContext context) { if (hierarchy >= HIERARCHY_COUNT) { return; } List <Node> createdChildren = new List <Node>(); foreach (var item in parents) { for (int i = 1; i <= CHILDREN_COUNT; i++) { var child = AddChild(item, item.Name + "." + i, context); createdChildren.Add(child); } } CURRENT_HIERARCHY = CURRENT_HIERARCHY + 1; CreateChildren(createdChildren, CURRENT_HIERARCHY, context); }
public async Task <IActionResult> OnPostRebuildSystem() { try { FinancialPeriods period = new(NodeContext); if (await period.Rebuild()) { return(RedirectToPage("./Index")); } else { return(RedirectToPage("/Admin/EventLog/Index")); } } catch (Exception e) { { NodeContext.ErrorLog(e); throw; } } }
private void txtValue_KeyUp(object sender, KeyEventArgs e) { //MessageBox.Show(txtValue.Text); NodeContext nodeContext = (NodeContext)tv.SelectedNode.Tag; nodeContext.ValueAttr = txtValue.Text; //nodeContext.Id = txtId.Text; if (string.IsNullOrEmpty(nodeContext.ValueAttr) && string.IsNullOrEmpty(nodeContext.IdAttr)) { tv.SelectedNode.NodeFont = null; RemoveChildIdFromParentNode(tv.SelectedNode, nodeContext.NodeId); HighlightParentNode(tv.SelectedNode, nodeContext.NodeId); } else { AddChildIdToParentNode(tv.SelectedNode, nodeContext.NodeId); tv.SelectedNode.NodeFont = nodeFont; HighlightParentNode(tv.SelectedNode, nodeContext.NodeId); } // ExportToXML(tv); WriteJson(); }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } NodeContext.Cash_tbCategories.Add(Cash_tbCategory); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("categoryCode", Cash_tbCategory.CategoryCode); return(RedirectToPage("./Edit", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public ServiceFabricHealthReporter(string entityIdentifier) { if (string.IsNullOrWhiteSpace(entityIdentifier)) { throw new ArgumentException("entityIdentifier cannot be null or empty", "entityIdentifier"); } this.entityIdentifier = entityIdentifier; this.fabricClient = new FabricClient( new FabricClientSettings() { HealthReportSendInterval = TimeSpan.FromSeconds(5) } ); CodePackageActivationContext activationContext = FabricRuntime.GetActivationContext(); this.applicatioName = new Uri(activationContext.ApplicationName); this.serviceManifestName = activationContext.GetServiceManifestName(); NodeContext nodeContext = FabricRuntime.GetNodeContext(); this.nodeName = nodeContext.NodeName; }
/// <summary> /// Instantiates a new MSBuild process acting as a child node. /// </summary> public bool CreateNode(int nodeId, INodePacketFactory factory, NodeConfiguration configuration) { ErrorUtilities.VerifyThrowArgumentNull(factory, "factory"); if (_nodeContexts.Count == ComponentHost.BuildParameters.MaxNodeCount) { ErrorUtilities.ThrowInternalError("All allowable nodes already created ({0}).", _nodeContexts.Count); return(false); } // Start the new process. We pass in a node mode with a node number of 1, to indicate that we // want to start up just a standard MSBuild out-of-proc node. // Note: We need to always pass /nodeReuse to ensure the value for /nodeReuse from msbuild.rsp // (next to msbuild.exe) is ignored. string commandLineArgs = $"/nologo /nodemode:1 /nodeReuse:{ComponentHost.BuildParameters.EnableNodeReuse.ToString().ToLower()} /low:{ComponentHost.BuildParameters.LowPriority.ToString().ToLower()}"; // Make it here. CommunicationsUtilities.Trace("Starting to acquire a new or existing node to establish node ID {0}...", nodeId); long hostHandShake = NodeProviderOutOfProc.GetHostHandshake(ComponentHost.BuildParameters.EnableNodeReuse, ComponentHost.BuildParameters.LowPriority); NodeContext context = GetNode(null, commandLineArgs, nodeId, factory, hostHandShake, NodeProviderOutOfProc.GetClientHandshake(ComponentHost.BuildParameters.EnableNodeReuse, ComponentHost.BuildParameters.LowPriority), NodeContextTerminated); if (null != context) { _nodeContexts[nodeId] = context; // Start the asynchronous read. context.BeginAsyncPacketRead(); // Configure the node. context.SendData(configuration); return(true); } throw new BuildAbortedException(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("CouldNotConnectToMSBuildExe", ComponentHost.BuildParameters.NodeExeLocation)); }
public async Task <IActionResult> OnGetAsync(string id) { try { if (id == null) { return(NotFound()); } AspNet_UserRegistration = await NodeContext.AspNet_UserRegistrations.FirstOrDefaultAsync(m => m.Id == id); if (AspNet_UserRegistration == null) { return(NotFound()); } else { var isAuthorized = await AuthorizationService.AuthorizeAsync( User, AspNet_UserRegistration, Operations.Delete); if (!isAuthorized.Succeeded) { return(Forbid()); } await SetViewData(); return(Page()); } } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Invoice_Entry.TaxCode = await NodeContext.App_tbTaxCodes.Where(c => c.TaxDescription == TaxDescription).Select(c => c.TaxCode).FirstAsync(); NodeContext.Attach(Invoice_Entry).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Invoice_Entries.AnyAsync(e => e.AccountCode == Invoice_Entry.AccountCode && e.CashCode == Invoice_Entry.CashCode)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
/// <summary> /// Shuts down all of the managed nodes permanently. /// </summary> /// <param name="hostHandshake">host handshake key</param> /// <param name="clientHandshake">client handshake key</param> /// <param name="terminateNode">Delegate used to tell the node provider that a context has terminated</param> protected void ShutdownAllNodes(long hostHandshake, long clientHandshake, NodeContextTerminateDelegate terminateNode) { // INodePacketFactory INodePacketFactory factory = new NodePacketFactory(); // Find proper msbuild executable name string msbuildExeName = Environment.GetEnvironmentVariable("MSBUILD_EXE_NAME"); if (String.IsNullOrEmpty(msbuildExeName)) { msbuildExeName = "MSBuild.exe"; } // Search for all instances of the msbuild process and create a list of them List <Process> nodeProcesses = new List <Process>(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(msbuildExeName))); // Find proper MSBuildTaskHost executable name string msbuildtaskhostExeName = NodeProviderOutOfProcTaskHost.TaskHostNameForClr2TaskHost; // Search for all instances of msbuildtaskhost process and add them to the process list nodeProcesses.AddRange(new List <Process>(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(msbuildtaskhostExeName)))); // For all processes in the list, send signal to terminate if able to connect foreach (Process nodeProcess in nodeProcesses) { NamedPipeClientStream nodeStream = TryConnectToProcess(nodeProcess.Id, 30 /*verified to miss nodes if smaller*/, hostHandshake, clientHandshake); if (null != nodeStream) { // If we're able to connect to such a process, send a packet requesting its termination CommunicationsUtilities.Trace("Shutting down node with pid = {0}", nodeProcess.Id); NodeContext nodeContext = new NodeContext(0, nodeProcess.Id, nodeStream, factory, terminateNode); nodeContext.SendData(new NodeBuildComplete(false /* no node reuse */)); nodeStream.Close(); } } }
private void SaveToXML(TreeNode parentNode, XmlTextWriter xmlTextWriter) { IEnumerable <TreeNode> childNodes = parentNode.Nodes.Cast <TreeNode>().Where(c => !string.IsNullOrEmpty(((NodeContext)c.Tag).ValueAttr) || ((NodeContext)c.Tag).ChildNodeIdList.Count > 0); foreach (TreeNode childNode in childNodes) { NodeContext nodeContext = (NodeContext)childNode.Tag; if (childNode.Nodes.Count > 0 && nodeContext.ChildNodeIdList.Count() > 0) { xmlTextWriter.WriteStartElement(childNode.Text); SaveToXML(childNode, xmlTextWriter); xmlTextWriter.WriteEndElement(); } else { if (nodeContext.IsLastNode && !string.IsNullOrEmpty(nodeContext.ValueAttr)) { xmlTextWriter.WriteStartElement(childNode.Text); xmlTextWriter.WriteAttributeString("value", nodeContext.ValueAttr); xmlTextWriter.WriteEndElement(); } } } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } NodeContext.Org_tbContacts.Add(Org_tbContact); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("AccountCode", Org_tbContact.AccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(short?yearNumber) { try { if (yearNumber == null) { return(NotFound()); } var tbYear = await NodeContext.App_tbYears.FindAsync(yearNumber); NodeContext.App_tbYears.Remove(tbYear); await NodeContext.SaveChangesAsync(); await SetViewData(); return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public ValueFileContext(NodeContext parent, ValueFileNode node) : base(parent, node) { string type = Node.Atts.ContainsKey("Type") ? Node.Atts["Type"] : "Line"; ValueFileMode mode = (ValueFileMode)Enum.Parse(typeof(ValueFileMode), Node.Atts.ContainsKey("Mode") ? Node.Atts["Mode"] : "Die"); IFileValues fileValues = null; if(Root.GetShared<FileValueShared>().FileValues.TryGetValue(Node.Name, out fileValues)) { if(fileValues.Type != type) throw new ApplicationException("ValueFile aready exists but is of different type: " + type); } else { fileValues = FileValues.Create(type); Root.GetShared<FileValueShared>().FileValues.Add(Node.Name, fileValues); } fileValues.Mode = mode; string file = GetStr(Node.Atts["File"]); using(StreamReader sr = new StreamReader(file)) fileValues.Load(sr); }
public async Task <IActionResult> OnGetAsync(string categoryCode) { try { if (string.IsNullOrEmpty(categoryCode)) { return(NotFound()); } Cash_tbCategory = await NodeContext.Cash_tbCategories.FindAsync(categoryCode); if (Cash_tbCategory == null) { return(NotFound()); } IsEnabled = Cash_tbCategory.IsEnabled != 0; var modes = NodeContext.Cash_tbModes.OrderBy(m => m.CashModeCode).Select(m => m.CashMode); CashModes = new SelectList(await modes.ToListAsync()); CashMode = await NodeContext.Cash_tbModes.Where(m => m.CashModeCode == Cash_tbCategory.CashModeCode).Select(m => m.CashMode).FirstAsync(); var types = NodeContext.Cash_tbTypes.OrderBy(t => t.CashTypeCode).Select(t => t.CashType); CashTypes = new SelectList(await types.ToListAsync()); CashType = await NodeContext.Cash_tbTypes.Where(t => t.CashTypeCode == Cash_tbCategory.CashTypeCode).Select(t => t.CashType).FirstAsync(); await SetViewData(); return(Page()); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public TerminalContext(NodeContext parent, TerminalNode node) : base(parent, node) { }
public InputVariableNode(int variableKey, NodeContext context) { this.context = context; this.variableKey = variableKey; }
public InputVariableNode(NodeContext context) { this.context = context; this.variableKey = context.AvailableInputs[RandomUtil.Random.Next(context.AvailableInputs.Count)]; }
public DivideNode(NodeContext context, INode numerator, INode denomiator) { this.context = (NodeContext) context.Clone(); this.numerator = (INode) numerator.Clone(); this.denomiator = (INode) denomiator.Clone(); }
/// <summary> /// Shuts down all of the managed nodes permanently. /// </summary> /// <param name="hostHandshake">host handshake key</param> /// <param name="clientHandshake">client handshake key</param> /// <param name="terminateNode">Delegate used to tell the node provider that a context has terminated</param> protected void ShutdownAllNodes(long hostHandshake, long clientHandshake, NodeContextTerminateDelegate terminateNode) { // INodePacketFactory INodePacketFactory factory = new NodePacketFactory(); // Find proper msbuild executable name string msbuildExeName = Environment.GetEnvironmentVariable("MSBUILD_EXE_NAME"); if (String.IsNullOrEmpty(msbuildExeName)) { msbuildExeName = "MSBuild.exe"; } // Search for all instances of the msbuild process and create a list of them List<Process> nodeProcesses = new List<Process>(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(msbuildExeName))); // Find proper MSBuildTaskHost executable name string msbuildtaskhostExeName = NodeProviderOutOfProcTaskHost.TaskHostNameForClr2TaskHost; // Search for all instances of msbuildtaskhost process and add them to the process list nodeProcesses.AddRange(new List<Process>(Process.GetProcessesByName(Path.GetFileNameWithoutExtension(msbuildtaskhostExeName)))); // For all processes in the list, send signal to terminate if able to connect foreach (Process nodeProcess in nodeProcesses) { NamedPipeClientStream nodeStream = TryConnectToProcess(nodeProcess.Id, 30/*verified to miss nodes if smaller*/, hostHandshake, clientHandshake); if (null != nodeStream) { // If we're able to connect to such a process, send a packet requesting its termination CommunicationsUtilities.Trace("Shutting down node with pid = {0}", nodeProcess.Id); NodeContext nodeContext = new NodeContext(0, nodeProcess.Id, nodeStream, factory, terminateNode); nodeContext.SendData(new NodeBuildComplete(false /* no node reuse */)); nodeStream.Close(); } } }
public ConstantNode(NodeContext context) { this.context = context; this.constant = RandomUtil.Random.Next(100); }
public SubtractNode(NodeContext context) { this.context = context; this.right = NodeFactory.GenerateNode(this.context); this.left = NodeFactory.GenerateNode(this.context); }
public RefContext(NodeContext parent, RefNode node) : base(parent, node) { }
public SumNode(NodeContext context, int collectionIndex, INode sumFunction) { this.Context = (NodeContext) context.Clone(); this.collectionIndex = collectionIndex; this.sumFunction = (INode) sumFunction.Clone(); }
public TryContext(NodeContext parent, MetaNode node) : base(parent, node) { }
public NullContext(NodeContext parent, NullNode node) : base(parent, node) { }
public InputSizeNode(NodeContext context) { this.context = context; }
public ConstantNode(NodeContext context, double constant) { this.context = (NodeContext) context.Clone(); this.constant = constant; }
public CollectionSizeNode(int collectionIndex, NodeContext context) { this.Context = (NodeContext) context.Clone(); this.collectionIndex = collectionIndex; }
/// <summary> /// Sends data to the specified node. /// </summary> /// <param name="context">The node to which data shall be sent.</param> /// <param name="packet">The packet to send.</param> protected void SendData(NodeContext context, INodePacket packet) { ErrorUtilities.VerifyThrowArgumentNull(packet, "packet"); context.SendData(packet); }
public SubtractNode(NodeContext context, INode left, INode right) { this.context = (NodeContext) context.Clone(); this.left = (INode) left.Clone(); this.right = (INode) right.Clone(); }
public AddNode(NodeContext context, INode right, INode left) { this.context = (NodeContext) context.Clone(); this.right = (INode) right.Clone(); this.left = (INode) left.Clone(); }
public MultiplyNode(NodeContext context, INode left, INode right) { this.context = (NodeContext) context.Clone(); this.left = (INode) left.Clone(); this.right = (INode) right.Clone(); }
public CollectionSizeNode(NodeContext context) { this.Context = context; this.collectionIndex = context.AvailableCollections[RandomUtil.Random.Next(context.AvailableCollections.Count)]; }
public ConstContext(NodeContext parent, ConstNode node) : base(parent, node) { Root.GetShared<ConstShared>().Consts.TryGetValue(Node.Name, out val); }
public DivideNode(NodeContext context) { this.context = context; this.numerator = NodeFactory.GenerateNode(this.context); this.denomiator = NodeFactory.GenerateNode(this.context); }
public MultiplyNode(NodeContext context) { this.context = context; this.left = NodeFactory.GenerateNode(this.context); this.right = NodeFactory.GenerateNode(this.context); }
public SetConstContext(NodeContext parent, SetConstNode node) : base(parent, node) { Root.GetShared<ConstShared>().Consts[Node.Name] = GetStr(Node.Atts["Value"]); }
public ChanceContext(NodeContext parent, ChanceNode node) : base(parent, node) { }