Exemplo n.º 1
0
        public void AddStream(Models.Stream stream, bool local, Panel toPanel)
        {
            StreamInfo ctrlInfo = new StreamInfo
            {
                infoFileURL = stream.URL,
            };

            if (stream.Size != "-")
            {
                ctrlInfo.infoSize.Text = UtilityTools.bytesToString(Convert.ToInt32(stream.Size));
            }
            else
            {
                ctrlInfo.infoSize.Text = stream.Size;
            }
            if (stream.DateUploaded != "-")
            {
                ctrlInfo.infoAge.Text = UtilityTools.getTimeAgo(Convert.ToDateTime(stream.DateUploaded));
            }
            else
            {
                ctrlInfo.infoAge.Text = stream.DateUploaded;
            }
            ctrlInfo.infoName.Text = stream.Name;
            toPanel.Controls.Add(ctrlInfo);
        }
Exemplo n.º 2
0
        public ActionResult Create(School school)
        {
            if (ModelState.IsValid)
            {
                SchoolAddress schoolAddress = new SchoolAddress();

                if (school.schoolAddress.street != null)
                {
                    school.schoolAddress.street = school.schoolAddress.street.Trim();
                }
                school.name = school.name.Trim();
                school.schoolAddress.suburb = school.schoolAddress.suburb.Trim();
                school.schoolAddress.city   = school.schoolAddress.city.Trim();

                var schl = db.Schools.ToList().Find(p => p.name.ToLower() == school.name.ToLower());
                if (schl != null)
                {
                    ModelState.AddModelError("", "This school has already been registered.");
                    return(View(school));
                }

                byte[] imageData = new byte[0];
                if (school.poImgFile != null)
                {
                    using (var binary = new BinaryReader(school.poImgFile.InputStream))
                    {
                        imageData = binary.ReadBytes(school.poImgFile.ContentLength);
                    }
                }
                school.schoolPhoto     = imageData;
                schoolAddress.province = school.schoolAddress.province;
                schoolAddress.street   = school.schoolAddress.street;
                schoolAddress.suburb   = school.schoolAddress.suburb;
                schoolAddress.city     = school.schoolAddress.city;
                schoolAddress.code     = school.schoolAddress.code;
                db.Schools.Add(school);
                schoolAddress.School = school;
                db.SchoolAddresses.Add(schoolAddress);
                db.SaveChanges();
                var stream = new Models.Stream {
                    name = "Grade 8 & 9", school = school
                };
                db.Streams.Add(stream);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(school));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fix any gaps in the stream by adding empty stream rows (just have a time stream)
        /// </summary>
        internal void FixGaps()
        {
            foreach (int missingTime in FindGapsInStream())
            {
                // find the previous stream item.  We'll use this to get some values for the new time row.
                Stream previous = this.Stream.Where(t => t.Time == missingTime - 1).FirstOrDefault();

                // create new stream item with default values.
                Stream newItem = new Models.Stream()
                {
                    Time        = missingTime,
                    ActivityId  = ActivityId,
                    Latitude    = previous.Latitude,
                    Longitude   = previous.Longitude,
                    Moving      = false,
                    Altitude    = previous.Altitude,
                    Distance    = previous.Distance,
                    Temperature = previous.Temperature,
                    HeartRate   = previous.HeartRate
                };

                // for velocity, gradient, cadence and watts then if the stream is un use set value to 0
                // so as not to mess up peaks/averages by copying previous values.
                if (previous.Velocity != null)
                {
                    newItem.Velocity = 0;
                }

                if (previous.Gradient != null)
                {
                    newItem.Gradient = 0;
                }

                if (previous.Cadence != null)
                {
                    newItem.Cadence = 0;
                }

                if (previous.Watts != null)
                {
                    newItem.Watts = 0;
                }

                this.Stream.Add(newItem);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Add Stream
 /// </summary>
 /// <param name="encodingId">Id of the encoding. (required)</param>
 /// <param name="stream">The Stream to be created</param>
 public async Task <Models.Stream> CreateAsync(string encodingId, Models.Stream stream)
 {
     return(await _apiClient.CreateAsync(encodingId, stream));
 }