Ejemplo n.º 1
0
        public TagView(Entry e, MainWindow _root)
        {
            InitializeComponent();
            this.root = _root;
            this.entry = e;     

            Keys = entry.Meta.getKeys();
            tagListBox.ItemsSource = this.entry.Meta.getKeys();
        }
Ejemplo n.º 2
0
 public MainWindow()
 {
     InitializeComponent();
     //folder icon init
     ImageSourceConverter c = new ImageSourceConverter();
     folderIcon = (ImageSource)c.ConvertFrom("pack://application:,,,/img/folderImage.png");
     entry = new Entry();
     
     ManagementObjectSearcher theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE InterfaceType='USB'");
     foreach (ManagementObject currentObject in theSearcher.Get())
     {
         ManagementObject theSerialNumberObjectQuery = new ManagementObject("Win32_PhysicalMedia.Tag='" + currentObject["DeviceID"] + "'");
         MessageBox.Show(theSerialNumberObjectQuery["SerialNumber"].ToString());
     }
     //Request = new RequestManager();
     //watcher = new FileSystemWatcher();
 }
Ejemplo n.º 3
0
        public void deleteFileFromMeta(Entry entry, EntryElement target)
        {

        }
Ejemplo n.º 4
0
 public static void deleteEntry(Queue<History> historyQueue, Entry entry, EntryElement e)
 {
     EntryElement parent = EntryElement.getParent(entry, e);
     if (parent != null)
     {
         if (e.Type == EntryType.Folder)
         {
             deleteEntryHelper(historyQueue, entry, e);
         }
         historyQueue.Enqueue(parent.removeChild(e));
     }
 }
Ejemplo n.º 5
0
 public static Entry buildEntryFromFileList(Entry entry, EntryElement[] fileList)
 {
     if (fileList.Length > 0)
     {
         Entry newEntry = new Entry();
         newEntry.setRoot(fileList[0]);
         entry.Root.File.FileId = newEntry.Root.File.FileId;
         for (int i = 1; i < fileList.Length; i++)
         {
             EntryElement parent = EntryElement.findParent(newEntry.Root, fileList[i]);
             parent.addChild(entry, fileList[i]);
         }
         return newEntry;
     }
     return null;            
 }
Ejemplo n.º 6
0
 public static void compareEntryHelper(Queue<History> historyQueue, Hashtable metadata, Entry prv, Entry cur)
 {
     recursiveCompareDelete(historyQueue, metadata, prv, prv.Root, cur.Root);
     recursiveCompareCreate(historyQueue, metadata, prv, prv.Root, cur.Root);
 }
Ejemplo n.º 7
0
        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);
                            }
                        }
                    }

                    
                }
            }
        }
Ejemplo n.º 8
0
        public void uploadSynk(string uId, string key, Entry entry)
        {
            foreach (History h in entry.HistoryQueue)
            {
                if (h.Type == HistoryType.Create)
                {
                    uploadFile(uId, key, entry, h.Data);
                }
                else if (h.Type == HistoryType.Delete)
                {

                }
                else if (h.Type == HistoryType.Change)
                {

                }
                else if (h.Type == HistoryType.Rename)
                {

                }
                else
                {

                }
            }
        }
