Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    int siteId  = int.Parse(Request.QueryString["SiteId"]);
                    int plantId = int.Parse(Request.QueryString["PlantId"]);
                    int lineId  = int.Parse(Request.QueryString["LineId"]);


                    int machineId = 0;
                    int.TryParse(Request.QueryString["MachineId"], out machineId);


                    //  int machineId = (Request.QueryString["MachineId"] != ""? int.Parse(Request.QueryString["MachineId"]):0) ;

                    DateTime startDate = DateTime.Parse(Request.QueryString["StartDate"]);
                    DateTime endDate   = DateTime.Parse(Request.QueryString["EndDate"]);
                    //string year = Request.QueryString["year"];

                    BreakDownReportService _breakDownReportService = new BreakDownReportService();
                    var dataSource = _breakDownReportService.GetHistoryReportGridData(siteId, plantId, lineId, machineId, startDate, endDate, true);
                    //var dataSource = _breakDownReportService.GetHistoryReportGridData(siteId, plantId, lineId, year);
                    String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportsFolder"].ToString();
                    if (dataSource.Count > 0)
                    {
                        rvSiteMapping.Visible        = true;
                        pnlNoData.Visible            = false;
                        rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                        // rvSiteMapping.ServerReport.ReportPath = String.Format(@"\{0}\{1}", reportFolder, Request["ReportName"].ToString());


                        // Customers dsCustomers = GetData("select top 20 * from customers");
                        //ReportDataSource datasource = new ReportDataSource();
                        //datasource.Name = "DataSet1";
                        //rvSiteMapping.LocalReport.DataSources.Clear();
                        //rvSiteMapping.LocalReport.DataSources.Add(datasource);

                        Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource);
                        datasrc.Name = "DataSet1";
                        //datasrc.DataSourceId=
                        rvSiteMapping.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource));
                        this.rvSiteMapping.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("DateFrom", startDate.ToString()));
                        this.rvSiteMapping.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("DateTo", endDate.ToString()));
                        this.rvSiteMapping.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("LineName", dataSource.Select(f => f.LineName).FirstOrDefault()));
                    }
                    else
                    {
                        rvSiteMapping.Visible = false;
                        pnlNoData.Visible     = true;
                        Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource);
                        datasrc.Name = "DataSet1";
                        //datasrc.DataSourceId=
                        rvSiteMapping.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource));
                        //this.rvSiteMapping.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("DateFrom", DateTime.Now.ToString()));
                        //this.rvSiteMapping.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("DateTo", DateTime.Now.ToString()));
                        // this.rvSiteMapping.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("LineName", "P1"));
                    }
                    rvSiteMapping.LocalReport.Refresh();
                }
                catch (Exception ex)
                {
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    int    siteId  = int.Parse(Request.QueryString["SiteId"]);
                    int    plantId = int.Parse(Request.QueryString["PlantId"]);
                    int    lineId  = 0;      //int.Parse(Request.QueryString["LineId"]);
                    int    month   = 0;
                    string year    = "2017"; //Request.QueryString["year"];

                    BreakDownReportService _breakDownReportService = new BreakDownReportService();
                    //List<Services.Models.BreakDownMonthlySummaryDataSet> dataSource = _breakDownReportService.GetBreakdownDataGroupByType(1, plantId, 12, startDate, endDate);
                    List <Services.Models.BreakDownMonthlySummaryDataSet> dataSource = _breakDownReportService.GetBreakdownDataGroupByType(siteId, plantId, 0, year, month);
                    //new DateTime(dateTime.Year, dateTime.Month, 1)
                    if (dataSource.Count > 0)
                    {
                        rvSiteMapping.Visible = true;
                        pnlNoData.Visible     = false;

                        int           maxMonth      = ((from d in dataSource select d.Date.Value).Max()).Month;
                        int           minMonth      = ((from d in dataSource select d.Date.Value).Min()).Month;
                        List <string> BreakDownType = new List <string> {
                            "Electrical", "Mechanical", "Instrumentation", "Utility", "Power", "Process", "PRV", "Idle"
                        };
                        List <string> lines = new List <string>();
                        if (lineId == 0)
                        {
                            lines = _breakDownReportService.getLineNamesByPlantId(plantId);
                        }
                        else
                        {
                            lines.Add(dataSource[0].LineName);
                        }
                        string plantName = _breakDownReportService.getPlantNameBylantId(plantId);

                        for (int i = 1; i <= 12; i++)
                        {
                            foreach (string lineName in lines)
                            {
                                foreach (string type in BreakDownType)
                                {
                                    dataSource.Add(new Services.Models.BreakDownMonthlySummaryDataSet
                                    {
                                        Date          = new DateTime(int.Parse(year), i, 1),
                                        DaysInMonth   = DateTime.DaysInMonth(int.Parse(year), i),
                                        TotalTime     = 0,
                                        PlantName     = plantName,
                                        LineName      = lineName,
                                        BreakDownType = type
                                    });
                                }
                            }
                        }
                        String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportsFolder"].ToString();
                        rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                        Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource);
                        datasrc.Name = "DataSet1";
                        rvSiteMapping.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource));
                        this.rvSiteMapping.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("Year", DateTime.Now.ToString()));
                    }
                    else
                    {
                        rvSiteMapping.Visible = false;
                        pnlNoData.Visible     = true;
                        Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource);
                        datasrc.Name = "DataSet1";
                        rvSiteMapping.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource));
                    }
                    rvSiteMapping.LocalReport.Refresh();
                }
                catch (Exception ex)
                {
                }
            }
        }