예제 #1
0
        public override void InitPluginData(DbContext baseDbContext, IServiceProvider servicep, string webRootPath)
        {
            //base.InitPluginData(baseDbContext, servicep);
            var dbContext = servicep.GetService <WeiXinDbContext>();

            if (dbContext.WeiXinConfigs.CountAsync().Result != 0)
            {
                return;
            }
            if (DataInitTool.workbook == null)
            {
                DataInitTool.OpenExcel("InitData.xlsx", webRootPath);
            }
            DataInitTool.ProcessSheet("Plugin_WeiXin_Config", colums =>
            {
                WeiXinConfigEntity entity = new WeiXinConfigEntity();
                entity.Id             = colums[0];
                entity.AppId          = colums[1];
                entity.EncodingAESKey = colums[2];
                entity.Token          = colums[3];
                entity.AppSecret      = colums[4];
                entity.TenantId       = colums[5];
                dbContext.WeiXinConfigs.Add(entity);
            });
            dbContext.SaveChanges();
        }
 public Task <int> Save(WeiXinConfigEntity organizeEntity, string keyValue, string userId)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         organizeEntity.AttachModifyInfo(keyValue, userId);
         return(repo.UpdateAsync(organizeEntity));
     }
     else
     {
         organizeEntity.AttachCreateInfo(userId);
         return(repo.InsertAsync(organizeEntity));
     }
 }