Пример #1
0
        public static void SendNewsletters()
        {
            List <Newsletter_Send> newslettersToSend = NewsletterJobDAL.GetNewslettersToSend();

            foreach (var newsletter in newslettersToSend)
            {
                foreach (var newsletterSendItem in newsletter.Newsletter_Send_Item)
                {
                    if (!newsletterSendItem.IsSent)
                    {
                        if (newsletterSendItem.SendToContactId != null && newsletterSendItem.SendToContactId > 0 &&
                            ContactBLL.IsUnsubscribed(newsletterSendItem.SendToContactId))
                        {
                            continue;
                        }

                        string mailContent = string.Concat(newsletter.NewsletterContent,
                                                           string.Format(@"<img style='height: 0px; width: 0px; display: none;' src='http://gradera-klubb.local/api/NewsletterJob/ReadNewsletter/{0}' />
                            <center><p><a href='{1}unsubscribe/{0}'>Avbryt prenumerationen på detta nyhetsbrev</a></p></center>",
                                                                         newsletterSendItem.NewsletterSendItemGUID,
                                                                         AppSettingsHelper.GetAppSetting("ExternalPath") ?? "//club.gradera.nu/external.html#/"));
                        EmailHelper.SendEmail(newsletterSendItem.Email,
                                              mailContent,
                                              newsletter.NewsletterName);
                        NewsletterJobDAL.UpdateNewsletterSendItemToSent(newsletterSendItem.Id);
                        Thread.Sleep(10000);
                    }
                }
            }
        }
Пример #2
0
        public HttpResponseMessage SaveContact(Contact contact)
        {
            HttpResponseMessage response     = new HttpResponseMessage(HttpStatusCode.OK);
            UserPrincipal       loggedInUser = (UserPrincipal)HttpContext.Current.User;

            ContactBLL.SaveContact(contact, loggedInUser.AccountSession.ClubId);
            return(response);
        }
Пример #3
0
        public HttpResponseMessage GetContactForEmail(string email, int clubId)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
            Contact             contact  = ContactBLL.GetContactForEmail(email, clubId);

            response.Content = new ObjectContent <ContactModel>(new ContactModel(contact), new JsonMediaTypeFormatter());
            return(response);
        }
Пример #4
0
        /// <summary>
        /// 保存模板信息
        /// </summary>
        private void SaveActionTemp(HttpContext context)
        {
            crm_contact_action_tmpl actionTemp = null;
            var sendEmail        = (sbyte)(context.Request.QueryString["sendEmail"] == "1"?1:0);
            var tempId           = context.Request.QueryString["tempId"];
            var noteActionTypeId = context.Request.QueryString["noteActionTypeId"];
            var noteDescription  = context.Request.QueryString["noteDescription"];

            var todoActionTypeId = context.Request.QueryString["todoActionTypeId"];
            var todoDescription  = context.Request.QueryString["todoDescription"];
            var todoResourceId   = context.Request.QueryString["todoResourceId"];
            var todoStartDate    = context.Request.QueryString["todoStartDate"];
            var todoEndDate      = context.Request.QueryString["todoEndDate"];

            var description = context.Request.QueryString["description"];

            if (!string.IsNullOrEmpty(tempId))
            {
                actionTemp = new ContactBLL().GetTempById(long.Parse(tempId));
            }
            if (actionTemp == null)
            {
                actionTemp      = new crm_contact_action_tmpl();
                actionTemp.name = context.Request.QueryString["name"];
            }
            actionTemp.send_email = sendEmail;
            if (!string.IsNullOrEmpty(noteActionTypeId))
            {
                actionTemp.note_action_type_id = int.Parse(noteActionTypeId);
                actionTemp.note_description    = noteDescription;
            }
            else
            {
                actionTemp.note_action_type_id = null;
                actionTemp.note_description    = string.Empty;
            }
            if (!string.IsNullOrEmpty(todoActionTypeId) && !string.IsNullOrEmpty(todoStartDate) && !string.IsNullOrEmpty(todoEndDate))
            {
                actionTemp.todo_action_type_id = int.Parse(todoActionTypeId);
                actionTemp.todo_description    = todoDescription;
                actionTemp.todo_resource_id    = long.Parse(todoResourceId);
                actionTemp.todo_start_date     = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(todoStartDate));
                actionTemp.todo_end_date       = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(todoEndDate));
            }
            else
            {
                actionTemp.todo_action_type_id = null;
                actionTemp.todo_description    = string.Empty;
                actionTemp.todo_resource_id    = null;
                actionTemp.todo_start_date     = null;
                actionTemp.todo_end_date       = null;
            }
            actionTemp.description = description;
            long thisTempId = 0;
            var  result     = new ContactBLL().SaveActionTemp(actionTemp, LoginUserId, ref thisTempId);

            context.Response.Write(new Tools.Serialize().SerializeJson(new { result = result, id = thisTempId }));
        }
