old_flsystem/应用/TBAppraisalTools/Config.cs

345 lines
13 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Api.Framework.Enums;
using Api.Framework.SDK;
using Api.Framework.Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UI.Framework.Entitys;
using static TBAppraisalTools.Enums;
namespace TBAppraisalTools
{
[Config(Name = "插件-评价工具")]
public class Config
{
/// <summary>
/// 登录的淘宝Cookies
/// </summary>
[Browsable(false)]
public List<TbLoginInfo> TbLoginInfos { get; set; }
#region
public string _couponDenomination;
/// <summary>
/// 优惠券面值比例
/// </summary>
[
Category("1、优惠券配置"), DisplayName("01.优惠券面值比例"), DefaultValue("50-80"),
Description(@"优惠券面值比例是以商品实价的基础上进行比例的计算.单位 百分比")
]
public string CouponDenomination
{
get { return _couponDenomination; }
set
{
if (string.IsNullOrWhiteSpace(value)) throw new Exception("优惠券比例不能为空");
var rates = value.Trim().Split('-');
if (rates.Length == 2)
{
if (int.Parse(rates[0]) >= int.Parse(rates[1])) throw new Exception("比例区间必须前小后大");
_couponDenomination = value;
}
else
throw new Exception("比例格式不正确,请看下方说明");
}
}
/// <summary>
/// 优惠券面值取整
/// </summary>
[
Category("1、优惠券配置"), DisplayName("02.优惠券面值取整"), DefaultValue(SwitchType.开启),
Description(@"优惠券面值比例是以商品实价的基础上进行比例的计算.计算所得值取整(10的倍数),所得值必须大于10")
]
public SwitchType IsRounding { get; set; }
/// <summary>
/// 优惠券有效期计划天数
/// </summary>
[
Category("1、优惠券配置"), DisplayName("03.优惠券有效期计划天数"), DefaultValue(0),
Description(@"优惠券有效期开始日期以优惠券生成时为基准(优惠券生成时为默认有效期开始时间),增加多少天.
例如:2019年1月1号生成,设置的值为2,那么优惠券的有效期开始日期为2019年1月3号开始")
]
public int ManufacturePlansAddDay { get; set; }
private int _expirationDate;
/// <summary>
/// 优惠券有效期有效天数
/// </summary>
[
Category("1、优惠券配置"), DisplayName("04.优惠券有效期有效天数"), DefaultValue(7),
Description(@"优惠券有效期开始日期加上设置的有效天数为有效期结束时间.
例如:2019年1月3号生成,有效天数设置的值为7,那么优惠券的有效期输入日期为2019年1月10号结束")
]
public int ExpirationDate
{
get { return _expirationDate; }
set
{
if (value < 0) throw new Exception("该值不能小于零");
_expirationDate = value;
}
}
#endregion
#region
private int _analyzePage;
/// <summary>
/// 解析评价的页数
/// </summary>
[
Category("2、其他选项"), DisplayName("01.解析评价页数"), DefaultValue(2),
Description(@"解析评价页数,评价的页数必须大于0并且小于5")
]
public int AnalyzePage
{
get { return _analyzePage; }
set
{
if (value <= 0) throw new Exception("该值应该大于0");
else if (value > 6) throw new Exception("为了解析性能,评价页数不能超过5页");
_analyzePage = value;
}
}
private string _buttonPic;
/// <summary>
/// 诱导图地址
/// </summary>
[
Category("2、其他选项"), DisplayName("02.按钮图标"), DefaultValue(""),
Description(@"设置按钮图标,评价图片中间将增加一个按钮标.支持本地图片和网络图片(请填写地址)")
]
public string ButtonPic
{
get { return _buttonPic; }
set
{
try
{
var path = value.Trim();
if (string.IsNullOrWhiteSpace(path))
{
if (File.Exists(TbTools.BUTTONICO))
File.Delete(TbTools.BUTTONICO);//用户设置为空的时候,删除图片
_buttonPic = path;
}
else
{
if (File.Exists(path))
{
if (path != TbTools.BUTTONICO)
{
File.Copy(path, TbTools.BUTTONICO, true);
_buttonPic = TbTools.BUTTONICO;
}
else
throw new Exception("路径不能为保存路径");
}
else
{
try
{
Tools.DownloadImage(path, TbTools.BUTTONICO);
_buttonPic = TbTools.BUTTONICO;
}
catch (Exception)
{
throw new Exception("请输入正确的图片路径");
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
}
private string _abductionPic;
/// <summary>
/// 诱导图地址
/// </summary>
[
Category("2、其他选项"), DisplayName("03.诱导图地址"), DefaultValue(""),
Description(@"设置诱导图,可以上传一张自己认为有空的图片.支持本地图片和网络图片(请填写地址)")
]
public string AbductionPic
{
get { return _abductionPic; }
set
{
try
{
var path = value.Trim();
if (string.IsNullOrWhiteSpace(path))
{
if (File.Exists(TbTools.ABDUCTIONICO))
File.Delete(TbTools.ABDUCTIONICO);//用户设置为空的时候,删除图片
_abductionPic = path;
}
else
{
if (File.Exists(path))
{
if (path != TbTools.ABDUCTIONICO)
{
File.Copy(path, TbTools.ABDUCTIONICO, true);
_abductionPic = TbTools.ABDUCTIONICO;
}
else
throw new Exception("路径不能为保存路径");
}
else
{
try
{
Tools.DownloadImage(path, TbTools.ABDUCTIONICO);
_abductionPic = TbTools.ABDUCTIONICO;
}
catch (Exception)
{
throw new Exception("请输入正确的图片路径");
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
}
/// <summary>
/// 评论图片合成GIF
/// </summary>
[
Category("2、其他选项"), DisplayName("04.评论图片合成GIF"), DefaultValue(SwitchType.开启),
Description(@"评论图片合成GIF图片")
]
public SwitchType BondCommentPic { get; set; }
private int _PUTImage;
/// <summary>
/// Gif图片数量
/// </summary>
[
Category("2、其他选项"), DisplayName("05.Gif图片数量"), DefaultValue(5),
Description(@"转多少张图片为Gif,数量包含诱导图")
]
public int PUTImage
{
get { return _PUTImage; }
set
{
if (value <= 0) throw new Exception("该值应该大于0");
_PUTImage = value;
}
}
private string _TbItemSavePath;
/// <summary>
/// 解析后保存路径
/// </summary>
[
Category("2、其他选项"), DisplayName("06.解析后保存路径"),
Description(@"解析出来内容的保存路径")
]
public string TbItemSavePath
{
get { return _TbItemSavePath; }
set
{
if (string.IsNullOrWhiteSpace(value)) throw new Exception("保存路径不能为空");
if (!Directory.Exists(value)) throw new Exception("目录路径不正确");
else _TbItemSavePath = value;
}
}
/// <summary>
/// 正在搜索宝贝提示语
/// </summary>
[
Category("2、其他选项"), DisplayName("07.正在搜索宝贝"), DefaultValue(@"评价信息合成中....."),
Description(@"支持变量:[机器人账号][][][]"),
Editor(typeof(PropertyGridRichText), typeof(System.Drawing.Design.UITypeEditor))
]
public string SearchingTip { get; set; }
[
Category("2、其他选项"), DisplayName("08.宝贝解析成功"), DefaultValue(@"宝贝解析成功.[追加参数]"),
Description(@"宝贝解析成功提示语 支持变量:[追加参数]"),
Editor(typeof(PropertyGridRichText), typeof(System.Drawing.Design.UITypeEditor))
]
public string AnalysisSuccess { get; set; }
[
Category("2、其他选项"), DisplayName("09.宝贝解析失败"), DefaultValue(@"宝贝解析失败,请稍后重试"),
Description(@"宝贝解析失败提示语"),
Editor(typeof(PropertyGridRichText), typeof(System.Drawing.Design.UITypeEditor))
]
public string AnalysisError { get; set; }
[
Category("3、积分操作"), DisplayName("01.积分奖励指令"), DefaultValue(@"^[加|减]?\s*?(?<>[\+-]?\d+?)$"),
Description(@"")
]
public string PointOperation { get; set; }
[
Category("3、积分操作"), DisplayName("02.积分奖励方式"), DefaultValue(RechargeType.余额),
Description(@"给评价的用户奖励")
]
public RechargeType Point_RechargeType { get; set; }
[
Category("3、积分操作"), DisplayName("03.积分奖励成功"), DefaultValue(@"成功奖励积分[奖励积分][]
[] []"),
Description(@"给评价的用户奖励成功提示语 支持变量:[机器人账号]、[机器人昵称]、[账号]、[昵称]、[奖励积分]、[剩余积分]、[积分名称]"),
Editor(typeof(PropertyGridRichText), typeof(System.Drawing.Design.UITypeEditor))
]
public string PointRechargeSuccess { get; set; }
[
Category("3、积分操作"), DisplayName("04.积分奖励失败"), DefaultValue(@"积分奖励失败"),
Description(@"给评价的用户奖励失败提示语 支持变量:[机器人账号][][][][][][]"),
Editor(typeof(PropertyGridRichText), typeof(System.Drawing.Design.UITypeEditor))
]
public string PointRechargeError { get; set; }
#endregion
public Config()
{
this.TbLoginInfos = new List<TbLoginInfo>();
this.CouponDenomination = "50-80";
this.IsRounding = SwitchType.;
this.BondCommentPic = SwitchType.;
this.ManufacturePlansAddDay = 0;
this.ExpirationDate = 7;
this.AnalyzePage = 2;
this.PUTImage = 5;
this.AbductionPic = ButtonPic = string.Empty;
this.TbItemSavePath = Util.MapPath(@"File\评价工具缓存\其他图片");
this.PointOperation = @"^[加|减]?\s*?(?<积分>[\+-]?\d+?)元$";
this.Point_RechargeType = RechargeType.;
this.SearchingTip = @"评价信息合成中.....";
this.AnalysisError = @"宝贝解析失败,请稍后重试";
this.AnalysisSuccess = @"宝贝解析成功.[追加参数]";
this.PointRechargeError = @"积分奖励失败";
this.PointRechargeSuccess = @"成功奖励积分[奖励积分][积分名称]
【剩余积分】[剩余积分] [积分名称]";
}
}
}