Esempio n. 1
0
        public async Task ImportAsync(int siteId, string filePath, bool overwrite)
        {
            var json = await FileUtils.ReadTextAsync(filePath);

            var rule = TranslateUtils.JsonDeserialize <Rule>(json);

            if (rule != null)
            {
                rule.SiteId           = siteId;
                rule.CreatedDate      = DateTime.Now;
                rule.LastModifiedDate = DateTime.Now;
                rule.LastGatherDate   = null;

                var srcRule = await _ruleRepository.GetByRuleNameAsync(siteId, rule.RuleName);

                if (srcRule != null)
                {
                    if (overwrite)
                    {
                        await _ruleRepository.DeleteAsync(srcRule.Id);
                    }
                    else
                    {
                        rule.RuleName = await _ruleRepository.GetImportRuleNameAsync(siteId, rule.RuleName);
                    }
                }

                await _ruleRepository.InsertAsync(rule);
            }
        }
Esempio n. 2
0
 public async Task Delete(int id)
 {
     await _rulesRepository.DeleteAsync(id);
 }