Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie woLoadSummCookies = new HttpCookie("woloadsumm");

            if (!IsPostBack)
            {
                var dtStart = Request.QueryString["fromdatetime"];
                var dtEnd   = Request.QueryString["todatetime"];
                var asstGrp = Request.QueryString["asstgrp"];
                var woType  = Request.QueryString["wotype"];


                var filterStart = DateTime.ParseExact(dtStart, "dd/MM/yyyy hh:mm:ss tt", null);
                var filterEnd   = DateTime.ParseExact(dtEnd, "dd/MM/yyyy hh:mm:ss tt", null);

                var formatStart = filterStart.ToString("dd-MMM-yyy HH:mm:ss");
                var formatEnd   = filterEnd.ToString("dd-MMM-yyy HH:mm:ss");

                //Get a work orders lists
                rvWorkLoad.ProcessingMode         = ProcessingMode.Local;
                rvWorkLoad.LocalReport.ReportPath = Server.MapPath("WorkLoadSumm.rdlc");
                SAAEntities saaentities = new SAAEntities();

                woLoadSummCookies["fromdatetime"] = dtStart;
                woLoadSummCookies["todatetime"]   = dtEnd;
                woLoadSummCookies["asstgrp"]      = asstGrp;
                woLoadSummCookies["wotype"]       = woType;
                woLoadSummCookies.Expires         = DateTime.Now.AddYears(1);
                Response.Cookies.Add(woLoadSummCookies);

                var newq = from workorders in saaentities.T_BT
                           join resources in (from ligne_bt in saaentities.T_LIGNE_BT
                                              where ligne_bt.TYPE_LIGNE_BT == "I"
                                              select new
                {
                    CLE_BT = ligne_bt.CLE_BT,
                    CLE_ELEMENT = ligne_bt.CLE_ELEMENT
                })
                           on workorders.NUM_BT equals resources.CLE_BT into r
                           from resources in r.DefaultIfEmpty()
                           join tech in saaentities.T_INTERV on resources.CLE_ELEMENT equals tech.NUM_INTERV into t
                           from tech in t.DefaultIfEmpty()
                           join asset in saaentities.T_UI on workorders.CLE_UI equals asset.NUM_UI into a
                           from asset in a.DefaultIfEmpty()
                           join assetfamily in saaentities.T_FAMILLE_UI on asset.CLE_FAM equals assetfamily.CLE_FAM into af
                           from assetfamily in af.DefaultIfEmpty()
                           join wostat in saaentities.T_ETAT_BT on workorders.CLE_ETAT_BT equals wostat.CLE_ETAT_BT into wos
                           from wostat in wos.DefaultIfEmpty()
                           join wotype in saaentities.T_TYPE_TRAV on workorders.CLE_TYPE_TRAV equals wotype.NUM_TYPE_TRAV into wot
                           from wotype in wot.DefaultIfEmpty()
                           where workorders.DATE_DEB_PREV >= filterStart && workorders.DATE_DEB_PREV <= filterEnd
                           orderby workorders.NUM_BT ascending
                           group workorders by new { workorders.NUM_BT, workorders.TITRE_BT, assetfamily.CODE_FAM, tech.PRENOM_INTERV, wostat.DES_ETAT_BT, wotype.DES_TYPE_TRAV } into g
                    select new
                {
                    TITRE_BT      = g.Key.TITRE_BT,
                    CODE_FAM      = g.Key.CODE_FAM,
                    PRENOM_INTERV = g.Key.PRENOM_INTERV,
                    WOSTAT        = g.Key.DES_ETAT_BT,
                    WOTYPE        = g.Key.DES_TYPE_TRAV,
                    COUNT         = g.Count()
                };


                if (asstGrp != "All")
                {
                    newq = newq.Where(p => p.CODE_FAM == asstGrp);
                }

                if (woType != "All")
                {
                    newq = newq.Where(p => p.WOTYPE == woType);
                }



                var distinctCodeFam = (from r in newq select r.CODE_FAM).Distinct();
                List <WorkLoadSummaryModel> workLoadSumm = new List <WorkLoadSummaryModel>();
                foreach (var dFam in distinctCodeFam)
                {
                    int countWorkOrderByFam = (from h in newq where h.CODE_FAM == dFam select h).Count();
                    int countStaff          = (from h in newq where h.CODE_FAM == dFam group h by new { h.PRENOM_INTERV } into g select g.Key.PRENOM_INTERV).Count();

                    int countOutStandingWo = (from oswo in newq where oswo.WOSTAT != "Closed" && oswo.WOSTAT != "Completed" && oswo.CODE_FAM == dFam select oswo).Count();
                    int countCompltWo      = (from oswo in newq where oswo.CODE_FAM == dFam && (oswo.WOSTAT == "Closed" || oswo.WOSTAT == "Completed") select oswo).Count();
                    workLoadSumm.Add(new WorkLoadSummaryModel()
                    {
                        AssetGroup            = dFam,
                        StaffCount            = countStaff,
                        IssuedWorkOrders      = countWorkOrderByFam,
                        OutStandingWorkOrders = countOutStandingWo,
                        CompletedWorkOrders   = countCompltWo,
                        AverageWoPerStaff     = string.Format("{0:0.00}", (decimal)countWorkOrderByFam / countStaff)
                    });
                }

                ReportDataSource datasource = new ReportDataSource("DataSet1", workLoadSumm);
                rvWorkLoad.LocalReport.DataSources.Clear();
                rvWorkLoad.LocalReport.DataSources.Add(datasource);

                //ReportParameter rp = new ReportParameter("WorkLoadSummaryPeriod", formatStart + " - " + formatEnd, true);

                List <ReportParameter> rParam = new List <ReportParameter>()
                {
                    new ReportParameter("WorkLoadSummaryPeriod", formatStart + " to " + formatEnd, true),
                    new ReportParameter("WorkLoadSummaryWOType", Request.QueryString["wotype"], true),
                    new ReportParameter("WorkLoadSummaryAsstGrp", Request.QueryString["asstgrp"], true),
                };

                //ReportParameter rp2 = new ReportParameter("DateTo", this.TextBox2.Text, false);
                rvWorkLoad.LocalReport.SetParameters(rParam);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cmpltTimeDetailsCookies = new HttpCookie("cmplttimedetails");

            if (!IsPostBack)
            {
                //form in WorkOrderDetails - WebForm
                var dtStart = Request.QueryString["fromdatetime"];
                var dtEnd   = Request.QueryString["todatetime"];
                var asstGrp = Request.QueryString["asstgrp"];
                var woType  = Request.QueryString["wotype"];
                //var woStat = Request.QueryString["wostat"];
                var locs = Request.QueryString["location"];
                //var asstsItems = Request.QueryString["asset"];

                //var asstType = Request.QueryString["assttyp"];
                var techRep = Request.QueryString["tech"];
                //var repoBy = Request.QueryString["reportby"];

                var problem = Request.QueryString["problem"];

                var priority = Request.QueryString["priority"];

                //Response.Cookies["fromdatetime"].Value = dtStart;
                //Response.Cookies["todatetime"].Value = dtEnd;
                //Response.Cookies["asstgrp"].Value = asstGrp;
                //Response.Cookies["wotype"].Value = woType;

                cmpltTimeDetailsCookies["fromdatetime"] = dtStart;
                cmpltTimeDetailsCookies["todatetime"]   = dtEnd;
                cmpltTimeDetailsCookies["asstgrp"]      = asstGrp;
                cmpltTimeDetailsCookies["wotype"]       = woType;

                //cmpltTimeDetailsCookies["wostat"] = woStat;
                cmpltTimeDetailsCookies["location"] = locs;
                //cmpltTimeDetailsCookies["asset"] = asstsItems;

                //cmpltTimeDetailsCookies["assttyp"] = asstType;
                cmpltTimeDetailsCookies["tech"] = techRep;
                //cmpltTimeDetailsCookies["reportby"] = repoBy;

                cmpltTimeDetailsCookies["problem"] = problem;

                cmpltTimeDetailsCookies["priority"] = priority;
                //woDetailsCookies["wotype"] = woType;
                //dtStart = "01/09/2018 12:00:00 AM";
                //dtEnd = "30/09/2018 11:59:59 PM";
                //var asstgrp = Request.Cookies("wodetails")("asstgrp");
                //if (string.IsNullOrEmpty())
                //{
                //    woDetailsCookies["asstgrp"] = asstGrp;
                //}

                //Debug.WriteLine(woDetailsCookies["asstgrp"]);
                cmpltTimeDetailsCookies.Expires = DateTime.Now.AddYears(1);
                Response.Cookies.Add(cmpltTimeDetailsCookies);

                //Request.Cookies["asstgrp"] = "";

                var filterStart = DateTime.ParseExact(dtStart, "dd/MM/yyyy hh:mm:ss tt", null);
                var filterEnd   = DateTime.ParseExact(dtEnd, "dd/MM/yyyy hh:mm:ss tt", null);

                var formatStart = filterStart.ToString("dd-MMM-yyy HH:mm:ss");
                var formatEnd   = filterEnd.ToString("dd-MMM-yyy HH:mm:ss");

                rvCmpltTimeDet.ProcessingMode         = ProcessingMode.Local;
                rvCmpltTimeDet.LocalReport.ReportPath = Server.MapPath("CmpltTimeDetails.rdlc");
                SAAEntities saaentities = new SAAEntities();


                var newq = (from workorders in saaentities.T_BT
                            join resources in (from ligne_bt in saaentities.T_LIGNE_BT
                                               where ligne_bt.TYPE_LIGNE_BT == "I"
                                               select new
                {
                    CLE_BT = ligne_bt.CLE_BT,
                    CLE_ELEMENT = ligne_bt.CLE_ELEMENT
                })
                            on workorders.NUM_BT equals resources.CLE_BT into r
                            from resources in r.DefaultIfEmpty()
                            join tech in saaentities.T_INTERV on resources.CLE_ELEMENT equals tech.NUM_INTERV into t
                            from tech in t.DefaultIfEmpty()
                            join asset in saaentities.T_UI on workorders.CLE_UI equals asset.NUM_UI into a
                            from asset in a.DefaultIfEmpty()
                            join assettype in saaentities.T_TYPE_UI on asset.CLE_TUI equals assettype.CLE_TYPE_UI into at
                            from assettype in at.DefaultIfEmpty()
                            join locations in saaentities.T_LIEU on asset.CLE_LIEU equals locations.CLE_LIEU into loc
                            from locations in loc.DefaultIfEmpty()
                            join assetfamily in saaentities.T_FAMILLE_UI on asset.CLE_FAM equals assetfamily.CLE_FAM into af
                            from assetfamily in af.DefaultIfEmpty()
                            join wostat in saaentities.T_ETAT_BT on workorders.CLE_ETAT_BT equals wostat.CLE_ETAT_BT into wos
                            from wostat in wos.DefaultIfEmpty()
                            join wotype in saaentities.T_TYPE_TRAV on workorders.CLE_TYPE_TRAV equals wotype.NUM_TYPE_TRAV into wot
                            from wotype in wot.DefaultIfEmpty()
                            join reportby in saaentities.T_DEMANDEUR on workorders.CLE_DEMANDEUR equals reportby.CLE_DEMANDEUR into rb
                            from reportby in rb.DefaultIfEmpty()
                            join priolevel in saaentities.T_DEGDURGENCE on workorders.CLE_DEGDURG equals priolevel.NUM_ENR into pl
                            from priolevel in pl.DefaultIfEmpty()
                            where workorders.DATE_DEB_PREV >= filterStart && workorders.DATE_DEB_PREV <= filterEnd
                            orderby workorders.NUM_BT ascending
                            group workorders by new
                {
                    workorders.NUM_BT,
                    workorders.TITRE_BT,
                    assetfamily.CODE_FAM,
                    tech.PRENOM_INTERV,
                    wostat.DES_ETAT_BT,
                    wotype.DES_TYPE_TRAV,
                    workorders.DATE_DEB_PREV,
                    asset.DESIGNATION_UI,
                    assettype.LIBELLE_TUI,
                    locations.LIBELLE_LIEU,
                    priolevel.DESIGN_URG,
                    workorders.DATE_CLOT,
                    workorders.DATE_DERS,
                    reportby.NOM_DEMANDEUR
                } into g
                            select new
                {
                    NUM_BT = g.Key.NUM_BT,
                    TITRE_BT = g.Key.TITRE_BT,
                    DESIGNATION_UI = g.Key.DESIGNATION_UI,
                    LIBELLE_TUI = g.Key.LIBELLE_TUI,
                    LIBELLE_LIEU = g.Key.LIBELLE_LIEU,
                    CODE_FAM = g.Key.CODE_FAM,
                    PRENOM_INTERV = g.Key.PRENOM_INTERV,
                    WOSTAT = g.Key.DES_ETAT_BT,
                    WOTYPE = g.Key.DES_TYPE_TRAV,
                    YEARDATE = g.Key.DATE_DEB_PREV,
                    REPORTBY = g.Key.NOM_DEMANDEUR,
                    PRIOLVL = g.Key.DESIGN_URG,
                    CLOT = g.Key.DATE_CLOT,
                    AEND = g.Key.DATE_DERS,
                    COUNT = g.Count()
                }).AsEnumerable()
                           .Where(p => (p.WOSTAT == "Closed" || p.WOSTAT == "Completed"))
                           .Select(c => new
                {
                    WoNum      = c.NUM_BT,
                    WoDesc     = c.TITRE_BT,
                    WoType     = c.WOTYPE,
                    AsstGrp    = c.CODE_FAM,
                    Asst       = c.DESIGNATION_UI,
                    Location   = c.LIBELLE_LIEU,
                    WoPriority = c.PRIOLVL,
                    RepoBy     = c.REPORTBY,
                    Technician = c.PRENOM_INTERV,
                    DtStarted  = ((DateTime)c.YEARDATE.Value).ToString("dd") + "-" +
                                 ((DateTime)c.YEARDATE.Value).ToString("MMM") + "-" +
                                 ((DateTime)c.YEARDATE.Value).ToString("yy") + " " +
                                 ((DateTime)c.YEARDATE.Value).ToString("hh") + ":" +
                                 ((DateTime)c.YEARDATE.Value).ToString("mm") + ":" +
                                 ((DateTime)c.YEARDATE.Value).ToString("ss") + " " +
                                 ((DateTime)c.YEARDATE.Value).ToString("tt"),
                    DtClose = (((DateTime)(c.CLOT)).Subtract((DateTime)(c.YEARDATE)).TotalSeconds < 0) ?            //Added Conditional logic to get actual end date if status was completed but not closed
                              ((DateTime)c.AEND.Value).ToString("dd") + "-" +
                              ((DateTime)c.AEND.Value).ToString("MMM") + "-" +
                              ((DateTime)c.AEND.Value).ToString("yy") + " " +
                              ((DateTime)c.AEND.Value).ToString("hh") + ":" +
                              ((DateTime)c.AEND.Value).ToString("mm") + ":" +
                              ((DateTime)c.AEND.Value).ToString("ss") + " " +
                              ((DateTime)c.AEND.Value).ToString("tt") :                // Added
                              ((DateTime)c.CLOT.Value).ToString("dd") + "-" +
                              ((DateTime)c.CLOT.Value).ToString("MMM") + "-" +
                              ((DateTime)c.CLOT.Value).ToString("yy") + " " +
                              ((DateTime)c.CLOT.Value).ToString("hh") + ":" +
                              ((DateTime)c.CLOT.Value).ToString("mm") + ":" +
                              ((DateTime)c.CLOT.Value).ToString("ss") + " " +
                              ((DateTime)c.CLOT.Value).ToString("tt"),
                    DtDayMonth = ((DateTime)c.YEARDATE.Value).ToString("dd") + "-" +
                                 ((DateTime)c.YEARDATE.Value).ToString("MMM") + "-" +
                                 ((DateTime)c.YEARDATE.Value).ToString("yy"),
                    //Added Conditional logic to get actual end date if status was completed but not closed
                    Execution = (((DateTime)(c.CLOT)).Subtract((DateTime)(c.YEARDATE)).TotalSeconds < 0) ? (((DateTime)(c.AEND)).Subtract((DateTime)(c.YEARDATE)).TotalSeconds) : (((DateTime)(c.CLOT)).Subtract((DateTime)(c.YEARDATE)).TotalSeconds)
                });


                if (woType != "All")
                {
                    newq = newq.Where(p => p.WoType == woType);
                }

                if (priority != "All")
                {
                    newq = newq.Where(p => p.WoPriority == priority);
                }

                if (asstGrp != "All")
                {
                    newq = newq.Where(p => p.AsstGrp == asstGrp);
                }

                if (locs != "All")
                {
                    newq = newq.Where(p => p.Location == locs);
                }

                if (techRep != "All")
                {
                    newq = newq.Where(p => p.Technician == techRep);
                }

                if (problem != "")
                {
                    newq = newq.Where(p => p.WoDesc.Contains(problem.ToLower()) ||
                                      p.WoDesc.Contains(problem.ToUpper()) ||
                                      p.WoDesc.Contains(UppercaseFirst(problem)) ||
                                      p.WoDesc.Contains(problem));
                }

                //////////////////////////////////////////////////////

                //if (repoBy != "All")
                //{
                //    newq = newq.Where(p => p.ReportBy == repoBy);
                //}

                //if (asstsItems != "All")
                //{
                //    newq = newq.Where(p => p.Asset == asstsItems);
                //}

                //if (asstType != "All")
                //{
                //    newq = newq.Where(p => p.AssetType == asstType);
                //}


                //if (woStat != "All")
                //{
                //    newq = newq.Where(p => p.WoStat == woStat);
                //}



                List <CmpltTimeDetailsModel> cmpltTimeDetails = new List <CmpltTimeDetailsModel>();
                foreach (var wo in newq)
                {
                    //int countWorkOrderByMonthYear = (from h in newq where h.MONTHYEAR == month select h).Count();
                    //int countWorkOrderByFam = (from h in newq where h.CODE_FAM == dFam select h).Count();
                    //int countStaff = (from h in newq where h.CODE_FAM == dFam group h by new { h.PRENOM_INTERV } into g select g.Key.PRENOM_INTERV).Count();

                    //int countOutStandingWo = (from oswo in newq where oswo.WOSTAT != "Closed" && oswo.WOSTAT != "Completed" && oswo.CODE_FAM == dFam select oswo).Count();
                    //int countCompltWo = (from oswo in newq where oswo.MONTHYEAR == month && (oswo.WOSTAT == "Closed" || oswo.WOSTAT == "Completed") select oswo).Count();
                    cmpltTimeDetails.Add(new CmpltTimeDetailsModel()
                    {
                        WoNum      = wo.WoNum,
                        WoDesc     = wo.WoDesc,
                        WoType     = wo.WoType,
                        AsstGrp    = wo.AsstGrp,
                        Asst       = wo.Asst,
                        Location   = wo.Location,
                        WoPriority = wo.WoPriority,
                        Technician = wo.Technician,
                        RepoBy     = wo.RepoBy,
                        DtStarted  = wo.DtStarted,
                        DtClose    = wo.DtClose,
                        DtDayMonth = wo.DtDayMonth,
                        //Execution = wo.Execution.ToString()
                        Execution = string.Format("{0:00}:{1:00}:{2:00}", Math.Floor(wo.Execution / 3600), Math.Floor(wo.Execution / 60) % 60, wo.Execution % 60)
                    });
                }
                //string res = "20130908";
                //DateTime d = DateTime.ParseExact(res, "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
                //Console.WriteLine(d.ToString("dd/MMM/yyyy"));


                //string height = HttpContext.Current.Request.Params["clientScreenHeight"];
                //string width = HttpContext.Current.Request.Params["clientScreenWidth"];

                ReportDataSource datasource = new ReportDataSource("DataSet1", cmpltTimeDetails);
                rvCmpltTimeDet.LocalReport.DataSources.Clear();
                rvCmpltTimeDet.Width  = (Request.Browser.ScreenPixelsWidth) * 2 - 100;
                rvCmpltTimeDet.Height = (Request.Browser.ScreenPixelsHeight) * 2 - 100;
                //rvWoDetails.Width = (Request.Browser.ScreenPixelsWidth) * 2 - 100;
                //rvWoDetails.Height = (Request.Browser.ScreenPixelsHeight) * 2 - 100;
                rvCmpltTimeDet.LocalReport.DataSources.Add(datasource);


                List <ReportParameter> rParam = new List <ReportParameter>()
                {
                    new ReportParameter("ParamCmpltTimeDetailsPeriod", formatStart + " to " + formatEnd, true),
                    new ReportParameter("ParamCmpltTimeDetailsWoType", Request.QueryString["wotype"], true),
                    new ReportParameter("ParamCmpltTimeDetailsAsstGrp", Request.QueryString["asstgrp"], true),
                    new ReportParameter("ParamCmpltTimeDetailsTechnician", Request.QueryString["tech"], true),
                    new ReportParameter("ParamCmpltTimeDetailsLocation", Request.QueryString["location"], true),
                    new ReportParameter("ParamCmpltTimeDetailsPriority", Request.QueryString["priority"], true),
                    new ReportParameter("ParamCmpltTimeDetailsProblem", (string.IsNullOrEmpty(Request.QueryString["problem"])) ? "All" : Request.QueryString["problem"], true)
                    //new ReportParameter("ParamWoDetailsRepoBy", Request.QueryString["reportby"], true),
                    //new ReportParameter("ParamWoDetailsAsst", Request.QueryString["asset"], true),
                    //new ReportParameter("ParamWoDetailsAsstType", Request.QueryString["assttyp"], true),
                    //new ReportParameter("ParamWoDetailsWoStat", Request.QueryString["wostat"], true),
                };
                rvCmpltTimeDet.LocalReport.SetParameters(rParam);
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie pmWODetailsCookies = new HttpCookie("pmwodetails");

            if (!IsPostBack)
            {
                //form in WorkOrderDetails - WebForm
                var dtStart = Request.QueryString["fromdatetime"];
                var dtEnd   = Request.QueryString["todatetime"];
                var asstGrp = Request.QueryString["asstgrp"];
                //var woType = Request.QueryString["wotype"];
                //var woStat = Request.QueryString["wostat"];
                var locs       = Request.QueryString["location"];
                var asstsItems = Request.QueryString["asset"];

                //var asstType = Request.QueryString["assttyp"];
                var techRep = Request.QueryString["tech"];
                //var repoBy = Request.QueryString["reportby"];

                //dtStart = "01/09/2018 12:00:00 AM";
                //dtEnd = "30/09/2018 11:59:59 PM";


                var filterStart = DateTime.ParseExact(dtStart, "dd/MM/yyyy hh:mm:ss tt", null);
                var filterEnd   = DateTime.ParseExact(dtEnd, "dd/MM/yyyy hh:mm:ss tt", null);

                var formatStart = filterStart.ToString("dd-MMM-yyy HH:mm:ss");
                var formatEnd   = filterEnd.ToString("dd-MMM-yyy HH:mm:ss");

                rvPmWoDetails.ProcessingMode         = ProcessingMode.Local;
                rvPmWoDetails.LocalReport.ReportPath = Server.MapPath("PMWorkDetails.rdlc");
                SAAEntities saaentities = new SAAEntities();


                pmWODetailsCookies["fromdatetime"] = dtStart;
                pmWODetailsCookies["todatetime"]   = dtEnd;
                pmWODetailsCookies["asstgrp"]      = asstGrp;
                pmWODetailsCookies["location"]     = locs;
                pmWODetailsCookies["asset"]        = asstsItems;
                pmWODetailsCookies["tech"]         = techRep;
                pmWODetailsCookies.Expires         = DateTime.Now.AddYears(1);
                Response.Cookies.Add(pmWODetailsCookies);

                var newq = (from workorders in saaentities.T_BT
                            join resources in (from ligne_bt in saaentities.T_LIGNE_BT
                                               where ligne_bt.TYPE_LIGNE_BT == "I"
                                               select new
                {
                    CLE_BT = ligne_bt.CLE_BT,
                    CLE_ELEMENT = ligne_bt.CLE_ELEMENT
                })
                            on workorders.NUM_BT equals resources.CLE_BT into r
                            from resources in r.DefaultIfEmpty()
                            join tech in saaentities.T_INTERV on resources.CLE_ELEMENT equals tech.NUM_INTERV into t
                            from tech in t.DefaultIfEmpty()
                            join asset in saaentities.T_UI on workorders.CLE_UI equals asset.NUM_UI into a
                            from asset in a.DefaultIfEmpty()
                            join assettype in saaentities.T_TYPE_UI on asset.CLE_TUI equals assettype.CLE_TYPE_UI into at
                            from assettype in at.DefaultIfEmpty()
                            join locations in saaentities.T_LIEU on asset.CLE_LIEU equals locations.CLE_LIEU into loc
                            from locations in loc.DefaultIfEmpty()
                            join assetfamily in saaentities.T_FAMILLE_UI on asset.CLE_FAM equals assetfamily.CLE_FAM into af
                            from assetfamily in af.DefaultIfEmpty()
                            join wostat in saaentities.T_ETAT_BT on workorders.CLE_ETAT_BT equals wostat.CLE_ETAT_BT into wos
                            from wostat in wos.DefaultIfEmpty()
                            join wotype in saaentities.T_TYPE_TRAV on workorders.CLE_TYPE_TRAV equals wotype.NUM_TYPE_TRAV into wot
                            from wotype in wot.DefaultIfEmpty()
                            join reportby in saaentities.T_DEMANDEUR on workorders.CLE_DEMANDEUR equals reportby.CLE_DEMANDEUR into rb
                            from reportby in rb.DefaultIfEmpty()
                            where workorders.DATE_DEB_PREV >= filterStart && workorders.DATE_DEB_PREV <= filterEnd
                            orderby workorders.NUM_BT ascending
                            group workorders by new
                {
                    workorders.NUM_BT,
                    workorders.TITRE_BT,
                    assetfamily.CODE_FAM,
                    tech.PRENOM_INTERV,
                    wostat.DES_ETAT_BT,
                    wotype.DES_TYPE_TRAV,
                    workorders.DATE_DEB_REEL,
                    asset.DESIGNATION_UI,
                    assettype.LIBELLE_TUI,
                    locations.LIBELLE_LIEU,
                    reportby.NOM_DEMANDEUR,
                    workorders.DATE_DEB_PREV,
                    workorders.DATE_CLOT,
                    workorders.COMM
                } into g
                            select new
                {
                    NUM_BT = g.Key.NUM_BT,
                    TITRE_BT = g.Key.TITRE_BT,
                    DESIGNATION_UI = g.Key.DESIGNATION_UI,
                    LIBELLE_TUI = g.Key.LIBELLE_TUI,
                    LIBELLE_LIEU = g.Key.LIBELLE_LIEU,
                    CODE_FAM = g.Key.CODE_FAM,
                    PRENOM_INTERV = g.Key.PRENOM_INTERV,
                    WOSTAT = g.Key.DES_ETAT_BT,
                    WOTYPE = g.Key.DES_TYPE_TRAV,
                    YEARDATE = g.Key.DATE_DEB_REEL,
                    REPORTBY = g.Key.NOM_DEMANDEUR,
                    PLANNEDSTARTDATE = g.Key.DATE_DEB_PREV,
                    CLOSEDDATE = g.Key.DATE_CLOT,
                    COMMENTS = g.Key.COMM,
                    COUNT = g.Count()
                }).AsEnumerable()
                           .Where(p => p.WOTYPE == "Preventive")
                           .Select(c => new
                {
                    WoNumber      = c.NUM_BT,
                    WoDescription = c.TITRE_BT,
                    WoType        = c.WOTYPE,
                    AssetGrp      = c.CODE_FAM,
                    Asset         = c.DESIGNATION_UI,
                    Location      = c.LIBELLE_LIEU,
                    AssetType     = c.LIBELLE_TUI,
                    Technician    = c.PRENOM_INTERV,
                    WoStat        = c.WOSTAT,
                    ReportBy      = c.REPORTBY,
                    TrgtStrtDate  = ((DateTime)c.PLANNEDSTARTDATE.Value).ToString("dd") + "-" +
                                    ((DateTime)c.PLANNEDSTARTDATE.Value).ToString("MMM") + "-" +
                                    ((DateTime)c.PLANNEDSTARTDATE.Value).ToString("yy"),
                    CmpltStrtDate = c.CLOSEDDATE,
                    Comments      = c.COMMENTS,
                    DateATime     = c.YEARDATE.ToString()
                });


                //if (woType != "All")
                //{
                //    newq = newq.Where(p => p.WoType == woType);
                //}

                if (asstGrp != "All")
                {
                    newq = newq.Where(p => p.AssetGrp == asstGrp);
                }

                //if (woStat != "All")
                //{
                //    newq = newq.Where(p => p.WoStat == woStat);
                //}

                if (locs != "All")
                {
                    newq = newq.Where(p => p.Location == locs);
                }

                if (asstsItems != "All")
                {
                    newq = newq.Where(p => p.Asset == asstsItems);
                }

                //if (asstType != "All")
                //{
                //    newq = newq.Where(p => p.AssetType == asstType);
                //}

                if (techRep != "All")
                {
                    newq = newq.Where(p => p.Technician == techRep);
                }

                //if (repoBy != "All")
                //{
                //    newq = newq.Where(p => p.ReportBy == repoBy);
                //}



                List <PMWoDetailsModel> workDetails = new List <PMWoDetailsModel>();
                foreach (var wo in newq)
                {
                    //int countWorkOrderByMonthYear = (from h in newq where h.MONTHYEAR == month select h).Count();
                    //int countWorkOrderByFam = (from h in newq where h.CODE_FAM == dFam select h).Count();
                    //int countStaff = (from h in newq where h.CODE_FAM == dFam group h by new { h.PRENOM_INTERV } into g select g.Key.PRENOM_INTERV).Count();

                    //int countOutStandingWo = (from oswo in newq where oswo.WOSTAT != "Closed" && oswo.WOSTAT != "Completed" && oswo.CODE_FAM == dFam select oswo).Count();
                    //int countCompltWo = (from oswo in newq where oswo.MONTHYEAR == month && (oswo.WOSTAT == "Closed" || oswo.WOSTAT == "Completed") select oswo).Count();
                    workDetails.Add(new PMWoDetailsModel()
                    {
                        WoNumber      = wo.WoNumber,
                        WoDescription = wo.WoDescription,
                        WoType        = wo.WoType,
                        AssetGrp      = wo.AssetGrp,
                        Asset         = wo.Asset,
                        Location      = wo.Location,
                        AssetType     = wo.AssetType,
                        Technician    = wo.Technician,
                        WoStat        = wo.WoStat,
                        ReportBy      = wo.ReportBy,
                        DateATime     = wo.DateATime,
                        TrgtStrtDate  = wo.TrgtStrtDate.ToString(),
                        CmpltStrtDate = wo.CmpltStrtDate.ToString(),
                        Comments      = wo.Comments
                    });
                }



                //string height = HttpContext.Current.Request.Params["clientScreenHeight"];
                //string width = HttpContext.Current.Request.Params["clientScreenWidth"];

                ReportDataSource datasource = new ReportDataSource("DataSet1", workDetails);
                rvPmWoDetails.LocalReport.DataSources.Clear();
                rvPmWoDetails.Width  = (Request.Browser.ScreenPixelsWidth) * 2 - 100;
                rvPmWoDetails.Height = (Request.Browser.ScreenPixelsHeight) * 2 - 100;
                //rvWoDetails.Width = (Request.Browser.ScreenPixelsWidth) * 2 - 100;
                //rvWoDetails.Height = (Request.Browser.ScreenPixelsHeight) * 2 - 100;
                rvPmWoDetails.LocalReport.DataSources.Add(datasource);


                //List<ReportParameter> rParam = new List<ReportParameter>()
                //{
                //    new ReportParameter("ParamPMWoDetailsPeriod", formatStart + " To " + formatEnd, true),
                //    new ReportParameter("ParamPMWoDetailsAsstGrp", Request.QueryString["asstgrp"], true),
                //    new ReportParameter("ParamPMWoDetailsAsst", Request.QueryString["asset"], true),
                //    new ReportParameter("ParamPMWoDetailsLocs", Request.QueryString["location"], true),
                //    new ReportParameter("ParamPMWoDetailsTech", Request.QueryString["tech"], true)
                //};
                List <ReportParameter> rParam = new List <ReportParameter>()
                {
                    new ReportParameter("ParamPMWoDetailsPeriod", formatStart + " to " + formatEnd, true),
                    new ReportParameter("ParamPMWoDetailsAsstGrp", Request.QueryString["asstgrp"], true),
                    new ReportParameter("ParamPMWoDetailsAsst", Request.QueryString["asset"], true),
                    new ReportParameter("ParamPMWoDetailsLocs", Request.QueryString["location"], true),
                    new ReportParameter("ParamPMWoDetailsTech", Request.QueryString["tech"], true)
                };

                rvPmWoDetails.LocalReport.SetParameters(rParam);
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie mosBreakDown = new HttpCookie("mosbreakdown");

            if (!IsPostBack)
            {
                var dtStart = Request.QueryString["fromdatetime"];
                var dtEnd   = Request.QueryString["todatetime"];
                var asstGrp = Request.QueryString["asstgrp"];
                var woType  = Request.QueryString["wotype"];


                var filterStart = DateTime.ParseExact(dtStart, "dd/MM/yyyy hh:mm:ss tt", null);
                var filterEnd   = DateTime.ParseExact(dtEnd, "dd/MM/yyyy hh:mm:ss tt", null);

                //var dtStart = "01/09/2018 12:00:00 AM";
                //var dtEnd = "30/12/2018 11:59:59 PM";
                //var filterStart = DateTime.ParseExact(dtStart, "dd/MM/yyyy hh:mm:ss tt", null);
                //var filterEnd = DateTime.ParseExact(dtEnd, "dd/MM/yyyy hh:mm:ss tt", null);

                var formatStart = filterStart.ToString("dd-MMM-yyy HH:mm:ss");
                var formatEnd   = filterEnd.ToString("dd-MMM-yyy HH:mm:ss");

                rvMonthBdown.ProcessingMode         = ProcessingMode.Local;
                rvMonthBdown.LocalReport.ReportPath = Server.MapPath("MonthlyBreakDown.rdlc");
                SAAEntities saaentities = new SAAEntities();

                mosBreakDown["fromdatetime"] = dtStart;
                mosBreakDown["todatetime"]   = dtEnd;
                mosBreakDown["wotype"]       = woType;
                mosBreakDown["asstgrp"]      = asstGrp;

                mosBreakDown.Expires = DateTime.Now.AddYears(1);

                Response.Cookies.Add(mosBreakDown);

                var newq = (from workorders in saaentities.T_BT
                            join resources in (from ligne_bt in saaentities.T_LIGNE_BT
                                               where ligne_bt.TYPE_LIGNE_BT == "I"
                                               select new
                {
                    CLE_BT = ligne_bt.CLE_BT,
                    CLE_ELEMENT = ligne_bt.CLE_ELEMENT
                })
                            on workorders.NUM_BT equals resources.CLE_BT into r
                            from resources in r.DefaultIfEmpty()
                            join tech in saaentities.T_INTERV on resources.CLE_ELEMENT equals tech.NUM_INTERV into t
                            from tech in t.DefaultIfEmpty()
                            join asset in saaentities.T_UI on workorders.CLE_UI equals asset.NUM_UI into a
                            from asset in a.DefaultIfEmpty()
                            join assetfamily in saaentities.T_FAMILLE_UI on asset.CLE_FAM equals assetfamily.CLE_FAM into af
                            from assetfamily in af.DefaultIfEmpty()
                            join wostat in saaentities.T_ETAT_BT on workorders.CLE_ETAT_BT equals wostat.CLE_ETAT_BT into wos
                            from wostat in wos.DefaultIfEmpty()
                            join wotype in saaentities.T_TYPE_TRAV on workorders.CLE_TYPE_TRAV equals wotype.NUM_TYPE_TRAV into wot
                            from wotype in wot.DefaultIfEmpty()
                            where workorders.DATE_DEB_PREV >= filterStart && workorders.DATE_DEB_PREV <= filterEnd
                            orderby workorders.NUM_BT ascending
                            group workorders by new { workorders.NUM_BT, workorders.TITRE_BT, assetfamily.CODE_FAM, tech.PRENOM_INTERV, wostat.DES_ETAT_BT, wotype.DES_TYPE_TRAV, workorders.DATE_DEB_PREV } into g
                            select new
                {
                    TITRE_BT = g.Key.TITRE_BT,
                    CODE_FAM = g.Key.CODE_FAM,
                    PRENOM_INTERV = g.Key.PRENOM_INTERV,
                    WOSTAT = g.Key.DES_ETAT_BT,
                    WOTYPE = g.Key.DES_TYPE_TRAV,
                    YEARDATE = g.Key.DATE_DEB_PREV,
                    COUNT = g.Count()
                }).AsEnumerable()
                           .Select(c => new
                {
                    DESC      = c.TITRE_BT,
                    ASSFAM    = c.CODE_FAM,
                    ASST      = c.PRENOM_INTERV,
                    WOSTAT    = c.WOSTAT,
                    WOTYPE    = c.WOTYPE,
                    MONTHYEAR = ((DateTime)c.YEARDATE.Value).ToString("MMM") + " " + ((DateTime)c.YEARDATE.Value).Year,
                });

                if (asstGrp != "All")
                {
                    newq = newq.Where(p => p.ASSFAM == asstGrp);
                }

                if (woType != "All")
                {
                    newq = newq.Where(p => p.WOTYPE == woType);
                }

                var getMonthYear = newq.Select(c => c.MONTHYEAR).Distinct();
                List <WoCmpltRateModel>     workCmpltRate   = new List <WoCmpltRateModel>();
                List <WorkLoadSummaryModel> woLoadSummModel = new List <WorkLoadSummaryModel>();
                foreach (var month in getMonthYear)
                {
                    int countWorkOrderByMonthYear = (from h in newq where h.MONTHYEAR == month select h).Count();
                    //int countWorkOrderByFam = (from h in newq where h.CODE_FAM == dFam select h).Count();
                    //int countStaff = (from h in newq where h.CODE_FAM == dFam group h by new { h.PRENOM_INTERV } into g select g.Key.PRENOM_INTERV).Count();

                    //int countOutStandingWo = (from oswo in newq where oswo.WOSTAT != "Closed" && oswo.WOSTAT != "Completed" && oswo.CODE_FAM == dFam select oswo).Count();
                    int countCompltWo = (from oswo in newq where oswo.MONTHYEAR == month && (oswo.WOSTAT == "Closed" || oswo.WOSTAT == "Completed") select oswo).Count();
                    workCmpltRate.Add(new WoCmpltRateModel()
                    {
                        MonthYear    = month,
                        IssuedWo     = countWorkOrderByMonthYear,
                        CompletedWo  = countCompltWo,
                        PercentCmplt = string.Format("{0:0.00}", (decimal)countCompltWo / countWorkOrderByMonthYear * 100)
                    });
                }

                var getAsstGrp = newq.Select(c => c.ASSFAM).Distinct();
                getAsstGrp.Reverse();
                foreach (var ag in getAsstGrp)
                {
                    int countWorkOrderByFam = (from h in newq where h.ASSFAM == ag select h).Count();
                    int countOutStandingWo  = (from oswo in newq where oswo.WOSTAT != "Closed" && oswo.WOSTAT != "Completed" && oswo.ASSFAM == ag select oswo).Count();
                    int countCompltWo       = (from oswo in newq where oswo.ASSFAM == ag && (oswo.WOSTAT == "Closed" || oswo.WOSTAT == "Completed") select oswo).Count();
                    woLoadSummModel.Add(new WorkLoadSummaryModel()
                    {
                        AssetGroup            = ag,
                        IssuedWorkOrders      = countWorkOrderByFam,
                        OutStandingWorkOrders = countOutStandingWo,
                        CompletedWorkOrders   = countCompltWo,
                    });
                }

                ReportDataSource datasource  = new ReportDataSource("DataSet1", workCmpltRate);
                ReportDataSource datasource2 = new ReportDataSource("DataSet2", woLoadSummModel);

                rvMonthBdown.LocalReport.DataSources.Clear();
                rvMonthBdown.LocalReport.DataSources.Add(datasource);
                rvMonthBdown.LocalReport.DataSources.Add(datasource2);

                List <ReportParameter> rParam = new List <ReportParameter>()
                {
                    new ReportParameter("ParamMosBreakDownPeriod", formatStart + " to " + formatEnd, true),
                    new ReportParameter("ParamMosBreakDownWoType", Request.QueryString["wotype"], true),
                    new ReportParameter("ParamMosBreakDownAsstGrp", Request.QueryString["asstgrp"], true)
                };

                rvMonthBdown.LocalReport.SetParameters(rParam);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rvKpiSummary.ProcessingMode         = ProcessingMode.Local;
                rvKpiSummary.LocalReport.ReportPath = Server.MapPath("ResponseTimeKpiSummaryReport.rdlc");

                SAAEntities saaentities = new SAAEntities();



                string query = "SELECT table2.[CODE_FAM],";
                query = query + "COUNT(table2.[CODE_FAM]) as SUM_BY_FAMILY ";
                query = query + "FROM[SAA].[dbo].[T_BT] table1 ";
                query = query + "LEFT JOIN(SELECT[NUM_UI]";
                query = query + ",[CLE_FAM],";
                query = query + "b.[CODE_FAM]";
                query = query + ",[DESIGNATION_UI]";
                query = query + "FROM[SAA].[dbo].[T_UI] a ";
                query = query + "INNER JOIN(SELECT[CLE_FAM] as Code,[CODE_FAM] FROM[SAA].[dbo].[T_FAMILLE_UI]) b ON a.[CLE_FAM] = b.[Code] ";
                query = query + "WHERE b.[CODE_FAM] <> '') table2 ON table1.[CLE_UI] = table2.[NUM_UI] ";
                query = query + "GROUP BY table2.[CODE_FAM]";

                //var gx = Request.QueryString["fromdatetime"];

                //var s = from asset in saaentities.T_UI
                //        join assetfamily in saaentities.T_FAMILLE_UI on asset equals assetfamily.
                //var qAssetFamily = from assetfamily in saaentities.T_FAMILLE_UI
                //            select new
                //            {
                //                Code = assetfamily.CLE_FAM,
                //                CODE_FAM = assetfamily.CODE_FAM
                //            };

                //JOIN Structure
                var qAsset = from asset in saaentities.T_UI
                             join assetfamily in (from af in saaentities.T_FAMILLE_UI select af) on asset.CLE_FAM equals assetfamily.CLE_FAM
                             where assetfamily.CODE_FAM != ""
                             orderby asset.NUM_UI
                             select new
                {
                    NUM_BT      = asset.NUM_UI,
                    TITRE_BT    = asset.CLE_FAM,
                    CLE_ETAT_BT = assetfamily.CODE_FAM
                };
                //var start = DateTime.Parse("09/01/2018 12:00:00 AM");
                //var end = DateTime.Parse("09/30/2018 12:00:00 AM");

                //var f = DateTime.ParseExact("01/09/2018 12:00:00 AM", "dd/MM/yyyy hh:mm:ss tt", null);

                var gx = Request.QueryString["fromdatetime"];
                var gz = Request.QueryString["todatetime"];

                var start = DateTime.ParseExact(gx, "dd/MM/yyyy hh:mm:ss tt", null);
                var end   = DateTime.ParseExact(gz, "dd/MM/yyyy hh:mm:ss tt", null);
                //var start = DateTime.Parse(gx);
                //var end = DateTime.Parse(gz);



                var q = from table1 in saaentities.T_BT
                        join table2 in (from asset in saaentities.T_UI
                                        join assetfamily in (from af in saaentities.T_FAMILLE_UI select af) on asset.CLE_FAM equals assetfamily.CLE_FAM
                                        where assetfamily.CODE_FAM != ""
                                        select new
                {
                    NUM_UI = asset.NUM_UI,
                    CLE_FAM = asset.CLE_FAM,
                    CODE_FAM = assetfamily.CODE_FAM,
                    DESIGNATION_UI = asset.DESIGNATION_UI
                }) on table1.CLE_UI equals table2.NUM_UI
                        //where table1.DATE_DEB_REEL >= DbFunctions.TruncateTime(DateTime.ParseExact("11/1/2018 12:00 AM", "MM/dd/yyyy HH:mm tt", null)) && table1.DATE_DEB_REEL <= DbFunctions.TruncateTime(DateTime.ParseExact("11/30/2018 11:59 PM", "MM/dd/yyyy HH:mm tt", null))
                        where table1.DATE_DEB_REEL >= start && table1.DATE_DEB_REEL <= end
                        group table1 by table2.CODE_FAM into g
                        select new
                {
                    NUM_BT   = g.Key,
                    TITRE_BT = g.Count()
                };


                var qz = from iw in (from table1 in saaentities.T_BT
                                     join table2 in (from asset in saaentities.T_UI
                                                     join assetfamily in (from af in saaentities.T_FAMILLE_UI select af) on asset.CLE_FAM equals assetfamily.CLE_FAM
                                                     where assetfamily.CODE_FAM != ""
                                                     select new
                {
                    NUM_UI = asset.NUM_UI,
                    CLE_FAM = asset.CLE_FAM,
                    CODE_FAM = assetfamily.CODE_FAM,
                    DESIGNATION_UI = asset.DESIGNATION_UI
                }) on table1.CLE_UI equals table2.NUM_UI
                                     //where table1.DATE_DEB_REEL >= DbFunctions.TruncateTime(DateTime.ParseExact("11/1/2018 12:00 AM", "MM/dd/yyyy HH:mm tt", null)) && table1.DATE_DEB_REEL <= DbFunctions.TruncateTime(DateTime.ParseExact("11/30/2018 11:59 PM", "MM/dd/yyyy HH:mm tt", null))
                                     where table1.DATE_DEB_REEL >= start && table1.DATE_DEB_REEL <= end
                                     group table1 by table2.CODE_FAM into g
                                     select new
                {
                    NUM_BT = g.Key,
                    TITRE_BT1 = g.Count()
                })
                         join ow in (from table1 in saaentities.T_BT
                                     join table2 in (from asset in saaentities.T_UI
                                                     join assetfamily in (from af in saaentities.T_FAMILLE_UI select af) on asset.CLE_FAM equals assetfamily.CLE_FAM
                                                     where assetfamily.CODE_FAM != ""
                                                     select new
                {
                    NUM_UI = asset.NUM_UI,
                    CLE_FAM = asset.CLE_FAM,
                    CODE_FAM = assetfamily.CODE_FAM,
                    DESIGNATION_UI = asset.DESIGNATION_UI
                }) on table1.CLE_UI equals table2.NUM_UI
                                     //where table1.DATE_DEB_REEL >= DbFunctions.TruncateTime(DateTime.ParseExact("11/1/2018 12:00 AM", "MM/dd/yyyy HH:mm tt", null)) && table1.DATE_DEB_REEL <= DbFunctions.TruncateTime(DateTime.ParseExact("11/30/2018 11:59 PM", "MM/dd/yyyy HH:mm tt", null))
                                     where table1.DATE_DEB_REEL >= start && table1.DATE_DEB_REEL <= end && table1.CLE_ETAT_BT != 3
                                     group table1 by table2.CODE_FAM into g
                                     select new
                {
                    NUM_BT = g.Key,
                    TITRE_BT2 = g.Count()
                })
                         on iw.NUM_BT equals ow.NUM_BT
                         select new {
                    NUM_BT = iw.NUM_BT,
                    IW     = iw.TITRE_BT1,
                    OW     = ow.TITRE_BT2,
                    CMPL   = iw.TITRE_BT1 - ow.TITRE_BT2
                };


                //DateTime.ParseExact("11/30/2018 11:59 PM", "MM/dd/yyyy HH:mm tt", null);

                //Convert.ToDateTime("11/30/2018 11:59 PM")
                int x = qAsset.Count();
                //var testquery = saaentities.T_BT
                //    .SqlQuery(query).ToList();


                //var woList = saaentities.T_BT.ToList();

                ReportDataSource datasource = new ReportDataSource("KpiSummary", qz);
                rvKpiSummary.LocalReport.DataSources.Clear();
                rvKpiSummary.LocalReport.DataSources.Add(datasource);
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie respTimeKpiSummCookie = new HttpCookie("resptimekpisumm");

            if (!IsPostBack)
            {
                var dtStart = Request.QueryString["fromdatetime"];
                var dtEnd   = Request.QueryString["todatetime"];
                var asstGrp = Request.QueryString["asstgrp"];
                var woType  = Request.QueryString["wotype"];


                var filterStart = DateTime.ParseExact(dtStart, "dd/MM/yyyy hh:mm:ss tt", null);
                var filterEnd   = DateTime.ParseExact(dtEnd, "dd/MM/yyyy hh:mm:ss tt", null);

                //var dtStart = "01/09/2018 12:00:00 AM";
                //var dtEnd = "30/12/2018 11:59:59 PM";
                //var filterStart = DateTime.ParseExact(dtStart, "dd/MM/yyyy hh:mm:ss tt", null);
                //var filterEnd = DateTime.ParseExact(dtEnd, "dd/MM/yyyy hh:mm:ss tt", null);

                var formatStart = filterStart.ToString("dd-MMM-yyy HH:mm:ss");
                var formatEnd   = filterEnd.ToString("dd-MMM-yyy HH:mm:ss");


                respTimeKpiSummCookie["fromdatetime"] = dtStart;
                respTimeKpiSummCookie["todatetime"]   = dtEnd;
                respTimeKpiSummCookie["wotype"]       = woType;
                respTimeKpiSummCookie["asstgrp"]      = asstGrp;

                respTimeKpiSummCookie.Expires = DateTime.Now.AddYears(1);

                Response.Cookies.Add(respTimeKpiSummCookie);

                rvRespoTimeKpiSumm.ProcessingMode         = ProcessingMode.Local;
                rvRespoTimeKpiSumm.LocalReport.ReportPath = Server.MapPath("ResponseTimeKpiSumm.rdlc");

                SAAEntities saaentities = new SAAEntities();


                var respo = (from r in saaentities.QREPORT_COMPLETION_TIME_KPI_REF
                             where r.TYPE == "RESPONSE"
                             select new
                {
                    MIN_SEC = r.MIN_SECS,
                    MIDDLE_SEC = r.MIDDLE_SECS,
                    MAX_SEC = r.MAX_SECS
                }).AsEnumerable()
                            .Select(c => new {
                    MIN    = c.MIN_SEC,
                    MIDDLE = c.MIDDLE_SEC,
                    MAX    = c.MAX_SEC
                });

                string minSecs    = respo.Select(p => p.MIN).SingleOrDefault().ToString();
                string middleSecs = respo.Select(p => p.MIDDLE).SingleOrDefault().ToString();
                string maxSecs    = respo.Select(p => p.MAX).SingleOrDefault().ToString();

                List <ReportParameter> rParam = new List <ReportParameter>()
                {
                    new ReportParameter("ParamMinSecs", string.IsNullOrEmpty(minSecs) ? "0" : minSecs, false),
                    new ReportParameter("ParamMidSecs", string.IsNullOrEmpty(middleSecs) ? "0" : middleSecs, false),
                    new ReportParameter("ParamMaxSecs", string.IsNullOrEmpty(maxSecs) ? "0" : maxSecs, false),
                    new ReportParameter("ParamWoType", woType, true),
                    new ReportParameter("ParamPeriod", formatStart + " to " + formatEnd, true),
                    new ReportParameter("ParamAssetGrp", asstGrp, true),
                };

                rvRespoTimeKpiSumm.LocalReport.SetParameters(rParam);


                var respoQuery = (from wo in saaentities.T_BT
                                  join statchange in (from todo in saaentities.T_HISTO_ETATS
                                                      where todo.OLD_ETAT == "To do"
                                                      select new
                {
                    CLE_OBJET_HISTO = todo.CLE_OBJET_HISTO,
                    OLD_ETAT = todo.OLD_ETAT,
                    NEW_ETAT = todo.NEW_ETAT,
                    RESPONSE = todo.DATE_HISTO
                }) on wo.NUM_BT equals statchange.CLE_OBJET_HISTO into sc
                                  from statchange in sc.DefaultIfEmpty()
                                  join asset in saaentities.T_UI on wo.CLE_UI equals asset.NUM_UI into a
                                  from asset in a.DefaultIfEmpty()
                                  join assetfamily in saaentities.T_FAMILLE_UI on asset.CLE_FAM equals assetfamily.CLE_FAM into af
                                  from assetfamily in af.DefaultIfEmpty()
                                  join wostat in saaentities.T_ETAT_BT on wo.CLE_ETAT_BT equals wostat.CLE_ETAT_BT into wos
                                  from wostat in wos.DefaultIfEmpty()
                                  join wotype in saaentities.T_TYPE_TRAV on wo.CLE_TYPE_TRAV equals wotype.NUM_TYPE_TRAV into wot
                                  from wotype in wot.DefaultIfEmpty()
                                  where wo.DATE_DEB_PREV >= filterStart && wo.DATE_DEB_PREV <= filterEnd
                                  select new
                {
                    woid = wo.NUM_BT,
                    wodesc = wo.TITRE_BT,
                    oldstat = statchange.OLD_ETAT,
                    newstat = statchange.NEW_ETAT,
                    wostat = wostat.DES_ETAT_BT,
                    wotype = wotype.DES_TYPE_TRAV,
                    assetgrp = assetfamily.CODE_FAM,
                    planneddt = wo.DATE_DEB_PREV,
                    responsedt = statchange.RESPONSE,
                    closedt = wo.DATE_CLOT
                }).AsEnumerable()
                                 .Where(p => p.wostat == "Closed")
                                 .Select(c => new {
                    woid       = c.woid,
                    wodesc     = c.wodesc,
                    oldstat    = c.oldstat,
                    newstat    = c.newstat,
                    wostat     = c.wostat,
                    wotype     = c.wotype,
                    assetgrp   = c.assetgrp,
                    planneddt  = c.planneddt,
                    responsedt = c.responsedt,
                    closedt    = c.closedt,
                    elapsec    = (((DateTime)(c.responsedt)).Subtract((DateTime)(c.planneddt)).TotalSeconds)
                });


                if (woType != "All")
                {
                    respoQuery = respoQuery.Where(p => p.wotype == woType);
                }

                if (asstGrp != "All")
                {
                    respoQuery = respoQuery.Where(p => p.assetgrp == asstGrp);
                }



                List <ResponseTimeKpiSummModel> respTimeKpiSumm = new List <ResponseTimeKpiSummModel>();

                foreach (var wo in respoQuery)
                {
                    //int countWorkOrderByMonthYear = (from h in newq where h.MONTHYEAR == month select h).Count();
                    //int countWorkOrderByFam = (from h in newq where h.CODE_FAM == dFam select h).Count();
                    //int countStaff = (from h in newq where h.CODE_FAM == dFam group h by new { h.PRENOM_INTERV } into g select g.Key.PRENOM_INTERV).Count();

                    //int countOutStandingWo = (from oswo in newq where oswo.WOSTAT != "Closed" && oswo.WOSTAT != "Completed" && oswo.CODE_FAM == dFam select oswo).Count();
                    //int countCompltWo = (from oswo in newq where oswo.MONTHYEAR == month && (oswo.WOSTAT == "Closed" || oswo.WOSTAT == "Completed") select oswo).Count();
                    respTimeKpiSumm.Add(new ResponseTimeKpiSummModel()
                    {
                        Description = wo.wodesc,
                        AssetGrp    = wo.assetgrp,
                        Percentage  = wo.elapsec.ToString()
                    });
                }

                ReportDataSource datasource = new ReportDataSource("DataSet1", respTimeKpiSumm);
                rvRespoTimeKpiSumm.LocalReport.DataSources.Clear();
                rvRespoTimeKpiSumm.Width  = (Request.Browser.ScreenPixelsWidth) * 2 - 100;
                rvRespoTimeKpiSumm.Height = (Request.Browser.ScreenPixelsHeight) * 2 - 100;
                //rvWoDetails.Width = (Request.Browser.ScreenPixelsWidth) * 2 - 100;
                //rvWoDetails.Height = (Request.Browser.ScreenPixelsHeight) * 2 - 100;
                rvRespoTimeKpiSumm.LocalReport.DataSources.Add(datasource);


                //int s = queryz.Count();
            }
        }