public ContentResult Search(SearchFilter SearchKey)
        {
            SearchKey.OrderBy = string.IsNullOrEmpty(SearchKey.OrderBy) ? "Id" : SearchKey.OrderBy;
            QueuedEmailCollection collection = QueuedEmailManager.Search(SearchKey);

            return(Content(JsonConvert.SerializeObject(collection), "application/json"));
        }
Example #2
0
        public static QueuedEmailCollection GetUnSendingEmail()
        {
            QueuedEmailCollection items = new QueuedEmailCollection();
            SearchFilter          value = new SearchFilter();

            value.CompanyID      = 1;
            value.Keyword        = "";
            value.OrderBy        = "CreatedOnUtc";
            value.ColumnsName    = "CreatedOnUtc";
            value.OrderDirection = "desc";
            value.Condition      = " CompanyID=1 and sentONUtc is null ";
            value.Page           = 1;
            value.PageSize       = 50;

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PostAsJsonAsync(Resource + "?method=search", value).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <QueuedEmailCollection>().GetAwaiter().GetResult();
                }
            }

            return(items);
        }
        protected void BindGrid()
        {
            DateTime? startDate = ctrlStartDatePicker.SelectedDate;
            DateTime? endDate = ctrlEndDatePicker.SelectedDate;
            DateTime startDateTmp = DateTime.Now;
            if(startDate.HasValue)
            {
                startDate = DateTimeHelper.ConvertToUtcTime(startDate.Value, DateTimeHelper.CurrentTimeZone);
            }
            if(endDate.HasValue)
            {
                endDate = DateTimeHelper.ConvertToUtcTime(endDate.Value, DateTimeHelper.CurrentTimeZone).AddDays(1);
            }

            string fromEmail = txtFromEmail.Text;
            string toEmail = txtToEmail.Text;
            bool loadNotSentItemsOnly = cbLoadNotSentItemsOnly.Checked;
            int maxSendTries = txtMaxSendTries.Value;

            QueuedEmailCollection queuedEmails = MessageManager.GetAllQueuedEmails(fromEmail, toEmail,
                startDate, endDate, 0, loadNotSentItemsOnly, maxSendTries);
            if (queuedEmails.Count > 0)
            {
                gvQueuedEmails.Visible = true;
                lblQueuedEmailsFound.Visible = false;
                gvQueuedEmails.DataSource = queuedEmails;
                gvQueuedEmails.DataBind();
            }
            else
            {
                gvQueuedEmails.Visible = false;
                lblQueuedEmailsFound.Visible = true;
            }
        }
