/// <inheritdoc /> /// <summary> /// Serialize a path parameter whose value is scalar (not a collection), into a string value /// </summary> /// <typeparam name="T">Type of the value to serialize</typeparam> /// <param name="value">Value of the path parameter</param> /// <param name="info">Extra info which may be useful to the serializer</param> /// <returns>A string value to use as path parameter</returns> /// <remarks> /// If the value is an enum value, the serializer will check if it has an EnumMember, DisplayName or Display /// attribute, and if so return the value of that instead (in that order of preference). /// </remarks> public override string SerializePathParam <T>(T value, RequestPathParamSerializerInfo info) { if (value == null) { return(null); } var type = typeof(T); if (!IsEnum(type)) { return(ToStringHelper.ToString(value, info.Format, info.FormatProvider)); } if (cache.TryGetValue(value, out var stringValue)) { return(stringValue); } stringValue = value.ToString(); var fieldInfo = GetField(type, stringValue); if (fieldInfo == null) { return(CacheAdd(value, stringValue)); } #if !NETSTANDARD1_1 var enumMemberAttribute = fieldInfo.GetCustomAttribute <EnumMemberAttribute>(); if (enumMemberAttribute != null) { return(CacheAdd(value, enumMemberAttribute.Value)); } var displayNameAttribute = fieldInfo.GetCustomAttribute <DisplayNameAttribute>(); if (displayNameAttribute != null) { return(CacheAdd(value, displayNameAttribute.DisplayName)); } #endif // netstandard can get this by referencing System.ComponentModel.DataAnnotations, (and framework // can get this by referencing the assembly). However we don't want a dependency on this nuget package, // for something so niche, so do a reflection-only load var displayAttribute = fieldInfo.CustomAttributes .FirstOrDefault(x => x.AttributeType.FullName == "System.ComponentModel.DataAnnotations.DisplayAttribute"); if (displayAttribute != null) { var name = displayAttribute.NamedArguments.FirstOrDefault(x => x.MemberName == "Name").TypedValue.Value; if (name != null) { return(CacheAdd(value, (string)name)); } } return(CacheAdd(value, stringValue)); }
/// <summary> /// Returns a logging Friendly version of the Group. /// </summary> /// <returns></returns> public override string ToString() { ToStringHelper sb = new ToStringHelper(); sb.Append("User"); sb.AppendProperty("Name", Name); sb.AppendProperty("GID", GID); sb.AppendProperty("Members", Members); return(sb.ToString()); }
/// <summary> /// Returns a logging Friendly version of the User. /// </summary> /// <returns></returns> public override string ToString() { ToStringHelper sb = new ToStringHelper(); sb.Append("User"); sb.AppendProperty("Name", Name); sb.AppendProperty("UID", UID); sb.AppendProperty("GID", GID); sb.AppendProperty("Comment", Comment); sb.AppendProperty("Home", Home); sb.AppendProperty("Shell", Shell); return(sb.ToString()); }
private void ProcessItems(IUnitOfWork db, string reportId, IList <ListingDefectDTO> items) { Log.Debug("ProcessItems begin"); foreach (var item in items) { Log.Debug("Stored item:" + ToStringHelper.ToString(item)); db.ListingDefects.CreateOrUpdate(item, DateTime.UtcNow); } //Mark all except parsed as removed db.ListingDefects.MarkExceptFromFeedAsRemoved(reportId); Log.Debug("ProcessItems end"); }
public override string ToString() { var text = ToStringHelper.ToString(this); text += ", Items="; if (Items != null) { text += String.Join(", ", Items.Select(i => i.ToString())); } else { text += "[null]"; } return(text); }
public string ToQueryString() { string delimeter = "?"; ToStringHelper sb = new ToStringHelper(); append(ref delimeter, "name", Name, sb); append(ref delimeter, "uid", UID, sb); append(ref delimeter, "gid", GID, sb); append(ref delimeter, "comment", Comment, sb); append(ref delimeter, "home", Home, sb); append(ref delimeter, "shell", Shell, sb); return(sb.ToString()); }
public string ToQueryString() { string delimeter = "?"; ToStringHelper sb = new ToStringHelper(); append(ref delimeter, "name", Name, sb); append(ref delimeter, "gid", GID, sb); foreach (string member in Member) { append(ref delimeter, "member", member, sb); } return(sb.ToString()); }
/// <summary> /// Returns a string version of a Sheet Object for test logging purposes /// </summary> /// <param name="sheet"></param> /// <returns></returns> public static string DisplayText(Sheet sheet) { ToStringHelper toStringHelper = new ToStringHelper(); toStringHelper.Append("\r\nSheet\r\n"); toStringHelper.AppendProperty("Id", sheet.Id); toStringHelper.AppendProperty("Name", sheet.Name); toStringHelper.AppendProperty("Permalink", sheet.Permalink); toStringHelper.AppendProperty("AccessLevel", sheet.AccessLevel); foreach (Column column in sheet.Columns) { toStringHelper.Append(ColumnHelper.DisplayText(column)); } return(toStringHelper.ToString()); }
/// <summary> /// Returns a string version of a Column Object for test logging purposes /// </summary> /// <param name="sheet"></param> /// <returns></returns> public static string DisplayText(Column column) { ToStringHelper toStringHelper = new ToStringHelper(); toStringHelper.Append("\r\nColumn\r\n"); toStringHelper.AppendProperty("Id", column.Id); toStringHelper.AppendProperty("Version", column.Version); toStringHelper.AppendProperty("Index", column.Index); toStringHelper.AppendProperty("Primary", column.Primary); toStringHelper.AppendProperty("Title", column.Title); toStringHelper.AppendProperty("Type", column.Type); toStringHelper.AppendProperty("Validation", column.Validation); toStringHelper.AppendProperty("Symbol", column.Symbol); toStringHelper.AppendProperty("AutoNumberFormat", column.AutoNumberFormat); return(toStringHelper.ToString()); }
private void ProcessItems(IUnitOfWork db, IList <ListingFBAEstFeeDTO> items) { Log.Debug("ProcessItems begin"); //Mark all except parsed as removed var removedList = db.ListingFBAEstFees.ProcessRemoved(items.Select(r => r.SKU)); foreach (var removedItem in removedList) { Log.Debug("Mark as removed, SKU=" + removedItem); } foreach (var item in items) { Log.Debug("Stored item:"); ToStringHelper.ToString(item); db.ListingFBAEstFees.CreateOrUpdate(item, DateTime.UtcNow); } Log.Debug("ProcessItems end"); }
public virtual ActionResult GetSizesInfo(long[] sizeIdList) { LogI("GetSizesInfo: " + ToStringHelper.ToString(sizeIdList)); var results = new List <StyleItemViewModel>(); if (sizeIdList != null) { var sizes = Db.Sizes.GetAllWithGroupAsDto() .Where(s => sizeIdList.Contains(s.Id)) .ToList(); results = sizes.Select(s => new StyleItemViewModel() { SizeId = s.Id, Size = s.Name, SizeGroupName = s.SizeGroupName, SizeGroupId = s.SizeGroupId, }).ToList(); } return(Json(new ValueResult <IList <StyleItemViewModel> >(true, "", results), JsonRequestBehavior.AllowGet)); }
public override void VisitBinaryOpNode(BinaryOpNode binop) { if (binop == null) { return; } var line = new ThreeAddrLine(); line.Accum = GenNewTemporaryVariable(); if (binop.LeftNode != null) { binop.LeftNode.Visit(this); line.LeftOp = GetLastLine().Accum; } binop.RightNode.Visit(this); line.RightOp = GetLastLine().Accum; line.OpType = ToStringHelper.ToString(binop.OpType); line.Label = GenNewLabel(); Data.Add(line); }
public override string ToString() { return(ToStringHelper.ToString(this)); }
public override string ToString() { var text = ToStringHelper.ToString(this); return(text); }
public long Apply(IUnitOfWork db, IDbFactory dbFactory, ILogService log, ICacheService cache, IPriceManager priceManager, IStyleItemHistoryService styleItemHistory, ISystemActionService actionService, DateTime when, long?by) { var style = db.Styles.Get(StyleId); style.UpdateDate = when; style.UpdatedBy = by; style.ReSaveDate = when; style.ReSaveBy = by; var excessiveShipmentAttr = db.StyleFeatureTextValues.GetAll().FirstOrDefault(sv => sv.StyleId == style.Id && sv.FeatureId == StyleFeatureHelper.EXCESSIVE_SHIPMENT); if (excessiveShipmentAttr == null) { excessiveShipmentAttr = new Core.Entities.Features.StyleFeatureTextValue() { StyleId = StyleId, CreateDate = when, CreatedBy = by, FeatureId = StyleFeatureHelper.EXCESSIVE_SHIPMENT, }; db.StyleFeatureTextValues.Add(excessiveShipmentAttr); } excessiveShipmentAttr.Value = ExcessiveShipmentAmount.HasValue ? ExcessiveShipmentAmount.ToString() : null; var wasAnyChanges = false; var wasAnyMinMaxChanges = false; if (Sizes != null && Sizes.Any()) { var styleItems = db.StyleItems.GetFiltered(si => si.StyleId == StyleId).ToList(); foreach (var size in Sizes) //Update prices (marking when/by) { var changeType = PriceChangeSourceType.None; string tag = null; bool wasChanged = false; var minMaxPriceChanged = false; var styleItem = styleItems.FirstOrDefault(si => si.Id == size.StyleItemId); if (styleItem != null) { StyleItemSale sale = size.SaleId.HasValue ? db.StyleItemSales .GetAll() .FirstOrDefault(s => s.Id == size.SaleId.Value) : null; if (sale == null) //If no sale Id remove all exist sales (Remove Sale action was performed) { IList <StyleItemSale> saleList = db.StyleItemSales .GetAll() .Where(s => s.StyleItemId == styleItem.Id && !s.IsDeleted) .ToList(); foreach (var toRemove in saleList) { log.Info("Sale mark removed, saleId=" + toRemove.Id + ", Info=" + ToStringHelper.ToString(toRemove)); toRemove.IsDeleted = true; db.Commit(); styleItemHistory.AddRecord(StyleItemHistoryTypes.RemoveSale, styleItem.Id, new HistorySaleData() { SaleStartDate = toRemove.SaleStartDate, SaleEndDate = toRemove.SaleEndDate, }, by); } } var salePrice = size.InitSalePrice ?? size.NewSalePrice; var sfpSalePrice = size.InitSFPSalePrice ?? size.NewSFPSalePrice; if (salePrice.HasValue || sfpSalePrice.HasValue) { //Get Default markets var markets = MarketPriceEditViewModel.GetForStyleItemId(db, dbFactory, size.StyleItemId, salePrice, sfpSalePrice); if ((SizePriceViewModel.SizeMarketApplyModes)size.MarketMode == SizePriceViewModel.SizeMarketApplyModes.OnlyAmazonUS) { markets = markets.Where(m => m.MarketplaceId == MarketplaceKeeper.AmazonComMarketplaceId).ToList(); } //Save Default markets if ((SizePriceViewModel.SizePriceApplyModes)size.ApplyMode == SizePriceViewModel.SizePriceApplyModes.Sale) { var results = MarketPriceEditViewModel.ApplySale(db, log, size.StyleItemId, markets, when, by); if (results.Any()) { var saleId = results[0].SaleId; sale = db.StyleItemSales.GetAll().FirstOrDefault(s => s.Id == saleId); } } } if ((SizePriceViewModel.SizePriceApplyModes)size.ApplyMode == SizePriceViewModel.SizePriceApplyModes.Permanent) { //Get Default markets var markets = MarketPriceEditViewModel.GetForStyleItemId(db, dbFactory, size.StyleItemId, salePrice, sfpSalePrice); if ((SizePriceViewModel.SizeMarketApplyModes)size.MarketMode == SizePriceViewModel.SizeMarketApplyModes.OnlyAmazonUS) { markets = markets.Where(m => m.MarketplaceId == MarketplaceKeeper.AmazonComMarketplaceId).ToList(); } //NOTE: also mark exist sale as deleted MarketPriceEditViewModel.ApplyPermanent(db, log, priceManager, size.StyleItemId, markets, when, by); styleItemHistory.AddRecord(StyleItemHistoryTypes.AddPermanentSale, styleItem.Id, new HistorySaleData() { SalePrice = salePrice }, by); } if (sale != null) { // if (size.NewSalePrice.HasValue) // { // log.Info("Updated sale price, saleId=" + sale.Id + ", to=" + size.NewSalePrice + ", SFP=" + size.NewSFPSalePrice); // MarketPriceEditViewModel.UpdateSalePrices(db, // size.StyleItemId, // sale.Id, // size.NewSalePrice.Value, // size.NewSFPSalePrice); // } sale.SaleStartDate = size.SaleStartDate; sale.SaleEndDate = size.SaleEndDate; sale.MaxPiecesMode = MaxPiecesOnSale.HasValue ? (int)MaxPiecesOnSaleMode.ByStyle : (int)MaxPiecesOnSaleMode.BySize; sale.MaxPiecesOnSale = size.MaxPiecesOnSale ?? MaxPiecesOnSale; db.Commit(); styleItemHistory.AddRecord(StyleItemHistoryTypes.AddSale, styleItem.Id, new HistorySaleData() { SalePrice = size.NewSalePrice, SaleStartDate = size.SaleStartDate, SaleEndDate = size.SaleEndDate }, by); } minMaxPriceChanged = styleItem.MinPrice != size.MinPrice || styleItem.MaxPrice != size.MaxPrice; if (minMaxPriceChanged) { styleItem.MinPrice = size.MinPrice; styleItem.MaxPrice = size.MaxPrice; db.Commit(); } wasAnyMinMaxChanges = wasAnyMinMaxChanges || minMaxPriceChanged; } } //NOTE: update all listing, ex. change price, start/end date, e.t.c. var styleListingIds = db.Listings.GetViewListingsAsDto(true) .Where(l => l.StyleId == StyleId) .Select(l => l.Id) .ToList(); var dbListings = db.Listings.GetAll().Where(l => styleListingIds.Contains(l.Id)).ToList(); foreach (var dbListing in dbListings) { dbListing.PriceUpdateRequested = true; if (wasAnyMinMaxChanges) { actionService.AddAction(db, SystemActionType.UpdateOnMarketProductPriceRule, dbListing.SKU, null, null, by); } } db.Commit(); } cache.RequestStyleIdUpdates(db, new List <long> { StyleId }, UpdateCacheMode.IncludeChild, AccessManager.UserId); return(StyleId); }
public override void VisitForCycleNode(ForCycleNode fc) { Console.WriteLine(Tag + " VisitForCycleNoe"); fc.Step.Visit(this); if (GetLastLine().Accum.StartsWith(TempVariableName)) { GetLastLine().Accum = "lc" + GetLastLine().Label; } var step = GetLastLine().Accum; fc.LeftBound.Visit(this); var L = GetLastLine().Accum; fc.RightBound.Visit(this); if (GetLastLine().Accum.StartsWith(TempVariableName)) { GetLastLine().Accum = "lr" + GetLastLine().Label; } var R = GetLastLine().Accum; var initCounterLine = new ThreeAddrLine(); initCounterLine.Accum = fc.Counter.Name; initCounterLine.OpType = ThreeAddrOpType.Assign; initCounterLine.RightOp = L; initCounterLine.Label = GenNewLabel(); Data.Add(initCounterLine); var startLoopLabel = GenNewLabel(); var checkLine = new ThreeAddrLine(); checkLine.Label = startLoopLabel; checkLine.Accum = GenNewTemporaryVariable(); checkLine.LeftOp = fc.Counter.Name; checkLine.OpType = ToStringHelper.ToString(BinaryOpType.Less); checkLine.RightOp = R; Data.Add(checkLine); var whileLine = new ThreeAddrLine(); whileLine.Label = GenNewLabel(); whileLine.LeftOp = GetLastLine().Accum; whileLine.OpType = ThreeAddrOpType.IfGoto; Data.Add(whileLine); var outsideWhileLine = new ThreeAddrLine(); outsideWhileLine.Label = GenNewLabel(); outsideWhileLine.OpType = ThreeAddrOpType.Goto; Data.Add(outsideWhileLine); whileLine.RightOp = GenNewLabel(); fc.Stat.Visit(this); var counterIncLine = new ThreeAddrLine(); counterIncLine.Label = GenNewLabel(); counterIncLine.Accum = fc.Counter.Name; counterIncLine.LeftOp = fc.Counter.Name; counterIncLine.OpType = ToStringHelper.ToString(BinaryOpType.Plus); counterIncLine.RightOp = step; Data.Add(counterIncLine); var gotoStartLine = new ThreeAddrLine(); gotoStartLine.Label = GenNewLabel(); gotoStartLine.OpType = ThreeAddrOpType.Goto; gotoStartLine.RightOp = startLoopLabel; Data.Add(gotoStartLine); InsertNop(); outsideWhileLine.RightOp = GetLastLine().Label; }