Config.cs 12.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
using ConfigHelper;
using System;

namespace BLL
{
    public partial class Config
    {
        private readonly DAL.ConfigRW config;

        public Config()
        {
            config = new(Model.FilePath.CONFIG_APP);
        }



        /// <summary>
        /// 软件版本
        /// </summary>
        public string SoftVersion { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 用户等级
        /// </summary>
        public Model.UserLevel UserLevel { get; set; }

        public string Language
        {
            get => config.Read<string>(LANGUAGE);
            set => config.Write(LANGUAGE, value);
        }

        /// <summary>
        /// 是否显示用户登录框
        /// </summary>
        public bool EnabledUserLogin
        {
            get => config.Read<bool>(ENABLED_USER_LOGIN);
            set => config.Write(ENABLED_USER_LOGIN, value);
        }

        /// <summary>
        /// 操作超时时间,秒
        /// </summary>
        public int OperateTimeout
        {
            get => config.Read(OPERATE_TIMEOUT, 300);
            set => config.Write(OPERATE_TIMEOUT, value);
        }

        /// <summary>
        /// 检查软件的快捷方式
        /// </summary>
        public bool CheckShortcut
        {
            get => config.Read<bool>(CHECK_SHORTCUT);
            set => config.Write(CHECK_SHORTCUT, value);
        }

        /// <summary>
        /// 打印机名称
        /// </summary>
        public string PrinterName
        {
            get => config.Read<string>(PRINTER_NAME);
            set => config.Write(PRINTER_NAME, value);
        }

        /// <summary>
        /// 打印方向,横向
        /// </summary>
        public bool PrintLandscape
        {
            get => config.Read<bool>(PRINT_LANDSCAPE);
            set => config.Write(PRINT_LANDSCAPE, value);
        }

        /// <summary>
        /// 追溯的图片质量
        /// </summary>
        public Model.HistoryImage HistoryImage
        {
            get => (Model.HistoryImage)Enum.Parse(typeof(Model.HistoryImage), config.Read<string>(HISTORY_IMAGE));
            set => config.Write(HISTORY_IMAGE, value.ToString());
        }

        public bool SelectHttpPN
        {
            get => config.Read<bool>(SELECT_HTTP_PN);
            set => config.Write(SELECT_HTTP_PN, value);
        }

        public bool LabelEmptyCheck
        {
            get => config.Read<bool>(LABEL_EMPTY_CHECK);
            set => config.Write(LABEL_EMPTY_CHECK, value);
        }

        /// <summary>
        /// 打印标签完成后清除扩展面板的内容
        /// </summary>
        public bool PrintCompletedClear
        {
            get => config.Read<bool>(PRINT_COMPLETED_CLEAR);
            set => config.Write(PRINT_COMPLETED_CLEAR, value);
        }
        /// <summary>
        /// check功能
        /// </summary>
        public bool CheckFunction
        {
            get => config.Read<bool>(Check_Function);
            set => config.Write(Check_Function, value);
        }

        /// <summary>
        /// 打开软件后开启工作模式
        /// </summary>
        public bool OpenStartWork
        {
            get => config.Read<bool>(OPEN_START_WORK);
            set => config.Write(OPEN_START_WORK, value);
        }

        public bool OpenMaximize
        {
            get => config.Read<bool>(OPEN_MAXIMIZE);
            set => config.Write(OPEN_MAXIMIZE, value);
        }

        /// <summary>
        /// 默认的打印标签名称
        /// </summary>
        public string DefaultPrintLabel
        {
            get => config.Read<string>(DEFAULT_PRINT_LABEL);
            set => config.Write(DEFAULT_PRINT_LABEL, value);
        }

        public bool PromptAfterPrinting
        {
            get => config.Read<bool>(PROMPT_AFTER_PRINTING);
            set => config.Write(PROMPT_AFTER_PRINTING, value);
        }
        public bool AutoPrint
        {
            get => config.Read<bool>(AUTO_PRINT);
            set => config.Write(AUTO_PRINT, value);
        }
        /// <summary>
        /// 启用IO模块
        /// </summary>
        public bool EnabledIO
        {
            get => config.Read<bool>(ENABLED_IO);
            set => config.Write(ENABLED_IO, value);
        }

        /// <summary>
        /// 启用视觉相机
        /// </summary>
        public bool EnabledCamera
        {
            get => config.Read<bool>(ENABLED_CAMERA);
            set => config.Write(ENABLED_CAMERA, value);
        }

        /// <summary>
        /// IO模块IP地址
        /// </summary>
        public string IOIPAddress
        {
            get => config.Read<string>(IO_IP);
            set => config.Write(IO_IP, value);
        }

        /// <summary>
        /// IO触发拍照的DO索引
        /// </summary>
        public int IOTouch
        {
            get => config.Read<int>(IO_TOUCH);
            set => config.Write(IO_TOUCH, value);
        }

        /// <summary>
        /// IO触发灯光的DO索引
        /// </summary>
        public int IOLight
        {
            get => config.Read<int>(IO_LIGHT);
            set => config.Write(IO_LIGHT, value);
        }

        /// <summary>
        /// 扩展面板的宽度
        /// </summary>
        public int ExtensionWidth
        {
            get => config.Read<int>(EXTENSION_WIDTH);
            set => config.Write(EXTENSION_WIDTH, value);
        }
        public string ReelIDKeyWord
        {
            get => config.Read<string>(REEL_ID_KEYWORD);
            set => config.Write(REEL_ID_KEYWORD, value);
        }
        public string ReelIDMatch
        {
            get => config.Read<string>(REEL_ID_MATCH);
            set => config.Write(REEL_ID_MATCH, value);
        }

        public int ReelIDPlaces
        {
            get => config.Read<int>(REEL_ID_PLACES);
            set => config.Write(REEL_ID_PLACES, value);
        }

        public bool ReelIDFillZero
        {
            get => config.Read<bool>(REEL_ID_FILL_ZERO);
            set => config.Write(REEL_ID_FILL_ZERO, value);
        }

        public string ReelIDPrefix
        {
            get => config.Read<string>(REEL_ID_PREFIX);
            set => config.Write(REEL_ID_PREFIX, value);
        }

        public string ReelIDPostfix
        {
            get => config.Read<string>(REEL_ID_POSTFIX);
            set => config.Write(REEL_ID_POSTFIX, value);
        }
        public bool ReelIDAutoResetByDate
        {
            get => config.Read<bool>(REEL_ID_AutoResetByDate);
            set => config.Write(REEL_ID_AutoResetByDate, value);
        }
        public string LockPassword
        {
            get => config.Read<string>(LOCK_PASSWORD);
            set => config.Write(LOCK_PASSWORD, value);
        }

        public string ExtensionName
        {
            get => config.Read<string>(EXTENSION_NAME);
            set => config.Write(EXTENSION_NAME, value);
        }

        public string HttpServer
        {
            get => config.Read<string>(HTTP_SERVER);
            set => config.Write(HTTP_SERVER, value);
        }

        public string HttpReelID
        {
            get => config.Read<string>(HTTP_REEL_ID);
            set => config.Write(HTTP_REEL_ID, value);
        }

        /// <summary>
        /// 默认的物料模板名称
        /// </summary>
        public string DefaultMaterialName
        {
            get => config.Read<string>(DEFAULT_MATERIAL_NAME);
            set => config.Write(DEFAULT_MATERIAL_NAME, value);
        }

        public bool TriggerOpenLight
        {
            get => config.Read<bool>(TRIGGER_OPEN_LIGHT);
            set => config.Write(TRIGGER_OPEN_LIGHT, value);
        }

        public string WebService
        {
            get => config.Read<string>(WEB_SERVICE);
            set => config.Write(WEB_SERVICE, value);
        }

        public string LightSerialPort
        {
            get => config.Read<string>(LIGHT_SERIAL_PORT);
            set => config.Write(LIGHT_SERIAL_PORT, value);
        }
        public string SmfServer
        {
            get => config.Read<string>(Smf_Server);
            set => config.Write(Smf_Server, value);
        }
        public string CID
        {
            get => config.Read<string>(ClientID);
            set => config.Write(ClientID, value);
        }
        public string iomodule
        {
            get => config.Read<string>(IOModule);
            set => config.Write(IOModule, value);
        }
     
        static Config()
        {
            ConfigHelper.Config.LoadMyConfig(typeof(Config));
        }
        /// <summary>
        /// 软件后台运行
        /// </summary>
        [MyConfigComment("软件后台运行")]
        public static MyConfig<bool> Backgrounder;
        [MyConfigComment("数据源类型")]
        public static MyConfig<string> DataSource_Type;
        [MyConfigComment("数据源文件路径")]
        public static MyConfig<string> DataSource_FilePath;
        [MyConfigComment("数据源编码")]
        public static MyConfig<string> DataSource_Encoding;
        [MyConfigComment("数据源匹配Key")]
        public static MyConfig<string> DataSource_DataKey;
        [MyConfigComment("数据源列标题")]
        public static MyConfig<string> DataSource_DataTitle;
        public static MyConfig<bool> DataSource_ShowBox = false;
        [MyConfigComment("遍历数据源目录")]
        public static MyConfig<bool> DataSource_Recursive;
        [MyConfigComment("是否启用OCR")]
        public static MyConfig<bool> Func_EnabledOCR;
        [MyConfigComment("允许修改打内容")]
        public static MyConfig<bool> AllowModifyPrintInfo;
        /// <summary>
        /// 0,不重置
        /// 1,按天
        /// 2,按月
        /// </summary>
        [MyConfigComment("唯一码后缀编号重置策略")]
        public static MyConfig<int> REEL_ID_AutoResetStrategy;
        [MyConfigComment("使用扫码相机")]
        public static MyConfig<bool> Func_UseIDCamera=false;
        [MyConfigComment("隐藏软件logo")]
        public static MyConfig<bool> AppUI_HideLogo=false;
        public void Save()
        {
            config.Save();
        }
    }

