コード例 #1
0
        /// <summary>
        /// Method to Save Report Data
        /// </summary>
        /// <param name="report">Report</param>
        /// <returns><c>true</c> if Report data is successfully saved else returns <c>false</c></returns>
        public bool SaveReportData(Report report)
        {
            bool isReportDataSaved = false;

            try
            {
                if (report != null && report.ReportDataList != null && report.ReportDataList.Count > 0)
                {
                    ReportEntity rptEntity = new ReportEntity()
                    {
                        Name       = report.Name,
                        ImportDate = DateTime.Now
                    };

                    db.Report.Add(rptEntity);
                    db.SaveChanges();

                    foreach (var reportData in report.ReportDataList)
                    {
                        ReportDataEntity rptDataEntity = new ReportDataEntity()
                        {
                            ReportId      = rptEntity.ReportId,
                            Node          = reportData.Node,
                            Panel         = reportData.Panel,
                            Event         = reportData.Event,
                            EventDateTime = reportData.EventDateTime,
                            CardNumber    = reportData.CardNumber,
                            CardName      = reportData.CardName,
                            Location      = reportData.Location,
                            ReaderId      = reportData.ReaderId,
                            In            = reportData.In,
                            Out           = reportData.Out,
                            Affiliation   = reportData.Affiliation,
                            AlarmText     = reportData.AlarmText,
                            EmployeeName  = ExtractEmployeeFirstName(reportData.CardName) + " " + ExtractEmployeeLastName(reportData.CardName),
                            EmployeeCode  = ExtractEmployeeCode(reportData.CardName)
                        };

                        db.ReportData.Add(rptDataEntity);
                    }

                    db.SaveChanges();
                    isReportDataSaved = true;
                }
            }
            catch (Exception ex) {
                throw ex;
            }
            return(isReportDataSaved);
        }
コード例 #2
0
        public static ReportDataEntity CalculateReport(Context ctx, ReportDataEntity reportDataEntity)
        {
            ReportDataEntity entity;
            ICaculateService service = ServiceFactory.GetService <ICaculateService>(ctx);

            try
            {
                entity = service.CalculateReport(ctx, reportDataEntity);
            }
            finally
            {
                ServiceFactory.CloseService(service);
            }
            return(entity);
        }
コード例 #3
0
        public static IOperationResult Save(Context ctx, ReportDataEntity entity)
        {
            IOperationResult        result;
            IReportOperationService service = ServiceFactory.GetService <IReportOperationService>(ctx);

            try
            {
                result = service.Save(ctx, entity);
            }
            finally
            {
                ServiceFactory.CloseService(service);
            }
            return(result);
        }