コード例 #1
0
ファイル: ConnectDB.cs プロジェクト: nofarelarat/childProject
        public async Task <symbol[]> GetUserCounterformDBAsync(symbol userSymbol)
        {
            string completeUri = "http://childappapiservice.azurewebsites.net/api/counters?email="
                                 + userSymbol.email + "&symbolName=" + userSymbol.symbolName;

            Uri requestUri = new Uri(completeUri);

            Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();

            //Send the GET request asynchronously and retrieve the response as a string.
            Windows.Web.Http.HttpResponseMessage httpResponse = new Windows.Web.Http.HttpResponseMessage();
            string httpResponseBody = "";

            try
            {
                //Send the GET request
                httpResponse = await httpClient.GetAsync(requestUri);

                httpResponse.EnsureSuccessStatusCode();
                httpResponseBody = await httpResponse.Content.ReadAsStringAsync();

                symbol[] userSymbolUsage = JsonConvert.DeserializeObject <symbol[]>(httpResponseBody);

                return(userSymbolUsage);
            }

            catch (Exception ex)
            {
                return(null);
            }
        }
コード例 #2
0
        public async Task <string> create_graphAsync(string combox)
        {
            symbol userSymbol = new symbol();

            userSymbol.email      = Common.myChild;
            userSymbol.symbolName = combox;
            symbol[] userSymbolUsage = await Common.GetUserCounterAsync(combox.ToString());

            string graph_values = "";

            int[] month_values = new int[12];
            if (userSymbolUsage != null)
            {
                for (int i = 0; i < userSymbolUsage.Length; i++)
                {
                    month_values[userSymbolUsage[i].date.Month - 1] += 1;
                }
            }
            for (int i = 0; i < 11; i++)
            {
                graph_values += month_values[i].ToString() + ",";
            }
            graph_values += month_values[11].ToString();
            return("http://chart.googleapis.com/chart?cht=bvg&chs=400x350&chxs=0,6699ff,12,0,lt|1,6699ff,10,1,lt&chxt=x,y&chxl=0:|Jan|Feb|Mar|Apr|May|June|July|Aug|Sep|Oct|Nov|Dec&chd=t:" + graph_values + "&chf=bg,s,&chco=3399ff");
        }
コード例 #3
0
ファイル: Common.cs プロジェクト: nofarelarat/childProject
        public static async Task <symbol[]> GetUserCounterAsync(string symbolName)
        {
            string child_email = myChild;

            symbol[]  res = null;
            ConnectDB db  = new ConnectDB();

            if (!who_am_i.Equals("") && !child_email.Equals(""))
            {
                symbol symbol = new symbol
                {
                    email      = child_email,
                    symbolName = symbolName,
                    date       = DateTime.Today
                };
                if (symbolName.Equals("allsymbols"))
                {
                    res = await db.GetUserAllCountersfromDBAsync(child_email);
                }
                else
                {
                    res = await db.GetUserCounterformDBAsync(symbol);
                }
            }
            return(res);
        }