Пример #1
0
 private Command getDataFromServer(Command cmd)
 {
     XmlManager xmlManager = new XmlManager();
     Security SmartSecurity = new Security();
     string category = cmd.Parameter;
     string filename = cmd.Filename;
     //TODO: IS FILE PATH ALLOWED?
     FileManager MyFileManager = new FileManager();
     byte[] data = MyFileManager.loadFile(category, filename);
     Logger.getDataFromServer();
     return CommandFactory.createCommand(cmd.Id, SERVERNAME, SEND_DATA_TO_CLIENT, filename, category, data);
 }
Пример #2
0
 private Command thumbnail(Command cmd)
 {
     CommandFactory cmdFactory = new CommandFactory();
     Security SmartSecurity = new Security();
     XmlManager xmlManager = new XmlManager();
     List<string> allRootPaths = xmlManager.getAllChilds();
     //TODO: IS IT A REAL IMAGE????
     Image image = Image.FromFile(cmd.Filename);
     Image thumb = image.GetThumbnailImage(120, 120, () => false, IntPtr.Zero);
     ImageConverter converter = new ImageConverter();
     byte[] imgArray = (byte[])converter.ConvertTo(thumb, typeof(byte[]));
     return CommandFactory.createCommand(this.SmartAuthenticator.Id, SERVERNAME, SEND_CLIENT_THUMBNAIL, cmd.Filename, "none", imgArray);
 }
Пример #3
0
 private Command deleteFileFromServer(Command cmd)
 {
     Security SmartSecurity = new Security();
     XmlManager xmlManager = new XmlManager();
     List<string> allRootPaths = xmlManager.getAllChilds();
     CommandFactory cmdFactory = new CommandFactory();
     //TODO: IS FILE PATH ALLOWED?
     //if (SmartSecurity.PathIsAllowed(allRootPaths,cmd.Filename))
     //{
     FileManager fileManager = new FileManager();
     fileManager.deleteFile(cmd.Filename);
     return CommandFactory.createCommand(SmartAuthenticator.Id,SERVERNAME,STATUS,cmd.Filename,"deleted file",new byte[1]);
     //}
     //return CommandFactory.createCommand(SmartAuthenticator.Id, SERVERNAME, STATUS, cmd.Filename, "not deleted file", new byte[1]);
 }