增加项目,分层

This commit is contained in:
chfei committed 2026-09-11 19:11:12 +08:00
1 parent 6e995a5bdb
commit 0a3e5af6a9
234 files changed
+26994 -1

No files matched your search

@@ -0,0 +1,89 @@
using System.IO;
namespace Store.Product.Models.PublishParameters.Image
{
/// <summary>
/// 上传图片参数
/// </summary>
public class ImageParameters
{
/// <summary>
/// 是否随机删除一张详情图
/// </summary>
public bool IsRandomDelDetailImg { get; set; }
/// <summary>
/// 是否随机主图
/// </summary>
public bool IsRandomMainImg { get; set; }
/// <summary>
/// 复制上家主图视频
/// </summary>
public bool IsUploadVideoByCopy { get; set; }
/// <summary>
/// 上传自己视频空间索引视频
/// </summary>
public SwitchParams<int> IsUploadVideoFromToIndex { get; set; }
/// <summary>
/// Logo水印
/// </summary>
public SwitchParams<System.Drawing.Image> IsLogoWaterMark { get; set; }
/// <summary>
/// 图片质量百分比
/// </summary>
public int PicQuality { get; set; }
/// <summary>
/// 商铺文字水印
/// </summary>
public bool IsShopNameWaterMark { get; set; }
/// <summary>
/// 是否随机属性图充当主图
/// </summary>
public bool IsRandomPropImgFillToMainImg { get; set; }
/// <summary>
/// 简单的电脑详情图
/// </summary>
public bool IsSimpleContentPc { get; set; }
/// <summary>
/// 是否删除主图 索引
/// </summary>
public SwitchParams<int> IsDelMainImgByIndex { get; set; } = new SwitchParams<int>();
/// <summary>
/// 是否删除详情图 索引 在之前
/// </summary>
public SwitchParams<int> IsDelDetailImgByFromToIndex { get; set; } = new SwitchParams<int>();
/// <summary>
/// 是否开启 详情图 最大上传
/// </summary>
public SwitchParams<int> IsOnlyUpDetailImgMaxCount { get; set; } = new SwitchParams<int>();
/// <summary>
/// 主图 白底最后一张
/// </summary>
public bool IsMainImgBackgroundWihiteLast { get; set; }
/// <summary>
/// 是否盗链
/// </summary>
public bool IsSteal { get; set; } = false;
/// <summary>
/// 是否保留前x张主图
/// </summary>
public SwitchParams<int> IsKeepMainImgNum { get; set; } = new SwitchParams<int>();
public ImageParameters()
{
IsLogoWaterMark = new SwitchParams<System.Drawing.Image>();
//string brandPath = Path.Combine(GlobalConfig.AppDirectory + "Brand\\brand.png");
//if(File.Exists(brandPath))
//{
// IsLogoWaterMark.Value = System.Drawing.Image.FromFile(brandPath);
//}
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 计算操作符
/// </summary>
public enum ComputationType
{
/// <summary>
/// 加
/// </summary>
ADD,
/// <summary>
/// 减法
/// </summary>
SUB
}
}
@@ -0,0 +1,60 @@
using Store.Product.Models.Product.Sku;
using System.Linq;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 高低价格配置
/// </summary>
public class HighLowPrice : PriceConfigBase
{
public override PriceStrategyType PriceType => PriceStrategyType.高低价格;
/// <summary>
/// 低价倍数
/// </summary>
public decimal LowMultiples { get; set; } = 1;
/// <summary>
/// 其他倍数
/// </summary>
public decimal OtherMultiples { get; set; } = 1;
/// <summary>
/// 计算价格
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public override decimal ComputedPrice(decimal oldPrice)
{
return oldPrice * OtherMultiples;
}
/// <summary>
/// 计算最低价
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public decimal ComputedLowPrice(decimal oldPrice)
{
return oldPrice * LowMultiples;
}
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
{
decimal minPrice = skuMaps.Min(a => a.Price);
foreach (var item in skuMaps)
{
if (item.Price == minPrice)
{
ComputedLowPrice(item.Price);
}
else
{
item.Price = ComputedPrice(item.Price);
}
}
return skuMaps;
}
}
}
@@ -0,0 +1,67 @@
using Store.Product.Models.Product.Sku;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 翻倍价格配置
/// </summary>
public class MultiplesPrice : PriceConfigBase
{
public override PriceStrategyType PriceType => PriceStrategyType.常规价格;
/// <summary>
/// 翻 x 倍
/// </summary>
public int Multiples { get; set; } = 1;
/// <summary>
/// 计算
/// </summary>
public ComputationType Computation { get; set; } = ComputationType.ADD;
/// <summary>
/// 基础加价
/// </summary>
public decimal AddPrice { get; set; }
public MultiplesPrice() { }
/// <summary>
/// 翻倍价格配置
/// </summary>
/// <param name="multiples">倍数</param>
/// <param name="addprice">加价</param>
public MultiplesPrice(int multiples, decimal addprice)
{
Multiples = multiples;
AddPrice = addprice;
}
/// <summary>
/// 计算价格
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public override decimal ComputedPrice(decimal oldPrice)
{
var newPrice = oldPrice;
newPrice = oldPrice * Multiples;
switch (Computation)
{
case ComputationType.ADD:
newPrice = newPrice + AddPrice;
break;
case ComputationType.SUB:
newPrice = newPrice - AddPrice;
break;
default:
break;
}
return newPrice;
}
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
{
foreach (var item in skuMaps)
{
item.Price = ComputedPrice(item.Price);
}
return skuMaps;
}
}
}
@@ -0,0 +1,39 @@
using Store.Product.Models.Product.Sku;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 价格配置
/// </summary>
public abstract class PriceConfigBase
{
/// <summary>
/// 价格类型
/// </summary>
public abstract PriceStrategyType PriceType { get; }
///// <summary>
///// 快递费是否增加到商品价格
///// </summary>
//public bool IsExpressAddPrice { get; set; } = false;
///// <summary>
///// 是否随机增加金额 0-1元
///// </summary>
//public bool IsRandomAddPrice { get; set; } = false;
/// <summary>
/// 计算价格
/// </summary>
/// <returns></returns>
public abstract decimal ComputedPrice(decimal oldPrice);
/// <summary>
/// 计算价格
/// </summary>
/// <returns></returns>
public abstract SkuMaps ComputedPrice(SkuMaps skuMaps);
}
}
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
///
/// </summary>
public class PriceStrategyFactory
{
public static PriceConfigBase GetPriceStrategy(PriceStrategyType strategyType)
{
PriceConfigBase priceConfig;
switch (strategyType)
{
case PriceStrategyType.常规价格:
priceConfig = new MultiplesPrice();
break;
case PriceStrategyType.高低价格:
priceConfig = new HighLowPrice();
break;
case PriceStrategyType.分段价格:
priceConfig = new SectionPrice();
break;
default:
priceConfig = null;
break;
}
return priceConfig;
}
}
}
@@ -0,0 +1,12 @@
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 价格策略类型
/// </summary>
public enum PriceStrategyType
{
常规价格 = 0,
高低价格 = 1,
分段价格 = 2
}
}
@@ -0,0 +1,72 @@
using Store.Product.Models.Product.Sku;
using System.Collections.Generic;
using System.Linq;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 区间价格配置
/// </summary>
public class SectionPrice : PriceConfigBase
{
public override PriceStrategyType PriceType => PriceStrategyType.分段价格;
/// <summary>
/// 区间列表
/// </summary>
public List<SectionItemPrice> SectionList { get; set; } = new List<SectionItemPrice>();
/// <summary>
/// 计算价格
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public override decimal ComputedPrice(decimal oldPrice)
{
var newPrice = oldPrice;
if (SectionList != null && SectionList.Count > 0)
{
foreach (var item in SectionList)
{
if (item.BeginPrice < newPrice && newPrice < item.EndPrice)
{
newPrice = item.ComputedPrice(newPrice);
}
}
if (newPrice == oldPrice)
{
newPrice = SectionList.Last().ComputedPrice(newPrice);
}
}
return newPrice;
}
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
{
foreach (var item in skuMaps)
{
item.Price = ComputedPrice(item.Price);
}
return skuMaps;
}
/// <summary>
/// 指定区间价格
/// </summary>
public class SectionItemPrice : MultiplesPrice
{
/// <summary>
/// 开始价格
/// </summary>
public decimal BeginPrice { get; set; } = 0;
/// <summary>
/// 结束价格
/// </summary>
public decimal EndPrice { get; set; } = 10000000;
}
}
}
@@ -0,0 +1,66 @@
using Newtonsoft.Json;
using Store.Product.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters
{
/// <summary>
/// 商品存储状态
/// </summary>
public class ProductStorage
{
/// <summary>
/// 立即上架
/// </summary>
public static ProductStorage OnSale
{
get
{
return new ProductStorage() { Status = ProductStorageStatus.立刻上架 };
}
}
/// <summary>
/// 放入仓库
/// </summary>
public static ProductStorage InStock
{
get
{
return new ProductStorage() { Status = ProductStorageStatus.放入仓库 };
}
}
/// <summary>
/// 定时上架
/// </summary>
/// <returns></returns>
public static ProductStorage TimedOnSale(DateTime time)
{
return new ProductStorage { Status = ProductStorageStatus.定时上架, ShelfTime = time };
}
public ProductStorage()
{
}
public ProductStorage(ProductStorageStatus status, DateTime? time = null)
{
Status = status;
if (Status == ProductStorageStatus.定时上架)
{
ShelfTime = time;
}
}
/// <summary>
/// 发布商品状态
/// </summary>
public ProductStorageStatus Status { get; set; } = ProductStorageStatus.立刻上架;
/// <summary>
/// 定时上架时间
/// </summary>
public DateTime? ShelfTime { get; set; }
}
}
@@ -0,0 +1,111 @@
using Store.Framework.Models;
using Store.Framework.Models.Product;
using Store.Product.Enums;
using Store.Product.Models.Product;
using Store.Product.Models.PublishParameters.Image;
using Store.Product.Models.PublishParameters.Price;
using Store.Product.Models.PublishParameters.Sku;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Product.Models.PublishParameters;
public class PublishParameters
{
/// <summary>
/// 价格配置
/// </summary>
public PriceConfigBase PriceStrategy { get; set; }
/// <summary>
/// 图片上传参数
/// </summary>
public ImageParameters UpImageParams { get; set; } = new ImageParameters();
#region 重要参数
/// <summary>
/// Sku 上传参数
/// </summary>
public SkuParameters SkuParams { get; set; } = new SkuParameters();
/// <summary>1
/// 存储类型 上架Or仓库 Stock
/// </summary>
public ProductStorage StorageType { get; set; } = new ProductStorage();
/// <summary>
/// 店铺上传最大限制
/// </summary>
public int ShopUpMaxCount { get; set; }
/// <summary>
/// 过滤商品价格
/// </summary>
public SwitchParams<Tuple<int, int>> IsFilterPrice { get; set; } = new SwitchParams<Tuple<int, int>>(false, new Tuple<int, int>(0, int.MaxValue));
/// <summary>
/// 运费模板类型
/// </summary>
public FreightTemplateType FreightTemplateType { get; set; } = FreightTemplateType.Fixed;
///// <summary>
/// 运费模板
/// </summary>
//public FreightTemplateModel FreightTemplate { get; set; }
/// <summary>
/// 标题前缀
/// </summary>
public string TitlePrefix { get; set; }
#endregion
#region 其他参数
/// <summary>
/// 自定义删除标题关键字
/// </summary>
public bool IsRemoveCustomTitleKeywors { get; set; }
/// <summary>
/// 自定义过滤标题关键字
/// </summary>
public bool IsFilterCustomTitleKeywors { get; set; }
/// <summary>
/// 自定义类目
/// </summary>
public SwitchParams<CategoryModel> IsCustomCategory { get; set; } = new SwitchParams<CategoryModel>();
/// <summary>
/// 自定义描述
/// </summary>
public string CustomDescription { get; set; }
/// <summary>
/// 过滤非法标题
/// </summary>
public bool IsFilterIllegalTitle { get; set; }
/// <summary>
/// 过滤不包邮
/// </summary>
public bool IsFilterPackage { get; set; }
/// <summary>
/// 是否设置最低价库存
/// </summary>
public SwitchParams<int> IsSetLowPriceStock { get; set; } = new SwitchParams<int>();
/// <summary>
/// 是否使用代理
/// </summary>
public bool IsProxy { get; set; }
/// <summary>
/// 是否自动删除标题违规词语
/// </summary>
public bool IsRemoveIllegalTitle { get; set; }
#endregion
}
@@ -0,0 +1,28 @@
using Store.Product.Models.PublishParameters.Price;
namespace Store.Product.Models.PublishParameters.Sku
{
/// <summary>
/// 自定义Sku
/// </summary>
public class CustomSku
{
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 翻倍
/// </summary>
public MultiplesPrice Multiples { get; set; }
/// <summary>
/// 图片地址
/// </summary>
public string ImagePath { get; set; }
/// <summary>
/// 库存
/// </summary>
public int StockCount { get; set; }
}
}
@@ -0,0 +1,27 @@
using Store.Product.Models.PublishParameters;
namespace Store.Product.Models.PublishParameters.Sku
{
/// <summary>
/// 上传Sku配置
/// </summary>
public class SkuParameters
{
/// <summary>
/// Sku名称随机增加特殊字符
/// </summary>
public bool IsSkuPropertyRandomChar { get; set; }
/// <summary>
/// 随机删除Sku
/// </summary>
public bool IsRandomDelSku { get; set; }
/// <summary>
/// 自定义Sku
/// </summary>
public SwitchParams<CustomSku> IsCustomSku { get; set; } = new SwitchParams<CustomSku>();
/// <summary>
/// 是否固定截取
/// </summary>
public bool IsSkuFixedSplit { get; set; }
}
}
@@ -0,0 +1,24 @@
namespace Store.Product.Models.PublishParameters
{
/// <summary>
/// 请求参数 是否开启 和值
/// </summary>
/// <typeparam name="T"></typeparam>
public class SwitchParams<T>
{
/// <summary>
/// 是否开启
/// </summary>
public bool IsOpened { get; set; } = false;
/// <summary>
/// 值
/// </summary>
public T Value { get; set; } = default;
public SwitchParams() { }
public SwitchParams(bool isopen, T value)
{
IsOpened = isopen;
Value = value;
}
}
}
@@ -0,0 +1,263 @@
using AllBase.Model.DBModel;
using AllBase.Model.Param.WXParam;
using AllBase.Model.Result;
using AllBase.Model.Result.PDDResult;
using AllBase.Model.Result.WXResult;
using Newtonsoft.Json.Linq;
using Store.Framework.Extensions;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace Store.Product.Models.PublishParameters.Wx;
/// <summary>
/// Store.Product 新的微信商品上传参数实体。
/// 说明:这里不修改 AllBase 中已有上传参数实体,当前作为迁移期承载对象复用其字段结构。
/// </summary>
public class WxProductUploadParam
{
public WxProductUploadSource Source { get; set; } = new();
public WXUploadProductInitParam InitParameter { get; set; } = new();
public WXUploadProductParam ProductParameter { get; set; } = new();
public WxProductPublishState State { get; set; } = new();
public WxProductUploadOptions Options { get; set; } = new();
public WxProductUploadRuntime Runtime { get; set; } = new();
/// <summary>步骤正常提前结束或最终成功时写入的返回 JSON。</summary>
public string Result { get; set; }
/// <summary>正常提前结束发布时置为 true,流水线不再执行后续步骤。</summary>
public bool IsCompleted { get; set; }
}
public class WxProductUploadSource
{
public ShopLoginInfo Shop { get; set; }
public KJDDBProduct DbProduct { get; set; }
public TemuDBProductSelect SelectProduct { get; set; }
public DateTime StartTime { get; set; } = DateTime.Now;
}
/// <summary>
/// 原 UploadProduct 方法中跨 #region 使用的可变状态。
/// TODO(迁移): 个别字段当前为 dynamic,需按 Store.Product 最终 DTO 改为明确类型。
/// </summary>
public class WxProductPublishState
{
public int CommissionRate { get; set; }
public int MinCommissionRate { get; set; }
public int MaxCommissionRate { get; set; }
public int CommissionRateChange { get; set; }
public int? FromCommissionRate { get; set; }
public WXGetEditProductInfoLite WxEditProdInfo { get; set; }
public JObject ProdJObject { get; set; } = new();
public bool IsChangeImgDic { get; set; }
public Dictionary<string, string> WxImgMapDic { get; set; } = new();
public PDDProductInfo ProdInfo { get; set; }
public int MainImgCount { get; set; }
public bool NeedAddRandomBlock { get; set; }
public bool WantAddRandomBlock { get; set; }
public WXShopTokenInfo Token { get; set; }
public string ProdTitle { get; set; }
public string ExtCode { get; set; }
public List<gallery_item> MainGalleries { get; set; } = new();
public List<long> AiCateIdLst { get; set; } = new();
public string GetCateRst { get; set; }
public JObject JCateRst { get; set; }
public long LeafCatId { get; set; }
public WxCatBoundInfo Bound { get; set; }
public int MaxBound { get; set; }
public int MinBound { get; set; }
public string SpBrandId { get; set; }
public string SpBrandName { get; set; }
public string ShippingTemplateJson { get; set; }
public int ShipPrice { get; set; }
public string ExpressRst { get; set; }
public List<gallery_item> DetailGalleries { get; set; } = new();
public WXUploadProductInfoRecommendParam RecommendParamRst { get; set; } = new();
public allAttrParam ProductAttr { get; set; }
public int MaxSkuSpecCnt { get; set; }
public int SkuIndex { get; set; }
public int Id { get; set; }
public long CatId { get; set; }
public long FCatId { get; set; }
public long ValueCatId { get; set; }
public Dictionary<string, long> DicSpecParentNameId { get; set; } = new();
public Dictionary<string, long> DicSpecParentNameCatId { get; set; } = new();
public Dictionary<string, long> DicSpecNameFCatId { get; set; } = new();
public Dictionary<string, long> DicSpecNameCatId { get; set; } = new();
public string UploadDraftRst { get; set; }
public string CommissionRstStr { get; set; }
public string DefaultAdultBrandId { get; set; }
public bool IsWxNotUseSoftwareDefaultAddressOnce { get; set; }
public List<WXShopTokenInfo> WxShopTokenInfoList { get; set; } = new();
public List<wx_qualification_image_info> QualificationImages { get; set; } = new();
public List<string> ForceFilterKeywords { get; set; } = new();
public List<dynamic> AddPriceRules { get; set; } = new();
public dynamic WxUploadRule { get; set; }
public string PddProductCates { get; set; }
public dynamic UploadDraftProductList { get; set; }
}
/// <summary>
/// UploadProduct 从窗体控件和配置读取的入参快照。
/// TODO(迁移): 后续可将这些字段逐步替换成 Store.Product 自己的发布规则模型。
/// </summary>
public class WxProductUploadOptions
{
public WxProductUploadFormState Form { get; set; } = new();
}
/// <summary>
/// 原方法依赖的窗体操作与通用上传能力适配入口。
/// </summary>
public class WxProductUploadRuntime
{
public object Host { get; set; }
public dynamic Cell { get; set; } = new WxUploadCellState();
public dynamic CancellationTokenSource { get; set; } = new WxUploadCancellationState();
public Func<string, string> GetAiImg { get; set; }
public Func<ShopLoginInfo, string, object, bool, string> UploadImgByUrl { get; set; }
public Func<ShopLoginInfo, Bitmap, object, string> UploadImgByBitmap { get; set; }
public GetImgBase64ForApiHandler GetImgBase64ForApi { get; set; }
public Action<string> SetStatus { get; set; }
public Action Cancel { get; set; }
public Action<string> ShowError { get; set; }
}
public delegate string GetImgBase64ForApiHandler(
out string errorMsg,
string imgUrl,
bool needAddRandomBlock,
bool wantAddRandomBlock,
int imgWidth = 0,
int imgHeight = 0,
bool wantAddRandomBorder = false);
public class WxUploadCellState
{
private object _value;
public object Value
{
get => _value;
set => _value = value;
}
}
public class WxUploadCancellationState
{
public Action CancelAction { get; set; }
public void Cancel()
{
CancelAction?.Invoke();
}
}
/// <summary>
/// 原窗体控件的状态代理,避免 Store.Product 直接引用 WinForms 控件类型。
/// </summary>
public class WxProductUploadFormState
{
public dynamic chkFissionGoodsName { get; set; } = new WxControlState();
public dynamic txtFissionTitle { get; set; } = new WxControlState();
public dynamic chkSkipUploaded { get; set; } = new WxControlState();
public dynamic chkCommission { get; set; } = new WxControlState();
public dynamic cmbCommissionAddOrReduce { get; set; } = new WxControlState();
public dynamic txtCommissionChangeValue { get; set; } = new WxControlState();
public dynamic txtMinUpCommission { get; set; } = new WxControlState();
public dynamic txtMaxUpCommission { get; set; } = new WxControlState();
public dynamic chkImgRandomBlock { get; set; } = new WxControlState();
public dynamic chkRandomMainImgOrder { get; set; } = new WxControlState();
public dynamic chkRandomDetailImgOrder { get; set; } = new WxControlState();
public dynamic chkFissionRandomPriceChange { get; set; } = new WxControlState();
public dynamic txtFissionRandomPriceChange { get; set; } = new WxControlState();
public dynamic chkHighestPriceSku { get; set; } = new WxControlState();
public dynamic chkLowestPriceSku { get; set; } = new WxControlState();
public dynamic chkSameSpecPriceUp { get; set; } = new WxControlState();
public dynamic chkSameSpecPriceDown { get; set; } = new WxControlState();
public dynamic txtMinPrice { get; set; } = new WxControlState();
public dynamic txtMaxPrice { get; set; } = new WxControlState();
public dynamic txtReplaceText { get; set; } = new WxControlState();
public dynamic chkSkipReplaceText { get; set; } = new WxControlState();
public dynamic chkRemoveSpecialChar { get; set; } = new WxControlState();
public dynamic chkUseWXComplateProd { get; set; } = new WxControlState();
public dynamic chkUseRecommand { get; set; } = new WxControlState();
public dynamic cmbSpBrandName { get; set; } = new WxControlState();
public dynamic txtFilterBoundMax { get; set; } = new WxControlState();
public dynamic txtFilterBoundMin { get; set; } = new WxControlState();
public dynamic txtMainBorderImgCount { get; set; } = new WxControlState();
public dynamic txtDetailBorderImgCount { get; set; } = new WxControlState();
public dynamic chkRandomImgBorder { get; set; } = new WxControlState();
public dynamic chkAiImage { get; set; } = new WxControlState();
public dynamic txtAiImgCount { get; set; } = new WxControlState();
public dynamic chkFreightInsurance { get; set; } = new WxControlState();
public dynamic chkUseShanghaiReturnOrderAddress { get; set; } = new WxControlState();
public dynamic chkPreSale { get; set; } = new WxControlState();
public dynamic chkDefaultBestBefore { get; set; } = new WxControlState();
public dynamic txtDefaultBestBefore { get; set; } = new WxControlState();
public dynamic chkTestNoAuditUpload { get; set; } = new WxControlState();
public dynamic chkUpDraft { get; set; } = new WxControlState();
public dynamic chkIsSubmitSuccess { get; set; } = new WxControlState();
public dynamic dgvShop { get; set; } = new WxControlState();
}
public class WxControlState
{
public bool Checked { get; set; }
public string Text { get; set; } = "";
public decimal Value { get; set; }
public object SelectedValue { get; set; }
public object SelectedItem { get; set; }
public int SelectedIndex { get; set; } = -1;
public dynamic Items { get; set; } = new List<object>();
public static WxControlState FromCheckBox(dynamic checkBox)
{
return new WxControlState
{
Checked = checkBox?.Checked == true,
Text = checkBox?.Text ?? ""
};
}
public static WxControlState FromTextBox(dynamic textBox)
{
return new WxControlState
{
Text = textBox?.Text ?? ""
};
}
public static WxControlState FromComboBox(dynamic comboBox)
{
if (comboBox == null)
{
return new WxControlState();
}
return new WxControlState
{
Text = comboBox.Text ?? "",
SelectedValue = comboBox.SelectedValue,
SelectedItem = comboBox.SelectedItem,
SelectedIndex = comboBox.SelectedIndex
};
}
public static WxControlState FromNumericUpDown(dynamic numericUpDown)
{
return new WxControlState
{
Value = numericUpDown?.Value ?? 0m,
Text = numericUpDown?.Text ?? ""
};
}
}