Ejemplo n.º 1
0
        List <VulpesSMARTInfo> LoadData(string MachineID, SQLLib sql)
        {
            List <VulpesSMARTInfo> lst = new List <VulpesSMARTInfo>();

            SqlDataReader dr = sql.ExecSQLReader("Select * from SMARTData WHERE MachineID=@id", new SQLParam("@id", MachineID));

            while (dr.Read())
            {
                VulpesSMARTInfo s = new VulpesSMARTInfo();
                sql.LoadIntoClass(dr, s);
                lst.Add(s);
            }
            dr.Close();

            foreach (VulpesSMARTInfo sm in lst)
            {
                sm.Attributes = new Dictionary <int, VulpesSMARTAttribute>();

                dr = sql.ExecSQLReader("Select * from SMARTDataAttributes WHERE MachineID=@id AND PnPDeviceID=@pnp",
                                       new SQLParam("@id", MachineID),
                                       new SQLParam("@pnp", sm.PNPDeviceID));
                while (dr.Read())
                {
                    VulpesSMARTAttribute attr = new VulpesSMARTAttribute();
                    sql.LoadIntoClass(dr, attr);
                    sm.Attributes.Add(attr.ID, attr);
                }
                dr.Close();
            }
            return(lst);
        }
Ejemplo n.º 2
0
        public RESTStatus GetPackage(SQLLib sql, object dummy, NetworkConnectionInfo ni, Int64 id)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            lock (ni.sqllock)
            {
                if (PackageExists(sql, id) == false)
                {
                    ni.Error   = "Invalid data";
                    ni.ErrorID = ErrorFlags.InvalidID;
                    return(RESTStatus.NotFound);
                }
            }

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("Select * FROM Packages WHERE ID=@id",
                                                     new SQLParam("@id", id));
                dr.Read();

                PackageData = new PackageData();
                sql.LoadIntoClass(dr, PackageData);
                dr.Close();
            }
            return(RESTStatus.Success);
        }
Ejemplo n.º 3
0
        public RESTStatus GetPackages(SQLLib sql, object dummy, NetworkConnectionInfo ni)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            PackageDataList       = new PackageDataList();
            PackageDataList.Items = new List <FoxSDC_Common.PackageData>();

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("Select * FROM Packages");

                while (dr.Read())
                {
                    PackageData pd = new PackageData();
                    sql.LoadIntoClass(dr, pd);
                    PackageDataList.Items.Add(pd);
                }

                dr.Close();
            }
            return(RESTStatus.Success);
        }
Ejemplo n.º 4
0
        public RESTStatus GetSTask(SQLLib sql, object dummy, NetworkConnectionInfo ni, Int64 id)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("select * from SimpleTasks WHERE ID=@id", new SQLParam("@id", id));
                if (dr.HasRows == false)
                {
                    dr.Close();
                    return(RESTStatus.NotFound);
                }

                SimpleTask = new SimpleTask();

                while (dr.Read())
                {
                    sql.LoadIntoClass(dr, SimpleTask);
                }
                dr.Close();
            }

            return(RESTStatus.Success);
        }
Ejemplo n.º 5
0
        public RESTStatus GetPackageSigned(SQLLib sql, object dummy, NetworkConnectionInfo ni, Int64 id)
        {
            if (ni.HasAcl(ACLFlags.ComputerLogin) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            lock (ni.sqllock)
            {
                if (PackageExists(sql, id) == false)
                {
                    ni.Error   = "Invalid data";
                    ni.ErrorID = ErrorFlags.InvalidID;
                    return(RESTStatus.NotFound);
                }
            }

            PackageData pp = null;

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("Select * FROM Packages WHERE ID=@id",
                                                     new SQLParam("@id", id));
                dr.Read();

                pp = new PackageData();
                sql.LoadIntoClass(dr, pp);
                dr.Close();
            }

            PackageDataSigned         = new PackageDataSigned();
            PackageDataSigned.Package = pp;
            if (Certificates.Sign(PackageDataSigned, SettingsManager.Settings.UseCertificate) == false)
            {
                FoxEventLog.WriteEventLog("Cannot sign package element with Certificate " + SettingsManager.Settings.UseCertificate, System.Diagnostics.EventLogEntryType.Warning);
                ni.Error   = "Cannot sign package element with Certificate " + SettingsManager.Settings.UseCertificate;
                ni.ErrorID = ErrorFlags.CannotSign;
                return(RESTStatus.ServerError);
            }

            return(RESTStatus.Success);
        }
