コード例 #1
0
        // GET api/jsondata
        public HttpResponseMessage GetJson()
        {
            try
            {
                SqlQueries.Project_Main_Tbl sq = new SqlQueries.Project_Main_Tbl();
                DataTable dt = sq.GetAllCampaigns();

                if (dt == null)
                {
                    Logger.Debug("JsonDataController.GetJson: Sql Db Null Error");
                    return Request.CreateResponse(HttpStatusCode.InternalServerError, "No Data Found in Database");
                }
                if(dt.Rows.Count <= 0)
                {
                    Logger.Debug("JsonDataController.GetJson: Sql Db Empty Error");
                    return Request.CreateResponse(HttpStatusCode.InternalServerError, "No Data Found in Database");
                }

                string jsonString = JsonConvert.SerializeObject(dt);
                List<ProjectVM_Send> root = (List<ProjectVM_Send>)Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProjectVM_Send>>(jsonString);

                return Request.CreateResponse(HttpStatusCode.OK, root);

            }
            catch
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, "Exception Occuered While Retrieving Data");
            }
            //return JsonDeserializer.JsonFileDeserializer();
        }
コード例 #2
0
        // GET api/jsondata
        public HttpResponseMessage GetJson()
        {
            try
            {
                int redmineUserId ;
                AccountsServices ac = new AccountsServices();
                string auth = ac.CheckToken(Request);
                if (string.IsNullOrEmpty(auth))
                    return Request.CreateResponse(HttpStatusCode.Unauthorized, false);//"Unauthorized access");
                else if (auth.Contains("Exception"))
                    return Request.CreateResponse(HttpStatusCode.Unauthorized, false);//"Authentication error!! Please try again");
                else
                    int.TryParse(auth, out redmineUserId);

                SqlQueries.Project_Main_Tbl sq = new SqlQueries.Project_Main_Tbl();
                DataTable dt = sq.GetAllCampaigns(redmineUserId.ToString());

                if (dt == null)
                {
                    Logger.Debug("JsonDataController.GetJson: Sql Db Null Error");
                    return Request.CreateResponse(HttpStatusCode.OK, false);//"No Data Found in Database");
                }
                if (dt.Rows.Count <= 0)
                {
                    Logger.Debug("JsonDataController.GetJson: Sql Db Empty Error");
                    return Request.CreateResponse(HttpStatusCode.OK, false);//"No Data Found in Database");
                }

                string jsonString = JsonConvert.SerializeObject(dt);
                List<ProjectVM_Send> root = (List<ProjectVM_Send>)Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProjectVM_Send>>(jsonString);

                return Request.CreateResponse(HttpStatusCode.OK, root);

            }
            catch
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, false);//"Exception Occuered While Retrieving Data");
            }
            //return JsonDeserializer.JsonFileDeserializer();
        }