private void Initialize()
        {
            _tasks = new List <SueetieTask>();

            var tasknodes = from tasknode in this.TaskConfig.Descendants("Task")
                            select new
            {
                Minutes      = (double)tasknode.Attribute("minutes"),
                Name         = (string)tasknode.Attribute("name"),
                TaskType     = Type.GetType((string)tasknode.Attribute("type"), true),
                Enabled      = (bool)tasknode.Attribute("enabled"),
                XTaskElement = tasknode
            };

            foreach (var _tasknode in tasknodes)
            {
                try
                {
                    var sueetieTask = new SueetieTask(_tasknode.Minutes * 60000);
                    sueetieTask.Minutes      = _tasknode.Minutes;
                    sueetieTask.Name         = _tasknode.Name;
                    sueetieTask.TaskType     = _tasknode.TaskType;
                    sueetieTask.Enabled      = _tasknode.Enabled;
                    sueetieTask.XTaskElement = _tasknode.XTaskElement;
                    _tasks.Add(sueetieTask);
                }
                catch (Exception exception)
                {
                    SueetieLogs.LogTaskException("Task Exception: " + exception.Message);
                }
            }
        }
Exemple #2
0
        internal void ExecuteTask()
        {
            this.IsRunning = true;
            var task = this.CreateTaskInstance();

            if (task != null)
            {
                this.LastRunStart = DateTime.Now;
                try
                {
                    task.Execute(this.XTaskElement);
                    this.IsLastRunSuccessful = true;
                }
                catch (Exception exception)
                {
                    this.IsLastRunSuccessful = false;
                    SueetieLogs.LogTaskException("Task Exception: " + exception.Message);
                }
                finally
                {
                    this.LastRunEnd = DateTime.Now;
                }
            }
            this.IsRunning = false;
        }
 public static void PerformRequestLogInsert(SueetieRequest sueetieRequest)
 {
     try
     {
         var provider = SueetieDataProvider.LoadProvider();
         provider.AddSueetieRequest(sueetieRequest);
     }
     catch (Exception ex)
     {
         SueetieLogs.LogException("Analytics Logging Error: " + HttpContext.Current.Request.RawUrl + " : " + ex.Message + " STACK TRACE: " + ex.StackTrace);
     }
 }
        public string BlogCommenterFollow(int userID, string postGuid)
        {
            SueetieBlogComment sueetieBlogComment = SueetieBlogs.GetSueetieBlogComment(postGuid);

            if (userID > 0)
            {
                if (sueetieBlogComment.SueetieCommentID > 0)
                {
                    string        result        = "You are now following " + sueetieBlogComment.DisplayName;
                    SueetieFollow sueetieFollow = new SueetieFollow
                    {
                        FollowerUserID    = userID,
                        FollowingUserID   = sueetieBlogComment.UserID,
                        ContentIDFollowed = sueetieBlogComment.SueetieCommentID
                    };

                    if (sueetieBlogComment.UserID > 0)
                    {
                        if (sueetieFollow.FollowerUserID == sueetieFollow.FollowingUserID)
                        {
                            result = "Sorry, you cannot follow yourself...";
                        }
                        else
                        {
                            int followID = SueetieUsers.FollowUser(sueetieFollow);
                            if (followID < 0)
                            {
                                result = "You are already following " + sueetieBlogComment.DisplayName;
                            }
                            else
                            {
                                SueetieLogs.LogUserEntry(UserLogCategoryType.Following, sueetieBlogComment.UserID, userID);
                            }
                        }
                    }
                    else
                    {
                        result = "Sorry, " + sueetieBlogComment.Author + " is not a member and thus cannot be followed.";
                    }
                    return(result);
                }
                else
                {
                    return("Sorry, we added following after this comment was posted. Please use a more current comment to follow this member.");
                }
            }
            else
            {
                return("Please login or become a member to follow this person.");
            }
        }
Exemple #5
0
 private static void TrySendMessage(MailMessage message)
 {
     try
     {
         GenerateSmtpClient().Send(message);
     }
     catch (Exception ex)
     {
         if (ex is SmtpException)
         {
             SueetieLogs.LogSiteEntry(SiteLogType.Exception, SiteLogCategoryType.EmailException, "SMTP ERROR: " + ex.Message);
         }
         else
         {
             SueetieLogs.LogSiteEntry(SiteLogType.Exception, SiteLogCategoryType.EmailException, "EMAIL ERROR: " + ex.Message);
         }
     }
 }
Exemple #6
0
        public SueetieUrl GetSueetieUrl(string _name)
        {
            var _sueetieUrl = new SueetieUrl();

            foreach (var url in _urls)
            {
                if (url.Name == _name)
                {
                    _sueetieUrl = url;
                }
            }
            if (string.IsNullOrEmpty(_sueetieUrl.Name))
            {
                SueetieLogs.LogException("SUEETIE URL " + _name + " was not found.");
            }

            return(_sueetieUrl);
        }
