/// <summary>
        /// Get date attribute out of the byref parameter object.
        /// </summary>
        /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
        /// <param name="attributeName">The attribute name.</param>
        /// <returns>The date value from the OpenROAD parameter.</returns>
        public static DateTime GetDateAttribute(ORPDOClass pdo, string attributeName)
        {
            // Call underlying private method
            // DateTime dtm = (DateTime) ;
            object   oDtm = GetAttribute(pdo, attributeName);
            DateTime dtm  = Constants.OR_MIN_DATE_VALUE.Date;

            //If the attribute is of type DateTime, do a direct cast.
            if (oDtm is DateTime)
            {
                dtm = (DateTime)oDtm;
            }
            else
            {
                //otherwise, get the string representation and use TryParse.
                DateTime.TryParse((string)GetAttribute(pdo, attributeName), out dtm);
            }

            // Convert the time to co-ordinated local time
            dtm = dtm.ToLocalTime();

            // Perform the magic on the date conversion to prevent problems moving between OpenROAD and .NET
            // they have difference min value dates;
            if (dtm.Date == Constants.OR_MIN_DATE_VALUE.Date)
            {
                dtm = DateTime.MinValue;
            }

            return(dtm);
        }
        /// <summary>
        /// The underlying delegate method to get Attribute value
        /// </summary>
        /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
        /// <param name="attributeName">The attribute name.</param>
        /// <returns>The attribute value.</returns>
        public static object GetAttribute(ORPDOClass pdo, string attributeName)
        {
            object rtn;

            rtn = pdo.GetAttribute(attributeName);

            return(rtn);
        }
        /// <summary>
        /// Set an attribute on a PDO.
        /// </summary>
        /// <param name="pdo"></param>
        /// <param name="attributeName"></param>
        /// <param name="val"></param>
        public static void SetAttribute(ORPDOClass pdo, string attributeName, object val)
        {
            object objVal = val;
            if (val is DateTime)
            {
                // Convert Date & Time to UTC format as OpenROAD expects them in this format
                objVal = ((DateTime)val).ToUniversalTime();
            }

            pdo.SetAttribute(attributeName, ref val);
        }
        /// <summary>
        /// Set an attribute on a PDO.
        /// </summary>
        /// <param name="pdo"></param>
        /// <param name="attributeName"></param>
        /// <param name="val"></param>
        public static void SetAttribute(ORPDOClass pdo, string attributeName, object val)
        {
            object objVal = val;

            if (val is DateTime)
            {
                // Convert Date & Time to UTC format as OpenROAD expects them in this format
                objVal = ((DateTime)val).ToUniversalTime();
            }

            pdo.SetAttribute(attributeName, ref val);
        }
