//
        // execute method is the only public
        //
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string   returnHtml = "";
            DateTime dateLastEmail;
            DateTime rightNow  = DateTime.Now;
            DateTime today     = rightNow.Date;
            DateTime yesterday = today.AddDays(-1);
            //string sqlCriteria = "";
            string sqlDateLastEmail = "";

            //
            try
            {
                dateLastEmail    = cp.Site.GetDate("Forums Notification Last Sent", yesterday.ToString());
                sqlDateLastEmail = cp.Db.EncodeSQLDate(dateLastEmail);
                if (dateLastEmail < today)
                {
                    cp.Utils.ExecuteAddon(sendUpdatesGuid);
                }
            }
            catch (Exception ex)
            {
                errorReport(cp, ex, "execute");
            }
            return(returnHtml);
        }
Ejemplo n.º 2
0
        //
        //====================================================================================================
        /// <summary>
        /// getFieldEditorPreference remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                //
                core.doc.addRefreshQueryString(RequestNameHardCodedPage, HardCodedPageSiteExplorer);
                string LinkObjectName = core.docProperties.getText("LinkObjectName");
                if (!string.IsNullOrEmpty(LinkObjectName))
                {
                    //
                    // Open a page compatible with a dialog
                    //
                    core.doc.addRefreshQueryString("LinkObjectName", LinkObjectName);
                    core.html.addTitle("Site Explorer");
                    core.doc.setMetaContent(0, 0);
                    string copy = core.addon.execute(AddonModel.createByUniqueName(core.cpParent, "Site Explorer"), new CPUtilsBaseClass.addonExecuteContext {
                        addonType           = CPUtilsBaseClass.addonContext.ContextPage,
                        errorContextMessage = "processing site explorer response"
                    });
                    core.html.addScriptCode_onLoad("document.body.style.overflow='scroll';", "Site Explorer");
                    string htmlBodyTag = "<body class=\"container-fluid ccBodyAdmin ccCon\" style=\"overflow:scroll\">";
                    string htmlBody    = ""
                                         + GenericController.nop(core.html.getPanelHeader("Contensive Site Explorer")) + "\r<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td>"
                                         + GenericController.nop(copy) + "\r</td></tr></table>"
                                         + "";
                    result = core.html.getHtmlDoc(htmlBody, htmlBodyTag, false, false);
                    core.doc.continueProcessing = false;
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Ejemplo n.º 3
0
        //
        // ===============================================================================================
        // performs all housekeeping when a thread record is changed (add,mod,del)
        // ===============================================================================================
        //
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            //int sourceFormId = 0;
            //int formId = 0;
            //int forumId = 0;
            int           threadId = 0;
            string        s        = "";
            string        sql      = "";
            CPCSBaseClass cs       = cp.CSNew();

            //
            threadId = cp.Utils.EncodeInteger(cp.Doc.GetProperty("recordId", ""));
            if (threadId == 0)
            {
                //
                // re count 'threads' in all forums
                //
                sql = "select ccforums.id as forumId"
                      + ",(select count(ccforumthreads.id) from ccforumthreads where forumId=ccForums.id) as threadCnt"
                      + ",(select count(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as postCnt"
                      + ",(select max(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as lastPostId"
                      + " from ccforums"
                      + "";
            }
            else
            {
                //
                // update forum for thread provided
                //
                sql = "select ccforums.id as forumId"
                      + ",(select count(ccforumthreads.id) from ccforumthreads where forumId=ccForums.id) as threadCnt"
                      + ",(select count(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as postCnt"
                      + ",(select max(p.id) from ccforumPosts p left join ccforumThreads t on t.id=p.threadid where t.forumId=ccforums.id) as lastPostId"
                      + " from ccforums"
                      + " where ccforums.id in (select forumid from ccforumthreads where id=" + threadId + ")"
                      + "";
            }
            //
            if (cs.OpenSQL2(sql, "", 1000, 1))
            {
                while (cs.OK())
                {
                    sql = "update ccforums set threads=" + cs.GetInteger("threadCnt") + ",posts=" + cs.GetInteger("postCnt") + ",lastPostId=" + cs.GetInteger("lastPostId") + " where id=" + cs.GetInteger("forumId");
                    cp.Db.ExecuteSQL(sql, "", "1", "1", "1");
                    cs.GoNext();
                }
            }
            cs.Close();
            //
            return(s);
        }