Ejemplo n.º 9
0
        public int uploadFile(string uId, string Key, Entry entry, FileData f)
        {
            using (HttpClient client = new HttpClient())
            {

                using (MultipartFormDataContent content = new MultipartFormDataContent())
                {
                    string fileId = f.FileName;
                    KeyValuePair<string, string>[] values = new KeyValuePair<string, string>[] {
                        new KeyValuePair<string, string>("parentId", HttpUtility.UrlEncode(f.Parent.ToString())),
                        new KeyValuePair<string, string>("userId", HttpUtility.UrlEncode(uId)),
                        new KeyValuePair<string, string>("clientKey", HttpUtility.UrlEncode(Key))
                    };

                    foreach (var keyValuePair in values)
                    {
                        content.Add(new StringContent(keyValuePair.Value, Encoding.UTF8), keyValuePair.Key);
                    }

                    ByteArrayContent fileContent = new ByteArrayContent(System.IO.File.ReadAllBytes(entry.RootPath + f.FullPathStr  + "\\" + f.FileName));
                    fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
                    {
                        Name = "file",
                        FileName = HttpUtility.UrlEncode(f.FileName)
                    };

                    content.Add(fileContent);
                    var requestUri = "http://210.118.74.120:8080/cu/api/upload";

                    //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data"));
                    //var result2 = client.PostAsync(requestUri, content).Result;
                    System.Net.Http.HttpResponseMessage response = client.PostAsync(requestUri, content).Result;
                    dynamic jsonStr = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);
                    string r = jsonStr["result"];

                    if (r.Equals("true"))
                    {
                        return jsonStr["fileId"];
                    }
                    else
                    {
                        return -1;
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public void downloadFile(string uId, string Key, Entry entry, EntryElement e)
 {
     string req = string.Format("fileId={0}&userId={1}&clientKey={2}", e.FID, uId, Key);            
     HttpWebResponse reqResult = SendPOSTRequest("http://210.118.74.120:8080/cu/api/download", req, null, null, true);
     GetResponseContentToFile(reqResult,entry.RootPath + e.File.FullPathStr + "\\" + e.FILENAME);
 }
Ejemplo n.º 11
0
        public void fileDownload(string uId, string Key, int fileId, string root, Entry entry, History h)
        {
            string req = string.Format("fileId={0}&userId={1}&clientKey={2}", fileId, uId, Key);
            HttpWebResponse reqResult = SendPOSTRequest("http://210.118.74.120:8080/cu/api/download", req, null, null, true);
            string rpath = makePath(entry, h);
            string fullPath = root + rpath + "\\" + h.Data.FileName;
            string[] path = makePathToken(entry, h);
            EntryElement targetFolder = entry.Root;
            EntryElement newEntryElement;

            if (path != null)
            {
                for (int i = 0; i < path.Length; i++)
                {
                    targetFolder = (EntryElement)targetFolder.NamedChildren[path[i]];
                }
            }

            if (!targetFolder.NamedChildren.ContainsKey(h.Data.FileName))
            {
                h.Data.FullPathStr = rpath;

                GetResponseContentToFile(reqResult, fullPath);

                newEntryElement = new EntryElement
                {
                    File = h.Data,
                    Type = EntryType.File
                };

                targetFolder.Children.Add(newEntryElement);
                targetFolder.NamedChildren.Add(h.Data.FileName, newEntryElement);
            }
            else
            {
                if (h.Data.FileId != ((EntryElement)targetFolder.NamedChildren[h.Data.FileName]).File.FileId)
                {
                    string prvFileName = h.Data.FileName;
                    h.Data.FileName = h.Data.FileName + "_";
                    h.Data.FullPathStr = rpath + "\\" + h.Data.FileName;
                    fullPath = root + rpath + "\\" + h.Data.FileName;
                    
                    GetResponseContentToFile(reqResult, fullPath);

                    newEntryElement = new EntryElement
                    {
                        File = h.Data,
                        Type = EntryType.File
                    };

                    targetFolder.Children.Add(newEntryElement);
                    targetFolder.NamedChildren.Add(h.Data.FileName, newEntryElement);
                    string date = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
                    entry.HistoryQueue.Enqueue(new History(HistoryType.Rename, h.Data, rpath + "\\" + prvFileName, date, false));
                }
            }
        }
Ejemplo n.º 12
0
        public void makeFolder(string root, Entry entry, History h)
        {
            string rpath = makePath(entry, h);
            string fullPath = root + rpath + "\\" + h.Data.FileName; ;
            string[] path = makePathToken(entry, h);
            EntryElement newEntryElement;
            EntryElement targetFolder = entry.Root;
            if (path != null)
            {
                for (int i = 0; i < path.Length; i++)
                {
                    targetFolder = (EntryElement)targetFolder.NamedChildren[path[i]];
                }                
            }

            if (!targetFolder.NamedChildren.ContainsKey(h.Data.FileName))
            {

                h.Data.FullPathStr = rpath + "\\" + h.Data.FileName;
                newEntryElement = new EntryElement
                {
                    File = h.Data,
                    Type = EntryType.Folder
                };

                targetFolder.Children.Add(newEntryElement);
                targetFolder.NamedChildren.Add(h.Data.FileName, newEntryElement);

                System.IO.Directory.CreateDirectory(fullPath);
            }
            else
            {
                if (h.Data.FileId != ((EntryElement)targetFolder.NamedChildren[h.Data.FileName]).File.FileId)
                {
                    string prvFileName = h.Data.FileName;
                    h.Data.FileName = h.Data.FileName + "_";
                    h.Data.FullPathStr = rpath + "\\" + h.Data.FileName;
                    fullPath = root + rpath + "\\" + h.Data.FileName ;

                    System.IO.Directory.CreateDirectory(fullPath);

                    newEntryElement = new EntryElement
                    {
                        File = h.Data,
                        Type = EntryType.Folder
                    };

                    targetFolder.Children.Add(newEntryElement);
                    targetFolder.NamedChildren.Add(h.Data.FileName, newEntryElement);
                    string date = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
                    entry.HistoryQueue.Enqueue(new History(HistoryType.Rename, h.Data, rpath + "\\" + prvFileName,date, false));

                }
            }
        }
Ejemplo n.º 13
0
        public string[] makePathToken(Entry entry, History h)
        {
            Queue<string> p = new Queue<string>();
            EntryElement[] pathToken = findParent(entry.Root, h);
            if (pathToken != null)
            {
                for (int i = pathToken.Length - 1; i >= 0; i--)
                {
                    p.Enqueue(pathToken[i].File.FileName);
                }
                string[] result = p.ToArray();
                return result;
            }
            else
                return null;

            
        }
Ejemplo n.º 14
0
 public string makePath(Entry entry, History h)
 {
     /*int current = h.Data.Parent;            
     string result = "";
     while (((FileData)LinearList[current]).Parent != 0)
     {                
         FileData cFile = (FileData)LinearList[current];
         result = "\\" + cFile.FileName + result;
         current = cFile.Parent;
     }            
     return result;*/
     EntryElement[] pathToken = findParent(entry.Root, h);
     string result = "";
     if (pathToken != null)
     {
         for (int i = pathToken.Length - 1; i >= 0; i--)
         {
             result = "\\" + pathToken[i].File.FileName;
         }
     }
     return result;
 }
Ejemplo n.º 15
0
 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);
                 }
             }
         }
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 해당 노드의 부모 노드를 반환한다
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        
        public static EntryElement getParent(Entry entry, EntryElement e)
        {
            Queue<EntryElement> queue = new Queue<EntryElement>();
            queue.Enqueue(entry.Root);

            while (queue.Count > 0)
            {
                EntryElement target = queue.Dequeue();
                if (target.contains(e))
                {
                    return target;
                }
                else
                {
                    EntryElement[] Directories = target.getDirectories();
                    //EntryElement[] Files = target.getFiles();                    
                    foreach (EntryElement d in Directories)
                    {
                        queue.Enqueue(d);
                    }
                }
            }
            return null;
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 두 Entry를 비교, 클라이언트의 동기화 이전 목록과 현제 목록을 비교하여 History 생성 및 Metadata입력
 /// </summary>
 /// <param name="prv"></param>
 /// <param name="cur"></param>
 public static void compareEntry(Entry prv, Entry cur)
 {
     curQueue.Clear();
     metaTable.Clear();
     compareEntryHelper(curQueue, metaTable, prv, cur);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// EntryElement의 자식도느 추가
        /// </summary>
        /// <param name="entry">전체 Entry</param>
        /// <param name="e">추가 할 EntryElement</param>
        public History addChild(Entry entry, EntryElement e)
        {
            if (!contains(e))
            {
                int count = 1;
                string[] fileNameToken = e.FILENAME.Split('.');
                string resultFileName = e.FILENAME;
                if (fileNameToken.Length > 1)
                {
                    while (NamedChildren.Contains(resultFileName))
                    {
                        
                        resultFileName = makeFileName(fileNameToken[0], fileNameToken[1], count++);
                    }
                }
                else
                {
                    while (NamedChildren.Contains(resultFileName))
                    {
                        resultFileName = makeFileName(fileNameToken[0], "", count++);
                    }
                }

                if (count > 1)
                {
                    System.IO.File.Move(entry.RootPath + e.File.FullPathStr + "\\" + e.FILENAME, entry.RootPath + e.File.FullPathStr + "\\" + resultFileName);
                    e.File.FileName = resultFileName;
                }

                HistoryFileType ht;
                e.File.Parent = File.FileId;
                Children.Add(e);
                NamedChildren.Add(e.FILENAME, e);

                if (e.Type == EntryType.File)
                    ht = HistoryFileType.File;
                else
                    ht = HistoryFileType.Folder;

                string date = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);

                Date = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);

                return new History
                {
                    Type = HistoryType.Create,
                    FType = ht,
                    Data = e.File,
                    Sync = false,
                    Date = date
                };
            }
            return null;
        }
