Exemple #1
0
        public async Task GetCompanies()
        {
            ArrayOfXElement elements = await serviceProxy.GetCompaniesAsync();

            foreach (XElement el in elements.Nodes)
            {
                var test = el.Value;
            }

            DataSet dataset = new DataSet();

            dataset.ReadXml(new System.IO.StringReader(elements.ToString()));

            if (!dataset.HasErrors)
            {
                Companies = new List <Models.Company>();
                foreach (DataRow row in dataset.Tables[0].Rows)
                {
                    Companies.Add(new Models.Company
                    {
                        ObjectID         = int.Parse(row["ObjectID"].ToString()),
                        Name             = row["Name"].ToString(),
                        NumberOfChildren = int.Parse(row["NumberOfChildren"].ToString()),
                    });
                }

                await Task.FromResult(1);
            }
            await Task.FromResult(0);
        }
Exemple #2
0
        public async Task GetMetersForSiteId(int?siteID)
        {
            Meters = new List <Models.Meter>();
            meter  = new MeterSoapClient(basicHttpBinding, basicendpoint);
            //meter.CookieContainer = cookieContainer;

            DataSet meterDataSet = new DataSet();

            if (siteID.HasValue)
            {
                ArrayOfXElement elements = await meter.GetMetersForSiteIDAsync(siteID.Value);

                meterDataSet = new DataSet();
                meterDataSet.ReadXml(new System.IO.StringReader(elements.ToString()));
            }
            else
            {
                ArrayOfXElement elements = await meter.GetMetersAsync();

                meterDataSet = new DataSet();
                meterDataSet.ReadXml(new System.IO.StringReader(elements.ToString()));
            }

            foreach (DataRow row in meterDataSet.Tables[0].Rows)
            {
                bool Enabled = false;
                bool.TryParse(row["Enabled"].ToString(), out Enabled);
                bool AMR = false;
                bool.TryParse(row["AMR"].ToString(), out AMR);
                Meters.Add(new Models.Meter
                {
                    AMR                = AMR,
                    ContractNumber     = row["ContractNumber"].ToString(),
                    DataImportCode     = row["DataImportCode"].ToString(),
                    Enabled            = Enabled,
                    MeterCode          = row["MeterCode"].ToString(),
                    MeterID            = int.Parse(row["MeterID"].ToString()),
                    MeterNumber        = row["MeterNumber"].ToString(),
                    MeterPrefix        = row["MeterPrefix"].ToString(),
                    MeterReadFrequency = row["MeterReadFrequency"].ToString(),
                    MeterType          = row["MeterType"].ToString(),
                    MeterTypeID        = int.Parse(row["MeterTypeID"].ToString()),
                    Name               = row["Name"].ToString(),
                    ParentID           = int.Parse(row["ParentID"].ToString()),
                    ParentTypeID       = int.Parse(row["ParentTypeID"].ToString()),
                    SerialNumber       = row["SerialNumber"].ToString(),
                    SiteMeterCode      = row["SiteMeterCode"].ToString(),
                    TypeID             = int.Parse(row["TypeID"].ToString()),
                });
            }
            await Task.FromResult(1);
        }