예제 #1
0
 /// <summary>
 /// アップロードセッションパネルを追加する。
 /// </summary>
 /// <param name="sessionList">アップロードするセッションのリスト</param>
 public void AddSessionPanels(List <SessionManager.SessionInfo> sessionList)
 {
     try
     {
         sessionList.Sort();
         sessionList.Reverse();
         foreach (SessionManager.SessionInfo info in sessionList)
         {
             UploadSessionPanel panel = new UploadSessionPanel();
             panel.SetSession(info);
             uploadPanel.Controls.Add(panel);
         }
     }
     catch (Exception e)
     {
         PhotoChat.WriteErrorLog(e.ToString());
     }
 }
예제 #2
0
        private void ServerUpload()
        {
            try
            {
                // 進行状況表示ウィンドウ
                int count = 0;
                foreach (Control control in uploadPanel.Controls)
                {
                    if (((UploadSessionPanel)control).DoUpload)
                    {
                        count++;
                    }
                }
                ProgressWindow progressWindow = new ProgressWindow(
                    count, "PhotoChatサーバにアップロードしています");
                count = 0;
                progressWindow.Show(this);

                // サーバにログイン
                PhotoChatClient  client = PhotoChatClient.Instance;
                Command          command;
                ServerConnection connection = new ServerConnection();
                if (connection.IsConnecting)
                {
                    connection.Send(Command.CreateLoginCommand(
                                        client.ID, mailTextBox.Text, passwordTextBox.Text, client.UserName));
                    command = connection.Receive();
                    if (command == null || !bool.Parse(command.UserName))
                    {
                        MessageBox.Show("メールアドレスまたはパスワードが間違っています");
                        connection.Close();
                        progressWindow.Dispose();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("PhotoChatサーバに接続できませんでした");
                    connection.Close();
                    progressWindow.Dispose();
                    return;
                }

                // セッションごとにアップロード
                foreach (Control control in uploadPanel.Controls)
                {
                    UploadSessionPanel panel = (UploadSessionPanel)control;
                    if (panel.DoUpload)
                    {
                        // セッションデータのアップロード開始
                        SessionManager.SessionInfo info = panel.SessionInfo;
                        connection.Send(Command.CreateSessionCommand(
                                            client.ID, info.ID, info.Name, panel.IsPublic));
                        command = connection.Receive();
                        if (command != null && command.Type == Command.TypeSession)
                        {
                            // 端末ごとのデータをアップロード
                            foreach (string directory in Directory.GetDirectories(PhotoChat.UserIndexDirectory))
                            {
                                string filePath = Path.Combine(directory, info.ID + ".dat");
                                if (File.Exists(filePath))
                                {
                                    UploadIndexData(connection, filePath);
                                }
                            }
                            // セッションデータのアップロード完了
                            uploadedSessionList.Add(info);
                        }
                        progressWindow.SetCount(++count);
                    }
                }
                // アップロード終了
                connection.Send(Command.CreateDisconnectCommand(client.ID, client.ID));
                command = connection.Receive();
                if (command != null && command.Type == Command.TypeDisconnect)
                {
                    uploadComplete = true;
                }

                // アカウント情報保存
                if (savePasswordCheckBox.Checked)
                {
                    SaveAccount();
                }

                progressWindow.Dispose();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception e)
            {
                PhotoChat.WriteErrorLog(e.ToString());
            }
        }