コード例 #1
0
ファイル: Entry.cs プロジェクト: jangsohee/CloudUSB-Client
        public static void recursiveCompareCreate(Queue<History> historyQueue, Hashtable metadata, Entry prvEntry, EntryElement prv, EntryElement cur)
        {
            //파일 생성 : Prv에 없는데 Current에 있는것, 현재 리스트를 과거 리스트에 대조하여 과거 리스트에 없는 Element는 새로 생성된 Element이다.
            EntryElement[] curList = cur.getChildren();
            foreach (EntryElement e in curList)
            {
                EntryElement targetElement = Entry.findTargetByID(prv, e);
                if (targetElement == null)
                {
                    createEntry(historyQueue, metadata, prvEntry, prv, e);
                }
                else
                {
                    //폴더나 파일명이 서로 다르다면
                    if (!e.FILENAME.Equals(targetElement.FILENAME))
                    {
                        historyQueue.Enqueue(targetElement.changeFilename(e.FILENAME));
                    }

                    e.FID = targetElement.FID;
                    //폴더면 제귀적으로 자식 노드를 구성, 파일이면 메타데이터 추가
                    if (targetElement.Type == EntryType.Folder)
                    {                        
                        recursiveCompareCreate(historyQueue, metadata, prvEntry, targetElement, e);
                    }
                    else
                    {
                        e.Metadata = targetElement.Metadata;
                        string[] keys = e.Metadata.ToArray(typeof(string)) as string[];
                        foreach (string key in keys)
                        {
                            if (metadata.Contains(key))
                            {
                                ((ArrayList)metadata[key]).Add(e.File);
                            }
                            else
                            {
                                ArrayList newList = new ArrayList();
                                newList.Add(e.File);
                                metadata.Add(key, newList);
                            }
                        }
                    }

                    
                }
            }
        }
コード例 #2
0
ファイル: Entry.cs プロジェクト: jangsohee/CloudUSB-Client
        public static void createEntry(Queue<History> historyQueue, Hashtable metadata, Entry entry, EntryElement p, EntryElement e)
        {
            EntryElement newElement = new EntryElement
            {
                Index = e.Index,
                Type = e.Type,
                File = e.File,
                Children = e.Children,
                NamedChildren = e.NamedChildren,
                Metadata = e.Metadata
            };

            

            historyQueue.Enqueue(p.addChild(entry, newElement));

            if (e.Type == EntryType.Folder)
            {
                EntryElement[] childrenList = e.getChildren();

                foreach (EntryElement c in childrenList)
                {
                    createEntry(historyQueue, metadata, entry, newElement, c);
                }
            }
        }
コード例 #3
0
ファイル: Entry.cs プロジェクト: jangsohee/CloudUSB-Client
 public static void recursiveCompareDelete(Queue<History> historyQueue, Hashtable metadata, Entry prvEntry, EntryElement prv, EntryElement cur)
 {
                 
     //파일 삭제 : Prv에 있는데 Current에 없는것, 과거 리스트를 현재 리스트에 대조하여 현재 리스트에 없는 Element는 삭제된 Element이다.
     EntryElement[] prvList = prv.getChildren();
     foreach (EntryElement e in prvList)
     {
         EntryElement targetElement = Entry.findTargetByID(cur, e);
         if (targetElement == null)
         {
             deleteEntry(historyQueue, prvEntry, e);
         }
         else
         {
             //폴더면 제귀적으로 자식 노드를 구성
             if (targetElement.Type == EntryType.Folder)
                 recursiveCompareDelete(historyQueue, metadata, prvEntry, e, cur);
         }
     }            
 }
コード例 #4
0
ファイル: Entry.cs プロジェクト: jangsohee/CloudUSB-Client
        public static EntryElement findTargetByID(EntryElement root, EntryElement e)
        {
            if (root.Type == EntryType.Folder)
            {
                if (root.FILENAME == e.FILENAME)
                    return root;
                else
                {
                    EntryElement[] nextfile = root.getChildren();

                    foreach (EntryElement n in nextfile)
                    {
                        EntryElement element = findTargetByID(n, e);
                        if (element != null)
                            return element;
                    }
                    return null;
                }
            }
            else
            {
                if (root.File.ID == e.File.ID)
                    return root;
                else
                    return null;
            }            
        }
