/// <summary> /// Parses the SIF Version from the version attribute or namespace. If not able /// to parse the version, the default version is returned. /// </summary> /// <param name="reader"></param> /// <param name="dtd"></param> /// <param name="zone"></param> /// <param name="flags"></param> /// <param name="defaultVersion"></param> /// <returns></returns> private SifVersion ParseVersion( XmlReader reader, IDtd dtd, IZone zone, SifParserFlags flags, SifVersion defaultVersion) { SifVersion version; String verAttr = reader.GetAttribute("Version"); // Order of precedence: // 1) Version attribute of message // 2) The version passed in (if not null) // 3) The namespace version (if able to parse) // 4) The ADK SIF Version if (verAttr != null) { version = SifVersion.Parse(verAttr); } else if (defaultVersion != null) { version = defaultVersion; } else { String namespc = reader.NamespaceURI; version = SifVersion.ParseXmlns(namespc); if (version == null) { version = Adk.SifVersion; } } // Do validation on the version if (!Adk.IsSIFVersionSupported(version)) { throw new SifException( SifErrorCategoryCode.Generic, SifErrorCodes.GENERIC_VERSION_NOT_SUPPORTED_3, string.Format("SIF {0} not supported", version.ToString()), reader.NamespaceURI, zone); } else if (zone != null && zone.Properties.StrictVersioning) { if (version.CompareTo(Adk.SifVersion) != 0) { throw new SifException( SifErrorCategoryCode.Generic, SifErrorCodes.GENERIC_VERSION_NOT_SUPPORTED_3, "SIF " + version.ToString() + " message support disabled by this agent", string.Format("This agent is running in strict SIF {0} mode", Adk.SifVersion.ToString()), zone); } } return(version); }
public static StaffAssignment CreateStaffAssignment() { StaffAssignment sa = new StaffAssignment(Adk.MakeGuid(), Adk.MakeGuid(), 2008, Adk.MakeGuid(), YesNo.YES); sa.Description = "Description of this Assignment"; sa.EmployeePersonalRefId = Adk.MakeGuid(); sa.GradeClassification = new GradeClassification(GradeClassificationCode.POSTSECONDARY); return(sa); }
/// <summary> Initialize the Adk to use the specified version of SIF. /// /// Calling this method when the Adk has already been initialized has no effect. /// /// This method must be called at agent startup to initialize /// various resources of the Adk, establish global settings for the /// class framework, and set the default version of SIF to which /// all messages originating from the agent will conform. /// /// Beginning with Adk 1.5.0, this method also configures the global /// Adk <c>ServerLog</c> instance with a logging module that /// will be inherited by the ServerLog of all zones. It installs a /// single logging module implementation: <c>DefaultServerLogModule</c>. /// The behavior of this module is to report SIF_LogEntry objects to /// the zone integration server via an Add SIF_Event message whenever /// <c>ServerLog.reportLogEntry</c> is called on a zone and /// the agent is running in SIF 1.5 or later. DefaultServerLogModule /// also echos server log messages to the zone's local logging framework Category /// so that agents do not need to duplicate logging to both the server /// and local agent log. If you want to install a custom <i>ServerLogModule</i> /// implementation -- or need to adjust the settings of the default /// module installed when the Adk is initialized -- call the /// <c>Adk.getServerLog</c> method to obtain a reference to the /// root of the <c>ServerLog</c> chain, then call its methods /// to add and remove modules. Refer to the ServerLog class for more /// information on server logging. /// /// </summary> /// <param name="version">The version of SIF that will be used by the agent this /// session. Supported versions are enumerated by constants of the /// <see cref="OpenADK.Library.SifVersion"/> class. Once initialized, /// the version cannot be changed. /// </param> /// <param name="sdoLibraries">One or more of the constants defined by the SdoLibrary /// class, identifying the SIF Data Object libraries to be loaded into /// memory (e.g. SdoLibraryType.STUDENT | SdoLibraryType.HR ) /// /// </param> /// <exception cref="AdkException">If the ADK cannot be initialized</exception> /// <exception cref="OpenADK.Library.AdkNotSupportedException"> AdkNotSupportedException is thrown if the specified SIF /// version is not supported by the Adk, or if the <i>sdoLibraries</i> /// parameter is invalid /// </exception> public static void Initialize(SifVersion version, SIFVariant dataModel, int sdoLibraries) { if (Initialized) { return; } // TODO: This code could be done in more of a modular way so that it // doesn't need to be hand-edited each time a new SIFVariant is added. if (dataModel == SIFVariant.SIF_US) { sDtd = new OpenADK.Library.us.SifDtd(); } else if (dataModel == SIFVariant.SIF_UK) { sDtd = new OpenADK.Library.uk.SifDtd(); } else if (dataModel == SIFVariant.SIF_AU) { sDtd = new OpenADK.Library.au.SifDtd(); } //if (dataModel == null) //{ // Console.Out.WriteLine("ERROR - No variant DTD loaded"); //} //else //{ Console.Out.WriteLine("Using datamodel - " + dataModel.ToString("G")); //} try { InitLogging(); } catch (Exception e) { Console.Out.WriteLine(e); } if (version == null) { throw new ArgumentException("SifVersion cannot be null"); } sSingleton = new Adk(); // the default formatter for String APIs in the ADK is the SIF 1.x formatter // for backwards compatibility sSingleton.fDefaultFormatter = SifDtd.SIF_1X_FORMATTER; // // Set up the ServerLog // ServerLog sl = ServerLog; if (sl != null) { sl.AddLogger(new DefaultServerLogModule()); } // HTTP and HTTPS transports always available TransportPlugin tp = new HttpTransportPlugin(); sSingleton.fTransports[tp.Protocol] = tp; tp = new HttpsTransportPlugin(); sSingleton.fTransports[tp.Protocol] = tp; if (Debug != AdkDebugFlags.None) { sLog.Debug("Using Adk " + AdkVersion); } sSingleton.fVersion = version; //Dtd.LoadLibraries(sdoLibraries); ((DTDInternals)Dtd).LoadLibraries((int)sdoLibraries); }
/// <summary> Initialize the Adk to use the specified version of SIF. /// /// Calling this method when the Adk has already been initialized has no effect. /// /// This method must be called at agent startup to initialize /// various resources of the Adk, establish global settings for the /// class framework, and set the default version of SIF to which /// all messages originating from the agent will conform. /// /// Beginning with Adk 1.5.0, this method also configures the global /// Adk <c>ServerLog</c> instance with a logging module that /// will be inherited by the ServerLog of all zones. It installs a /// single logging module implementation: <c>DefaultServerLogModule</c>. /// The behavior of this module is to report SIF_LogEntry objects to /// the zone integration server via an Add SIF_Event message whenever /// <c>ServerLog.reportLogEntry</c> is called on a zone and /// the agent is running in SIF 1.5 or later. DefaultServerLogModule /// also echos server log messages to the zone's local logging framework Category /// so that agents do not need to duplicate logging to both the server /// and local agent log. If you want to install a custom <i>ServerLogModule</i> /// implementation -- or need to adjust the settings of the default /// module installed when the Adk is initialized -- call the /// <c>Adk.getServerLog</c> method to obtain a reference to the /// root of the <c>ServerLog</c> chain, then call its methods /// to add and remove modules. Refer to the ServerLog class for more /// information on server logging. /// /// </summary> /// <param name="version">The version of SIF that will be used by the agent this /// session. Supported versions are enumerated by constants of the /// <see cref="OpenADK.Library.SifVersion"/> class. Once initialized, /// the version cannot be changed. /// </param> /// <param name="sdoLibraries">One or more of the constants defined by the SdoLibrary /// class, identifying the SIF Data Object libraries to be loaded into /// memory (e.g. SdoLibraryType.STUDENT | SdoLibraryType.HR ) /// /// </param> /// <exception cref="AdkException">If the ADK cannot be initialized</exception> /// <exception cref="OpenADK.Library.AdkNotSupportedException"> AdkNotSupportedException is thrown if the specified SIF /// version is not supported by the Adk, or if the <i>sdoLibraries</i> /// parameter is invalid /// </exception> public static void Initialize(SifVersion version, SIFVariant dataModel, int sdoLibraries) { if (Initialized) { return; } // TODO: This code could be done in more of a modular way so that it // doesn't need to be hand-edited each time a new SIFVariant is added. if (dataModel == SIFVariant.SIF_US) { sDtd = new OpenADK.Library.us.SifDtd(); } else if (dataModel == SIFVariant.SIF_UK) { sDtd = new OpenADK.Library.uk.SifDtd(); } else if (dataModel == SIFVariant.SIF_AU) { sDtd = new OpenADK.Library.au.SifDtd(); } //if (dataModel == null) //{ // Console.Out.WriteLine("ERROR - No variant DTD loaded"); //} //else //{ Console.Out.WriteLine("Using datamodel - " + dataModel.ToString("G")); //} try { InitLogging(); } catch (Exception e) { Console.Out.WriteLine(e); } if (version == null) { throw new ArgumentException("SifVersion cannot be null"); } sSingleton = new Adk(); // the default formatter for String APIs in the ADK is the SIF 1.x formatter // for backwards compatibility sSingleton.fDefaultFormatter = SifDtd.SIF_1X_FORMATTER; // // Set up the ServerLog // ServerLog sl = ServerLog; if (sl != null) { sl.AddLogger(new DefaultServerLogModule()); } // HTTP and HTTPS transports always available TransportPlugin tp = new HttpTransportPlugin(); sSingleton.fTransports[tp.Protocol] = tp; tp = new HttpsTransportPlugin(); sSingleton.fTransports[tp.Protocol] = tp; if (Debug != AdkDebugFlags.None) { sLog.Debug("Using Adk " + AdkVersion); } sSingleton.fVersion = version; //Dtd.LoadLibraries(sdoLibraries); ((DTDInternals)Dtd).LoadLibraries((int)sdoLibraries); }