示例#1
0
        /// <summary>
        /// Gets the next report number for this foundry
        /// </summary>
        /// <param name="ctx">Context under which to give the report number</param>
        /// <returns></returns>
        public String getNextReportNumber(RadiographyContext ctx)
        {
            //period logic - first check whether which is the current period or we need to create a new period
            if(NextResetDate < DateTime.Now)
            {
                //end date the current period, and create a new period
                if(CurrentPeriod != null)
                {
                    CurrentPeriod.EndDate = NextResetDate;
                }
                var newPeriod = new Period
                    {
                        StartDate = NextResetDate,
                        Foundry = this,
                        FoundryID = ID,
                    };
                Periods.Add(newPeriod);

                //set the next reset date to one year hence
                NextResetDate = NextResetDate.AddYears(1);
                //for ctx to get these changes
                ctx.Foundries.AttachAsModified(this, ctx);
                ctx.Periods.Add(newPeriod);
                ctx.SaveChanges();
            }

            //fetch immediately from the database, otherwise convert.toint32 will fail
            var reports = ctx.RGReports.Where(p => p.ReportNo.StartsWith(this.ReportNumberPrefix) && p.ReportDate > CurrentPeriod.StartDate).ToList();
            var lastNumber = !reports.Any() ? 0 : reports.Max(p => Convert.ToInt32(p.ReportNo.Replace(ReportNumberPrefix, "")));
            return String.Concat(ReportNumberPrefix, " ", (lastNumber + 1).ToString("D4"));
        }
示例#2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            Database.SetInitializer<RadiographyContext>(new CustomDBInitializer());

            //TODO: this is done to force database create if it is not already created. Check how to avoid this
            RadiographyContext context = new RadiographyContext();
            var test = context.Customers.Count();

            //initialize culture
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-IN");
        }
示例#3
0
        /// <summary>
        /// This constructor creates an follow up RG report based on an existing RG Report for the same RT No. 
        /// </summary>
        /// <param name="reportNo"> </param>
        /// <param name="ctx">Database Context with reference which to create the object</param>
        /// <param name="parentRGReports"> </param>
        public RGReport(List<RGReport> parentRGReports, String reportNo, RadiographyContext ctx)
        {
            if (reportNo == null) throw new ArgumentNullException("reportNo");
            var latestParent = parentRGReports.OrderByDescending(p => p.ReportDate).First();

            //all rows with some remark
            var rows = from r in parentRGReports.SelectMany(p => p.RGReportRows)
                       where r.Remark != null
                       select r;

            //latest row for each location and segment combination
            var latestRows = rows.Where(p => rows != null && !rows.Any(r => r.Location == p.Location &&
                                                                            r.Segment == p.Segment &&
                                                                            r.RGReport.ReportDate > p.RGReport.ReportDate));

            //all those that are not yet acceptable
            var neededRows = latestRows
                             .Where(p => p.Remark.Value != "ACCEPTABLE")
                             .OrderBy(p => p.FPSLNo);

            latestParent.CopyTo(this, "ID,ReportDate,RGReportRows");
            this.ReportDate = DateTime.Now;
            this.ReportNo = reportNo;
            this.RGReportRows = new List<RGReportRow>();
            this.RowsDeleted = false;

            //since this is at least the second report
            this.First = false;

            //categorize this report as reshoot, and assign reshoot number
            this.ReportType = "Reshoot";
            this.ReshootNo = parentRGReports.Max(p => p.ReshootNo) + 1;
            this.ReportTypeAndNo = this.ReportType + "-" + this.ReshootNo.ToString();

            //only those rows to be copied from entire history which do not have acceptable against that particular location and segment
            var slNo = 1;

            foreach (var row in neededRows)
            {
                if (row.Remark.Value == "ACCEPTABLE") continue;

                //row type for this row depends on the corresponding parent rows remarks
                var reportRow = new RGReportRow()
                {
                    RowType = RGReportRowType.getRowType(row.Remark.Value, ctx),
                    Observations = " "
                };
                row.CopyTo(reportRow,
                    "ID,RGReport,Observations,Remark,RemarkText,ObservationsText," +
                    "Technician,TechnicianText,Welder,WelderText,RowType,ReportNo");
                reportRow.SlNo = slNo++;
                this.RGReportRows.Add(reportRow);
            }
        }
