Esempio n. 1
0
            // Execute when user Log out.
            private void DeleteUserFiles(User user)
            {
                foreach (FileDetails file in user.FileList)
                {
                    if (ServerFileList.ContainsKey(file))
                    {
                        // File exsits in list.
                        if (ServerFileList[file].Contains(user))
                        {
                            // This user in owner of this file.
                            ServerFileList[file].Remove(user);

                            // Delete this file if there is no longer more owners.
                            if (ServerFileList[file].Count == 0)
                            {
                                ServerFileList.Remove(file);
                            }
                        }
                    }
                }

                // Delete user from list if is active.
                if (ActiveUsers.Contains(user))
                {
                    ActiveUsers.Remove(user);
                }

                while (bwUpdateUserList.IsBusy)
                {
                    ;
                }
                bwUpdateUserList.RunWorkerAsync();
            }
Esempio n. 2
0
            // Execute when user Log in.
            private void AddUserFiles(User user, OperationsDB DB)
            {
                lock (thisLock)
                {
                    if (!ActiveUsers.Contains(user))
                    {
                        ActiveUsers.Add(user);
                    }
                }

                foreach (FileDetails file in user.FileList)
                {
                    if (ServerFileList.ContainsKey(file))
                    {
                        // This file already exist in list.
                        // Add this user as adition peer to download.
                        lock (thisLock)
                        {
                            if (!ServerFileList[file].Contains(user))
                            {
                                ServerFileList[file].Add(user);
                                DB.AddPeerToFile(file.FileName, file.FileSize);
                            }
                        }
                    }

                    else
                    {
                        // This file new in list.
                        lock (thisLock)
                        {
                            ServerFileList.Add(file, new List <User>());
                            ServerFileList[file].Add(user);
                            DB.AddFile(file.FileName, file.FileSize);
                        }
                    }
                }

                while (bwUpdateUserList.IsBusy)
                {
                    ;
                }
                bwUpdateUserList.RunWorkerAsync();
            }
Esempio n. 3
0
        private void btnServerFileChoose_Click(object sender, EventArgs e)
        {
            this.ButtonClicked(btnServerFileChoose, alternativeText: lblServer.Text + ":" + btnServerFileChoose.Text);
            ClearStatusMessage();

            try
            {
                var serverPath      = !string.IsNullOrEmpty(txtServerPath.Text) ? txtServerPath.Text : ServerDesktopDirectory;
                var rootBrowserPath = new List <string>();
                if (!ShowRootFolderBrowserDialog(serverPath, out rootBrowserPath, FolderBrowserType.SelectAndEditFolder))
                {
                    return;
                }

                txtServerPath.Text = rootBrowserPath.FirstOrDefault();
                ServerFileList.Clear();
                ServerFileList              = GetFiles(rootBrowserPath.FirstOrDefault());
                grdServer.DataSource        = new BindingSource(ServerFileList, null);
                btnDL.Enabled               = false;
                btnServerCheckAll.Enabled   = ServerFileList.Count > 0;
                btnServerUncheckAll.Enabled = ServerFileList.Count > 0;
            }
            catch (Exception ex)
            {
                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    grdServer.DataSource        = null;
                    btnDL.Enabled               = false;
                    btnServerCheckAll.Enabled   = false;
                    btnServerUncheckAll.Enabled = false;
                }
                else
                {
                    Debug.Fail(ex.ToString());
                    NLogHandler.WriteErrorLog(this, ex, SessionKey);
                }
            }
        }
Esempio n. 4
0
        private void SetServer()
        {
            try
            {
                var task = Util.GetGeneralSettingServerPathAsync(Login);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                var path = task.Result;
                if (!string.IsNullOrEmpty(path))
                {
                    txtServerPath.Text = path;
                }

                if (string.IsNullOrEmpty(txtServerPath.Text) || !Directory.Exists(txtServerPath.Text))
                {
                    return;
                }

                ServerFileList.Clear();
                ServerFileList              = GetFiles(txtServerPath.Text);
                grdServer.DataSource        = new BindingSource(ServerFileList, null);
                btnServerCheckAll.Enabled   = ServerFileList.Count > 0;
                btnServerUncheckAll.Enabled = ServerFileList.Count > 0;
            }
            catch (Exception ex)
            {
                if (ex is IOException || ex is UnauthorizedAccessException)
                {
                    txtServerPath.Clear();
                }
                else
                {
                    Debug.Fail(ex.ToString());
                }
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// WebService를 이용하여 서버 배포 경로의 파일 리스트를 가져온다. (웹서비스 호출)
        /// <paramref name="_liLocalFileList">로컬 파일 리스트 정보</paramref>
        /// </summary>
        private List <ServerFileList> GetServerFileListByWebService(ref List <LocalFileList> _liLocalFileList)
        {
            try
            {
                // 서버 파일 리스트 저장 변수
                List <ServerFileList> liServerFileList = new List <ServerFileList>();

                //using (LocalDeployWebService.LiveUpdateWebServiceClient client = new LocalDeployWebService.LiveUpdateWebServiceClient())
                using (DeployWebService.LiveUpdateWebServiceClient client = new DeployWebService.LiveUpdateWebServiceClient())
                {
                    // 웹서비스 호출
                    var resp = client.GetServerDeployList();

                    // 호출 후 리턴값이 있는 경우
                    if (resp.Count() > 0)
                    {
                        foreach (KeyValuePair <string, string[]> list in resp)
                        {
                            ServerFileList df = new ServerFileList();
                            string         strFileDirectory = string.Empty;
                            string         strResource      = string.Empty;

                            #region + 다국어 구분을 위한 구문
                            if (list.Key.Contains("ko-KR"))
                            {
                                strResource = "ko-KR";
                            }
                            else if (list.Key.Contains("th-TH"))
                            {
                                strResource = "th-TH";
                            }
                            #endregion

                            foreach (var item in list.Value)
                            {
                                if (item[2].ToString().Length > 0)
                                {
                                    strFileDirectory = item[2].ToString();
                                    break;
                                }
                            }

                            for (int i = 0; i < list.Value.Count(); i++)
                            {
                                df.FILE_NAME           = list.Value[0].ToString();      // 파일명
                                df.FILE_EXTENSION      = list.Value[1].ToString();      // 파일 확장자
                                df.FILE_DIRECTORY      = list.Value[2].ToString();      // 파일 경로
                                df.SERVER_FILE_VERSION = list.Value[3].ToString();      // 서버파일 버전
                                df.RESOURCE_KIND       = strResource;                   // 리소스 파일 종류

                                // 로컬리스트와 서버리스트를 비교해서 같은 파일인 경우 서버파일 버전을 로컬파일 버전 필드에 저장
                                _liLocalFileList.Where(p => p.FILE_NAME == df.FILE_NAME).ToList().ForEach(p => p.SERVER_FILE_VERSION = df.SERVER_FILE_VERSION);
                            }

                            liServerFileList.Add(df);
                        }
                    }
                }

                return(liServerFileList);
            }
            catch { throw; }
        }