Ejemplo n.º 4
0
        //
        // -- Contensive calls the execute method of your addon class
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try
            {
                //
                // your code here
                //
                result = "success response";
            }
            catch (Exception ex)
            {
                cp.Site.ErrorReport(ex);
                result = "error response";
            }
            return(result);
        }
        //
        //====================================================================================================
        /// <summary>
        /// getFieldEditorPreference remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                //
                // -- default login page
                core.doc.continueProcessing = false;
                Dictionary <string, string> addonArguments = new Dictionary <string, string>();
                addonArguments.Add("Force Default Login", "true");
                return(core.addon.execute(addonGuidLoginPage, new CPUtilsBaseClass.addonExecuteContext {
                    addonType = CPUtilsBaseClass.addonContext.ContextPage,
                    argumentKeyValuePairs = addonArguments,
                    errorContextMessage = "processing field editor preference remote"
                }));
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Ejemplo n.º 6
0
        //
        //====================================================================================================
        /// <summary>
        /// getFieldEditorPreference remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                //
                // -- login
                core.session.logout();
                core.doc.continueProcessing = false;
                Dictionary <string, string> addonArguments = new Dictionary <string, string>();
                addonArguments.Add("Force Default Login", "false");
                return(core.addon.execute(addonGuidLoginPage, new CPUtilsBaseClass.addonExecuteContext {
                    addonType = CPUtilsBaseClass.addonContext.ContextPage,
                    errorContextMessage = "processing logout/login method"
                }));
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Ejemplo n.º 7
0
        //
        //====================================================================================================
        /// <summary>
        /// Process Login
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                //
                // -- login
                core.doc.continueProcessing = false;
                Dictionary <string, string> addonArguments = new Dictionary <string, string>();
                addonArguments.Add("Force Default Login", "false");
                return(core.addon.execute(DbBaseModel.create <AddonModel>(core.cpParent, addonGuidLoginPage), new CPUtilsBaseClass.addonExecuteContext {
                    addonType = CPUtilsBaseClass.addonContext.ContextPage,
                    argumentKeyValuePairs = addonArguments,
                    forceHtmlDocument = true,
                    errorContextMessage = "Process Login"
                }));
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Ejemplo n.º 8
0
 //
 //====================================================================================================
 /// <summary>
 /// addon method, deliver complete Html admin site
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public override object Execute(Contensive.BaseClasses.CPBaseClass cpBase)
 {
     return(get((CPClass)cpBase));
 }
Ejemplo n.º 9
0
 //
 // execute method is the only public
 //
 public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
 {
     return("Hello World");
 }
