Пример #1
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     SplendidError.SystemMessage("Log", new StackTrace(true).GetFrame(0), "Remove Me " + Request["identifier"]);
     try
     {
         Guid gID = Sql.ToGuid(Request["identifier"]);
         if (!Sql.IsEmptyGuid(gID))
         {
             Guid   gTARGET_ID   = Guid.Empty;
             string sTARGET_TYPE = string.Empty;
             SqlProcs.spCAMPAIGN_LOG_UpdateTracker(gID, "removed", Guid.Empty, ref gTARGET_ID, ref sTARGET_TYPE);
             if (sTARGET_TYPE == "Users")
             {
                 Response.Write(L10n.Term("Campaigns.LBL_USERS_CANNOT_OPTOUT"));
             }
             else
             {
                 SqlProcs.spCAMPAIGNS_OptOut(gTARGET_ID, sTARGET_TYPE);
                 Response.Write(L10n.Term("Campaigns.LBL_ELECTED_TO_OPTOUT"));
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
     }
 }
        public static void Process(HttpApplicationState Application)
        {
            if (!bInsideWorkflow)
            {
                bInsideWorkflow = true;
                try
                {
                    //SplendidError.SystemMessage(Application, "Warning", new StackTrace(true).GetFrame(0), "WorkflowUtils.Process Begin");

                    spWORKFLOW_EVENTS_ProcessAll(Application);

                    /*
                     * DbProviderFactory dbf = DbProviderFactories.GetFactory(Application);
                     * using ( IDbConnection con = dbf.CreateConnection() )
                     * {
                     *      string sSQL ;
                     *      sSQL = "select *                " + ControlChars.CrLf
                     + "  from vwWORKFLOW_EVENTS" + ControlChars.CrLf
                     + " order by AUDIT_VERSION " + ControlChars.CrLf;
                     +      using ( IDbCommand cmd = con.CreateCommand() )
                     +      {
                     +              cmd.CommandText = sSQL;
                     +              con.Open();
                     +
                     +              using ( DbDataAdapter da = dbf.CreateDataAdapter() )
                     +              {
                     +                      ((IDbDataAdapter)da).SelectCommand = cmd;
                     +                      using ( DataTable dt = new DataTable() )
                     +                      {
                     +                              da.Fill(dt);
                     +                              if ( dt.Rows.Count > 0 )
                     +                                      SplendidError.SystemMessage(Application, "Warning", new StackTrace(true).GetFrame(0), "Processing " + dt.Rows.Count.ToString() + " workflow events");
                     +                              foreach ( DataRow row in dt.Rows )
                     +                              {
                     +                                      Guid gID = Sql.ToGuid(row["ID"]);
                     +                                      // 12/30/2007 Paul.  We are not going to do anything yet, but we do need to clean up the table.
                     +                                      spWORKFLOW_EVENTS_Delete(Application, gID);
                     +                              }
                     +                      }
                     +              }
                     +      }
                     + }
                     */
                }
                catch (Exception ex)
                {
                    SplendidError.SystemMessage(Application, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
                }
                finally
                {
                    bInsideWorkflow = false;
                }
            }
        }
Пример #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SplendidError.SystemMessage("Log", new StackTrace(true).GetFrame(0), "Campaign Tracker v2 " + Request["identifier"] + ", " + Request["track"]);
            Guid gID      = Sql.ToGuid(Request["identifier"]);
            Guid gTrackID = Sql.ToGuid(Request["track"]);

            try
            {
                if (!Sql.IsEmptyGuid(gID))
                {
                    Guid   gTARGET_ID   = Guid.Empty;
                    string sTARGET_TYPE = string.Empty;
                    SqlProcs.spCAMPAIGN_LOG_UpdateTracker(gID, "link", gTrackID, ref gTARGET_ID, ref sTARGET_TYPE);
                }
                else
                {
                    // 09/10/2007 Paul.  Web campaigns will not have an identifier.
                    SqlProcs.spCAMPAIGN_LOG_BannerTracker("link", gTrackID, Request.UserHostAddress);
                }
                if (!Sql.IsEmptyGuid(gTrackID))
                {
                    DbProviderFactory dbf = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        string sSQL;
                        sSQL = "select TRACKER_URL     " + ControlChars.CrLf
                               + "  from vwCAMPAIGN_TRKRS" + ControlChars.CrLf
                               + " where ID = @ID        " + ControlChars.CrLf;
                        using (IDbCommand cmd = con.CreateCommand())
                        {
                            cmd.CommandText = sSQL;
                            Sql.AddParameter(cmd, "@ID", gTrackID);
                            string sTRACKER_URL = Sql.ToString(cmd.ExecuteScalar());
                            if (!Sql.IsEmptyString(sTRACKER_URL))
                            {
                                Response.Redirect(sTRACKER_URL);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
            }
        }
Пример #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SplendidError.SystemMessage("Log", new StackTrace(true).GetFrame(0), "Tracker image request for " + Request["identifier"]);
            Guid gID = Sql.ToGuid(Request["identifier"]);

            try
            {
                if (!Sql.IsEmptyGuid(gID))
                {
                    Guid   gTARGET_ID   = Guid.Empty;
                    string sTARGET_TYPE = string.Empty;
                    SqlProcs.spCAMPAIGN_LOG_UpdateTracker(gID, "viewed", Guid.Empty, ref gTARGET_ID, ref sTARGET_TYPE);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
            }
            Response.ContentType = "image/gif";
            Response.WriteFile(Request.MapPath("~/include/images/blank.gif"));
        }
        public static void OnTimer(Object sender)
        {
            // 12/22/2007 Paul.  In case the timer takes a long time, only allow one timer event to be processed.
            if (!bInsideTimer)
            {
                bInsideTimer = true;
                HttpApplication global = sender as HttpApplication;
                try
                {
                    // 12/30/2007 Paul.  Workflow events always get processed.
                    WorkflowUtils.Process(global.Application);

                    DbProviderFactory dbf = DbProviderFactories.GetFactory(global.Application);
                    using (DataTable dt = new DataTable())
                    {
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            con.Open();
                            string sSQL;
                            sSQL = "select *               " + ControlChars.CrLf
                                   + "  from vwSCHEDULERS_Run" + ControlChars.CrLf
                                   + " order by NEXT_RUN     " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                // 01/01/2008 Paul.  The scheduler query should always be very fast.
                                // In the off chance that there is a problem, abort after 15 seconds.
                                cmd.CommandTimeout = 15;

                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    da.Fill(dt);
                                }
                            }
                        }
                        // 01/13/2008 Paul.  Loop outside the connection so that only one connection will be used.
                        foreach (DataRow row in dt.Rows)
                        {
                            Guid     gID        = Sql.ToGuid(row["ID"]);
                            string   sJOB       = Sql.ToString(row["JOB"]);
                            DateTime dtNEXT_RUN = Sql.ToDateTime(row["NEXT_RUN"]);
                            try
                            {
                                switch (sJOB)
                                {
                                case "function::BackupDatabase":
                                {
                                    // 01/28/2008 Paul.  Cannot perform a backup or restore operation within a transaction. BACKUP DATABASE is terminating abnormally.
                                    using (IDbConnection con = dbf.CreateConnection())
                                    {
                                        con.Open();
                                        try
                                        {
                                            string sFILENAME = String.Empty;
                                            string sTYPE     = "FULL";
                                            //SqlProcs.spSqlBackupDatabase(ref sNAME, "FULL", trn);
                                            using (IDbCommand cmd = con.CreateCommand())
                                            {
                                                cmd.CommandType = CommandType.StoredProcedure;
                                                cmd.CommandText = "spSqlBackupDatabase";
                                                IDbDataParameter parFILENAME = Sql.AddParameter(cmd, "@FILENAME", sFILENAME, 255);
                                                IDbDataParameter parTYPE     = Sql.AddParameter(cmd, "@TYPE", sTYPE, 20);
                                                parFILENAME.Direction = ParameterDirection.InputOutput;
                                                cmd.ExecuteNonQuery();
                                                sFILENAME = Sql.ToString(parFILENAME.Value);
                                            }
                                            SplendidError.SystemMessage(global.Application, "Information", new StackTrace(true).GetFrame(0), "Database backup complete " + sFILENAME);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemMessage(global.Application, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
                                        }
                                    }
                                    break;
                                }

                                case "function::BackupTransactionLog":
                                {
                                    // 01/28/2008 Paul.  Cannot perform a backup or restore operation within a transaction. BACKUP DATABASE is terminating abnormally.
                                    using (IDbConnection con = dbf.CreateConnection())
                                    {
                                        con.Open();
                                        try
                                        {
                                            string sFILENAME = String.Empty;
                                            string sTYPE     = "LOG";
                                            //SqlProcs.spSqlBackupDatabase(ref sNAME, "LOG", trn);
                                            using (IDbCommand cmd = con.CreateCommand())
                                            {
                                                cmd.CommandType = CommandType.StoredProcedure;
                                                cmd.CommandText = "spSqlBackupDatabase";
                                                IDbDataParameter parFILENAME = Sql.AddParameter(cmd, "@FILENAME", sFILENAME, 255);
                                                IDbDataParameter parTYPE     = Sql.AddParameter(cmd, "@TYPE", sTYPE, 20);
                                                parFILENAME.Direction = ParameterDirection.InputOutput;
                                                cmd.ExecuteNonQuery();
                                                sFILENAME = Sql.ToString(parFILENAME.Value);
                                            }
                                            SplendidError.SystemMessage(global.Application, "Information", new StackTrace(true).GetFrame(0), "Transaction Log backup complete " + sFILENAME);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemMessage(global.Application, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
                                        }
                                    }
                                    break;
                                }

                                case "function::runMassEmailCampaign":
                                {
                                    // 12/30/2007 Paul.  Update the last run date before running so that the date marks the start of the run.
                                    EmailUtils.SendQueued(global.Application, Guid.Empty, Guid.Empty, false);
                                    break;
                                }

                                case "function::pruneDatabase":
                                {
                                    using (IDbConnection con = dbf.CreateConnection())
                                    {
                                        con.Open();
                                        using (IDbTransaction trn = con.BeginTransaction())
                                        {
                                            try
                                            {
                                                SqlProcs.spSqlPruneDatabase(trn);
                                                trn.Commit();
                                            }
                                            catch (Exception ex)
                                            {
                                                trn.Rollback();
                                                SplendidError.SystemMessage(global.Application, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
                                            }
                                        }
                                    }
                                    break;
                                }

                                case "function::pollMonitoredInboxes":
                                {
                                    EmailUtils.CheckMonitored(global.Application, Guid.Empty);
                                    break;
                                }

                                case "function::pollMonitoredInboxesForBouncedCampaignEmails":
                                {
                                    EmailUtils.CheckBounced(global.Application, Guid.Empty);
                                    break;
                                }

                                case "function::CheckVersion":
                                {
                                    DataTable dtVersions = Utils.CheckVersion(global.Application);

                                    DataView vwVersions = dtVersions.DefaultView;
                                    vwVersions.RowFilter = "New = '1'";
                                    if (vwVersions.Count > 0)
                                    {
                                        global.Application["available_version"]             = Sql.ToString(vwVersions[0]["Build"]);
                                        global.Application["available_version_description"] = Sql.ToString(vwVersions[0]["Description"]);
                                    }
                                    break;
                                }
                                }
                            }
                            finally
                            {
                                using (IDbConnection con = dbf.CreateConnection())
                                {
                                    con.Open();
                                    using (IDbTransaction trn = con.BeginTransaction())
                                    {
                                        try
                                        {
                                            // 01/12/2008 Paul.  Make sure the Last Run value is updated after the operation.
                                            SqlProcs.spSCHEDULERS_UpdateLastRun(gID, dtNEXT_RUN, trn);
                                            trn.Commit();
                                        }
                                        catch (Exception ex)
                                        {
                                            trn.Rollback();
                                            SplendidError.SystemMessage(global.Application, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    SplendidError.SystemMessage(global.Application, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
                }
                finally
                {
                    bInsideTimer = false;
                }
            }
        }