示例#1
0
 public Call(Contact contact, ContactPhone contactPhone, DateTime callTime, CallDirection callDirection)
 {
     Contact       = contact;
     ContactPhone  = contactPhone;
     CallTime      = callTime;
     CallDirection = callDirection;
 }
示例#2
0
        private bool ProcessCreateContactPhone(int contactId, int?areaCode, int?phone, int?phoneTypeId)
        {
            try
            {
                var contact = _dbContext.Contacts.FirstOrDefault(x => x.Id == contactId);
                if (contact == null)
                {
                    return(false);
                }

                PhoneType phoneType = null;
                if (phoneTypeId != null)
                {
                    phoneType = _dbContext.PhoneTypes.FirstOrDefault(x => x.Id == phoneTypeId);
                }

                var contactPhone = new ContactPhone()
                {
                    ContactId = contact.Id,
                    AreaCode  = areaCode,
                    Phone     = phone,
                    PhoneType = phoneType
                };

                contact.ContactPhones.Add(contactPhone);
                _dbContext.SaveChangesAsync();
                return(true);
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                throw;
            }
        }
示例#3
0
        /// <summary>
        /// Zrób ramkę z danymi do edycji kontaktu
        /// </summary>
        /// <param name="number"></param>
        /// <param name="comment"></param>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <param name="rid"></param>
        /// <returns></returns>
        public string EditContact(string number, string comment, string name, string id, out string rid)
        {
            XCTIP     packet    = new XCTIP();
            XCTIPSync xCTIPSync = new XCTIPSync();
            XCTIPSyncSendChange_REQ        sendChange_REQ = new XCTIPSyncSendChange_REQ();
            XCTIPSyncRecords_ANSRow        row            = new XCTIPSyncRecords_ANSRow();
            XCTIPSyncRecords_ANSRowContact contact        = new XCTIPSyncRecords_ANSRowContact();
            ContactPhone phone = new ContactPhone();

            sendChange_REQ.CId = id;
            sendChange_REQ.Row = new XCTIPSyncRecords_ANSRow[] { row };
            row.RowType        = "AddField";
            row.Contact        = new XCTIPSyncRecords_ANSRowContact[] { contact };
            //phone.Number = textBox1.Text;
            phone.Number = number;
            //phone.Comment = textBox2.Text;
            phone.Comment = comment;
            phone.PhoneId = "1";
            contact.Phone = new ContactPhone[] { phone };
            //contact.Name = label3.Text;
            contact.Name = name;
            //contact.ContactId = contactId[label3.Text];
            // TODO: fix it
            //contact.ContactId = StaticFields.contactId[id];
            xCTIPSync.SendChange_REQ = new XCTIPSyncSendChange_REQ[] { sendChange_REQ };
            packet.SyncItems         = new XCTIPSync[] { xCTIPSync };
            String xml = ServiceXML.GenericSerialize(packet, true);

            rid = sendChange_REQ.CId;
            return(xml);
        }
示例#4
0
        public string ToString(string format, IFormatProvider provider)
        {
            if (String.IsNullOrEmpty(format))
            {
                format = "D";
            }
            if (provider == null)
            {
                provider = CultureInfo.CurrentCulture;
            }

            switch (format.ToUpperInvariant())
            {
            case "D":
                return($"{Name.ToString(provider)}, {Revenue.ToString("N", provider)}, {ContactPhone}");

            case "P":
                return(ContactPhone.ToString(provider));

            case "N":
                return(Name.ToString(provider));

            case "R":
                return(Revenue.ToString(provider));

            case "NR":
                return($"{Name.ToString(provider)}, {Revenue.ToString("N", provider)}");

            default:
                throw new FormatException(String.Format("The {0} format string is not supported.", format));
            }
        }
