Example #1
0
 private static void GetItems(ILogMaintainer maintainer, RemapLogParameter parameter,
                              RemapLogResult remapLogResult)
 {
     remapLogResult.Items = parameter.GetItemsParameters.Any()
         ? maintainer.GetItems(parameter.GetItemsParameters)
         : new LogItem[0][];
 }
Example #2
0
 private static void SaveItem(ILogMaintainer maintainer, RemapLogParameter parameter, RemapLogResult remapLogResult)
 {
     if (parameter.ItemToSave == null)
     {
         return;
     }
     remapLogResult.SaveResult = maintainer.Save(parameter.ItemToSave);
 }
Example #3
0
        public void Run(IService service)
        {
            _remapList = new List <Tuple <RemapLogParameter, Action <LogItem[]>[], LogItem> >();
            foreach (LogAbstract log in _logs.Values)
            {
                var getInfo = log.GetInfo();
                var p       = new RemapLogParameter {
                    ItemTimesToDelete  = log.TimesForDelete(),
                    ItemToSave         = log.ItemToSave(),
                    GetItemsParameters = getInfo.Select(i => new Tuple <CriteriaType, DateTime, int, bool>(
                                                            i.Item1, i.Item2, i.Item3, i.Item4)).ToArray()
                };
                if (!p.ItemTimesToDelete.Any() && p.ItemToSave == null && !p.GetItemsParameters.Any())
                {
                    continue;
                }
                p.LogId = log.Id;
                _remapList.Add(new Tuple <RemapLogParameter, Action <LogItem[]>[], LogItem>(
                                   p, getInfo.Select(i => i.Item5).ToArray(), p.ItemToSave));
            }

            if (!_remapList.Any())
            {
                return;
            }
            var parameters = _remapList.Select(t => t.Item1).ToArray();
            var result     = service.RemapLogs(parameters);

            for (var i = 0; i < parameters.Length; i++)
            {
                var     getCallbacks = _remapList[i].Item2;
                LogItem itemToSave   = _remapList[i].Item3;
                if (itemToSave != null)
                {
                    itemToSave.Time = result[i].SaveResult;
                }
                RemapLogResult r = result[i];
                for (var j = 0; j < r.Items.Length; j++)
                {
                    var items    = r.Items[j];
                    var callback = getCallbacks[j];
                    callback(items);
                }
            }
        }
Example #4
0
        public RemapLogResult[] RemapLogs(RemapLogParameter[] parameters)
        {
            if (NotValid())
            {
                return(null);
            }
            var result = new RemapLogResult[parameters.Length];

            for (var i = 0; i < parameters.Length; i++)
            {
                RemapLogParameter parameter  = parameters[i];
                ILogMaintainer    maintainer = _project.LogMaintainers[parameter.LogId];
                var r = new RemapLogResult();
                DeleteItems(maintainer, parameter);
                SaveItem(maintainer, parameter, r);
                GetItems(maintainer, parameter, r);
                result[i] = r;
            }

            return(result);
        }
Example #5
0
 private static void DeleteItems(ILogMaintainer maintainer, RemapLogParameter parameter)
 {
     maintainer.Delete(parameter.ItemTimesToDelete);
 }