public static IEnumerable <NodeEntity> AsEntityModel(this IEnumerable <Node> models, GraphEntity graph) { if (models == null || graph == null) { return(new List <NodeEntity>()); } var nodes = models as IList <Node> ?? models.ToList(); var counter = 0; var dict = nodes.FirstOrDefault(n => n != null).Parent.Nodes.Where(m => m != null) .Select(m => { var entity = new NodeEntity { Graph = graph, Id = m.Id, Key = m.Key, Position = counter }; counter++; return(entity); }) .ToDictionary(m => m.Id, m => m); foreach (var model in nodes.Where(m => m != null)) { NodeEntity entity = dict[model.Id]; entity.Neighbours = new List <NodeEntity>(); foreach (var ngh in model.Neighbours.Where(ngh => ngh != null)) { entity.Neighbours.Add(dict[ngh.Id]); } } return(dict.Values.ToList()); }
private List <JoinKeyword> JoinsFromNode(NodeEntity arg) { List <JoinKeyword> ret = new List <JoinKeyword>(); string tableName = arg.Find(@"Select").Find(@"Columns", @"attr", @"Main").Find(@"Table").GetNodeValue(); string tableAlias = arg.Find(@"Select").Find(@"Columns", @"attr", @"Main").Find(@"Alias").GetNodeValue(); NodeEntity joins = arg.Find(@"Join"); joins.GetChildren().ForEach(item => { JoinKeyword add = new JoinKeyword(); add.SetTable(tableName); add.SetTableAlias(tableAlias); add.SetJoinTable(item.Find(@"Name").GetNodeValue()); add.SetJoinTableAlias(item.Find(@"Alias").GetNodeValue()); add.SetInnerJoin(item.Find(@"Inner").GetNodeValue() == @"True" ? true : false); add.SetLeftOuterJoin(item.Find(@"Left").GetNodeValue() == @"True" ? true : false); add.SetRightOuterJoin(item.Find(@"Right").GetNodeValue() == @"True" ? true : false); add.SetCrossJoin(item.Find(@"Cross").GetNodeValue() == @"True" ? true : false); item.Find(@"Conditions").GetChildren().ForEach(c => { add.AddCondition( c.Find(@"Equal").GetNodeValue() == @"True" ? true : false , c.Find(@"GreaterThanEqual").GetNodeValue() == @"True" ? true : false , c.Find(@"JoinTableAsLarger").GetNodeValue() == @"True" ? true : false , c.Find(@"JoinTableColumn").GetNodeValue() , c.Find(@"TableColumn").GetNodeValue()); }); ret.Add(add); }); return(ret); }
public void Tree(NodeEntity arg) { root = new XMLNode(); root.SetNode(arg); root.Tree(); tree.Items.Add(root); }
/// <summary> /// Adds new node if it doesn't exist. /// </summary> /// <param name="node">New node entity.</param> /// <returns>The Task.</returns> public async Task <NodeEntity> AddOrUpdateAsync(NodeEntity node) { try { node.Cost = 1; await this.DbContext.Cypher .Merge("(n:NodeEntity { Id: {id} })") .OnCreate() .Set("n = {node}") .WithParams(new { id = node.Id, node }) .ExecuteWithoutResultsAsync(); if (!string.IsNullOrEmpty(node.Label)) { await this.DbContext.Cypher .Match("(n:NodeEntity)") .Where((NodeEntity n) => n.Id == node.Id) .Set("n.Label = {label}") .WithParam("label", node.Label) .ExecuteWithoutResultsAsync(); } return(node); } catch (Exception e) { log.ErrorFormat("Add new node entity failed: {0}", e); throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(this.Request.QueryString["infoid"], out this.infoId)) { this.Response.Write("<script>alert('参数错误!');</script>"); this.Response.Write("<script>window.location = 'info_manager.aspx';</script>"); return; } this.articleManager = new ArticleManager("EFConnectionString"); this.article = this.articleManager.Get(this.infoId) as ArticleEntity; NodeManager nodeManager = new NodeManager("EFConnectionString"); NodeEntity node = nodeManager.Get(this.article.NodeId); StringDictionary roles = (this.Master as AdminLayout).UserRoles; if (!nodeManager.CheckNodeRole(node, roles, ActionType.ManageInfo)) { this.Response.Write("<script>alert('无权限!');</script>"); this.Response.Write("<script>window.location = 'info_manager.aspx';</script>"); return; } if (!this.IsPostBack) { this.title.Text = this.article.Title; this.content.Text = this.article.Content; this.source.Text = this.article.Source; this.image.Text = this.article.Image; this.link.Text = this.article.Link; this.isTop.Checked = this.article.IsTop; this.stateList.SelectedIndex = (int)this.article.State; } }
/// <summary> /// Update the passed in album entity by passing in an anonymous object with related values. This is implemented /// using an anonymous object because the PATCH verb only expects values for the things you want to update. IE: /// if I only want to update the keywords array obj, so I only set the keywords array property /// and pass this: { "UploadKey": "test" } /// </summary> /// <param name="node"></param> /// <param name="updateAlbumObject">An anonymous object with the settings to be updated. Only specify the fields you wish to update.</param> /// <returns></returns> public async Task <bool> UpdateAlbumAsync(NodeEntity node, object updateAlbumObject) { var requestUri = $"{SmugMugConstants.Addresses.SmugMug}{node.Uris["Album"].Id}"; await apiService.PatchRequestAsync(requestUri, updateAlbumObject); return(true); }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.Request.QueryString["nodeid"])) { NodeManager nodeManager = new NodeManager("EFConnectionString"); nodeManager.FillTreeView(nodeTreeView, (this.Master as AdminLayout).UserRoles, ActionType.ManageInfo, "add_info.aspx?nodeid="); } else { int nodeId; if (!int.TryParse(this.Request.QueryString["nodeid"], out nodeId)) { this.Response.Write("<script>alert('参数错误!');</script>"); this.Response.Write("<script>window.location = 'add_info.aspx';</script>"); return; } NodeManager nodeManager = new NodeManager("EFConnectionString"); NodeEntity node = nodeManager.Get(nodeId); if (string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings[string.Format(addPageString, node.ApplicationId.ToString())])) { this.Response.Write("<script>alert('配置出错!请联系程序猿!');</script>"); this.Response.Write("<script>window.location = 'add_info.aspx';</script>"); } else { this.Response.Redirect(ConfigurationManager.AppSettings[string.Format(addPageString, node.ApplicationId.ToString())] + "?nodeid=" + nodeId); } } }
protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(this.Request.QueryString["nodeid"], out this.nodeId)) { this.Response.Write("<script>alert('参数错误!');</script>"); this.Response.Write("<script>window.location = 'node_manager.aspx';</script>"); return; } this.nodeManager = new NodeManager("EFConnectionString"); this.node = this.nodeManager.Get(this.nodeId); StringDictionary roles = (this.Master as AdminLayout).UserRoles; if (!nodeManager.CheckNodeRole(node, roles, ActionType.ManageNode)) { this.Response.Write("<script>alert('无权限!');</script>"); this.Response.Write("<script>window.location = 'node_manager.aspx';</script>"); return; } if (!this.IsPostBack) { this.nodeName.Text = this.node.NodeName; this.imagePath.Text = this.node.ImagePath; this.needAudit.Checked = this.node.NeedAudit; this.comment.Text = this.node.Comment; this.enable.Checked = this.node.Enable; this.addNodeLink.NavigateUrl += this.nodeId.ToString(); } }
public static IEnumerable<NodeEntity> AsEntityModel(this IEnumerable<Node> models, GraphEntity graph) { if (models == null || graph == null) return new List<NodeEntity>(); var nodes = models as IList<Node> ?? models.ToList(); var counter = 0; var dict = nodes.FirstOrDefault(n => n != null).Parent.Nodes.Where(m => m != null) .Select(m => { var entity = new NodeEntity { Graph = graph, Id = m.Id, Key = m.Key, Position = counter }; counter++; return entity; }) .ToDictionary(m => m.Id, m => m); foreach (var model in nodes.Where(m => m != null)) { NodeEntity entity = dict[model.Id]; entity.Neighbours = new List<NodeEntity>(); foreach (var ngh in model.Neighbours.Where(ngh => ngh != null)) { entity.Neighbours.Add(dict[ngh.Id]); } } return dict.Values.ToList(); }
/// <summary> /// Evaluate the user information in range of neighbor nodes. /// </summary> private void EvaluateNearbyUsers() { List <UserEntity> tempUsers = new List <UserEntity>(usersInRange); foreach (UserEntity user in tempUsers) { float userDistanceSqr = (user.transform.position - transform.position).sqrMagnitude; if (userDistanceSqr > Mathf.Pow(NetworkManager.inst.connectionRadius, 2f) / 2f) { NodeEntity bestNode = this; foreach (NodeEntity node in neighbors) { try { float neighborDistanceSqr = (node.transform.position - user.transform.position).sqrMagnitude; if (neighborDistanceSqr < userDistanceSqr) { userDistanceSqr = neighborDistanceSqr; bestNode = node; } } catch (Exception e) { } } if (bestNode != this) { bestNode.usersInRange.Add(user); user.nearestNode = bestNode; usersInRange.Remove(user); } } } }
public void Fill(NodeEntity node) { root = new XMLNode { Node = node }; root.Fill(); OwnTree.Items.Add(root); }
public virtual void LogNodeHealthState(NodeEntity node) { MonitoringEventSource.Current.LogNodeHealthState( node.ClusterName, node.NodeName, node.Health.AggregatedHealthState.ToString(), node.Health.GetHealthEvaluationString()); }
public TableListCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"TableList"); ReloadButton = page.Find(@"ReloadButton").NodeValue; TableNameColumn = page.Find(@"TableNameColumn").NodeValue; }
public TagCardCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"TagCard"); TagInput = page.Find(@"TagInput").NodeValue; RegisterButton = page.Find(@"RegisterButton").NodeValue; }
public async Task <int> CreateAsync(NodeEntity model) { context.Nodes.Add(model); await context.SaveChangesAsync(); return(model.Id); }
public TagMasterCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"TagMaster"); TagInput = page.Find(@"TagInput").NodeValue; SearchButton = page.Find(@"SearchButton").NodeValue; }
public NodeEntity GetSubNode(NodeEntity parentFolder, string subFolderName, TypeEnum nodeType, out bool haveCreated, bool cached = true, string subFolderPassword = "******") { var key = $"{parentFolder.Key}.{subFolderName}"; haveCreated = false; if (cached && _cache.ContainsKey(key)) { ConsolePrinter.Write(ConsoleColor.Green, $"Loaded {nodeType} : {subFolderName} (cached)"); return(_cache[key]); } var subFolder = parentFolder.GetChildrenAsync(type: nodeType).Result?.FirstOrDefault(f => string.Equals(f.Name, subFolderName, StringComparison.CurrentCultureIgnoreCase)); if (subFolder != null) { subFolder.Key = key; if (!_cache.ContainsKey(key)) { _cache.Add(key, subFolder); } else { _cache[key] = subFolder; } ConsolePrinter.Write(ConsoleColor.Green, $"Loaded {nodeType} : {subFolderName}"); return(subFolder); } ConsolePrinter.Write(ConsoleColor.DarkYellow, $"Creating {nodeType} : {subFolderName}"); //we need to create it subFolder = new NodeEntity(_oauthToken) { Type = nodeType, Description = subFolderName, Name = subFolderName, UrlName = subFolderName, Keywords = new[] { subFolderName }, Parent = parentFolder, Privacy = subFolderPassword == "NONE" ? PrivacyEnum.Public : PrivacyEnum.Unlisted, SecurityType = subFolderPassword == "NONE" ? SecurityTypeEnum.None : SecurityTypeEnum.Password, Password = subFolderPassword == "NONE" ? null : subFolderPassword, PasswordHint = subFolderPassword == "NONE" ? null : "It's on your sales reciept", Key = key }; subFolder.CreateAsync(parentFolder).Wait(); haveCreated = true; //Read it back in so we got all properties subFolder = parentFolder.GetChildrenAsync(type: nodeType).Result?.FirstOrDefault(f => string.Equals(f.Name, subFolderName, StringComparison.CurrentCultureIgnoreCase)); subFolder.Key = key; _cache.Add(key, subFolder); return(subFolder); }
public override void LogNodeHealthEvent(NodeEntity node, EntityHealthEvent healthEvent) { AppendHealthEventToFile( string.Format( "LogNodeHealthEvent: ClusterName: {0}, NodeName: {1}", node.ClusterName, node.NodeName), healthEvent); }
private void Fill(XMLNode arg1, NodeEntity arg2) { var add = new XMLNode { Header = arg2.NodeName, Name = arg2.NodeName, Tag = arg2.CloneWithoutChildren() }; arg2.Children.ForEach(c => Fill(add, c)); arg1.Items.Add(add); }
public BinaryStorageCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"BinaryStorage"); KeyInput = page.Find(@"KeyInput").NodeValue; TagInput = page.Find(@"TagInput").NodeValue; SearchButton = page.Find(@"SearchButton").NodeValue; }
public override void EmitNodeHealthState(NodeEntity node) { AppendToFile( string.Format( "nodeHealthMetric: ClusterName: {0}, NodeName: {2}, HealthState: {1}", node.ClusterName, node.Health.AggregatedHealthState.ToString(), node.NodeName)); }
public NodeInfo(NodeEntity node) { Assert.IsNotNull(node, "Node can't be null"); this.NodeId = node.NodeId; this.NodeName = node.NodeName; this.NodeUpTime = node.NodeUpTime; this.IsSeedNode = node.IsSeedNode; this.CodeVersion = node.CodeVersion; }
protected void Page_Load(object sender, EventArgs e) { int id; if (int.TryParse(this.Request.QueryString["nodeid"], out id)) { NodeManager nodeManager = new NodeManager("EFConnectionString"); NodeEntity node = nodeManager.Get(id); StringDictionary roles = (this.Master as AdminLayout).UserRoles; if (!nodeManager.CheckNodeRole(node, roles, ActionType.ManageNode)) { this.Response.Write("<script>alert('无权限!');</script>"); this.Response.Write("<script>window.location = 'info_manager.aspx';</script>"); return; } int infoCount; if (node.ApplicationId == 3) { InfoManager infoManager = new InfoManager("EFConnectionString"); this.infosView.DataSource = infoManager.GetByNodeId(id, true, int.Parse(this.pageIndex.Value), int.Parse(this.pageSize.Value), out infoCount); } else { infoCount = 0; } this.infoCount.Value = infoCount.ToString(); this.infosView.DataBind(); } else if (int.TryParse(this.Request.QueryString["infoid"], out id)) { InfoManager infoManager = new InfoManager("EFConnectionString"); InfoEntity info = infoManager.Get(id); int nodeId = info.NodeId; NodeManager nodeManager = new NodeManager("EFConnectionString"); NodeEntity node = nodeManager.Get(nodeId); if (string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings[string.Format(updatePageString, node.ApplicationId.ToString())])) { this.Response.Write("<script>alert('配置出错!请联系程序猿!');</script>"); this.Response.Write("<script>window.location = 'info_manager.aspx';</script>"); } else { this.Response.Redirect(ConfigurationManager.AppSettings[string.Format(updatePageString, node.ApplicationId.ToString())] + "?infoid=" + id); } } else { this.Response.Write("<script>alert('参数错误!');</script>"); this.Response.Write("<script>window.location = 'info_manager.aspx';</script>"); } }
public StringCardCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"StringCard"); Key = page.Find(@"Key").NodeValue; Value = page.Find(@"Value").NodeValue; TagInputList = page.Find(@"TagInputList").NodeValue; RegisterButton = page.Find(@"RegisterButton").NodeValue; }
public QueryStringInputCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"QueryStringInput"); ExecuteButton = page.Find(@"ExecuteButton").NodeValue; BeginButton = page.Find(@"BeginButton").NodeValue; CommitButton = page.Find(@"CommitButton").NodeValue; RollbackButton = page.Find(@"RollbackButton").NodeValue; }
public FileBrowseCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"FileBrowse"); PasswordInput = page.Find(@"PasswordInput").NodeValue; BrowseButton = page.Find(@"BrowseButton").NodeValue; NewFileButton = page.Find(@"NewFileButton").NodeValue; FilePathOutput = page.Find(@"FilePathOutput").NodeValue; }
public CloneCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"Clone"); PasswordInput = page.Find(@"PasswordInput").NodeValue; SelectFileButton = page.Find(@"SelectFileButton").NodeValue; RunButton = page.Find(@"RunButton").NodeValue; FilePathOutput = page.Find(@"FilePathOutput").NodeValue; }
public override void LogNodeHealthState(NodeEntity node) { AppendToFile( string.Format( "LogNodeHealthState: ClusterName: {0}, NodeName:{3} HealthState: {1}, EvaluationString: {2}", node.ClusterName, node.Health.AggregatedHealthState.ToString(), node.Health.GetHealthEvaluationString(), node.NodeName)); }
public async Task Initialize() { client = new SmugMugClient(new OAuthToken(API_KEY, API_SECRET, OAUTH_TOKEN, OAUTH_SECRET)); var rootNode = await client.GetRootNodeAsync(); var childrenNodes = await client.GetNodeChildrenAsync(rootNode); brendaHoffmanFolder = childrenNodes.FirstOrDefault(n => n.NodeID == "mVVhcs"); Bethany5kNodes = await client.GetNodeChildrenAsync(brendaHoffmanFolder); }
public BinaryCardCaptions(NodeEntity n) { var lang = n.Find(@"SettingDef").Find(@"Language").NodeValue; var page = n.Find(@"SettingDef").Find(@"Localization").Find(lang).Find(@"BinaryCard"); Key = page.Find(@"Key").NodeValue; FileNameOutput = page.Find(@"FileNameOutput").NodeValue; TagInputList = page.Find(@"TagInputList").NodeValue; RetrieveFileButton = page.Find(@"RetrieveFileButton").NodeValue; SelectFileButton = page.Find(@"SelectFileButton").NodeValue; RegisterButton = page.Find(@"RegisterButton").NodeValue; }
public virtual void LogNodeHealthEvent(NodeEntity node, EntityHealthEvent healthEvent) { MonitoringEventSource.Current.LogNodeHealthEvent( node.ClusterName, node.NodeName, healthEvent.HealthState.ToString(), healthEvent.Description, healthEvent.Property, healthEvent.SequenceNumber.ToString(), healthEvent.SourceId, healthEvent.IsExpired.ToString()); }