示例#5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (registrationDate_ != null)
            {
                hash ^= RegistrationDate.GetHashCode();
            }
            if (CompanyWebsite.Length != 0)
            {
                hash ^= CompanyWebsite.GetHashCode();
            }
            if (ContactPhone.Length != 0)
            {
                hash ^= ContactPhone.GetHashCode();
            }
            if (ContactName.Length != 0)
            {
                hash ^= ContactName.GetHashCode();
            }
            if (CompanyLogo.Length != 0)
            {
                hash ^= CompanyLogo.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#6
0
        public int Insert(ContactPhone contactPhone)
        {
            _context.Add(contactPhone);
            var result = _context.SaveChanges();

            return(result);
        }
示例#7
0
        public override int GetHashCode()
        {
            int hashCode =
                IdVer.GetHashCode() +
                IdSubVer.GetHashCode() +
                Timestamp.GetHashCode() +
                (IdCustomer == null ? 0 : IdCustomer.GetHashCode()) +
                (CustomerName == null ? 0 : CustomerName.GetHashCode()) +
                Active.GetHashCode() +
                (VATNum == null ? 0 : VATNum.GetHashCode()) +
                (ShippingAddress == null ? 0 : ShippingAddress.GetHashCode()) +
                (ShippingAddressZh == null ? 0 : ShippingAddressZh.GetHashCode()) +
                (BillingAddress == null ? 0 : BillingAddress.GetHashCode()) +
                (BillingAddressZh == null ? 0 : BillingAddressZh.GetHashCode()) +
                (ContactName == null ? 0 : ContactName.GetHashCode()) +
                (ContactNameZh == null ? 0 : ContactNameZh.GetHashCode()) +
                (ContactPhone == null ? 0 : ContactPhone.GetHashCode()) +
                (Comments == null ? 0 : Comments.GetHashCode()) +
                (IdIncoterm == null ? 0 : IdIncoterm.GetHashCode()) +
                (IdPaymentTerms == null ? 0 : IdPaymentTerms.GetHashCode()) +
                (IdDefaultCurrency == null ? 0 : IdDefaultCurrency.GetHashCode()) +
                (User == null ? 0 : User.GetHashCode());

            return(hashCode);
        }
示例#8
0
        public Contact CreateContactFromUserInput(TextBox EmailAddress, TextBox PhoneNumber)
        {
            if (EmailAddress.Text.Length == 0 && PhoneNumber.Text.Length == 0)
            {
                NotifyUser("You must enter an email address and/or phone number.", NotifyType.ErrorMessage);
                return(null);
            }

            Contact contact = new Contact();

            // Maximum length for email address is 321, enforced by XAML markup.
            if (EmailAddress.Text.Length > 0)
            {
                ContactEmail email = new ContactEmail()
                {
                    Address = EmailAddress.Text
                };
                contact.Emails.Add(email);
            }

            // Maximum length for phone number is 50, enforced by XAML markup.
            if (PhoneNumber.Text.Length > 0)
            {
                ContactPhone phone = new ContactPhone()
                {
                    Number = PhoneNumber.Text
                };
                contact.Phones.Add(phone);
            }

            return(contact);
        }
示例#9
0
        private void OnTimerEvent(Object source, ElapsedEventArgs e)
        {
            Random        rand          = new Random();
            CallDirection callDirection = rand.NextDouble() > 0.2 ? CallDirection.Incoming : CallDirection.Outgoing;
            DateTime      callTime      = DateTime.Now;
            Contact       contact;
            Call          call;

            double nextDouble = rand.NextDouble();

            if (nextDouble < 0.33)
            {
                contact = new Contact("+380675432523");
                call    = new Call(contact, ContactPhone.Phone1, callTime, callDirection);
            }
            else if (nextDouble < 0.66)
            {
                contact = new Contact("+380631890789", "044556699");
                ContactPhone contactPhone = rand.NextDouble() > 0.4 ? ContactPhone.Phone1 : ContactPhone.Phone2;
                call = new Call(contact, contactPhone, callTime, callDirection);
            }
            else
            {
                contact = new Contact("+380983335768");
                call    = new Call(contact, ContactPhone.Phone1, callTime, callDirection);
            }

            Console.WriteLine(call.GetContactPhone() + " " + callDirection + " " + call.CallTime);

            RaiseCallReceivedEvent(call);
        }
        public Contact CreateContactFromUserInput(TextBox EmailAddress, TextBox PhoneNumber)
        {
            if (EmailAddress.Text.Length == 0 && PhoneNumber.Text.Length == 0)
            {
                NotifyUser("You must enter an email address and/or phone number.", NotifyType.ErrorMessage);
                return null;
            }

            Contact contact = new Contact();

            // Maximum length for email address is 321, enforced by XAML markup.
            if (EmailAddress.Text.Length > 0)
            {
                ContactEmail email = new ContactEmail() { Address = EmailAddress.Text };
                contact.Emails.Add(email);
            }

            // Maximum length for phone number is 50, enforced by XAML markup.
            if (PhoneNumber.Text.Length > 0)
            {
                ContactPhone phone = new ContactPhone() { Number = PhoneNumber.Text };
                contact.Phones.Add(phone);
            }

            return contact;
        }
示例#11
0
        protected override void Execute(CodeActivityContext context)
        {
            // Create a Lead class and populate it with the input arguments
            Lead l = new Lead();

            l.ContactName  = ContactName.Get(context);
            l.ContactPhone = ContactPhone.Get(context);
            l.Interests    = Interests.Get(context);
            l.Comments     = Notes.Get(context);
            l.WorkflowID   = context.WorkflowInstanceId;
            l.Status       = "Open";

            // Get the connection string
            DBExtension ext = context.GetExtension <DBExtension>();

            if (ext == null)
            {
                throw new InvalidProgramException("No connection string available");
            }

            // Insert a record into the Lead table
            LeadDataDataContext dc =
                new LeadDataDataContext(ext.ConnectionString);

            dc.Leads.InsertOnSubmit(l);
            dc.SubmitChanges();

            // Store the request in the OutArgument
            Lead.Set(context, l);
        }
示例#12
0
        /// <summary>
        /// Utility method to convert phone information from the vCard library to a
        /// WinRT ContactPhone instance.
        /// No 1:1 matching is possible between both classes, the method tries to
        /// keep the conversion as accurate as possible.
        /// </summary>
        /// <param name="phone">Phone information from the vCard library.</param>
        /// <returns>The phone information from the vCard library converted to a
        /// WinRT ContactPhone instance.</returns>
        private ContactPhone ConvertVcardToPhone(vCardPhone phone)
        {
            var cp = new ContactPhone
            {
                Number = phone.FullNumber
            };

            if (phone.IsWork)
            {
                cp.Kind = ContactPhoneKind.Work;
            }
            else if (phone.IsCellular)
            {
                cp.Kind = ContactPhoneKind.Mobile;
            }
            else if (phone.IsHome)
            {
                cp.Kind = ContactPhoneKind.Home;
            }
            else
            {
                cp.Kind = ContactPhoneKind.Other;
            }
            return(cp);
        }
示例#13
0
        protected override void Execute(CodeActivityContext context)
        {
            // Create a Lead class and populate it with the input arguments
            Lead l = new Lead();

            l.ContactName  = ContactName.Get(context);
            l.ContactPhone = ContactPhone.Get(context);
            l.Interests    = Interests.Get(context);
            l.Comments     = Notes.Get(context);
            l.WorkflowID   = context.WorkflowInstanceId;
            l.Status       = "Open";

            // Add this to the work queue to be persisted later
            PersistLead persist = context.GetExtension <PersistLead>();

            persist.AddLead(l, "Insert");

            // Store the request in the OutArgument
            Lead.Set(context, l);

            // Add a custom track record
            CustomTrackingRecord userRecord = new CustomTrackingRecord("New Lead")
            {
                Data =
                {
                    { "Name",  l.ContactName  },
                    { "Phone", l.ContactPhone }
                }
            };

            // Emit the custom tracking record
            context.Track(userRecord);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Visible && !IsPostBack)
     {
         SaveContactPhone = ContactPhone.GetPhoneNumbersByContactID(ContactID);
         BuildPhoneList();
     }
 }
 public PhoneResponse ConvertPhoneFromRequest(ContactPhone phone)
 {
     return(new PhoneResponse
     {
         PhoneNumber = phone.PhoneNumber,
         Type = phone.Type
     });
 }
