/** * This method shows how to connect to zones and hook up a basic message handler * @param args */ private void startAgent(string[] args) { this.Initialize(); NameValueCollection parameters = AdkExamples.parseCL(this, args); string zoneId = parameters["zone"]; string url = parameters["url"]; if (zoneId == null || url == null) { Console.WriteLine("The /zone and /url parameters are required"); Console.Beep(); throw new ArgumentException("The /zone and /url parameters are required"); } // 1) Get an instance of the zone to connect to IZone zone = ZoneFactory.GetInstance(zoneId, url); // 2) Create an instance of the the LearnerPersonalHandler class // This class is responsible for dealing with events and responses // received that contain LearnerPersonal data objects LearnerPersonalHandler sdh = new LearnerPersonalHandler(); // The LearnerPersonalHandler is allowed to provision itself with the zone sdh.provision(zone); // Connect zone.Connect(AdkExamples.Reg ? ProvisioningFlags.Register : ProvisioningFlags.None); // The LearnerPersonalHandler class has a sync() method, which it uses to // request data from the SIF zone sdh.sync(zone); }
private void StartAgent(String[] args) { this.Initialize(); NameValueCollection parameters = AdkExamples.parseCL(this, args); string zoneId = parameters["zone"]; string url = parameters["url"]; if( zoneId == null || url == null ) { Console.WriteLine("The /zone and /url parameters are required"); Environment.Exit(0); } // only for SIF_Register and versions in SIF_Request messages... // this.Properties.OverrideSifVersions = "2.3,2.*"; // only for SIF_Message Version attribute in SIF_Request messages // this.Properties.OverrideSifMessageVersionForSifRequests = "2.3"; // 1) Get an instance of the zone to connect to IZone zone = ZoneFactory.GetInstance(zoneId, url); zone.SetQueryResults( this ); // 2) Connect to zones zone.Connect( AdkExamples.Reg ? ProvisioningFlags.Register : ProvisioningFlags.None ); }
/** * This method shows how to connect to zones and hook up a basic message handler * @param args */ private void startAgent(string[] args) { Initialize(); NameValueCollection parameters = AdkExamples.parseCL(this, args); string zoneId = parameters["zone"]; string url = parameters["url"]; if (zoneId == null || url == null) { Console.WriteLine("The /zone and /url parameters are required"); Console.Beep(); throw new ArgumentException("The /zone and /url parameters are required"); } // 1) Get an instance of the zone to connect to IZone zone = ZoneFactory.GetInstance(zoneId, url); // 2) Create an instance of the the LearnerPersonalProvider class // This class is responsible for publishing LearnerPersonal LearnerPersonalProvider lpp = new LearnerPersonalProvider(); // The LearnerPersonalProvider is allowed to provision itself with the zone lpp.provision(zone); // 2) Create an instance of the the LearnerPersonalProvider class // This class is responsible for publishing LearnerPersonal WorkforcePersonalProvider wpp = new WorkforcePersonalProvider(); // The LearnerPersonalProvider is allowed to provision itself with the zone wpp.provision(zone); // Connect zone.Connect(AdkExamples.Reg ? ProvisioningFlags.Register : ProvisioningFlags.None); // The StudentPersonalProvider will periodically send changes to the StudentPersonal // objects if (parameters["events"] != null) { lpp.startEventProcessing(zone); } }
private void StartAgent(String[] args) { this.Initialize(); NameValueCollection parameters = AdkExamples.parseCL(this, args); string zoneId = parameters["zone"]; string url = parameters["url"]; if (zoneId == null || url == null) { Console.WriteLine("The /zone and /url parameters are required"); Environment.Exit(0); } // 1) Get an instance of the zone to connect to IZone zone = ZoneFactory.GetInstance(zoneId, url); zone.SetQueryResults(this); // 2) Connect to zones zone.Connect(AdkExamples.Reg ? ProvisioningFlags.Register : ProvisioningFlags.None); }
/** * This method shows how to connect to zones and hook up a basic message handler * @param args */ private void StartAgent(String[] args) { this.Initialize(); NameValueCollection parameters = AdkExamples.parseCL(this, args); // /url http://127.0.0.1:7080/test /zone test /pull /sourceID SimpleProvider String zoneId = parameters["zone"]; String url = parameters["url"]; if (zoneId == null || url == null) { Console.WriteLine("The /zone and /url parameters are required"); Environment.Exit(0); } // 1) Get an instance of the zone to connect to IZone zone = ZoneFactory.GetInstance(zoneId, url); // 2) Create an instance of the the StudentPersonalProvider class // This class is responsible for publishing LearnerPersonal StudentPersonalProvider lpp = new StudentPersonalProvider(); // The StudentPersonalProvider is allowed to provision itself with the zone lpp.Provision(zone); // 3) Connect to zones zone.Connect(AdkExamples.Reg ? ProvisioningFlags.Register : ProvisioningFlags.None); // The StudentPersonalProvider will periodically send changes to the StudentPersonal // objects if (parameters["events"] != null) { lpp.StartEventProcessing(zone); } }
private void _processSIF_ZoneStatus(SIF_ZoneStatus zoneStatus, IZone zone) { if (zoneStatus == null) { return; } bool sync = getChameleonProperty(zone, "sync", false); bool events = getChameleonProperty(zone, "logEvents", true); bool logEntry = getChameleonProperty(zone, "sifLogEntrySupport", false); fLogger.UseLogEntry = logEntry; string syncObjects = zone.Properties.GetProperty("chameleon.syncObjects"); ArrayList objectDefs = new ArrayList(); SIF_Providers providers = zoneStatus.SIF_Providers; if (providers != null) { foreach (SIF_Provider p in providers) { if (p.SIF_ObjectList != null) { foreach (SIF_Object obj in p.SIF_ObjectList) { // Lookup the topic for each provided object in the zone IElementDef def = Adk.Dtd.LookupElementDef(obj.ObjectName); if (def != null) { // Pull out just the objects specified according to configuration settings // or all, if the syncObjects setting is not specified if (syncObjects == null || (syncObjects.Length > 0 && syncObjects.IndexOf(def.Name) > -1)) { objectDefs.Add(def); if (events) { ITopic topic = TopicFactory.GetInstance(def); if (topic.GetSubscriber() == null) { topic.SetSubscriber(fLogger, null); } } } } } } } } if (logEntry) { ITopic sifLogEntryTopic = TopicFactory.GetInstance(InfraDTD.SIF_LOGENTRY); sifLogEntryTopic.SetSubscriber(fLogger, null); } // Disconnect the zone before provisioning zone.Disconnect(ProvisioningFlags.None); foreach (ITopic topic in TopicFactory.GetAllTopics(SifContext.DEFAULT)) { try { // Join the topic to each zone ( causes the agent to subscribe to the joined objects ) // TODO: Add an "isJoinedTo()" API to topic so that it doesn't throw an exception if (topic.ObjectType != InfraDTD.SIF_ZONESTATUS.Name) { topic.Join(zone); } } catch (Exception ex) { zone.Log.Error(ex.Message, ex); } } zone.Connect(ProvisioningFlags.Register); if (sync) { if (objectDefs.Count == 0) { zone.ServerLog.Log (LogLevel.WARNING, "No objects are being provided in this zone", null, "1001"); } foreach (IElementDef def in objectDefs) { if (def.IsSupported(Adk.SifVersion)) { Query q = new Query(def); // Query by specific parameters string condition = zone.Properties.GetProperty ("chameleon.syncConditions." + def.Name); if (condition != null && condition.Length > 0) { // The condition should be in the format "path=value" e.g "@RefId=123412341...1234|@Name=asdfasdf" String[] queryConditions = condition.Split('|'); foreach (String cond in queryConditions) { string[] conds = cond.Split('='); if (conds.Length == 2) { q.AddCondition(conds[0], "EQ", conds[1]); } } } if (logEntry) { zone.ServerLog.Log (LogLevel.INFO, "Requesting " + q.ObjectType.Name + " from the zone", q.ToXml(Adk.SifVersion), "1002"); } zone.Query(q); } else { String debug = "Will not request " + def.Name + " because it is not supported in " + Adk.SifVersion.ToString(); Console.WriteLine(debug); zone.ServerLog.Log(LogLevel.WARNING, debug, null, "1001"); } } } }