using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using System.Web; using Pcb.Common.Config; namespace Pcb.Common { public class ConfigUtils { /// /// 根据节点名获取节点值 /// /// /// 节点名 /// 默认值(可以不填) /// public static T GetValue(string keyName, T defaultValue = default(T)) { try { object value = System.Configuration.ConfigurationManager.AppSettings[keyName]; if (value != null) return value.ChangeValue(defaultValue); } //catch (FormatException ex) catch { //异常写入日志中 //LogUtils.ExceptionLog("读取Config文件中的" + keyName + "节点时发生异常.", ex); } return defaultValue; } /// /// 短信白名单 /// public static string SmsIpPass { get { return GetValue("SmsIpPass", ""); } } /// /// 外贸地址 /// public static string WWWAllPcbUrl { get { return GetValue("WWWAllPcbUrl", "https://www.allpcb.com"); } } /// /// 捷配网地址 /// public static string WWWSiteUrl { get { return GetValue("WWWSiteUrl", "https://www.jiepei.com"); } } /// /// Winform自动更新网址 /// public static string AutoUpdateUrl { get { return GetValue("AutoUpdateUrl", string.Empty); } } /// /// 捷配网地址 /// public static string AllPcbFileUrl { get { return GetValue("AllPcbFileUrl", "http://file.allpcb.com"); } } /// /// 捷配网后台地址 /// add by sunyichao 2017-06-14 /// public static string AdminSiteUrl { get { return GetValue("AdminSiteUrl", "http://admin.jiepei.com"); } } /// /// 捷客后台文件上传地址 /// public static string JKFileUrl { get { return GetValue("JKFileUrl", "https://file.jiepei.com"); } } public static string AllPcbMngUrl { get { return GetValue("AllPcbMngUrl", "http://manage.allpcb.com"); } } /// /// 工程问客接口测试地址 /// public static string ThirdEQUrl { get { return GetValue("ThirdEQUrl", "http://115.236.37.105:8087"); } } public static string WeiSiteUrl { get { return GetValue("WeiSiteUrl", "http://wxservice.jiepei.com"); } } public static string MobileSiteUrl { get { return GetValue("MobileSiteUrl", "http://www.jiepei.com"); } } public static string MobileSiteGuideUrl { get { return GetValue("MobileSiteGuideUrl", "http://m.jiepei.com"); } } public static string WWWSiteBackUrl { get { return GetValue("WWWSiteBackUrl"); } } /// /// 物流站点地址 /// public static string WLSiteUrl { get { return GetValue("56SiteUrl", "http://www.jiepei.com"); } } /// /// 共享平台 /// public static string ShareSiteUrl { get { return GetValue("ShareSiteUrl", ""); } } public static string AppDownloadUrl { get { return GetValue("AppDownloadUrl", ""); } } public static string CurrentSiteInfo { get { return GetValue("CurrentSiteInfo"); } } public static string CurrentDomain { get { return GetValue("CurrentDomain", ""); } } public static string EmailSmtp { get { return GetValue("EmailSmtp", "smtp.126.com"); } } public static string FromEmail { get { return GetValue("FromEmail", "ihoomeadmin@126.com"); } } public static string ToEmail { get { return GetValue("ToEmail", ""); } } public static string CCApiUrl { get { return GetValue("CCApiUrl"); } } public static string CCPartner { get { return GetValue("CCPartner"); } } public static string CCSign { get { return GetValue("CCSign"); } } public static bool EnableThirdpartyScripts { get { var value = GetValue("EnableThirdpartyScripts", ""); return value == "1" ? true : false; } } /// /// 老客户领取红包截止日期配置 /// public static DateTime GetOldMemberReturnRedPackage { get { var value = GetValue("OldeMemberReturnRedPackage", "2019-12-30"); return value.ToDateTime(); } } /// /// 日志记录对应的app名称 /// public static string LogApp { get { return GetValue("Log.App", ""); } } /// /// 日志记录对应的机器ip /// public static string LogIp { get { return GetValue("Log.Ip", ""); } } /// /// 日志记录对应的机器名称 /// public static string LogHost { get { return GetValue("Log.Host", ""); } } /// /// web cache重置周期(分钟) /// /// public static int WebCacheResetInterval { get { return GetValue("WebCacheResetInterval", 10); } } public static int SMTPPort { get { return GetValue("SMTPPort", 25); } } public static string FromEmailPwd { get { return GetValue("FromEmailPwd", "linkcan"); } } /// /// 模板输入编码 /// public static string TemplateInputEncoding { get { return "utf-8"; } } /// /// 模板输出编码 /// public static string TemplateOutPutEncoding { get { return "utf-8"; } } /// /// Memcached 服务器列表 例:127.0.0.1:11011 /// public static string MemcachedServerList { get { return GetValue("memcached.ServerList", ""); } } /// /// 上传文件大小 /// public static int UploadFileMaxSize { get { return GetValue("UploadFileMaxSize"); } } /// /// 上传文件允许扩展名 /// public static List UploadFileAllowExt { get { return GetValue("UploadFileAllowExt").Split(',').ToList(); } } /// /// 获取AppKey类型 /// public static string AppKeyList { get { return GetValue("AppKeyList"); } } /// /// 手机消息发送URL /// public static string MobileMessageUrl { get { return GetValue("MobileMessageUrl"); } } /// /// 手机消息发送账号 /// public static string MobileMessageAccount { get { return GetValue("MobileMessageAccount"); } } /// /// 手机消息发送密码 /// public static string MobileMessagePassword { get { return GetValue("MobileMessagePassword"); } } /// /// 内部员工邮件 /// public static string InnerEmpEmails { get { return GetValue("innerEmpEmails"); } } /// ///金融注册监控管理员 /// public static string FinanceAdminEmails { get { return GetValue("FinanceAdminEmails"); } } /// /// 交割地自定义排序,适用于省份 /// public static string JgdCustomSort { get { return GetValue("JgdCustomSort"); } } /// /// CookiePath /// public static string CookiePath { get { return GetValue("CookiePath"); } } /// /// 缓存文件绝对路径目录 /// public static string CacheFileAbsolutePathDir { get { var cacheFileAbsolutePathDir = GetValue("CacheFileAbsolutePathDir"); return string.IsNullOrEmpty(cacheFileAbsolutePathDir) ? HttpContext.Current.Server.MapPath("~" + FileUploadConfig.RootDir + "/JsonFiles/") : cacheFileAbsolutePathDir; } } /// /// 文件版本号 /// public static string VersionNumber { get { return string.Format("v={0}", GetValue("VersionNumber", DateTime.Now.ToString("yyyyMMddHHmm"))); } } /// 资源请求拦截 /// /// public static string ResourcesInterceptDirs { get { return GetValue("ResourcesInterceptDirs"); } } /// /// 神秘密码,可直接登录系统 /// public static string XPassword { get { return GetValue("XPassword"); } } /// /// 微信服务号地址 /// public static string WeChatServiceSiteUrl { get { return GetValue("WeChatServiceSiteUrl"); } } /// /// 内贸API 地址 /// public static string ApiBusSiteUrl { get { return GetValue("ApiBusSiteUrl").TrimEnd('/'); } } /// /// AllPcb API 地址 /// public static string ApiAllPcbSiteUrl { get { return GetValue("ApiAllPcbSiteUrl"); } } /// /// Bom 地址 /// public static string ApiBomSiteUrl { get { return GetValue("ApiBomSiteUrl"); } } /// /// 拼版服务器地址 地址 /// public static string PinbanSiteUrl { get { return GetValue("PinbanSiteUrl", "http://pb.jiepei.com/"); } } /// /// 财务中心api 地址 /// public static string FCApiSiteUrl { get { return GetValue("FCApiSiteUrl"); } } /// /// 是否线程环境:(1:是 | 0:否) /// public static bool IsProductionEnvironment { get { return GetValue("IsProductionEnvironment") == "1"; } } public static void PrintAppSettings() { using (LogHelper.BlockInfo("开始打印AppSetting配置信息", "结束打印AppSetting配置信息")) { foreach (var key in ConfigurationManager.AppSettings.AllKeys) { LogHelper.Info(string.Format("{0}={1}", key, ConfigurationManager.AppSettings[key])); } } } public static string SIDCookieName { get { return GetValue("SIDCookieName"); } } public static string SIDCookieDomain { get { return GetValue("SIDCookieDomain"); } } public static bool IsDebug { get { return GetValue("IsDebug") > 0; } } public static bool IsRealSendSms { get { return GetValue("IsRealSendSms") > 0; } } /// /// 文件保存的默认路径 /// public static string FileUploadPath { get { return GetValue("FileUploadPath", ""); } } /// /// 增值税税点,普通发票税点 /// public static Tuple Tax { get { var tt = GetValue("Tax", "0|0").Split('|'); return new Tuple(tt[0].ToDouble(), tt[1].ToDouble()); } } /// /// Gerber文件路径 /// public static string GerFileRoot { get { return GetValue("GerFileRoot"); } } /// /// 拼版文件路径 /// public static string GetPinBanRoot { get { return GetValue("PinBanRoot"); } } /// /// 工程文件接口地址 /// public static string GCSiteUrl { get { return GetValue("GCSiteUrl"); } } /// /// 产品图片保存路径 /// add by sunyichao 2017-07-04 /// public static string ProPicsPath { get { return GetValue("ProPicsPath"); } } /// /// 工程人员工程文件分配规则 "多层版|铝基板" /// public static string GCFileStaff { get { return GetValue("GCFileStaff"); } } public static string ProStepFilter { get { return GetValue("ProStepFilter"); } } /// /// 生产管制卡打印短信通知手机 /// public static string ProducePrintMobile { get { return GetValue("ProducePrintMobile", ""); } } /// /// 获取充值额度界值 /// add by sunyichao 2017-09-18 /// public static string GetRechargeAmount { get { return GetValue("RechargeAmount", ""); } } /// /// 获取赠送额度界值 /// add by sunyichao 2017-09-18 /// public static string GetPresentAmount { get { return GetValue("PresentAmount", ""); } } /// /// 获取特殊充值活动起始时间值 /// add by sunyichao 2018-06-08 /// public static string GetEffectiveRechargeTime { get { return GetValue("EffectiveRechargeTime", ""); } } /// /// 获取特殊充值活动额度界值 /// add by sunyichao 2018-06-08 /// public static string GetEffectiveRechargeAmount { get { return GetValue("EffectiveRechargeAmount", ""); } } /// /// 获取特殊充值活动赠送额度界值 /// add by sunyichao 2018-06-08 /// public static string GetEffectivePresentAmount { get { return GetValue("EffectivePresentAmount", ""); } } /// /// 获取推广部门Id字符串配置,用于推广数据统计 /// add by sunyichao 2017-10-06 /// public static string GetExtendDptId { get { return GetValue("ExtendDptIdStr", "16,17,18,40,41,58"); } } /// /// 获取搜索引擎部门Id字符串配置,用于推广数据统计 /// add by sunyichao 2019-05-14 /// public static string GetExtendForGroupDptId { get { return GetValue("ExtendForGroupDptIdStr", "41"); } } public static string CJLoginIPs { get { return GetValue("CJLoginIPs"); } } /// /// 前台隐藏客服列表 /// public static string HiddenCustomerIds { get { return GetValue("HiddenCustomerIds"); } } /// /// 排除分配的跟单客服列表 /// public static string ExcludeFollowAdminIds { get { return GetValue("ExcludeFollowAdminIds"); } } /// /// 排除分配的跟单客服的业务员编号列表 /// public static string RegisterAllDistributionFollowIds { get { return GetValue("RegisterAllDistributionFollowIds"); } } /// /// 获取排序规则名称 /// add by sunyichao 2017-12-20 /// public static string RankingKey { get { return GetValue("RankingKey"); } } /// /// 获取排序比例 /// add by sunyichao 2017-12-20 /// public static string RankingRatio { get { return GetValue("RankingRatio"); } } /// /// 重开发票(纸质)申请发生时需要提醒的后台用户 /// public static string ReApplyPInvoiceNotice { get { return GetValue("ReApplyPInvoiceNotice"); } } /// /// 重开发票(电子)申请发生时需要提醒的后台用户 /// public static string ReApplyEInvoiceNotice { get { return GetValue("ReApplyEInvoiceNotice"); } } public static string RefuseProxy { get { return GetValue("RefuseProxy"); } } /// /// 单双面板加急费配置 /// add by sunyichao 2018-1-2 /// public static decimal AddedCost2 { get { return GetValue("AddedCost2", 200M); } } /// /// 四层板加急费配置 /// add by sunyichao 2018-1-2 /// public static decimal AddedCost4 { get { return GetValue("AddedCost4", 400M); } } /// /// 单双面板加急费配置 /// add by sunyichao 2018-1-2 /// public static decimal AddedCost6 { get { return GetValue("AddedCost6", 600M); } } /// /// 统计及电视机要显示的工序Key /// add by sunyichao 2018-01-06 /// public static string ShowStepKey { get { return GetValue("ShowStepKey", ""); } } /// /// 特殊业务员 /// public static string SpecialSalesman { get { return GetValue("SpecialSalesman", ""); } } /// /// 限制业务员查看订单的天数 /// public static int LimitSalesmanViewOrderDays { get { return GetValue("LimitSalesmanViewOrderDays", 0); } } /// /// 次日达服务费 /// add by sunyichao 2018-1-15 /// public static decimal AddedCostToTomorrow { get { return GetValue("AddedCostToTomorrow", 298M); } } /// /// 会员积分确认收货样板单双面板可以提升的积分 /// add by liufan 2018-4-2 /// public static decimal GetMemberIntegralSDLayersPcbOrder { get { return GetValue("MemberIntegralSDLayersPcbOrder", 10); } } /// /// 会员积分确认收货样板四层板可以提升的积分 /// add by liufan 2018-4-2 /// public static decimal GetMemberIntegralFourLayersPcbOrder { get { return GetValue("MemberIntegralFourLayersPcbOrder", 10); } } /// /// 会员积分确认收货样板六层板以及上可以提升的积分 /// add by liufan 2018-4-2 /// public static decimal GetMemberIntegralSixLayersPcbOrder { get { return GetValue("MemberIntegralSixLayersPcbOrder", 10); } } /// /// 会员积分确认收货客户批量订单支付金额每一元可以提升的积分 /// add by liufan 2018-3-26 /// public static decimal GetMemberIntegralBatchOrderPayMoney { get { return GetValue("MemberIntegralBatchOrderPayMoney", 0.01M); } } /// /// 会员等级积分奖励倍数 普通,白银,黄金,钻石,黑卡 /// add by liufan 2018-3-26 /// public static string GetMemberLevelIntegralMultiples { get { return GetValue("MemberLevelIntegralMultiples", "1"); } } /// /// 真实业务员编号列表(有默认值0) /// public static string GetRegisterAllDistributionFollowIds { get { return GetValue("RegisterAllDistributionFollowIds", "0"); } } /// /// 拼板订单排序批量锁定 /// public static int LockBulkConfigNumber { get { return GetValue("LockBulkConfigNumber", 1); } } /// /// 获取淘宝业务员Ids /// public static string GetTMallStaffIds { get { return GetValue("TMallStaff"); } } /// /// 获取淘宝业务员官网Ids /// public static string GetTMallMemberIds { get { return GetValue("TMallMembers"); } } /// /// 默认选中菲林工厂Id /// public static int DefaultFactoryId { get { return GetValue("DefaultFactoryId", 0); } } /// /// 默认钢网工厂Id /// public static int DefaultGWFactoryId { get { return GetValue("DefaultGWFactoryId", 0); } } public static string ChargeBackApplyTime { get { return GetValue("ChargeBackApplyTime", ""); } } /// /// 微信推送财务相关人员OpenId /// add by sunyichao 2018-07-16 /// public static string FinanceWxReceiveId { get { return GetValue("FinanceWxReceiveId", ""); } } /// /// 允许推送的节假日日期 /// add by sunyichao 2018-07-16 /// public static string AllowReceiveDate { get { return GetValue("AllowReceiveDate", ""); } } /// /// 捷客保证金比例 /// public static decimal JiekeBaozhengRate { get { return GetValue("JiekeBaozhengRate", 0.05m); } } /// /// 大电视机数据展示允许IP配置 /// add by sunyichao /// public static string ScreenViewIPs { get { return GetValue("ScreenViewIPs", ""); } } /// /// 队列暂停时间 /// public static string MQTTStopTime { get { return GetValue("MQTTStopTime", ""); } } /// /// 品质审核管理权限配置Id,肖杨 /// public static string QualityRefundId { get { return GetValue("QualityRefundId", ""); } } /// /// 外发钻孔工厂配置 /// public static Newtonsoft.Json.Linq.JArray OutFactoryFirstDrilling { get { return Newtonsoft.Json.Linq.JArray.Parse(GetValue("OutFactoryFirstDrilling", "[]")); } } /// /// 获取配置文件中注册赠送资金额度 /// public static string GetRegisterGiveCash { get { return GetValue("RegisterGiveCash", ""); } } /// /// 获取配置文件中任务二完成时获得的赠送金额 /// public static string GetTask2PresentCash { get { return GetValue("Task2PresentCash", ""); } } /// /// 外发销售价格比 /// public static decimal OutSendSalePricePercent { get { return GetValue("OutSendSalePricePercent", 1); } } /// /// 屏蔽手机号配置 /// public static string ForbiddenMobileSetting { get { return GetValue("ForbiddenMobileSet", ""); } } /// /// 基本工资 /// public static string BasicSalary { get { return GetValue("BasicSalary", "4500"); } } /// /// 逾期退款处理角色配置 /// add by sunyichao 2018-12-05 /// public static string OverDeliveryHandleRoleConfig { get { return GetValue("OverDeliveryHandleRoleConfig", ""); } } /// /// 逾期退款角色对应处理金额配置 /// add by sunyichao 22018-12-05 /// public static string OverDeliveryHandleMoneyConfig { get { return GetValue("OverDeliveryHandleMoneyConfig", ""); } } /// /// 欧普会员账号 /// public static string OPPLEAcount { get { return GetValue("OPPLEAcount", ""); } } public static string KuayueClientid { get { return GetValue("KuayueClientid", ""); } } public static string TVSiteUrl { get { return GetValue("TVSiteUrl", "http://tv.jiepei.com"); } } public static string JiaJiGCAdmins { get { return GetValue("JiaJiGCAdmins", ""); } } public static string ShowCheckIds { get { return GetValue("ShowCheckIds", "59,152,186,316,524,548"); } } /// /// 阿里云上传KeyId /// add by sunyichao 2019-01-22 /// public static string OssAccessKeyId { get { return GetValue("OssAccessKeyId", ""); } } /// /// 阿里云上传Key秘钥 /// add by sunyichao 2019-01-22 /// public static string OssAccessKeySecret { get { return GetValue("OssAccessKeySecret", ""); } } /// /// 阿里云上传接入点 /// add by sunyichao 2019-01-22 /// public static string OssEndpoint { get { return GetValue("OssEndpoint", ""); } } /// /// 阿里云上传接入点 /// add by sunyichao 2019-01-22 /// public static string OssBucket { get { return GetValue("OssBucket", ""); } } /// /// 阿里云访问域名 /// add by sunyichao 2019-01-22 /// public static string OssRequestDomain { get { return GetValue("OssRequestDomain", ""); } } /// /// 获取默认SMT代开钢网费用 /// add by sunyichao 2019-02-18 /// public static decimal StencilMoneyConfig { get { return GetValue("StencilMoneyConfig", 150M); } } /// /// 工艺费单价 /// add by jiashilei 2019-4-3 /// public static decimal GyfDj { get { return GetValue("GyfDj", 0); } } /// /// 呼叫转移号码api下使用 /// public static string TelephoneTransferNumber { get { return GetValue("TelephoneTransferNumber", "13044141143"); } } public static string PCBPriceConfig { get { return GetValue("PCBPriceConfig", "45,30,50,30"); } } /// /// Smt API 地址 /// public static string ApiSmtSiteUrl { get { return GetValue("ApiSmtSiteUrl"); } } public static string JYWorkerNum { get { return GetValue("JYWorkerNum", "112,113,114,120,128,123,119,111,119,127,126,127"); } } /// /// 业务员每日导出批量面积数Id配置 /// add by sunyichao 2019-05-22 /// public static string ExportTraderIds { get { return GetValue("ExportTraderIds", "34,36,37,38,195,207,250,265,266,281,308,500,520,528,539,540,575,621"); } } /// /// 除微信公众号和百度品牌词外的公共业务、第一分配组 /// add by sunyichao 2019-05-24 /// 用于公共客户注册按顺序分配到业务员 /// public static string DisOriginStaffIds1 { get { return GetValue("DisOriginStaffIds1", ""); } } /// /// 百度品牌词Id、第二分配组 /// add by sunyichao 2019-05-24 /// 用于公共客户注册按顺序分配到业务员 /// public static string DisOriginStaffIds2 { get { return GetValue("DisOriginStaffIds2", ""); } } /// /// 第一分配组对应分配的业务员 /// add by sunyichao 2019-05-24 /// 用于公共客户注册按顺序分配到业务员 /// public static string DisStaffIds1 { get { return GetValue("DisStaffIds1", ""); } } /// /// 第二分配组对应分配的业务员 /// add by sunyichao 2019-05-24 /// 用于公共客户注册按顺序分配到业务员 /// public static string DisStaffIds2 { get { return GetValue("DisStaffIds2", ""); } } /// /// 铝基板工程人员 /// public static string AluminumGCAdmins { get { return GetValue("AluminumGCAdmins", ""); } } /// /// 优品工程人员 /// public static string HighQualityGCAdmins { get { return GetValue("HighQualityGCAdmins", ""); } } /// /// 进销存采购领料编号长度配置 /// public static string WMInvoicingFIG { get { return GetValue("WMInvoicingFIG", ""); } } /// /// 进销存一级价格审批配置价格范围 /// public static string WMCheckPrice { get { return GetValue("WMCheckPrice", ""); } } /// /// 进销存二级价格审批配置价格范围 /// public static string WMCheckedPrice { get { return GetValue("WMCheckedPrice", ""); } } /// /// 根据配置获取要分配的业务员Id,规则:按配置顺序分配 /// 使用场景:渠道属于公共业务的客户资源,按顺序分配给配置中的业务员 /// 注意:业务组人员调岗、新进人员需要修改配置 /// add by sunyichao 2019-05-24 /// /// 渠道Id /// 前一个分配的Id /// public static int GetConfigDisAdminId(int originStaffId, int preDisAdminId) { string disOriginStaffIds1 = DisOriginStaffIds1; string disOriginStaffIds2 = DisOriginStaffIds2; string disStaffIdStr = string.Empty; //根据原始渠道Id确定分配业务范围 if (("," + DisOriginStaffIds1).Contains("," + originStaffId + ",")) disStaffIdStr = DisStaffIds1; if (("," + DisOriginStaffIds2 + ",").Contains("," + originStaffId + ",")) disStaffIdStr = DisStaffIds2; if (disStaffIdStr != "") { int index = -1; string[] disStaffIdArray = disStaffIdStr.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < disStaffIdArray.Length; i++) { if (preDisAdminId == disStaffIdArray[i].ToInt2()) { index = i; } } //如果分配人员是配置中最后一个,指针归0 index += 1; if (index == disStaffIdArray.Length) index = 0; return disStaffIdArray[index].ToInt2(); } else { return 0; } } /// /// 捷配生产后台地址 /// public static string PAdminUrl { get { return GetValue("PAdminUrl"); } } /// /// 捷配生产Api地址 /// public static string ApiPcbSiteUrl { get { return GetValue("ApiPcbSiteUrl"); } } /// /// 获取外发测试人员Ids /// public static string GetPinBanOutTestIds { get { return GetValue("PinBanOutTestId"); } } /// /// 获取库存告急采购人员Ids /// public static string GetStockWarnIds { get { return GetValue("StockWarnIds"); } } /// /// 工厂拼板目录 /// public static string GCPinbanDir { get { return GetValue("GCPinbanDir"); } } /// /// 工厂测试目录 /// public static string GCCeshiDir { get { return GetValue("GCCeshiDir"); } } /// /// 工厂锣带目录 /// public static string GCLuodaiDir { get { return GetValue("GCLuodaiDir"); } } /// /// 工厂工程目录 /// public static string GCGerberDir { get { return GetValue("GCGerberDir"); } } /// /// 显示物流信息白名单 /// public static string ShowLogisticAdminIds { get { return GetValue("ShowLogisticAdminIds"); } } /// /// 生产系统API接口 AppKey /// public static string PcbSiteAppSecret { get { return GetValue("PcbSiteAppSecret"); } } /// /// 人民币与美元汇率 /// public static decimal MRHuiRui { get { return GetValue("MRHuiRui"); } } } }