public static CalendarEvent ConvertToCalendarEvents(IntakeData intakedata)
        {
            var dataArray = intakedata.dateOfIntake.Split(':');

            var date = new DateTime(int.Parse(dataArray[0]), int.Parse(dataArray[1]), int.Parse(dataArray[2]));

            CalendarEvent calendarEvent = new CalendarEvent()
            {
                Start   = date,
                End     = date,
                Subject = intakedata.user +
                          " " +
                          intakedata.dateOfIntake,
                Description =
                    " CHOMealGrams: " + intakedata.CHOMealGrams +
                    " CHORatio: " + intakedata.CHORatio +
                    " InsulinUnits: " + intakedata.InsulinUnits +
                    " weight:" + intakedata.weight +
                    " User: "******"green",
                IsFullDay = true,
            };

            return(calendarEvent);
        }
        public JsonResult GetcurrentDay(IntakeData date)
        {
            var current = date.dateOfIntake.Replace('-', ':');

            TempData["currentDate"] = current;
            return(Json(new { redirectTo = Url.Action("DisplayCurrentDay", "Calendar") }));
        }
        public static IntakeDataModel ConvertToModel(IntakeData intakeData)
        {
            IntakeDataModel data = new IntakeDataModel
            {
                Date              = DateTime.Parse(intakeData.dateOfIntake),
                CalorieIntake     = intakeData.CHOMealGrams,
                CHORatio          = intakeData.CHORatio,
                InsulinUnitsTaken = intakeData.InsulinUnits,
                bloodSugar        = intakeData.bloodSugar,
                weight            = intakeData.weight,
                user              = intakeData.user,
            };

            return(data);
        }
Пример #4
0
        /// <summary>
        /// Read Extractions.
        /// The boolean set dates indicates whether the dates read from the DRWPLANTINTAKE table should be used as Pumpingstart
        /// and pumpingstop.
        /// </summary>
        /// <param name="Plants"></param>
        /// <param name="Wells"></param>
        public IPlantCollection ReadPlants(IWellCollection Wells)
        {
            List <Plant>     Plants  = new List <Plant>();
            IPlantCollection DPlants = new IPlantCollection();

            JXL.ReadPlantData();

            IIntake CurrentIntake = null;
            Plant   CurrentPlant;

            List <Tuple <int, Plant> > SubPlants = new List <Tuple <int, Plant> >();


            foreach (var Anlaeg in JXL.DRWPLANT)
            {
                CurrentPlant = new Plant(Anlaeg.PLANTID);
                DPlants.Add(CurrentPlant);

                if (Anlaeg.IsPLANTNAMENull())
                {
                    CurrentPlant.Name = "<no name in database>";
                }
                else
                {
                    CurrentPlant.Name = Anlaeg.PLANTNAME;
                }

                CurrentPlant.Address = Anlaeg.PLANTADDRESS;

                CurrentPlant.PostalCode = Anlaeg.PLANTPOSTALCODE;

                if (!Anlaeg.IsSUPPLANTNull())
                {
                    CurrentPlant.SuperiorPlantNumber = Anlaeg.SUPPLANT;
                }

                CurrentPlant.NewCommuneNumber = Anlaeg.MUNICIPALITYNO2007;
                CurrentPlant.OldCommuneNumber = Anlaeg.MUNICIPALITYNO;


                var cmp = Anlaeg.GetDRWPLANTCOMPANYTYPERows().LastOrDefault();
                if (cmp != null)
                {
                    CurrentPlant.CompanyType = cmp.COMPANYTYPE;
                }

                if (!Anlaeg.IsPERMITDATENull())
                {
                    CurrentPlant.PermitDate = Anlaeg.PERMITDATE;
                }

                if (!Anlaeg.IsPERMITEXPIREDATENull())
                {
                    CurrentPlant.PermitExpiryDate = Anlaeg.PERMITEXPIREDATE;
                }

                if (Anlaeg.IsPERMITAMOUNTNull())
                {
                    CurrentPlant.Permit = 0;
                }
                else
                {
                    CurrentPlant.Permit = Anlaeg.PERMITAMOUNT;
                }

                if (!Anlaeg.IsSUPPLANTNull())
                {
                    SubPlants.Add(new Tuple <int, Plant>(Anlaeg.SUPPLANT, CurrentPlant));
                }

                if (!Anlaeg.IsXUTMNull())
                {
                    CurrentPlant.X = Anlaeg.XUTM;
                }

                if (!Anlaeg.IsYUTMNull())
                {
                    CurrentPlant.Y = Anlaeg.YUTM;
                }


                //Loop the intakes. Only add intakes from wells already in table
                foreach (var IntakeData in Anlaeg.GetDRWPLANTINTAKERows())
                {
                    if (Wells.Contains(IntakeData.BOREHOLENO))
                    {
                        JupiterWell jw = Wells[IntakeData.BOREHOLENO] as JupiterWell;
                        CurrentIntake = jw.Intakes.FirstOrDefault(var => var.IDNumber == IntakeData.INTAKENO);
                        if (CurrentIntake != null)
                        {
                            PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant);
                            CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake);

                            if (!IntakeData.IsSTARTDATENull())
                            {
                                CurrentPumpingIntake.StartNullable = IntakeData.STARTDATE;
                            }
                            else if (jw.StartDate.HasValue)
                            {
                                CurrentPumpingIntake.StartNullable = jw.StartDate;
                            }
                            else if (CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Count() != 0)
                            {
                                CurrentPumpingIntake.StartNullable = CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Min(var => var.StartDate);
                            }

                            if (!IntakeData.IsENDDATENull())
                            {
                                CurrentPumpingIntake.EndNullable = IntakeData.ENDDATE;
                            }
                            else if (jw.EndDate.HasValue)
                            {
                                CurrentPumpingIntake.EndNullable = jw.EndDate;
                            }
                            else if (CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Count() != 0)
                            {
                                CurrentPumpingIntake.EndNullable = CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Max(var => var.EndDate);
                            }
                        }
                    }
                }
            }
            //Now attach the subplants
            foreach (Tuple <int, Plant> KVP in SubPlants)
            {
                Plant Upper;
                if (DPlants.TryGetValue(KVP.Item1, out Upper))
                {
                    if (Upper == KVP.Item2)
                    {
                        string l = "what";
                    }
                    else
                    {
                        Upper.SubPlants.Add(KVP.Item2);
                        foreach (PumpingIntake PI in KVP.Item2.PumpingIntakes)
                        {
                            PumpingIntake d = Upper.PumpingIntakes.FirstOrDefault(var => var.Intake.well.ID == PI.Intake.well.ID);
                            //Remove pumping intakes from upper plant if they are attached to lower plants.
                            if (d != null)
                            {
                                Upper.PumpingIntakes.Remove(d);
                            }
                        }
                    }
                }
            }

            JXL.DRWPLANT.Dispose();
            JXL.DRWPLANTINTAKE.Dispose();
            return(DPlants);
        }