コード例 #1
0
        public string DoReplacements(SMSItem item)
        {
            var person = CurrentDatabase.LoadPersonById(item.PeopleID ?? 0);

            var texta = new List <string>(stringlist);

            for (var i = 1; i < texta.Count; i++)
            {
                var part = texta[i];
                if (part.StartsWith("{") || part.StartsWith("http"))
                {
                    texta[i] = DoReplaceCode(part, person, item);
                }
            }
            return(string.Join("", texta));
        }
コード例 #2
0
 private string DoReplaceCode(string code, Person person, SMSItem item)
 {
     if (codeFunctions.ContainsKey(code))
     {
         var func = codeFunctions[code];
         return(func(person));
     }
     if (SpecialLinkRe.IsMatch(code))
     {
         return(SpecialLinkReplacement(code, item));
     }
     if (OtherLinkRe.IsMatch(code))
     {
         return(OtherLinkReplacement(code));
     }
     return(code); // nothing matched
 }
コード例 #3
0
 private void detach_SMSItems(SMSItem entity)
 {
     this.SendPropertyChanging();
     entity.SMSList = null;
 }
コード例 #4
0
 private void attach_SMSItems(SMSItem entity)
 {
     this.SendPropertyChanging();
     entity.SMSList = this;
 }
コード例 #5
0
ファイル: Person.cs プロジェクト: GSBCfamily/bvcms
		private void detach_SMSItems(SMSItem entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}
コード例 #6
0
ファイル: Person.cs プロジェクト: GSBCfamily/bvcms
		private void attach_SMSItems(SMSItem entity)
		{
			this.SendPropertyChanging();
			entity.Person = this;
		}
コード例 #7
0
ファイル: TwilioHelper.cs プロジェクト: hkouns/bvcms
        public static void QueueSMS(Guid iQBID, int iSendGroupID, string sTitle, string sMessage)
        {
            var q = DbUtil.Db.PeopleQuery(iQBID);

            // Create new SMS send list
            var list = new SMSList();

            list.Created = DateTime.Now;
            list.SendAt = DateTime.Now;
            list.SenderID = Util.UserPeopleId ?? 1;
            list.SendGroupID = iSendGroupID;
            list.Title = sTitle;
            list.Message = sMessage;

            DbUtil.Db.SMSLists.InsertOnSubmit(list);
            DbUtil.Db.SubmitChanges();

            // Load all people but tell why they can or can't be sent to

            foreach (var i in q)
            {
                var item = new SMSItem();

                item.ListID = list.Id;
                item.PeopleID = i.PeopleId;

                if (i.CellPhone != null && i.CellPhone.Length > 0)
                {
                    item.Number = i.CellPhone;
                }
                else
                {
                    item.Number = "";
                    item.NoNumber = true;
                }

                if (!i.ReceiveSMS)
                {
                    item.NoOptIn = true;
                }

                DbUtil.Db.SMSItems.InsertOnSubmit(item);
            }

            DbUtil.Db.SubmitChanges();

            // Check for how many people have cell numbers and want to receive texts
            var qSMS = from p in q
                where p.CellPhone != null
                where p.ReceiveSMS == true
                select p;

            var countSMS = qSMS.Count();

            /*
            if (countSMS > 0)
            {
                foreach (var i in qSMS)
                {
                    var item = new SMSItem();

                    item.ListID = list.Id;
                    item.PeopleID = i.PeopleId;
                    item.Number = i.CellPhone;

                    DbUtil.Db.SMSItems.InsertOnSubmit(item);
                }
            }
            */

            // Add counts for SMS, e-Mail and none
            list.SentSMS = countSMS;
            list.SentNone = q.Count() - countSMS;

            DbUtil.Db.SubmitChanges();

            ProcessQueue(list.Id);
        }
コード例 #8
0
        private string SpecialLinkReplacement(string code, SMSItem item)
        {
            // remove the non url parts and reformat
            code = code.Replace("\"", string.Empty);
            code = code.Replace("&amp;", "&");
            code = HttpUtility.UrlDecode(code);

            // parse the special link url to get the component parts
            Uri    specialLink = new Uri(code);
            string type        = specialLink.Host;
            var    querystring = HttpUtility.ParseQueryString(specialLink.Query);
            string orgId       = querystring.Get("org");
            string meetingId   = querystring.Get("meeting");
            string groupId     = querystring.Get("group");
            string confirm     = querystring.Get("confirm");
            string message     = querystring.Get("msg");

            // result variables
            string qs;      // the unique link combination for the db

            // set some defaults for any missing properties
            bool showfamily = false;

            if (!message.HasValue())
            {
                message = "Thank you for responding.";
            }
            if (!confirm.HasValue())
            {
                confirm = "false";
            }

            // generate the one time link code and update any vars based on the link type
            switch (type)
            {
            case "rsvplink":
            case "regretslink":
                qs = $"{meetingId},{item.PeopleID},{item.Id},{groupId}";
                break;

            case "registerlink":
            case "registerlink2":
                showfamily = (type == "registerlink2");
                qs         = $"{orgId},{item.PeopleID},{item.Id}";
                break;

            case "sendlink":
            case "sendlink2":
                showfamily = (type == "sendlink2");
                qs         = $"{orgId},{item.PeopleID},{item.Id},{(showfamily ? "registerlink2" : "registerlink")}";
                break;

            case "votelink":
                string pre = "";
                var    a   = groupId.SplitStr(":");
                if (a.Length > 1)
                {
                    pre = a[0];
                }
                qs = $"{orgId},{item.PeopleID},{item.Id},{pre},{groupId}";
                break;

            default:
                return(code);
            }

            var ot  = CreateOrFetchOneTimeLink(qs, oneTimeLinkList);
            var url = CreateUrlForLink(type, ot, confirm, message, showfamily);

            return(PythonModel.CreateTinyUrl(url));
        }