示例#1
0
        public virtual object GetMyJobs(string token, string mac)
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return(null);
            }

            return(from job in this.Context.Jobs
                   join client in this.Context.Clients on job.IdClient equals client.Id
                   join configuration in this.Context.Configurations on job.IdConfiguration equals configuration.Id
                   from source in this.Context.Sources
                   .Where(source => configuration.Id == source.IdConfiguration)
                   .DefaultIfEmpty()
                   from destFtpServer in this.Context.DestFtpServers
                   .Where(destFtpServer => configuration.Id == destFtpServer.IdConfiguration)
                   .DefaultIfEmpty()
                   from destLocal in this.Context.DestLocals
                   .Where(destLocal => configuration.Id == destLocal.IdConfiguration)
                   .DefaultIfEmpty()
                   where client.MAC == mac
                   select new
            {
                configuration,
                source,
                destFtpServer,
                destLocal
            });
        }
示例#2
0
        public virtual object GetClient(string token, string MAC)
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return(null);
            }

            return(this.Context.Clients
                   .Where(client => client.MAC == MAC));
        }
示例#3
0
        public virtual object LoggedClients(string token)
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return(null);
            }

            return(this.Context.Clients
                   .Where(client => client.DateOfLogin != null).ToList());
        }
 public virtual T Get(string token, int Id) // Return specific
 {
     if (AuthenticationController.CheckToken(token))
     {
         return((T)this.DbSet.Find(Id));
     }
     else
     {
         return(null);
     }
 }
 public virtual IEnumerable <T> Get(string token) // Return all
 {
     if (AuthenticationController.CheckToken(token))
     {
         return(this.DbSet as IEnumerable <T>);
     }
     else
     {
         return(null);
     }
 }
        public virtual void Post(string token, T item) // Add
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return;
            }

            if (item == null)
            {
                return;
            }

            this.DbSet.Add(item);
            this.Context.SaveChanges();
        }
        public virtual void Delete(string token, int id)
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return;
            }

            T item = (T)this.DbSet.Find(id);

            if (item == null)
            {
                return;
            }

            this.Context.Set(typeof(T)).Remove(item);
            this.Context.SaveChanges();
        }
示例#8
0
        public virtual object HomeQuery(string token)
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return(null);
            }

            return((from cl in Context.Clients
                    join j in Context.Jobs on cl.Id equals j.IdClient
                    join c in Context.Configurations on j.IdConfiguration equals c.Id
                    select new
            {
                Id = cl.Id,
                CLName = cl.Name,
                COName = c.Name,
                Desc = c.Description
            }).ToList());
        }
示例#9
0
        public virtual object IncomingBackupsQuery(string token)
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return(null);
            }

            return(Context.Schedules
                   .Where(schedule => schedule.IdJob == schedule.Job.Id)
                   .Where(schedule => schedule.Job.Configuration.Id == schedule.Job.IdConfiguration)
                   .Where(Schedule => Schedule.Job.Client.Id == Schedule.Job.IdClient)
                   .Where(schedule => schedule.BackupDate >= DateTime.Now)
                   .Select(schedule => new
            {
                Datum = schedule.BackupDate,
                ClientName = schedule.Job.Client.Name,
                ConfigurationName = schedule.Job.Configuration.Name,
                schedule.Job.Configuration.Description
            }));
        }
        public virtual void Put(string token, T item) // Edit
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return;
            }

            if (item == null)
            {
                return;
            }

            T tmp = Context.Set <T>().Find(item.Id);

            if (tmp == null)
            {
                return;
            }

            this.Context.Entry(tmp).CurrentValues.SetValues(item);
            this.Context.SaveChanges();
        }
示例#11
0
        public virtual object ClientQuery(string token)
        {
            if (!AuthenticationController.CheckToken(token))
            {
                return(null);
            }

            return(Context.Clients
                   .GroupJoin(Context.Jobs
                              .Where(jobs => jobs.IdConfiguration == jobs.Configuration.Id),
                              client => client.Id,
                              q => q.IdClient,
                              (client, q) => new
            {
                Client = client,
                Configuration = q
            })
                   .SelectMany(x => x.Configuration
                               .DefaultIfEmpty(),
                               (x, y) => new
            {
                x.Client.Id,
                x.Client.Name,
                x.Client.MAC,
                Configuration = (y == null ? String.Empty : y.Configuration.Name)
            })
                   .GroupBy(client => client.Id)
                   .ToList()
                   .Select(eg => new
            {
                Id = eg.Key,
                Name = eg.First().Name,
                MAC = eg.First().MAC,
                Configuration = string.Join(",", eg.Select(i => i.Configuration))
            }));
        }