Beispiel #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="onContext">Context with all the information about the execution of the request</param>
 /// <param name="className">Name of the class that represents the instance</param>
 /// <param name="idClass">Identificator of the class</param>
 public ONInstance(ONContext onContext, string className, string idClass)
 {
     ClassName = className;
     IdClass   = idClass;
     Oid       = null;
     Lmd       = ONDateTime.Null;
     Modified  = false;
     OnContext = onContext;
 }
Beispiel #2
0
 /// <summary>
 /// Method of Copy
 /// </summary>
 /// <param name="instance">Instance to be copied</param>
 public virtual void Copy(ONInstance instance)
 {
     if (instance != null)
     {
         OnContext = instance.OnContext;
         ClassName = instance.ClassName;
         if ((object)instance.Lmd.Value == null)
         {
             Lmd = null;
         }
         else if (instance.Lmd.Value == null)
         {
             Lmd = ONDateTime.Null;
         }
         else
         {
             Lmd = new ONDateTime(instance.Lmd.TypedValue);
         }
         Modified = instance.Modified;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Creates XML elements from the data of the system.
        /// </summary>
        /// <param name="xmlWriter">Object with the XML message to add new information and return to client side</param>
        /// <param name="val">Value to be puted inside the XML message</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        /// <param name="xmlElement">Element of the XML that is checked</param>
        public static void ON2XML(XmlWriter xmlWriter, ONDateTime val, double dtdVersion, string xmlElement)
        {
            if (val == null)
            {
                if (xmlElement == ONXml.XMLTAG_V)
                {
                    xmlWriter.WriteElementString(xmlElement, "");
                }
                else
                {
                    xmlWriter.WriteElementString(ONXml.XMLTAG_NULL, null);
                }
            }
            else
            {
                if (dtdVersion < 2.0)                 // Apply the locale format
                {
                    xmlWriter.WriteElementString(xmlElement, val.TypedValue.ToString());
                }
                else
                {
                    xmlWriter.WriteStartElement(xmlElement);
                    if (xmlElement == ONXml.XMLTAG_OIDFIELD && dtdVersion > 2.0)
                    {
                        xmlWriter.WriteAttributeString("Type", "datetime");
                    }

                    if (val.TypedValue.Millisecond == 0)
                    {
                        xmlWriter.WriteString(val.TypedValue.ToString("yyyy-MM-ddTHH:mm:ss"));
                    }
                    else
                    {
                        xmlWriter.WriteString(val.TypedValue.ToString("yyyy-MM-ddTHH:mm:ss.fff"));
                    }
                    xmlWriter.WriteEndElement();
                }
            }
        }