示例#16
0
 private Abstractions.Phone Convert(ContactPhone contactPhone)
 {
     Abstractions.Phone phone = new Abstractions.Phone();
     phone.Number = contactPhone.Number;
     phone.Label  = contactPhone.Description;
     phone.Type   = Convert(contactPhone.Kind);
     return(phone);
 }
示例#17
0
 public ContactPhoneViewControl(ContactPhone contactPhone, Contact contact)
 {
     this.InitializeComponent();
     this.contactPhone     = contactPhone;
     PersonPicture.Contact = contact;
     ContactName.Text      = contact.DisplayName;
     ContactPhone.Text     = contactPhone.Number + " (" + contactPhone.Kind.ToString() + ")";
 }
示例#18
0
        public static ContactPhone UpdatePhone(this ContactPhone basePhone, ContactPhone updatedPhone)
        {
            basePhone.Number      = updatedPhone.Number;
            basePhone.Description = updatedPhone.Description;
            basePhone.IsPrimary   = updatedPhone.IsPrimary;

            return(basePhone);
        }
示例#19
0
        public EnterLead()
        {
            // Define the variables used by this workflow
            Variable <Lead> lead = new Variable <Lead> {
                Name = "lead"
            };

            // Define the SendRequest workflow
            this.Implementation = () => new Sequence
            {
                DisplayName = "EnterLead",
                Variables   = { lead },
                Activities  =
                {
                    new CreateLead
                    {
                        ContactName = new InArgument <string>
                                          (env => ContactName.Get(env)),
                        ContactPhone = new InArgument <string>
                                           (env => ContactPhone.Get(env)),
                        Interests = new InArgument <string>
                                        (env => Interests.Get(env)),
                        Notes            = new InArgument <string>(env => Notes.Get(env)),
                        ConnectionString = new InArgument <string>
                                               (env => ConnectionString.Get(env)),
                        Lead = new OutArgument <Lead>(env => lead.Get(env)),
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead received [" + Rating.Get(env).ToString()
                                   + "]; waiting for assignment"),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    },
                    new InvokeMethod
                    {
                        TargetType = typeof(ApplicationInterface),
                        MethodName = "NewLead",
                        Parameters =
                        {
                            new InArgument <Lead>(env => lead.Get(env))
                        }
                    },
                    new WaitForInput <Lead>
                    {
                        BookmarkName = "GetAssignment",
                        Input        = new OutArgument <Lead>(env => lead.Get(env))
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>
                                   (env => "Lead assigned [" + Rating.Get(env).ToString()
                                   + "] to " + lead.Get(env).AssignedTo),
                        TextWriter = new InArgument <TextWriter> (env => Writer.Get(env))
                    }
                }
            };
        }
        public async Task <ActionResult> DeleteConfirmed(int id, string RedirectUrl)
        {
            ContactPhone contactPhone = await db.ContactPhones.FindAsync(id);

            db.ContactPhones.Remove(contactPhone);
            await db.SaveChangesAsync();

            return(Redirect(RedirectUrl));
        }