示例#4
0
        /// <summary>
        /// This constructor creates an initial RGReport based on an existing fpTemplate. It does not check whether
        /// an existing RG Report exists, so make sure of that before calling this method
        /// </summary>
        /// <param name="fpTemplate"></param>
        /// <param name="ctx">Database Context with reference which to create the object</param>
        public RGReport(FixedPatternTemplate fpTemplate, string RTNo, string ReportNo, RadiographyContext ctx)
        {
            //shallow copy properties
            fpTemplate.CopyTo(this, "ID");
            this.DateOfTest = this.ReportDate = DateTime.Now;
            this.Shift = Shift.getShift("DAY", ctx); //defaulting so it can be saved
            this.Status = RGStatus.getStatus("CASTING UNDER REPAIR", ctx);
            this.RTNo = RTNo;
            this.ReportNo = ReportNo;

            RGReportRowType freshRowType = RGReportRowType.getRowType("FRESH", ctx);
            if (fpTemplate.FPTemplateRows == null) return;

            this.RGReportRows = new List<RGReportRow>();

            //some default values as suggested by Shankaran (10-Apr-2012)
            this.Film = "AGFA D7";
            if (fpTemplate.FixedPattern.Customer.FoundryID == 7)
            {
                this.LeadScreen = "0.25mm"; //Default for Leadscreen changed as per NEW requirements shared on 07-Jun-14.
                this.LeadScreenBack = "0.25mm"; //Default for Leadscreen changed as per NEW requirements shared on 07-Jun-14.
            }
            else if (fpTemplate.FixedPattern.Customer.FoundryID == 6)
            {
                this.LeadScreen = "0.125mm"; //Default for Leadscreen changed as per NEW requirements shared on 07-Jun-14.
                this.LeadScreenBack = "0.125mm"; //Default for Leadscreen changed as per NEW requirements shared on 07-Jun-14.
            }
            this.ReportTypeAndNo = this.ReportType = "Fresh";
            this.ReshootNo = 0; //explicitly setting this, even though this is the default value

            //since this is the first report for this FP and RT No
            this.First = true;
            this.RowsDeleted = false;
            foreach (var row in fpTemplate.FPTemplateRows.OrderBy(p => p.SlNo))
            {
                var rgReportRow = new RGReportRow
                                            {
                                                RowType = freshRowType,
                                                Energy = Energy.getEnergyForThickness(row.Thickness, ctx),
                                                Observations = " ", //for grid to work fine
                                                FilmCount = 1 // default for the new film count
                                            };
                row.CopyTo(rgReportRow, "ID,FilmSizeString");

                //for future reports, so that ordering can be done on this basis
                rgReportRow.FPSLNo = row.SlNo;

                this.RGReportRows.Add(rgReportRow);
            }
        }
        /// <summary>
        /// Gets the data context for the report to be generated
        /// </summary>
        /// <returns></returns>
        private RGReport GetDataContext()
        {
            var reportNo = Request.Params["ReportNo"];
            var reportId =Convert.ToInt32(Request.Params["ReportId"]);

            if (String.IsNullOrEmpty(reportNo))
                return null;

            using (var ctx = new RadiographyContext())
            {
                return ctx.RGReports.Include(p => p.FixedPattern.Customer.Foundry)
                    .Include(p => p.Status)
                    .Include(p => p.RGReportRows.Select(r => r.FilmSize))
                    .Include(p => p.Coverage).FirstOrDefault(p => p.ID == reportId);
            }
        }
示例#6
0
 public static RGStatus getStatus(string status, RadiographyContext ctx)
 {
     return(ctx.RGStatuses.First(p => p.Status == status));
 }
示例#7
0
 public static Observation getObservation(string observationReference, RadiographyContext ctx)
 {
     return ctx.Observations.FirstOrDefault(p => p.Value.ToUpper() == observationReference.ToUpper());
 }
示例#8
0
 public static AcceptanceAsPer getAcceptanceAsPer(string acceptanceAsPer, RadiographyContext ctx)
 {
     return ctx.AcceptanceAsPers.FirstOrDefault(p => p.Value.ToUpper() == acceptanceAsPer.ToUpper());
 }
示例#9
0
 public static Energy getEnergyFromName(String name, RadiographyContext ctx)
 {
     return ctx.Energies.Where(p => p.Name == name).FirstOrDefault();
 }
