Esempio n. 1
0
        public static ContactBase AddADRecipientToContacts(UserContext userContext, ADRecipient adRecipient)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (adRecipient == null)
            {
                throw new ArgumentNullException("adRecipient");
            }
            Participant primaryParticipant = ContactUtilities.GetPrimaryParticipant(adRecipient);

            if (primaryParticipant == null)
            {
                return(null);
            }
            if (adRecipient is IADDistributionList)
            {
                DistributionList distributionList = DistributionList.Create(userContext.MailboxSession, userContext.ContactsFolderId);
                distributionList.Add(new Participant(adRecipient));
                distributionList.DisplayName = (string)adRecipient[ADRecipientSchema.DisplayName];
                distributionList.Save(SaveMode.ResolveConflicts);
                return(distributionList);
            }
            Contact contact = Contact.Create(userContext.MailboxSession, userContext.ContactsFolderId);

            ContactUtilities.AddContactProperties(userContext, contact, adRecipient, primaryParticipant);
            contact.Save(SaveMode.ResolveConflicts);
            return(contact);
        }
Esempio n. 2
0
        public DistributionList generateRandomDist(int count)
        {
            var  dists      = new DistributionList();
            var  dist       = new DistributionSummary();
            var  rand       = new Random();
            bool hasDeposit = false;

            for (int i = 0; i < count; i++)
            {
                hasDeposit = rand.Next(1, 10) % 2 == 0;

                dist = new DistributionSummary()
                {
                    OriginalDistributionID = rand.Next(100000, 999999),
                    TargetAgentID          = rand.Next(100, 10000),
                    TargetAgentName        = "Random Branch #" + i,
                    RequestTime            = DateTime.Now.AddMinutes(rand.Next(100, 10000) * -1),
                    Amount          = rand.Next(10, 10000) * 1000,
                    HasDeposit      = hasDeposit,
                    BankName        = hasDeposit ? "Random Bank #" + i : null,
                    AccountNumber   = hasDeposit ? rand.Next(1000000, 9999999).ToString() : null,
                    ReferenceNumber = hasDeposit ? rand.Next(10000, 99999).ToString() : null,
                    DepositComment  = "Deposit comment #" + i
                };
                if (hasDeposit)
                {
                    dist.DepositDate = DateTime.Now.AddMinutes(rand.Next(100, 10000) * -1);
                }

                dists.Add(dist);
            }
            return(dists);
        }
Esempio n. 3
0
        // Token: 0x06002DA8 RID: 11688 RVA: 0x00102654 File Offset: 0x00100854
        private static void AddMembersToDL(DistributionList distributionList, RecipientInfo[] recipients, int validCount)
        {
            int num = 0;

            while (num < recipients.Length && num < validCount)
            {
                Participant participant;
                recipients[num].ToParticipant(out participant);
                distributionList.Add(participant);
                num++;
            }
        }
Esempio n. 4
0
 private void SettingsChangedMethod(object sender, NotifyCollectionChangedEventArgs e)
 {
     //different kind of changes that may have occurred in collection
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         foreach (Setting item in e.NewItems)
         {
             item.PropertyChanged += Setting_PropertyChanged;
             if (item.Scope == Setting.Scopes.DistributionSource.ToString() && item.Key != null)
             {
                 DistributionSourceMap[item.Key] = item.Value;
                 NotifyPropertyChanged("DistributionSourceMap");
             }
             if (item.Scope == Setting.Scopes.DistributionTarget.ToString() && item.Key != null)
             {
                 DistributionList.Add(new DistributionItem()
                 {
                     Folder = item.Key
                 });
                 DistributionTargetMap[item.Key] = item.Value;
                 NotifyPropertyChanged("DistributionTargetMap");
             }
             if (item.Scope == Setting.Scopes.DistributionExe.ToString() && item.Key != null)
             {
                 if (!Executables.Contains(item.Value))
                 {
                     Executables.Add(item.Value);
                 }
                 var distribution = DistributionList.FirstOrDefault(x => x.Folder == item.Key);
                 if (distribution != null)
                 {
                     distribution.Executable = item.Value;
                 }
             }
         }
     }
     if (e.Action == NotifyCollectionChangedAction.Replace)
     {
         foreach (Setting item in e.OldItems)
         {
             item.PropertyChanged -= Setting_PropertyChanged;
         }
         foreach (Setting item in e.NewItems)
         {
             item.PropertyChanged += Setting_PropertyChanged;
         }
     }
     if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         foreach (Setting item in e.OldItems)
         {
             item.PropertyChanged -= Setting_PropertyChanged;
             if (item.Scope == Setting.Scopes.DistributionSource.ToString() && item.Key != null)
             {
                 DistributionSourceMap.Remove(item.Key);
             }
             if (item.Scope == Setting.Scopes.DistributionTarget.ToString() && item.Key != null)
             {
                 DistributionTargetMap.Remove(item.Key);
             }
             if (item.Scope == Setting.Scopes.DistributionExe.ToString() && item.Key != null)
             {
                 var setting = SettingsList.First(x => (x.Scope == item.Scope && x.Value == item.Value));
                 if (setting == null && Executables.Contains(item.Value))
                 {
                     Executables.Remove(item.Value);
                 }
                 var distribution = DistributionList.First(x => x.Folder == item.Key);
                 if (distribution != null)
                 {
                     distribution.Executable = "";
                 }
             }
         }
     }
     if (e.Action == NotifyCollectionChangedAction.Move)
     {
         //your code
     }
 }