示例#21
0
        public IActionResult DeleteContactPhone(int contactId, int phoneId)
        {
            Contact      ct = _unitOfWork.Contacts.GetSingleContactById(contactId);
            ContactPhone cp = ct.ContactPhones.FirstOrDefault(a => a.Id == phoneId);

            _unitOfWork.ContactPhones.DeleteContactPhone(cp);
            _unitOfWork.Complete();
            return(RedirectToAction(nameof(Edit), new { id = contactId }));
        }
示例#22
0
 public static ContactPhoneDto ToDto(this ContactPhone contact)
 {
     return(new()
     {
         ContactId = contact.ContactId,
         Value = contact.Value,
         Type = contact.Type.ToString()
     });
 }
示例#23
0
 private void initEmployee()
 {
     _Services      = new HRManagementService();
     _Person        = new Person();
     _Qualification = new Qualification();
     _Education     = new Education();
     _ContactInfo   = new ContactInfo();
     _ContactPhone  = new ContactPhone();
     _NextOfKin     = new NextOfKin();
 }
        public async Task <ActionResult> Edit([Bind(Include = "ContactPhoneId,PhoneNumber,Type,ContactId")] ContactPhone contactPhone, string RedirectUrl)
        {
            if (ModelState.IsValid)
            {
                db.Entry(contactPhone).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(Redirect(RedirectUrl));
            }
            return(View(contactPhone));
        }
        public static ContactPhone ToContactPhone(this NGPhone phone)
        {
            var winPhone = new ContactPhone()
            {
                Kind        = (ContactPhoneKind)phone.Kind,
                Number      = phone.Number,
                Description = phone.Description
            };

            return(winPhone);
        }
        protected void gvPhone_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            gvPhone.EditIndex = -1;

            ContactPhone phone = ContactPhone.getPhoneByID(Int32.Parse(e.Keys[0].ToString()));

            phone.Delete();

            SaveContactPhone = ContactPhone.GetPhoneNumbersByContactID(ContactID);
            BuildPhoneList();
        }
        public static NGPhone ToNGPhone(this ContactPhone phone)
        {
            var ngPhone = new NGPhone()
            {
                Kind = (NGPhoneKind)phone.Kind,

                Number      = phone.Number,
                Description = phone.Description
            };

            return(ngPhone);
        }
        public async Task <ActionResult> Create([Bind(Include = "ContactPhoneId,PhoneNumber,Type,ContactId")] ContactPhone contactPhone, string RedirectUrl)
        {
            if (ModelState.IsValid)
            {
                db.ContactPhones.Add(contactPhone);
                await db.SaveChangesAsync();

                return(Redirect(RedirectUrl));
            }

            return(View(contactPhone));
        }
        private void AddContact()
        {
            var user = Item as TLUser;

            if (user != null)
            {
                // Create the contact-card
                Contact userContact = new Contact();

                // Check if the user has a normal name
                if (user.FullName != "" || user.FullName != null)
                {
                    if (user.FirstName != null)
                    {
                        userContact.FirstName = user.FirstName;
                    }
                    if (user.LastName != null)
                    {
                        userContact.LastName = user.LastName;
                    }
                }
                // if not, use username
                else if (user.HasUsername != false)
                {
                    if (user.Username != null)
                    {
                        userContact.LastName = user.Username;
                    }
                }
                // if all else fails, use phone number (where possible)
                else if (user.HasPhone != false)
                {
                    if (user.Username != null)
                    {
                        userContact.LastName = user.Phone;
                    }
                }
                // TODO Check why phone numbers are not being shown when the contact is not yet in the users People Hub
                if (user.Phone != null)
                {
                    ContactPhone userPhone = new ContactPhone();
                    userPhone.Number = user.Phone;
                    userContact.Phones.Add(userPhone);
                }

                // Set options for the Dialog-window
                FullContactCardOptions options = new FullContactCardOptions();
                options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.Default;

                // Show the card
                ContactManager.ShowFullContactCard(userContact, options);
            }
        }