Esempio n. 5
0
        /// <summary>
        /// Populates itself based on the OSCA parameters in the ByRefPDO object
        /// </summary>
        /// <param name="byRefPDO"></param>
        public static void PopulateSelfFromByRef(ORPDOClass byRefPDO)
        {
            //Extract the OSCA parameters from the ByRef Class

            if (null != byRefPDO)
            {
                contextId   = (int)byRefPDO.GetAttribute("b_osca.i_context_id");
                errorNumber = (int)byRefPDO.GetAttribute("b_osca.i_error_no");
                errorType   = (int)byRefPDO.GetAttribute("b_osca.i_error_type");
                messageText = (string)byRefPDO.GetAttribute("b_osca.v_msg_txt");
                isEmpty     = false;
            }
        }
        /// <summary>
        /// Declare attribute parameters.
        /// </summary>
        protected virtual void DeclareAttributes()
        {
            // Declare the PDO's
            orByValParameter = new ORPDOClass();
            orByRefParameter = new ORPDOClass();

            //Declare OSCA
            orByRefParameter.DeclareAttribute("b_osca", Constants.OR_ASA_DATATYPE_USERCLASS);
            orByRefParameter.DeclareAttribute("b_osca.i_context_id", Constants.OR_ASA_DATATYPE_INTEGER);
            orByRefParameter.DeclareAttribute("b_osca.i_error_no", Constants.OR_ASA_DATATYPE_INTEGER);
            orByRefParameter.DeclareAttribute("b_osca.i_error_type", Constants.OR_ASA_DATATYPE_INTEGER);
            orByRefParameter.DeclareAttribute("b_osca.v_msg_txt", Constants.OR_ASA_DATATYPE_STRING);
        }
 /// <summary>
 /// Get string attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static string GetStringAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return((string)GetAttribute(pdo, attributeName));
 }
        /// <summary>
        /// The underlying delegate method to get Attribute value
        /// </summary>
        /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
        /// <param name="attributeName">The attribute name.</param>
        /// <returns>The attribute value.</returns>
        public static object GetAttribute(ORPDOClass pdo, string attributeName)
        {
            object rtn;

            rtn = pdo.GetAttribute(attributeName);

            return rtn;
        }
        /// <summary>
        /// Get date attribute out of the byref parameter object.
        /// </summary>
        /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
        /// <param name="attributeName">The attribute name.</param>
        /// <returns>The date value from the OpenROAD parameter.</returns>
        public static DateTime GetDateAttribute(ORPDOClass pdo, string attributeName)
        {
            // Call underlying private method
            // DateTime dtm = (DateTime) ;
            object oDtm = GetAttribute(pdo, attributeName);
            DateTime dtm = Constants.OR_MIN_DATE_VALUE.Date;

            //If the attribute is of type DateTime, do a direct cast.
            if (oDtm is DateTime)
            {
                dtm = (DateTime)oDtm;
            }
            else
            {
                //otherwise, get the string representation and use TryParse.
                DateTime.TryParse((string)GetAttribute(pdo, attributeName), out dtm);
            }

            // Convert the time to co-ordinated local time
            dtm = dtm.ToLocalTime();

            // Perform the magic on the date conversion to prevent problems moving between OpenROAD and .NET
            // they have difference min value dates;
            if (dtm.Date == Constants.OR_MIN_DATE_VALUE.Date)
            {
                dtm = DateTime.MinValue;
            }

            return dtm;
        }
 /// <summary>
 /// Get double attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static double GetDoubleAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return (double)GetAttribute(pdo, attributeName);
 }
 /// <summary>
 /// Gets decimal attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter"></param>
 /// <param name="attributeName"></param>
 /// <returns></returns>
 public static decimal GetDecimalAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return (decimal)GetAttribute(pdo, attributeName);
 }
 /// <summary>
 /// Get short attribute out of the ByRef parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static Int16 GetShortAttribute(ORPDOClass pdo, string attributeName)
 {
     return Convert.ToInt16(GetAttribute(pdo, attributeName));
 }
 /// <summary>
 /// Get boolean attribute out of the ByRef parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static bool GetBooleanAttribute(ORPDOClass pdo, string attributeName)
 {
     return(Convert.ToInt16(GetAttribute(pdo, attributeName)) == 1);
 }
 /// <summary>
 /// Declare an attribute on a PDO.
 /// </summary>
 /// <param name="pdo"></param>
 /// <param name="attributeName"></param>
 /// <param name="attributeType"></param>
 public static void DeclareAttribute(ORPDOClass pdo, string attributeName, string attributeType)
 {
     pdo.DeclareAttribute(attributeName, attributeType);
 }
 /// <summary>
 /// Get string attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static string GetStringAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return (string)GetAttribute(pdo, attributeName);
 }
 /// <summary>
 /// Get integer attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static int GetIntegerAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return((int)GetAttribute(pdo, attributeName));
 }
 /// <summary>
 /// Declare an attribute on a PDO.
 /// </summary>
 /// <param name="pdo"></param>
 /// <param name="attributeName"></param>
 /// <param name="attributeType"></param>
 public static void DeclareAttribute(ORPDOClass pdo, string attributeName, string attributeType)
 {
     pdo.DeclareAttribute(attributeName, attributeType);
 }
 /// <summary>
 /// Get short attribute out of the ByRef parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static Int16 GetShortAttribute(ORPDOClass pdo, string attributeName)
 {
     return(Convert.ToInt16(GetAttribute(pdo, attributeName)));
 }
 /// <summary>
 /// Gets decimal attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter"></param>
 /// <param name="attributeName"></param>
 /// <returns></returns>
 public static decimal GetDecimalAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return((decimal)GetAttribute(pdo, attributeName));
 }
 /// <summary>
 /// Get double attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static double GetDoubleAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return((double)GetAttribute(pdo, attributeName));
 }
 /// <summary>
 /// Get integer attribute out of the byref parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static int GetIntegerAttribute(ORPDOClass pdo, string attributeName)
 {
     // Call underlying private method
     return (int)GetAttribute(pdo, attributeName);
 }