    public partial class Config
    {
        private const string LANGUAGE = "Language";
        private const string Smf_Server = "SmfServer";
        private const string ClientID = "CID";
        private const string IOModule = "IOModule";
        private const string dataSourceType = "DataSourceType";
        private const string dataSourceString = "dataSourceString";
        private const string ENABLED_USER_LOGIN = "EnabledUserLogin";
        private const string OPERATE_TIMEOUT = "OperateTimeout";
        private const string CHECK_SHORTCUT = "CheckShortcut";
        private const string PRINTER_NAME = "PrinterName";
        private const string PRINT_LANDSCAPE = "PrintLandscape";
        private const string HISTORY_IMAGE = "HistoryImage";
        private const string SELECT_HTTP_PN = "SelectHttpPN";
        private const string LABEL_EMPTY_CHECK = "LabelEmptyCheck";
        private const string PRINT_COMPLETED_CLEAR = "PrintCompletedClear"; 
        private const string Check_Function = "CheckFunction";
        private const string OPEN_START_WORK = "OpenStartWork";
        private const string OPEN_MAXIMIZE = "OpenMaximize";
        private const string DEFAULT_PRINT_LABEL = "DefaultPrintLabel";
        private const string PROMPT_AFTER_PRINTING = "PromptAfterPrinting";
        private const string ENABLED_IO = "EnabledIO";
        private const string ENABLED_CAMERA = "EnabledCamera";
        private const string IO_IP = "IOIP";
        private const string IO_TOUCH = "IOTouch";
        private const string IO_LIGHT = "IOLight";
        private const string EXTENSION_WIDTH = "ExtensionWidth";
        private const string REEL_ID_KEYWORD = "ReelIDKeyWord";
        private const string REEL_ID_MATCH = "ReelIDMatch";
        private const string REEL_ID_PLACES = "ReelIDPlaces";
        private const string REEL_ID_FILL_ZERO = "ReelIDFillZero";
        private const string REEL_ID_PREFIX = "ReelIDPrefix";
        private const string REEL_ID_POSTFIX = "ReelIDPostfix";
        private const string REEL_ID_AutoResetByDate = "ReelIDAutoResetByDate";
        private const string LOCK_PASSWORD = "LockPassword";
        private const string EXTENSION_NAME = "ExtensionGroup";
        private const string HTTP_SERVER = "HttpServer";
        private const string HTTP_REEL_ID = "HttpReelID";
        private const string DEFAULT_MATERIAL_NAME = "DefaultMaterialName";
        private const string TRIGGER_OPEN_LIGHT = "TriggerOpenLight";
        private const string WEB_SERVICE = "WebService";
        private const string LIGHT_SERIAL_PORT = "LightSerialPort";
        private const string AUTO_PRINT = "AutoPrint";
       
    }
}