public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int id = 99999; AgentConfig agentConfig = new AgentConfig(); WeixinAgentItem weixinAgentItem = agentConfig.GetItem(id); if (weixinAgentItem != null) { string host = "http://" + HttpContext.Current.Request.Url.Host; string nonce_str = Util.GetRandomString(32, true, true, true, false, ""); string timestamp = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds).ToString(); string sn = weixinAgentItem.sn; Hashtable ht = new Hashtable(); ht.Add("nonce_str", nonce_str); ht.Add("timestamp", timestamp); ht.Add("id", id); string sign = GetSignX(ht, sn); string requestUrl = host + "/api/access_token/"; requestUrl += "?nonce_str=" + nonce_str + "×tamp=" + timestamp + "&id=" + id; requestUrl += "&sign=" + sign; context.Response.Write(HttpService.Get(requestUrl)); } else { context.Response.Write("示例配置记录不存在"); } }
public override void setUp() { base.setUp(); Adk.SifVersion = SifVersion.SIF15r1; fCfg = new AgentConfig(); fCfg.Read("..\\..\\Library\\Tools\\Mapping\\Destiny2.0.cfg", false); }
public virtual void setUp() { Adk.Initialize(); fCfg = new AgentConfig(); fCfg.Read("..\\..\\Library\\Tools\\Mapping\\SIF1.5.agent.cfg", false); }
private bool CheckConfig(int checkid) { bool check = false; AgentConfig agentConfig = new AgentConfig(); WeixinAgent weixinAgent = agentConfig.GetConfig(); foreach (WeixinAgentItem item in weixinAgent.agentItem) { int id = item.id; bool authorize = item.authorize; string begin = item.begin; //.ToString("yyyy-MM-dd"); string end = item.end; //.ToString("yyyy-MM-dd"); //logs.Fatal("url:"+ url + " checkurl:"+ checkurl+ " begin:"+ begin+ " end:"+ end); if (checkid == id && authorize) { check = DateTimeManger.Availability(DateTime.Parse(begin), DateTime.Parse(end), DateTime.Now); //logs.Fatal("check:" + check); if (check) { break; } } } return(check); }
public IEnumerator move_agent_to_vector2() { // Use the Assert class to test conditions. // Use yield to skip a frame. AgentConfig config = ScriptableObject.CreateInstance <AgentConfig>(); config.MovementSpeed = 1; config.UsesRigidbody2D = true; GameObject go = new GameObject(); Agents.Agent agent = go.AddComponent <Agents.Agent>(); go.AddComponent <Rigidbody2D>(); MoverFromInput mover = go.AddComponent <MoverFromInput>(); mover.Init(agent, config); go.transform.position = Vector2.zero; mover.Move(new Vector2(5, 5)); yield return(new WaitForSeconds(1f)); Assert.That((Vector2)go.transform.position != Vector2.zero); go.transform.position = Vector2.zero; go.GetComponent <Rigidbody2D>().AddForce(new Vector2(5, 5)); yield return(new WaitForSeconds(1f)); Assert.That((Vector2)go.transform.position != Vector2.zero); Debug.Log(go.transform.position); }
private void Application_Startup(object sender, StartupEventArgs e) { var mainPage = new MainPage(); mainPage.DataContext = new MainViewModel(AgentConfig.Load()); this.RootVisual = mainPage; }
private bool CheckConfig(string checkurl) { bool check = false; AgentConfig agentConfig = new AgentConfig(); WeixinAgent weixinAgent = agentConfig.GetConfig(); foreach (WeixinAgentItem item in weixinAgent.agentItem) { string url = item.url; bool signature = item.signature; string begin = item.begin; //.ToString("yyyy-MM-dd"); string end = item.end; //.ToString("yyyy-MM-dd"); //logs.Fatal("url:"+ url + " checkurl:"+ checkurl+ " begin:"+ begin+ " end:"+ end); if (checkurl == url && signature) { check = DateTimeManger.Availability(DateTime.Parse(begin), DateTime.Parse(end), DateTime.Now); //logs.Fatal("check:" + check); if (check) { break; } } } return(check); }
static bool Initialize(string configPath) { _logger.Debug("Initialize ..."); try { if (File.Exists(configPath)) { AgentConfig config = Utility.Read <AgentConfig>(configPath, true); foreach (TaskSequence sequence in config) { _sequence = sequence; break; } } else { _logger.Error("Agent Configuration [" + configPath + "] not found."); return(false); } } catch (Exception ex) { _logger.Error("Initialization failed: " + ex.Message, ex); return(false); } return(true); }
/// <summary> /// Create an instance using the Agent configuration file. /// </summary> /// <param name="agentConfig">Configuration file for the SIF Agent.</param> /// <exception cref="System.ArgumentException">agentConfig parameter is null.</exception> /// <exception cref="Systemic.Sif.Demo.Publishing.Database.AgentDbException">Database details missing from application configuration file.</exception> /// <exception cref="Systemic.Sif.Framework.Publisher.IteratorException">Error parsing mapping section of the Agent configuration file.</exception> public StudentPersonalIterator(AgentConfig agentConfig) { if (agentConfig == null) { throw new ArgumentException("agentConfig parameter is null."); } // Read the database connection details from the application configuration file. databaseDriver = ConfigurationManager.ConnectionStrings["database.demo"].ProviderName.Trim(); databaseConnectionString = ConfigurationManager.ConnectionStrings["database.demo"].ConnectionString.Trim(); if (String.IsNullOrEmpty(databaseDriver)) { throw new AgentDbException("No database driver specified."); } if (String.IsNullOrEmpty(databaseConnectionString)) { throw new AgentDbException("No database connection string provided"); } //if (log.IsDebugEnabled) log.Debug("Database driver specified: " + databaseDriver + "."); //if (log.IsDebugEnabled) log.Debug("Database connection string specified: " + databaseConnectionString + "."); mappings = agentConfig.Mappings.GetMappings("Default"); if (mappings == null) { throw new IteratorException("<mappings id=\"Default\"> has not been specified for Agent " + agentConfig.SourceId + "."); } students = GetRecords("select * from student where local_id = '1233493989'"); eventTotal = students.Count; responseTotal = students.Count; }
public ConfigViewModel(AgentConfig agentConfig) { m_AgentConfig = agentConfig; m_Nodes = new ObservableCollection <NodeConfig>(agentConfig.Nodes); m_Nodes.Add(new NewNodeConfig()); SelectedNode = m_Nodes.First(); }
public override void setUp() { base.setUp(); Adk.SifVersion = fVersion; fCfg = new AgentConfig(); fCfg.Read(fFileName, false); }
void Start() { this.Generation = 0; this.AgentCount = 0; this.Config = this.gameObject.GetComponent <AgentConfig>(); this.Spawn(AgentPrefab, this.StartNumberOfAgents); }
/// <summary> /// Create an instance using the Agent configuration file. /// </summary> /// <param name="agentConfig">Configuration file for the SIF Agent.</param> /// <exception cref="System.ArgumentException">agentConfig parameter is null.</exception> /// <exception cref="Systemic.Sif.Framework.Publisher.IteratorException">Error parsing student details from the Agent configuration file.</exception> public StudentPersonalIterator(AgentConfig agentConfig) { if (agentConfig == null) { throw new ArgumentException("agentConfig parameter is null."); } Mappings mappings = agentConfig.Mappings.GetMappings("Default"); if (mappings == null) { throw new IteratorException("<mappings id=\"Default\"> has not been specified for Agent " + agentConfig.SourceId + "."); } objectMapping = mappings.GetObjectMapping(typeof(StudentPersonal).Name, true); if (objectMapping == null) { throw new IteratorException("An object mapping for StudentPersonal has not been specified for Agent " + agentConfig.SourceId + "."); } string xml = objectMapping.XmlElement.InnerXml; IElementDef elementDef = Adk.Dtd.LookupElementDef(objectMapping.ObjectType); try { studentPersonal = (StudentPersonal)sifParser.Parse(xml); } catch (AdkParsingException e) { throw new IteratorException("The following event message from StudentPersonalIterator has parsing errors: " + xml + ".", e); } }
public void testCopyMappingsThroughDOM() { AgentConfig cfg = createMappings(); Mappings m = cfg.Mappings; Mappings newRoot = getCopyFromDOM(m.GetMappings("Test")); assertMappings(newRoot); }
void Start() { agentController = GetComponent <AgentController>(); utils = GetComponent <AgentUtils>(); config = agentController.config; ball = GameObject.Find("Ball").transform; }
public AgentConfig <TAgent> ConfigureAgentType <TAgent>() where TAgent : IAgent { var type = typeof(TAgent); var ac = new AgentConfig <TAgent>(); _agentConfigs.Add(type, ac as AgentConfig <IAgent>); return(ac); }
public void Init(Agents.Agent _agent, AgentConfig _config, Tile _currentTile) { config = _config; currentTile = _currentTile; agent = _agent; movementSpeed = config.MovementSpeed; detectionSphere = transform.GetChild(0).transform; detectionSphere.localScale *= agent.DetectionRange + 2; }
/// <summary> /// Create an instance of the Subscriber based upon the Agent configuration settings. /// </summary> /// <param name="agentConfig">Agent configuration settings.</param> /// <exception cref="System.ArgumentException">agentConfig parameter is null.</exception> public WithDependentsCachingSubscriber(AgentConfig agentConfig) : base(agentConfig) { agentConfig.GetAgentProperties(agentProperties); if (log.IsDebugEnabled) { log.Debug("Subscriber " + this.GetType().Name + " has a cache expiry period of " + ExpiryPeriod + " and expiry strategy of " + ExpiryStrategy + "."); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; AgentConfig agentConfig2 = new AgentConfig(); List <WeixinAgentItem> items2 = agentConfig2.GetItems(); context.Response.Write("countB:" + items2.Count + "\n\r"); }
public Agent(string apiKey) { logger = new Logger(); agentConfig = new AgentConfig(); cloudHealthAPI = new API(agentConfig, apiKey); quitEvent = new ManualResetEvent(false); perfMonitor = new PerformanceCollector(AgentInfo.GetAgentInfo().Identifier); intendedExitCode = 0; }
void Start() { world = FindObjectOfType <World>(); agentConfig = FindObjectOfType <AgentConfig>(); position = transform.position; //Add an initial velocity for test purposes velocity = new Vector3(UnityEngine.Random.Range(-3, 3), 0, UnityEngine.Random.Range(-3, 3)); }
/// <summary> /// Creates the baby agent using the frame lifes as a heuristic for how well it has performed, i.e. lifetime /// </summary> /// <param name="birthPosition">Birth position.</param> /// <param name="configOne">Config one.</param> /// <param name="frameLifeOne">Frame life one.</param> /// <param name="configTwo">Config two.</param> /// <param name="frameLifeTwo">Frame life two.</param> public void CreateChild(Vector2 birthPosition, AgentConfig configOne, int frameLifeOne, AgentConfig configTwo, int frameLifeTwo) { // Add to agents World.Instance.IncrementAgentCount(); // Instantiate new agent GameObject agent = Instantiate(this.Agent, birthPosition, Quaternion.identity) as GameObject; // Get config of agent AgentConfig newConfig = agent.GetComponent <AgentConfig>(); // Get likelihood of component one versus component two int componentLikeliHood = frameLifeOne / (frameLifeOne + frameLifeTwo); // Get fields of class System.Reflection.FieldInfo[] fields = newConfig.GetType().GetFields(); // loop through fields for (int i = 0; i < fields.Length; ++i) { // Check field if (!fields[i].Name.Equals("MaxAcceleration") && !fields[i].Name.Equals("MaxVelocity")) { // create new value float newVal; // Check if gene will mutate if (UnityEngine.Random.Range(0, 100) < this.MutationPercentage) { // Check if a radius or weight if (fields[i].Name.Contains("Radius")) { newVal = UnityEngine.Random.Range(0, AgentConfig.MaxRadius); } else { newVal = UnityEngine.Random.Range(0, AgentConfig.MaxWeight); } } else { // pick new val based on percentage from other if (UnityEngine.Random.Range(0, 100) / 100 > componentLikeliHood) { newVal = (float)fields[i].GetValue(configTwo); } else { newVal = (float)fields[i].GetValue(configOne); } } // set the value fields[i].SetValue(newConfig, newVal); } } }
// Start is called before the first frame update void Start() { world = FindObjectOfType <World>(); configuration = FindObjectOfType <AgentConfig>(); position = transform.position; velocity = new Vector3(Random.Range(-3, 3), 0, Random.Range(-3, 3)); //debugWanderCube = GameObject.CreatePrimitive(PrimitiveType.Cube); }
//public GameObject debugCube; // Use this for initialization void Start() { world = FindObjectOfType <World> (); conf = FindObjectOfType <AgentConfig> (); position = transform.position; velocity = new Vector3(Random.Range(-3, 3), 0, Random.Range(-3, 3)); //debugCube = Instantiate(debugCube); }
private AgentConfig createConfig(String cfg) { String fileName = "AdvancedMappings.cfg"; writeConfig(cfg, fileName); AgentConfig config = new AgentConfig(); config.Read(fileName, false); return(config); }
/// <summary> /// Initializes a new instance of the <see cref="CreateBrokerRequest" /> class. /// </summary> /// <param name="brokerName">The broker name.</param> /// <param name="agentName">Name of the agent.</param> /// <param name="agentConfig">The agent configuration.</param> public CreateBrokerRequest(string brokerName, string agentName, AgentConfig agentConfig) { Contract.Requires <ArgumentNullException>(brokerName != null, "brokerName"); Contract.Requires <ArgumentNullException>(agentConfig != null, "agent"); Contract.Requires <ArgumentNullException>(agentName != null, "agentName"); BrokerName = brokerName; AgentName = agentName; AgentConfig = agentConfig; }
/// <summary> /// Adds the agent location on which the message was processed. /// </summary> /// <param name="a">The agent configuration containing information about the agent.</param> internal void AddAgentLocation(AgentConfig a) { if (a == null) { throw new ArgumentNullException(nameof(a)); } AgentName = a.Name; AgentType = a.Type; }
public void setUp() { if (!Adk.Initialized) { Adk.Initialize( ); } Adk.SifVersion = fVersion; fCfg = new AgentConfig(); fCfg.Read("..\\..\\Library\\Tools\\Mapping\\SASI2.0.cfg", false); }
/// <summary> /// Create an instance of the Publisher based upon the Agent configuration settings. /// </summary> /// <param name="agentConfig">Agent configuration settings.</param> /// <exception cref="System.ArgumentException">agentConfig parameter is null.</exception> public GenericPublisher(AgentConfig agentConfig) { if (agentConfig == null) { throw new ArgumentException("agentConfig parameter is null."); } AgentConfiguration = agentConfig; AgentConfiguration.GetAgentProperties(agentProperties); }
/// <summary> Initialize and start the agent /// </summary> /// <param name="args">Command-line arguments (run with no arguments to display help) /// </param> public virtual void StartAgent(string[] args) { Console.WriteLine("Initializing agent..."); // Read the configuration file fCfg = new AgentConfig(); Console.Out.WriteLine("Reading configuration file..."); fCfg.Read("agent.cfg", false); // Override the SourceId passed to the constructor with the SourceId // specified in the configuration file Id = fCfg.SourceId; // Inform the ADK of the version of SIF specified in the sifVersion= // attribute of the <agent> element SifVersion version = fCfg.Version; Adk.SifVersion = version; // Now call the superclass initialize once the configuration file has been read base.Initialize(); // Ask the AgentConfig instance to "apply" all configuration settings // to this Agent; for example, all <property> elements that are children // of the root <agent> node are parsed and applied to this Agent's // AgentProperties object; all <zone> elements are parsed and registered // with the Agent's ZoneFactory, and so on. // fCfg.Apply(this, true); // Create the logging object fLogger = new ObjectLogger(this); // Now, connect to all zones and just get the zone status foreach (IZone zone in ZoneFactory.GetAllZones()) { if (getChameleonProperty(zone, "logRaw", false)) { zone.Properties.KeepMessageContent = true; zone.AddMessagingListener(fLogger); // Set this class as the recipient of all SIF_ZoneStatus // query results zone.SetQueryResults(this, InfraDTD.SIF_ZONESTATUS); } // Provision the logger class to log all QueryResults zone.Connect(ProvisioningFlags.Register); } // On a seperate thread, go through the exercise of getting the // SIF_ZoneStatus object from all zones AsyncUtils.QueueTaskToThreadPool(new SimpleMethod(GetZoneStatus)); }
private AgentConfig createConfig(String cfg) { String fileName = "AdvancedMappings.cfg"; writeConfig(cfg, fileName); AgentConfig config = new AgentConfig(); config.Read(fileName, false); return config; }
/// <summary> Initialize and start the agent /// </summary> /// <param name="args">Command-line arguments (run with no arguments to display help) /// /// </param> public virtual void startAgent(string[] args) { Name = "SIFWorks ADK Example"; Console.WriteLine("Initializing agent..."); // Read the configuration file fCfg = new AgentConfig(); Console.WriteLine("Reading configuration file..."); fCfg.Read("agent.cfg", false); // Override the SourceId passed to the constructor with the SourceId // specified in the configuration file Id = fCfg.SourceId; // Inform the ADK of the version of SIF specified in the sifVersion= // attribute of the <agent> element SifVersion version = fCfg.Version; //SifVersion version = SifVersion.SIF15r1; Adk.SifVersion = version; // Now call the superclass initialize once the configuration file has been read base.Initialize(); // // Ask the AgentConfig instance to "apply" all configuration settings // to this Agent; for example, all <property> elements that are children // of the root <agent> node are parsed and applied to this Agent's // AgentProperties object; all <zone> elements are parsed and registered // with the Agent's ZoneFactory, and so on. // fCfg.Apply(this, true); // Establish the ODBC connection to the Students.mdb database file. // The JDBC driver and URL are specified in the agent.cfg configuration // file and were automatically added to the AgentProperties when the // apply method was called above. // Console.WriteLine("Opening database..."); AgentProperties props = Properties; string driver = props.GetProperty("Connection"); string url = props.GetProperty("ConnectionString"); Console.WriteLine("- Using driver: " + driver); Console.WriteLine("- Connecting to URL: " + url); // Load the DataDriver driver // Get a Connection fConn = (IDbConnection)ClassFactory.CreateInstance(driver); fConn.ConnectionString = url; // Connect to each zone specified in the configuration file, registering // this agent as the Provider of StudentPersonal objects. Once connected, // send a request for StudentPersonal. // Console.WriteLine("Connecting to zones and requesting StudentPersonal objects..."); IZone[] allZones = ZoneFactory.GetAllZones(); for (int i = 0; i < allZones.Length; i++) { try { // Connect to this zone Console.WriteLine ("- Connecting to zone \"" + allZones[i].ZoneId + "\" at " + allZones[i].ZoneUrl); allZones[i].SetPublisher(this, StudentDTD.STUDENTPERSONAL, null); allZones[i].SetQueryResults(this); allZones[i].Connect(ProvisioningFlags.Register); // Request all students Query q = new Query(StudentDTD.STUDENTPERSONAL); q.UserData = "Mappings Demo"; allZones[i].Query(q); } catch (AdkException ex) { Console.WriteLine(" " + ex.Message); } } }