Ejemplo n.º 1
0
        public void BackupIOSysDB(PerformContext context)
        {
            LogHelper.Info("开始[BackupIOSysDB] 备份收支系统数据库");

            //头部参数
            var headerParams = new Dictionary <string, string>();

            headerParams["Authorization"] = "0";

            //请求备份接口
            var client = new TdbHttpClient(SysJson.Inst.Sys.ApiUrl.Base);
            var res    = client.ExecPost <ResultInfo <bool> >(SysJson.Inst.Sys.ApiUrl.BackupDB, null, headerParams);

            if (res.StatusCode == System.Net.HttpStatusCode.OK && res.Result.IsOK)
            {
                LogHelper.Info("完成[BackupIOSysDB] 备份收支系统数据库成功");
            }
            else
            {
                LogHelper.Info(res.ErrorException, $"失败[BackupIOSysDB] 备份收支系统数据库失败。错误信息:{res.Result.Msg}");

                //发送邮件
                var content = $"收支数据库备份失败,{DateTime.Now.ToString("yyyyMMdd")}";
                EmailHelper.Send(content, content, false, SysJson.Inst.Sys.EmailAddr.BackupIODBFails);
            }
        }
        /// <summary>
        /// 查询支出列表
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <param name="date">收入日期</param>
        /// <returns></returns>
        private List <OutPutListInfo> QueryOutPut(LoginInfo user, DateTime date)
        {
            //token
            var dicHeader = new Dictionary <string, string>();

            dicHeader["Authorization"] = user.Token;

            //请求接口
            var client = new TdbHttpClient(AppConfig.Inst.App.IOApiUrl);
            var res    = client.ExecGet <ResultList <OutPutListInfo> >("api/InOut/QueryOutPut/" + date.ToString("yyyy-MM-dd"), null, dicHeader);

            return(res.Result.LstInfo);
        }
        /// <summary>
        /// 查询收入类型列表
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <returns></returns>
        private List <InTypeListInfo> QueryInType(LoginInfo user)
        {
            //token
            var dicHeader = new Dictionary <string, string>();

            dicHeader["Authorization"] = user.Token;

            //请求接口
            var client = new TdbHttpClient(AppConfig.Inst.App.IOApiUrl);
            var res    = client.ExecGet <ResultList <InTypeListInfo> >("api/Basic/QueryInType", null, dicHeader);

            return(res.Result.LstInfo);
        }
        /// <summary>
        /// 查询支出类型列表
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <returns></returns>
        private List <OutTypeListInfo> QueryOutType(LoginInfo user)
        {
            //token
            var dicHeader = new Dictionary <string, string>();

            dicHeader["Authorization"] = user.Token;

            //请求接口
            var client = new TdbHttpClient(AppConfig.Inst.App.IOApiUrl);
            var res    = client.ExecGet <ResultList <OutCategoryTypeListInfo> >("api/Basic/QueryOutCategoryType", null, dicHeader);

            var list = res.Result.LstInfo.SelectMany(m => m.LstOutType).ToList();

            return(list);
        }
Ejemplo n.º 5
0
        public void UpdateInTypeSortWeight(PerformContext context)
        {
            LogHelper.Info("开始[UpdateInTypeSortWeight] 统计收入类型排序权重");

            //头部参数
            var headerParams = new Dictionary <string, string>();

            headerParams["Authorization"] = "0";

            //请求备份接口
            var client = new TdbHttpClient(SysJson.Inst.Sys.ApiUrl.Base);
            var res    = client.ExecPost <ResultInfo <bool> >(SysJson.Inst.Sys.ApiUrl.UpdateInTypeSortWeight, null, headerParams);

            LogHelper.Info("完成[UpdateInTypeSortWeight] 统计收入类型排序权重");
        }
        /// <summary>
        /// 保存支出信息
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <param name="info">支出信息</param>
        /// <returns>主键ID</returns>
        private int SaveOutPut(LoginInfo user, OutPutInfo info)
        {
            //token
            var dicHeader = new Dictionary <string, string>();

            dicHeader["Authorization"] = user.Token;

            //条件
            var req = new LoginReq();

            req.LoginName = AppConfig.Inst.App.IOLoginName;
            req.Password  = AppConfig.Inst.App.IOLoginPwd;

            //请求接口
            var client = new TdbHttpClient(AppConfig.Inst.App.IOApiUrl);
            var res    = client.ExecPost <ResultInfo <int> >("api/InOut/SaveOutPut", info, dicHeader);

            return(res.Result.Info);
        }
        /// <summary>
        /// 用默认账号登录
        /// </summary>
        /// <returns></returns>
        private LoginInfo Login()
        {
            if (user != null)
            {
                return(user);
            }

            var req = new LoginReq();

            req.LoginName = AppConfig.Inst.App.IOLoginName;
            req.Password  = EncryptHelper.EncryptAES(AppConfig.Inst.App.IOLoginPwd);

            //请求接口
            var client = new TdbHttpClient(AppConfig.Inst.App.IOApiUrl);
            var res    = client.ExecPost <ResultInfo <LoginInfo> >("api/Account/Login", req);

            if (res.StatusCode == System.Net.HttpStatusCode.OK && res.Result.IsOK)
            {
                user = res.Result.Info;
            }

            return(res.Result.Info);
        }