public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            string str = context.Parameters["ids"];

            if (!String.IsNullOrEmpty(str))
            {
                TargetAudience ta = Sitecore.Modules.EmailCampaign.Factory.GetTargetAudience(str);
                if (ta != null)
                {
                    Item item = ta.InnerItem;
                    if (CanBeDeleted(ta))
                    {
                        ClientPipelineArgs args = new ClientPipelineArgs();
                        args.Parameters["rid"]   = str;
                        args.Parameters["rname"] = ta.Name;
                        Util.StartClientPipeline(this, "Run", args);
                    }
                    else
                    {
                        NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("This Recipient List is used in messages and cannot be deleted."));
                        return;
                    }
                }
            }
            else
            {
                NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("Please select a Recipient List."));
            }
        }
Ejemplo n.º 2
0
        public static (TargetAudience tAge, TargetAudience tGender, TargetAudience tInstruction, TargetAudience tSP) GetAudienceCriteriasFromGrammar(string grammarId)
        {
            TargetAudience age         = new TargetAudience();
            TargetAudience gender      = new TargetAudience();
            TargetAudience instruction = new TargetAudience();
            TargetAudience sp          = new TargetAudience();

            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                connection.Open();

                OleDbCommand storedProcedure = new OleDbCommand("GetAudienceCriteriaFromId", connection);
                storedProcedure.CommandType = System.Data.CommandType.StoredProcedure;
                storedProcedure.Parameters.AddWithValue("@grammarId", grammarId);

                OleDbDataReader reader = storedProcedure.ExecuteReader();

                if (reader.Read())
                {
                    age.AudienceCriteria = Convert.ToInt32(reader["t_age_id"]);
                    age.AudienceName     = reader["t_age"].ToString();

                    gender.AudienceCriteria = Convert.ToInt32(reader["t_gender_id"]);
                    gender.AudienceName     = reader["t_gender"].ToString();

                    instruction.AudienceCriteria = Convert.ToInt32(reader["t_instruction_id"]);
                    instruction.AudienceName     = reader["t_instruction"].ToString();

                    sp.AudienceCriteria = Convert.ToInt32(reader["t_sp_id"]);
                    sp.AudienceName     = reader["t_sp"].ToString();
                }
            }
            return(age, gender, instruction, sp);
        }
Ejemplo n.º 3
0
 private StudentBuilder()
 {
     _faker         = new Faker();
     Name           = _faker.Person.FullName;
     Email          = _faker.Person.Email;
     TargetAudience = TargetAudience.Student;
 }
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            string         str = context.Parameters["ids"];
            TargetAudience ta  = Factory.GetTargetAudience(str);

            if (ta != null)
            {
                Item innerItem;
                if (context.Items.Length == 0)
                {
                    ManagerRoot managerRoot = UIFactory.Instance.GetSpeakContext().ManagerRoot;
                    if (managerRoot == null)
                    {
                        return;
                    }
                    innerItem = managerRoot.InnerItem;
                }
                else
                {
                    innerItem = context.Items[0];
                }

                ClientPipelineArgs args = new ClientPipelineArgs();
                args.Parameters.Add("rid", str);
                args.Parameters["itemID"] = innerItem.ID.ToString();
                string methodName = "Run";
                Util.StartClientPipeline(this, methodName, args);
            }
            else
            {
                NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("Please select a Recipient List."));
            }
        }