Exemple #7
0
        public static string GetString(string name, string fileName, string[] textArgs)
        {
            List <SueetieResource> locals = null;
            var sueetieContext            = SueetieContext.Current;
            var _language = sueetieContext.SiteSettings.DefaultLanguage ?? "en-US";

            if (!string.IsNullOrEmpty(fileName))
            {
                locals = LoadLanguageFile(_language, fileName);
            }
            else
            {
                locals = LoadLanguageFile(_language, "Sueetie.xml");
            }

            string text = null;

            try
            {
                text = locals.Find(l => l.Key == name).Value;
                if (textArgs != null)
                {
                    text = string.Format(text, textArgs);
                }
            }
            catch (Exception ex)
            {
                SueetieLogs.LogSiteEntry(SiteLogType.Exception, SiteLogCategoryType.GeneralException, ex.Message + " STRING NAME: " + name +
                                         " FILENAME: " + fileName + " STACKTRACE: " + ex.StackTrace);
            }

            if (text == null)
            {
#if DEBUG
                text = string.Format("<strong><FONT color=#ff0000>[{0}]</FONT></strong>", name);
                SueetieLogs.LogSiteEntry(SiteLogType.Exception, SiteLogCategoryType.GeneralException,
                                         string.Format("Missing Resource: {0} Page: {1}", name, sueetieContext.RawUrl));
#else
                text = string.Empty;
#endif
            }
            return(text);
        }
Exemple #8
0
        protected override void OnLoad(EventArgs e)
        {
            if (!this.Page.IsCallback && !this.Page.IsPostBack)
            {
                try
                {
                    var metaStart   = string.Format("{0}{0}<!-- Start Current Sueetie Framework Version -->{0}", Environment.NewLine);
                    var metaEnd     = string.Format("{0}<!-- End Current Sueetie Framework Version -->{0}{0}", Environment.NewLine);
                    var ltMetaStart = new LiteralControl(metaStart);
                    var ltMetaEnd   = new LiteralControl(metaEnd);
                    if (this.Page.Header != null)
                    {
                        this.Page.Header.Controls.Add(ltMetaStart);
                        this.AddMetaTag("CommunityFramework", SiteStatistics.Instance.SueetieVersion);
                        this.Page.Header.Controls.Add(ltMetaEnd);

                        if (!string.IsNullOrEmpty(this.CurrentPageContext.SiteSettings.HtmlHeader))
                        {
                            this.AddCustomCodeToHead();
                        }
                    }

                    this.AddTrackingScript();
                }
                catch
                {
                    // ScrewTurn Wiki SessionRefresh.aspx has no header, as it executes in an iFrame in Edit.aspx and elsewhere
                }

                if (SueetieApplications.Current.ApplicationTypeID != (int)SueetieApplicationType.MediaGallery &&
                    SueetieApplications.Current.ApplicationTypeID != (int)SueetieApplicationType.Forum &&
                    SueetieApplications.Current.ApplicationTypeID != (int)SueetieApplicationType.Wiki)
                {
                    SueetieLogs.LogRequest(this.Title, this.CurrentContentID, this.CurrentSueetieUserID);
                }
            }

            base.OnLoad(e);
        }
Exemple #9
0
        public static string GetPageTitle(string titleKey)
        {
            var _titleOut = string.Empty;

            try
            {
                var _localizedTitle = GetString(titleKey, "pagetitles.xml");
                if (!string.IsNullOrEmpty(SiteSettings.Instance.SitePageTitleLead))
                {
                    _titleOut = SiteSettings.Instance.SitePageTitleLead + GetString("page_title_separator", "pagetitles.xml") + _localizedTitle;
                }
                else
                {
                    _titleOut = _localizedTitle;
                }
            }
            catch (Exception ex)
            {
                SueetieLogs.LogException(ex.Message);
            }

            return(_titleOut);
        }
Exemple #10
0
        public SueetieUrl GetSueetieUrl(string _name, string[] args)
        {
            var _sueetieUrl = new SueetieUrl();

            foreach (var url in _urls)
            {
                if (url.Name == _name)
                {
                    url.Url = this.FormatUrl(url.Pattern, args);
                    if (url.RewrittenUrl != null)
                    {
                        url.RewrittenUrl = this.FormatUrl(url.RewrittenUrl, args);
                    }
                    _sueetieUrl = url;
                }
            }
            if (string.IsNullOrEmpty(_sueetieUrl.Name))
            {
                SueetieLogs.LogException("SUEETIE URL " + _name + " was not found.");
            }

            return(_sueetieUrl);
        }