Exemplo n.º 1
0
        public HeaderXML MontarHeaderXML(string xmlDocForm)
        {
            var headerXML = new HeaderXML();

            XmlSerializer serializer = new XmlSerializer(typeof(HeaderXML));

            using (TextReader reader = new StringReader(xmlDocForm))
            {
                headerXML = (HeaderXML)serializer.Deserialize(reader);
            }

            return(headerXML);
        }
        public bool InserirHeaderXML(HeaderXML pw)
        {
            bool status = true;

            using (SqlConnection conn = GetConnection())
            {
                try
                {
                    string queryString = "InsertHeaderXML";

                    SqlCommand cm = new SqlCommand(queryString, conn);

                    //Header
                    cm.Parameters.Add("@EventType", SqlDbType.Int).Value              = pw.EventType;
                    cm.Parameters.Add("@EventDate", SqlDbType.Date).Value             = pw.EventDate;
                    cm.Parameters.Add("@EventDateAge", SqlDbType.Int).Value           = pw.EventDateAge;
                    cm.Parameters.Add("@EventDateFromEpoch", SqlDbType.VarChar).Value = pw.EventDateFromEpoch;
                    cm.Parameters.Add("@EntryType", SqlDbType.Int).Value              = pw.EntryType;
                    cm.Parameters.Add("@EntryGuid", SqlDbType.Date).Value             = pw.EntryGuid;
                    cm.Parameters.Add("@EntryDate", SqlDbType.Int).Value              = pw.EntryDate;
                    cm.Parameters.Add("@EntryDateAge", SqlDbType.VarChar).Value       = pw.EntryDateAge;
                    cm.Parameters.Add("@EntryDateFromEpoch", SqlDbType.VarChar).Value = pw.EntryDateFromEpoch;
                    cm.Parameters.Add("@EntrySource", SqlDbType.VarChar).Value        = pw.EntrySource;

                    foreach (var item in pw.entryLocation)
                    {
                    }


                    cm.CommandType = CommandType.Text;
                    conn.Open();

                    cm.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {
                    status = false;
                    Console.WriteLine(Ex);
                }
                finally
                {
                    conn.Close();
                }
            }

            return(status);
        }