Esempio n. 22
0
        /// <summary>
        /// Connect to the application server using the RSO method.
        /// </summary>
        private void ORConnectRSO()
        {
            //Ensure we have a Session.
            if (ORSession == null)
            {
                throw new SCPInvalidArgumentException(Constants.OR_SESSION_UNAVAILABLE_EXCEPTION_MESSAGE);
            }

            //If not connected then attempt to connect.
            if (ORSession.IsConnected == 0)
            {
                if (ImageName == null || ImageName.Length == 0)
                {
                    throw new SCPInvalidArgumentException(Constants.INVALID_AKA_NAME_EXCEPTION_MESSAGE);
                }

                //If location not provided then default to current machine.
                if (Location == null || Location.Length == 0)
                {
                    Location = System.Environment.MachineName;
                }

                //If routing not provided then default to empty string.
                if (Routing == null || Routing.Length == 0)
                {
                    Routing = "";
                }

                try
                {
                    // Find host by name
                    IPHostEntry iphostentry = Dns.GetHostEntry(Dns.GetHostName());

                    // Enumerate IP addresses
                    string ipAddress = "";
                    foreach (IPAddress ipaddress in iphostentry.AddressList)
                    {
                        ipAddress = ipaddress.ToString();
                    }

                    // Create OR ASO Session
                    ORRSOClass rso = new ORRSOClass();
                    ORPDOClass byVal = new ORPDOClass();
                    ORPDOClass byRef = new ORPDOClass();

                    ORSession.v_user_name = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                    ORSession.v_ip_address = ipAddress;
                    ORSession.i_user_id = -1;

                    object options = "0";
                    rso.UseASOLib = 1;
                    rso.Initiate(AKAName, Flags, Location, Routing, 0, ref options);

                    object remoteServer = rso;
                    ORSession.AttachRSO(ref remoteServer);
                }
                catch (Exception ex)
                {
                    throw new SCPConnectException(Constants.OR_SESSION_CONNECT_EXCEPTION_MESSAGE, ex);
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Declare attribute parameters.
        /// </summary>
        protected virtual void DeclareAttributes()
        {

            // Declare the PDO's
            orByValParameter = new ORPDOClass();
            orByRefParameter = new ORPDOClass();

            //Declare OSCA
            orByRefParameter.DeclareAttribute("b_osca", Constants.OR_ASA_DATATYPE_USERCLASS);
            orByRefParameter.DeclareAttribute("b_osca.i_context_id", Constants.OR_ASA_DATATYPE_INTEGER);
            orByRefParameter.DeclareAttribute("b_osca.i_error_no", Constants.OR_ASA_DATATYPE_INTEGER);
            orByRefParameter.DeclareAttribute("b_osca.i_error_type", Constants.OR_ASA_DATATYPE_INTEGER);
            orByRefParameter.DeclareAttribute("b_osca.v_msg_txt", Constants.OR_ASA_DATATYPE_STRING);
        }
 /// <summary>
 /// Get boolean attribute out of the ByRef parameter object.
 /// </summary>
 /// <param name="useByValParameter">Flag to indicate which PDO to use.</param>
 /// <param name="attributeName">The attribute name.</param>
 /// <returns>The value from the OpenROAD parameter.</returns>
 public static bool GetBooleanAttribute(ORPDOClass pdo, string attributeName)
 {
     return Convert.ToInt16(GetAttribute(pdo, attributeName)) == 1;
 }
Esempio n. 25
0
        /// <summary>
        /// Populates itself based on the OSCA parameters in the ByRefPDO object
        /// </summary>
        /// <param name="byRefPDO"></param>
        public static void PopulateSelfFromByRef(ORPDOClass byRefPDO)
        {
            //Extract the OSCA parameters from the ByRef Class

            if (null != byRefPDO)
            {
                contextId = (int)byRefPDO.GetAttribute("b_osca.i_context_id");
                errorNumber = (int)byRefPDO.GetAttribute("b_osca.i_error_no");
                errorType = (int)byRefPDO.GetAttribute("b_osca.i_error_type");
                messageText = (string)byRefPDO.GetAttribute("b_osca.v_msg_txt");
                isEmpty = false;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Connect to the application server using the RSO method.
        /// </summary>
        private void ORConnectRSO()
        {
            //Ensure we have a Session.
            if (ORSession == null)
            {
                throw new SCPInvalidArgumentException(Constants.OR_SESSION_UNAVAILABLE_EXCEPTION_MESSAGE);
            }

            //If not connected then attempt to connect.
            if (ORSession.IsConnected == 0)
            {
                if (ImageName == null || ImageName.Length == 0)
                {
                    throw new SCPInvalidArgumentException(Constants.INVALID_AKA_NAME_EXCEPTION_MESSAGE);
                }

                //If location not provided then default to current machine.
                if (Location == null || Location.Length == 0)
                {
                    Location = System.Environment.MachineName;
                }

                //If routing not provided then default to empty string.
                if (Routing == null || Routing.Length == 0)
                {
                    Routing = "";
                }

                try
                {
                    // Find host by name
                    IPHostEntry iphostentry = Dns.GetHostEntry(Dns.GetHostName());

                    // Enumerate IP addresses
                    string ipAddress = "";
                    foreach (IPAddress ipaddress in iphostentry.AddressList)
                    {
                        ipAddress = ipaddress.ToString();
                    }

                    // Create OR ASO Session
                    ORRSOClass rso   = new ORRSOClass();
                    ORPDOClass byVal = new ORPDOClass();
                    ORPDOClass byRef = new ORPDOClass();

                    ORSession.v_user_name  = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                    ORSession.v_ip_address = ipAddress;
                    ORSession.i_user_id    = -1;

                    object options = "0";
                    rso.UseASOLib = 1;
                    rso.Initiate(AKAName, Flags, Location, Routing, 0, ref options);

                    object remoteServer = rso;
                    ORSession.AttachRSO(ref remoteServer);
                }
                catch (Exception ex)
                {
                    throw new SCPConnectException(Constants.OR_SESSION_CONNECT_EXCEPTION_MESSAGE, ex);
                }
            }
        }