Beispiel #1
0
        public void Update(long soundId, HttpPostedFileBase sound, string soundDescription)
        {
            try
            {
                var s = _sr.Find(soundId);
                if (s == null)
                {
                    return;
                }
                s.Description = soundDescription;
                _sr.Update(s);

                if (sound != null)
                {
                    var arr = new byte[sound.ContentLength];
                    sound.InputStream.Read(arr, 0, arr.Length);

                    var rawSound = _rsr.Find(soundId);
                    if (rawSound == null)
                    {
                        return;
                    }
                    rawSound.Data     = arr;
                    rawSound.FileName = sound.FileName;
                    rawSound.MIMEType = sound.ContentType;
                    _rsr.Update(rawSound);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
            }
        }
Beispiel #2
0
        public ActionResult SoundTests()
        {
            try
            {
                var ctm = new CacheTestModel();

                var c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (c == null)
                {
                    ctm.Message = "Initial Get Failed";
                    return(View(ctm));
                }

                var dt = DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal);

                var rawSound = new RawSound();
                rawSound.Data     = new byte[1];
                rawSound.FileName = "LocationControllerTest";
                rawSound.MIMEType = "audio/mpeg";

                var s = new Sound();
                s.GHLocationID = 1;
                s.Description  = "Location Controller Test";
                s.UserName     = UserHelper.Instance.CurrentUserName;
                _sr.Insert(s);

                rawSound.RawSoundID = s.SoundID;
                _rsr.Insert(rawSound);

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal) == dt)
                {
                    ctm.Message = "Update Date Last Modified On Sound Insert Failed";
                    return(View(ctm));
                }
                dt = DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal);

                s.Description = "Cache Update Test";
                _sr.Update(s);

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal) == dt)
                {
                    ctm.Message = "Update Date Last Modified On Sound Update Failed";
                    return(View(ctm));
                }
                dt = DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal);

                _sr.Delete(s);
                _rsr.Delete(rawSound);

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                if (DateTime.Parse(c.DateLastModified, null, DateTimeStyles.AdjustToUniversal) == dt)
                {
                    ctm.Message = "Update Date Last Modified On Sound Delete Failed";
                    return(View(ctm));
                }

                c = CacheHelper <GHLocationTransmitModel> .Instance.GetCacheable("1");

                ctm.Message = "Success";

                return(View(ctm));
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                return(new HttpStatusCodeResult(500));
            }
        }