void Validate() { super.Validate(); if (this.SearchQueries == null || this.SearchQueries.Count == 0) { throw new ServiceValidationException(Strings.MailboxQueriesParameterIsNotSpecified); } for (MailboxQuery searchQuery in this.SearchQueries) { if (searchQuery.MailboxSearchScopes == null || searchQuery.MailboxSearchScopes.Length == 0) { throw new ServiceValidationException(Strings.MailboxQueriesParameterIsNotSpecified); } } if (!StringUtils.IsNullOrEmpty(this.SortByProperty)) { PropertyDefinitionBase prop = null; try { prop = ServiceObjectSchema.FindPropertyDefinition(this.SortByProperty); } catch (KeyNotFoundException) { } if (prop == null) { throw new ServiceValidationException(string.Format(Strings.InvalidSortByPropertyForMailboxSearch, this.SortByProperty)); } } }
/// <summary> /// 导出会议到文件 /// </summary> /// <param name="path">目的物理路径</param> /// <param name="count">要导出的数量</param> /// <param name="config"></param> /// <returns>导出结果</returns> public static bool ExportMimeAppointment(string path, int count, ExchangeAdminConfig config) { try { InitializeEws(config); Folder inbox = Folder.Bind(Service, WellKnownFolderName.Calendar); ItemView view = new ItemView(count); view.PropertySet = new PropertySet(BasePropertySet.IdOnly); FindItemsResults <Item> results = inbox.FindItems(view); foreach (var item in results) { PropertyDefinitionBase[] bas = new PropertyDefinitionBase[] { ItemSchema.Id, AppointmentSchema.Start, AppointmentSchema.End, ItemSchema.Subject, ItemSchema.Body, AppointmentSchema.RequiredAttendees, AppointmentSchema.Location, ItemSchema.MimeContent }; PropertySet props = new PropertySet(bas); Appointment email = Appointment.Bind(Service, item.Id, props); string iCalFileName = path + email.Start.ToString("yyyy-MM-dd") + "_" + email.Subject + ".ics"; using (FileStream fs = new FileStream(iCalFileName, FileMode.Create, FileAccess.Write)) { fs.Write(email.MimeContent.Content, 0, email.MimeContent.Content.Length); } } return(true); } catch (Exception) { return(false); throw; } }
/// <summary> /// 获取当前用户指定时间段的会议列表 /// </summary> /// <param name="start">开始时间</param> /// <param name="end">结束时间</param> /// <param name="config"></param> /// <returns>会议列表</returns> public static List <AppointmentProperty> GetAppointment(DateTime start, DateTime end, ExchangeAdminConfig config) { InitializeEws(config); //要返回的会议列表 List <AppointmentProperty> appointments = new List <AppointmentProperty>(); //要获取的时间段 CalendarView cv = new CalendarView(start, end); FindItemsResults <Appointment> aps = Service.FindAppointments(WellKnownFolderName.Calendar, cv); foreach (Appointment ap in aps) { //定义需要的会议属性 PropertyDefinitionBase[] bas = new PropertyDefinitionBase[] { ItemSchema.Id, AppointmentSchema.Start, AppointmentSchema.End, ItemSchema.Subject, ItemSchema.Body, AppointmentSchema.RequiredAttendees, AppointmentSchema.Location }; PropertySet props = new PropertySet(bas); Appointment email = Appointment.Bind(Service, ap.Id, props); AppointmentProperty appointment = new AppointmentProperty(); appointment.Start = email.Start; appointment.End = email.End; appointment.Body = email.Body; appointment.Subject = email.Subject; appointment.Location = email.Location; appointment.Attendees = email.RequiredAttendees.Select(p => p.Address).ToList(); appointment.ID = email.Id; appointments.Add(appointment); } return(appointments); }
private void AddCondition(ref List <SearchFilter> searchFilterCollection, PropertyDefinitionBase oProp, string sValue, string sConditional) { switch (sConditional) { case "ContainsSubstring": searchFilterCollection.Add(new SearchFilter.ContainsSubstring(oProp, sValue)); break; case "IsEqualTo": searchFilterCollection.Add(new SearchFilter.IsEqualTo(oProp, sValue)); break; case "IsGreaterThan": searchFilterCollection.Add(new SearchFilter.IsGreaterThan(oProp, sValue)); break; case "IsGreaterThanOrEqualTo": searchFilterCollection.Add(new SearchFilter.IsGreaterThanOrEqualTo(oProp, sValue)); break; case "IsLessThan": searchFilterCollection.Add(new SearchFilter.IsLessThan(oProp, sValue)); break; case "IsLessThanOrEqualTo": searchFilterCollection.Add(new SearchFilter.IsLessThanOrEqualTo(oProp, sValue)); break; case "IsNotEqualTo": searchFilterCollection.Add(new SearchFilter.IsNotEqualTo(oProp, sValue)); break; } }
public static DialogResult ShowDialog(ServiceObject owner, PropertyDefinitionBase propDef, bool isReadOnly) { PropertyEditorDialog editor = new PropertyEditorDialog(); editor.CurrentProperty = propDef; editor.CurrentServiceObejct = owner; editor.IsReadOnly = isReadOnly; return(editor.ShowDialog()); }
public static DialogResult Show(IWin32Window owner, out PropertyDefinitionBase propDef) { SchemaPropertyDialog spd = new SchemaPropertyDialog(); DialogResult ret = spd.ShowDialog(owner); propDef = spd.propDef; return(ret); }
/// <summary> /// Launch form to get Schema Property information /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void BtnAddSchema_Click(object sender, EventArgs e) { PropertyDefinitionBase prop = null; if (SchemaPropertyDialog.Show(this, out prop) == DialogResult.OK && prop != null) { this.AddPropertyToDisplayTable(prop); } }
private static void HideProperty(PropertyGridControl grid, string propertyName) { PropertyDefinitionBase propertyInstance = grid.PropertyDefinitions.FirstOrDefault(x=> x.Path == propertyName); if(propertyInstance == null){ propertyInstance = new PropertyDefinition() { Path = propertyName, }; grid.PropertyDefinitions.Add(propertyInstance); } propertyInstance.Visibility = System.Windows.Visibility.Collapsed; }
private void LoadSchemaIntoTreeView(Type objType) { TreeNode rootNode = tvwSchemas.Nodes.Add(objType.Name); foreach (FieldInfo fieldInfo in objType.GetFields()) { PropertyDefinitionBase def = (PropertyDefinitionBase)fieldInfo.GetValue(objType); TreeNode newNode = rootNode.Nodes.Add(fieldInfo.Name); newNode.Tag = def; } }
/// <summary> /// Return the type name for the given PropertyDefinitionBase, if an /// ExtendedPropertyDefinition use the same logic in /// GetPropertyType(ExtendedPropertyDefinition). If a PropertyDefinition /// return the type FullName. /// </summary> /// <param name="exPropDef">Property defintion to examine</param> /// <returns> /// FullName of Type for a PropertyDefinition. See the GetPropertyType() /// overloads for ExtendedPropertyDefinition format. /// </returns> public static string GetPropertyType(PropertyDefinitionBase propDef) { ExtendedPropertyDefinition exPropDef = propDef as ExtendedPropertyDefinition; if (exPropDef != null) { return(GetPropertyType(exPropDef)); } return(propDef.GetType().Name); }
public static string GetComments(ServiceObject owner, PropertyDefinitionBase propDef) { ExtendedPropertyDefinition exPropDef = propDef as ExtendedPropertyDefinition; if (exPropDef != null) { return(GetComments(KnownExtendedProperties.Instance().GetKnownExtendedPropertyInfo( exPropDef))); } return(string.Empty); }
private bool IsPropertyDefinitionInList(PropertyDefinitionBase propDef) { foreach (PropertyDefinitionBase item in this.propList) { if (item == propDef) { return(true); } } return(false); }
public static string GetAlternateNames(PropertyDefinitionBase propDef) { ExtendedPropertyDefinition exPropDef = propDef as ExtendedPropertyDefinition; if (exPropDef != null) { return(GetAlternateNames(KnownExtendedProperties.Instance().GetKnownExtendedPropertyInfo( exPropDef))); } return(string.Empty); }
EmailMessage GetEmailMessage(IMailItem model, params PropertyDefinitionBase[] additionalProperties) { if (additionalProperties == null) { additionalProperties = new PropertyDefinitionBase[] { ItemSchema.Attachments, ItemSchema.Body, ItemSchema.Categories, ItemSchema.Flag, ItemSchema.Importance, ItemSchema.ConversationId } } ; PropertySet prop = new PropertySet(BasePropertySet.FirstClassProperties, additionalProperties); return(EmailMessage.Bind(Service, new ItemId(model.UniqueId))); }
private void LoadSchemaIntoTreeView(Type objType) { TreeNode rootNode = tvwSchemas.Nodes.Add(objType.Name); foreach (FieldInfo fieldInfo in objType.GetFields()) { PropertyDefinitionBase def = (PropertyDefinitionBase)fieldInfo.GetValue(objType); TreeNode newNode = rootNode.Nodes.Add(fieldInfo.Name); newNode.Tag = def; if (IsPropertyDefinitionInList(def)) { this.lstProps.Items.Add(new SchemaPropertyListItem(GetListItemName(newNode), (PropertyDefinition)def)); newNode.Remove(); } } }
private void btnOK_Click(object sender, EventArgs e) { if (this.tvwSchemas.SelectedNode != null) { // The form currently does support multiple selections. // If a parent node is selected, warn the user and bail // out of this method. if (this.tvwSchemas.SelectedNode.Nodes.Count > 0) { ErrorDialog.ShowWarning(DisplayStrings.WARN_SELECT_SCHEMA_PROPS); this.DialogResult = DialogResult.Ignore; return; } this.propDef = this.tvwSchemas.SelectedNode.Tag as PropertyDefinitionBase; this.DialogResult = DialogResult.OK; } }
/// <summary> /// Get property information for a schema property or extended property /// using a ServiceObject and a PropertyDefinitionBase. /// </summary> /// <param name="owner">The ServiceObject whose owns the property to interpret.</param> /// <param name="propDef">Property definition used to get type and value information /// from.</param> public PropertyInterpretation(ServiceObject owner, PropertyDefinitionBase propDef) { Name = GetPropertyName(propDef); Value = GetPropertyValue(owner, propDef, out TypeName); SmartView = GetSmartView(owner, propDef); ExtendedPropertyDefinition exPropDef = propDef as ExtendedPropertyDefinition; if (exPropDef != null) { KnownExtendedPropertyInfo?propInfo = KnownExtendedProperties.Instance().GetKnownExtendedPropertyInfo( exPropDef); if (propInfo.HasValue) { AlternateNames = GetAlternateNames(propInfo.Value); Comments = GetComments(propInfo.Value); } } }
/// <summary> /// Return text to describe a PropertyDefinitionBase object, whether a /// PropertyDefinition or ExtendedPropertyDefinition. If a PropertyDefintion /// return the Name. If an ExtendedPropertyDefinition, call use the same /// logic in GetPropertyName(ExtendedPropertyDefintion) /// </summary> /// <param name="exPropDef">Property defintion to examine</param> /// <returns> /// Name for a PropertyDefinition. See the GetPropertyName() overloads /// for ExtendedPropertyDefinition format. /// </returns> public static string GetPropertyName(PropertyDefinitionBase propDefBase) { if (propDefBase == null) { return(null); } ExtendedPropertyDefinition exPropDef; PropertyDefinition propDef; if (null != (exPropDef = propDefBase as ExtendedPropertyDefinition)) { return(GetPropertyName(exPropDef)); } else if (null != (propDef = propDefBase as PropertyDefinition)) { return((propDef as PropertyDefinition).Name); } return(propDefBase.ToString()); }
/// <summary> /// Get text representation of a property value and the property value's type. Some /// property types have specialized logic, if so then dispatch to the appropriate method /// for translation. /// </summary> /// <param name="owner">ServiceObject which is the owner of the property</param> /// <param name="propDef">Definition of the property</param> /// <param name="typeName">Output: The type name of the property value.</param> /// <returns> /// Text representation of a property value and the property value's type. If /// TryGetProperty() fails for this property, no values is returned. /// </returns> public static string GetPropertyValue(ServiceObject owner, PropertyDefinitionBase propDef, out string typeName) { object value = null; typeName = string.Empty; if (owner.TryGetProperty(propDef, out value)) { ExtendedPropertyDefinition extProp = propDef as ExtendedPropertyDefinition; if (extProp != null) { typeName = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}.{1}", extProp.MapiType.GetType().FullName, extProp.MapiType.ToString()); } else { typeName = value.GetType().FullName; } // See if we have any special type interpreters for this type. if (value != null) { ITypeValue interpreter = TypeValueFinder.GetTypeInterpreter(value.GetType()); if (interpreter != null) { return(interpreter.GetValue(value)); } else { // If no interpreters are found, simply return the // ToString() value of the object. return(value.ToString()); } } } return(string.Empty); }
/// <summary> /// Add the given property to the display table. The grid is /// customized as to how it sorts and displays property /// information. /// </summary> /// <param name="prop">Property to be added to the table.</param> private void AddPropertyToDisplayTable(PropertyDefinitionBase prop) { // If there is no property then bail out if (prop == null) { return; } DataRow row = this.propertyDisplayTable.NewRow(); row["PropertyName"] = PropertyInterpretation.GetPropertyName(prop); row["PropertyType"] = PropertyInterpretation.GetPropertyType(prop); row["WellKnownName"] = PropertyInterpretation.GetAlternateNames(prop); row["PropertyDefinitionBase"] = prop; // Don't add the row if it already exists if (!this.propertyDisplayTable.Rows.Contains(row["PropertyName"])) { this.propertyDisplayTable.Rows.Add(row); } }
public static string GetSmartView(ServiceObject owner, PropertyDefinitionBase propDef) { ExtendedPropertyDefinition exPropDef = propDef as ExtendedPropertyDefinition; if (exPropDef != null) { object value = null; if (owner.TryGetProperty(propDef, out value)) { // See if we have any SmartViews for this property. if (value != null) { ISmartView smartView = SmartViewFinder.GetSmartView(exPropDef); if (smartView != null) { return(smartView.GetSmartView(value)); } } } } return(string.Empty); }
public EwsStoreObjectPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, PropertyDefinitionFlags flags, object defaultValue, object initialValue, PropertyDefinitionBase storePropertyDefinition) : this(name, versionAdded, type, flags, defaultValue, initialValue, storePropertyDefinition, null) { }
// Called by Alteryx for an Input tool to request all of the records. public bool PI_PushAllRecords(long nRecordLimit) { // The nRecordLimit parameter specifies the maximum number of records that // should be provided, or -1 for unlimited. If it is -1, set it to // long.MaxValue to make the processing easier later on. Sometimes Alteryx // will call this function with a record limit of 0 just to get the output // record configuration. if (nRecordLimit < 0) { nRecordLimit = long.MaxValue; } m_engineInterface.OutputMessage(m_nToolId, AlteryxRecordInfoNet.MessageStatus.STATUS_Info, nRecordLimit.ToString()); if (m_engineInterface.GetInitVar("UpdateOnly") == "True") { m_engineInterface.OutputMessage(m_nToolId, AlteryxRecordInfoNet.MessageStatus.STATUS_Complete, nRecordLimit.ToString()); } else { // Get the configuration section out of the properties xml that was passed // into PI_Init() and use it to determine the xml file, container element, // and field configuration for our tool. XmlElement configXml = m_xmlProperties.SelectSingleNode("Configuration") as XmlElement; XmlInputConfiguration xmlConfig = XmlInputConfiguration.LoadFromConfiguration(configXml); if (xmlConfig == null) { throw new ApplicationException("Invalid configuration. Ensure that the input file is set correctly."); } if (xmlConfig.Fields.Count == 0) { throw new ApplicationException("There are no fields. Make sure your container element is set properly."); } // Create a new RecordInfo object to describe our outgoing message records and // configure it based on the field information in our saved configuration. AlteryxRecordInfoNet.RecordInfo recordInfoOut = new AlteryxRecordInfoNet.RecordInfo(); foreach (XmlInputField field in xmlConfig.Fields) { // For each field in our configuration, add it to our RecordInfo object. recordInfoOut.AddField(field.Name, field.FieldType, field.Size, field.Scale, "", ""); } // Use the new RecordInfo object to initialize the PluginOutputConnectionHelper. // The PluginOutputConnectionHelper can't be used until this step is performed. m_outputHelper.Init(recordInfoOut, "Message Output", null, m_xmlProperties); // Create a Record object to hold the data for each outgoing message record. AlteryxRecordInfoNet.Record recordOut = recordInfoOut.CreateRecord(); // Create a new RecordInfo object to describe our outgoing attachment records and // configure it based on the field information in our saved configuration. AlteryxRecordInfoNet.RecordInfo recordInfoOut_AttachmentPaths = new AlteryxRecordInfoNet.RecordInfo(); // For each field in our configuration, add it to our RecordInfo object. recordInfoOut_AttachmentPaths.AddField("Id", AlteryxRecordInfoNet.FieldType.E_FT_String, 4000, 0, "", ""); recordInfoOut_AttachmentPaths.AddField("AttachmentPath", AlteryxRecordInfoNet.FieldType.E_FT_String, 4000, 0, "", ""); // Use the new RecordInfo object to initialize the PluginOutputConnectionHelper. // The PluginOutputConnectionHelper can't be used until this step is performed. m_attachmentOutputHelper.Init(recordInfoOut_AttachmentPaths, "Attachment Output", null, m_xmlProperties); // Create a Record object to hold the data for each outgoing attachment record. AlteryxRecordInfoNet.Record recordOut_AttachmentPaths = recordInfoOut_AttachmentPaths.CreateRecord(); // Define the necessary PropertyDefinitionBase objects for each field in the XML configuration document. PropertyDefinitionBase[] propertyDefinitionBase = new PropertyDefinitionBase[xmlConfig.Fields.Count]; for (int i = 0; i < xmlConfig.Fields.Count; i++) { if ((WellKnownFolderName)xmlConfig.Folder == WellKnownFolderName.Calendar && typeof(AppointmentSchema).GetField(xmlConfig.Fields[i].Name) != null) { propertyDefinitionBase[i] = (PropertyDefinitionBase)typeof(AppointmentSchema).GetField(xmlConfig.Fields[i].Name).GetValue(null); } else if ((WellKnownFolderName)xmlConfig.Folder == WellKnownFolderName.Inbox && typeof(EmailMessageSchema).GetField(xmlConfig.Fields[i].Name) != null) { propertyDefinitionBase[i] = (PropertyDefinitionBase)typeof(EmailMessageSchema).GetField(xmlConfig.Fields[i].Name).GetValue(null); } else if ((WellKnownFolderName)xmlConfig.Folder == WellKnownFolderName.Tasks && typeof(TaskSchema).GetField(xmlConfig.Fields[i].Name) != null) { propertyDefinitionBase[i] = (PropertyDefinitionBase)typeof(TaskSchema).GetField(xmlConfig.Fields[i].Name).GetValue(null); } else { propertyDefinitionBase[i] = (PropertyDefinitionBase)typeof(ItemSchema).GetField(xmlConfig.Fields[i].Name).GetValue(null); } } // Assign the configuration settings and field list to the OutlookEmail object. OutlookEmail email = new OutlookEmail() { UserName = xmlConfig.UserName, Password = xmlConfig.Password, ExchangeServerVersion = xmlConfig.ExchangeVersion, UseManualServiceURL = xmlConfig.UseManualServiceURL, ServiceURL = xmlConfig.ServiceURL, UseDifferentMailbox = xmlConfig.UseDifferentMailbox, Mailbox = xmlConfig.Mailbox, Folder = (WellKnownFolderName)xmlConfig.Folder, IncludeRecurringEvents = xmlConfig.IncludeRecurringEvents, StartDate = xmlConfig.StartDate, EndDate = xmlConfig.EndDate, AttachmentPath = xmlConfig.AttachmentPath, QueryString = xmlConfig.QueryString, IncludeSubFolders = xmlConfig.IncludeSubFolders, SubFolderName = xmlConfig.SubFolderName, SkipRootFolder = xmlConfig.SkipRootFolder, UseUniqueFileName = xmlConfig.UseUniqueFileName, AttachmentFilter = xmlConfig.AttachmentFilter }; email.Fields = new PropertySet(propertyDefinitionBase); // Get the list of items (this includes attachments if the Attachment field was selected for output). List <OItem> oItems = email.GetItems(nRecordLimit); // We will need to send status updates to Alteryx at regular intervals during // this process, so we'll do that based on an elapsed time. DateTime last = DateTime.Now; // We need to keep track of how many records we have processed. long nRecords = 0; // Process the data in each message object. foreach (var oItem in oItems) { // If we've exceeded the record limit, stop processing. if (nRecords >= nRecordLimit) { break; } // Reset our output record so we can reuse it. This is better than // creating a new Record in each iteration as these objects can get large. recordOut.Reset(); // For each field, load the data from the corresponding element into the Record. foreach (XmlInputField field in xmlConfig.Fields) { // Get the FieldBase from the RecordInfo for the field. AlteryxRecordInfoNet.FieldBase fieldBase = recordInfoOut.GetFieldByName(field.Name, false); if (fieldBase != null) { // Find the element within the container element that has the same name as the field. var value = Convert.ToString(oItem.Item.GetType().GetProperty(field.Name).GetValue(oItem.Item, null)); if (value == null) { // If the field element doesn't exist, set the output field's value to null. fieldBase.SetNull(recordOut); } else { // Otherwise, set the output field's value based on the element's inner text. fieldBase.SetFromString(recordOut, value); } } } // Return message attachments if applicable. if (!string.IsNullOrWhiteSpace(xmlConfig.AttachmentPath)) { foreach (var attachment in oItem.Attachments) { // Reset our output record so we can reuse it. This is better than // creating a new Record in each iteration as these objects can get large. recordOut_AttachmentPaths.Reset(); // Get the FieldBase from the RecordInfo for the ID field. AlteryxRecordInfoNet.FieldBase fieldBase_ID = recordInfoOut_AttachmentPaths.GetFieldByName("ID", false); if (fieldBase_ID != null) { fieldBase_ID.SetFromString(recordOut_AttachmentPaths, oItem.Item.Id.ToString()); } // Get the FieldBase from the RecordInfo for the AttachmentPath field. AlteryxRecordInfoNet.FieldBase fieldBase_AttachmentPath = recordInfoOut_AttachmentPaths.GetFieldByName("AttachmentPath", false); if (fieldBase_AttachmentPath != null) { fieldBase_AttachmentPath.SetFromString(recordOut_AttachmentPaths, attachment.AttachmentPath); } // Send the record to the downstream tools through the PluginOutputConnectionHelper. m_attachmentOutputHelper.PushRecord(recordOut_AttachmentPaths.GetRecord()); } } // Send the record to the downstream tools through the PluginOutputConnectionHelper. m_outputHelper.PushRecord(recordOut.GetRecord()); // If at least 1 second has passed since we started or our last update, update progress. if (DateTime.Now.Subtract(last).TotalSeconds >= 1) { // Determine the percent complete: (Records Processed) / Min(RecordLimit, # of Container Elements) double percentComplete = (double)nRecords / Math.Min(nRecordLimit, oItems.Count); // Output the progress if (m_engineInterface.OutputToolProgress(m_nToolId, percentComplete) != 0) { // If this returns anything but 0, then the user has canceled the operation. throw new AlteryxRecordInfoNet.UserCanceledException(); } // Have the PluginOutputConnectionHelper ask the downstream tools to update their progress. m_outputHelper.UpdateProgress(percentComplete); // Reset the timer. last = DateTime.Now; } // Have the PluginOutputConnectionHelper update the record count display in Alteryx. // The PluginOutputConnectionHelper will actually only do this if enough time and data has elapsed, // so it's ok to call this in every iteration. m_outputHelper.OutputRecordCount(false); // Update our record count. nRecords++; } // If we weren't just getting the output config, send a status message to Alterys that // will display the number of records that we output. if (nRecordLimit > 0) { m_engineInterface.OutputMessage(m_nToolId, AlteryxRecordInfoNet.MessageStatus.STATUS_Info, nRecords.ToString() + " records read from " + xmlConfig.UserName); } // Tell Alteryx that we are done sending data so that it can close the connections to our plugin. m_engineInterface.OutputMessage(m_nToolId, AlteryxRecordInfoNet.MessageStatus.STATUS_Complete, ""); } // Close our ouput connections. m_outputHelper.Close(); m_attachmentOutputHelper.Close(); // Return true to indicate that we successfully processed our data. return(true); }
/// <summary> /// Write the contacts into the CSV file. /// </summary> public static void WriteContacts(StreamWriter writer, PropertyDefinitionBase proerty, Contact contact) { if (proerty.Equals(ContactSchema.Surname)) { if (!String.IsNullOrWhiteSpace(contact.Surname)) { writer.Write("\"{0}\"", contact.Surname); } } else if (proerty.Equals(ContactSchema.GivenName)) { if (!String.IsNullOrWhiteSpace(contact.GivenName)) { writer.Write("\"{0}\"", contact.GivenName); } } else if (proerty.Equals(ContactSchema.CompanyName)) { if (!String.IsNullOrWhiteSpace(contact.CompanyName)) { writer.Write("\"{0}\"", contact.CompanyName); } } else if (proerty.Equals(ContactSchema.Department)) { if (!String.IsNullOrWhiteSpace(contact.Department)) { writer.Write("\"{0}\"", contact.Department); } } else if (proerty.Equals(ContactSchema.JobTitle)) { if (!String.IsNullOrWhiteSpace(contact.JobTitle)) { writer.Write("\"{0}\"", contact.JobTitle); } } else if (proerty.Equals(ContactSchema.BusinessPhone)) { if (contact.PhoneNumbers.Contains(PhoneNumberKey.BusinessPhone)) { if (!String.IsNullOrWhiteSpace(contact.PhoneNumbers[PhoneNumberKey.BusinessPhone])) { writer.Write("\"{0}\"", contact.PhoneNumbers[PhoneNumberKey.BusinessPhone]); } } } else if (proerty.Equals(ContactSchema.HomePhone)) { if (contact.PhoneNumbers.Contains(PhoneNumberKey.HomePhone)) { if (!String.IsNullOrWhiteSpace(contact.PhoneNumbers[PhoneNumberKey.HomePhone])) { writer.Write("\"{0}\"", contact.PhoneNumbers[PhoneNumberKey.HomePhone]); } } } else if (proerty.Equals(ContactSchema.MobilePhone)) { if (contact.PhoneNumbers.Contains(PhoneNumberKey.MobilePhone)) { if (!String.IsNullOrWhiteSpace(contact.PhoneNumbers[PhoneNumberKey.MobilePhone])) { writer.Write("\"{0}\"", contact.PhoneNumbers[PhoneNumberKey.MobilePhone]); } } } else if (proerty.Equals(ContactSchema.BusinessAddressStreet)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Business)) { if (!String.IsNullOrWhiteSpace(contact.PhysicalAddresses[PhysicalAddressKey.Business].Street)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Business].Street); } } } else if (proerty.Equals(ContactSchema.BusinessAddressCity)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Business)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Business].City); } } else if (proerty.Equals(ContactSchema.BusinessAddressState)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Business)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Business].State); } } else if (proerty.Equals(ContactSchema.BusinessAddressPostalCode)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Business)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Business].PostalCode); } } else if (proerty.Equals(ContactSchema.BusinessAddressCountryOrRegion)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Business)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Business].CountryOrRegion); } } else if (proerty.Equals(ContactSchema.HomeAddressStreet)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Home)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Home].Street); } } else if (proerty.Equals(ContactSchema.HomeAddressCity)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Home)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Home].City); } } else if (proerty.Equals(ContactSchema.HomeAddressState)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Home)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Home].State); } } else if (proerty.Equals(ContactSchema.HomeAddressPostalCode)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Home)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Home].PostalCode); } } else if (proerty.Equals(ContactSchema.HomeAddressCountryOrRegion)) { if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Home)) { writer.Write("\"{0}\"", contact.PhysicalAddresses[PhysicalAddressKey.Home].CountryOrRegion); } } else if (proerty.Equals(ContactSchema.EmailAddress1)) { if (contact.EmailAddresses.Contains(EmailAddressKey.EmailAddress1)) { writer.Write("\"{0}\"", contact.EmailAddresses[EmailAddressKey.EmailAddress1].Address); } } }
private void btnAddPropertiesFromCsv_Click(object sender, EventArgs e) { PropertySetDialogAddFromCSV oForm = new PropertySetDialogAddFromCSV(); oForm.ShowDialog(); if (oForm.ClickedOK == true) { PropertyDefinitionBase oPD = null; //bool bNamedProp = false; foreach (AdditionalPropertyDefinition o in oForm.APD) { MapiPropertyType oMapiPropertyType = MapiPropertyType.String; AdditionalProperties.GetMapiPropertyTypeFromString(o.PropertyType, ref oMapiPropertyType); if (o.PropertyIdIsString == true) { oPD = (PropertyDefinitionBase) new ExtendedPropertyDefinition( new Guid(o.PropertySetId), o.PropertySetIdString, oMapiPropertyType); } else { if (o.PropertySetId != "") { oPD = (PropertyDefinitionBase) new ExtendedPropertyDefinition( new Guid(o.PropertySetId), o.PropertyId, oMapiPropertyType); } else { oPD = (PropertyDefinitionBase) new ExtendedPropertyDefinition( o.PropertyId, oMapiPropertyType); } } AddPropertyToDisplayTable(oPD); //DataRow row = this.propertyDisplayTable.NewRow(); //row["PropertyName"] = o.PropertyName; //row["PropertyType"] = o.PropertyType; //row["WellKnownName"] = o.PropertyName; //row["PropertyDefinitionBase"] = o.PropertyDefinitionType; //// Don't add the row if it already exists //if (!this.propertyDisplayTable.Rows.Contains(row["PropertyName"])) //{ // this.propertyDisplayTable.Rows.Add(row); //} //AddPropertyToDisplayTable(PropertyDefinitionBase prop) } } }
public EwsStoreObjectPropertyDefinition(string name, ExchangeObjectVersion versionAdded, Type type, PropertyDefinitionFlags flags, object defaultValue, object initialValue, PropertyDefinitionBase storePropertyDefinition, Action <Item, object> itemPropertySetter) : base(name, versionAdded ?? EwsHelper.EwsVersionToExchangeObjectVersion(storePropertyDefinition.Version), type, flags, defaultValue, initialValue) { if (storePropertyDefinition == null) { throw new ArgumentNullException("storePropertyDefinition"); } if (storePropertyDefinition is PropertyDefinition) { if (itemPropertySetter == null && !this.IsReadOnly && storePropertyDefinition != ItemSchema.Attachments) { throw new ArgumentException("ItemPropertySetter must be provided for writable first class property."); } } else if (storePropertyDefinition is ExtendedPropertyDefinition && itemPropertySetter != null) { throw new ArgumentException("ItemPropertySetter shouldn't be provided for extended property."); } this.storePropertyDefinition = storePropertyDefinition; this.ItemPropertySetter = itemPropertySetter; }