Example #4
0
        public static QueuedEmailCollection Search(SearchFilter value)
        {
            QueuedEmailCollection items = new QueuedEmailCollection();
            //string key = string.Format(SETTINGS_Search_KEY, value.CompanyID+value.Keyword+value.Page+value.PageSize+value.OrderBy+value.OrderDirection)
            string key = string.Format(SETTINGS_Search_KEY, value.Keyword, value.Page, value.PageSize, value.OrderBy, value.OrderDirection, value.Condition);

            if (SystemConfig.AllowSearchCache)
            {
                object obj2 = HttpCache.Get(key);

                if ((obj2 != null))
                {
                    return((QueuedEmailCollection)obj2);
                }
            }

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PostAsJsonAsync(Resource + "?method=search", value).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <QueuedEmailCollection>().GetAwaiter().GetResult();
                }
            }

            if (SystemConfig.AllowSearchCache)
            {
                HttpCache.Max(key, items);
            }
            return(items);
        }
        /// <summary>
        /// use for scrolling page
        /// </summary>
        /// <returns></returns>
        public ContentResult GetPg(int page, int pagesize)
        {
            string                condition = "";
            SearchFilter          SearchKey = SearchFilter.SearchPG(CurrentUser.CompanyID, page, pagesize, "Id", "Id", "Desc", condition);
            QueuedEmailCollection objItem   = QueuedEmailManager.Search(SearchKey);

            return(Content(JsonConvert.SerializeObject(objItem), "application/json"));
        }
        public JsonResult GetGata([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            SearchFilter          SearchKey  = SearchFilter.SearchData(CurrentUser.CompanyID, requestModel, "Id", "Id");
            QueuedEmailCollection collection = QueuedEmailManager.Search(SearchKey);
            int TotalRecord = 0;

            if (collection.Count > 0)
            {
                TotalRecord = collection[0].TotalRecord;
            }
            //QueuedEmailCollection data = QueuedEmailManager.GetAll(CurrentUser.CompanyID);
            return(Json(new DataTablesResponse(requestModel.Draw, collection, TotalRecord, TotalRecord), JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetSearchData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, string searchprm)
        {
            SearchFilter SearchKey = BindSearch(searchprm);

            SearchKey = SearchFilter.SearchData(SearchKey, requestModel);
            QueuedEmailCollection collection = QueuedEmailManager.Search(SearchKey);
            int TotalRecord = 0;

            if (collection.Count > 0)
            {
                TotalRecord = collection[0].TotalRecord;
            }
            return(Json(new DataTablesResponse(requestModel.Draw, collection, TotalRecord, TotalRecord), JsonRequestBehavior.AllowGet));
        }
Example #8
0
        /// <summary>
        /// return the Probation Email List
        /// </summary>
        /// <param name="CompanyID"></param>
        /// <returns></returns>
        public static QueuedEmailCollection GetProbationContractList(int CompanyID)
        {
            QueuedEmailCollection items = new QueuedEmailCollection();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                //HttpResponseMessage response = client.GetAsync(Resource).GetAwaiter().GetResult();
                HttpResponseMessage response = client.GetAsync(string.Format(Resource + "?CompanyID={0}", CompanyID)).GetAwaiter().GetResult();
                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <QueuedEmailCollection>().GetAwaiter().GetResult();
                }
            }
            return(items);
        }
Example #9
0
        public static QueuedEmailCollection Search(SearchFilter SearchKey)
        {
            QueuedEmailCollection collection = new QueuedEmailCollection();

            using (var reader = SqlHelper.ExecuteReader("QueuedEmail_Search", SearchFilterManager.SqlSearchParam(SearchKey)))
            {
                while (reader.Read())
                {
                    QueuedEmail obj = new QueuedEmail();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Example #10
0
        public static QueuedEmailCollection ReminderContractEmailList(int CompanyID)
        {
            QueuedEmailCollection collection = new QueuedEmailCollection();

            //var sqlParams = new SqlParameter[1];
            //sqlParams[0] = new SqlParameter("@isActive", isActive);
            using (var reader = SqlHelper.ExecuteLongReaderService(ModuleConfig.MyConnection, 600, "USP_CMS_JOB_Reminder_Fetch_V1", null))
            {
                QueuedEmail obj = new QueuedEmail();
                while (reader.Read())
                {
                    obj = GetQueMessageFromReader(reader, CompanyID);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Example #11
0
        /// <summary>
        /// ExportExcel File
        /// </summary>
        /// <returns></returns>
        public string ExportExcel()
        {
            QueuedEmailCollection collection = QueuedEmailManager.GetAll(CurrentUser.CompanyID);
            DataTable             dt         = collection.ToDataTable <QueuedEmail>();
            string fileName = "QueuedEmail_" + SystemConfig.CurrentDate.ToString("MM-dd-yyyy");

            string[] RemoveColumn = { "CompanyID", "TargetDisplayID", "ReturnDisplay", "TotalRecord", "CreatedUser", "CreatedDate" };
            for (int i = 0; i < RemoveColumn.Length; i++)
            {
                if (dt.Columns.Contains(RemoveColumn[i]))
                {
                    dt.Columns.Remove(RemoveColumn[i]);
                }
            }
            FileInputHelper.ExportExcel(dt, fileName, "QueuedEmail List", false);
            return(fileName);
        }
Example #12
0
        /// <summary>
        /// Executes a task
        /// </summary>
        /// <param name="node">Xml node that represents a task description</param>
        public void Execute(XmlNode node)
        {
            XmlAttribute attribute1 = node.Attributes["maxTries"];

            if (attribute1 != null && !String.IsNullOrEmpty(attribute1.Value))
            {
                this._maxTries = int.Parse(attribute1.Value);
            }

            QueuedEmailCollection queuedEmails = MessageManager.GetAllQueuedEmails(10000, true, _maxTries);

            foreach (QueuedEmail queuedEmail in queuedEmails)
            {
                List <string> bcc = new List <string>();
                foreach (string str1 in queuedEmail.Bcc.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    bcc.Add(str1);
                }
                List <string> cc = new List <string>();
                foreach (string str1 in queuedEmail.Cc.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    cc.Add(str1);
                }

                try
                {
                    MessageManager.SendEmail(queuedEmail.Subject, queuedEmail.Body,
                                             new MailAddress(queuedEmail.From, queuedEmail.FromName),
                                             new MailAddress(queuedEmail.To, queuedEmail.ToName), bcc, cc);

                    MessageManager.UpdateQueuedEmail(queuedEmail.QueuedEmailID, queuedEmail.Priority,
                                                     queuedEmail.From, queuedEmail.FromName, queuedEmail.To, queuedEmail.ToName,
                                                     queuedEmail.Cc, queuedEmail.Bcc, queuedEmail.Subject, queuedEmail.Body,
                                                     queuedEmail.CreatedOn, ++queuedEmail.SendTries, DateTime.Now);
                }
                catch (Exception exc)
                {
                    MessageManager.UpdateQueuedEmail(queuedEmail.QueuedEmailID, queuedEmail.Priority,
                                                     queuedEmail.From, queuedEmail.FromName, queuedEmail.To, queuedEmail.ToName,
                                                     queuedEmail.Cc, queuedEmail.Bcc, queuedEmail.Subject, queuedEmail.Body,
                                                     queuedEmail.CreatedOn, ++queuedEmail.SendTries, queuedEmail.SentOn);

                    LogManager.InsertLog(LogTypeEnum.MailError, string.Format("Error sending e-mail. {0}", exc.Message), exc);
                }
            }
        }
Example #13
0
        public static QueuedEmailCollection GetbyUser(string CreatedUser, int CompanyID)
        {
            QueuedEmailCollection collection = new QueuedEmailCollection();
            QueuedEmail           obj;
            var sqlParams = new SqlParameter[]
            {
                new SqlParameter("@CreatedUser", CreatedUser),
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("QueuedEmail_GetAll_byUser", sqlParams))
            {
                while (reader.Read())
                {
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Example #14
0
        public static QueuedEmailCollection GetAllItem(int CompanyID)
        {
            QueuedEmailCollection collection = new QueuedEmailCollection();

            var sqlParams = new SqlParameter[]
            {
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("QueuedEmail_GetAll", sqlParams))
            {
                while (reader.Read())
                {
                    QueuedEmail obj = new QueuedEmail();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Example #15
0
        public static QueuedEmailCollection GetAll(int CompanyID)
        {
            QueuedEmailCollection items = new QueuedEmailCollection();
            string key  = String.Format(SETTINGS_ALL_KEY, CompanyID);
            object obj2 = HttpCache.Get(key);

            if ((obj2 != null))
            {
                return((QueuedEmailCollection)obj2);
            }
            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.GetAsync(string.Format(Resource + "?CompanyID={0}", CompanyID)).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <QueuedEmailCollection>().GetAwaiter().GetResult();
                }
            }
            HttpCache.Max(key, items);
            return(items);
        }
        protected void BindGrid()
        {
            DateTime?startDate    = null;
            DateTime?endDate      = null;
            DateTime startDateTmp = DateTime.Now;

            if (DateTime.TryParse(txtStartDate.Text, out startDateTmp))
            {
                startDate = DateTime.SpecifyKind(startDateTmp, DateTimeKind.Utc);
            }
            DateTime endDateTmp = DateTime.Now;

            if (DateTime.TryParse(txtEndDate.Text, out endDateTmp))
            {
                endDate = DateTime.SpecifyKind(endDateTmp, DateTimeKind.Utc);
            }

            string fromEmail            = txtFromEmail.Text;
            string toEmail              = txtToEmail.Text;
            bool   loadNotSentItemsOnly = cbLoadNotSentItemsOnly.Checked;
            int    maxSendTries         = txtMaxSendTries.Value;

            QueuedEmailCollection queuedEmails = MessageManager.GetAllQueuedEmails(fromEmail, toEmail,
                                                                                   startDate, endDate, 0, loadNotSentItemsOnly, maxSendTries);

            if (queuedEmails.Count > 0)
            {
                gvQueuedEmails.Visible       = true;
                lblQueuedEmailsFound.Visible = false;
                gvQueuedEmails.DataSource    = queuedEmails;
                gvQueuedEmails.DataBind();
            }
            else
            {
                gvQueuedEmails.Visible       = false;
                lblQueuedEmailsFound.Visible = true;
            }
        }
Example #17
0
        public ActionResult list()
        {
            QueuedEmailCollection collection = QueuedEmailManager.GetAll(CurrentUser.CompanyID);

            return(View(ViewFolder + "list.cshtml", collection));
        }