Esempio n. 1
0
        /// <summary>
        /// Grabs all the field info from a FM XML field node.
        /// </summary>
        /// <param name="theNode">The XML node representing a FileMaker field.</param>
        /// <returns>FMField struct</returns>
        public FMField PopulateFieldInfo(XmlNode theNode)
        {
            FMField temp = new FMField();

            if (theNode.Attributes.GetNamedItem("global").Value == "yes")
            {
                temp.Global = "yes";
            }
            else
            {
                // don't want to leave it null...
                temp.Global = "";
            }
            temp.Name = theNode.Attributes.GetNamedItem("name").Value;
            temp.RepetitionCount = Convert.ToInt32(theNode.Attributes.GetNamedItem("max-repeat").Value);
            temp.Result = theNode.Attributes.GetNamedItem("result").Value;
            temp.Type = theNode.Attributes.GetNamedItem("type").Value;

            return temp;
        }
Esempio n. 2
0
        /// <summary>
        /// Populates the dataset row with FM data, used in the XML parsing code to create a DataSet.
        /// </summary>
        /// <param name="row">The row to put the data in.</param>
        /// <param name="theField">The XML node representing the FileMaker field.</param>
        /// <param name="f">The FMField data element to put the parsed data in.</param>
        /// <returns>DataRow with FM data</returns>
        public static DataRow PopulateRow(DataRow row, XmlNode theField, FMField[] f, String TimeStampFormat, String DateFormat)
        {
            /* now loop through all the fields in the record
             * and add the data to the row */

            String theName = theField.Attributes.GetNamedItem("name").Value;
            String currentType = "";
            for (int y = 0; y < f.Length; y++)
            {
                if (f[y].Name == theName)
                {
                    currentType = f[y].Result;
                    break;
                }
            }

            try
            {

                // add the data to the row ...
                if (theField.HasChildNodes)
                {
                    String theData = theField.FirstChild.InnerText;
                    if (theData.Length > 0)
                    {
                        // MessageBox.Show(theName + " = " + field.FirstChild.InnerText);
                        switch (currentType)
                        {
                            case "text":
                                row[theName] = theData;
                                break;
                            case "number":
                                // NB 9/18/2009 - Converted to TryParse to prevent errors on
                                // dirty data.
                                Double d = 0;
                                if (Double.TryParse(theData, out d))
                                {
                                    row[theName] = d;
                                }
                                else
                                {
                                    row[theName] = 0d;
                                }

                                //row[theName] = Convert.ToDouble(theData);    // ToInt32(theData);
                                break;
                            case "container":
                                row[theName] = theData;
                                break;
                            case "date":
                                //row[theName] = Convert.ToDateTime(theData);
                                row[theName] = ConvertToDate(theData, DateFormat);
                                break;
                            case "time":
                                // Change Koen Van Hulle - [email protected]
                                row[theName] = Convert.ToDateTime(theData);
                                break;
                            case "timestamp":
                                // Change Koen Van Hulle - [email protected]
                                //row[theName] = Convert.ToDateTime(theData);
                                row[theName] = ConvertToTimeStamp(theData, TimeStampFormat);
                                break;
                        }
                    } // if data length > 0
                } //  if field has child nodes

                return row;
            }
            catch (Exception ex)
            {
                ArgumentException ae = new ArgumentException(String.Format("Invalid data in {0}", theName), ex);
                throw ae;
            }
        }