コード例 #1
0
        //[HttpPost]
        public JsonResult GetReportData(GetTicketsVM model)
        {
            var checkCookie = PreventiveMaintenanceManager.getCookie("LtpaToken2", "LtpaToken2");

            checkCookieExistence(checkCookie);
            var response = PreventiveMaintenanceManager.getReportData(model);

            if (!response.Contains("error"))
            {
                var obj    = JsonConvert.DeserializeObject <List <GetTicketsVM> >(response);
                var result = new JsonResult
                {
                    Data = obj
                };
                return(Json(new { success = true, data = obj }));
            }
            else
            {
                return(Json(new { success = false, data = response }));
            }
        }
コード例 #2
0
        public static string getReportData(GetTicketsVM model)
        {
            //StringBuilder whereClause = new StringBuilder();
            //if(model.sitecode != null || model.sitecode != "")
            //{
            //    whereClause.Append("sitecode=" + model.sitecode);
            //}
            //if(model.)
            List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();

            model.sitecode           = model.sitecode ?? "";
            model.ttstatus           = model.ttstatus ?? "";
            model.rbu                = model.rbu ?? "";
            model.mbu                = model.mbu ?? "";
            model.commregion         = model.commregion ?? "";
            model.approvalstatus     = model.approvalstatus ?? "";
            model.issueStartTimeFrom = model.issueStartTimeFrom ?? "";
            model.issueStartTimeTo   = model.issueStartTimeTo ?? "";
            if (model.sitecode != "")
            {
                parameters.Add(new KeyValuePair <string, string>("sitecode", model.sitecode));
            }
            if (model.ttstatus != "")
            {
                parameters.Add(new KeyValuePair <string, string>("ttstatus", model.ttstatus));
            }
            if (model.rbu != "")
            {
                parameters.Add(new KeyValuePair <string, string>("rbu", model.rbu));
            }

            if (model.mbu != "")
            {
                parameters.Add(new KeyValuePair <string, string>("mbu", model.mbu));
            }
            if (model.commregion != "")
            {
                parameters.Add(new KeyValuePair <string, string>("commregion", model.commregion));
            }
            if (model.approvalstatus != "")
            {
                parameters.Add(new KeyValuePair <string, string>("approvalstatus", model.approvalstatus));
            }
            if (model.issueStartTimeFrom != "")
            {
                parameters.Add(new KeyValuePair <string, string>("issuestarttimeFrom", model.issueStartTimeFrom));
            }
            if (model.issueStartTimeTo != "")
            {
                parameters.Add(new KeyValuePair <string, string>("issuestarttimeTo", model.issueStartTimeTo));
            }

            StringBuilder where = new StringBuilder();
            for (int i = 0; i < parameters.Count(); i++)
            {
                if (i == 0)
                {
                    if (parameters[i].Key == "issuestarttimeFrom")
                    {
                        where.Append(string.Format("issuestarttime>=\"{0}\"", parameters[i].Value));
                    }
                    //else if (parameters[i].Key == "issuestarttimeTo")
                    //{
                    //    where.Append(string.Format(" and issuestarttime<\"{0}\"", parameters[i].Value));
                    //}
                    else
                    {
                        where.Append(string.Format(parameters[i].Key + "=\"{0}\"", parameters[i].Value));
                    }
                }
                else
                {
                    if (parameters[i].Key == "issuestarttimeFrom")
                    {
                        where.Append(string.Format(" and issuestarttime>=\"{0}\"", parameters[i].Value));
                    }
                    else if (parameters[i].Key == "issuestarttimeTo")
                    {
                        where.Append(string.Format(" and issuestarttime<=\"{0}\"", parameters[i].Value));
                    }
                    else
                    {
                        where.Append(string.Format(" and " + parameters[i].Key + "=\"{0}\"", parameters[i].Value));
                    }
                }
            }
            var whereClause = "oslc.where=" + where.ToString();
            //string whereClause = string.Format("sitecode=\"{0}\" and ttstatus=\"{1}\" and rbu=\"{2}\" and mbu=\"{3}\" and comregion=\"{4}\" and approvalstatus=\"{5}\"",model.sitecode,model.ttstatus,model.rbu,model.mbu,model.comregion,model.approvalstatus);
            var selectClause = "oslc.select=*";
            //var pageSize = "oslc.pageSize=100";
            var orderBy  = "oslc.orderBy=-issuestarttime";
            var response = ApiRequest("/maximo/oslc/os/tprime?" + selectClause + "&" + whereClause + "&_dropnulls=0", Method.GET, null, 0, null);

            //var response = ApiRequest("/maximo/oslc/os/prime?" + selectClause + "&" + whereClause + "&_dropnulls=0", Method.GET, null, 0, null);
            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var parseJson = JObject.Parse(response.Content);
                var data      = parseJson["rdfs:member"].ToString();
                return(data);
            }
            else
            {
                return(response.Content);
            }
        }