public static IList <Model_Campaign> GetCampaign(string param)
    {
        Model_Campaign c = new Model_Campaign(HttpContext.Current);

        return(c.model_Que(param));
    }
예제 #2
0
    public static int SendQue()
    {
        Model_Campaign c = new Model_Campaign();
        Model_Mailbox  m = new Model_Mailbox();

        IList <Model_Campaign> cl = c.model_Que();
        IList <Model_Mailbox>  ml = m.model_Que();


        //SendingJob sj = new SendingJob();
        //SendingJobItem st = new SendingJobItem();



        foreach (Model_Campaign i in cl)
        {
            byte             mailStatus = 3;
            byte             jobstatus  = 1;
            Model_SendingJob sd         = new Model_SendingJob();

            try
            {
                bool IsinTime = QueIsinTime(i.DateTimePublish);
                IList <Model_Subscriber> sl = allSubscriber(i.SG);
                var sl_filter = sl.Where(e => MAilSender.IsMatchEmail(e.Email)).GroupBy(j => j.Email);

                int TotalSubscriber = sl_filter.Count();


                sd = QueAddJob(sd, i.IsSchedule, i.CID, TotalSubscriber, IsinTime, 1);


                //Sending

                if (sd.SDID > 0)
                {
                    QueAddJobItem(sd, sl_filter);
                }
            }
            catch
            {
            }

            sd.UpdateJobStatus(sd.SDID, jobstatus);
            i.model_updatestatus(i.CID, mailStatus);
            i.model_UpdateToJob(i.CID, true);
        }

        foreach (Model_Mailbox i in ml)
        {
            byte             mailStatus = 3;
            byte             jobstatus  = 1;
            Model_SendingJob sd         = new Model_SendingJob();
            try
            {
                bool IsinTime = QueIsinTime(i.DateTimePublish);
                IList <Model_Subscriber> sl = allSubscriber(i.SG);
                var sl_filter = sl.Where(e => MAilSender.IsMatchEmail(e.Email)).GroupBy(j => j.Email);

                string[] mailboxreciever = MailAddress(i.Mailaddress);


                int TotalSubscriber = sl_filter.Count();
                int Totalmailbox    = mailboxreciever.Count();

                sd = QueAddJob(sd, i.IsSchedule, i.CID, TotalSubscriber + Totalmailbox, IsinTime, 2);


                if (sd.SDID > 0)
                {
                    QueAddJobItem(sd, sl_filter, mailboxreciever);
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message + ex.StackTrace;
            }

            sd.UpdateJobStatus(sd.SDID, jobstatus);
            i.model_updatestatus(i.CID, mailStatus);

            i.model_UpdateToJob(i.CID, true);
        }



        return(SendNow());
    }