Esempio n. 1
0
        public override void treatResponse(Dictionary <string, object> response)
        {
            object outobj;

            response.TryGetValue("authorized", out outobj);
            int authorized = Int32.Parse(outobj.ToString());

            if (authorized == 1)
            {
                object queues;
                response.TryGetValue("queues", out queues);
                Dictionary <string, string> queuesNames = JSONManipulator.DeserializeDict <String, string>(queues.ToString());

                foreach (File f in files)
                {
                    if (queuesNames.Keys.Contains(f.path))
                    {
                        string qname;
                        queuesNames.TryGetValue(f.path, out qname);
                        Thread thread = new Thread(delegate()
                        {
                            (new UploadFileOnParts(qname, f)).execute();
                        });
                        thread.Start();
                    }
                    f.fileStatus = FileStatus.UPTODATE;
                }
            }
            else
            {
                FormsHandler.popup(Messages.Attention_NotAutorized);
            }
        }
Esempio n. 2
0
        public List <Folder> initializeFolders(string projects)
        {
            foldersQueue.Clear();
            Dictionary <String, Folder> foldersMap = new Dictionary <string, Folder>();
            List <Folder> initialFolders           = JSONManipulator.DeserializeList <Folder>(projects);

            foreach (Folder fld in initialFolders)
            {
                foldersQueue.Add(fld);
                foldersMap.Add(fld.name, fld);
                fld.path = fld.name;
                List <File> filesInInitialFolder = fld.GetFiles();
                for (int i = 0; i < filesInInitialFolder.Count(); i++)
                {
                    String pathSoFar             = fld.name;
                    File   file                  = filesInInitialFolder.ElementAt(i);
                    String file_path             = file.path;
                    IEnumerable <string> folders = file_path.Replace('\\', '/').Split('/');;
                    String newPath               = pathSoFar;
                    if (folders.ElementAt(0).Equals(file_path))
                    {
                        fld.addFile(file);
                    }
                    else
                    {
                        for (int j = 0; j < folders.Count() - 1; j++)
                        {
                            newPath += "/" + folders.ElementAt(j);
                            Folder parentFolder = GetFolderInMap(foldersMap, pathSoFar);
                            Folder childFolder  = GetFolderInMap(foldersMap, newPath);
                            parentFolder.addChildIfNotThere(childFolder);
                            pathSoFar = newPath;
                        }
                        GetFolderInMap(foldersMap, pathSoFar).addFile(file);
                        fld.removeFile(file);
                    }
                }
            }
            return(foldersQueue.ToList <Folder>());
        }
Esempio n. 3
0
 internal List <File> getFiles(string outString)
 {
     return(JSONManipulator.DeserializeList <File>(outString));
 }