private static ContactInformationType BuildContactInformation(Contact contact) { var contactInfo = new ContactInformationType() { id = contact.GetID(), ContactMailingAddress = new AddressType() { Item = new StructuredAddressType() { Items = contact.StreetAdress.Select(x => new StreetType() { StreetFullText = BuildTextType(x) }).ToArray(), LocationCityName = new ProperNameTextType() { Value = contact.City }, LocationPostalCode = BuildTextType(contact.ZipCode), Item1 = new CountryAlpha2CodeType() { Value = contact.Country }, } }, ContactTelephoneNumber = new TelephoneNumberType() { Item = new NANPTelephoneNumberType() { TelephoneAreaCodeID = BuildTextType(contact.AreaCode), TelephoneExchangeID = BuildTextType(contact.ExchangeID), TelephoneLineID = BuildTextType(contact.LineID), } } }; if (!string.IsNullOrEmpty(contact.Email)) { contactInfo.ContactEmailID = BuildTextType(contact.Email); } if (!string.IsNullOrEmpty(contact.State)) { contactInfo.ContactMailingAddress.Item.LocationStateName = new ProperNameTextType() { Value = contact.State }; } if (contact.UsState != null) { contactInfo.ContactMailingAddress.Item.LocationStateUSPostalServiceCode = new USStateCodeType() { Value = contact.UsState.Value }; } return(contactInfo); }
private void RegisterUser(object obj) { var userToRegister = new User { Active = true, Email = Email, FirstName = FirstName, LastName = LastName, Description = "" }; if (Password.Equals(PasswordRepeat)) { _addUserService.AddUser(userToRegister, Password); } else { MessageBox.Show("Lösenorden stämmer inte överrens."); } var savedUser = _userService.FindUserByEmail(userToRegister.Email); UserContactInformation userContactInformationToRegister = CreateUserContactInformation(); savedUser.UserContactInformations.Add(userContactInformationToRegister); var userContactInformationType = savedUser.UserContactInformations.FirstOrDefault().ContactInformationTypes = new List <ContactInformationType>(); ContactInformationType userContactInformationTypeToRegister = CreateContactInformationType(); userContactInformationType.Add(userContactInformationTypeToRegister); var phoneNumberList = userContactInformationToRegister.UserPhoneNumbers = new List <UserPhoneNumber>(); foreach (var number in PhoneNumbers) { phoneNumberList.Add(new UserPhoneNumber() { Active = true, PhoneNumber = number }); } TryToRegisterUserToDatabase(userToRegister); }
/// <summary> /// 获取某联系人的指定消息 /// </summary> /// <returns></returns> public static string GetInformationAcording(Contact contact, ContactInformationType contactInformationType) { string info = string.Empty; try { if (ConversationCodeEnterEntity.lyncClient != null) { info = Convert.ToString(contact.GetContactInformation(contactInformationType)); } } catch (Exception ex) { LogManage.WriteLog(typeof(LyncHelper), ex); } finally { } return(info); }
private byte[] _GetContactImageBytes(Contact contact, ContactInformationType imageType) { if ( contact == null || imageType != ContactInformationType.Photo && imageType != ContactInformationType.IconStream ) { return(new byte[0]); } Stream imgStream = null; try { imgStream = (Stream)contact.GetContactInformation(imageType); } catch { return(new byte[0]); } if (imgStream == null) { return(new byte[0]); } byte[] buffer = new byte[16 * 1024]; using (MemoryStream ms = new MemoryStream()) { int read; while ((read = imgStream.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); } return(ms.ToArray()); } }
private void OnNewAddressReceived(UserAddress address) { var user = _userService.GetAllUsers().FirstOrDefault(x => x.Id == _userId); UserAddresses.Add(address); if (address.BoxNo == 0) { address.BoxNo = null; } var contactInformationType = new ContactInformationType() { Active = true, Type = address.AddressType, Description = address.Description }; user.UserContactInformations.Add(new UserContactInformation() { Active = true, BoxNo = address.BoxNo, City = address.City, ContactInformationTypes = new List <ContactInformationType>() { contactInformationType }, Country = address.Country, Street = address.Street, Zip_Code = address.Zip_Code }); }
/// <summary> /// Method to generate a list of Sources in a ValuesDataSet /// This is done as a separate method since Values can could contain other VariableValue Types /// /// </summary> /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param> /// <returns></returns> public static List <SourceType> datasetSources(ValuesDataSet ds) { /* generate a list * create a distinct DataSet * - new data view * - set filter (no nulls) * - use toTable with unique to get unique list * foreach to generate qualifiers * */ string COLUMN = "SourceID"; string TABLENAME = "sources"; List <SourceType> list = new List <SourceType>(); try { DataView view = new DataView(ds.DataValues); view.RowFilter = COLUMN + " is not Null"; DataTable ids = view.ToTable(TABLENAME, true, new string[] { COLUMN }); foreach (DataRow r in ids.Rows) { try { Object aId = r[COLUMN]; // edit here ValuesDataSet.SourcesRow source = ds.Sources.FindBySourceID((int)aId); if (source != null) { SourceType t = new SourceType(); t.sourceID = source.SourceID; t.sourceIDSpecified = true; if (!String.IsNullOrEmpty(source.Organization)) { t.Organization = source.Organization; } t.SourceDescription = source.SourceDescription; if (!source.IsSourceLinkNull()) { t.SourceLink = source.SourceLink; } // create a contact // only one for now ContactInformationType contact = new ContactInformationType(); contact.TypeOfContact = "main"; if (!String.IsNullOrEmpty(source.ContactName)) { contact.ContactName = source.ContactName; } if (!String.IsNullOrEmpty(source.Email)) { contact.Email = source.Email; } if (!String.IsNullOrEmpty(source.Phone)) { contact.Phone = source.Phone; } StringBuilder address = new StringBuilder(); if (!String.IsNullOrEmpty(source.Address)) { address.Append(source.Address + System.Environment.NewLine); } if (!String.IsNullOrEmpty(source.City) && !String.IsNullOrEmpty(source.State) && !String.IsNullOrEmpty(source.ZipCode)) { address.AppendFormat(",{0}, {1} {2}", source.City, source.State, source.ZipCode); } contact.Address = address.ToString(); //ContactInformationType[] contacts = new ContactInformationType[1]; // contacts[0] = contact; // t.ContactInformation = contacts; t.ContactInformation = contact; list.Add(t); } } catch (Exception e) { log.Error("Error generating a qualifier " + r.ToString() + e.Message); } } return(list); } catch (Exception e) { log.Error("Error generating a qualifiers " + e.Message); // non fatal exceptions return(null); } }
public ContactInformation(ContactInformationType type, string value) { Type = type; Value = value ?? throw new ArgumentNullException(nameof(value)); }
public ContactPersonPrimaryEnumerator(ContactInformationType par) { this.SetSamplerState(0, SamplerStateparent = par; this.SetSamplerState(0, SamplerStatenIndex = -1; }
/// <summary> /// Method to generate a list of Sources in a ValuesDataSet /// This is done as a separate method since Values can could contain other VariableValue Types /// /// </summary> /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param> /// <returns></returns> public static List<SourceType> datasetSources(ValuesDataSet ds, string valuesWhereClause) { /* generate a list * create a distinct DataSet * - new data view * - set filter (no nulls) * - use toTable with unique to get unique list * foreach to generate qualifiers * */ string COLUMN = "SourceID"; string TABLENAME = "sources"; List<SourceType> list = new List<SourceType>(); try { DataView view = new DataView(ds.DataValues); view.RowFilter = valuesWhereClause; DataTable ids = view.ToTable(TABLENAME, true, new string[] {COLUMN}); foreach (DataRow r in ids.Rows) { try { //Object aId = r[COLUMN]; if (r[COLUMN] == DBNull.Value) { continue; } int? aId = Convert.ToInt32(r[COLUMN]); ValuesDataSet.SourcesRow source = ds.Sources.FindBySourceID((int) aId.Value); if (source != null) { SourceType t = new SourceType(); t.sourceID = source.SourceID; t.sourceIDSpecified = true; t.sourceCode = source.SourceID.ToString(); if (!String.IsNullOrEmpty(source.Organization)) t.organization = source.Organization; t.sourceDescription = source.SourceDescription; if (!source.IsSourceLinkNull()) { t.sourceLink = new string[] {source.SourceLink}; } // create a contact // only one for now ContactInformationType contact = new ContactInformationType(); contact.typeOfContact = "main"; if (!String.IsNullOrEmpty(source.ContactName)) contact.contactName = source.ContactName; if (!String.IsNullOrEmpty(source.Email)) { contact.email = new string[] {source.Email}; } if (!String.IsNullOrEmpty(source.Phone)) { contact.phone = new string[] {source.Phone}; } StringBuilder address = new StringBuilder(); if (!String.IsNullOrEmpty(source.Address)) address.Append(source.Address + System.Environment.NewLine); if (!String.IsNullOrEmpty(source.City) && !String.IsNullOrEmpty(source.State) && !String.IsNullOrEmpty(source.ZipCode)) address.AppendFormat(",{0}, {1} {2}", source.City, source.State, source.ZipCode); contact.address = new string[] {address.ToString()}; t.contactInformation = new ContactInformationType[] {contact}; if (!String.IsNullOrEmpty(source.Citation)) { t.citation = source.Citation; } if (source.MetadataID != 0 && source.ISOMetadataRow != null) { MetaDataType m= new MetaDataType(); m.topicCategory = source.ISOMetadataRow.TopicCategory; m.title = source.ISOMetadataRow.Title; m.@abstract = source.ISOMetadataRow.Abstract; m.profileVersion = source.ISOMetadataRow.ProfileVersion; if (!source.ISOMetadataRow.IsMetadataLinkNull()) { m.metadataLink = source.ISOMetadataRow.MetadataLink; } t.metadata = m; } list.Add(t); } } catch (Exception e) { log.Error("Error generating a qualifier " + r.ToString() + e.Message); } } return list; } catch (Exception e) { log.Error("Error generating a qualifiers " + e.Message); // non fatal exceptions return null; } }
/// <summary> /// Method to generate a list of Sources in a ValuesDataSet /// This is done as a separate method since Values can could contain other VariableValue Types /// /// </summary> /// <param name="ds">ValuesDataSet with the values used in the timeSeries</param> /// <returns></returns> public static List <SourceType> datasetSources(ValuesDataSet ds, string valuesWhereClause) { /* generate a list * create a distinct DataSet * - new data view * - set filter (no nulls) * - use toTable with unique to get unique list * foreach to generate qualifiers * */ string COLUMN = "SourceID"; string TABLENAME = "sources"; List <SourceType> list = new List <SourceType>(); try { DataView view = new DataView(ds.DataValues); view.RowFilter = valuesWhereClause; DataTable ids = view.ToTable(TABLENAME, true, new string[] { COLUMN }); foreach (DataRow r in ids.Rows) { try { //Object aId = r[COLUMN]; if (r[COLUMN] == DBNull.Value) { continue; } int?aId = Convert.ToInt32(r[COLUMN]); ValuesDataSet.SourcesRow source = ds.Sources.FindBySourceID((int)aId.Value); if (source != null) { SourceType t = new SourceType(); t.sourceID = source.SourceID; t.sourceIDSpecified = true; t.sourceCode = source.SourceID.ToString(); if (!String.IsNullOrEmpty(source.Organization)) { t.organization = source.Organization; } t.sourceDescription = source.SourceDescription; if (!source.IsSourceLinkNull()) { t.sourceLink = new string[] { source.SourceLink }; } // create a contact // only one for now ContactInformationType contact = new ContactInformationType(); contact.typeOfContact = "main"; if (!String.IsNullOrEmpty(source.ContactName)) { contact.contactName = source.ContactName; } if (!String.IsNullOrEmpty(source.Email)) { contact.email = new string[] { source.Email }; } if (!String.IsNullOrEmpty(source.Phone)) { contact.phone = new string[] { source.Phone }; } StringBuilder address = new StringBuilder(); if (!String.IsNullOrEmpty(source.Address)) { address.Append(source.Address + System.Environment.NewLine); } if (!String.IsNullOrEmpty(source.City) && !String.IsNullOrEmpty(source.State) && !String.IsNullOrEmpty(source.ZipCode)) { address.AppendFormat(",{0}, {1} {2}", source.City, source.State, source.ZipCode); } contact.address = new string[] { address.ToString() }; t.contactInformation = new ContactInformationType[] { contact }; if (!String.IsNullOrEmpty(source.Citation)) { t.citation = source.Citation; } if (source.MetadataID != 0 && source.ISOMetadataRow != null) { MetaDataType m = new MetaDataType(); m.topicCategory = source.ISOMetadataRow.TopicCategory; m.title = source.ISOMetadataRow.Title; m.@abstract = source.ISOMetadataRow.Abstract; m.profileVersion = source.ISOMetadataRow.ProfileVersion; if (!source.ISOMetadataRow.IsMetadataLinkNull()) { m.metadataLink = source.ISOMetadataRow.MetadataLink; } t.metadata = m; } list.Add(t); } } catch (Exception e) { log.Error("Error generating a qualifier " + r.ToString() + e.Message); } } return(list); } catch (Exception e) { log.Error("Error generating a qualifiers " + e.Message); // non fatal exceptions return(null); } }