/// <summary> /// Creates query criteria to read listings. /// </summary> /// <param name="channelProperties">Properties of the channel.</param> /// <param name="searchCriteria">Search criteria.</param> /// <param name="isInitialSync">Is initial sync.</param> /// <returns>New instance of filter criteria.</returns> private QueryResultSettings CreateGetListingsCriteria( IEnumerable <ChannelProperty> channelProperties, ChangedProductsSearchCriteria searchCriteria, out bool isInitialSync) { char[] syncToken; ChannelProperty channelProperty = channelProperties.SingleOrDefault(p => p.Name == KeySyncAnchor); if (channelProperty == null) { syncToken = ProductChangeTrackingAnchorSet.GetSynchronizationTokenFromAnchorSet(new ProductChangeTrackingAnchorSet(), 0); isInitialSync = true; } else { syncToken = channelProperty.Value.ToCharArray(); isInitialSync = false; } // Reading listings. QueryResultSettings getListingsCriteria = new QueryResultSettings(new PagingInfo(this.publishingConfig.CRTListingPageSize, 0)); searchCriteria.SynchronizationToken = syncToken; return(getListingsCriteria); }
public void HappyPath() { // Arrange var prop = new ChannelProperty("nAmE", "vAlUe"); // Act / Assert AssertChannelProp(prop, "nAmE", "vAlUe"); }
public void BlankValue() { // Arrange var prop = new ChannelProperty("nAmE", string.Empty); // Act / Assert AssertChannelProp(prop, "nAmE", string.Empty); }
private void SetInt(ChannelProperty flag, int value) { Library.Api.SetChannelVariableAsInt(this, flag, value); if (ID != 0) { FlushChannelUpdates(); } }
private void Channel_SetProperty(ChannelProperty property, object value) { var channelId = 1; var client = Initialize_Client(new SetChannelPropertyResponse(property, channelId, value)); client.SetObjectProperty(1234, channelId, property, value); }
private void SetString(ChannelProperty flag, string value) { Library.Api.SetChannelVariableAsString(this, flag, value); if (ID != 0) { FlushChannelUpdates(); } }
private void SetUInt64(ChannelProperty flag, ulong value) { Library.Api.SetChannelVariableAsUInt64(this, flag, value); if (ID != 0) { FlushChannelUpdates(); } }
// 确保获得一个 ChannelProperty 对象 public virtual ChannelProperty GetProperty() { if (this._property != null) { return(this._property); } this._property = new ChannelProperty(); return(this._property); }
public void ValueWithXmlChars_Seralizes() { // Arrange var prop = new ChannelProperty("prop", "why<would>you&do this?"); // Act var result = prop.ToXElement(); // Assert result.ToString(SaveOptions.DisableFormatting).Should().Be("<prop>why<would>you&do this?</prop>"); }
private ChannelLimitAnalysis GetHighest(Func <Channel, double?> selector, ChannelProperty property) { var group = Channels .GroupBy(selector) //e.g. group by UpperErrorLimit .Where(g => g.Key != null) //excluding those that don't have an UpperErrorLimit .OrderByDescending(g => g.Count()) //select the group of sensors that have the highest number of sensors with any particular UpperErrorLimit .FirstOrDefault(); //Associate ChannelProperty.UpperErrorLimit with the group of channels that have the highest incidence of any particular UpperErrorLimit return(new ChannelLimitAnalysis(group?.Key, group?.ToList(), property)); }
private void SetObjectProperty(ChannelProperty property, object value, string expectedSerializedValue = null) { if (expectedSerializedValue == null) { expectedSerializedValue = value.ToString(); } var client = Initialize_Client(new SetObjectPropertyResponse <ChannelProperty>(property, expectedSerializedValue)); client.SetObjectProperty(1, 1, property, value); }
public SetChannelSettingParameters(int sensorId, int channelId, ChannelProperty property, object value) { var attrib = property.GetEnumAttribute <RequireValueAttribute>(); if (value == null && (attrib == null || (attrib != null && attrib.ValueRequired))) { throw new ArgumentNullException($"Property '{property}' does not support null values."); } var customParams = GetChannelSetObjectPropertyCustomParams(channelId, property, value); SensorId = sensorId; CustomParameters = customParams; }
public void SetProp(string json) { Prop = JsonConvert.DeserializeObject <ChannelProperty>(json); Prop.PropStatus = ChannelProperty.PropState.PROP_SET; var mqttFactory = new MqttFactory(); MqttClient = mqttFactory.CreateMqttClient(); Options = new MqttClientOptionsBuilder() .WithTcpServer(Prop.Host, Prop.Port) .WithCredentials(Prop.Token, "") .WithTls() .WithCleanSession() .Build(); }
private void SetAndRevertChannelProperty <T>(T newValue, ChannelProperty property, Func <Channel, T> getProperty) { var initialChannel = client.GetChannels(Settings.ChannelSensor).First(c => c.Id == Settings.Channel); Assert.AreNotEqual(getProperty(initialChannel), newValue); client.SetObjectProperty(Settings.ChannelSensor, Settings.Channel, property, newValue); var newChannel = client.GetChannels(Settings.ChannelSensor).First(c => c.Id == Settings.Channel); Assert.AreEqual(newValue, getProperty(newChannel)); client.SetObjectProperty(Settings.ChannelSensor, Settings.Channel, property, getProperty(initialChannel)); var finalChannel = client.GetChannels(Settings.ChannelSensor).First(c => c.Id == Settings.Channel); Assert.AreEqual(getProperty(initialChannel), getProperty(finalChannel)); }
private void SetAndRevertChannelProperty <T>(T newValue, ChannelProperty property, Func <Channel, T> getProperty) { var initialChannel = client.GetChannels(Settings.ChannelSensor).First(c => c.Id == Settings.Channel); AssertEx.AreNotEqual(getProperty(initialChannel), newValue, "Initial channel value was not expected value"); client.SetObjectProperty(Settings.ChannelSensor, Settings.Channel, property, newValue); var newChannel = client.GetChannels(Settings.ChannelSensor).First(c => c.Id == Settings.Channel); AssertEx.AreEqual(newValue, getProperty(newChannel), "New channel value did not apply properly"); client.SetObjectProperty(Settings.ChannelSensor, Settings.Channel, property, getProperty(initialChannel)); var finalChannel = client.GetChannels(Settings.ChannelSensor).First(c => c.Id == Settings.Channel); AssertEx.AreEqual(getProperty(initialChannel), getProperty(finalChannel), "Channel value did not revert properly"); }
public URLClientAdapter() { Prop = new ChannelProperty(); #if NETFX_CORE SetProp(File.ReadAllText(@"Assets/ChannelProperty.json")); #elif __ANDROID__ var context = Uno.UI.ContextHelper.Current; var p = PreferenceManager.GetDefaultSharedPreferences(context); var channelInfo = p.GetString("CHANNEL_INFO", ""); if (channelInfo != "") { SetProp(channelInfo); } #endif }
set => SetValue(ChannelProperty, value);
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "speedtime", value); }
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "LimitMaxError", value); }
/// <summary> /// Initiates a catalog publishing. /// </summary> /// <param name="catalogPublisher">Instance of the object which implements ICatalogPublisher.</param> /// <returns>True if changed products were found in CRT, False otherwise.</returns> /// <remarks>Retrieves the channel's catalogs from CRT and then checks whether CRT contains changed products for each of the catalogs. If changed products are found then /// ICatalogPublisher's callbacks are executed to let the caller's code process changed products.</remarks> public bool PublishCatalog(ICatalogPublisher catalogPublisher) { if (catalogPublisher == null) { throw new ArgumentNullException(nameof(catalogPublisher)); } List <long> productCatalogIds = new List <long>(1); // If catalogs were published to this channel, a given product will be published into SP for each catalog // in which it appears, so catalogless publishing would not yield different results for those products. // If, however, a product was published directly from the assortment, that product will only be detected // and published to SP if the ForceCataloglessPublishing flag is set to 'true' (1) in the job configuration file. // The semantics of forcing catalogless publishing as strict, in that catalog-less products will be published // if and only if the flag is set. That means, for instance, that if the flag is not set and there are no // catalogs published to this channel, the SP job will not detect/publish any products to SP. if (this.publishingConfig.ForceNoCatalogPublishing) { NetTracer.Information(Resources.ProductCatalogToPublish, 0, "unspecified", "(not a proper catalog)"); productCatalogIds.Add(0); } IReadOnlyCollection <ProductCatalog> productCatalogs = this.GetCatalogs(); bool deletesFound = this.DeleteProducts(productCatalogs, catalogPublisher); foreach (ProductCatalog productCatalog in productCatalogs) { productCatalogIds.Add(productCatalog.RecordId); } ChangedProductsSearchCriteria searchCriteria = new ChangedProductsSearchCriteria { DataLevel = CommerceEntityDataLevel.Complete }; searchCriteria.Context.ChannelId = this.onlineChannel.RecordId; bool isInitialSync; QueryResultSettings productsQuerySettings = this.CreateGetListingsCriteria( this.onlineChannel.ChannelProperties, searchCriteria, out isInitialSync); bool changesFound = false; try { Stopwatch readChangedProductsWatch = Stopwatch.StartNew(); searchCriteria.Session = this.productManager.BeginReadChangedProducts(searchCriteria); readChangedProductsWatch.Stop(); this.LogTimingMessage(Resources.Duration_ReadChangedProducts, readChangedProductsWatch.Elapsed, searchCriteria.Session.TotalNumberOfProducts); if (searchCriteria.Session.TotalNumberOfProducts > 0) { changesFound = true; int totalProductsCount = 0; Stopwatch timerCummulativeListingRetrieval = new Stopwatch(); // loop through the product catalogs, retrieving products. foreach (long productCatalogId in productCatalogIds) { NetTracer.Information(Resources.StartReadProductsFromCatalog, productCatalogId); // set the catalog id on the search criteria searchCriteria.Context.CatalogId = productCatalogId; searchCriteria.Session.ResetNumberOfProductsRead(); int pageNumberForCatalog = 0; int catalogProductsCount = 0; // inner loop: load changes, page by page, up to catalog max size do { timerCummulativeListingRetrieval.Start(); ChangedProductsSearchResult getProductsResults = this.LoadChangedProducts(searchCriteria, productsQuerySettings); timerCummulativeListingRetrieval.Stop(); int numberOfReadProducts = getProductsResults.Results.Count; totalProductsCount += numberOfReadProducts; catalogProductsCount += numberOfReadProducts; this.LogTimingMessage(Resources.NumberOfReadProductsInPageSummary, productCatalogId, catalogProductsCount, totalProductsCount, timerCummulativeListingRetrieval.Elapsed); catalogPublisher.OnChangedProductsFound(getProductsResults, pageNumberForCatalog, productCatalogId); pageNumberForCatalog++; }while (searchCriteria.Session.NumberOfProductsRead < searchCriteria.Session.TotalNumberOfProducts); this.LogTimingMessage(Resources.CatalogReadCompleted, productCatalogId, catalogProductsCount, totalProductsCount, timerCummulativeListingRetrieval.Elapsed); catalogPublisher.OnCatalogReadCompleted(productCatalogId, this); } // for each product catalog this.LogTimingMessage(Resources.AllCatalogsReadCompleted, totalProductsCount, timerCummulativeListingRetrieval.Elapsed); } // if changed products were found } finally { this.productManager.EndReadChangedProducts(searchCriteria.Session); } ChannelProperty channelProperty = new ChannelProperty { Name = KeySyncAnchor, Value = new string(searchCriteria.Session.NextSynchronizationToken) }; this.channelManager.UpdateChannelProperties(new ChannelProperty[] { channelProperty }); return(changesFound || deletesFound); }
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "limitminwarning", value); }
public PropertyParameterAttribute(ChannelProperty property) { Property = property; }
public SetChannelPropertyResponse(ChannelProperty property, int channelId, object value) { this.property = property; this.channelId = channelId; this.value = value; }
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "showtable", value); }
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "customunit", value); }
public ChannelLimitAnalysis(double?limitValue, List <Channel> channels, ChannelProperty property) { LimitValue = limitValue; Channels = channels; Property = property; }
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "limiterrormsg", value); }
private List <CustomParameter> GetChannelSetObjectPropertyCustomParams(int channelId, ChannelProperty property, object value) { bool valAsBool; var valIsBool = bool.TryParse(value?.ToString(), out valAsBool); List <CustomParameter> customParams = new List <CustomParameter>(); if (valIsBool) { if (valAsBool) { value = 1; } else //if we're disabling a property, check if there are values dependent on us. if so, disable them too! { value = 0; var associatedProperties = property.GetDependentProperties <ChannelProperty>(); customParams.AddRange(associatedProperties.Select(prop => ObjectSettings.CreateCustomParameter(channelId, prop, string.Empty))); } } else //if we're enabling a property, check if there are values we depend on. if so, enable them! { var dependentProperty = property.GetEnumAttribute <DependentPropertyAttribute>(); if (dependentProperty != null) { customParams.Add(ObjectSettings.CreateCustomParameter(channelId, dependentProperty.Name.ToEnum <ChannelProperty>(), "1")); } } customParams.Add(ObjectSettings.CreateCustomParameter(channelId, property, value)); return(customParams); }
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "volumesize", value); }
private static void AssertChannelProp(ChannelProperty channelProp, string value) { AssertChannelProp(channelProp, "float", value); }