示例#30
0
        static public Contact GetContact()
        {
            var adress = new ContactAdress()
            {
                Street      = "Brivibas iela",
                HouseNumber = "132",
                City        = "Riga",
                Type        = AdressType.Home
            };
            var email1 = new ContactEmail()
            {
                Email = "*****@*****.**",
                Type  = EmailType.Work
            };
            var email2 = new ContactEmail()
            {
                Email = "*****@*****.**",
                Type  = EmailType.Work
            };
            var phone = new ContactPhone()
            {
                PhoneNumber = "23156758",
                Type        = PhoneType.Work
            };
            var phone2 = new ContactPhone()
            {
                PhoneNumber = "26784567",
                Type        = PhoneType.MobilePhone
            };
            var adresses = new List <ContactAdress>();
            var emails   = new List <ContactEmail>();
            var phones   = new List <ContactPhone>();

            adresses.Add(adress);
            emails.Add(email1);
            emails.Add(email2);
            phones.Add(phone);
            phones.Add(phone2);
            var contact = new Contact()
            {
                Name        = "John",
                LastName    = "Woodhill",
                Company     = "Latvijas balzams",
                Notes       = "A guy I met in a pub",
                DateOfBirth = "12-8-1974",
                Adresses    = adresses,
                Phones      = phones,
                Emails      = emails
            };

            return(contact);
        }
        protected void gvPhone_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            gvPhone.EditIndex = -1;

            ContactPhone phone = ContactPhone.getPhoneByID(Int32.Parse(e.Keys[0].ToString()));

            phone.PhoneNumber = (String)e.NewValues[0];
            phone.ContactID   = ContactID;
            phone.Save();

            SaveContactPhone = ContactPhone.GetPhoneNumbersByContactID(ContactID);
            BuildPhoneList();
        }
        /// <summary>
        /// This is the click handler for the 'Show contact card' button.  
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShowContactCardButton_Click(object sender, RoutedEventArgs e)
        {
            if ((this.EmailAddress.Text.Length == 0) && (this.PhoneNumber.Text.Length == 0))
            {
                this.rootPage.NotifyUser("You must enter an email address and/or phone number of the contact for the system to search and show the contact card.", NotifyType.ErrorMessage);
            }
            else
            {
                Contact contact = new Contact();
                if (this.EmailAddress.Text.Length > 0)
                {
                    if (this.EmailAddress.Text.Length <= MAX_EMAIL_ADDRESS_LENGTH)
                    {
                        ContactEmail email = new ContactEmail();
                        email.Address = this.EmailAddress.Text;
                        contact.Emails.Add(email);
                    }
                    else
                    {
                        this.rootPage.NotifyUser("The email address you entered is too long.", NotifyType.ErrorMessage);
                        return;
                    }
                }

                if (this.PhoneNumber.Text.Length > 0)
                {
                    if (this.PhoneNumber.Text.Length <= MAX_PHONE_NUMBER_LENGTH)
                    {
                        ContactPhone phone = new ContactPhone();
                        phone.Number = this.PhoneNumber.Text;
                        contact.Phones.Add(phone);
                    }
                    else
                    {
                        this.rootPage.NotifyUser("The phone number you entered is too long.", NotifyType.ErrorMessage);
                        return;
                    }
                }

                // Get the selection rect of the button pressed to show contact card.
                Rect rect = Helper.GetElementRect(sender as FrameworkElement);

                ContactManager.ShowContactCard(contact, rect, Windows.UI.Popups.Placement.Default);
                this.rootPage.NotifyUser("ContactManager.ShowContactCard() was called.", NotifyType.StatusMessage);
            }
        }
        private async Task<Contact> DownloadContactDataAsync(Contact contact)
        {
            // Simulate the download latency by delaying the execution by 2 seconds.
            await Task.Delay(2000);

            if (!DownloadSucceeded.IsChecked.Value)
            {
                return null;
            }

            // Add more data to the contact object.
            ContactEmail workEmail = new ContactEmail();
            workEmail.Address = "*****@*****.**";
            workEmail.Kind = ContactEmailKind.Work;
            contact.Emails.Add(workEmail);

            ContactPhone homePhone = new ContactPhone();
            homePhone.Number = "(444) 555-0101";
            homePhone.Kind = ContactPhoneKind.Home;
            contact.Phones.Add(homePhone);

            ContactPhone workPhone = new ContactPhone();
            workPhone.Number = "(245) 555-0123";
            workPhone.Kind = ContactPhoneKind.Work;
            contact.Phones.Add(workPhone);

            ContactPhone mobilePhone = new ContactPhone();
            mobilePhone.Number = "(921) 555-0187";
            mobilePhone.Kind = ContactPhoneKind.Mobile;
            contact.Phones.Add(mobilePhone);

            ContactAddress address = new ContactAddress();
            address.StreetAddress = "123 Main St";
            address.Locality = "Redmond";
            address.Region = "WA";
            address.Country = "USA";
            address.PostalCode = "00000";
            address.Kind = ContactAddressKind.Home;
            contact.Addresses.Add(address);

            return contact;
        }
