public void WakeupProcessor(NodeMethod methodProcessorType) { switch (methodProcessorType) { case NodeMethod.Submit: WakeProcessors <SubmitProcessor>(); break; case NodeMethod.Solicit: WakeProcessors <SolicitProcessor>(); break; case NodeMethod.Task: WakeProcessors <TaskProcessor>(); break; case NodeMethod.Schedule: WakeProcessors <ScheduleProcessor>(); break; case NodeMethod.Notify: WakeProcessors <NotifyProcessor>(); break; case NodeMethod.Execute: WakeProcessors <ExecuteProcessor>(); break; default: throw new ArgumentException(string.Format("Unrecognized methodProcessorType: {0}", methodProcessorType.ToString())); } }
private Activity MapActivity(IDataReader reader) { int index = 0; string id = reader.GetString(index++); string activityTypeString = reader.GetString(index++); ActivityType type = EnumUtils.ParseEnum <ActivityType>(activityTypeString); string transactionId = reader.GetString(index++); string ip = reader.GetString(index++); string nodeMethodString = reader.GetString(index++); NodeMethod method = EnumUtils.ParseEnum <NodeMethod>(nodeMethodString); string flowName = reader.GetString(index++); string operation = reader.GetString(index++); Activity activity = new Activity(method, flowName, operation, type, transactionId, ip, null, null); activity.Id = id; activity.ModifiedById = reader.GetString(index++); activity.ModifiedOn = reader.GetDateTime(index++); if (activity.Method == NodeMethod.None) { if (activityTypeString == OldAdminAuthType) { activity.Method = NodeMethod.AdminLogin; } } return(activity); }
/// <summary> /// Validate NAAS token /// </summary> /// <param name="securityToken"></param> /// <param name="clientHostIP"></param> /// <returns></returns> public string Validate( string securityToken, string clientHostIP, NodeMethod method) { return(Validate(securityToken, clientHostIP, method, null, null)); }
private bool ValidateTransaction(EndpointVersionType endpointVersion, NodeMethod transactionWebMethod, ComplexContent content, bool doValidateFlowOperation, string flowId, out string networkId) { networkId = null; string dbOperation; NodeMethod webMethod; bool isNetworkTransactionId = false; string transactionFlowId; TransactionStatus transactionStatus = TransactionManager.GetTransactionStatus(content.Transaction.Id, out transactionFlowId, out dbOperation, out webMethod); if (transactionStatus == null) { transactionStatus = TransactionManager.GetTransactionStatusByNetworkId(content.Transaction.Id, out transactionFlowId, out dbOperation, out webMethod); if (transactionStatus == null) { throw FaultProvider.GetFault(endpointVersion, ENExceptionCodeType.E_TransactionId, "Transaction \"{0}\" was not found", content.Transaction.Id); } isNetworkTransactionId = true; } if (transactionFlowId != flowId) { throw FaultProvider.GetFault(endpointVersion, ENExceptionCodeType.E_InvalidDataflow, "Flow operation \"{0}\" is not valid for transaction \"{1}\"", content.Flow.Operation, content.Transaction.Id); } if (doValidateFlowOperation && !string.Equals(dbOperation, content.Flow.Operation ?? string.Empty, StringComparison.InvariantCultureIgnoreCase)) { throw FaultProvider.GetFault(endpointVersion, ENExceptionCodeType.E_InvalidDataflow, "Flow operation \"{0}\" is not valid for transaction \"{1}\"", content.Flow.Operation, content.Transaction.Id); } if ((transactionWebMethod == NodeMethod.Submit) && (webMethod != NodeMethod.Submit)) { // Create new transaction and reference the input transaction id as the network id for // the new transcation networkId = content.Transaction.Id; } if (networkId != null) { content.Transaction.Id = string.Empty; return(true); } else { if (isNetworkTransactionId) { // Use the "real" db transcation id content.Transaction.Id = transactionStatus.Id; } return(false); } }
public ActionVm(NodeMethod target) { this.Name = target.Name; this.DisplayName = target.DisplayName; this.Url = target.Url; this.RequestType = target.ParameterType.FullName; this.ResponseType = target.ResultType.FullName; }
internal NodeMethodParameter(NodeMethod nodeMethod, MethodInfo mi, ParameterInfo parameterInfo, int order) { _nodeMethod = nodeMethod; _mi = mi; _parameterInfo = parameterInfo; Parent = nodeMethod; Order = order; }
private string LogMessage(NodeMethod method, string flowName, ActivityType type, NodeVisit visit, string messageFormat, params object[] args) { Activity activity = new Activity(method, flowName, null, type, null, (visit == null) ? string.Empty : visit.IP, messageFormat, args); activity.ModifiedById = (visit == null) ? AccountManager.AdminAccount.Id : visit.Account.Id; return(Log(activity)); }
public string LogAudit(NodeMethod method, string flowName, string operation, string transactionId, NodeVisit visit, string messageFormat, params object[] args) { Activity activity = new Activity(method, flowName, operation, ActivityType.Audit, transactionId, (visit == null) ? string.Empty : visit.IP, messageFormat, args); activity.ModifiedById = (visit == null) ? AccountManager.AdminAccount.Id : visit.Account.Id; return(Log(activity)); }
/// <summary> /// Make a generic Endpoint visit /// </summary> /// <typeparam name="T"></typeparam> /// <param name="visit"></param> /// <returns>Activity</returns> protected void AuthenticateEndpointActivity(AuthEndpointVisit visit, ActivityType activityType, NodeMethod method, out NodeVisit nodeVisit, out string userToken, out Activity activity) { if (visit == null) { throw new ArgumentNullException("visit"); } activity = new Activity(method, null, null, activityType, null, visit.IP, "Visit from endpoint version {0} for method {1}.", visit.Version, method.ToString()); UserAccount userAccount = AccountManager.GetByName(visit.Credentials.UserName); if ((userAccount != null) && !userAccount.IsActive) { var message = string.Format("The user account \"{0}\" is not active on this node.", visit.Credentials.UserName); activity.AppendFormat(message); throw new ArgumentException(message); } activity.AppendFormat("Attempting to authenticate {0} from IP {1} using {2}.", visit.Credentials.UserName, visit.IP, visit.AuthMethod); // Get a token or fail trying userToken = AuthProvider.AuthenticateUser(visit.Credentials, visit.IP, visit.AuthMethod); activity.AppendFormat("Successfully authenticated {0} with user token {1}.", visit.Credentials.UserName, userToken); //Always returns an account bool wasCreated; userAccount = AccountManager.GetOrCreate(visit.Credentials.UserName, true, out wasCreated); //Update the activity to created by the current user activity.ModifiedById = userAccount.Id; IDictionary <string, string> flowsIdToNameMap = _flowManager.GetAllFlowsIdToNameMap(); nodeVisit = new NodeVisit(userAccount, visit.IP, flowsIdToNameMap); if (wasCreated) { activity.AppendFormat("Successfully created local user account for {0}.", visit.Credentials.UserName); } else { activity.AppendFormat("Successfully got local user account for {0}.", visit.Credentials.UserName); } }
public string LogError(NodeMethod method, string flowName, string operation, ActivityType type, Exception exception, NodeVisit visit, string messageFormat, params object[] args) { Activity activity = new Activity(method, flowName, operation, type, null, (visit == null) ? string.Empty : visit.IP, messageFormat, args); activity.ModifiedById = (visit == null) ? AccountManager.AdminAccount.Id : visit.Account.Id; activity.AppendFormat("EXCEPTION: {0}", ExceptionUtils.GetDeepExceptionMessage(exception)); return(Log(activity)); }
public void DoRemoteTransactionStatusNotifications(NodeMethod transactionMethod, string filePath, TransactionStatus status, string flowName, string operation, string emailAddresses) { SendNotificationsPriv(flowName, status.Id, emailAddresses, RemoteTransactionStatusKey, _remoteTransactionStatusSubjectLine, (Stream)null, (string)null, new string[] { DateTime.Now.ToString(), status.Id.ToString(), status.Status.ToString(), AdminInterfaceUrl, status.Id.ToString() }); }
/// <summary> /// Validate NAAS token /// </summary> /// <param name="securityToken"></param> /// <param name="clientHostIP"></param> /// <returns></returns> public string Validate( string securityToken, string clientHostIP, NodeMethod method, string flowCode, string serviceName) { try { NAAS_CLIENT.Validate req = new NAAS_CLIENT.Validate(); req.clientIp = clientHostIP; req.credential = _naasRuntimeCredential.Password; req.domain = _naasRuntimeCredentialDomain; req.securityToken = securityToken; req.userId = _naasRuntimeCredential.UserName; if (method == NodeMethod.None) { req.resourceURI = string.Empty; } else { // TODO: Need to format req.resourceURI based upon input flowCode and serviceName req.resourceURI = string.Format( "{0}?node={1}&method={2}&request={3}¶ms={4}", "http://localhost/Node2008Endpoint/Service.asmx", NodeId, method.ToString().ToLower(), string.IsNullOrEmpty(serviceName) ? "any" : serviceName.ToLower().Trim(), string.IsNullOrEmpty(flowCode) ? "any" : MakeFlowPolicyArg(flowCode)); throw new NotImplementedException("TODO: Needs to be implemented"); } NAAS_CLIENT.ValidateResponse resp = _naasClient.Validate(req); string account = resp.@return; if (string.IsNullOrEmpty(account)) { throw new ApplicationException("NAAS Returned an empty account"); } return(CleanUpNAASReturnedAccountName(account)); } catch (Exception ex) { #if DEBUG if (BypassNaasAuthenticateFailures) { return(_bypassNaasUserName); } #endif // DEBUG throw new ApplicationException("Invalid token", ex); } }
public Activity(NodeMethod nodeMethod, string flowName, string operation, ActivityType type, string transactionId, string Ip, string message, params object[] args) { _type = type; _transactionId = transactionId; _ip = Ip; _method = nodeMethod; _flowName = flowName; _flowOperation = operation; if (!string.IsNullOrEmpty(message)) { AppendFormat(message, args); } }
/// <summary> /// Make a generic Endpoint visit /// </summary> /// <typeparam name="T"></typeparam> /// <param name="visit"></param> /// <returns>Activity</returns> protected void MakeEndpointActivity(NamedEndpointVisit visit, ActivityType activityType, NodeMethod method, out NodeVisit nodeVisit, out Activity activity) { if (visit == null) { throw new ArgumentNullException("visit"); } activity = new Activity(method, null, null, activityType, null, visit.IP, "Visit from endpoint version {0} for method {1}.", visit.Version, method.ToString()); activity.AppendFormat("Attempting to validate user token {0} from IP {1}.", visit.Token, visit.IP); string username = AuthProvider.Validate(visit.Token, visit.IP); activity.AppendFormat("Successfully validated user token {0} with user name {1}.", visit.Token, username); bool wasCreated; UserAccount userAccount = AccountManager.GetOrCreate(username, true, out wasCreated); activity.ModifiedById = userAccount.Id; IDictionary <string, string> flowsIdToNameMap = _flowManager.GetAllFlowsIdToNameMap(); nodeVisit = new NodeVisit(userAccount, visit.IP, flowsIdToNameMap); if (wasCreated) { activity.AppendFormat("Successfully created local user account for {0}.", username); } else { activity.AppendFormat("Successfully got local user account for {0}.", username); } }
protected void ValidateUserPermissions(NodeVisit nodeVisit, string flowName, string serviceName, NodeMethod webMethod, Activity activity) { bool hasPermission = nodeVisit.IsFlowPermittedByName(flowName, FlowRoleType.Endpoint); if (!hasPermission) { string message = string.Format("User \"{0}\" is not authorized to access the flow \"{1}\"", nodeVisit.Account.NaasAccount, flowName); activity.AppendFormat("Raising exception: " + message); throw new UnauthorizedAccessException(message); } if (string.IsNullOrEmpty(serviceName)) { activity.AppendFormat("User {0} authorized for flow {1} and method {2}", nodeVisit.Account.NaasAccount, flowName, webMethod.ToString()); } else { activity.AppendFormat("User {0} authorized for flow {1} and operation {2} and method {3}", nodeVisit.Account.NaasAccount, flowName, serviceName, webMethod.ToString()); } }
public string LogInfo(NodeMethod method, string flowName, NodeVisit visit, string messageFormat, params object[] args) { return(LogMessage(method, flowName, ActivityType.Info, visit, messageFormat, args)); }
public string LogError(NodeMethod method, string flowName, Exception exception, NodeVisit visit, string messageFormat, params object[] args) { return(LogError(method, flowName, ActivityType.Error, exception, visit, messageFormat, args)); }
public string LogAudit(NodeMethod method, string flowName, string transactionId, NodeVisit visit, string messageFormat, params object[] args) { return(LogAudit(method, flowName, null, transactionId, visit, messageFormat, args)); }
public bool IsEqual(SearchNode node2) { return(NodeMethod.IsEqual(this, node2)); }
public NotEnoughParametersForNodeMethodException(NodeMethod nodeMethod, IInvokeableParameter parameterInfo, object[] parameters) { NodeMethod = nodeMethod; ParameterInfo = parameterInfo; Parameters = parameters; }
private void FindWay(SearchNode startNode, SearchNode endNode) { List <SearchNode> openSet = new List <SearchNode>(); List <SearchNode> closeSet = new List <SearchNode>(); SearchNode currentNode = startNode; //find while (!currentNode.IsEqual(endNode)) { List <SearchNode> adjacentNode = currentNode.GetAdjacent(); for (int i = 0; i < adjacentNode.Count; i++) {//寻找附近的八个点 var tryNode = adjacentNode[i]; if (NodeMethod.ContainNode(closeSet, tryNode)) {//判断这个点是否走过 continue; } if (NodeMethod.ContainNode(openSet, tryNode)) {//判断这个点是否已经被添加到待走列表 //判断G值计算最近的点 var cur_g = currentNode.g + 1; if (cur_g < tryNode.g) { tryNode.parent = currentNode; tryNode.g = cur_g; tryNode.f = tryNode.g + tryNode.h; } } else {//如果这个点还没有走过 直接添加 tryNode.parent = currentNode; tryNode.h = Mathf.Abs(tryNode.pos.x - endNode.pos.x) + Mathf.Abs(tryNode.pos.y - endNode.pos.y); tryNode.g = currentNode.g + 1; tryNode.f = tryNode.g + tryNode.h; openSet.Add(tryNode); } } if (openSet.Count == 0) { break; } currentNode = NodeMethod.GetMinFNode(openSet); NodeMethod.RemoveNode(openSet, currentNode); closeSet.Add(currentNode); } //out if (currentNode.IsEqual(endNode)) { Stack <SearchNode> path = new Stack <SearchNode>();//翻转列表 SearchNode node = NodeMethod.GetNode(closeSet, endNode); while (node != null) { path.Push(node); node = node.parent; } string str = "Path is: "; node = path.Pop(); while (path.Count > 0) { str += node; node = path.Pop(); } str += endNode; Debug.Log(str); } else { Debug.Log("Can't find the way!"); } }
public bool IsValidPos() { return(NodeMethod.IsValidPos(pos)); }
public List <SearchNode> GetAdjacent() { return(NodeMethod.GetAdjacent(this)); }