Beispiel #1
0
        private void FindVideoFilePath()
        {
            if (!IsValid)
                return;

            Video video = null;
            using (var db = new DefaultContext())
            {
                if (_isAdmin && Id > 0)
                {
                    video = VideoCache.GetDetail(db, Id);
                }
                else if (!String.IsNullOrEmpty(Token))
                {
                    string decryptedToken = Cryptography.Decrypt(Token);
                    if (String.IsNullOrEmpty(decryptedToken))
                        return;

                    int videoTokenId;
                    if (!Int32.TryParse(decryptedToken, out videoTokenId) || videoTokenId < 1)
                        return;

                    VideoToken videoToken = VideoTokenCache.GetDetail(db, videoTokenId);
                    if (videoToken == null)
                        return;

                    if (!videoToken.IsPlayedByRecipient && videoToken.Sender != null && videoToken.Recipient != null)
                    {
                        DateTime timeToSend = DateTime.Now.AddSeconds(videoToken.Video.Duration);
                        string textBody = String.Format(videoToken.Video.EmailSenderBody, videoToken.Recipient.FullName, videoToken.Video.Title, timeToSend.ToString("dd. MM. yyyy HH:mm:ss"));
                        var lazyMail = new LazyMail
                                           {
                                               Address = videoToken.Sender.Email1,
                                               TextBody = textBody,
                                               TimeToSend = timeToSend
                                           };
                        LazyMailCache.InsertWithoutSave(db, lazyMail);

                        videoToken.IsPlayedByRecipient = true;

                        VideoTokenCache.Update(db, videoToken);
                    }

                    video = videoToken.Video;
                }
            }

            if (video == null)
                return;

            string videoAbsoluteFilePath = FileService.GetAbsoluteFilePath(_server, video.RelativeFilePath);
            if (!File.Exists(videoAbsoluteFilePath))
                return;

            VideoRelativeFilePath = video.RelativeFilePath;
            VideoAbsoluteFilePath = videoAbsoluteFilePath;
        }
Beispiel #2
0
 public static void InsertWithoutSave(DefaultContext db, LazyMail lazyMail)
 {
     db.LazyMails.Add(lazyMail);
 }