Ejemplo n.º 19
0
 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);
         }
     }            
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 입력된 EntryElement의 리스트에 포함된 EntryElement를 자식노드에 추가
 /// </summary>
 /// <param name="entryList"></param>
 public void addChildren(Entry entry, EntryElement[] entryList)
 {
     foreach (EntryElement e in entryList)
     {
         addChild(entry, e);
     }
 }
Ejemplo n.º 21
0
        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);
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// File과 Directory를 입력받아 자식노드에 추가
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="fileList"></param>
        /// <param name="folderList"></param>
        public void addChildren(Entry entry, string[] fileList, string[] folderList)
        {
            foreach (string file in fileList)
            {
                EntryElement newElement = new EntryElement(entry, EntryType.File, file);                
                addChild(entry, newElement);              

                string date = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                entry.addMetaData(date, newElement.File);
                string[] ext = file.Split('.');
                if (ext.Length > 1)
                    entry.addMetaData(ext.Last(), newElement.File);
            }
            foreach (string folder in folderList)
            {
                EntryElement newElement = new EntryElement(entry, EntryType.Folder, folder);                
                addChild(entry, newElement);
            }
        }
Ejemplo n.º 23
0
        public static void deleteEntryHelper(Queue<History> historyQueue, Entry entry, EntryElement e)
        {
            EntryElement[] folderList = e.getDirectories();
            EntryElement[] fileList = e.getFiles();

            foreach (EntryElement d in folderList)
            {
                deleteEntry(historyQueue, entry, d);
                historyQueue.Enqueue(e.removeChild(d));
            }

            
            string date = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
            foreach (EntryElement f in fileList)
            {                
                string[] ext = f.FILENAME.Split('.');
                if (ext.Length > 1)
                    entry.addMetaData(ext.Last(), e.File);
                entry.addMetaData(date, e.File);
                historyQueue.Enqueue(e.removeChild(f));
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 두 Entry를 병합, 서버와 클라이언트간 동기화를 위해 사용. 병합 후 히스토리 생성
        /// </summary>
        /// <param name="prv"></param>
        /// <param name="cur"></param>
        public static void mergeEntry(Entry svr, Entry clt, RequestManager rm)
        {
            //Client용 queue
            curQueue.Clear();

            //Server용 queue
            svrQueue.Clear();

            //병합 시작
            mergeEntryHelper(svrQueue, curQueue, svr, clt, rm);
        }
Ejemplo n.º 25
0
        public EntryElement(Entry entry, EntryType type, string file)
        {
            this.Type = type;

            string[] rootToken = entry.RootPath.Split('\\');
            string[] fileToken = file.Split('\\');
            string relativePath = "";
            FileData target;
            //EntryElement parentElement = entry.Root;
            for (int i = rootToken.Length; i < fileToken.Length - 1; i++)
            {
                relativePath = relativePath + "\\" + fileToken[i];
            }



            if (type == EntryType.File)
                target = new FileData
                {
                    FileName = fileToken.Last(),
                    FileId = entry.count--,
                    ID = FileManager.GetFileIDB(file).ToString(),
                    FullPathStr = relativePath
                    //Parent = parentElement.FID
                };
            else
                target = new FileData
                {
                    FileName = fileToken.Last(),
                    FileId = entry.count--,
                    ID = "-1",
                    FullPathStr = relativePath
                    //Parent = parentElement.FID
                };

            this.File = target;
            this.Children = new ArrayList();
            this.Metadata = new ArrayList();
            this.NamedChildren = new Hashtable();
            Date = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
        }
Ejemplo n.º 26
0
        public static void mergeEntryHelper(Queue<History> svrQueue, Queue<History> cltQueue, Entry svr, Entry clt, RequestManager rm)
        {
            //병합은 삭제 없이 생성만 수행

            //1. 업로드 : FID가 없는 엔트리에 대해 업로드 수행 후 FID 설정
            //폴더는 이름이 있는지 없는지 확인 있다면 FID 있지 확인 후 FID 설정
            clt.Root.File.FileId = svr.Root.FID;
            uploadEntryElement(clt, svr.Root, clt.Root, rm);
            string[] Keys = new string[clt.Meta.Count];
            clt.Meta.Keys.CopyTo(Keys, 0);
            foreach (string key in Keys)
            {
                ArrayList al = (ArrayList)clt.Meta[key];
                foreach (FileData val in al)
                {
                    EntryElement t = EntryElement.getChild(clt.Root, val.ID);
                    rm.insertMeta(rm.userID, rm.aKey, t.File, key);
                }
            }

            //2. 다운로드 : 파일 비교 후 클라이언트 측 엔트리에 존재하지 않는 파일 모두 다운로드
            //파일아이디로 엔트리 검색 후 null인 노드에 대해 다운로드한다
            downloadEntryElement(clt, svr.Root, clt.Root, rm);
        }
Ejemplo n.º 27
0
 public TagView()
 {
     InitializeComponent();
     tagListBox.ItemsSource = null;
     entry = null;
 }
Ejemplo n.º 28
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 29
0
        private void SyncOKbutton_Click(object sender, RoutedEventArgs e)
        {
            //최신 목록을 만들어 ㄱㄱ
            mw.stop();
            Entry currentEntry = new Entry();
            currentEntry.setRoot(mw.defaultPath);
            currentEntry.buildEntry();

            currentEntry.Root.File.FileId = mw.entry.Root.File.FileId;

            Entry.compareEntry(mw.entry, currentEntry);

            foreach (DictionaryEntry k in Entry.metaTable)
            {
                if (!currentEntry.Meta.Contains(k.Key))
                    currentEntry.Meta.Add(k.Key, k.Value);
            }
            mw.Request.syncStart(mw.Request.userID, mw.Request.aKey);
            ContentManager.EntryElement[] fileList = mw.Request.getAllFileList(mw.userID, mw.userToken);
            Entry entry2 = Entry.buildEntryFromFileList(currentEntry, fileList);

            Entry.mergeEntry(entry2, currentEntry, mw.Request);
            mw.Request.syncEnd(mw.Request.userID, mw.Request.aKey);
            mw.entry = currentEntry;
            mw.play();
            this.Close();
            //((EntryElement)main.entry.Root.Children[0]).File.Parent = entry2.Root.FID;
            //main.Request.uploadFile(main.userID, main.userToken, main.entry, ((EntryElement)main.entry.Root.Children[0]).File);
        }
Ejemplo n.º 30
0
 public void deleteTarget(Entry entry, EntryElement parent, EntryElement target)
 {
     if (target.Type == EntryType.Folder)
     {
         EntryElement[] children = target.Children.ToArray(typeof(EntryElement)) as EntryElement[];
         foreach (EntryElement e in children)
         {
             deleteTarget(entry, target, e);
         }                
         parent.Children.Remove(target);
         parent.NamedChildren.Remove(target.File.FileName);                
     }
     else if (target.Type == EntryType.File)
     {                
         parent.Children.Remove(target);
         parent.NamedChildren.Remove(target.File.FileName);
         deleteFileFromMeta(entry, target);
     }
 }