public static KpiModel GetCCDKpi(string projectname, string equipmentadress, string equipmenttype, string department)
        {
            KpiModel kpi = new KpiModel();

            try
            {
                string strsql = "";
                #region
                //if (projectname == "all")
                //{
                //    if (equipmentadress == "all")
                //        strsql = "SELECT * FROM kpi where CONVERT(VARCHAR(100), collecttime,23)=CONVERT (VARCHAR(10),GETDATE(),23)";
                //    else
                //        strsql = "select * from kpi WHERE CONVERT(VARCHAR(100), collecttime,23)=CONVERT (VARCHAR(10),GETDATE(),23) and equipmentadress='" + equipmentadress + "'";
                //}
                //else
                //    strsql = string.Format("SELECT * FROM kpi where  CONVERT(VARCHAR(100), collecttime,23)=CONVERT (VARCHAR(10),GETDATE(),23) {0} {1} {2}", projectname == "all" ? "" : " and projectname='" + projectname + "'", equipmentadress == "all" ? "" : "and  equipmentadress='" + equipmentadress + "'", equipmenttype == "all" ? "" : " and equipmenttype='" + equipmenttype + "'");
                //strsql = string.Format("SELECT * FROM kpi where  CONVERT(VARCHAR(100), collecttime,23)=CONVERT (VARCHAR(10),GETDATE(),23) {0} {1} {2}", projectname == "all" ? "" : " and projectname='" + projectname + "'", equipmentadress == "all" ? "" : "and  equipmentadress='" + equipmentadress + "'", equipmenttype == "all" ? "" : " and equipmenttype='" + equipmenttype + "'");
                #endregion
                strsql = string.Format("SELECT * FROM kpi where CONVERT(VARCHAR(100), collecttime,23)=CONVERT (VARCHAR(10),GETDATE(),23) and  1=1  {0} {1} {2} {3} ORDER BY CONVERT(VARCHAR(100),collecttime,23)  DESC", projectname == "all" ? "" : " and projectname='" + projectname + "'", equipmentadress == "all" ? "" : "and  equipmentadress='" + equipmentadress + "'", equipmenttype == "all" ? "" : " and equipmenttype='" + equipmenttype + "'", department == "all" ? "" : "and equipmentadress like '%" + department + "%'");
                List <itemKpiModel> kpiList = DBHelper.GetList <itemKpiModel>(strsql, null).ToList();
                kpi.ListKpi = kpiList;
            }
            catch (Exception)
            {
                throw;
            }
            return(kpi);
        }
        public Dashboard KpiDetails(Dashboard board, User user)
        {
            string url = WebConfigurationManager.AppSettings["ReportingServerURL"];

            board.KpiModel = new List <KpiModel>();
            //Get KPIs
            KpisApi kpiObj = new KpisApi(IO.Swagger.Client.Configuration.DefaultApiClient);

            var kpis = kpiObj.GetKpisString(0, 0, "", "", "", "", user.Username, user.Password, url);

            JObject jObject = JObject.Parse(kpis);

            int count = 0;

            if (((Newtonsoft.Json.Linq.JContainer)jObject.Last.Last).Count > 0)
            {
                foreach (var item in ((Newtonsoft.Json.Linq.JContainer)jObject.Last.Last).ToList())
                {
                    if (item.ToString().Substring(item.ToString().IndexOf("Path") + 9).StartsWith("Hoxworth"))
                    {
                        count++;
                        KpiModel model      = new KpiModel();
                        var      startIndex = item.ToString().IndexOf("Name");
                        startIndex = startIndex + 8;
                        var endINdex = item.ToString().IndexOf("Description");
                        endINdex   = endINdex - 7;
                        model.Name = item.ToString().Substring(startIndex, (endINdex - startIndex));

                        var values = item.ToString().Substring(item.ToString().IndexOf("Values"));
                        startIndex  = values.IndexOf("Value\":");
                        startIndex  = startIndex + 9;
                        endINdex    = values.ToString().IndexOf(",");
                        endINdex    = endINdex - 1;
                        model.Value = values.ToString().Substring(startIndex, (endINdex - startIndex));

                        //startIndex = values.IndexOf("Goal\":");
                        //startIndex = startIndex + 7;
                        //endINdex = values.ToString().IndexOf("Status");
                        //endINdex = endINdex - 8;
                        //model.Goal = values.ToString().Substring(startIndex, (endINdex - startIndex));

                        //int percentComplete = (int)Math.Round((double)(100 * Convert.ToDouble(model.Value)) / Convert.ToDouble(model.Goal));
                        //model.Percent = percentComplete + "%";

                        startIndex   = values.IndexOf("Status\":");
                        startIndex   = startIndex + 9;
                        endINdex     = values.ToString().IndexOf("TrendSet");
                        endINdex     = endINdex - 7;
                        model.Status = values.ToString().Substring(startIndex, (endINdex - startIndex));

                        board.KpiModel.Add(model);
                    }
                }
            }
            board.KpiCount = count;
            return(board);
        }
        public static KpiModel GetOutLine(string IsOnline, string department)
        {
            KpiModel kpi = new KpiModel();

            try
            {
                string strsql = string.Format("select * from kpi where CONVERT(VARCHAR(100), collecttime,23)!=CONVERT (VARCHAR(10),GETDATE(),23) {0}", department == "all" ? "" : "and equipmentadress like '%" + department + "%'");
                List <itemKpiModel> kpiList = DBHelper.GetList <itemKpiModel>(strsql, null).ToList();
                kpi.ListKpi = kpiList;
            }
            catch (Exception)
            {
                throw;
            }
            return(kpi);
        }