コード例 #1
0
ファイル: CompanyModel.cs プロジェクト: KevinKao809/CDS10
        public async Task <CompanySession> GetCompanySessionData()
        {
            if (HttpContext.Current.Session["compSession"] == null)
            {
                RestfulAPIHelper apiHelper     = new RestfulAPIHelper();
                string           CompanyEntiry = await apiHelper.callAPIService("GET", Global._companyEndPoint, null);

                dynamic companyObj = JObject.Parse(CompanyEntiry);

                CompanySession compSession = new CompanySession();
                if (companyObj.ShortName != null)
                {
                    compSession.shortName = companyObj.ShortName;
                }
                else
                {
                    compSession.shortName = companyObj.Name;
                }

                compSession.name        = companyObj.Name;
                compSession.photoURL    = companyObj.LogoURL;
                compSession.allowDomain = companyObj.AllowDomain;
                compSession.id          = companyObj.Id;
                compSession.lat         = companyObj.Latitude;
                compSession.lng         = companyObj.Longitude;

                HttpContext.Current.Session["compSession"] = compSession.Serialize();
            }

            return(CompanySession.LoadByJsonString(HttpContext.Current.Session["compSession"].ToString()));
        }
コード例 #2
0
        private async Task Init_CertificateThumbprint(string certificateId)
        {
            RestfulAPIHelper apiHelper = new RestfulAPIHelper();
            string           endPoint  = Global._deviceCertificateEndPoint;

            endPoint = endPoint + "/" + certificateId;
            string jsonString = await apiHelper.callAPIService("get", endPoint, null);

            dynamic jsonResult = JObject.Parse(jsonString);

            this.certificateThumbprint = jsonResult.Thumbprint;
        }
コード例 #3
0
        private async Task Init_IoTHubConnectionString(string iotDeviceId)
        {
            RestfulAPIHelper apiHelper  = new RestfulAPIHelper();
            string           jsonString = null;
            dynamic          jsonResult = null;

            string endPoint_iotdevice = Global._iotDeviceEndPoint + "/" + iotDeviceId;

            jsonString = await apiHelper.callAPIService("get", endPoint_iotdevice, null);

            jsonResult = JObject.Parse(jsonString);
            string iotHubAlias = jsonResult.IoTHubAlias;

            string endPoint_iotHub = Global._iotHubEndPoint + "/" + iotHubAlias;

            jsonString = await apiHelper.callAPIService("get", endPoint_iotHub, null);

            jsonResult = JObject.Parse(jsonString);
            this.primaryIothubConnectionString   = jsonResult.P_IoTHubConnectionString;
            this.secondaryIothubConnectionString = jsonResult.S_IoTHubConnectionString;
        }
コード例 #4
0
        private async Task Init_oldIoTHubConnectionString(string iotHubAlias)
        {
            RestfulAPIHelper apiHelper = new RestfulAPIHelper();
            string           endPoint  = Global._iotHubEndPoint;

            endPoint = endPoint + "/" + iotHubAlias;
            string jsonString = await apiHelper.callAPIService("get", endPoint, null);

            dynamic jsonResult = JObject.Parse(jsonString);

            this.oldPrimaryIothubConnectionString   = jsonResult.P_IoTHubConnectionString;
            this.oldSecondaryIothubConnectionString = jsonResult.S_IoTHubConnectionString;
        }
コード例 #5
0
        private async Task Init_IoTDeviceKey()
        {
            RestfulAPIHelper apiHelper = new RestfulAPIHelper();
            string           endPoint  = Global._iotDeviceEndPoint;

            endPoint = endPoint + "/" + this.iothubDeviceId;
            string jsonString = await apiHelper.callAPIService("GET", endPoint, null);

            dynamic jsonResult = JObject.Parse(jsonString);

            this.iothubDeviceKey = jsonResult.IoTHubDeviceKey;
            if (string.IsNullOrEmpty(this.iothubDeviceKey))
            {
                this.iothubDeviceKey = GenerateIoTDeviceKey();
            }
        }