public Ac4yXMLObject LoadXmlById(int id)
        {
            Ac4yXMLObject a = null;

            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                var query = ctx.Ac4yXMLObjects
                            .Where(ss => ss.id == id)
                            .FirstOrDefault <Ac4yXMLObject>();

                a = query;
            }

            string xml = a.serialization;

            Ac4yXMLObject aResult = null;

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

            StringReader reader = new StringReader(xml);

            aResult = (Ac4yXMLObject)serializer.Deserialize(reader);
            reader.Close();

            return(aResult);
        }
        public void addNew(Ac4yXMLObject _Ac4yXMLObject)
        {
            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.Ac4yXMLObjects.Add(_Ac4yXMLObject);

                ctx.SaveChanges();
            }
        }
        public Ac4yXMLObject findFirstById(int id)
        {
            Ac4yXMLObject a = null;

            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                var query = ctx.Ac4yXMLObjects
                            .Where(ss => ss.id == id)
                            .FirstOrDefault <Ac4yXMLObject>();

                a = query;
            }
            return(a);
        }
        public void SaveWithXml(Ac4yXMLObject _Ac4yXMLObject)
        {
            string xml = "";

            XmlSerializer serializer   = new XmlSerializer(typeof(Ac4yXMLObject));
            StringWriter  stringWriter = new StringWriter();
            XmlWriter     xmlWriter    = XmlWriter.Create(stringWriter);

            serializer.Serialize(xmlWriter, _Ac4yXMLObject);

            xml = stringWriter.ToString();

            _Ac4yXMLObject.serialization = xml;

            using (var ctx = new AllContext(serverName, baseName, userName, password))
            {
                ctx.Ac4yXMLObjects.Add(_Ac4yXMLObject);

                ctx.SaveChanges();
            }
        }
Example #5
0
        public GetObjectResponse SaveWithXml(Ac4yXMLObject _Ac4yXMLObject)
        {
            var response = new GetObjectResponse();

            try
            {
                _Ac4yXMLObjectEntityMethods.SaveWithXml(_Ac4yXMLObject);
                response.Result = new Ac4yProcessResult()
                {
                    Code = "1"
                };
            }
            catch (Exception exception)
            {
                response.Result = (new Ac4yProcessResult()
                {
                    Code = "-1", Message = exception.Message
                });
            }

            return(response);
        }