Ejemplo n.º 10
0
        //
        // execute method is the only public
        //
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            const string forumNotificationBody = ""
                                                 + "<h2>Forum Notification</h2>"
                                                 + "<p>The following forums have had changes over the past day.<p>"
                                                 + "";
            string        returnHtml = "";
            DateTime      dateLastEmail;
            DateTime      rightNow  = DateTime.Now;
            DateTime      today     = rightNow.Date;
            DateTime      yesterday = today.AddDays(-1);
            CPCSBaseClass cs        = cp.CSNew();
            int           memberId;
            bool          memberMatch;
            string        sqlCriteria        = "";
            string        forumIdChangedList = "";
            int           forumId;
            Hashtable     forumNamesRef = new Hashtable();
            string        emailBody     = "";
            string        sql;
            string        testSrc;
            int           testId           = 0;
            string        qs               = "";
            string        forumQs          = cp.Site.GetText("forum last display qs", "");
            string        sqlDateLastEmail = "";
            string        emailDomain      = cp.Site.DomainPrimary;

            //
            try
            {
                dateLastEmail = cp.Site.GetDate("Forums Notification Last Sent", yesterday.ToString());
                cp.Site.SetProperty("Forums Notification Last Sent", rightNow.ToString());
                sqlDateLastEmail = cp.Db.EncodeSQLDate(dateLastEmail);
                //
                // verify Forum Notification email
                //
                testId = cp.Content.GetRecordID("system email", "Forum Notification");
                if (testId == 0)
                {
                    if (emailDomain.IndexOf(".") < 0)
                    {
                        emailDomain = "kma.net";
                    }
                    cs.Insert("system Email");
                    cs.SetField("name", "Forum Notification");
                    cs.SetField("subject", cp.Site.DomainPrimary + " Daily Forum Updates");
                    cs.SetField("fromAddress", "ForumNotification@" + emailDomain);
                    cs.SetField("copyFilename", forumNotificationBody);
                    cs.Close();
                }
                //
                // make a list of forums with changes
                //
                sql = "select distinct f.id as forumId,f.name as forumName"
                      + " from ((ccForums f"
                      + " left join ccforumThreads t on t.forumId=f.id)"
                      + " left join ccforumPosts p on p.threadid=t.id)"
                      + " where"
                      + " (t.dateAdded>" + sqlDateLastEmail + ")"
                      + " or(p.dateAdded>" + sqlDateLastEmail + ")"
                      + " order by f.id";
                cs.OpenSQL(sql);
                while (cs.OK())
                {
                    forumId = cs.GetInteger("forumId");
                    testSrc = "," + forumIdChangedList + ",";
                    if (testSrc.IndexOf("," + forumId.ToString() + ",") < 0)
                    {
                        forumIdChangedList += "," + forumId;
                        sqlCriteria        += "or(forumId=" + forumId + ")";
                        forumNamesRef.Add(forumId, cs.GetText("forumName"));
                    }
                    cs.GoNext();
                }
                cs.Close();
                //
                // check for people who want notifications for these forums
                //
                if (sqlCriteria != "")
                {
                    sqlCriteria = "(" + sqlCriteria.Substring(2) + ")";
                    if (cs.Open("forum notification rules", sqlCriteria, "memberId,forumId", true, "memberId,forumId", 999, 1))
                    {
                        do
                        {
                            //
                            // send this member a list of forums that changed and are on his list
                            //
                            memberId  = cs.GetInteger("memberId");
                            emailBody = "";
                            do
                            {
                                memberMatch = (memberId == cs.GetInteger("memberId"));
                                if (memberMatch)
                                {
                                    forumId = cs.GetInteger("forumId");
                                    testSrc = "," + forumIdChangedList + ",";
                                    if (testSrc.IndexOf("," + forumIdChangedList.ToString() + ",") >= 0)
                                    {
                                        qs         = cp.Utils.ModifyQueryString(forumQs, "forumId", forumId.ToString(), true);
                                        emailBody += "<li><a href=\"http://" + cp.Site.DomainPrimary + cp.Site.AppRootPath + cp.Site.PageDefault + "?" + qs + "\">" + forumNamesRef[forumId].ToString() + "</a></li>";
                                    }
                                    cs.GoNext();
                                }
                            }while (cs.OK() && memberMatch);
                            if (emailBody != "")
                            {
                                emailBody = "<ul>" + emailBody + "</ul>";
                                cp.Email.sendSystem("Forum Notification", emailBody, memberId);
                            }
                        }while (cs.OK());
                    }
                }
            }
            catch (Exception ex)
            {
                errorReport(cp, ex, "execute");
            }
            return(returnHtml);
        }
