using Infrastructure.Helpers;
using OpenAuth.Repository;
using OpenAuth.Repository.Domain;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenAuth.App.BasicQueryService
{
    public class WorkFlowMangaer
    {
        ISqlSugarClient client;
        ISugarUnitOfWork<SugarDbContext> unitWork;
        public WorkFlowMangaer(
            ISqlSugarClient sqlSugarClient,
            ISugarUnitOfWork<SugarDbContext> unitWork)
        {
            client = sqlSugarClient;
            this.unitWork = unitWork;
        }

        #region 模版

        #endregion

        #region 流程

        #endregion

        #region 任务

        #endregion

        #region 签名


        public string ToWfImg(string keyValue, string password)
        {
            return "";

            //if (string.IsNullOrEmpty(keyValue))
            //{
            //    return "";
            //}

            //WFStamp entity = await GetEntity(keyValue);
            //if (entity != null && (entity.F_IsNotPassword == 0 || entity.F_Password.Equals(password)))
            //{
            //    var imgId = entity.F_ImgFile;
            //    var data = await _annexesFileIBLL.GetEntity(imgId);
            //    if (data == null)
            //    {
            //        // 说明上传的是附件夹主键
            //        var list = (List<AnnexesFileEntity>)await _annexesFileIBLL.GetList(imgId);
            //        if (list.Count == 0)
            //        {
            //            return "";
            //        }
            //        data = list[0];
            //    }
            //    var basePath = ConfigHelper.GetConfig().FilePath;
            //    string path = $"{basePath}/Learun_WF_IMG/{imgId}{data.F_FileExtensions}";
            //    if (!File.Exists(path))
            //    {
            //        byte[] arr = FileHelper.Read($"{basePath}/Learun_ANNEXESFILE/{data.F_FilePath}");
            //        FileHelper.Write(path, arr);
            //    }

            //    return $"{imgId}{data.F_FileExtensions}";
            //}
            //else
            //{
            //    return "";
            //}
        }


        #endregion
    }
}