示例#34
0
 /// <summary>
 /// Utility method to convert phone information from the vCard library to a
 /// WinRT ContactPhone instance.
 /// No 1:1 matching is possible between both classes, the method tries to
 /// keep the conversion as accurate as possible.
 /// </summary>
 /// <param name="phone">Phone information from the vCard library.</param>
 /// <returns>The phone information from the vCard library converted to a 
 /// WinRT ContactPhone instance.</returns>
 private ContactPhone ConvertVcardToPhone(vCardPhone phone)
 {
     var cp = new ContactPhone
     {
         Number = phone.FullNumber
     };
     if (phone.IsWork)
     {
         cp.Kind = ContactPhoneKind.Work;
     }
     else if (phone.IsCellular)
     {
         cp.Kind = ContactPhoneKind.Mobile;
     }
     else if (phone.IsHome)
     {
         cp.Kind = ContactPhoneKind.Home;
     }
     else
     {
         cp.Kind = ContactPhoneKind.Other;
     }
     return cp;
 }
        /// <summary>
        /// Adds a contact to ContactPickerUI.
        /// </summary>
        /// <param name="sampleContact">Sample contact to add</param>
        private void AddSampleContact(SampleContact sampleContact)
        {
            Contact contact = new Contact();
            contact.Id = sampleContact.Id;
            contact.FirstName = sampleContact.FirstName;
            contact.LastName = sampleContact.LastName;

            if (!string.IsNullOrEmpty(sampleContact.HomeEmail))
            {
                ContactEmail homeEmail = new ContactEmail();
                homeEmail.Address = sampleContact.HomeEmail;
                homeEmail.Kind = ContactEmailKind.Personal;
                contact.Emails.Add(homeEmail);
            }

            if (!string.IsNullOrEmpty(sampleContact.WorkEmail))
            {
                ContactEmail workEmail = new ContactEmail();
                workEmail.Address = sampleContact.WorkEmail;
                workEmail.Kind = ContactEmailKind.Work;
                contact.Emails.Add(workEmail);
            }

            if (!string.IsNullOrEmpty(sampleContact.HomePhone))
            {
                ContactPhone homePhone = new ContactPhone();
                homePhone.Number = sampleContact.HomePhone;
                homePhone.Kind = ContactPhoneKind.Home;
                contact.Phones.Add(homePhone);
            }

            if (!string.IsNullOrEmpty(sampleContact.MobilePhone))
            {
                ContactPhone mobilePhone = new ContactPhone();
                mobilePhone.Number = sampleContact.MobilePhone;
                mobilePhone.Kind = ContactPhoneKind.Mobile;
                contact.Phones.Add(mobilePhone);
            }

            if (!string.IsNullOrEmpty(sampleContact.WorkPhone))
            {
                ContactPhone workPhone = new ContactPhone();
                workPhone.Number = sampleContact.WorkPhone;
                workPhone.Kind = ContactPhoneKind.Work;
                contact.Phones.Add(workPhone);
            }

            switch (this.contactPickerUI.AddContact(contact))
            {
                case AddContactResult.Added:
                    // Notify the user that the contact was added
                    OutputText.Text = contact.DisplayName + " was added to the basket";
                    break;
                case AddContactResult.AlreadyAdded:
                    // Notify the user that the contact is already added
                    OutputText.Text = contact.DisplayName + " is already in the basket";
                    break;
                case AddContactResult.Unavailable:
                default:
                    // Notify the user that the basket is unavailable
                    OutputText.Text = contact.DisplayName + " could not be added to the basket";
                    break;
            }
        }
        private async void CreateTestContacts()
        {
            //
            // Creating two test contacts with email address and phone number.
            //

            Contact contact1 = new Contact();
            contact1.FirstName = "TestContact1";

            ContactEmail email1 = new ContactEmail();
            email1.Address = "*****@*****.**";
            contact1.Emails.Add(email1);

            ContactPhone phone1 = new ContactPhone();
            phone1.Number = "4255550100";
            contact1.Phones.Add(phone1);

            Contact contact2 = new Contact();
            contact2.FirstName = "TestContact2";

            ContactEmail email2 = new ContactEmail();
            email2.Address = "*****@*****.**";
            email2.Kind = ContactEmailKind.Other;
            contact2.Emails.Add(email2);

            ContactPhone phone2 = new ContactPhone();
            phone2.Number = "4255550101";
            phone2.Kind = ContactPhoneKind.Mobile;
            contact2.Phones.Add(phone2);

            // Save the contacts
            ContactList contactList = await _GetContactList();
            if (null == contactList)
            {
                return;
            }

            await contactList.SaveContactAsync(contact1);
            await contactList.SaveContactAsync(contact2);

            //
            // Create annotations for those test contacts.
            // Annotation is the contact meta data that allows People App to generate deep links
            // in the contact card that takes the user back into this app.
            //

            ContactAnnotationList annotationList = await _GetContactAnnotationList();
            if (null == annotationList)
            {
                return;
            }

            ContactAnnotation annotation = new ContactAnnotation();
            annotation.ContactId = contact1.Id;

            // Remote ID: The identifier of the user relevant for this app. When this app is
            // launched into from the People App, this id will be provided as context on which user
            // the operation (e.g. ContactProfile) is for.
            annotation.RemoteId = "user12";

            // The supported operations flags indicate that this app can fulfill these operations
            // for this contact. These flags are read by apps such as the People App to create deep
            // links back into this app. This app must also be registered for the relevant
            // protocols in the Package.appxmanifest (in this case, ms-contact-profile).
            annotation.SupportedOperations = ContactAnnotationOperations.ContactProfile;

            if (!await annotationList.TrySaveAnnotationAsync(annotation))
            {
                rootPage.NotifyUser("Failed to save annotation for TestContact1 to the store.", NotifyType.ErrorMessage);
                return;
            }

            annotation = new ContactAnnotation();
            annotation.ContactId = contact2.Id;
            annotation.RemoteId = "user22";

            // You can also specify multiple supported operations for a contact in a single
            // annotation. In this case, this annotation indicates that the user can be
            // communicated via VOIP call, Video Call, or IM via this application.
            annotation.SupportedOperations = ContactAnnotationOperations.Message |
                ContactAnnotationOperations.AudioCall |
                ContactAnnotationOperations.VideoCall;

            if (!await annotationList.TrySaveAnnotationAsync(annotation))
            {
                rootPage.NotifyUser("Failed to save annotation for TestContact2 to the store.", NotifyType.ErrorMessage);
                return;
            }

            rootPage.NotifyUser("Sample data created successfully.", NotifyType.StatusMessage);
        }