Ejemplo n.º 6
0
        public RESTStatus ListSTasks(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            lock (ni.sqllock)
            {
                SqlDataReader dr;
                if (string.IsNullOrWhiteSpace(id) == false)
                {
                    if (Computers.MachineExists(sql, id) == false)
                    {
                        ni.Error   = "Access denied";
                        ni.ErrorID = ErrorFlags.InvalidData;
                        return(RESTStatus.NotFound);
                    }

                    dr = sql.ExecSQLReader("select SimpleTasks.*,ComputerName from SimpleTasks inner join ComputerAccounts on ComputerAccounts.MachineID=SimpleTasks.MachineID where SimpleTasks.MachineID=@m order by MachineID,Name",
                                           new SQLParam("@m", id));
                }
                else
                {
                    dr = sql.ExecSQLReader("select SimpleTasks.*,ComputerName from SimpleTasks inner join ComputerAccounts on ComputerAccounts.MachineID=SimpleTasks.MachineID order by MachineID,Name");
                }

                SimpleList      = new SimpleTaskLiteList();
                SimpleList.List = new List <SimpleTaskLite>();

                while (dr.Read())
                {
                    SimpleTaskLite d = new SimpleTaskLite();
                    sql.LoadIntoClass(dr, d);
                    SimpleList.List.Add(d);
                }
                dr.Close();
            }

            return(RESTStatus.Success);
        }
Ejemplo n.º 7
0
        public RESTStatus ListDiskData(SQLLib sql, object dummy, NetworkConnectionInfo ni, string id)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            lock (ni.sqllock)
            {
                SqlDataReader dr;
                if (string.IsNullOrWhiteSpace(id) == false)
                {
                    if (Computers.MachineExists(sql, id) == false)
                    {
                        ni.Error   = "Access denied";
                        ni.ErrorID = ErrorFlags.InvalidData;
                        return(RESTStatus.NotFound);
                    }

                    dr = sql.ExecSQLReader("select DiskData.*,ComputerName from DiskData inner join ComputerAccounts on ComputerAccounts.MachineID=DiskData.MachineID where diskData.MachineID=@m order by MachineID,Caption",
                                           new SQLParam("@m", id));
                }
                else
                {
                    dr = sql.ExecSQLReader("select DiskData.*,ComputerName from DiskData inner join ComputerAccounts on ComputerAccounts.MachineID=DiskData.MachineID order by MachineID,Caption");
                }

                LstDiskData       = new ListDiskDataReport();
                LstDiskData.Items = new List <DiskDataReport>();

                while (dr.Read())
                {
                    DiskDataReport d = new DiskDataReport();
                    sql.LoadIntoClass(dr, d);
                    LstDiskData.Items.Add(d);
                }
                dr.Close();
            }

            return(RESTStatus.Success);
        }
Ejemplo n.º 8
0
        public RESTStatus GetSTaskSigned(SQLLib sql, object dummy, NetworkConnectionInfo ni)
        {
            if (ni.HasAcl(ACLFlags.ComputerLogin) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            SimpleTask SimpleTask;

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("select top 1 * from SimpleTasks WHERE MachineID=@id AND GETUTCDATE()>isnull(execafter,'2010-01-01') ORDER BY ID asc",
                                                     new SQLParam("@id", ni.Username));
                if (dr.HasRows == false)
                {
                    dr.Close();
                    return(RESTStatus.NoContent);
                }

                SimpleTask = new SimpleTask();

                while (dr.Read())
                {
                    sql.LoadIntoClass(dr, SimpleTask);
                }
                dr.Close();
            }

            STaskDataSigned       = new SimpleTaskDataSigned();
            STaskDataSigned.STask = SimpleTask;
            if (Certificates.Sign(STaskDataSigned, SettingsManager.Settings.UseCertificate) == false)
            {
                FoxEventLog.WriteEventLog("Cannot sign STask Data with Certificate " + SettingsManager.Settings.UseCertificate, System.Diagnostics.EventLogEntryType.Warning);
                ni.Error   = "Cannot sign STask Data with Certificate " + SettingsManager.Settings.UseCertificate;
                ni.ErrorID = ErrorFlags.CannotSign;
                return(RESTStatus.ServerError);
            }

            return(RESTStatus.Success);
        }