コード例 #1
0
        public IEnumerable <Model.Descendent> GetDescendents(Model.Organization parent)
        {
            long currentPage = 1;
            int  itemCount   = 0;

            do
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = BaseAddress;
                    var byteArray = Encoding.ASCII.GetBytes($"{ApiKey}:x");
                    client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

                    var result = client.GetAsync($"/organizations/{parent.Id}/descendents.xml?page={currentPage}").Result;
                    using (var stream = result.Content.ReadAsStreamAsync().Result)
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(DescendentCollection));
                        // resultContent = result.Content.ReadAsStringAsync().Result;
                        var orgs = (DescendentCollection)serializer.Deserialize(stream);
                        itemCount = orgs.Descendents.Count;
                        foreach (var org in orgs.Descendents)
                        {
                            yield return(new Model.Descendent(org));
                        }
                        currentPage++;
                    }
                }
            }while (itemCount != 100 && itemCount != 0);
        }
コード例 #2
0
 public View.Organization Build(Model.Organization organization)
 {
     return(new View.Organization
     {
         OrganizationGuid = organization.OrganizationGuid,
         OrganizationName = organization.OrganizationName,
         MaxDevices = organization.MaxDevices.ToString(),
         CreatedOn = organization.CreatedOn.ToString(),
         UpdatedOn = organization.UpdatedOn.ToString()
     });
 }
コード例 #3
0
        public OrganizationData(Model.Organization organization)
        {
            if (organization == null)
            {
                return;
            }

            ID               = organization.ID;
            Name             = organization.Name;
            FullName         = organization.FullName;
            INN              = organization.INN;
            OrganizationType = new OrganizationTypeData(organization.OrganizationType);
        }
コード例 #4
0
ファイル: XmlDao.cs プロジェクト: ixd2568/Project3
        /// <summary>
        /// Same, except for physicians
        /// </summary>
        /// <param name="organization"></param>
        /// <returns></returns>
        public List <Model.OrgPhysicians> getPhysicianSearchResults(Model.Organization organization)
        {
            string serializedForm = "";

            if (!organization.type.Equals(""))
            {
                serializedForm += "type=" + organization.type + "&";
            }
            if (!organization.name.Equals(""))
            {
                serializedForm += "name=" + organization.name + "&";
            }
            if (!organization.state.Equals(""))
            {
                serializedForm += "state=" + organization.state + "&";
            }
            if (!organization.city.Equals(""))
            {
                serializedForm += "town=" + organization.city + "&";
            }
            if (!organization.county.Equals(""))
            {
                serializedForm += "county=" + organization.county + "&";
            }
            if (!organization.zip.Equals(0))
            {
                serializedForm += "zip=" + organization.zip;
            }

            try
            {
                XmlSerializer  serializer = new XmlSerializer(typeof(Model.OrgPhysiciansList));
                HttpWebRequest request    = (HttpWebRequest)WebRequest.Create(DATA_URL + "Organizations?" + serializedForm);
                request.Method = "GET";
                Model.OrgPhysiciansList physicians = (Model.OrgPhysiciansList)serializer.Deserialize(((HttpWebResponse)request.GetResponse()).GetResponseStream());

                return(physicians.physicians);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #5
0
        public Model.Organization Get(Model.Organization org)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = BaseAddress;
                var byteArray = Encoding.ASCII.GetBytes($"{ApiKey}:x");
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

                var result = client.GetAsync($"/organizations/{org.Id}.xml").Result;
                using (var stream = result.Content.ReadAsStreamAsync().Result)
                {
                    XmlSerializer      serializer;
                    Model.Organization returnVal;
                    switch (org.Type)
                    {
                    case Model.OrganizationType.Division:
                        serializer = new XmlSerializer(typeof(Division));
                        returnVal  = new Model.Division((Division)serializer.Deserialize(stream));
                        break;

                    case Model.OrganizationType.Franchise:
                        serializer = new XmlSerializer(typeof(Franchise));
                        returnVal  = new Model.Franchise((Franchise)serializer.Deserialize(stream));
                        break;

                    case Model.OrganizationType.Franchisor:
                        serializer = new XmlSerializer(typeof(Franchisor));
                        returnVal  = new Model.Franchisor((Franchisor)serializer.Deserialize(stream));
                        break;

                    default:
                        throw new NotImplementedException($"The Entity {org.Type} is not supported");
                    }

                    // resultContent = result.Content.ReadAsStringAsync().Result;
                    return(returnVal);
                }
            }
        }
コード例 #6
0
 public Model.Technician GetTechnician(Model.Organization org, long techId)
 {
     return(GetTechnician(org.Id, techId));
 }
コード例 #7
0
 public Model.Technician GetTechnician(Model.Organization org, Model.Technician tech)
 {
     return(GetTechnician(org.Id, tech.Id));
 }
コード例 #8
0
 public Model.Job GetJob(Model.Organization org, long jobId)
 {
     return(GetJob(org.Id, jobId));
 }
コード例 #9
0
 public Model.Job GetJob(Model.Organization org, Model.Job job)
 {
     return(GetJob(org.Id, job.Id));
 }
コード例 #10
0
 public Boolean UpdateOrganization(Model.Organization organization)
 {
     organization.Update();
     return(true);
 }
コード例 #11
0
 public Object CreateOrganization(Model.Organization organization)
 {
     return(Newtonsoft.Json.JsonConvert.SerializeObject(organization.Create()));
 }