private bool Reload(Picklist <FeedItem> parent) { if (selectedFeed != null) { selectedFeed.Load(true); var articleListHeader = _mainView.Controls.FirstOrDefault(x => x.GetType() == typeof(Header)) as Header; if (articleListHeader != null) { articleListHeader.DisplayText = selectedFeed.FormatLine(headerFormat); articleListHeader.Refresh(); } var items = selectedFeed.FeedItems .OrderByDescending(x => x.PublishDate) .Where(x => x.Deleted == false) .Select((item, index) => { item.Index = index; item.DisplayText = item.DisplayLine; return(item); } ); parent.UpdateList(items); parent.Refresh(); if (articleListHeader != null) { articleListHeader.DisplayText = selectedFeed.FormatLine(headerFormat); articleListHeader.Refresh(); } } return(true); }
/// <summary> /// Purges articles marked for deletion in selected <see cref="RssFeed"/>. /// </summary> /// <param name="parent"></param> /// <returns></returns> private bool PurgeDeletedArticles(Picklist <RssFeed> parent) { Dictionary <string, object> choices = new Dictionary <string, object> { { Config.Global.UI.Strings.PromptAnswerYes, 1 }, { Config.Global.UI.Strings.PromptAnswerNo, 2 } }; var dialog = new Dialog(Config.Global.UI.Strings.PromptPurge, choices); dialog.ItemSelected += Purge_ItemSelected; dialog.Show(); _mainView?.Refresh(); if (purge) { foreach (var feed in parent.ListItems.Where(x => !x.IsDynamic)) { if (!feed.IsProcessing) { feed.Purge(); } } purge = false; } return(true); }
internal void Create(string tenantCode, Picklist picklist) { try { var cmd = CreateProcedureCommand("dbo.Picklist_Create"); cmd.AppendXSmallText("@strTenantCode", tenantCode); cmd.AppendSmallInt("@intId", picklist.Id); cmd.AppendSmallText("@strName", picklist.Name); cmd.AppendBit("@bitIsStandard", picklist.IsStandard); if (picklist.EntityId > 0) { cmd.AppendSmallInt("@intEntityId", picklist.EntityId); } cmd.AppendBit("@bitFixedValueList", picklist.FixedValueList); cmd.AppendBit("@bitCustomizeValue", picklist.CustomizeValue); cmd.AppendBit("@bitIsKeyValueType", picklist.IsKeyValueType); cmd.AppendBit("@bitActive", picklist.Active); cmd.AppendBit("@bitIsDeletetd", picklist.IsDeleteted); cmd.AppendGuid("@guidUpdatedBy", picklist.UpdatedBy); SqlParameter retvalue = cmd.AppendInt("@intReturn"); ExecuteCommand(cmd); if ((int)retvalue.Value == 1) { throw new VPCException(DbErrorCode.Duplicate); } } catch (SqlException e) { _log.Error(e); throw ReportAndTranslateException(e, "Picklist::Create"); } }
internal bool Update(string tenantCode, short id, Picklist picklist) { try { var cmd = CreateProcedureCommand("dbo.Picklist_Update"); cmd.AppendXSmallText("@strTenantCode", tenantCode); cmd.AppendSmallInt("@intId", id); cmd.AppendSmallText("@strName", picklist.Name); cmd.AppendBit("@bitIsStandard", picklist.IsStandard); if (picklist.EntityId > 0) { cmd.AppendSmallInt("@intEntityId", picklist.EntityId); } cmd.AppendBit("@bitFixedValueList", picklist.FixedValueList); cmd.AppendBit("@bitCustomizeValue", picklist.CustomizeValue); cmd.AppendBit("@bitIsKeyValueType", picklist.IsKeyValueType); cmd.AppendBit("@bitActive", picklist.Active); cmd.AppendBit("@bitIsDeletetd", picklist.IsDeleteted); cmd.AppendGuid("@guidUpdatedBy", picklist.UpdatedBy); ExecuteCommand(cmd); return(true); } catch (SqlException e) { _log.Error(e); throw ReportAndTranslateException(e, "Picklist::Update"); } }
internal Picklist GetById(string tenantCode, short id) { var picklist = new Picklist(); try { var cmd = CreateProcedureCommand("dbo.Picklist_GetBy_Id"); cmd.AppendXSmallText("@strTenantCode", tenantCode); cmd.AppendSmallInt("@intId", id); using (var reader = ExecuteCommandAndReturnReader(cmd)) { while (reader.Read()) { picklist.Id = (short)(reader.IsDBNull(0) ? 0 : reader.GetInt16(0)); picklist.Name = reader.IsDBNull(1) ? string.Empty : reader.GetString(1); picklist.IsStandard = !reader.IsDBNull(2) && reader.GetBoolean(2); picklist.EntityId = (short)(reader.IsDBNull(3) ? 0 : reader.GetInt16(3)); picklist.FixedValueList = !reader.IsDBNull(4) && reader.GetBoolean(4); picklist.CustomizeValue = !reader.IsDBNull(5) && reader.GetBoolean(5); picklist.IsKeyValueType = !reader.IsDBNull(6) && reader.GetBoolean(6); picklist.Active = !reader.IsDBNull(7) && reader.GetBoolean(7); picklist.IsDeleteted = !reader.IsDBNull(8) && reader.GetBoolean(8); picklist.UpdatedBy = reader.IsDBNull(9) ? Guid.Empty : reader.GetGuid(9); picklist.UpdatedDate = reader.IsDBNull(10) ? DateTime.MinValue : reader.GetDateTime(10); } } } catch (SqlException e) { throw ReportAndTranslateException(e, "Picklist::GetById"); } return(picklist); }
public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] SelectedPickListDTO picklist) { if (!ModelState.IsValid) { return(request.CreateResponse(HttpStatusCode.BadRequest, picklist)); } try { var newPickList = new Picklist { QuoteId = picklist.QuoteId, DispatchDate = picklist.DipatchDate, DeliveryAddress = picklist.DeliveryAddress, DeliveryNeeded = picklist.DeliveryNeeded, IsPicked = picklist.IsPicked, IsPacked = picklist.IsPacked, IsDelivered = picklist.IsPacked, Comment = picklist.Comment, EstimatedDelivery = picklist.EsimatedDelivery, Active = true //Default to true as initial save }; db.Picklists.Add(newPickList); db.SaveChanges(); db.Entry(newPickList).Reload(); var pickListId = newPickList.PicklistId; foreach (var plant in picklist.PickListPlants) { var thisPlant = new PlantsForPicklist { PicklistId = pickListId, PlantForQuoteId = plant.PlantForQuoteId, PlantName = plant.PlantName, FormSize = plant.FormSize, QuantityToPick = plant.QuantityToPick, SubbedFor = plant.SubbedFor, isSubbed = plant.IsSubbed, DispatchLocation = plant.DispatchLocation, Active = true }; db.PlantsForPicklists.Add(thisPlant); } db.SaveChanges(); return(request.CreateResponse(HttpStatusCode.OK, picklist)); } catch (Exception ex) { return(request.CreateResponse(HttpStatusCode.BadRequest, ex)); } }
// Field Value /// <summary> /// Returns the string property value /// </summary> /// <param name="dynamicEntityInstance">Entity</param> /// <param name="entityPropertyLogicalName">Attribute name</param> /// <returns>Attribute Value(String)</returns> public static string GetPropertyValue(this DynamicEntity dynamicEntityInstance, string entityPropertyLogicalName) { string returnValue = ""; string propertyType = null; try { propertyType = dynamicEntityInstance.Properties[entityPropertyLogicalName].GetType().ToString(); } catch (Exception e) { propertyType = e.Message; returnValue = e.Message; return(null); } if (propertyType == "Microsoft.Crm.Sdk.Owner") { Owner ownerType = (Owner)dynamicEntityInstance[entityPropertyLogicalName]; return(ownerType.name); } else if (propertyType == "Microsoft.Crm.Sdk.Customer") { Customer customerType = (Customer)dynamicEntityInstance[entityPropertyLogicalName]; return(customerType.name); } else if (propertyType == "Microsoft.Crm.Sdk.CrmDateTime") { CrmDateTimeProperty crmDataTimeType = new CrmDateTimeProperty(entityPropertyLogicalName, (CrmDateTime)dynamicEntityInstance.Properties[entityPropertyLogicalName]); return(crmDataTimeType.Value.date); } else if (propertyType == "Microsoft.Crm.Sdk.CrmBoolean") { CrmBooleanProperty crmBooleanProperty = new CrmBooleanProperty(entityPropertyLogicalName, (CrmBoolean)dynamicEntityInstance.Properties[entityPropertyLogicalName]); returnValue = crmBooleanProperty.Value.Value.ToString(); } else if (propertyType == "System.String") { return(dynamicEntityInstance.Properties[entityPropertyLogicalName].ToString()); } else if (propertyType == "Microsoft.Crm.Sdk.Lookup") { Lookup lookupType = (Lookup)dynamicEntityInstance[entityPropertyLogicalName]; return(lookupType.name); } else if (propertyType == "Microsoft.Crm.Sdk.Picklist") { Picklist picklistType = (Picklist)dynamicEntityInstance[entityPropertyLogicalName]; return(picklistType.name); } return(returnValue); }
public void FillList <T>([NotNull] object control, [NotNull] IEnumerable <T> list, [NotNull] Expression <Func <T, object> > expression) where T : IComparable { var picklist = new Picklist <T>(list); picklist.DisplayMember = ReflectionHelper.GetProperty(expression).Name; var element = (IListElement)FindElementForControl(control); Assert.NotNull(element, "element not found for {0}", control); element.FillWithList(picklist); }
private bool OpenArticle(FeedItem selectedItem, Picklist <FeedItem> parent) { parent.IsDisplayed = false; parent.Clear(); while (selectedItem != null) { using (ArticleView article = new ArticleView(Config.Global.UI.Layout.Article)) { article.NextArticle = selectedItem; article.Show(selectedFeed, parent); selectedItem = article.NextArticle; } _mainView.Refresh(); } return(true); }
public void FillList <T>([NotNull] object control, [NotNull] IEnumerable <T> list, [NotNull] string propertyName) where T : IComparable { Assert.ArgumentNotNullOrEmpty(propertyName, nameof(propertyName)); var picklist = new Picklist <T>(list); picklist.DisplayMember = ReflectionUtils.GetProperty <T>(propertyName).Name; var element = (IListElement)FindElementForControl(control); Assert.NotNull(element, "element not found"); element.FillWithList(picklist); }
/// <summary> /// Shows selected feed articles /// </summary> /// <param name="selectedItem">Selected <see cref="RssFeed"/> item</param> /// <param name="parent">Parent <see cref="Picklist{RssFeed}"/></param> /// <returns></returns> private bool OpenSelectedFeed(RssFeed selectedItem, Picklist <RssFeed> parent) { if (selectedItem != null) { if (!selectedItem.IsProcessing) { parent.IsDisplayed = false; using (ArticleListView articleList = new ArticleListView(Config.Global.UI.Layout.ArticleList)) { articleList.Show(selectedItem); } _mainView.Refresh(); } } return(true); }
/// <summary> /// Reloads all feeds /// </summary> /// <param name="parent">The parent <see cref="Picklist{RssFeed}"/></param> /// <param name="online">Should it download feed? <see cref="bool"/></param> private void ReloadAll(Picklist <RssFeed> parent, bool online) { new Thread(() => { Thread.CurrentThread.IsBackground = true; /* first load online feeds */ Parallel.ForEach(parent.ListItems.Where(i => ((RssFeed)i).IsDynamic == false), (item) => { ReloadOne(item, online); }); /* then load dynamic feeds */ Parallel.ForEach(parent.ListItems.Where(i => ((RssFeed)i)?.IsDynamic == true), (item) => { ((RssFeed)item).Load(false); }); }).Start(); }
internal List <Picklist> GetAll(string tenantCode, PicklistQuery query) { var lstPicklists = new List <Picklist>(); try { var cmd = CreateProcedureCommand("dbo.Picklist_GetAll"); cmd.AppendXSmallText("@strTenantCode", tenantCode); cmd.AppendInt("@intPageNumber", query.PagingParameters.PageNumber); cmd.AppendInt("@intPageSize", query.PagingParameters.PageSize); if (!string.IsNullOrEmpty(query.SearchText)) { cmd.AppendSmallText("@strSearchText", query.SearchText); } cmd.AppendBit("@bitIsdeleted", query.IsDeleted); using (SqlDataReader reader = ExecuteCommandAndReturnReader(cmd)) { while (reader.Read()) { var info = new Picklist() { Id = (short)(reader.IsDBNull(0) ? 0 : reader.GetInt16(0)), Name = reader.IsDBNull(1) ? string.Empty : reader.GetString(1), IsStandard = !reader.IsDBNull(2) && reader.GetBoolean(2), EntityId = (short)(reader.IsDBNull(3) ? 0 : reader.GetInt16(3)), FixedValueList = !reader.IsDBNull(4) && reader.GetBoolean(4), CustomizeValue = !reader.IsDBNull(5) && reader.GetBoolean(5), IsKeyValueType = !reader.IsDBNull(6) && reader.GetBoolean(6), Active = !reader.IsDBNull(7) && reader.GetBoolean(7), IsDeleteted = !reader.IsDBNull(8) && reader.GetBoolean(8), UpdatedBy = reader.IsDBNull(9) ? Guid.Empty : reader.GetGuid(9), UpdatedDate = reader.IsDBNull(10) ? DateTime.MinValue : reader.GetDateTime(10) }; lstPicklists.Add(info); } } } catch (SqlException e) { throw ReportAndTranslateException(e, "Picklist::GetAll"); } return(lstPicklists); }
static void Main(string[] args) { using (var host = new NancyHost(new HostConfiguration() { RewriteLocalhost = false }, new Uri("http://localhost:9130"))) { host.Start(); Console.WriteLine("Running on http://localhost:9130"); var credentials = new Credentials() { Username = "******", Password = "******" }; var jsonRpcRequest = new JsonRpcRequest() { Id = "1", Method = "system.login", Params = credentials }; Console.WriteLine("\nExample system.login request:"); Console.WriteLine(JsonConvert.SerializeObject(jsonRpcRequest)); var pickList = new Picklist() { Ident = "4711" }; jsonRpcRequest = new JsonRpcRequest() { Id = "2", Method = "orderPicking.getPickList", Params = pickList }; Console.WriteLine("\nExample orderPicking.getPickList request:"); Console.WriteLine(JsonConvert.SerializeObject(jsonRpcRequest)); Console.ReadLine(); } }
// public Methods public JsonRpcResponse GetPickList(JsonRpcRequest jsonRpcRequest) { var pickRequest = ((JObject)jsonRpcRequest.Params).ToObject <Picklist>(); //TODO query WMS and return pickList var pickList = new Picklist() { Ident = pickRequest.Ident }; pickList.Lines.Add(new Pickline() { Ident = "1", Location = "01-05-34-04", Item = "Guinness", Quantity = 120M, Unit = "gallon" }); pickList.Lines.Add(new Pickline() { Ident = "2", Location = "01-08-46-01", Item = "Smithwick's", Quantity = 200M, Unit = "gallon" }); pickList.Lines.Add(new Pickline() { Ident = "3", Location = "01-12-11-03", Item = "Murphy's Irish Red", Quantity = 80M, Unit = "gallon" }); pickList.Lines.Add(new Pickline() { Ident = "4", Location = "01-22-34-05", Item = "Curim Gold Celtic Wheat", Quantity = 40M, Unit = "gallon" }); var error = new JsonRpcError() { Code = ErrorCodes.E_Ok }; return(new JsonRpcResponse() { Id = jsonRpcRequest.Id, Error = error, Result = pickList }); }
public void ShowTest() { using (ShimsContext.Create()) { ShimLog.AllInstances.ConfiguredLogLevelGet = (a) => { return(LogLevel.FromString("Debug")); }; ShimFeedListView.AllInstances.GetFeedListIListOfRssFeed = (a, b) => { var f = new List <RssFeed>(); return(Result.Ok <IList <RssFeed> >(f)); }; ShimBaseView.AllInstances.ShowHeaderString = (a, b) => { }; ShimBaseView.AllInstances.ShowFooterString = (a, b) => { }; ShimFeedListView.AllInstances.GetPicklist = (a) => { var r = new Picklist <RssFeed>(); return(Result.Ok(r)); }; ConfigObject layout = new ConfigObject(); var controls = new List <GuiElement>(); layout.Add(new KeyValuePair <string, object>("Width", 100)); layout.Add(new KeyValuePair <string, object>("Height", 101)); layout.Add(new KeyValuePair <string, object>("Controls", controls)); var view = new FeedListView(layout); var feeds = new List <RssFeed>(); view.Show(false, feeds); Assert.AreEqual(view._mainView.Width, 100); Assert.AreEqual(view._mainView.Height, 101); } }
/// <summary> /// Sets the value. /// </summary> /// <param name="value">The value.</param> /// <param name="data">The data.</param> public override void SetValue(string value, params string[] data) { if (this.Adaptee is StateProperty) { ((StateProperty)this.Adaptee).Value = value; return; } if (this.Adaptee is StringProperty) { ((StringProperty)this.Adaptee).Value = value; return; } if (this.Adaptee is UniqueIdentifierProperty) { ID idValue; if (ID.TryParse(value, out idValue)) { var identifier = new UniqueIdentifier { Value = idValue.Guid }; ((UniqueIdentifierProperty)this.Adaptee).Value = identifier; } return; } if (this.Adaptee is StatusProperty) { int intValue; if (int.TryParse(value, out intValue)) { var status = new Status { Value = intValue }; ((StatusProperty)this.Adaptee).Value = status; } return; } if (this.Adaptee is PicklistProperty) { string picklistValue = value; Picklist list = null; int intValue; if (!string.IsNullOrEmpty(picklistValue) && int.TryParse(picklistValue, out intValue)) { list = new Picklist { Value = intValue }; } else { picklistValue = null; } if (string.IsNullOrEmpty(picklistValue)) { list = new Picklist { IsNull = true, IsNullSpecified = true }; } ((PicklistProperty)this.Adaptee).Value = list; return; } if (this.Adaptee is OwnerProperty) { ID idValue; if (ID.TryParse(value, out idValue)) { var owner = new Owner { Value = idValue.Guid, type = data[0] }; ((OwnerProperty)this.Adaptee).Value = owner; } return; } if (this.Adaptee is LookupProperty) { ID idValue; if (ID.TryParse(value, out idValue)) { var lookup = new Lookup { Value = idValue.Guid, type = data[0] }; ((LookupProperty)this.Adaptee).Value = lookup; } return; } if (this.Adaptee is KeyProperty) { ID idValue; if (ID.TryParse(value, out idValue)) { var key = new Key { Value = idValue.Guid }; ((KeyProperty)this.Adaptee).Value = key; } return; } if (this.Adaptee is EntityNameReferenceProperty) { var reference = new EntityNameReference { Value = value }; ((EntityNameReferenceProperty)this.Adaptee).Value = reference; return; } if (this.Adaptee is DynamicEntityArrayProperty) { var dynamycProperty = (DynamicEntityArrayProperty)this.Adaptee; dynamycProperty.Value = new[] { new DynamicEntity { Name = "activityparty", Properties = new[] { new LookupProperty { Name = "partyid", Value = new Lookup { Value = new Guid(value), type = data[0] } } } } }; } if (this.Adaptee is CustomerProperty) { ID idValue; if (ID.TryParse(value, out idValue)) { var customer = new Customer { Value = idValue.Guid, type = data[0] }; ((CustomerProperty)this.Adaptee).Value = customer; } return; } if (this.Adaptee is CrmNumberProperty) { int intValue; if (int.TryParse(value, out intValue)) { var number = new CrmNumber { Value = intValue }; ((CrmNumberProperty)this.Adaptee).Value = number; } return; } if (this.Adaptee is CrmMoneyProperty) { decimal decimalValue; if (decimal.TryParse(value, out decimalValue)) { var money = new CrmMoney { Value = decimalValue }; ((CrmMoneyProperty)this.Adaptee).Value = money; } return; } if (this.Adaptee is CrmFloatProperty) { float decimalValue; if (float.TryParse(value, out decimalValue)) { var crmFloat = new CrmFloat { Value = decimalValue }; ((CrmFloatProperty)this.Adaptee).Value = crmFloat; } return; } if (this.Adaptee is CrmDecimalProperty) { decimal decimalValue; if (decimal.TryParse(value, out decimalValue)) { var crmDecimal = new CrmDecimal { Value = decimalValue }; ((CrmDecimalProperty)this.Adaptee).Value = crmDecimal; } return; } if (this.Adaptee is CrmDateTimeProperty) { DateTime parsedValue; if (value.TryParseDateTime(out parsedValue)) { ((CrmDateTimeProperty)this.Adaptee).Value = new CrmDateTime { Value = parsedValue.ToCrmDateTimeString() }; } } if (this.Adaptee is CrmBooleanProperty) { var boolValue = MainUtil.GetBool(value, false); var crmBool = new CrmBoolean { Value = boolValue }; ((CrmBooleanProperty)this.Adaptee).Value = crmBool; } }
private void InitializeForm() { // Create the list of user data categories given the appropriate type from that supplied _listCategories = new UserDataCategoryList(_category.Scope); // Populate the 'Categories' combo with possible values _listCategories.Populate(); foreach (UserDataCategory availableCategory in _listCategories) { ValueListItem item = cbCategories.Items.Add(availableCategory, availableCategory.Name); if (availableCategory.CategoryID == _category.CategoryID) { cbCategories.SelectedItem = item; } } // Set the form title Text = (_field.FieldID == 0) ? "New User Data Field" : "User Data Field Properties"; Text += " [" + _category.ScopeAsString + "]"; // Populate the 'Type' combo with possible types Dictionary <UserDataField.FieldType, string> fieldTypes = _field.FieldTypes; foreach (KeyValuePair <UserDataField.FieldType, string> kvp in fieldTypes) { cbFieldType.Items.Add(kvp.Key, kvp.Value); } // Populate the Case Combo with possible input cases Dictionary <UserDataField.FieldCase, string> fieldCases = _field.FieldInputCases; foreach (KeyValuePair <UserDataField.FieldCase, string> kvp in fieldCases) { InputCase.Items.Add(kvp.Key, kvp.Value); } InputCase.SelectedIndex = 0; // Populate the Picklists combo with the names of any picklists that have been defined PickListList picklists = new PickListList(); picklists.Populate(); foreach (PickList picklist in picklists) { Picklist.Items.Add(picklist, picklist.Name); } if (Picklist.Items.Count != 0) { Picklist.SelectedIndex = 0; } // Set the initial data tbFieldName.Text = _field.Name; //TabOrder.Value = field.TabOrder; cbMandatory.Checked = _field.IsMandatory; cbInteractiveInclude.Checked = (_field.ParentScope == UserDataCategory.SCOPE.Asset); // Set the field type in the combo box int selectedIndex = cbFieldType.FindStringExact(fieldTypes[_field.Type]); cbFieldType.SelectedIndex = selectedIndex == -1 ? 0 : selectedIndex; // The remainder of the fields depend on the field type switch ((int)_field.Type) { // For text fields the input length is stored in 'Value1' and Input Case encoded into Value2 case (int)UserDataField.FieldType.Text: selectedIndex = InputCase.FindStringExact(_field.InputCase == "title" ? "TitleCase" : _field.InputCase); InputCase.SelectedIndex = (selectedIndex == -1) ? 0 : selectedIndex; break; // Numeric fields - Minimum is 'Value1' Maximum is 'Value2' case (int)UserDataField.FieldType.Number: break; // For a picklist, the name of the picklist (if any) is stored in 'Value1' case (int)UserDataField.FieldType.Picklist: selectedIndex = (Picklist.FindStringExact(_field.Picklist)); Picklist.SelectedIndex = (selectedIndex == -1) ? 0 : selectedIndex; break; // Environment Variable - the permitted length is stored as 'Value1' with the name of the variable // in question stored as 'Value2' case (int)UserDataField.FieldType.Environment: tbEnvironmentVariableName.Text = _field.EnvironmentVariable; break; // Registry Keys : The Key name is stored as value1 with the value name as Value2 case (int)UserDataField.FieldType.Registry: tbRegistryKey.Text = _field.RegistryKey; tbRegistryValue.Text = _field.RegistryValue; break; //// Boolean Fields - no additional fields required //case (int)UserDataField.FieldType.boolean: // break; // Date Fields - no additional fields required case (int)UserDataField.FieldType.Date: break; // Currency Fields - no additional fields required case (int)UserDataField.FieldType.Currency: break; default: MessageBox.Show("An invalid type has been identified in the User Data Field Definition"); break; } }
/// <summary> /// Validate the data entered /// </summary> /// <returns></returns> private bool ValidateData() { // First ensure that we have specified the field name if (tbFieldName.Text == "") { MessageBox.Show("You must specify the name of the User Defined Data Field", "Validation Failed"); tbFieldName.Focus(); return(false); } // Ensure that this field does not duplicate an existing one within the same category foreach (UserDataField field in _category) { if ((field.Name == _field.Name) && (field.FieldID != _field.FieldID)) { MessageBox.Show("A User Defined Data Field of this name already exists within this category, please enter a unique name for this field", "Field Exists"); tbFieldName.Focus(); return(false); } } // Validate the remainder of the fields based on the field type UserDataField.FieldType fieldType = (UserDataField.FieldType)cbFieldType.SelectedItem.DataValue; switch ((int)fieldType) { // For text fields we need to the length and the Case - both must be valid anyway case (int)UserDataField.FieldType.Text: break; // Numeric fields save the minimum and maximum values as Value1 and Value2 respectively ensuring that // minimum is less than or equal to maximum case (int)UserDataField.FieldType.Number: break; // Picklist - save the name of the picklist as Value1 - there must be a picklist specified case (int)UserDataField.FieldType.Picklist: if (Picklist.SelectedIndex == -1) { MessageBox.Show("A picklist must be associated with this field", "Validation Error"); Picklist.Focus(); return(false); } break; // Environment Variable - We must have specified a name case (int)UserDataField.FieldType.Environment: if (tbEnvironmentVariableName.Text == "") { MessageBox.Show("You must specify the name of an environment variable for this field", "Validation Error"); tbEnvironmentVariableName.Focus(); return(false); } break; // Registry Key - Key at least must be specified - an empty value means recover the default value case (int)UserDataField.FieldType.Registry: if (tbRegistryKey.Text == "") { MessageBox.Show("You must specify a registry key for the field", "Validation Error"); tbRegistryKey.Focus(); return(false); } break; //// No additional values required for boolean //case (int)UserDataField.FieldType.boolean: // break; case (int)UserDataField.FieldType.Date: if (_editing && _existingType != UserDataField.FieldType.Date) { if (MessageBox.Show("Please ensure any existing dates are stored in the format 'YYYY-MM-DD'." + Environment.NewLine + Environment.NewLine + "Any data not in this format may be lost. Do you wish to proceed?", "Change data type", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(false); } } break; case (int)UserDataField.FieldType.Currency: if (_editing && _existingType != UserDataField.FieldType.Currency) { if (MessageBox.Show("Please ensure any existing currency data is stored in numeric format only." + Environment.NewLine + Environment.NewLine + "Any data not in this format may be lost. Do you wish to proceed?", "Change data type", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return(false); } } break; } return(true); }
/// <summary> /// The handles key press in feed list /// </summary> /// <param name="key">The <see cref="ConsoleKeyInfo"/></param> /// <param name="selectedItem">The <see cref="RssFeed"/></param> /// <param name="parent">The <see cref="Picklist{RssFeed}"/></param> /// <returns>The <see cref="bool"/></returns> private bool FeedList_OnItemKeyHandler(ConsoleKeyInfo key, RssFeed selectedItem, Picklist <RssFeed> parent) { //Open if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenFeed)) { return(OpenSelectedFeed(selectedItem, parent)); } //Exit app if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.QuitApp)) { return(false); } //Reload all if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.ReloadAll)) { ReloadAll(parent, true); parent.Refresh(); return(true); } //Reload if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Reload)) { if (!selectedItem.IsProcessing) { ReloadOne(selectedItem, true); Parallel.ForEach(parent.ListItems.Where(i => ((RssFeed)i).IsDynamic == true), (item) => { ((RssFeed)item).Load(false); }); } return(true); } //Mark all read if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkAllRead)) { return(MarkAllArticlesRead(selectedItem)); } //Purge deleted if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Purge)) { return(PurgeDeletedArticles(parent)); } //Redraw view if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.RefreshView)) { _mainView.Refresh(); } //open feed URL if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenBrowser)) { return(OpenFeedInBrowser(selectedItem)); } //search if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Search)) { parent.IsDisplayed = false; var result = GlobalMethods.Search(_mainView); parent.IsDisplayed = true; return(result); } return(true); }
private bool ArticleList_OnItemKeyHandler(ConsoleKeyInfo key, FeedItem selectedItem, Picklist <FeedItem> parent) { //Open article if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenArticle)) { return(OpenArticle(selectedItem, parent)); } //Mark selected item as read if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkRead)) { if (selectedItem != null) { selectedItem.MarkAsRead(); selectedItem.DisplayText = selectedItem.DisplayLine; } } //Mark all read if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkAllRead)) { return(MarkAllRead()); } //Mark selected item as unread if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.MarkUnread)) { if (selectedItem != null && !selectedItem.IsNew) { selectedItem.MarkUnread(); selectedItem.DisplayText = selectedItem.DisplayLine; } } //Mark current item for deletion if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Delete)) { if (selectedItem != null) { selectedItem.MarkDeleted(); selectedItem.DisplayText = selectedItem.DisplayLine; } } if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.DeleteAll)) { return(DeleteAllArticles()); } if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.StepBack)) { return(false); } if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Reload)) { return(Reload(parent)); } //Download selected item content to local storage if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Download)) { return(Download(selectedItem)); } //Delete locally stored content if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.DeleteContent)) { return(DeleteContent(selectedItem)); } //open in browser if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.OpenBrowser)) { return(OpenArticleInBrowser(selectedItem)); } //search if (key.VerifyKey((ConfigObject)Config.Global.Shortcuts.Search)) { parent.IsDisplayed = false; var result = GlobalMethods.Search(_mainView); parent.IsDisplayed = true; return(result); } return(true); }
public virtual void SetPropertyValue(Property property, string value, params string[] data) { Assert.ArgumentNotNull(property, "property"); if (property is StateProperty) { ((StateProperty)property).Value = value; return; } if (property is StringProperty) { ((StringProperty)property).Value = value; return; } if (property is UniqueIdentifierProperty) { ID idValue = null; if (ID.TryParse(value, out idValue)) { var identifier = new UniqueIdentifier { Value = idValue.Guid }; ((UniqueIdentifierProperty)property).Value = identifier; } return; } if (property is StatusProperty) { int intValue = 0; if (int.TryParse(value, out intValue)) { var status = new Status { Value = intValue }; ((StatusProperty)property).Value = status; } return; } if (property is PicklistProperty) { string picklistValue = value; Picklist list = null; int intValue = 0; if (!string.IsNullOrEmpty(picklistValue) && int.TryParse(picklistValue, out intValue)) { list = new Picklist { Value = intValue }; } else { picklistValue = null; } if (string.IsNullOrEmpty(picklistValue)) { list = new Picklist { IsNull = true, IsNullSpecified = true }; } ((PicklistProperty)property).Value = list; return; } if (property is OwnerProperty) { ID idValue = null; if (ID.TryParse(value, out idValue)) { var owner = new Owner { Value = idValue.Guid, type = data[0] }; ((OwnerProperty)property).Value = owner; } return; } if (property is LookupProperty) { ID idValue = null; if (ID.TryParse(value, out idValue)) { var lookup = new Lookup { Value = idValue.Guid, type = data[0] }; ((LookupProperty)property).Value = lookup; } return; } if (property is KeyProperty) { ID idValue = null; if (ID.TryParse(value, out idValue)) { var key = new CrmCampaignIntegration.Services.Key { Value = idValue.Guid }; ((KeyProperty)property).Value = key; } return; } if (property is EntityNameReferenceProperty) { var reference = new EntityNameReference { Value = value }; ((EntityNameReferenceProperty)property).Value = reference; return; } if (property is DynamicEntityArrayProperty) { var dynamycProperty = (DynamicEntityArrayProperty)property; dynamycProperty.Value = new[] { new DynamicEntity { Name = "activityparty", Properties = new [] { new LookupProperty { Name = "partyid", Value = new Lookup { Value = new Guid(value), type = data[0] } } } } }; } if (property is CustomerProperty) { ID idValue = null; if (ID.TryParse(value, out idValue)) { var customer = new Customer { Value = idValue.Guid, type = data[0] }; ((CustomerProperty)property).Value = customer; } return; } if (property is CrmNumberProperty) { int intValue = 0; if (int.TryParse(value, out intValue)) { var number = new CrmCampaignIntegration.Services.CrmNumber { Value = intValue }; ((CrmNumberProperty)property).Value = number; } return; } if (property is CrmMoneyProperty) { decimal decimalValue = 0; if (decimal.TryParse(value, out decimalValue)) { var money = new CrmMoney { Value = decimalValue }; ((CrmMoneyProperty)property).Value = money; } return; } if (property is CrmFloatProperty) { float decimalValue = 0; if (float.TryParse(value, out decimalValue)) { var crmFloat = new CrmCampaignIntegration.Services.CrmFloat { Value = decimalValue }; ((CrmFloatProperty)property).Value = crmFloat; } return; } if (property is CrmDecimalProperty) { decimal decimalValue = 0; if (decimal.TryParse(value, out decimalValue)) { var crmDecimal = new CrmDecimal { Value = decimalValue }; ((CrmDecimalProperty)property).Value = crmDecimal; } return; } if (property is CrmDateTimeProperty) { var dateTime = Sitecore.CrmCampaignIntegrations.Core.Utility.DateUtil.ToCrmDateTime(value); if (dateTime != null) { var crmDateTime = new CrmCampaignIntegration.Services.CrmDateTime { Value = dateTime.Value }; ((CrmDateTimeProperty)property).Value = crmDateTime; } } if (property is CrmBooleanProperty) { var boolValue = MainUtil.GetBool(value, false); var crmBool = new CrmCampaignIntegration.Services.CrmBoolean { Value = boolValue }; ((CrmBooleanProperty)property).Value = crmBool; return; } }
public void FillWithEnum <T>() where T : struct, IComparable, IFormattable { var list = new Picklist <T>(EnumUtils.GetList <T>()); FillWithList(list); }
public void FillWith <T>(params T[] items) where T : IComparable { var list = new Picklist <T>(items); FillWithList(list); }
public void FillWithList(string[] strings) { var list = new Picklist <string>(strings); FillWithList(list); }
//Field Value Object /// <summary> /// Returns the entity attribute /// </summary> /// <param name="dynamicEntityInstance">Entity</param> /// <param name="entityPropertyLogicalName">Attribute name<</param> /// <returns>Attribute value(Object)</returns> public static Object GetPropertyObj(this DynamicEntity dynamicEntityInstance, string entityPropertyLogicalName) { if (dynamicEntityInstance.Properties.Contains(entityPropertyLogicalName)) { string propertyType = null; Object returnObject; try { //"CrmTypes" propertyType = dynamicEntityInstance.Properties[entityPropertyLogicalName].GetType().ToString(); } catch (Exception e) { propertyType = e.Message; returnObject = e.Message; return(null); } if (propertyType == "Microsoft.Crm.Sdk.Owner") { Owner ownerObject = (dynamicEntityInstance[entityPropertyLogicalName]) as Owner; returnObject = new { Value = ownerObject, Type = propertyType }; return(returnObject); } if (propertyType == "Microsoft.Crm.Sdk.Customer") { Customer customerObject = (dynamicEntityInstance[entityPropertyLogicalName]) as Customer; returnObject = new { Value = customerObject, Type = propertyType }; return(returnObject); } if (propertyType == "Microsoft.Crm.Sdk.CrmDateTime") { CrmDateTimeProperty datetimeObject = new CrmDateTimeProperty(entityPropertyLogicalName, (CrmDateTime)dynamicEntityInstance.Properties[entityPropertyLogicalName]); returnObject = new { Value = datetimeObject, Type = propertyType }; return(returnObject); } if (propertyType == "Microsoft.Crm.Sdk.CrmBoolean") { CrmBooleanProperty booleanObject = new CrmBooleanProperty(entityPropertyLogicalName, (CrmBoolean)dynamicEntityInstance.Properties[entityPropertyLogicalName]); returnObject = new { Value = booleanObject, Type = propertyType }; return(returnObject); } if (propertyType == "System.String") { returnObject = new { Value = (dynamicEntityInstance.Properties[entityPropertyLogicalName]), Type = propertyType }; return(returnObject); } if (propertyType == "Microsoft.Crm.Sdk.Lookup") { Lookup lookupObject = dynamicEntityInstance[entityPropertyLogicalName] as Lookup; returnObject = new { Value = lookupObject, Type = propertyType }; return(returnObject); } if (propertyType == "Microsoft.Crm.Sdk.Picklist") { Picklist piclkistObject = dynamicEntityInstance[entityPropertyLogicalName] as Picklist; returnObject = new { Value = piclkistObject, Type = propertyType }; return(returnObject); } } else { object nullObject = new { value = "Null", type = "Null" }; return(nullObject); } object nullreturn = new { value = "null", type = "null" }; return(nullreturn); }
protected void SetPropertyValue <T>(string attribute, PropertyType pt, T value) { try { switch (pt) { case PropertyType.Key: this.Properties[attribute] = new Key((Guid)(object)value); break; case PropertyType.UniqueIdentifier: this.Properties[attribute] = new UniqueIdentifier((Guid)(object)value); break; case PropertyType.Number: this.Properties[attribute] = new CrmNumber((int)(object)value); break; case PropertyType.Money: this.Properties[attribute] = new CrmMoney((decimal)(object)value); break; case PropertyType.Decimal: this.Properties[attribute] = new CrmDecimal((decimal)(object)value); break; case PropertyType.String: this.Properties[attribute] = value; break; case PropertyType.DateTime: this.Properties[attribute] = new CrmDateTime(((DateTime)(object)value).ToString("yyyy-MM-ddTHH:mm:ss Z")); break; case PropertyType.Picklist: int intValue = (int)(object)value; Picklist picklist = new Picklist(); if (intValue == 0) { picklist.IsNull = true; picklist.IsNullSpecified = true; } else { picklist.Value = intValue; } this.Properties[attribute] = picklist; break; case PropertyType.Owner: this.Properties[attribute] = new Owner("systemuser", (Guid)(object)value); break; case PropertyType.Lookup: Guid guidValue = (Guid)(object)value; Lookup lookup = new Lookup(); if (guidValue == Guid.Empty) { lookup.IsNull = true; lookup.IsNullSpecified = true; } else { lookup.Value = guidValue; } this.Properties[attribute] = lookup; //this.Properties[attribute] = new Lookup("systemuser", (Guid)(object)value); break; case PropertyType.Customer: this.Properties[attribute] = new Customer("account", (Guid)(object)value); break; case PropertyType.Bit: this.Properties[attribute] = new CrmBoolean((Boolean)(object)value); break; case PropertyType.Status: this.Properties[attribute] = new Status((int)(object)value); break; } } catch { } }
/// <summary> /// Returns the default string value /// </summary> /// <param name="crmEntity">Entity</param> /// <param name="propertyName">Attribute Name</param> /// <returns>Attribute value(String)</returns> public static string GetDefaultFieldValue(this DynamicEntity crmEntity, string propertyName) { if (crmEntity.Properties.Contains(propertyName)) { string ret = string.Empty; string type = null; try { //TODO: Google "CrmTypes" type = crmEntity.Properties[propertyName].GetType().ToString(); } catch (Exception exception) { type = exception.Message; ret = exception.Message; return(null); } if (type == "Microsoft.Crm.Sdk.Owner") { Owner owner = (Owner)crmEntity[propertyName]; return(owner.name); } if (type == "Microsoft.Crm.Sdk.Customer") { Customer customer = (Customer)crmEntity[propertyName]; return(customer.name); } if (type == "Microsoft.Crm.Sdk.CrmDateTime") { CrmDateTimeProperty crmDataTime = new CrmDateTimeProperty(propertyName, (CrmDateTime)crmEntity.Properties[propertyName]); return(crmDataTime.Value.date); } if (type == "Microsoft.Crm.Sdk.CrmBoolean") { CrmBooleanProperty crmBooleanProperty = new CrmBooleanProperty(propertyName, (CrmBoolean)crmEntity.Properties[propertyName]); ret = crmBooleanProperty.Value.Value.ToString(); return(ret); } if (type == "System.String") { return(crmEntity.Properties[propertyName].ToString()); } if (type == "Microsoft.Crm.Sdk.Lookup") { Lookup crmLookup = (Lookup)crmEntity[propertyName]; return(crmLookup.name); } if (type == "Microsoft.Crm.Sdk.Picklist") { Picklist crmPicklist = (Picklist)crmEntity[propertyName]; return(crmPicklist.name); } if (type == "Microsoft.Crm.Sdk.CrmNumber") { CrmNumber num = (CrmNumber)crmEntity[propertyName]; return(num.Value.ToString()); } return(ret); } else { return("The Entity doesn't have this property defined"); } }
public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] SelectedPickListDTO picklist) { if (!ModelState.IsValid) { return(request.CreateResponse(HttpStatusCode.BadRequest, picklist)); } try { var newPickList = new Picklist { QuoteId = picklist.QuoteId, DispatchDate = DateTime.ParseExact(picklist.DispatchDate, "dd/MM/yyyy", CultureInfo.InvariantCulture), DeliveryAddress = picklist.DeliveryAddress, DeliveryNeeded = picklist.DeliveryNeeded, IsPicked = picklist.IsPicked, IsAllocated = picklist.IsAllocated, IsDelivered = picklist.IsDelivered, Comment = picklist.Comment, EstimatedDelivery = picklist.EstimatedDelivery, Active = true //Default to true as initial save }; db.Picklists.Add(newPickList); db.SaveChanges(); db.Entry(newPickList).Reload(); var pickListId = newPickList.PicklistId; foreach (var plant in picklist.PickListPlants) { var needsPurchasing = false; if (plant.Location == "PB") { needsPurchasing = true; } var thisPlant = new PlantsForPicklist { PicklistId = pickListId, PlantForQuoteId = plant.PlantForQuoteId, BatchId = plant.BatchId, PlantName = plant.PlantName, FormSize = plant.FormSize, QuantityToPick = plant.QuantityToPick, IsSubbed = plant.IsSubbed, DispatchLocation = plant.DispatchLocation, QuantityPicked = 0, //Default this to 0 because none will have been picked on creation?? NeedsPurchasing = needsPurchasing, Active = true }; db.PlantsForPicklists.Add(thisPlant); } db.SaveChanges(); return(request.CreateResponse(HttpStatusCode.OK, picklist)); } catch (Exception ex) { return(request.CreateResponse(HttpStatusCode.BadRequest, ex)); } }
/// <summary> /// This method is used to get attributes from a specified entity. It returns Dictionary containing all the required attributes values. /// </summary> /// <param name="entityGuid">GUID of the entity</param> /// <param name="entityName_">The entity name type (contact,lead,...)</param> ///<param name="entityAttributes">The ArrayList containing the attributes names types you want to retrieve (firstname,lastname,...)</param> public Dictionary<string, string> getEntity(Guid entityGuid, string entityName_, ArrayList entityAttributes) { Dictionary<string, string> arrayData = new Dictionary<string, string>(); try { isconnected(); ArrayList arrayResults = new ArrayList(); // Create the retrieve target. TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic(); // Set the properties of the target. targetRetrieve.EntityName = entityName_; targetRetrieve.EntityId = entityGuid; // Create the request object. RetrieveRequest retrieve = new RetrieveRequest(); ColumnSet col = new ColumnSet(); // Set the properties of the request object. retrieve.Target = targetRetrieve; for (int i = 0; i < entityAttributes.Count; i++) { col.AddColumn(entityAttributes[i].ToString()); } retrieve.ColumnSet = col; // Indicate that the BusinessEntity should be retrieved as a // DynamicEntity. retrieve.ReturnDynamicEntities = true; // Execute the request. RetrieveResponse retrieved = (RetrieveResponse)m_crmService.Execute(retrieve); // Extract the DynamicEntity from the request. DynamicEntity entity = (DynamicEntity)retrieved.BusinessEntity; Microsoft.Crm.Sdk.CrmDateTime crmDateTimeVar = new Microsoft.Crm.Sdk.CrmDateTime(); Microsoft.Crm.Sdk.CrmNumber crmNumberVar = new Microsoft.Crm.Sdk.CrmNumber(); Picklist crmPickList = new Picklist(); Guid crmGuid = new Guid(); Microsoft.Crm.Sdk.Key keyVar = new Microsoft.Crm.Sdk.Key(); Lookup lookupVar = new Lookup(); Microsoft.Crm.Sdk.CrmBoolean boolVar = new Microsoft.Crm.Sdk.CrmBoolean(); for (int i = 0; i < entityAttributes.Count; i++) { if (entity.Properties.Contains(entityAttributes[i].ToString())) { if (entity.Properties[entityAttributes[i].ToString()].GetType().Equals(crmDateTimeVar.GetType())) { crmDateTimeVar = (Microsoft.Crm.Sdk.CrmDateTime)entity.Properties[entityAttributes[i].ToString()]; arrayData.Add(entityAttributes[i].ToString(),crmDateTimeVar.date.ToString()); } else { if (entity.Properties[entityAttributes[i].ToString()].GetType().Equals(crmNumberVar.GetType())) { crmNumberVar = (Microsoft.Crm.Sdk.CrmNumber)entity.Properties[entityAttributes[i].ToString()]; arrayData.Add(entityAttributes[i].ToString(), crmNumberVar.Value.ToString()); } else { if (entity.Properties[entityAttributes[i].ToString()].GetType().Equals(keyVar.GetType())) { keyVar = (Microsoft.Crm.Sdk.Key)entity.Properties[entityAttributes[i].ToString()]; arrayData.Add(entityAttributes[i].ToString(), keyVar.Value.ToString()); } else { if (entity.Properties[entityAttributes[i].ToString()].GetType().Equals(lookupVar.GetType())) { lookupVar = (Microsoft.Crm.Sdk.Lookup)entity.Properties[entityAttributes[i].ToString()]; arrayData.Add(entityAttributes[i].ToString(), lookupVar.Value.ToString()); } else { if (entity.Properties[entityAttributes[i].ToString()].GetType().Equals(boolVar.GetType())) { boolVar = (Microsoft.Crm.Sdk.CrmBoolean)entity.Properties[entityAttributes[i].ToString()]; arrayData.Add(entityAttributes[i].ToString(), boolVar.Value.ToString()); } else { if (entity.Properties[entityAttributes[i].ToString()].GetType().Equals(crmPickList.GetType())) { crmPickList = (Microsoft.Crm.Sdk.Picklist)entity.Properties[entityAttributes[i].ToString()]; arrayData.Add(entityAttributes[i].ToString(), crmPickList.Value.ToString()); } else { if (entity.Properties[entityAttributes[i].ToString()].GetType().Equals(crmGuid.GetType())) { crmGuid = (Guid)entity.Properties[entityAttributes[i].ToString()]; arrayData.Add(entityAttributes[i].ToString(), crmGuid.ToString()); } else { arrayData.Add(entityAttributes[i].ToString(), entity.Properties[entityAttributes[i].ToString()].ToString()); } } } } } } } } else { arrayData.Add(entityAttributes[i].ToString(), ""); } } return arrayData; } catch (SoapException ex) { throw new InvalidPluginExecutionException("!SoapException!\n" + ex.Detail.SelectSingleNode("//description").InnerText); } catch (Exception ex) { throw new ESC_CRM_EX.getEntityException(ex.Message, entityName_, entityGuid); } }
/// <summary> /// Set field value /// </summary> /// <param name="DynamicEntityObject">DynamicEntity</param> /// <param name="service">MetadataService</param> /// <param name="AttributeType">Type of attribute</param> /// <param name="AttributeName">Attribute name</param> /// <param name="AttributeValue1">Attribute first value</param> /// <param name="AttributeValue2">Attribute first value</param> /// <returns></returns> public static bool SetFieldValue(this DynamicEntity DynamicEntityObject, MetadataService service, String AttributeType, string AttributeName, String AttributeValue1, String AttributeValue2) { //bool ret = false; string TypeOfAttribute; // = null; try { //$ when the if (DynamicEntityObject.Properties.Contains(AttributeName)) { TypeOfAttribute = DynamicEntityObject.Properties[AttributeName].GetType().Name; } else { //TODO: replace this function with meta data service TypeOfAttribute = RetrieveAttributeMetadata(service, DynamicEntityObject.Name, AttributeName); } if (TypeOfAttribute == null || TypeOfAttribute == "PrimaryKey") { return(false); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.Owner" || TypeOfAttribute == "Owner") { DynamicEntityObject[AttributeName] = new Lookup(AttributeValue1, new Guid(AttributeValue2)); return(true); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.Customer" || TypeOfAttribute == "Customer") { DynamicEntityObject[AttributeName] = new Customer(AttributeValue1, new Guid(AttributeValue2)); return(true); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.CrmDateTime" || TypeOfAttribute == "CrmDateTime" || TypeOfAttribute == "Microsoft.Crm.Sdk.Metadata.DateTimeAttributeMetadata") { DynamicEntityObject[AttributeName] = new CrmDateTime(AttributeValue1); return(true); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.CrmBoolean" || TypeOfAttribute == "CrmBoolean" || TypeOfAttribute == "Microsoft.Crm.Sdk.Metadata.BooleanAttributeMetadata") { DynamicEntityObject.Properties[AttributeName] = new CrmBoolean(bool.Parse(AttributeValue1)); return(true); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.String" || TypeOfAttribute == "String" || TypeOfAttribute == "Microsoft.Crm.Sdk.Metadata.StringAttributeMetadata") { DynamicEntityObject[AttributeName] = (string)AttributeValue1; return(true); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.Lookup" || TypeOfAttribute == "Lookup" || TypeOfAttribute == "Microsoft.Crm.Sdk.Metadata.LookupAttributeMetadata") { DynamicEntityObject[AttributeName] = new Lookup(AttributeValue1, new Guid(AttributeValue2)); return(true); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.Picklist" || TypeOfAttribute == "Picklist" || TypeOfAttribute == "Microsoft.Crm.Sdk.Metadata.PicklistAttributeMetadata") { DynamicEntityObject[AttributeName] = new Picklist(int.Parse(AttributeValue1)); return(true); } else if (TypeOfAttribute == "Microsoft.Crm.Sdk.CrmNumber" || TypeOfAttribute == "CrmNumber" || TypeOfAttribute == "Integer" || TypeOfAttribute == "Microsoft.Crm.Sdk.Metadata.IntegerAttributeMetadata") { DynamicEntityObject[AttributeName] = new CrmNumber(int.Parse(AttributeValue1)); return(true); } } catch (SoapException sopEx) { throw; } return(false); }