示例#37
0
		public void FillProviderCreatedItem(Microsoft.Communications.Contacts.Contact contact, Microsoft.LiveFX.Client.Contact c)
		{
			if (c == null) return;

			c.Resource.FamilyName = contact.Names[0].FamilyName;
			c.Resource.MiddleName = contact.Names[0].MiddleName;
			c.Resource.GivenName = contact.Names[0].GivenName;

			//foreach (PhoneNumber pn in contact.PhoneNumbers)
			{
				
				if (contact.PhoneNumbers[PhoneLabels.Cellular] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Mobile;
					cp.Value = contact.PhoneNumbers[PhoneLabels.Cellular].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}

				if (contact.PhoneNumbers[PropertyLabels.Personal] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Personal;
					cp.Value = contact.PhoneNumbers[PropertyLabels.Personal].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}
				
				if (contact.PhoneNumbers[PropertyLabels.Business] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Business;
					cp.Value = contact.PhoneNumbers[PropertyLabels.Business].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}
				
				if (contact.PhoneNumbers[PhoneLabels.Fax] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Fax;
					cp.Value = contact.PhoneNumbers[PhoneLabels.Fax].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}

			}

			if (contact.Positions["Business"] != null)
			{
				c.Resource.JobTitle = contact.Positions["Business"].JobTitle;
			}

			
			if (contact.EmailAddresses.Count > 0)
			{
				ContactEmail ce = new ContactEmail();	
				ce.Type = ContactEmail.ContactEmailType.Personal;
				ce.Value = contact.EmailAddresses[0].Address;
				c.Resource.Emails.Add(ce);
			}
			if (contact.EmailAddresses.Count > 1)
			{
				ContactEmail ce = new ContactEmail();
				ce.Type = ContactEmail.ContactEmailType.Personal;
				ce.Value = contact.EmailAddresses[1].Address;
				c.Resource.Emails.Add(ce);
			}
			if (contact.EmailAddresses.Count > 2)
			{
				ContactEmail ce = new ContactEmail();
				ce.Type = ContactEmail.ContactEmailType.Personal;
				ce.Value = contact.EmailAddresses[2].Address;
				c.Resource.Emails.Add(ce);
			}
		}
