示例#1
0
        public bool AddLabReport(LabReport LR)
        {
            MySqlCommand mysqlcommand = new MySqlCommand("addLabReport", this.con);

            mysqlcommand.CommandType = CommandType.StoredProcedure;

            mysqlcommand.Parameters.AddWithValue("_description", LR.Descriptionm);
            mysqlcommand.Parameters.AddWithValue("_patientid", LR.patientId);
            mysqlcommand.Parameters.AddWithValue("_patientname", LR.patientName);
            mysqlcommand.Parameters.AddWithValue("_doctorid", LR.docId);
            mysqlcommand.Parameters.AddWithValue("_doctername", LR.docName);
            mysqlcommand.Parameters.AddWithValue("_createdate", LR.createdate);
            mysqlcommand.Parameters.AddWithValue("_completedate", LR.completedate);
            mysqlcommand.Parameters.AddWithValue("_type", LR.types);
            mysqlcommand.Parameters.AddWithValue("_status", LR.status);
            mysqlcommand.Parameters.AddWithValue("_labassistentid", LR.labAssistent);
            mysqlcommand.Parameters.AddWithValue("_labassistentname", LR.labAssistentname);
            mysqlcommand.Parameters.AddWithValue("_reporturl", LR.reportUrl);

            if (mysqlcommand.ExecuteNonQuery() >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public ActionResult CreateReport(LabReport collection)
        {
            List <Patient> Patients = _context.Patients.ToList();

            ViewBag.Patientlist = new SelectList(Patients, "Id", "Name");

            List <Doctor> Doctors = _context.Doctors.ToList();

            ViewBag.Doctorlist   = new SelectList(Doctors, "DoctorName", "DoctorName");
            collection.Updated   = DateTime.Now;
            collection.UpdatedBy = User.Identity.Name;
            try
            {
                // Will be deleated

                collection.PatientName = _context.Patients.FirstOrDefault(x => x.Id == collection.PatientId).Name;
                _context.LabReport.Add(collection);
                _context.SaveChanges();
                ViewBag.Status = "Yes";
                return(View(collection));
            }
            catch
            {
                ViewBag.Status = "Not";
                return(View(collection));
            }
        }
示例#3
0
        public LabReportTO(LabReport report)
        {
            if (report == null)
            {
                return;
            }
            this.panel = new LabPanelTO(report.Panel);
            //if (report.Tests != null && report.Tests.Count > 0)
            //{
            //    tests = new LabTestArray(report.Tests);
            //}
            if (report.Result != null)
            {
                result = new LabResultTO(report.Result);
            }
            author     = new AuthorTO(report.Author);
            caseNumber = report.CaseNumber;
            comment    = report.Comment;
            if (report.Facility != null)
            {
                facility = new SiteTO(new mdo.Site(report.Facility.Id, report.Facility.Name));
            }
            id = report.Id;
            //Specimen = new LabSpecimenTO(report.Specimen);
            timestamp = report.Timestamp;
            title     = report.Title;
            type      = report.Type;
            text      = report.Text;

            if (report.Specimen != null)
            {
                specimen = new LabSpecimenTO(report.Specimen);
            }
        }
示例#4
0
        // GET: LabResults/Create
        public ActionResult Create(Guid id) // this is lab report id
        {
            try
            {
                LabReport labReport  = db.LabReports.SingleOrDefault(q => q.Id == id);
                var       categories = db.TestTypes
                                       .Select(q => new TestTypeVM {
                    Id = q.Id, Category = q.Category
                })
                                       .ToList()
                                       .DistinctBy(q => q.Category)
                                       .ToList();
                ReportResultVM reportResultVM = new ReportResultVM
                {
                    LabReport = labReport
                };

                ViewBag.Category        = new SelectList(categories, "Category", "Category");
                ViewBag.TestItem        = new SelectList(db.TestTypes, "Id", "TestItem");
                ViewBag.DefaultCategory = categories.First().Category;

                return(View(reportResultVM));
            }
            catch (Exception e)
            {
                ViewBag.ExceptionMessage = e.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
示例#5
0
        // GET: LabReport/Details/5
        public ActionResult ReportDetails(Guid?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                LabReport labReport = context.LabReports.Find(id);

                Guid pid = new Guid(User.Identity.Name);
                ViewBag.PatientId = pid;

                if (labReport == null)
                {
                    return(HttpNotFound());
                }
                return(View(labReport));
            }
            catch (Exception e)
            {
                ViewBag.ExceptionMessage = e.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
示例#6
0
 public static void UpdateLabReport(this LabReport labReport, LabReportVM labReportVM)
 {
     labReport.Description = labReportVM.Description;
     labReport.LabName     = labReportVM.LabName;
     labReport.SeqNum      = labReportVM.SeqNum;
     labReport.TCDate      = labReportVM.TCDate;
     labReport.TCNumber    = labReportVM.TCNumber;
 }
        internal MDLabReport GetDBLabReport(LabReport report)
        {
            MDLabReport mdReport = report.ConvertToDbEntity();

            mdReport.InsertedDate = DateTime.Now;
            mdReport.UpdatedDate  = DateTime.Now;
            mdReport.isDeleted    = false;
            return(mdReport);
        }
示例#8
0
 public static MDLabReport ConvertToDbEntity(this LabReport report)
 {
     return(new MDLabReport()
     {
         ProfileID = report.ProfileId,
         LabReportId = report.ReportId ?? 0,
         Report = JsonConvert.SerializeObject(report.LabTests),
         ReportDate = report.ReportDate
     });
 }
        public async Task <IHttpActionResult> UpsertAsyn(LabReport report)
        {
            long updatedReportId = await manager.UpsertReportAsync(report);

            if (report.ReportId != updatedReportId)
            {
                return(Created(new Uri($"{Request.RequestUri.GetLeftPart(UriPartial.Authority)}/labreport/{updatedReportId}"), updatedReportId));
            }
            return(Ok(report.ReportId));
        }
示例#10
0
        private static void CreateLabReports(ApplicationDbContext dbContext)
        {
            //local variables
            DateTime createdDate      = new DateTime(2020, 01, 01, 12, 30, 00);
            DateTime lastModifiedDate = DateTime.Now;

            //default User who created patients
            var userId = dbContext.Users.Where(u => u.UserName == "Admin")
                         .FirstOrDefault().Id;

            //Create 2 type of lab reports
            string[] labReportTypes = { "regular", "expedited" };

            //Collet 10 patient ids to insert into the foreign key
            var patientIds = dbContext.Patients.Take(10).Select(p => p.Id).ToList();

            //#if DEBUG
            foreach (var id in patientIds)
            {
                //create 2 lab reports for each patient
                var labReport_1 = new LabReport
                {
                    Id               = Guid.NewGuid(),
                    PatientId        = id,
                    Result           = LabTestResult.Positive,
                    Status           = LabReportStatus.Routine,
                    Physician        = "Test Physician",
                    CreatedDate      = createdDate,
                    LastModifiedDate = lastModifiedDate,
                    LabReportType    = labReportTypes[0],
                    LabTestTime      = DateTime.Now,
                    CreatedByUserId  = userId
                };
                var labReport_2 = new LabReport
                {
                    Id               = Guid.NewGuid(),
                    PatientId        = id,
                    Result           = LabTestResult.Negative,
                    Status           = LabReportStatus.Stat,
                    Physician        = "Test Physician 2",
                    CreatedDate      = createdDate,
                    LastModifiedDate = lastModifiedDate,
                    LabReportType    = labReportTypes[1],
                    LabTestTime      = DateTime.Now,
                    CreatedByUserId  = userId
                };

                dbContext.LabReports.Add(labReport_1);
                dbContext.LabReports.Add(labReport_2);

                //saving the changes
                dbContext.SaveChanges();
            }
            //#endif
        }
示例#11
0
 private string SelectedReport(MillDetail millDetail, LabReport labReport)
 {
     if (millDetail != null && !string.IsNullOrWhiteSpace(millDetail.MillName) && !string.IsNullOrWhiteSpace(millDetail.TCNumber))
     {
         return("MillDetails");
     }
     else
     {
         return("LabReports");
     }
 }
示例#12
0
文件: BL.cs 项目: mohithadira/Parla
        void AddReport(LabReport labReport)
        {
            labReports.Add(labReport);

            Console.Write($"Report ID : {labReport.reportID}\t");
            Console.Write($"Patient Name : {labReport.patientName}\n");
            Console.Write($"Test Date : {labReport.testDate}\t");
            Console.Write($"Test Type : {labReport.testType}\n");
            Console.Write($"Doctor Name : {labReport.doctor}\n");
            Console.Write($"Remarks : {labReport.remarks}\n");
    }
示例#13
0
 public IHttpActionResult GetLabReports(long?doctorTreatmentId)
 {
     try
     {
         labReport = new LabReport();
         var result = labReport.GetLabReport(doctorTreatmentId);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#14
0
 public IHttpActionResult Dental_ShowTreatmentLabReport(long?labReportRequestId)
 {
     try
     {
         labReport = new LabReport();
         var result = labReport.Dental_ShowTreatmentLabReport(labReportRequestId);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public ActionResult Edit(int id)
        {
            List <Patient> Patients = _context.Patients.ToList();

            ViewBag.Patientlist = new SelectList(Patients, "Id", "Name");

            List <Doctor> Doctors = _context.Doctors.ToList();

            ViewBag.Doctorlist = new SelectList(Doctors, "DoctorName", "DoctorName");
            LabReport labReport = _context.LabReport.Find(id);

            return(View(labReport));
        }
示例#16
0
 public LabReportTO(LabReport report)
 {
     Author     = new AuthorTO(report.Author);
     CaseNumber = report.CaseNumber;
     Comment    = report.Comment;
     if (report.Facility != null)
     {
         Facility = new SiteTO(new mdo.Site(report.Facility.Id, report.Facility.Name));
     }
     Id        = report.Id;
     Specimen  = new LabSpecimenTO(report.Specimen);
     Timestamp = report.Timestamp;
     Title     = report.Title;
 }
        public ActionResult Edit(int id, LabReport collection)
        {
            try
            {
                collection.Updated   = DateTime.Now;
                collection.UpdatedBy = User.Identity.Name;

                collection.PatientName = _context.Patients.FirstOrDefault(x => x.Id == collection.PatientId).Name;

                _context.Entry(collection).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();

                return(RedirectToAction("Reportlist"));
            }
            catch { return(View()); }
        }
示例#18
0
 public IHttpActionResult SaveLabReport(LabReport labReport)
 {
     try
     {
         //labReport = new LabReport();
         var result = labReport.SaveLabReport();
         if (result == null)
         {
             return(NotFound());
         }
         return(Ok(result));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#19
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            try
            {
                LabReport     labReport = db.LabReports.Find(id);
                List <Result> results   = db.Results.Where(q => q.LabReport.Id == id).ToList();
                Guid          patientId = labReport.PatientId;

                db.Results.RemoveRange(results);
                db.LabReports.Remove(labReport);
                db.SaveChanges();
                return(RedirectToAction("Index", new { Id = patientId }));
            }
            catch (Exception e)
            {
                ViewBag.ExceptionMessage = e.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
        public IActionResult Put([FromBody] LabReportViewModel m)
        {
            // return generic HTTP Status 500 if client payload is invalid
            if (m == null)
            {
                return(new StatusCodeResult(500));
            }

            var labReport = new LabReport();

            //properties taken from request
            labReport.PatientId       = m.PatientId;
            labReport.Result          = m.Result;
            labReport.Status          = m.Status;
            labReport.Physician       = m.Physician;
            labReport.LabReportType   = m.LabReportType;
            labReport.CreatedByUserId = m.CreatedByUserId;
            labReport.LabTestTime     = m.LabTestTime;

            //server side properties
            labReport.Id               = Guid.NewGuid();
            labReport.CreatedDate      = DateTime.Now;
            labReport.LastModifiedDate = DateTime.Now;

            //Created by admin
            labReport.CreatedByUserId = DbContext.Users.Where(u => u.UserName == "Admin")
                                        .FirstOrDefault().Id;

            //adding the patient to the database
            DbContext.LabReports.Add(labReport);

            //persist to DB
            DbContext.SaveChanges();

            // return created patient back to client

            return(new JsonResult(labReport.Adapt <LabReportViewModel>(),
                                  new JsonSerializerOptions
            {
                WriteIndented = true
            }));
        }
示例#21
0
        public async Task <long> UpsertReportAsync(LabReport report)
        {
            MDLabReport dbLabReport = await dbContext.LabReports.Where(rpt => rpt.LabReportId == report.ReportId).FirstOrDefaultAsync();

            if (dbLabReport == null)
            {
                dbLabReport = GetDBLabReport(report);
                dbContext.MemberProfiles.Where(mp => mp.ProfileID == dbLabReport.ProfileID).FirstOrDefault().ConsolidatedReport = dbLabReport.Report;
                dbContext.LabReports.Add(dbLabReport);
            }
            else
            {
                dbLabReport.Report = JsonConvert.SerializeObject(report.LabTests);
                dbLabReport.MemberProfile.ConsolidatedReport = dbLabReport.Report;
            }

            await dbContext.SaveChangesAsync();

            return(dbLabReport.LabReportId);
        }
示例#22
0
        // GET: LabReport/Edit/5
        public ActionResult Edit(Guid?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                LabReport   labReport   = db.LabReports.Find(id);
                LabReportVM labReportVM = new LabReportVM
                {
                    Id             = labReport.Id,
                    CollectionDate = labReport.CollectionDate,
                    IssueDate      = labReport.IssueDate,
                    OrderedBy      = labReport.OrderedBy,
                    PatientId      = labReport.PatientId,
                    Status         = labReport.Status
                };

                var patient = labReport.Patient;
                ViewBag.PatientName = $"{patient.FirstName} {patient.LastName}";
                ViewBag.PatientId   = patient.Id;

                if (labReport == null)
                {
                    return(HttpNotFound());
                }

                return(View(labReportVM));
            }
            catch (Exception e)
            {
                ViewBag.ExceptionMessage = e.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
示例#23
0
        public ActionResult Create(Guid id, LabReportVM labReportVM, bool add_result) // this id is PatientId
        {
            try
            {
                if (ModelState.IsValid)
                {
                    LabReport labReport = new LabReport()
                    {
                        PatientId      = id,
                        Id             = Guid.NewGuid(),
                        CollectionDate = labReportVM.CollectionDate,
                        IssueDate      = DateTime.Now,
                        OrderedBy      = labReportVM.OrderedBy,
                        Status         = labReportVM.Status
                    };
                    db.LabReports.Add(labReport);
                    db.SaveChanges();

                    if (add_result)
                    {
                        return(RedirectToAction("Create", "LabResults", new { Id = labReport.Id }));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "LabReport", new { Id = labReport.PatientId }));
                    }
                }

                return(View(labReportVM));
            }
            catch (Exception e)
            {
                ViewBag.ExceptionMessage = e.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
示例#24
0
        public ActionResult Edit(LabReportVM labReportVM, bool add_result)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var patientId = labReportVM.PatientId;

                    LabReport labReport = new LabReport
                    {
                        OrderedBy      = labReportVM.OrderedBy,
                        Status         = labReportVM.Status,
                        CollectionDate = labReportVM.CollectionDate,
                        PatientId      = labReportVM.PatientId,
                        IssueDate      = labReportVM.IssueDate,
                        Id             = labReportVM.Id
                    };

                    db.Entry(labReport).State = EntityState.Modified;
                    db.SaveChanges();

                    if (add_result)
                    {
                        return(RedirectToAction("Create", "LabResults", new { Id = labReport.Id }));
                    }
                    return(RedirectToAction("Index", "LabReport", new { Id = labReport.PatientId }));
                }

                return(View(labReportVM));
            }
            catch (Exception e)
            {
                ViewBag.ExceptionMessage = e.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
示例#25
0
        // GET: LabReport/Delete/5
        public ActionResult Delete(Guid?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                LabReport labReport = db.LabReports.Find(id);
                ViewBag.PatientId = labReport.PatientId;

                if (labReport == null)
                {
                    return(HttpNotFound());
                }
                return(View(labReport));
            }
            catch (Exception e)
            {
                ViewBag.ExceptionMessage = e.Message;
            }
            return(View("~/Views/Errors/Details.cshtml"));
        }
示例#26
0
 public bool UpdateLabReport(LabReport LR)
 {
     throw new NotImplementedException();
 }
        public async Task LabReportLog(CommandContext ctx,
                                       [Description("\nTakes group IDs, type !group to retrieve all groups.\n")] string groupId              = "",
                                       [Description("\nTakes class' short names, type !class to retrive all classes.\n")] string classType   = "",
                                       [Description("\nTakes dates in dd/mm/yyyy format, accepts different separators.\n")] string eventDate = "",
                                       [Description("\nTakes time in hh:mm format.\n")] string eventTime = "",
                                       [Description("\nTakes additional information, multiple words must be wrapped with \"\".\n")] string additionalInfo = "",
                                       [Description("\nTakes material links, multiple links must be wrapped with \"\".\n")] string materials = "")
        {
            DateTime parsedEventDate = new DateTime();
            DateTime parsedEventTime = new DateTime();

            if (groupId == "")
            {
                await ctx.RespondAsync("Learn to read you dumbass. The command looks like: !labreport <group> <class> <labReportDate> <labReportTime> Try again!");

                return;
            }
            else if (!JackTheStudent.Program.groupList.Contains(groupId))
            {
                await ctx.RespondAsync("There's no such group dumbass. Try again!");

                return;
            }
            else if (classType == "")
            {
                await ctx.RespondAsync("Learn to read you dumbass. The command looks like: !labreport <group> <class> <labReportDate> <labReportTime> Try again!");

                return;
            }
            else if (!JackTheStudent.Program.classList.Any(c => c.ShortName == classType))
            {
                await ctx.RespondAsync("There's no such class, you high bruh?");

                return;
            }
            else if (eventDate == "")
            {
                await ctx.RespondAsync("There's date missing, fix it!");

                return;
            }
            else if (!DateTime.TryParse(eventDate, out parsedEventDate))
            {
                await ctx.RespondAsync("That's not a valid date you retard, learn to type!");

                return;
            }
            else if (eventTime == "")
            {
                await ctx.RespondAsync("There's time missing, fix it!");

                return;
            }
            else if (!DateTime.TryParse(eventTime, out parsedEventTime))
            {
                await ctx.RespondAsync("That's not a valid time you retard, learn to type!");

                return;
            }
            else
            {
                try {
                    using (var db = new JackTheStudentContext()){
                        var labReport = new LabReport {
                            Class          = classType,
                            Date           = parsedEventDate.Date.Add(parsedEventTime.TimeOfDay),
                            GroupId        = groupId,
                            LogById        = ctx.Message.Author.Id.ToString(),
                            LogByUsername  = ctx.Message.Author.Username + "#" + ctx.Message.Author.Discriminator,
                            AdditionalInfo = additionalInfo,
                            Materials      = materials
                        };
                        JackTheStudent.Program.labReportList.Add(labReport);
                        db.LabReport.Add(labReport);
                        await db.SaveChangesAsync();
                    }
                } catch (Exception ex) {
                    Console.Error.WriteLine("[Jack] " + ex.ToString());
                    await ctx.RespondAsync("Log failed");

                    return;
                }
                await ctx.RespondAsync("Lab report logged successfully");

                return;
            }
        }
示例#28
0
        public void GenerateDimensions()
        {
            try
            {
                int r, m, n;
                Foot_H                   = Foot_Sol_H + Foot_PCC_H + Foot_Rect_H + Foot_Trap_H;
                WallBelowGL_H            = Brick_Sol_H + Brick_PCC_H + LWall_H;
                TotalFinal_Wall_Beam_Len = Final_TL - ANc * Col_L + Nj * Lj;
                //1.General------------------------------------------------------------------
                //1.1 Information board
                InfoBoard            = 1;
                TotalEachQuantity[0] = InfoBoard;

                //1.2 Lab report
                LabReport            = 1;
                TotalEachQuantity[1] = LabReport;

                //2. Earth work------------------------------------------------------------------
                //2.1 Excavation for Column Foundation
                r = 0;
                Earthwork[r, 0] = ANc;
                Earthwork[r, 1] = Foot_Length_L + Foot_Proj_PCC;
                Earthwork[r, 2] = Foot_Breadth_B + Foot_Proj_PCC;
                Earthwork[r, 3] = Foot_H + WallBelowGL_H + Beam_H;
                Earthwork[r, 4] = Earthwork[r, 0] * Earthwork[r, 1] * Earthwork[r, 2] * Earthwork[r, 3];

                //Excavation for Wall Foundation
                r = 1;
                Earthwork[r, 0] = 1;
                Earthwork[r, 1] = TotalFinal_Wall_Beam_Len + Col_L * Nw - (Foot_Length_L + Foot_Proj_PCC) * Nw;
                Earthwork[r, 2] = Lower_Wall_Th + Brick_Proj_PCC * 2;
                Earthwork[r, 3] = WallBelowGL_H + Beam_H;
                Earthwork[r, 4] = Earthwork[r, 0] * Earthwork[r, 1] * Earthwork[r, 2] * Earthwork[r, 3];

                TotalEachQuantity[2] = Earthwork[0, 4] + Earthwork[1, 4];

                //2.2 Earth fill
                EW_Filling           = Convert.ToSingle(2.0 / 3.0) * TotalEachQuantity[2];
                TotalEachQuantity[3] = EW_Filling;

                //3. Concrete Work------------------------------------------------------------------
                //3.1 PCC for footing
                r = 0;
                Concretework[r, 0] = ANc;
                Concretework[r, 1] = Foot_Length_L + Foot_Proj_PCC;
                Concretework[r, 2] = Foot_Breadth_B + Foot_Proj_PCC;
                Concretework[r, 3] = Foot_PCC_H;
                Concretework[r, 4] = Concretework[r, 0] * Concretework[r, 1] * Concretework[r, 2] * Concretework[r, 3];

                //PCC for Wall
                r = 1;
                Concretework[r, 0] = 1;
                Concretework[r, 1] = TotalFinal_Wall_Beam_Len;
                Concretework[r, 2] = Lower_Wall_Th + Brick_Proj_PCC * 2;
                Concretework[r, 3] = Brick_PCC_H;
                Concretework[r, 4] = Concretework[r, 0] * Concretework[r, 1] * Concretework[r, 2] * Concretework[r, 3];

                //Coping
                r = 2;
                Concretework[r, 0] = 1;
                Concretework[r, 1] = Final_TL;
                Concretework[r, 2] = Coping_B; // Upper_Wall_Th
                Concretework[r, 3] = Coping_H;
                Concretework[r, 4] = Concretework[r, 0] * Concretework[r, 1] * Concretework[r, 2] * Concretework[r, 3];

                TotalEachQuantity[4] = Concretework[0, 4] + Concretework[1, 4] + Concretework[2, 4];

                //3.2 Column foundation base (Rectangular)
                r = 3;
                Concretework[r, 0] = ANc;
                Concretework[r, 1] = Foot_Length_L;
                Concretework[r, 2] = Foot_Breadth_B;
                Concretework[r, 3] = Foot_Rect_H;
                Concretework[r, 4] = Concretework[r, 0] * Concretework[r, 1] * Concretework[r, 2] * Concretework[r, 3];

                //Slope Part Top of Trapezoidal
                r = 4;
                Concretework[r, 0] = ANc;
                Concretework[r, 1] = Col_L + Foot_Trap_Proj * 2;
                Concretework[r, 2] = Col_B + Foot_Trap_Proj * 2;
                Concretework[r, 3] = Foot_Trap_H;
                Trap_LArea         = Foot_Length_L * Foot_Breadth_B;
                Trap_UArea         = Concretework[r, 1] * Concretework[r, 2];
                float sumArea, SqrRt;
                sumArea = Trap_LArea + Trap_UArea;
                SqrRt   = Convert.ToSingle(Math.Sqrt(Trap_LArea * Trap_UArea));
                float Trap_Volume = Concretework[r, 3] / 3 * (sumArea + SqrRt);
                Concretework[r, 4] = Trap_Volume * ANc;

                //Tie Beam
                r = 5;
                Concretework[r, 0] = 1;
                Concretework[r, 1] = TotalFinal_Wall_Beam_Len;
                Concretework[r, 2] = Beam_B;
                Concretework[r, 3] = Beam_H;
                Concretework[r, 4] = Concretework[r, 0] * Concretework[r, 1] * Concretework[r, 2] * Concretework[r, 3];

                //Column
                r = 6;
                Concretework[r, 0] = ANc;
                Concretework[r, 1] = Col_L;
                Concretework[r, 2] = Col_B;
                Concretework[r, 3] = WallBelowGL_H + Beam_H + UWall_H;
                Concretework[r, 4] = Concretework[r, 0] * Concretework[r, 1] * Concretework[r, 2] * Concretework[r, 3];

                TotalEachQuantity[5] = Concretework[3, 4] + Concretework[4, 4] + Concretework[5, 4] + Concretework[6, 4];

                //3.3 Reiforcement
                Reinf = 4000;
                TotalEachQuantity[6] = Reinf;

                //4. Masonry------------------------------------------------------------------
                //4.1 Column Foundation soling
                r = 0;
                Masonrywork[r, 0] = ANc;
                Masonrywork[r, 1] = Foot_Length_L + Foot_Proj_PCC;
                Masonrywork[r, 2] = Foot_Breadth_B + Foot_Proj_PCC;
                Masonrywork[r, 3] = Foot_Sol_H;
                Masonrywork[r, 4] = Masonrywork[r, 0] * Masonrywork[r, 1] * Masonrywork[r, 2] * Masonrywork[r, 3];

                //Wall Foundation soling
                r = 1;
                Masonrywork[r, 0] = 1;
                Masonrywork[r, 1] = TotalFinal_Wall_Beam_Len;
                Masonrywork[r, 2] = Lower_Wall_Th + Brick_Proj_PCC * 2;
                Masonrywork[r, 3] = Brick_Sol_H;
                Masonrywork[r, 4] = Masonrywork[r, 0] * Masonrywork[r, 1] * Masonrywork[r, 2] * Masonrywork[r, 3];

                TotalEachQuantity[7] = Masonrywork[0, 4] + Masonrywork[1, 4];

                //4.2 Lower brick work
                r = 2;
                Masonrywork[r, 0] = 1;
                Masonrywork[r, 1] = TotalFinal_Wall_Beam_Len;
                Masonrywork[r, 2] = Lower_Wall_Th;
                Masonrywork[r, 3] = LWall_H;
                Masonrywork[r, 4] = Masonrywork[r, 0] * Masonrywork[r, 1] * Masonrywork[r, 2] * Masonrywork[r, 3];

                TotalEachQuantity[8] = Masonrywork[2, 4];

                //4.3 Upper brick work
                r = 3;
                Masonrywork[r, 0] = 1;
                Masonrywork[r, 1] = TotalFinal_Wall_Beam_Len;
                Masonrywork[r, 2] = Upper_Wall_Th;
                Masonrywork[r, 3] = UWall_H;
                Masonrywork[r, 4] = Masonrywork[r, 0] * Masonrywork[r, 1] * Masonrywork[r, 2] * Masonrywork[r, 3];

                TotalEachQuantity[9] = Masonrywork[3, 4];

                //Write Dimension and product to Datagridview of Detail Estimate
                dataGridViewDetEst.Rows[1].Cells[6].Value = InfoBoard.ToString("0.000");   //1.1
                dataGridViewDetEst.Rows[4].Cells[6].Value = LabReport.ToString("0.000");   //1.2

                WriteToDataGridViewOfDetEst(9, 10, 0, Earthwork);                          //2.1 Earthwork
                dataGridViewDetEst.Rows[14].Cells[6].Value = EW_Filling.ToString("0.000"); //2.2

                WriteToDataGridViewOfDetEst(19, 21, 0, Concretework);                      //3.1 Concrete work
                WriteToDataGridViewOfDetEst(25, 28, 3, Concretework);                      //3.2 Concrete work
                dataGridViewDetEst.Rows[32].Cells[6].Value = Reinf.ToString("0.000");      //3.3

                WriteToDataGridViewOfDetEst(37, 38, 0, Masonrywork);                       //4.1 Masonry work
                WriteToDataGridViewOfDetEst(42, 42, 2, Masonrywork);                       //4.2 Masonry work
                WriteToDataGridViewOfDetEst(46, 46, 3, Masonrywork);                       //4.3 Masonry work

                //Write Total of each quantity to Datagridview of Detail Estimate
                dataGridViewDetEst.Rows[2].Cells[6].Value = TotalEachQuantity[0].ToString("0.000");
                dataGridViewDetEst.Rows[5].Cells[6].Value = TotalEachQuantity[1].ToString("0.000");

                dataGridViewDetEst.Rows[11].Cells[6].Value = TotalEachQuantity[2].ToString("0.000");
                dataGridViewDetEst.Rows[15].Cells[6].Value = TotalEachQuantity[3].ToString("0.000");

                dataGridViewDetEst.Rows[22].Cells[6].Value = TotalEachQuantity[4].ToString("0.000");
                dataGridViewDetEst.Rows[29].Cells[6].Value = TotalEachQuantity[5].ToString("0.000");
                dataGridViewDetEst.Rows[33].Cells[6].Value = TotalEachQuantity[6].ToString("0.000");

                dataGridViewDetEst.Rows[39].Cells[6].Value = TotalEachQuantity[7].ToString("0.000");
                dataGridViewDetEst.Rows[43].Cells[6].Value = TotalEachQuantity[8].ToString("0.000");
                dataGridViewDetEst.Rows[47].Cells[6].Value = TotalEachQuantity[9].ToString("0.000");
            }
            catch
            {
            }
        }
示例#29
0
        public void TestReportsWithOneComputer_includeClasses()
        {

            Lab lab = new Lab();
            lab.LabId = 3000;
            ComputerLab cl = new ComputerLab();
            cl.Computer = new Computer();
            cl.Computer.ComputerId = 3000;
            cl.Lab = lab;
            cl.Entrance = new DateTime(2010, 2, 15);
            cl.Exit = new DateTime(2010, 3, 15, 10, 0, 0);
            lab.ComputerLabs.Add(cl);
            cl.Computer.ComputerLabs.Add(cl);

            Activity act1 = new Activity();
            act1.Computer = cl.Computer;
            cl.Computer.Activities.Add(act1);
            act1.Login = new DateTime(2010, 2, 16, 10, 0, 0);
            act1.Logout = new DateTime(2010, 2, 16, 12, 0, 0);
            act1.Mode = ActivityType.User;

            Activity cact1 = new Activity();
            cact1.Computer = cl.Computer;
            cl.Computer.Activities.Add(cact1);
            cact1.Login = new DateTime(2010, 2, 16, 10, 0, 0);
            cact1.Logout = new DateTime(2010, 2, 16, 12, 0, 0);
            cact1.Mode = ActivityType.Class;


            ReportModel model = new ReportModel(controller);
            List<int> list = new List<int>();
            DateTime startDate = new DateTime(2010, 2, 16);
            DateTime endDate = new DateTime(2010, 2, 17);
            DateTime startHour = new DateTime();
            TimeSpan ts = new TimeSpan(9, 00, 0);
            startHour = startHour.Date + ts;

            DateTime endHour = new DateTime();
            ts = new TimeSpan(19, 00, 0);
            endHour = endHour.Date + ts;


            //
            string msg = "2h user activity, 2h user activity - union 2h";
            LabReport lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(2, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(2, item.GetComputerTotalActiveTimeWithClasses().Hours, msg + ": computer total activity time (with classes)");

                Assert.AreEqual(10, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(20, item.AverageUsage, msg + "- avarageUsage of comp ");
            }
            Assert.AreEqual(20, lr.AverageUsage, msg + "- avarageUsage of lab ");

            cact1.Login = new DateTime(2010, 2, 16, 9, 0, 0);
            cact1.Logout = new DateTime(2010, 2, 16, 11, 0, 0);
            //
            msg = "2h user activity, 2h user activity- union 3h";
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(2, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(3, item.GetComputerTotalActiveTimeWithClasses().Hours, msg + ": computer total activity time (with classes)");

                Assert.AreEqual(10, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(20, item.AverageUsage, msg + "- avarageUsage of comp ");
                Assert.AreEqual(30, item.ScheduleAverageUsage, msg + "- avarageUsage of comp ");

            }
            Assert.AreEqual(20, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(30, lr.ScheduleAverageUsage, msg + "- avarageUsage of lab ");

            cact1.Login = new DateTime(2010, 2, 16, 9, 0, 0);
            cact1.Logout = new DateTime(2010, 2, 16, 14, 0, 0);
            //
            msg = "2h user activity, 5h user activity- union 5h";
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(2, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(5, item.GetComputerTotalActiveTimeWithClasses().Hours, msg + ": computer total activity time (with classes)");

                Assert.AreEqual(10, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(20, item.AverageUsage, msg + "- avarageUsage of comp ");
                Assert.AreEqual(50, item.ScheduleAverageUsage, msg + "- avarageUsage of comp ");

            }
            Assert.AreEqual(20, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(50, lr.ScheduleAverageUsage, msg + "- avarageUsage of lab ");

            cact1.Login = new DateTime(2010, 2, 16, 13, 0, 0);
            cact1.Logout = new DateTime(2010, 2, 16, 15, 0, 0);
            //
            msg = "2h user activity, 2h user activity- union 4h";
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(2, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(4, item.GetComputerTotalActiveTimeWithClasses().Hours, msg + ": computer total activity time (with classes)");

                Assert.AreEqual(10, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(20, item.AverageUsage, msg + "- avarageUsage of comp ");
                Assert.AreEqual(40, item.ScheduleAverageUsage, msg + "- avarageUsage of comp ");

            }
            Assert.AreEqual(20, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(40, lr.ScheduleAverageUsage, msg + "- avarageUsage of lab ");

            //
            Activity cact2 = new Activity();
            cact2.Computer = cl.Computer;
            cl.Computer.Activities.Add(cact2);
            cact2.Login = new DateTime(2010, 2, 16, 10, 30, 0);
            cact2.Logout = new DateTime(2010, 2, 16, 12, 30, 0);
            cact2.Mode = ActivityType.Class;


            msg = "1h out of 2h, 1.5h union with class";
            startHour = new DateTime().Date + new TimeSpan(11, 0, 0);
            endHour = new DateTime().Date + new TimeSpan(13, 0, 0);
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(1, item.GetComputerTotalActiveTime().TotalHours, msg + ": computer total activity time ");
                Assert.AreEqual(1.5, item.GetComputerTotalActiveTimeWithClasses().TotalHours, msg + ": computer total class activity time ");
                Assert.AreEqual(2, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(50, item.AverageUsage, msg + "- avarageUsage of comp ");
                Assert.AreEqual(75, item.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of comp ");

            }
            Assert.AreEqual(50, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(75, lr.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of lab ");


            //

            msg = "1h out of 2h, class union-1h";
            startHour = new DateTime().Date + new TimeSpan(9, 0, 0);
            endHour = new DateTime().Date + new TimeSpan(11, 0, 0);
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(1, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(1, item.GetComputerTotalActiveTimeWithClasses().Hours, msg + ": computer total class activity time ");
                Assert.AreEqual(2, item.GetComputerTotalTime(), msg + ": computer total time");


                Assert.AreEqual(50, item.AverageUsage, msg + "- avarageUsage of comp ");
                Assert.AreEqual(50, item.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of comp ");

            }
            Assert.AreEqual(50, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(50, lr.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of lab ");


            //
            msg = "no user activity out of 2h, class union- 2h";
            startHour = new DateTime().Date + new TimeSpan(13, 00, 0);
            endHour = new DateTime().Date + new TimeSpan(15, 00, 0);
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(0, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(2, item.GetComputerTotalActiveTimeWithClasses().Hours, msg + ": computer total class activity time ");
                Assert.AreEqual(2, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(0, item.AverageUsage, msg + "- avarageUsage of comp ");
                Assert.AreEqual(100, item.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of comp ");

            }
            Assert.AreEqual(0, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(100, lr.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of lab ");


            cact2.Login = new DateTime(2010, 2, 16, 10, 30, 0);
            cact2.Logout = new DateTime(2010, 2, 16, 11, 30, 0);

            Activity cact3 = new Activity();
            cact3.Computer = cl.Computer;
            cl.Computer.Activities.Add(cact3);
            cact3.Login = new DateTime(2010, 2, 16, 11, 30, 0);
            cact3.Logout = new DateTime(2010, 2, 16, 12, 30, 0);
            cact3.Mode = ActivityType.Class;

            // two activities 10-12,13-15
            Activity act2 = new Activity();
            act2.Computer = cl.Computer;
            cl.Computer.Activities.Add(act2);
            act2.Login = new DateTime(2010, 2, 16, 13, 0, 0);
            act2.Logout = new DateTime(2010, 2, 16, 15, 0, 0);
            act2.Mode = ActivityType.User;

            //
            msg = "0h out of 1h, class union- 0.5h";
            startHour = new DateTime().Date + new TimeSpan(12, 00, 0);
            endHour = new DateTime().Date + new TimeSpan(13, 00, 0);
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(0, item.GetComputerTotalActiveTime().TotalHours, msg + ": computer total activity time ");
                Assert.AreEqual(0.5, item.GetComputerTotalActiveTimeWithClasses().TotalHours, msg + ": computer total class activity time ");

                Assert.AreEqual(1, item.GetComputerTotalTime(), msg + ": computer total time");
            }
            Assert.AreEqual(0, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(50, lr.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of lab ");

            Activity act3 = new Activity();
            act3.Computer = cl.Computer;
            cl.Computer.Activities.Add(act3);
            act3.Login = new DateTime(2010, 2, 16, 8, 0, 0);
            act3.Logout = new DateTime(2010, 2, 16, 9, 0, 0);
            act3.Mode = ActivityType.User;
            Activity act4 = new Activity();
            act3.Computer = cl.Computer;
            cl.Computer.Activities.Add(act4);
            act4.Login = new DateTime(2010, 2, 16, 9, 30, 0);
            act4.Logout = new DateTime(2010, 2, 16, 10, 0, 0);
            act4.Mode = ActivityType.User;
            Activity cact4 = new Activity();
            act3.Computer = cl.Computer;
            cl.Computer.Activities.Add(cact4);
            cact4.Login = new DateTime(2010, 2, 16, 8, 30, 0);
            cact4.Logout = new DateTime(2010, 2, 16, 9, 30, 0);
            cact4.Mode = ActivityType.Class;
            cact1.Login = new DateTime(2010, 2, 16, 14, 0, 0);
            cact1.Logout = new DateTime(2010, 2, 16,16, 0, 0);
            //
            msg = "5.5h out of 10h, class union-7.5h";
            startHour = new DateTime().Date + new TimeSpan(8, 00, 0);
            endHour = new DateTime().Date + new TimeSpan(18, 00, 0);
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(5.5, item.GetComputerTotalActiveTime().TotalHours, msg + ": computer total activity time ");
                Assert.AreEqual(7.5, item.GetComputerTotalActiveTimeWithClasses().TotalHours, msg + ": computer total class activity time ");

                Assert.AreEqual(10, item.GetComputerTotalTime(), msg + ": computer total time");
            }
            Assert.AreEqual((int)55, (int)lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(75, lr.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of lab ");

            //
            msg = "2h out of 3h, class union-2.5h";
            startHour = new DateTime().Date + new TimeSpan(11, 00, 0);
            endHour = new DateTime().Date + new TimeSpan(14, 00, 0);
            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(2, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(2.5, item.GetComputerTotalActiveTimeWithClasses().TotalHours, msg + ": computer total class activity time ");

                Assert.AreEqual(3, item.GetComputerTotalTime(), msg + ": computer total time");
            }
            Assert.AreEqual(Math.Round(((double)2 / 3) * 100,2), lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(Math.Round(((double)2.5 / 3) * 100, 2), lr.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of lab ");

            //
            msg = "no activities should be included in the report out of 20 hours";
            startHour = new DateTime().Date + new TimeSpan(8, 00, 0);
            endHour = new DateTime().Date + new TimeSpan(18, 00, 0);
            startDate = new DateTime(2010, 2, 17);
            endDate = new DateTime(2010, 2, 19);

            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(0, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(0, item.GetComputerTotalActiveTimeWithClasses().Hours, msg + ": computer total class activity time ");

                Assert.AreEqual(20, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(0, item.AverageUsage, msg + "- avarageUsage of comp ");
            }
            Assert.AreEqual(0, lr.AverageUsage, msg + "- avarageUsage of lab ");
            Assert.AreEqual(0, lr.ScheduleAverageUsage, msg + "- ScheduleAverageUsage of lab ");

            //
            msg = "no activities computer exit the lab during the report";
            startHour = new DateTime().Date + new TimeSpan(8, 00, 0);
            endHour = new DateTime().Date + new TimeSpan(12, 00, 0);
            startDate = new DateTime(2010, 3, 15);
            endDate = new DateTime(2010, 3, 16);

            lr = model.CreateLabReport(startDate, endDate, startHour, endHour, lab, true);

            Assert.AreEqual(1, lr.ComputersReport.Count, "one computer report expected: " + msg);
            foreach (var item in lr.ComputersReport)
            {
                Assert.AreEqual(0, item.GetComputerTotalActiveTime().Hours, msg + ": computer total activity time ");
                Assert.AreEqual(2, item.GetComputerTotalTime(), msg + ": computer total time");

                Assert.AreEqual(0, item.AverageUsage, msg + "- avarageUsage of comp ");
            }
            Assert.AreEqual(0, lr.AverageUsage, msg + "- avarageUsage of lab ");

        }
示例#30
0
 public Task <long> UpsertReportAsync(LabReport report)
 {
     return(dataManager.UpsertReportAsync(report));
 }