public static void UpdateCampaign(Model_Mailbox parameters)
    {
        Model_Mailbox ret = MailboxController.Update(parameters);


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
    public static void GetTotal(Model_Mailbox parameters)
    {
        Model_Subscriber ret = SubScriberController.GetSubProfileDetail();


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
    public static void GetAll_checkprocess(Model_Mailbox parameters)
    {
        IList <Model_Mailbox> ret = MailboxController.GetAllMailboxCP(parameters);


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
    public static void GetItemById(Model_Mailbox parameters)
    {
        Model_Mailbox ret = MailboxController.GetItemById(parameters);


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
Exemple #5
0
    public static IList <Model_Mailbox> GetAllMailboxCP(Model_Mailbox param)
    {
        Model_SendingJob mj = new Model_SendingJob();

        mj.UpdateStatusMailProcess();
        return(param.model_getMailbox_checkProcess(param));
    }
    public static void InsertNewMailbox(Model_Mailbox parameters)
    {
        Model_Mailbox ret = MailboxController.InsertTemplate(parameters);


        AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON());
    }
Exemple #7
0
    public static Model_Mailbox InsertTemplate(Model_Mailbox param)
    {
        Model_Mailbox cm = null;

        param.CreatedBy = HttpContext.Current.User.Identity.GetUserId();
        cm = param.model_InsertMailbox(param);


        //Model_Template cm =  param.model_InsertEmailEelement(param);
        // cm = cm.model_InsertEmailEelement(param);

        if (!string.IsNullOrEmpty(cm.EID))
        {
            EmailEelements el = new EmailEelements
            {
                EID      = cm.EID,
                Eelement = cm.EL.ObjectToJSON()
            };
            el.model_InsertEmailEelement(el);
        }

        SendingController.SendQue();

        return(cm);
    }
Exemple #8
0
    public static Model_Mailbox GetItemById(Model_Mailbox param)
    {
        EmailEelements e = new EmailEelements();
        Model_Mailbox  c = param.model_getMailboxByID(param);

        c.EL = (EModel)e.model_GetElementBYID(c.EID).Eelement.JsonToObject(new EModel());

        return(c);
    }
Exemple #9
0
    public static bool Updatestatus(object param, byte CSID)
    {
        Model_Mailbox c = new Model_Mailbox();

        object[] arr = (object[])param;

        for (int i = 0; i < arr.Length; i++)
        {
            c.model_updatestatus(int.Parse((string)arr[i]), CSID);
        }


        SendingController.SendQue();

        return(true);
    }
Exemple #10
0
    public static Model_Mailbox Update(Model_Mailbox param)
    {
        Model_Mailbox cm = null;

        cm = param.model_Update(param);

        if (!string.IsNullOrEmpty(cm.EID))
        {
            EmailEelements el = new EmailEelements
            {
                EID      = cm.EID,
                Eelement = cm.EL.ObjectToJSON()
            };
            el.model_InsertEmailEelement(el);
        }

        SendingController.SendQue();

        return(cm);
    }
Exemple #11
0
    public static IList <Model_Mailbox> GetMailbox(string param)
    {
        Model_Mailbox c = new Model_Mailbox(HttpContext.Current);

        return(c.model_Que(param));
    }
Exemple #12
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());
    }
Exemple #13
0
    public static void Sendnow(object param)
    {
        object[] parameters             = (object[])param;
        List <Model_SendingJobItem> cli = (List <Model_SendingJobItem>)parameters[0];
        Model_Setting s = (Model_Setting)parameters[1];

        Model_SendingJob ms = (Model_SendingJob)parameters[2];

        HttpContext context = (HttpContext)parameters[3];
        //Model_SendingJob ms = new Model_SendingJob();

        //var groupCampaignCID = cli.Where(cam => cam.CType == 1).GroupBy(c => c.CID);
        //var groupMailboxCID = cli.Where(cam => cam.CType == 2).GroupBy(c => c.CID);

        //StringBuilder strCam = new StringBuilder();
        //StringBuilder strMailBox = new StringBuilder();
        //foreach (var ss in groupCampaignCID)
        //{
        //    int propertyIntOfClassA = ss.Key;
        //    strCam.Append(propertyIntOfClassA + ",");
        //}
        //strCam.Append("0");
        //foreach (var ss in groupMailboxCID)
        //{
        //    int propertyIntOfClassA = ss.Key;
        //    strMailBox.Append(propertyIntOfClassA + ",");
        //}
        //strMailBox.Append("0");


        IList <Model_Campaign> mdc = CampaignController.GetCampaign(ms.CID.ToString());
        IList <Model_Mailbox>  mdm = MailboxController.GetMailbox(ms.CID.ToString());

        MailSenderOption option = new MailSenderOption
        {
            MailSetting = s,
            context     = context
        };
        EmailEelements e = new EmailEelements();

        // _el = (EModel)e.model_GetElementBYID(this.EID).Eelement.JsonToObject(new EModel());
        int count = 1;

        foreach (Model_SendingJobItem c in cli)
        {
            if (c.CType == 1)
            {
                Model_Campaign cam = mdc.SingleOrDefault(r => r.CID == c.CID);
                EModel         el  = (EModel)cam.ELRaw.JsonToObject(new EModel());
                option.Subject = cam.Subject;

                string bodymail = el.html;
                if (cam.Unsub)
                {
                    bodymail = bodymail.Replace("</body>", appendSubscription(c.SID));
                }

                option.Mailbody = bodymail;

                if (!string.IsNullOrEmpty(cam.FileMail))
                {
                    option.Attachment = GetFileMail(cam.FileMail);
                }
            }
            else
            {
                Model_Mailbox cam = mdm.SingleOrDefault(r => r.CID == c.CID);
                EModel        el  = (EModel)cam.ELRaw.JsonToObject(new EModel());
                option.Subject = cam.Subject;

                string bodymail = appendHtmlforMailbox(el.html);
                if (cam.Unsub && c.SID != 0)
                {
                    bodymail = bodymail.Replace("</body>", appendSubscription(c.SID));
                }

                option.Mailbody = bodymail;

                if (!string.IsNullOrEmpty(cam.FileMail))
                {
                    option.Attachment = GetFileMail(cam.FileMail);
                }
            }
            option.mailTo = c.Email;

            //"*****@*****.**", "Gosolve", c.Email, "Thread Sending", "", "Thread Sending Thread Sending"
            if (MAilSender.SendMailEngine(option))
            {
                c.UpdateStatus(c.SDIID, true);
            }



            // Lock.AcquireWriterLock(Timeout.Infinite);

            //SendingEngineController.SendResponse.SingleOrDefault(ii => ii.CID == c.CID).TotalSent += 1;
            // Lock.ReleaseWriterLock();



            ms.UpdateTotalSentAndISDone(c.SDID);
            count = count + 1;
        }

        Lock.AcquireWriterLock(Timeout.Infinite);
        SendingEngineController.Onprocess = false;
        Lock.ReleaseWriterLock();
    }