コード例 #1
0
        // Send mail to owner of group if user posted new topic in group
        private void GroupMailProcessTemplate(string ownerusername, string title, string username, string emailaddress, string inboxurl, long groupid)
        {
            //if sending mail option enabled
            if (Jugnoon.Settings.Configs.SmtpSettings.enable_email)
            {
                var lst = MailTemplateBLL.Get_Template(_context, "GRPTPAPR").Result;
                if (lst.Count > 0)
                {
                    string subject = MailProcess.Process2(lst[0].subject, "\\[ownerusername\\]", ownerusername);
                    subject = MailProcess.Process2(subject, "\\[username\\]", username);

                    string contents = MailProcess.Process2(lst[0].contents, "\\[ownerusername\\]", ownerusername);
                    contents = MailProcess.Process2(contents, "\\[username\\]", ownerusername);

                    string group_url = Config.GetUrl("group/" + groupid);
                    string url       = "<a href=\"" + group_url + "\">" + group_url + "</a>";

                    contents = MailProcess.Process2(contents, "\\[url\\]", url);
                    contents = MailProcess.Process2(contents, "\\[title\\]", title);
                    contents = MailProcess.Process2(contents, "\\[inboxurl\\]", inboxurl);

                    // attach signature
                    contents = MailProcess.Prepare_Email_Signature(contents);

                    MailProcess.Send_Mail(emailaddress, subject, contents);
                }
            }
        }
コード例 #2
0
        // send mail to admin or author of user
        private void Send_Email(string poster_username, string rusername, string emailaddress, string subject, string content, string url, List <JGN_MailTemplates> lst)
        {
            if (rusername != "guest")
            {
                if (rusername == "admin")
                {
                    // mail send to admin
                    emailaddress = Jugnoon.Settings.Configs.GeneralSettings.admin_mail;
                }

                string msubject = MailProcess.Process2(lst[0].subject, "\\[poster_username\\]", poster_username);
                msubject = MailProcess.Process2(msubject, "\\[username\\]", rusername);
                msubject = MailProcess.Process2(msubject, "\\[subject\\]", subject);
                var str = new StringBuilder();
                str.AppendLine("<a href=\"" + url + "\">" + subject + "</a><br /><br />");
                str.AppendLine(WebUtility.HtmlDecode(UtilityBLL.Process_Content_Text(content)));
                string contents = MailProcess.Process2(lst[0].contents, "\\[poster_username\\]", poster_username);
                contents = MailProcess.Process2(contents, "\\[username\\]", rusername);
                contents = MailProcess.Process2(contents, "\\[content\\]", str.ToString());

                // attach signature
                contents = MailProcess.Prepare_Email_Signature(contents);

                MailProcess.Send_Mail(emailaddress, msubject, contents);
            }
        }
コード例 #3
0
    private void MailTemplateProcess(string emailaddress, string username)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            string content = txt_content.Value;
            string subject = MailProcess.Process2(txt_subject.Text, "\\[username\\]", username);

            string contents = MailProcess.Process2(content, "\\[username\\]", username);
            contents = MailProcess.Process2(contents, "\\[email\\]", emailaddress);

            MailProcess.Send_Mail(emailaddress, subject, contents);
        }
    }
コード例 #4
0
    private void MailTemplateProcess(string username)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            string emailaddress = members.Return_Value(username, "email");
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRPRIVCHN");
            if (lst.Count > 0)
            {
                string subject  = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);

                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