Ejemplo n.º 11
0
        //
        // ===============================================================================================
        // performs all housekeeping when a post record is changed (add,mod,del)
        // ===============================================================================================
        //
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            //int sourceFormId = 0;
            //int formId = 0;
            //int forumId = 0;
            int           threadId = 0;
            int           postId   = 0;
            string        s        = "";
            string        sql      = "";
            CPCSBaseClass cs       = cp.CSNew();

            //
            postId = cp.Utils.EncodeInteger(cp.Doc.GetProperty("recordId", ""));
            if (postId == 0)
            {
                //
                // re count posts for all threads
                //
                sql = "select ccforumThreads.id as threadId"
                      + ",(select count(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as postCnt"
                      + ",(select max(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as lastPostId"
                      + " from ccforumThreads"
                      + "";
            }
            else
            {
                //
                // recount posts for just the thread effected
                //
                sql = "select ccforumThreads.id as threadId"
                      + ",(select count(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as postCnt"
                      + ",(select max(p.id) from ccforumPosts p where p.threadId=ccforumThreads.id) as lastPostId"
                      + " from ccforumThreads"
                      + " where ccforumThreads.id in (select threadid from ccforumPosts where id=" + postId + ")"
                      + "";
            }
            if (cs.OpenSQL2(sql, "", 1000, 1))
            {
                threadId = cs.GetInteger("threadId");
                while (cs.OK())
                {
                    sql = "update ccforumthreads"
                          + " set replyCnt=" + cs.GetInteger("postCnt") + ""
                          + ",lastPostId=" + cs.GetInteger("lastPostId") + ""
                          + " where id=" + cs.GetInteger("threadId");
                    cp.Db.ExecuteSQL(sql, "", "1", "1", "1");
                    cs.GoNext();
                }
                if (postId != 0)
                {
                    //
                    // this only affected one post, so only housekeep one thread
                    //
                    cp.Doc.SetProperty("recordId", threadId.ToString());
                }
            }
            cs.Close();
            //
            // this effects lastPostId, so housekeep threads also
            //
            threadHousekeepClass threadHousekeep = new threadHousekeepClass();

            threadHousekeep.Execute(cp);
            //
            return(s);
        }
