public HttpResponseMessage ProcessProgressInfo(HttpRequestMessage request) { return(GetHttpResponse(request, () => { HttpResponseMessage res = null; OtherInfo obj = new OtherInfo(); ProcessProgressModel processProgressInfo = obj.GetProcessProgressInfo(); res = request.CreateResponse(HttpStatusCode.OK, processProgressInfo); return res; })); }
} //========== end of the mtd public ProcessProgressModel GetProcessProgressInfo() { List <ProcessProgressTableModel> progressInfo = new List <ProcessProgressTableModel>(); ProcessProgressModel exProg = new ProcessProgressModel(); using (var con = new System.Data.SqlClient.SqlConnection(connectionString)) { var cmd = new System.Data.SqlClient.SqlCommand("spp_processprogressinfo", con); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandTimeout = 0; //cmd.Parameters.Add("@result", System.Data.SqlDbType.TinyInt).Direction = System.Data.ParameterDirection.Output; con.Open(); //cmd.ExecuteNonQuery(); //cmd2.ExecuteNonQuery(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { ProcessProgressTableModel pObj = new ProcessProgressTableModel(); // progressInfo.TotalCount = reader["teambankid"] != DBNull.Value ? int.Parse(reader["teambankid"].ToString()) : 0; pObj.PackageName = reader["processname"] != DBNull.Value ? reader["processname"].ToString() : ""; pObj.EstimatedTime = reader["EstimatedTime"] != DBNull.Value ? Convert.ToDateTime(reader["EstimatedTime"].ToString()) : Convert.ToDateTime("00:00:00.000"); pObj.Status = reader["Status"] != DBNull.Value ? reader["Status"].ToString() : ""; //pObj.Status = pObj.Status.ToUpper().Trim(); progressInfo.Add(pObj); } con.Close(); string status = "DONE"; exProg.TotalCount = progressInfo.Count(); exProg.CompletedPkgCount = progressInfo.Where(x => x.Status.ToUpper().Trim() == status).Count(); exProg.PackageName = progressInfo.Select(x => x.PackageName).FirstOrDefault(); exProg.EstimatedTimeString = progressInfo.Select(x => x.EstimatedTime).FirstOrDefault().ToString("HH:mm:ss"); //exProg.EstimatedTimeString = progressInfo.Select(x => x.EstimatedTime).FirstOrDefault().ToString("yyyy-MM-dd"); //string dt = DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss tt"); } return(exProg); } //========== end of the mtd