示例#10
0
 /// <summary>
 /// Get Energy for a particular Thickness by referencing the thickness-energy mapping
 /// </summary>
 /// <param name="thickness"></param>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public static Energy getEnergyForThickness(int thickness, RadiographyContext ctx)
 {
     return ctx.ThicknessRangesForEnergy.Include(p => p.Energy).First(p => p.ThicknessFrom <= thickness
                                             && p.ThicknessTo >= thickness)
                                             .Energy;
 }
示例#11
0
 public static Welder getWelder(string name, RadiographyContext ctx)
 {
     return(ctx.Welders.FirstOrDefault(p => p.Name.ToUpper() == name.ToUpper()));
 }
示例#12
0
 public static RGReportRowType getRowType(string rowType, RadiographyContext ctx)
 {
     return ctx.RGReportRowTypes.First(p => p.Value == rowType);
 }
示例#13
0
 public byte[] GetCompanyLogo()
 {
     using (var ctx = new RadiographyContext())
     {
         var company = ctx.Companies.Include(p => p.Logo).First();
         if (company.Logo != null)
         {
             return company.Logo.FileData;
         }
     }
     return null;
 }
示例#14
0
 public static Observation getObservation(string observationReference, RadiographyContext ctx)
 {
     return(ctx.Observations.FirstOrDefault(p => p.Value.ToUpper() == observationReference.ToUpper()));
 }
示例#15
0
 public static Technician getTechnician(string name, RadiographyContext ctx)
 {
     return ctx.Technicians.FirstOrDefault(p => p.Name.ToUpper() == name.ToUpper());
 }
示例#16
0
 public static ProcedureReference getProcedureReference(string procedureReference, RadiographyContext ctx)
 {
     return ctx.ProcedureReferences.FirstOrDefault(p => p.Value.ToUpper() == procedureReference.ToUpper());
 }
示例#17
0
 /// <summary>
 /// Get Energy for a particular Thickness by referencing the thickness-energy mapping
 /// </summary>
 /// <param name="thickness"></param>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public static Energy getEnergyForThickness(int thickness, RadiographyContext ctx)
 {
     return(ctx.ThicknessRangesForEnergy.Include(p => p.Energy).First(p => p.ThicknessFrom <= thickness &&
                                                                      p.ThicknessTo >= thickness)
            .Energy);
 }
示例#18
0
 public static RGStatus getStatus(string status, RadiographyContext ctx)
 {
     return ctx.RGStatuses.First(p => p.Status == status);
 }
示例#19
0
 public static Specification getSpecification(string specification, RadiographyContext ctx)
 {
     return ctx.Specifications.FirstOrDefault(p => p.Value.ToUpper() == specification.ToUpper());
 }
示例#20
0
 public static Energy getEnergyFromName(String name, RadiographyContext ctx)
 {
     return(ctx.Energies.Where(p => p.Name == name).FirstOrDefault());
 }
示例#21
0
 public static Shift getShift(string value, RadiographyContext ctx)
 {
     return ctx.Shifts.First(p => p.Value == value);
 }
示例#22
0
 public static Remark getRemark(string remark, RadiographyContext ctx)
 {
     return(ctx.Remarks.FirstOrDefault(p => p.Value.ToUpper() == remark.ToUpper()));
 }
示例#23
0
 public static RetakeReason getRetakeReasons(string retakeReason, RadiographyContext ctx)
 {
     return ctx.RetakeReasons.FirstOrDefault(p => p.Value.ToUpper() == retakeReason.ToUpper());
 }
示例#24
0
 public static Remark getRemark(string remark, RadiographyContext ctx)
 {
     return ctx.Remarks.FirstOrDefault(p => p.Value.ToUpper() == remark.ToUpper());
 }
示例#25
0
 public byte[] GetCustomerLogo()
 {
     using (var ctx = new RadiographyContext())
     {
         var customer = ctx.FixedPatterns.Where(p => p.ID == this.FixedPatternID)
                                 .Include(p => p.Customer.Logo)
                                 .First()
                                 .Customer;
         if (customer.Logo != null)
         {
             return customer.Logo.FileData;
         }
     }
     return null;
 }
示例#26
0
 public static Welder getWelder(string name, RadiographyContext ctx)
 {
     return ctx.Welders.FirstOrDefault(p => p.Name.ToUpper() == name.ToUpper());
 }