Example #1
0
	    public void LoadOperatorProcessReport(int operatorId)
	    {
	        var dataService = new OperatorReportDataService();
	        Report = dataService.GetOperatorProcessReport(operatorId, StartDate, EndDate);

	        var reportDocument = new ReportDocument();

	        var reader =
                new StreamReader(new FileStream(@"Views\Reporting\OperatorProcessReport.xaml", FileMode.Open, FileAccess.Read));
	        reportDocument.XamlData = reader.ReadToEnd();
	        reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Views\Reporting\");
	        reader.Close();

	        var data = new ReportData();

	        // set constant document values
	        data.ReportDocumentValues.Add("PrintDate", DateTime.Now);

	        var titleTabel = new DataTable("TitleTable");
	        titleTabel.Columns.Add("ReportTitle", typeof(string));
            var name = Common.Properties.Resources.ResourceManager.GetString("txtName") + Report.Title;
            var code = Common.Properties.Resources.ResourceManager.GetString("txtCode") + Report.Code;
	        var date = DateTime.Now.ToPersianCompactDateTimeString();
            titleTabel.Rows.Add(new object[] { name });
            titleTabel.Rows.Add(new object[] { code });
            titleTabel.Rows.Add(new object[] { date });

            data.DataTables.Add(titleTabel);

            var totalTabel = new DataTable("TotalTable");
            totalTabel.Columns.Add("TimeTotal", typeof(string));
            totalTabel.Columns.Add("CountTotal", typeof(string));

            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalTargetTime") + Format.ConvertToHMS((int) Report.TotalTargetTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalTargetCount") + Report.TotalTargetCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalProductionTime") + Format.ConvertToHMS((int)Report.TotalProductionTime), Common.Properties.Resources.ResourceManager.GetString("txTotalProductionCount") + Report.TotalProductionCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalExtraTime") + Format.ConvertToHMS((int)Report.TotalExtraTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalExtraCount") + Report.TotalExtraCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalShortageTime") + Format.ConvertToHMS((int)Report.TotalShortageTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalShortageCount") + Report.TotalShortageCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalDefectionTime") + Format.ConvertToHMS((int)Report.TotalDefectionTime), Common.Properties.Resources.ResourceManager.GetString("txtTotalDefectionCount") + Report.TotalDefectionCount });
            totalTabel.Rows.Add(new object[] { Common.Properties.Resources.ResourceManager.GetString("txtTotalWaste") + Report.TotalWaste, Common.Properties.Resources.ResourceManager.GetString("txtTotalSecondGrade") + Report.TotalSecondGrade });


            data.DataTables.Add(totalTabel);

	        var activitiesTable = new DataTable("ActivitiesReport");

            activitiesTable.Columns.Add("Date", typeof(string));
	        activitiesTable.Columns.Add("Product", typeof (string));
	        activitiesTable.Columns.Add("Station", typeof (string));
	        activitiesTable.Columns.Add("Activity", typeof (string));
	        activitiesTable.Columns.Add("TargetValue", typeof (string));
	        activitiesTable.Columns.Add("ProductionValue", typeof (string));
	        activitiesTable.Columns.Add("DefectionValue", typeof (string));
	        activitiesTable.Columns.Add("StoppageValue", typeof (string));
	        activitiesTable.Columns.Add("IsRework", typeof (string));

	        foreach (var item in Report.ActivityItems)
	        {
	            activitiesTable.Rows.Add(CurrentType == OEType.CountBased
	                ? new object[]
	                {
	                    item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, item.TargetCount, item.ProductionCount,
	                    item.DefectionCount, item.StoppageCount, item.IsRework
	                }
	                : new object[]
	                {
	                    item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, item.TargetTime, item.ProductionTime,
	                    item.DefectionTime, item.StoppageTime, item.IsRework
	                });
	        }

	        data.DataTables.Add(activitiesTable);

            var qualitiveTable = new DataTable("QualitiveReport");

            qualitiveTable.Columns.Add("Date", typeof(string));
            qualitiveTable.Columns.Add("Product", typeof(string));
            qualitiveTable.Columns.Add("Station", typeof(string));
            qualitiveTable.Columns.Add("Activity", typeof(string));
            qualitiveTable.Columns.Add("DefectionValue", typeof(string));
            qualitiveTable.Columns.Add("SecondGrade", typeof(string));
            qualitiveTable.Columns.Add("Waste", typeof(string));

            foreach (var item in Report.QualitiveItems)
            {
                var waste = item.Status == QualitiveStatus.Waste ? "*" : string.Empty;
                var secondGrade = item.Status == QualitiveStatus.SecondGrade ? "*" : string.Empty;
                var defection = CurrentType == OEType.CountBased ? item.DefectionCount : item.DefectionTime;
                qualitiveTable.Rows.Add(new object[]
                    {
                        item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, defection, secondGrade, waste
	                });
            }

            data.DataTables.Add(qualitiveTable);

            var technicalTable = new DataTable("TechnicalReport");

            technicalTable.Columns.Add("Date", typeof(string));
            technicalTable.Columns.Add("Product", typeof(string));
            technicalTable.Columns.Add("Station", typeof(string));
            technicalTable.Columns.Add("Activity", typeof(string));
            technicalTable.Columns.Add("StoppageValue", typeof(string));

            foreach (var item in Report.TechnicalItems)
            {
                var stoppage = CurrentType == OEType.CountBased ? item.StoppageCount : item.StoppageTime;
                technicalTable.Rows.Add(new object[]
                    {
                        item.Date.ToShortDateString(), item.Product, item.Station, item.Activity, stoppage
	                });
            }

            data.DataTables.Add(technicalTable);


	        XpsDocument xps = reportDocument.CreateXpsDocument(data);

	        Document = xps.GetFixedDocumentSequence();
            
	    }
Example #2
0
 public OperationReportsVm(AccessType access)
 {
     CenterPoint = 0;
     StartingPoint = 0;
     Access = access;
     _history = new Stack<OperatorBarInfo>();
     DataService = new OperatorReportDataService();
     CurrentInterval = DateTimeIntervals.Monthly;
     Scales = new ObservableCollection<int>();
     ScaleLines = new ObservableCollection<int>();
     InitializeProviders(null);
     CenterDateChanged += OperationReportsVmCenterDateChanged;
     NavigateInsideCommand = new Command(NavigateInside, CanNavigateInside);
     NavigateBackCommand = new Command(NavigateBack,CanNavigateBack);
     InitializeProviderCommand = new Command(InitializeProviders);
     RefreshCommand = new Command(Refresh,CanRefresh);
 }