Beispiel #1
0
        public static bool AddOrUpdate(WX_ApiConfig model)
        {
            if (string.IsNullOrWhiteSpace(model.CompanyID))
            {
                throw new MyException("获取单位编号失败");
            }

            IWXApiConfig factory = WXApiConfigFactory.GetFactory();

            if (factory.QueryByCompanyID(model.CompanyID) == null)
            {
                WX_ApiConfig oldApiConfig = factory.QueryByToKen(model.Token);
                if (oldApiConfig != null)
                {
                    throw new MyException("Token重复");
                }
                bool result = factory.Create(model);
                if (result)
                {
                    RefreshCache();
                    OperateLogServices.AddOperateLog <WX_ApiConfig>(model, OperateType.Add);
                }
                return(result);
            }
            else
            {
                WX_ApiConfig oldApiConfig = factory.QueryByToKen(model.Token);
                if (oldApiConfig != null && oldApiConfig.CompanyID != model.CompanyID)
                {
                    throw new MyException("Token重复");
                }

                bool result = factory.Update(model);
                if (result)
                {
                    RefreshCache();
                    OperateLogServices.AddOperateLog <WX_ApiConfig>(model, OperateType.Update);
                }
                return(result);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取当前单位的配置信息
        /// </summary>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public static WX_ApiConfig QueryByCompanyId(string companyId)
        {
            IWXApiConfig factory = WXApiConfigFactory.GetFactory();

            return(factory.QueryByCompanyID(companyId));
        }