Ejemplo n.º 5
0
 public async Task <MessengerProfileAPIResponse> SetTargetAudienceAsync(TargetAudience targetAudience)
 {
     return(await SetSettings(new MessengerProfileSetting
     {
         TargetAudience = targetAudience
     }));
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description")] TargetAudience targetAudience)
        {
            if (id != targetAudience.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(targetAudience);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TargetAudienceExists(targetAudience.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(targetAudience));
        }
Ejemplo n.º 7
0
        private IActionResult SaveTargetAudienceAsync(TargetAudience item)
        {
            //Check that Value/Name is unique
            if (_context.TargetAudience.AsNoTracking().FirstOrDefault(x => x.Value == item.Value && x.TargetAudienceId != item.TargetAudienceId) != null)
            {
                return(BadRequest("Duplicate entry/value found."));
            }

            var exiting = _context.TargetAudience.FirstOrDefault(x => x.TargetAudienceId == item.TargetAudienceId);

            if (exiting == null)
            {
                //ADD
                HelperExtensions.ClearIdentityValue(ref item);
                HelperExtensions.ClearNullableInts(ref item);
                _context.TargetAudience.Add(item);
                return(Created(item));
            }
            else
            {
                //UPDATE
                _context.Entry(exiting).CurrentValues.SetValues(item);
                return(Updated(exiting));
            }
        }
Ejemplo n.º 8
0
        public override void Execute(ActionContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            Util.AssertNotNull(context.Owner);

            string listId = ((RecipientListsObjectDetailList)UIUtil.FindControlByType(typeof(RecipientListsObjectDetailList))).LastSelectedRow;
            string userId = "";

            if (context.Model != null)
            {
                userId = context.Model.ToString();
            }
            if (!String.IsNullOrEmpty(listId) && !String.IsNullOrEmpty(userId))
            {
                TargetAudience ta = Factory.GetTargetAudience(listId);

                if (ta != null)
                {
                    string  userName = userId.Replace("__at__", "@").Replace("__dot__", ".").Replace("__slash__", "\\");
                    Contact contact  = Factory.GetContactFromName(userName);
                    contact.Unsubscribe(ta);
                    NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("Recipient was removed from the recipient list."));
                    NotificationManager.Instance.Notify("RecipientsChanged");
                    //ensure, try/catch
                }
            }
        }
        private bool CreateList(string nameParameter)
        {
            nameParameter = nameParameter.Trim();
            if (!String.IsNullOrEmpty(nameParameter))
            {
                using (new SecurityDisabler())
                {
                    ManagerRoot root = UIFactory.Instance.GetSpeakContext().ManagerRoot;
                    Util.AssertNotNull(root);

                    List <TargetAudience> taList  = root.GetTargetAudiences();
                    List <string>         taNames = new List <string>();
                    foreach (TargetAudience ta in taList)
                    {
                        taNames.Add(ta.Name);
                    }
                    if (taNames.Contains(nameParameter))
                    {
                        return(false);
                    }

                    Item listsContainerRoot = UIFactory.Instance.GetSpeakContext().ManagerRoot.GetRecipientListContainerItem();
                    if (listsContainerRoot != null)
                    {
                        TargetAudience ta = TargetAudienceSource.Create(nameParameter, listsContainerRoot, null, null);
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            TargetAudience targetAudience = db.TargetAudiences.Find(id);

            db.TargetAudiences.Remove(targetAudience);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 11
0
 public StudentBuilder()
 {
     _studentFaker   = new Faker("pt_BR");
     _cpf            = _studentFaker.Person.Cpf();
     _email          = _studentFaker.Person.Email;
     _name           = _studentFaker.Person.FullName;
     _targetAudience = _studentFaker.PickRandom <TargetAudience>();
 }
Ejemplo n.º 12
0
 public Course(string name, string description, double workload, TargetAudience targetAudience, double value)
 {
     this.Name           = name;
     this.Description    = description;
     this.Workload       = workload;
     this.TargetAudience = targetAudience;
     this.Value          = value;
 }
Ejemplo n.º 13
0
 public CourseTest()
 {
     _faker = new Faker();
     _name = _faker.Random.Word();
     _workload = _faker.Random.Int(50, 1000);
     _targetAudience = TargetAudience.Estudante;
     _courseFee = _faker.Random.Double(500, 2000);
     _description = _faker.Lorem.Paragraph();
 }
Ejemplo n.º 14
0
 public CourseTest()
 {
     _faker          = new Faker();
     _name           = _faker.Random.Word();
     _description    = _faker.Lorem.Paragraph();
     _workLoad       = _faker.Random.Double(50, 1000);
     _targetAudience = TargetAudience.Student;
     _value          = _faker.Random.Decimal(1, 10000);
 }
Ejemplo n.º 15
0
        public Course(Guid id, string name, int workload, TargetAudience targetAudience, double price)
        {
            SetId(id);
            SetName(name);
            SetWorkload(workload);
            SetTargetAudience(targetAudience);
            SetPrice(price);

            Validate(this, new CourseValidator());
        }
Ejemplo n.º 16
0
        public CourseTest()
        {
            _faker = new Faker();

            _nome           = _faker.Random.Word();
            _cargaHoraria   = _faker.Random.Double(50, 1000);
            _targetAudience = TargetAudience.Student;
            _valor          = _faker.Random.Double(100, 1000);
            _descricao      = _faker.Lorem.Paragraph();
        }
Ejemplo n.º 17
0
        public CourseTest()
        {
            var faker = new Faker();

            _name           = faker.Random.Word();
            _description    = faker.Lorem.Paragraph();
            _workLoad       = faker.Random.Double(50, 200);
            _targetAudience = TargetAudience.Student;
            _price          = faker.Random.Double(21, 1000);
        }
Ejemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "Id,Type")] TargetAudience targetAudience)
 {
     if (ModelState.IsValid)
     {
         db.Entry(targetAudience).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(targetAudience));
 }
        protected virtual bool SecurityDomainCompleted()
        {
            if (string.IsNullOrEmpty(this.DomainInput.Value))
            {
                SheerResponse.Alert(EcmTexts.Localize("You need to select a domain first.", new object[0]), new string[0]);
                return(false);
            }
            ImportOptions options = new ImportOptions
            {
                Filename         = FileUtil.MapPath("/temp/" + FileUtil.GetFileName(this.Filename.Value)),
                MappedProperties = this.MappedProperties,
                Root             = this.Root,
                DomainName       = this.DomainInput.Value
            };
            string str = Context.ClientPage.ClientRequest.Form[this.SkipUser.Name];

            if (string.IsNullOrEmpty(str) || str.Equals(this.SkipUser.Value))
            {
                options.ConflictOption = ImportOptions.ConflictOptions.SkipUser;
            }
            else
            {
                options.ConflictOption = str.Equals(this.OverwriteProperties.Value) ? ImportOptions.ConflictOptions.OverwriteProperties : ImportOptions.ConflictOptions.KeepProperties;
            }
            List <string> roles = new List <string>();

            try
            {
                string rolename = this.DomainInput.Value + "\\" + this.RecipientListName.Value;
                using (new SecurityDisabler())
                {
                    System.Web.Security.Roles.CreateRole(rolename);
                    Item listsContainerRoot = Root.GetRecipientListContainerItem();
                    if (listsContainerRoot != null)
                    {
                        TargetAudience ta = TargetAudienceSource.Create(this.RecipientListName.Value, listsContainerRoot, rolename, null);
                        if (ta == null)
                        {
                            return(false);
                        }
                    }
                }
                roles.Add(rolename);
            }
            catch (Exception exception)
            {
                SheerResponse.Alert(exception.Message, new string[0]);
                return(false);
            }

            options.Roles = roles.ToArray();
            JobHelper.StartJob("Import Users", "PerformImport", CoreFactory.Instance.GetRecipientImporter(), new object[] { options });
            this.CheckImport();
            return(true);
        }
Ejemplo n.º 20
0
        public ActionResult Create([Bind(Include = "Id,Type")] TargetAudience targetAudience)
        {
            if (ModelState.IsValid)
            {
                db.TargetAudiences.Add(targetAudience);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(targetAudience));
        }
        private bool CanBeDeleted(TargetAudience ta)
        {
            Item listItem = ta.InnerItem;

            ItemLink[] referrers = Globals.LinkDatabase.GetReferrers(listItem);
            if (referrers.Count() > 0)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 22
0
        public Student(string name, string email, TargetAudience targetAudiente)
        {
            RuleValidator.New()
            .When(string.IsNullOrEmpty(name), Messages.INVALID_NAME)
            .When(string.IsNullOrEmpty(email), Messages.INVALID_EMAIL)
            .ThrowExceptionIfExists();

            Name           = name;
            Email          = email;
            TargetAudience = targetAudiente;
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] TargetAudience targetAudience)
        {
            if (ModelState.IsValid)
            {
                _context.Add(targetAudience);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(targetAudience));
        }
Ejemplo n.º 24
0
        public CourseBuilder()
        {
            var faker = new Faker();

            _name           = faker.Random.Word();
            _workload       = faker.Random.Int(50, 1000);
            _targetAudience = faker.PickRandom <TargetAudience>();
            _courseFee      = faker.Random.Double(500, 2000);
            _description    = faker.Lorem.Paragraph();
            _id             = faker.Random.Int(50, 100);
        }
Ejemplo n.º 25
0
        // The constructor is always executed before each test method being executed (SetUp);
        public CourseTest(ITestOutputHelper output)
        {
            _output = output;
            _output.WriteLine("Constructor being executed");
            var faker = new Faker();

            _name           = faker.Random.Word();
            _workload       = faker.Random.Double(50, 1000);
            _targetAudience = TargetAudience.Student;
            _price          = faker.Random.Double(100, 1000);
            _description    = faker.Lorem.Paragraph();
        }
Ejemplo n.º 26
0
        public Student(string name, string email, string nif, TargetAudience targetAudience)
        {
            BaseValidator.New()
            .When(string.IsNullOrEmpty(name), Resource.InvalidName)
            .When(string.IsNullOrEmpty(email) || !_emailRegex.Match(email).Success, Resource.InvalidEmail)
            .When(string.IsNullOrEmpty(nif), Resource.InvalidNif)
            .TriggersIfExceptionExists();

            Name           = name;
            Nif            = nif;
            Email          = email;
            TargetAudience = targetAudience;
        }
Ejemplo n.º 27
0
        public CourseTest(ITestOutputHelper output)
        {
            _output = output;
            _output.WriteLine("Executing constructor !");

            var faker = new Faker();

            _name           = faker.Random.Words();
            _description    = faker.Lorem.Paragraph();
            _courseLoad     = faker.Random.Double(1, 1000);
            _targetAudience = TargetAudience.Programmer;
            _value          = faker.Random.Double(100, 1000);
        }
        private void DeleteList(string rid)
        {
            TargetAudience ta   = Sitecore.Modules.EmailCampaign.Factory.GetTargetAudience(rid);
            Item           item = ta.InnerItem;

            using (new SecurityDisabler())
            {
                item.Delete();
            }
            NotificationManager.Instance.Notify("RefreshRecipientLists");
            NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("The Recipient List has been deleted."));
            return;
        }
Ejemplo n.º 29
0
        public Course(string name, string description, double hours, TargetAudience targetAudience, double amount)
        {
            BaseValidator.New()
            .When(string.IsNullOrEmpty(name), Resource.InvalidName)
            .When(hours < 1, Resource.InvalidHours)
            .When(amount < 1, Resource.InvalidAmount)
            .TriggersIfExceptionExists();

            Name           = name;
            Description    = description;
            Hours          = hours;
            TargetAudience = targetAudience;
            Amount         = amount;
        }
Ejemplo n.º 30
0
        public Course(string name, string _description, double workLoad, TargetAudience targetAudience, decimal value)
        {
            RuleValidator.New()
            .When(string.IsNullOrEmpty(name), Messages.INVALID_NAME)
            .When(workLoad < 1, Messages.INVALID_WORKLOAD)
            .When(value < 1, Messages.INVALID_VALUE)
            .ThrowExceptionIfExists();

            this.Name           = name;
            this.WorkLoad       = workLoad;
            this.TargetAudience = targetAudience;
            this.Value          = value;
            this.Description    = _description;
        }
 private bool CanBeDeleted(TargetAudience ta)
 {
     Item listItem = ta.InnerItem;
     ItemLink[] referrers = Globals.LinkDatabase.GetReferrers(listItem);
     if (referrers.Count() > 0)
     {
         return false;
     }
     return true;
 }
 public void TestBroadcast()
 {
     string jsonRpcCallId = "x122abcd";
     Messaging.BroadcastRequest request = new Messaging.BroadcastRequest();
     request.BroadcastType = "Events";
     request.Text = "the greatest event of the world";
     Answer answer1 = new Answer();
     answer1.Id = "yes";
     answer1.Caption = "I will attend";
     answer1.Action = null;
     answer1.Type = AnswerType.BUTTON;
     answer1.UiFlags = 1;
     request.Answers.Add(answer1);
     Answer answer2 = new Answer();
     answer2.Id = "no";
     answer2.Caption = "I will not attend";
     answer2.Action = null;
     answer2.Type = AnswerType.BUTTON;
     answer2.UiFlags = 0;
     request.Answers.Add(answer2);
     Answer answer3 = new Answer();
     answer3.Id = "maybe";
     answer3.Caption = "Not sure yet";
     answer3.Action = null;
     answer3.Type = AnswerType.BUTTON;
     answer3.UiFlags = 0;
     request.Answers.Add(answer3);
     request.Flags = 0;
     request.Branding = null;
     request.Tag = "tag_big_event";
     request.AlertFlags = 0;
     request.DismissButtonUiFlags = 0;
     TargetAudience ta = new TargetAudience();
     ta.MinAge = 7;
     ta.MaxAge = 77;
     ta.Gender = "MALE";
     request.TargetAudience = ta;
     Attachment att = new Attachment();
     att.ContentType = "image/png";
     att.DownloadUrl = "http://www.rogerthat.net/wp-content/uploads/2012/09/rogerthat-logo.png";
     att.Name = "Rogerthat logo";
     att.Size = 17458;
     request.Attachments.Add(att);
     Messaging.BroadcastResponse response = this.Api.Broadcast(request, jsonRpcCallId);
     Assert.IsNotNull(response);
 }