コード例 #1
0
ファイル: repository.cs プロジェクト: kamsriv/Tracking
        public WMDashboardInfoList GetChartData(FilterAndPagerInfo filterInfo)
        {
            WMDashboardInfoList objDash = new WMDashboardInfoList(FinTrackRes.WM_CHART_ERR_MSG, false);

            try
            {
                objDash.LstByProcAct = new List <WMDashboardInfo>();
                objDash.LstByProc    = new List <WMDashboardInfo>();
                objDash.LstByRevAct  = new List <WMDashboardInfo>();
                objDash.LstByRev     = new List <WMDashboardInfo>();

                using (SqlConnection con = new SqlConnection(conStr))
                {
                    con.Open();
                    using (SqlCommand cmd = new SqlCommand(StaticData.GET_DASHBOARD_DATA, con))
                    {
                        cmd.CommandType    = System.Data.CommandType.StoredProcedure;
                        cmd.CommandTimeout = 0;
                        //we can pass the start date if possible otherwise it will take the current date as start date.
                        if (filterInfo.Filters != null)
                        {
                            foreach (Filter key in filterInfo.Filters)
                            {
                                if (key != null && key.Key != null)
                                {
                                    cmd.Parameters.AddWithValue("@" + key.Key, key.Value);
                                }
                            }
                        }
                        SqlDataReader rdr = cmd.ExecuteReader();
                        //Processor data
                        while (rdr.Read())
                        {
                            objDash.LstByProcAct.Add(new WMDashboardInfo()
                            {
                                User      = Convert.ToString(rdr["processor"]),
                                Activity  = Convert.ToString(rdr["Activity"]),
                                TotalTime = Convert.ToDecimal(rdr["Total Timespent (hrs)"]),
                                Target    = Convert.ToInt32(rdr["TargetHrs"])
                            });
                        }

                        rdr.NextResult();
                        while (rdr.Read())
                        {
                            objDash.LstByProc.Add(new WMDashboardInfo()
                            {
                                User      = Convert.ToString(rdr["processor"]),
                                TotalTime = Convert.ToDecimal(rdr["Total Timespent (hrs)"]),
                                Target    = Convert.ToInt32(rdr["TargetHrs"])
                            });
                        }
                        //Reviewer data
                        rdr.NextResult();
                        while (rdr.Read())
                        {
                            objDash.LstByRevAct.Add(new WMDashboardInfo()
                            {
                                User      = Convert.ToString(rdr["Reviewer"]),
                                Activity  = Convert.ToString(rdr["Activity"]),
                                TotalTime = Convert.ToDecimal(rdr["Total Timespent (hrs)"]),
                                Target    = Convert.ToInt32(rdr["TargetHrs"])
                            });
                        }

                        rdr.NextResult();
                        while (rdr.Read())
                        {
                            objDash.LstByRev.Add(new WMDashboardInfo()
                            {
                                User      = Convert.ToString(rdr["Reviewer"]),
                                TotalTime = Convert.ToDecimal(rdr["Total Timespent (hrs)"]),
                                Target    = Convert.ToInt32(rdr["TargetHrs"])
                            });
                        }
                        objDash._message = String.Empty;
                        objDash._success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(Logger.LogType.Error, ex.ToString());
                throw ex;
            }
            return(objDash);
        }
コード例 #2
0
ファイル: repository.cs プロジェクト: kamsriv/Tracking
        public WMViewModel getPendingList(FilterAndPagerInfo filterInfo)
        {
            WMViewModel workms = new WMViewModel("", false);

            workms.Activities = new ActivityList();
            List <WorkMaint>  wm  = new List <WorkMaint>();
            List <Activities> act = new List <Activities>();

            SqlCommand cmd    = null;
            String     sqlCmd = StaticData.GET_WORKMAINT_PENDING_REVIEW;

            try
            {
                using (con = new SqlConnection(conStr))
                {
                    con.Open();
                    using (cmd = new SqlCommand(sqlCmd, con))
                    {
                        SqlParameter totalRows = new SqlParameter("@TotalRows", System.Data.SqlDbType.Int);
                        totalRows.Direction = System.Data.ParameterDirection.Output;

                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@CreatedBy", Common.GetUser.UserId);
                        if (filterInfo.Filters != null)
                        {
                            foreach (Filter key in filterInfo.Filters)
                            {
                                if (key != null && key.Key != null)
                                {
                                    cmd.Parameters.AddWithValue("@" + key.Key, key.Value);
                                }
                            }
                        }
                        cmd.Parameters.AddWithValue("@PageIndex", filterInfo.PageIndex);
                        cmd.Parameters.AddWithValue("@PageSize", filterInfo.PageSize);
                        cmd.Parameters.Add(totalRows);

                        SqlDataReader rdr = cmd.ExecuteReader();
                        while (rdr.Read())
                        {
                            WorkMaint e = new WorkMaint();
                            e.WorkItemId    = Convert.ToInt32(rdr["workitemid"]);
                            e.ActivityId    = Convert.ToInt32(rdr["activityid"]);
                            e.InvoiceNumber = Convert.ToString(rdr["invoice_number"]);
                            e.ActivityName  = Convert.ToString(rdr["activityname"]);
                            e.RequestNumber = Convert.ToString(rdr["request_number"]);
                            e.Comments      = Convert.ToString(rdr["comments"]);
                            e.UserId        = Convert.ToString(rdr["userid"]);
                            e.StartedDate   = Convert.ToDateTime(rdr["starteddate"]);
                            e.Status        = Convert.ToString(rdr["itemstatus"]);
                            wm.Add(e);
                        }
                        workms.WorkMaintList = wm;
                        rdr.NextResult();
                        workms.TotalRows = Convert.ToInt32(totalRows.Value);

                        CloseReader(rdr);
                        workms._success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                workms._message = FinTrackRes.WM_RETRIEVE_ERR;
                Logger.Log(Logger.LogType.Error, ex.ToString());
            }
            return(workms);
        }