Ejemplo n.º 12
0
        //
        // ===========================================================================================
        //
        public void bounceProcess(Contensive.BaseClasses.CPBaseClass cp)
        {
            try {
                CPCSBaseClass CS = cp.CSNew();
                string        MessageText;
                string[]      FilterLines;
                string[]      FilterText = Array.Empty <string>();
                int[]         FilterType = Array.Empty <int>();
                int           LinePtr;
                string[]      LineSplit;
                int           FilterLineCnt = 0;
                string        Filter;
                int           BounceType;
                string        EmailAddress;
                string        PopServer;
                int           popPort;
                string        POPServerUsername;
                string        POPServerPassword;
                int           EmailBounceProcessAction;
                bool          AllowEmailBounceProcessing;
                string        bounceLogPathPage;
                string        ActionTaken;
                string        FilterFilename;
                string        Filename     = "";
                DateTime      rightNowDate = DateTime.Now.Date;
                string        logDatePart  = rightNowDate.Year + rightNowDate.Month.ToString().PadLeft(2) + rightNowDate.Day.ToString().PadLeft(2);
                string        amazonMsg    = "An error occurred while trying to deliver the mail to the following recipients:" + "\r\n";
                //
                AllowEmailBounceProcessing = cp.Site.GetBoolean("AllowEmailBounceProcessing", false);
                if (AllowEmailBounceProcessing)
                {
                    PopServer = cp.Site.GetText("PopServer", "");
                    popPort   = cp.Site.GetInteger("popServerPort", 110);
                    if (popPort <= 0)
                    {
                        popPort = 110;
                    }
                    POPServerUsername = cp.Site.GetText("POPServerUsername", "");
                    POPServerPassword = cp.Site.GetText("POPServerPassword", "");
                    if ((PopServer == "") | (POPServerUsername == "") | (POPServerPassword == ""))
                    {
                        cp.Utils.AppendLog("AllowEmailBounceProcessing true but server, username or password is blank");
                    }
                    else
                    {
                        bounceLogPathPage        = @"BounceLog\" + logDatePart + @"\trace.txt";
                        FilterFilename           = @"\config\EmailBounceFilters.txt";
                        EmailBounceProcessAction = cp.Site.GetInteger("EmailBounceProcessAction", 0);
                        //
                        // Read in the filter file
                        //
                        if (true)
                        {
                            string copy;
                            copy = cp.CdnFiles.Read(FilterFilename);
                            if (copy == "")
                            {
                                cp.Utils.AppendLog(@"Bounce processing filters file \config\EmailBounceFilters.txt is empty");
                            }
                            else
                            {
                                copy          = copy.Replace("\r\n", "\r");
                                copy          = copy.Replace("\n", "\r");
                                FilterLines   = copy.Split('\r');
                                FilterLineCnt = FilterLines.Length;
                                FilterText    = new string[FilterLineCnt + 100 + 1];
                                FilterType    = new int[FilterLineCnt + 100 + 1];
                                //
                                //
                                //
                                for (LinePtr = 0; LinePtr <= FilterLineCnt - 1; LinePtr++)
                                {
                                    if (FilterLines[LinePtr] != "")
                                    {
                                        LineSplit           = FilterLines[LinePtr].Split(',');
                                        FilterText[LinePtr] = LineSplit[0];
                                        if (LineSplit.Length > 0)
                                        {
                                            FilterType[LinePtr] = cp.Utils.EncodeInteger(LineSplit[1]);
                                        }
                                    }
                                }
                                //
                                // add amazon
                                //
                                FilterText[FilterLineCnt] = amazonMsg;
                                FilterType[FilterLineCnt] = 2;
                                FilterLineCnt            += 1;
                            }
                        }
                        //
                        // Retrieve the emails
                        //
                        int    MessageCnt;
                        string headerList;
                        OpenPop.Mime.Message msg;
                        using (OpenPop.Pop3.Pop3Client pop = new OpenPop.Pop3.Pop3Client()) {
                            try {
                                pop.Connect(PopServer, popPort, true);
                                pop.Authenticate(POPServerUsername, POPServerPassword);
                                MessageCnt = pop.GetMessageCount();
                                //
                                cp.CdnFiles.Append(bounceLogPathPage, "\r\n" + "New bounce emails, cnt=" + MessageCnt);
                                //
                                for (int msgPtr = 1; msgPtr <= MessageCnt; msgPtr++)
                                {
                                    msg          = pop.GetMessage(msgPtr);
                                    headerList   = "";
                                    EmailAddress = "";
                                    headerList   = "";
                                    MessageText  = "";
                                    if (!msg.Headers.From.HasValidMailAddress)
                                    {
                                        //
                                        cp.CdnFiles.Append(bounceLogPathPage, "\n\r" + "email" + msgPtr + "-" + "email address not found");
                                    }
                                    else
                                    {
                                        EmailAddress = msg.Headers.From.Address;

                                        foreach (string key in msg.Headers.UnknownHeaders.AllKeys)
                                        {
                                            string keyValue = msg.Headers.UnknownHeaders[key];
                                            headerList += "\r\n" + key + "=" + keyValue;
                                        }

                                        OpenPop.Mime.MessagePart msgBody;
                                        msgBody = msg.FindFirstPlainTextVersion();
                                        if ((msgBody == null))
                                        {
                                            msgBody = msg.FindFirstHtmlVersion();
                                        }
                                        MessageText = "";
                                        if (!(msgBody == null))
                                        {
                                            MessageText = msgBody.GetBodyAsText();
                                        }

                                        if (string.IsNullOrEmpty(MessageText))
                                        {
                                            //
                                            cp.CdnFiles.Append(bounceLogPathPage, "\n\r" + "email" + msgPtr + "-" + "email has blank body");
                                        }
                                        else
                                        {
                                            //
                                            // Process them as they come in
                                            //
                                            if ((EmailAddress == "*****@*****.**"))
                                            {
                                                if ((MessageText.IndexOf(amazonMsg) > -1))
                                                {
                                                    EmailAddress = MessageText.Replace(amazonMsg, "");
                                                }
                                            }
                                            ActionTaken = "no action";
                                            if (EmailAddress == "")
                                            {
                                                //
                                                cp.CdnFiles.Append(bounceLogPathPage, "\n\r" + "email" + msgPtr + "-" + "email address was blank");
                                                //
                                                ActionTaken = "deleted with no action, email address could not be determined, email content saved [" + Filename + "]";
                                            }
                                            else if (FilterLineCnt == 0)
                                            {
                                                //
                                                cp.CdnFiles.Append(bounceLogPathPage, "\n\r" + "email" + msgPtr + "-" + "email filter file was not found (" + FilterFilename + ")");
                                                //
                                                ActionTaken = "[" + EmailAddress + "], deleted with no action, no Filter File [" + FilterFilename + "]";
                                            }
                                            else
                                            {
                                                // Copy = strDecodeMime(MessageText, MessageHeaders)
                                                for (LinePtr = 0; LinePtr <= FilterLineCnt - 1; LinePtr++)
                                                {
                                                    Filter = FilterText[LinePtr].Trim();
                                                    if (Filter != "")
                                                    {
                                                        if (MessageText.IndexOf(Filter) >= 0)
                                                        {
                                                            BounceType = FilterType[LinePtr];
                                                            switch (BounceType)
                                                            {
                                                            case 0: {
                                                                //
                                                                ActionTaken = "[" + EmailAddress + "], deleted with no action, Filter [" + Filter + "] is not a bounce";
                                                                break;
                                                            }

                                                            case 1: {
                                                                //
                                                                // soft bounce - may recover
                                                                //
                                                                ActionTaken = "[" + EmailAddress + "], deleted with no action, Filter [" + Filter + "] is soft error, may recover";
                                                                break;
                                                            }

                                                            case 2: {
                                                                //
                                                                // hard bounce - take action on the member email
                                                                //
                                                                //
                                                                //
                                                                //
                                                                //
                                                                EmailBounceProcessAction = 1;
                                                                //
                                                                //
                                                                //
                                                                switch (EmailBounceProcessAction)
                                                                {
                                                                case 1: {
                                                                    //
                                                                    // clear allowgroupemail
                                                                    //
                                                                    ActionTaken = "[" + EmailAddress + "], clear allowBulkEmail action, Filter [" + Filter + "] is hard error";
                                                                    CS.Open("people", "email=" + cp.Db.EncodeSQLText(EmailAddress), "", true, "ID,Name,OrganizationID,allowbulkemail");
                                                                    if (!(CS.OK()))
                                                                    {
                                                                        ActionTaken += ", NO RECORD FOUND";
                                                                    }
                                                                    else
                                                                    {
                                                                        ActionTaken += ", clearing allowGroupEmail for records [";
                                                                        while (CS.OK())
                                                                        {
                                                                            ActionTaken += "," + CS.GetInteger("id").ToString();
                                                                            CS.SetField("allowbulkemail", 0.ToString());
                                                                            CS.GoNext();
                                                                        }
                                                                        ActionTaken += "]";
                                                                    }
                                                                    CS.Close();
                                                                    break;
                                                                }

                                                                case 2: {
                                                                    //
                                                                    // clear email
                                                                    //
                                                                    ActionTaken = "[" + EmailAddress + "], clear email address action, Filter [" + Filter + "] is hard error";
                                                                    CS.Open("people", "email=" + cp.Db.EncodeSQLText(EmailAddress), "", true, "ID,Name,OrganizationID,email");
                                                                    if (!CS.OK())
                                                                    {
                                                                        ActionTaken += ", NO RECORD FOUND";
                                                                    }
                                                                    else
                                                                    {
                                                                        ActionTaken += ", clear email address for records [";
                                                                        while (CS.OK())
                                                                        {
                                                                            CS.SetField("email", "");
                                                                            CS.GoNext();
                                                                        }
                                                                        ActionTaken += "]";
                                                                    }
                                                                    CS.Close();
                                                                    break;
                                                                }

                                                                case 3: {
                                                                    //
                                                                    // Delete Member
                                                                    //
                                                                    ActionTaken = "[" + EmailAddress + "], delete member, Filter [" + Filter + "] is hard error";
                                                                    CS.Open("people", "email=" + cp.Db.EncodeSQLText(EmailAddress), "", true, "ID,Name,OrganizationID");
                                                                    if (!CS.OK())
                                                                    {
                                                                        ActionTaken += ", NO RECORD FOUND";
                                                                    }
                                                                    else
                                                                    {
                                                                        ActionTaken += ", delete people records [";
                                                                        while (CS.OK())
                                                                        {
                                                                            CS.Delete();
                                                                            CS.GoNext();
                                                                        }
                                                                        ActionTaken += "]";
                                                                    }
                                                                    CS.Close();
                                                                    break;
                                                                }

                                                                default: {
                                                                    //
                                                                    // Unknown Process Action
                                                                    //
                                                                    ActionTaken = "[" + EmailAddress + "], deleted with no action, Filter [" + Filter + "] is hard error, but Process Action is unknown [" + EmailBounceProcessAction + "]";
                                                                    break;
                                                                }
                                                                }

                                                                break;
                                                            }
                                                            }
                                                            //
                                                            cp.CdnFiles.Append(bounceLogPathPage, "\n\r" + "email" + msgPtr + "-" + ActionTaken);
                                                            //
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    //
                                    // save bounced email
                                    //
                                    cp.CdnFiles.Save(@"BounceLog\" + logDatePart + @"\email-" + msgPtr + ".txt", EmailAddress + "\n\r" + headerList + "\n\r" + MessageText);
                                    //
                                    // delete the message
                                    //
                                    pop.DeleteMessage(msgPtr);
                                }
                            } catch (Exception ex) {
                                cp.Site.ErrorReport(ex, "Bounce Processing exception");
                            } finally {
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
        }
Ejemplo n.º 13
0
        //
        // execute method is the only public
        //
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string returnHtml = "Hello World";

            try
            {
                // rqs defined once and passed so when we do ajax integration, the rqs will be passed from
                //      from the ajax call so it can be the rqs of the original page, not the /remoteMethod rqs
                //      you get from cp.doc.RefreshQueryString.
                // srcFormId - passed from a submitting form. Otherwise 0.
                // dstFormId - the next for to display. used for links to new pages. Will be over-ridden
                //      by the formProcessing of srcFormId if it is present.
                // appId - Forms typically save data back to the Db. The 'application' is the table
                //      when the data is saved.
                // rightNow - the date and time when the page is hit. Set once and passed as argument to
                //      enable a test-mode where the time can be hard-coded.
                //
                int           srcFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnSrcFormId, ""));
                int           dstFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnDstFormId, ""));
                int           appId     = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnAppId, ""));
                string        rqs       = cp.Doc.RefreshQueryString;
                DateTime      rightNow  = DateTime.Now;
                CPCSBaseClass cs        = cp.CSNew();
                adminFramework.pageWithNavClass page = new adminFramework.pageWithNavClass();
                blankClass blank = new blankClass();
                //
                //------------------------------------------------------------------------
                // add common page elements
                //------------------------------------------------------------------------
                //
                page.title       = "Manager Sample Addon";
                page.description = "This is the visual studio c# addon template called Manager Sample. A manager addon is a set of forms that together manage a feature.";
                //
                //------------------------------------------------------------------------
                // process submitted form
                //------------------------------------------------------------------------
                //
                if (srcFormId != 0)
                {
                    switch (srcFormId)
                    {
                    // add a case for each form process needed
                    case statics.formIdBlank:
                        dstFormId = blank.processForm(cp, srcFormId, rqs, rightNow, ref appId);
                        break;
                    }
                }
                //
                //------------------------------------------------------------------------
                // add page navigation
                //------------------------------------------------------------------------
                //
                page.addNav();
                page.navCaption = "Home";
                page.navLink    = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, "0", true);
                //
                page.addNav();
                page.navCaption = "Blank Form";
                page.navLink    = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, statics.formIdBlank.ToString(), true);
                //
                switch (dstFormId)
                {
                case (statics.formIdBlank):
                    page.body = blank.getForm(cp, dstFormId, rqs, rightNow, ref appId);
                    break;

                default:
                    page.body = "<p>Welcome to the default form.</p>";
                    break;
                }
                //
                //------------------------------------------------------------------------
                // output the page
                //------------------------------------------------------------------------
                //
                returnHtml = page.getHtml(cp);
                cp.Doc.AddHeadStyle(page.styleSheet);
            }
            catch (Exception ex)
            {
                errorReport(cp, ex, "execute");
            }
            return(returnHtml);
        }
Ejemplo n.º 14
0
 //
 //==========================================================================================
 /// <summary>
 /// addon method
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
 {
     try {
         const string spAwsSecretAccessKey             = "AWS Secret Access Key";
         const string spAwsAccessKeyId                 = "AWS Access Key Id";
         const string spAwsSQSBounceEmailQueueEndpoint = "AWS SQS Bounce Email Queue Endpoint";
         //
         bool awsAllowBounceProcess = cp.Site.GetBoolean("AWS SES Allow Bounce Process");
         if (awsAllowBounceProcess)
         {
             //
             // -- aws keys, use the server config, but allow over-ride by site property
             string awsAccessKeyId = cp.Site.GetText(spAwsAccessKeyId);
             if (string.IsNullOrEmpty(awsAccessKeyId))
             {
                 awsAccessKeyId = cp.ServerConfig.awsAccessKey;
             }
             string awsSecretAccessKey = cp.Site.GetText(spAwsSecretAccessKey);
             if (string.IsNullOrEmpty(awsSecretAccessKey))
             {
                 awsSecretAccessKey = cp.ServerConfig.awsSecretAccessKey;
             }
             //
             // -- settings
             string awsSQSBounceEmailQueueEndpoint = cp.Site.GetText(spAwsSQSBounceEmailQueueEndpoint);
             //
             // -- setup aws client
             AmazonSQSClient       sqsClient             = new AmazonSQSClient(awsAccessKeyId, awsSecretAccessKey, Amazon.RegionEndpoint.USEast1);
             ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest {
                 QueueUrl            = awsSQSBounceEmailQueueEndpoint,
                 MaxNumberOfMessages = 10
             };
             //
             // -- download a message from queue, process and repeat until no more
             while (true)
             {
                 ReceiveMessageResponse receiveMessageResponse = sqsClient.ReceiveMessage(receiveMessageRequest);
                 if (receiveMessageResponse.Messages.Count == 0)
                 {
                     //
                     // -- no message, exit loop
                     break;
                 }
                 foreach (Message msg in receiveMessageResponse.Messages)
                 {
                     //
                     // -- convert the Amazon SNS message into a JSON object.
                     AmazonSqsNotification notification = Newtonsoft.Json.JsonConvert.DeserializeObject <AmazonSqsNotification>(msg.Body);
                     if (notification.type == "Notification")
                     {
                         //
                         // -- process SES bounce notification.
                         AmazonSesBounceNotification message = Newtonsoft.Json.JsonConvert.DeserializeObject <AmazonSesBounceNotification>(notification.message);
                         processSesBounceNotificationMessage(cp, message);
                     }
                     else if (notification.type == null)
                     {
                         //
                         // --unknown type, assume valid message
                         AmazonSesBounceNotification message = Newtonsoft.Json.JsonConvert.DeserializeObject <AmazonSesBounceNotification>(msg.Body);
                         processSesBounceNotificationMessage(cp, message);
                     }
                     //
                     // -- delete the processed message from the SES queue
                     var deleteMessageRequest = new DeleteMessageRequest {
                         QueueUrl      = awsSQSBounceEmailQueueEndpoint,
                         ReceiptHandle = msg.ReceiptHandle
                     };
                     sqsClient.DeleteMessage(deleteMessageRequest);
                 }
             }
             //
             // -- transient bounces beyond the grace period - convert to permanent failures
             using (CPCSBaseClass cs = cp.CSNew()) {
                 if (cs.Open("email bounce list", "(transient=1)and(transientFixDeadline<" + cp.Db.EncodeSQLDate(DateTime.Now) + ")"))
                 {
                     do
                     {
                         permanentFail(cp, cs.GetText("name"), DateTime.Now.ToString() + " converted from transient to permanent because grace period past with no action, original failure[" + cs.GetText("details") + "]");
                         cs.GoNext();
                     } while (cs.OK());
                 }
                 cs.Close();
             }
         }
         return(string.Empty);
     } catch (Exception ex) {
         cp.Site.ErrorReport(ex);
         return(string.Empty);
     }
 }