コード例 #5
0
    private void MailTemplateProcess(string emailaddress, string username, string url)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("FORPASS");
            if (lst.Count > 0)
            {
                string subject  = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                contents = MailProcess.Process2(contents, "\\[url\\]", url);

                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
コード例 #6
0
 private void ManageAccount_MailTemplateProcess(string username)
 {
     //if sending mail option enabled
     if (Jugnoon.Settings.Configs.SmtpSettings.enable_email)
     {
         string emailaddress = UserBLL.Return_Value_UserId(_context, username, "email");
         var    lst          = MailTemplateBLL.Get_Template(_context, "USRPASSCHN").Result;
         if (lst.Count > 0)
         {
             string subject  = MailProcess.Process2(lst[0].subject, "\\[username\\]", username);
             string contents = MailProcess.Process2(lst[0].contents, "\\[username\\]", username);
             // attach signature
             contents = MailProcess.Prepare_Email_Signature(contents);
             MailProcess.Send_Mail(emailaddress, subject, contents);
         }
     }
 }
コード例 #7
0
    // mail processing
    private void MailTemplateProcess(string emailaddress, string username, string password, string key)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRREG");
            if (lst.Count > 0)
            {
                string subject  = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                contents = MailProcess.Process2(contents, "\\[password\\]", password);
                string validation_url = Config.GetUrl("validate.aspx?key=" + key.Trim() + "&user="******"<a href=\"" + validation_url + "\">" + validation_url + "</a>";
                contents = MailProcess.Process2(contents, "\\[key_url\\]", url);

                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
コード例 #8
0
    // send mail to admin when new content added by user
    public static void Admin_New_Content_Added(string username, string contenttype, string url)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRAPRCNT");
            if (lst.Count > 0)
            {
                string subject = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                subject = MailProcess.Process2(subject, "\\[contenttype\\]", contenttype);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                subject  = MailProcess.Process2(subject, "\\[contenttype\\]", contenttype);
                contents = MailProcess.Process2(contents, "\\[url\\]", url);

                string emailaddress = Site_Settings.Admin_Mail;
                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
コード例 #9
0
    // ******************************
    // Mail Templates
    // ******************************

    // send mail to user when admin approved user posted content
    public static void User_Mail_Content_Action(string username, string contenttype, string url, string status)
    {
        //if sending mail option enabled
        if (Config.isEmailEnabled())
        {
            System.Collections.Generic.List <Struct_MailTemplates> lst = MailTemplateBLL.Get_Record("USRCNTAPP");
            if (lst.Count > 0)
            {
                string subject = MailProcess.Process2(lst[0].Subject, "\\[username\\]", username);
                subject = MailProcess.Process2(subject, "\\[status\\]", status);
                subject = MailProcess.Process2(subject, "\\[contenttype\\]", contenttype);
                string contents = MailProcess.Process2(lst[0].Contents, "\\[username\\]", username);
                contents = MailProcess.Process2(contents, "\\[contenttype\\]", contenttype);
                contents = MailProcess.Process2(contents, "\\[url\\]", url);
                contents = MailProcess.Process2(contents, "\\[status\\]", status);
                string emailaddress = members.Return_Value(username, "email");
                MailProcess.Send_Mail(emailaddress, subject, contents);
            }
        }
    }
        public ActionResult encode()
        {
            var    rootPath   = SiteConfig.Environment.ContentRootPath + "/wwwroot/";
            var    ffmpegPath = rootPath + Jugnoon.Videos.Configs.FfmpegSettings.ffmpeg_path;
            var    json       = new StreamReader(Request.Body).ReadToEnd();
            var    data       = JsonConvert.DeserializeObject <List <EncodeFFMPEGVideo> >(json);
            int    ActionType = data[0].tp;
            string username   = data[0].userid;

            var _response = new Dictionary <string, string>();

            _response["encodeoutput"] = "2.0";

            string Source    = "";
            string Published = "";
            string ProcessID = "";

            switch (ActionType)
            {
            case 0:
                // encode video
                Source    = data[0].sf;
                Published = data[0].pf;

                if (Source != "" && Published != null)
                {
                    var    _mhandler = new MediaHandler();
                    string RootPath  = SiteConfig.Environment.ContentRootPath;
                    _mhandler.FFMPEGPath           = ffmpegPath;
                    _mhandler.InputPath            = UrlConfig.Upload_Path(username, "default");
                    _mhandler.OutputPath           = UrlConfig.Upload_Path(username, "flv");
                    _mhandler.BackgroundProcessing = true;
                    _mhandler.FileName             = Source;
                    _mhandler.OutputFileName       = Published.Replace(Path.GetExtension(Published), "");
                    switch (Jugnoon.Videos.Configs.FfmpegSettings.encoding_options)
                    {
                    case 0:
                        // 240p
                        _mhandler.Parameters = Jugnoon.Videos.Configs.FfmpegSettings.mp4_240p_Settings;
                        break;

                    case 1:
                        // 360p
                        _mhandler.Parameters = Jugnoon.Videos.Configs.FfmpegSettings.mp4_360p_Settings;
                        break;

                    case 2:
                        // 480p
                        _mhandler.Parameters = Jugnoon.Videos.Configs.FfmpegSettings.mp4_480p_Settings;
                        break;

                    case 3:
                        // 720
                        _mhandler.Parameters = Jugnoon.Videos.Configs.FfmpegSettings.mp4_720p_Settings;
                        break;

                    case 4:
                        // 1080p
                        _mhandler.Parameters = Jugnoon.Videos.Configs.FfmpegSettings.mp4_1080p_Settings;
                        break;
                    }
                    _mhandler.OutputExtension = ".mp4";
                    _mhandler.vinfo           = _mhandler.ProcessMedia();
                    if (_mhandler.vinfo.ErrorCode > 0)
                    {
                        // remove file if failed to publish properly
                        if (System.IO.File.Exists(RootPath + "/" + _mhandler.InputPath))
                        {
                            System.IO.File.Delete(RootPath + "/" + _mhandler.InputPath);
                        }

                        _response["encodeoutput"] = "2.0";
                        _response["ecode"]        = _mhandler.vinfo.ErrorCode.ToString();
                        _response["edesc"]        = _mhandler.vinfo.FFMPEGOutput.ToString();


                        var _message = new System.Text.StringBuilder();
                        _message.Append("<h4>Video Upload Error</h4>");
                        _message.Append("<p>Error:" + _mhandler.vinfo.ErrorCode + " _ _ " + _mhandler.vinfo.ErrorMessage + "</p>");
                        _message.Append("<p>Source FileName: " + Source);
                        _message.Append("<p>Published FileName: " + Published);
                        MailProcess.Send_Mail(Jugnoon.Settings.Configs.GeneralSettings.admin_mail, "Publishing Error, description", _message.ToString());

                        return(Ok(_response));
                    }
                    else
                    {
                        // _mhandler.vinfo.ProcessID = Guid.NewGuid().ToString(); // unique guid to attach with each process to identify proper object on progress bar and get info request
                        _lst.Add(_mhandler);
                        _response["encodeoutput"] = "2.0";
                        _response["ecode"]        = _mhandler.vinfo.ErrorCode.ToString();
                        _response["procid"]       = _mhandler.vinfo.ProcessID; // _mhandler.vinfo.ProcessID;
                        return(Ok(_response));
                    }
                }
                break;

            case 1:
                // get progress status
                ProcessID = data[0].pid;
                if (ProcessID != "")
                {
                    string completed_process = "0";
                    if (_lst.Count > 0)
                    {
                        int i = 0;
                        for (i = 0; i <= _lst.Count - 1; i++)
                        {
                            if (_lst[i].vinfo.ProcessID == ProcessID)
                            {
                                completed_process = Math.Round(_lst[i].vinfo.ProcessingCompleted, 2).ToString();
                            }
                        }
                    }

                    _response["encodeoutput"] = "2.0";
                    _response["status"]       = completed_process;
                    return(Ok(_response));
                }

                break;

            case 2:
                // get information
                ProcessID = data[0].pid;
                if (ProcessID != "")
                {
                    if (_lst.Count > 0)
                    {
                        int i = 0;
                        for (i = 0; i <= _lst.Count - 1; i++)
                        {
                            if (_lst[i].vinfo.ProcessID == ProcessID)
                            {
                                _response["status"] = "OK";
                                _response["ecode"]  = _lst[i].vinfo.ErrorCode.ToString();
                                _response["fname"]  = _lst[i].vinfo.FileName.ToString();

                                _response["dur"]    = _lst[i].vinfo.Duration.ToString();
                                _response["dursec"] = _lst[i].vinfo.Duration_Sec.ToString();


                                // remove from list of corrent processes if processes reach this point
                                // store all information of completed process and remove it from list of concurrent processes
                                // e.g
                                VideoInfo current_uploaded_video_info = _lst[i].vinfo;
                                _lst.Remove(_lst[i]);

                                // Validation
                                int    plength = 0;
                                string path    = UrlConfig.Upload_Path(username, "flv") + "\\" + data[0].pf;
                                if (System.IO.File.Exists(path))
                                {
                                    FileInfo flv_info = new FileInfo(path);
                                    plength = (int)flv_info.Length;
                                }
                                if (plength == 0)
                                {
                                    var _message = new System.Text.StringBuilder();
                                    _message.Append("<h4>Video Publishing Error</h4>");
                                    _message.Append("<p>Error: 0kb file generated</p>");
                                    _message.Append("<p>Source FileName: " + Source);
                                    _message.Append("<p>Published FileName: " + Published);
                                    MailProcess.Send_Mail(Jugnoon.Settings.Configs.GeneralSettings.admin_mail, "Publishing Error, description", _message.ToString());
                                }

                                // ii: add meta information to mp4 video
                                try
                                {
                                    var mp4med = new MediaHandler();
                                    mp4med.MP4BoxPath = ffmpegPath;
                                    string _mp4_temp_path = "\"" + UrlConfig.Upload_Path(username, "flv") + "/" + data[0].pf + "\"";
                                    string meta_filename  = data[0].sf.Replace(".mp4", "_meta.mp4");
                                    mp4med.Parameters = "-isma -hint -add " + _mp4_temp_path + "";
                                    mp4med.FileName   = meta_filename;
                                    mp4med.InputPath  = UrlConfig.Upload_Path(username, "flv");
                                    mp4med.Set_MP4_Buffering();

                                    // check whether file created
                                    string pubPath = UrlConfig.Upload_Path(username, "flv");
                                    if (System.IO.File.Exists(pubPath + "\\" + meta_filename))
                                    {
                                        // remove temp mp4 file
                                        if (System.IO.File.Exists(pubPath + "" + data[0].pf))
                                        {
                                            System.IO.File.Delete(pubPath + "\\" + data[0].pf);
                                        }

                                        _response["fname"] = meta_filename;
                                    }
                                    else
                                    {
                                        // file not created by mp4box
                                        // rename published mp4 as _meta.mp4
                                        System.IO.File.Move(pubPath + "\\" + data[0].pf, pubPath + "\\" + meta_filename);
                                        _response["fname"] = meta_filename;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    var _message = new System.Text.StringBuilder();
                                    _message.Append("<h4>Video Meta Information Error</h4>");
                                    _message.Append("<p>Error: " + ex.Message + "</p>");
                                    _message.Append("<p>Source FileName: " + Source);
                                    _message.Append("<p>Published FileName: " + Published);
                                    MailProcess.Send_Mail(Jugnoon.Settings.Configs.GeneralSettings.admin_mail, "Publishing Error, description", _message.ToString());
                                }

                                _response["isenable"] = "1";

                                // Thumb Grabbing Script
                                string thumb_start_index = "";
                                try
                                {
                                    var med = new MediaHandler();
                                    med.FFMPEGPath           = ffmpegPath;
                                    med.InputPath            = UrlConfig.Upload_Path(username, "default"); // RootPath + "\\" + SourcePath;
                                    med.OutputPath           = UrlConfig.Upload_Path(username, "thumbs");  // RootPath + "\\" + PublishedPath;
                                    med.FileName             = data[0].sf;                                 // source file
                                    thumb_start_index        = med.FileName.Replace(Path.GetExtension(med.FileName), "_");
                                    med.Image_Format         = "jpg";
                                    med.VCodec               = "image2"; //optional
                                    med.ACodec               = "";
                                    med.ImageName            = thumb_start_index;
                                    med.Multiple_Thumbs      = true;
                                    med.ThumbMode            = 0;
                                    med.No_Of_Thumbs         = 10;
                                    med.Thumb_Start_Position = 5;     // start grabbing thumbs from 5th second
                                                                      //if (this.BackgroundProcessing)
                                                                      //    med.BackgroundProcessing = true;
                                    int width = Jugnoon.Videos.Configs.GeneralSettings.thumbnail_width;
                                    if (width > 0)
                                    {
                                        med.Width = width;
                                    }
                                    int height = Jugnoon.Videos.Configs.GeneralSettings.thumbnail_height;
                                    if (height > 0)
                                    {
                                        med.Height = height;
                                    }
                                    var tinfo = med.Grab_Thumb();
                                    if (tinfo.ErrorCode > 0)
                                    {
                                        // Error occured in grabbing thumbs - Rollback process
                                        _response["ecode"] = "1006";
                                        _response["edesc"] = "Grabbing thumbs from video failed";

                                        var _message = new System.Text.StringBuilder();
                                        _message.Append("<h4>Thumb Generation Error</h4>");
                                        _message.Append("<p>Error: " + _response["edesc"] + "</p>");
                                        _message.Append("<p>Source FileName: " + Source);
                                        _message.Append("<p>Published FileName: " + Published);
                                        MailProcess.Send_Mail(Jugnoon.Settings.Configs.GeneralSettings.admin_mail, "Thumb Generation Error, description", _message.ToString());

                                        // call rollback script here
                                        return(Ok(_response));
                                    }

                                    // Validate Thumbs
                                    path = UrlConfig.Upload_Path(username, "thumbs") + "/" + thumb_start_index;
                                    if (!System.IO.File.Exists(path + "004.jpg") || !System.IO.File.Exists(path + "008.jpg") || !System.IO.File.Exists(path + "011.jpg"))
                                    {
                                        // thumb failed try again grabbing thumbs from published video
                                        med.InputPath = UrlConfig.Upload_Path(username, "default");
                                        med.FileName  = data[0].pf;    // grab thumb from encoded video
                                        tinfo         = med.Grab_Thumb();
                                        if (tinfo.ErrorCode > 0)
                                        {
                                            // Error occured in grabbing thumbs - Rollback process
                                            _response["ecode"] = "1006";
                                            _response["edesc"] = "Grabbing thumbs from video failed";
                                            // rollback script here
                                            var _message = new System.Text.StringBuilder();
                                            _message.Append("<h4>Thumb Generation Error</h4>");
                                            _message.Append("<p>Error: " + _response["edesc"] + "</p>");
                                            _message.Append("<p>Source FileName: " + Source);
                                            _message.Append("<p>Published FileName: " + Published);
                                            MailProcess.Send_Mail(Jugnoon.Settings.Configs.GeneralSettings.admin_mail, "Thumb Generation Error, description", _message.ToString());
                                            return(Ok(_response));
                                        }
                                        // Disable Video
                                        if (!System.IO.File.Exists(path + "004.jpg") || !System.IO.File.Exists(path + "008.jpg") || !System.IO.File.Exists(path + "011.jpg"))
                                        {
                                            _response["isenable"] = "0";     // disable video - thumbs not grabbed properly.
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _response["ecode"] = "1010";
                                    _response["edesc"] = ex.Message;

                                    var _message = new System.Text.StringBuilder();
                                    _message.Append("<h4>Thumb Generation Error</h4>");
                                    _message.Append("<p>Error: " + ex.Message + "</p>");
                                    _message.Append("<p>Source FileName: " + Source);
                                    _message.Append("<p>Published FileName: " + Published);
                                    MailProcess.Send_Mail(Jugnoon.Settings.Configs.GeneralSettings.admin_mail, "Thumb Generation Error, description", _message.ToString());
                                }

                                _response["tfile"]   = thumb_start_index + "" + "008.jpg";
                                _response["fIndex"]  = thumb_start_index;
                                _response["img_url"] = Config.GetUrl("contents/member/" + username + "/thumbs/");     // + _response["tfile"]);
                            }
                        }
                    }
                    return(Ok(_response));
                }

                break;

            case 3:
                // final check
                ProcessID = data[0].pid;
                Source    = data[0].sf;
                Published = data[0].pf;

                if (ProcessID != "" && Source != "" && Published != "")
                {
                    if (_lst.Count > 0)
                    {
                        int i = 0;
                        for (i = 0; i <= _lst.Count - 1; i++)
                        {
                            if (_lst[i].vinfo.ProcessID == ProcessID)
                            {
                                if (_lst[i].vinfo.ProcessingCompleted >= 100)
                                {
                                    // check whether published file uploaded properly
                                    string publishedPath = UrlConfig.Upload_Path(username, "flv");

                                    if (!System.IO.File.Exists(publishedPath + "/" + Published))
                                    {
                                        _response["status"] = "INVALID";    // published file not found
                                    }
                                    else
                                    {
                                        _response["encodeoutput"] = "2.0";
                                        _response["status"]       = "OK";
                                    }
                                }
                            }
                        }
                    }

                    return(Ok(_response));
                }
                break;
            }
            _response["status"] = "INVALID";
            return(Ok(_response));
        }
コード例 #11
0
 /// <summary>
 /// Routine email sending method (used for normal smtp + mandril + ses and others)
 /// </summary>
 /// <param name="email"></param>
 /// <param name="subject"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public Task SendEmailAsync(string email, string subject, string message)
 {
     MailProcess.Send_Mail(email, subject, message);
     return(Task.CompletedTask);
 }