コード例 #5
0
ファイル: Entry.cs プロジェクト: jangsohee/CloudUSB-Client
 public static void uploadEntryElement(Entry cltEntry, EntryElement svr, EntryElement clt, RequestManager rm)
 {
     EntryElement[] cltList = clt.getChildren();
     foreach (EntryElement e in cltList)
     {   
         if (e.FID < 0)
         {
             //동기화 되지 않은 폴더 및 파일 -> 업로드한다                    
             e.File.Parent = clt.FID;
             if (e.Type == EntryType.Folder)
             {
                 int fid = rm.generateFolder(rm.userID, rm.aKey, e.File);
                 e.File.FileId = fid;
                 uploadEntryElement(cltEntry, svr, e, rm);                        
             }
             else
             {
                 int fid = rm.uploadFile(rm.userID, rm.aKey, cltEntry, e.File);
                 e.File.FileId = fid;
             }
         }
         else
         {
             //동기화된 파일 -> 충돌 확인
             EntryElement targetElement = Entry.findTarget(svr, e);
             if (targetElement == null)
             {
                 if (e.Type == EntryType.Folder)
                 {
                     e.File.Parent = clt.FID;
                     int fid = rm.generateFolder(rm.userID, rm.aKey, e.File);
                     e.File.FileId = fid;
                     
                     uploadEntryElement(cltEntry, svr, e, rm);
                 }
                 else
                 {
                     int fid = rm.uploadFile(rm.userID, rm.aKey, cltEntry, e.File);
                     e.File.FileId = fid;
                 }
             }
             else
             {
                 if (!e.FILENAME.Equals(targetElement.FILENAME))
                 {
                     //rm.renameFile(rm.userID, rm.aKey, e);
                 }
                 else
                 {
                     if (e.Type == EntryType.Folder)
                         uploadEntryElement(cltEntry, svr, e, rm);
                 }
             }
         }
     }
 }
コード例 #6
0
ファイル: Entry.cs プロジェクト: jangsohee/CloudUSB-Client
        public static void downloadEntryElement(Entry cltEntry, EntryElement svr, EntryElement clt, RequestManager rm)
        {
            EntryElement[] children = svr.getChildren();
            foreach (EntryElement c in children)
            {
                EntryElement targetElement = Entry.findTarget(clt, c);
                if (targetElement == null)
                {
                    string fullPath = cltEntry.RootPath + c.File.FullPathStr + "\\" + c.FILENAME;
                    if (c.Type == EntryType.File)
                    {                        
                        rm.downloadFile(rm.userID, rm.aKey, cltEntry, c);
                        EntryElement newElement = new EntryElement(cltEntry, EntryType.File, fullPath);
                        newElement.File.FileId = c.FID;
                        EntryElement parent = Entry.findTarget(clt, svr);
                        parent.addChild(cltEntry, newElement);
                    }
                    else
                    {
                        //폴더 생성
                        System.IO.Directory.CreateDirectory(fullPath);
                        EntryElement newElement = new EntryElement(cltEntry, EntryType.Folder, fullPath);
                        newElement.File.FileId = c.FID;
                        EntryElement parent = Entry.findTarget(clt, svr);
                        parent.addChild(cltEntry, newElement);
                        //생성 된 폴더에 대해 재귀
                        downloadEntryElement(cltEntry, c, clt, rm);
                    }
                }
                else
                {
                    //다운받지 않아도 존재하는 파일. 이부분에서 변경 날짜 확인 후 충돌리스트로
                    //만약 폴더라면 재귀
                    if (!c.FILENAME.Equals(targetElement.FILENAME))
                    {

                    }
                    else
                    {
                        if (c.Type == EntryType.Folder)
                        {
                            downloadEntryElement(cltEntry, c, clt, rm);
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: Entry.cs プロジェクト: jangsohee/CloudUSB-Client
        public static EntryElement findTarget(EntryElement root, EntryElement target)
        {
            if (root.FID == target.File.FileId)
                return root;
            else
            {
                if (root.Type == EntryType.Folder)
                {
                    EntryElement[] nextfile = root.getChildren();

                    foreach (EntryElement n in nextfile)
                    {
                        EntryElement e = findTarget(n, target);
                        if (e != null)
                            return e;
                    }
                }
                
                return null;
            }
        }