示例#38
0
        private void BtnWriteBusinessCard_Click(object sender, RoutedEventArgs e)
        {
            var contact = new Contact
            {
                FirstName = "Andreas",
                LastName = "Jakl"
            };
            // Add the personal email address to the Contact object’s emails vector
            var personalEmail = new ContactEmail { Address = "*****@*****.**", Kind = ContactEmailKind.Work };
            contact.Emails.Add(personalEmail);

            // Adds the home phone number to the Contact object’s phones vector
            var homePhone = new ContactPhone { Number = "+1234", Kind = ContactPhoneKind.Home };
            contact.Phones.Add(homePhone);

            // Adds the address to the Contact object’s addresses vector
            var workAddress = new ContactAddress
            {
                StreetAddress = "Street 1",
                Locality = "Vienna",
                Region = "Austria",
                PostalCode = "1234",
                Kind = ContactAddressKind.Work
            };
            contact.Addresses.Add(workAddress);

            contact.Websites.Add(new ContactWebsite { Uri = new Uri("http://www.nfcinteractor.com/") });

            contact.JobInfo.Add(new ContactJobInfo
            {
                CompanyName = "Andreas Jakl",
                Title = "Mobility Evangelist"
            });
            contact.Notes = "Developer of the NFC Library";

            //var record = new NdefVcardRecord(contact);

            //// Publish the record using the proximity device
            //PublishRecord(record, true);
        }