Пример #5
0
        public HttpResponseMessage GetAllContacts()
        {
            HttpResponseMessage response     = new HttpResponseMessage(HttpStatusCode.OK);
            UserPrincipal       loggedInUser = (UserPrincipal)HttpContext.Current.User;
            List <Contact>      contacts     = ContactBLL.GetContacts(loggedInUser.AccountSession.ClubId);
            List <ContactModel> models       = ContactModel.MapModels(contacts);

            response.Content = new ObjectContent <List <ContactModel> >(models, new JsonMediaTypeFormatter());
            return(response);
        }
Пример #6
0
        /// <summary>
        /// 删除联系人活动模板
        /// </summary>
        private void DeleteContactActionTemp(HttpContext context)
        {
            var tempId = context.Request.QueryString["tempId"];
            var result = false;

            if (!string.IsNullOrEmpty(tempId))
            {
                result = new ContactBLL().DeleteContactActionTemp(long.Parse(tempId), LoginUserId);
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #7
0
 /// <summary>
 /// 获取模板信息
 /// </summary>
 private void GetTempInfo(HttpContext context)
 {
     if (!string.IsNullOrEmpty(context.Request.QueryString["tempId"]))
     {
         var temp = new ContactBLL().GetTempById(long.Parse(context.Request.QueryString["tempId"]));
         if (temp != null)
         {
             context.Response.Write(new Tools.Serialize().SerializeJson(temp));
         }
     }
 }
Пример #8
0
        /// <summary>
        /// 从联系人组中移除联系人
        /// </summary>
        private void RemoveContactFromGroup(HttpContext context)
        {
            var ids     = context.Request.QueryString["ids"];
            var groupId = context.Request.QueryString["groupId"];
            var result  = false;

            if (!string.IsNullOrEmpty(groupId) && !string.IsNullOrEmpty(ids))
            {
                result = new ContactBLL().RemoveContactFromGroup(long.Parse(groupId), ids, LoginUserId);
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #9
0
        public bool PutContact(Contact contact)
        {
            bool status = false;

            contactBLL = new ContactBLL();
            if (ModelState.IsValid)
            {
                status = contactBLL.PutContact(contact);
            }

            return(status);
        }
Пример #10
0
 protected void grdContactsRowDelete(object sender, GridViewDeleteEventArgs e)
 {
     if (ContactBLL.Delete(e.Keys[0]) != 0)
     {
         msg.Text = "Запис видалено";
         gridFill();
     }
     else
     {
         msg.Text = "Запис не видалено";
     }
 }
Пример #11
0
        /// <summary>
        /// 获取联系人组信息
        /// </summary>
        private void GetContactGroup(HttpContext context)
        {
            var id = context.Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                var thisGroup = new ContactBLL().GetGroupById(long.Parse(id));
                if (thisGroup != null)
                {
                    context.Response.Write(new Tools.Serialize().SerializeJson(thisGroup));
                }
            }
        }
Пример #12
0
        /// <summary>
        /// 客户的联系人组管理
        /// </summary>
        private void AccountContractGroupManage(HttpContext context)
        {
            var accountId = context.Request.QueryString["accountId"];
            var groupId   = context.Request.QueryString["groupId"];
            var ids       = context.Request.QueryString["ids"];
            var result    = false;

            if (!string.IsNullOrEmpty(accountId) && !string.IsNullOrEmpty(groupId))
            {
                result = new ContactBLL().AccountContractGroupManage(long.Parse(accountId), long.Parse(groupId), ids, LoginUserId);
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #13
0
        public static string Unsubscribe(string guid)
        {
            string email = string.Empty;
            Newsletter_Send_Item newsletterSendItem = NewsletterDAL.GetNewsletterSendItemByGuid(guid);

            if (newsletterSendItem != null && newsletterSendItem.SendToContactId != null && newsletterSendItem.SendToContactId > 0)
            {
                NewsletterDAL.UnsubscribeNewsletterItem(newsletterSendItem);
                ContactBLL.Unsubscribe(newsletterSendItem.SendToContactId);
                email = newsletterSendItem.Email;
            }
            return(email);
        }
 protected void bt3_Click(object sender, EventArgs e)
 {
     try
     {
         int id = int.Parse(tb11.Text);
         ContactBLL.Delete(id);
         ltrContacts.Text = getAll();
         refreshBoxes();
     }
     catch (Exception err)
     {
         lblErrorMessage1.Text = "Error " + err.Message;
     }
 }
        private int maxID()
        {
            var l   = ContactBLL.GetAll();
            int max = 0;

            for (int i = 0; i < l.Count; i++)
            {
                if (l[i].contactId > max)
                {
                    max = l[i].contactId;
                }
            }
            return(max + 1);
        }
Пример #16
0
        /// <summary>
        /// 校验联系人群组名称
        /// </summary>
        private void CheckGroupName(HttpContext context)
        {
            var  name   = context.Request.QueryString["name"];
            var  result = false;
            long?id     = null;

            if (!string.IsNullOrEmpty(context.Request.QueryString["id"]))
            {
                id = long.Parse(context.Request.QueryString["id"]);
            }
            if (!string.IsNullOrEmpty(name))
            {
                result = new ContactBLL().CheckGroupName(name, id);
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #17
0
        /// <summary>
        /// 模板名称校验
        /// </summary>
        private void CheckTempName(HttpContext context)
        {
            var result = false;
            var name   = context.Request.QueryString["name"];

            if (!string.IsNullOrEmpty(name))
            {
                long id = 0;
                if (!string.IsNullOrEmpty(context.Request.QueryString["tempId"]))
                {
                    id = long.Parse(context.Request.QueryString["tempId"]);
                }
                result = new ContactBLL().CheckActionTempName(name, id);
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #18
0
        /// <summary>
        ///  激活/失活 联系人组
        /// </summary>
        /// <param name="context"></param>
        private void ActiveContactGroup(HttpContext context)
        {
            var groupId  = context.Request.QueryString["groupId"];
            var result   = false;
            var isActive = true;

            if (!string.IsNullOrEmpty(context.Request.QueryString["inActive"]))
            {
                isActive = false;
            }
            if (!string.IsNullOrEmpty(groupId))
            {
                result = new ContactBLL().ActiveContactGroup(long.Parse(groupId), isActive, LoginUserId);
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #19
0
        /// <summary>
        /// 删除联系人的事件
        /// </summary>
        /// <param name="context"></param>
        /// <param name="contact_id"></param>
        public void DeleteContact(HttpContext context, long contact_id)
        {
            if (AuthBLL.GetUserContactAuth(LoginUserId, LoginUser.security_Level_id, contact_id).CanDelete == false)
            {
                return;
            }

            var result = new ContactBLL().DeleteContact(contact_id, LoginUserId);

            if (result)
            {
                context.Response.Write("删除联系人成功!");
            }
            else
            {
                context.Response.Write("删除联系人失败!");
            }
        }
Пример #20
0
        /// <summary>
        /// 联系人群组管理(新增,编辑)
        /// </summary>
        private void GroupManage(HttpContext context)
        {
            var  name   = context.Request.QueryString["name"];
            var  result = false;
            long?id     = null;

            if (!string.IsNullOrEmpty(context.Request.QueryString["id"]))
            {
                id = long.Parse(context.Request.QueryString["id"]);
            }
            var isActive = Convert.ToSByte(context.Request.QueryString["isActive"]);

            if (!string.IsNullOrEmpty(name))
            {
                result = new ContactBLL().ContactGroupManage(id, name, isActive, LoginUserId);
            }
            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #21
0
 /// <summary>
 /// 保存联系人信息
 /// </summary>
 /// <returns></returns>
 private ERROR_CODE SaveContact()
 {
     SaveFormData();
     if (dto.contact.id == 0)
     {
         var res = new ContactBLL().Insert(dto, GetLoginUserId());
         // 08-21 新增商机时添加联系人并返回联系人更改,若不将联系人id重置为0 会影响提示结果,暂时这样处理吧QAQ -- by  zf
         if (!string.IsNullOrEmpty(callBackFiled))
         {
             Response.Write("<script>window.opener." + callBackFiled + "('" + dto.contact.id + "');</script>");
         }
         dto.contact.id = 0;
         return(res);
     }
     else
     {
         return(new ContactBLL().Update(dto, GetLoginUserId()));
     }
 }
Пример #22
0
        protected void grdContactsRowEdit(object sender, GridViewEditEventArgs e)
        {
            msg.Text = "";
            pnlGrdViewDetail.Enabled = true;
            pnlGrdViewDetail.Visible = true;


            imgbtnNew.Visible  = false;
            imgbtnSave.Visible = true;

            grdContacts.EditIndex     = e.NewEditIndex;
            grdContacts.SelectedIndex = e.NewEditIndex;

            gridFill();

            var contacts = ContactBLL.GetAll();

            ViewDetails(grdContacts.DataKeys[e.NewEditIndex].Value);
        }
Пример #23
0
        public HttpResponseMessage GetContact(int contactId)
        {
            HttpResponseMessage response     = new HttpResponseMessage(HttpStatusCode.OK);
            Contact             contact      = ContactBLL.GetContact(contactId);
            UserPrincipal       loggedInUser = (UserPrincipal)HttpContext.Current.User;

            if (loggedInUser.AccountSession.ClubId == contact.ClubId)
            {
                response.Content = new ObjectContent <ContactModel>(new ContactModel(contact), new JsonMediaTypeFormatter());
            }
            else
            {
                LogHelper.LogWarn(string.Format("UserId: {0} trying to get a contact outside of the club, contact: {1}",
                                                loggedInUser.AccountSession.AccountId, contactId), null, loggedInUser.AccountSession.ClubId);
                response.StatusCode = HttpStatusCode.Forbidden;
            }

            return(response);
        }
        private string getAll()
        {
            var l = ContactBLL.GetAll();
            //Console.WriteLine(l);
            StringBuilder str = new StringBuilder("");
            Contact       contact;

            for (int i = 0; i < l.Count; i++)
            {
                contact = l[i];
                Console.WriteLine(contact.address);
                str.Append("<li>");
                str.Append(contact.contactId.ToString() + ". ");
                str.Append(contact.ownerId + " " + contact.name + "   " + contact.address + "   " + contact.city +
                           "   " + contact.state + "   " + contact.zip + "   " + contact.email + "   " + contact.status);
                str.Append("</li>");
            }
            return(str.ToString());
        }
Пример #25
0
        protected void imgbtnSave_Click(object sender, ImageClickEventArgs e)
        {
            Contact product;

            if (checkValidators())
            {
                if (grdContacts.Rows.Count > 0 && grdContacts.SelectedValue != null)
                {
                    product = GetValueFromPage(new Guid(grdContacts.SelectedValue.ToString()));
                    int index = grdContacts.SelectedRow.DataItemIndex;

                    if ((ContactBLL.Update(product)) != 0)
                    {
                        imgbtnSave.Visible       = false;
                        pnlGrdViewDetail.Enabled = false;
                        imgbtnNew.Visible        = true;
                        msg.Text = GetGlobalResourceObject("GlobalResources", "SaveSuccess").ToString();
                        gridFill();
                    }
                    else
                    {
                        msg.Text = GetGlobalResourceObject("GlobalResources", "SaveUnSuccess").ToString();
                    }
                }
                else
                {
                    product = GetValueFromPage(Guid.NewGuid());
                    if (ContactBLL.Add(product) != 0)
                    {
                        imgbtnSave.Visible       = false;
                        pnlGrdViewDetail.Enabled = false;
                        imgbtnNew.Visible        = true;
                        msg.Text = GetGlobalResourceObject("GlobalResources", "SaveSuccess").ToString();
                        gridFill();
                    }
                    else
                    {
                        msg.Text = GetGlobalResourceObject("GlobalResources", "SaveUnSuccess").ToString();
                    }
                }
            }
        }
Пример #26
0
        protected void save_close_Click(object sender, EventArgs e)
        {
            var updateId   = Request.Params["updateId"];
            var fax        = Request.Params["Fax"];
            var phone      = Request.Params["Phone"];
            var account_id = Request.QueryString["account_id"];

            if (!string.IsNullOrEmpty(updateId))
            {
                var result = new ContactBLL().UpdateContacts(updateId, phone, fax, GetLoginUserId());
                if (result)
                {
                    Response.Write("<script>alert('修改联系人成功!');window.close();</script>");
                }
                else
                {
                    Response.Write("<script>alert('修改联系人失败!');window.close();</script>");
                }
            }
        }
 protected void bt4_Click(object sender, EventArgs e)
 {
     try
     {
         int           id  = int.Parse(tb12.Text);
         var           l   = ContactBLL.GetById(id);
         StringBuilder str = new StringBuilder("");
         str.Append("<li>");
         // str.Append(l.id.ToString() + ". ");
         str.Append(l.ownerId + " " + l.name + "   " + l.address + "   " + l.city + "   " + l.state + "   " +
                    l.zip + "   " + l.email + "   " + l.status);
         str.Append("</li>");
         ltrContacts0.Text = str.ToString();
         refreshBoxes();
     }
     catch (Exception err)
     {
         lblErrorMessage2.Text = "Error " + err.Message;
     }
 }
Пример #28
0
        public HttpResponseMessage DeleteContact(int contactId)
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

            Contact       contact      = ContactBLL.GetContact(contactId);
            UserPrincipal loggedInUser = (UserPrincipal)HttpContext.Current.User;

            if (loggedInUser.AccountSession.ClubId == contact.ClubId)
            {
                ContactBLL.DeleteContact(contact);
            }
            else
            {
                LogHelper.LogWarn(string.Format("UserId: {0} trying to delete a contact outside of the club, contact: {1}",
                                                loggedInUser.AccountSession.AccountId, contactId), null, loggedInUser.AccountSession.ClubId);
                response.StatusCode = HttpStatusCode.Forbidden;
            }

            return(response);
        }
Пример #29
0
        /// <summary>
        /// 保存联系人模板-只更新名称描述信息,功能同上
        /// </summary>
        private void SaveActionTempShort(HttpContext context)
        {
            crm_contact_action_tmpl actionTemp = null;
            var tempId = context.Request.QueryString["tempId"];

            if (!string.IsNullOrEmpty(tempId))
            {
                actionTemp = new ContactBLL().GetTempById(long.Parse(tempId));
            }
            if (actionTemp == null)
            {
                actionTemp = new crm_contact_action_tmpl();
            }
            actionTemp.name        = context.Request.QueryString["name"];
            actionTemp.description = context.Request.QueryString["description"];
            long thisTempId = 0;
            var  result     = new ContactBLL().SaveActionTemp(actionTemp, LoginUserId, ref thisTempId);

            context.Response.Write(new Tools.Serialize().SerializeJson(result));
        }
Пример #30
0
        public async Task <HttpResponseMessage> CsvImport()
        {
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

            if (!Request.Content.IsMimeMultipartContent())
            {
                response.StatusCode = HttpStatusCode.UnsupportedMediaType;
            }
            else
            {
                UserPrincipal loggedInUser             = (UserPrincipal)HttpContext.Current.User;
                MultipartMemoryStreamProvider provider = new MultipartMemoryStreamProvider();
                await Request.Content.ReadAsMultipartAsync(provider);

                Task <byte[]> fileData    = provider.Contents.First().ReadAsByteArrayAsync();
                int           importCount = ContactBLL.CsvImport(fileData.Result, loggedInUser.AccountSession.ClubId);
                response.Content = new ObjectContent <int>(importCount, new JsonMediaTypeFormatter());
            }

            return(response);
        }