Exemplo n.º 1
0
        static DisconnectedStrategy <T> Register <T>(DisconnectedStrategy <T> stragety) where T : Entity
        {
            if (typeof(T).IsEnumEntity())
            {
                throw new InvalidOperationException("EnumEntities can not be registered on DisconnectedLogic");
            }

            strategies.AddOrThrow(typeof(T), stragety, "{0} has already been registered");

            return(stragety);
        }
Exemplo n.º 2
0
        protected virtual SqlPreCommandSimple GetWhere(DisconnectedStrategy <T> pair)
        {
            var query = Database.Query <T>().Where(pair.DownloadSubset !).Select(a => a.Id);

            return(Administrator.QueryPreCommand(query));
        }
Exemplo n.º 3
0
        protected virtual int UnsafeLock <T>(Lite <DisconnectedMachineEntity> machine, DisconnectedStrategy <T> strategy, Lite <DisconnectedExportEntity> stats) where T : Entity, new()
        {
            using (ExecutionMode.Global())
            {
                var result = Database.Query <T>().Where(strategy.UploadSubset !)
                             .Where(a => a.Mixin <DisconnectedSubsetMixin>().DisconnectedMachine != null)
                             .Select(a => "{0} locked in {1}".FormatWith(a.Id, a.Mixin <DisconnectedSubsetMixin>().DisconnectedMachine !.Entity.MachineName))
                             .ToString("\r\n");

                if (result.HasText())
                {
                    stats.MListElementsLite(_ => _.Copies).Where(a => a.Element.Type.Is(typeof(T).ToTypeEntity())).UnsafeUpdateMList()
                    .Set(mle => mle.Element.Errors, mle => result)
                    .Execute();
                }

                return(Database.Query <T>().Where(strategy.UploadSubset !).UnsafeUpdate()
                       .Set(a => a.Mixin <DisconnectedSubsetMixin>().DisconnectedMachine, a => machine)
                       .Set(a => a.Mixin <DisconnectedSubsetMixin>().LastOnlineTicks, a => a.Ticks)
                       .Execute());
            }
        }