private void AuthorizeFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    try
                    {
                        FileSyncAuthorizeInfo authInfo = new FileSyncAuthorizeInfo();

                        string xml = arg.Response;

                        XmlDocument xd = new XmlDocument();
                        xd.LoadXml(xml);

                        authInfo.AuthSid = xd.SelectSingleNode("/QDocRoot/authSid").InnerText;
                        authInfo.UserName = xd.SelectSingleNode("/QDocRoot/username").InnerText;

                        FileSync.CurrentUser.SaveUserSessionInfo(authInfo);

                        if (tempCallback != null)
                        {
                            tempCallback(this, arg);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (tempCallback != null)
                        {
                            FileSyncError error = new FileSyncError();
                            error.error_code = requestErrorDomain;
                            error.error_msg = "An error occurs when parse server response." + ex.Message;

                            tempCallback(this, new FileSyncRequestResultEventArgs(null, FileSyncAPIRequestResult.Fail, error));
                        }
                    }

                    break;
                case FileSyncAPIRequestResult.Fail:
                    if (tempCallback != null)
                    {
                        tempCallback(this, arg);
                    }
                    break;
                default:
                    break;
            }
        }
        private void GetTreeFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    List<Folder> list = new List<Folder>();

                    list = JsonHelper.DeserializeObject<List<Folder>>(arg.Response);

                    AddFolder(list);

                    break;
                case FileSyncAPIRequestResult.Fail:
                    //SetResult(arg.Error.error_msg);
                    break;
                default:

                    break;
            }
        }
        private void AuthorizeFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    if (FileSync.CurrentUser.IsUserSessionValid())
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("登录失败!请重新登录");
                    }

                    //if (this.InvokeRequired)
                    //{
                    //    this.Invoke((EventHandler)delegate
                    //    {
                    //        this.Close();
                    //    });
                    //}
                    //else
                    //{
                    //    this.Close();
                    //}

                    //this.Owner.Show();


                    break;
                case FileSyncAPIRequestResult.Fail:
                    MessageBox.Show("登录失败!请重新登录");
                    break;
                default:
                    break;
            }

        }
        private void MoveFileFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    try
                    {
                        BaseResponse response = JsonConvert.DeserializeObject<BaseResponse>(arg.Response);

                        if (response.Status == 1)
                        {
                            MainFrm main = TaskForm.Instance.Owner as MainFrm;
                            if (main != null)
                            {
                                if (main.InvokeRequired)
                                {
                                    main.Invoke((EventHandler)delegate
                                    {
                                        main.SyncFolderViewState();
                                        main.SyncFileViewState();
                                    });
                                }
                                else
                                {
                                    main.SyncFolderViewState();
                                    main.SyncFileViewState();
                                }
                            }

                            UiLog.Log("移动文件成功");
                        }
                        else
                        {
                            UiLog.Log("移动文件失败");
                        }

                        if (currentTask != null)
                        {
                            list.Remove(currentTask);
                            currentTask = null;
                            LoadBackgroundTask();
                        }
                        else
                        {
                            DoBackgroundTask();
                        }
                    }
                    catch (Exception ex)
                    {
                        UiLog.Log(ex.Message);
                    }

                    break;
                case FileSyncAPIRequestResult.Fail:
                    MessageBox.Show("调用API时发生错误, 错误消息:" + arg.Error.error_msg);
                    break;
                default:
                    break;
            }
        }
Exemple #5
0
        private void GetListFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    FileListResponse fileList = JsonHelper.DeserializeObject<FileListResponse>(arg.Response);

                    if (listView1.InvokeRequired)
                    {
                        listView1.Invoke((EventHandler)delegate
                        {
                            listView1.Items.Clear();

                            if (fileList != null && fileList.datas != null && fileList.datas.Length > 0)
                            {
                                string filePath = arg.RequestParams["path"].ToString();

                                foreach (FileMeta file in fileList.datas)
                                {
                                    ListViewItem item = new ListViewItem(file.filename);
                                    file.FilePath = filePath;
                                    file.FullPath = LinuxEnvironment.ToPath(Path.Combine(file.FilePath, file.filename));
                                    item.Tag = file;

                                    string key = "";
                                    if (file.isfolder == "1")
                                    {
                                        key = "folder.gif";

                                        if (file.filename.Contains("@Recycle"))
                                        {
                                            key = file.filename.Remove(0, 1) + ".gif";
                                        }
                                    }
                                    else
                                    {
                                        key = "undefind.gif";

                                        ImageList il = listView1.LargeImageList;

                                        string ext = Path.GetExtension(file.filename);
                                        if (!string.IsNullOrEmpty(ext) && ext.Length > 0)
                                        {
                                            key = ext.Remove(0, 1) + ".gif";
                                        }

                                        if (!il.Images.ContainsKey(key))
                                        {
                                            key = "undefind.gif";
                                        }
                                    }

                                    item.ImageKey = key;

                                    listView1.Items.Add(item);
                                }
                            }
                        });
                    }
                    else
                    {
                        listView1.Items.Clear();

                        if (fileList != null && fileList.datas != null && fileList.datas.Length > 0)
                        {
                            string filePath = arg.RequestParams["path"].ToString();

                            foreach (FileMeta file in fileList.datas)
                            {
                                ListViewItem item = new ListViewItem(file.filename);
                                file.FilePath = filePath;
                                file.FullPath = LinuxEnvironment.ToPath(Path.Combine(file.FilePath, file.filename));
                                item.Tag = file;
                                string key = "folder.gif";
                                if (file.isfolder == "1")
                                {
                                    if (file.filename.Contains("@Recycle"))
                                    {
                                        key = file.filename.Remove(0, 1) + ".gif";
                                    }
                                }
                                else
                                {
                                    ImageList il = listView1.LargeImageList;

                                    string ext = Path.GetExtension(file.filename);
                                    if (!string.IsNullOrEmpty(ext) && ext.Length > 0)
                                    {
                                        key = ext.Remove(0, 1) + ".gif";
                                    }

                                    if (!il.Images.ContainsKey(key))
                                    {
                                        key = "undefind.gif";
                                    }
                                }

                                item.ImageKey = key;
                                listView1.Items.Add(item);
                            }
                        }
                    }

                    break;
                case FileSyncAPIRequestResult.Fail:
                    MessageBox.Show(arg.Error.error_msg);
                    break;
                default:
                    break;
            }
        }
Exemple #6
0
        private void LoginoutFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    try
                    {
                        BaseResponse response = JsonConvert.DeserializeObject<BaseResponse>(arg.Response);

                        if (response.Status == 1)
                        {
                            Program.fsConnect = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        UiLog.Log(ex.Message);
                    }

                    break;
                case FileSyncAPIRequestResult.Fail:
                    MessageBox.Show("调用API时发生错误, 错误消息:" + arg.Error.error_msg);
                    break;
                default:
                    break;
            }
        }
Exemple #7
0
        private void CreateDirFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    try
                    {
                        BaseResponse response = JsonConvert.DeserializeObject<BaseResponse>(arg.Response);

                        if (response.Status == 1)
                        {
                            SyncFolderViewState();
                            SyncFileViewState();

                            UiLog.Log("创建文件夹成功");
                        }
                        else
                        {
                            UiLog.Log("创建文件夹失败");
                        }
                    }
                    catch (Exception ex)
                    {
                        UiLog.Log(ex.Message);
                    }

                    break;
                case FileSyncAPIRequestResult.Fail:
                    MessageBox.Show("调用API时发生错误, 错误消息:" + arg.Error.error_msg);
                    break;
                default:
                    break;
            }
        }
Exemple #8
0
        private void GetDomainIPListFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    try
                    {
                        AboutMeFrm frm = new AboutMeFrm();
                        frm.Content = arg.Response;
                        frm.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        UiLog.Log(ex.Message);
                    }

                    break;
                case FileSyncAPIRequestResult.Fail:
                    MessageBox.Show("调用API时发生错误, 错误消息:" + arg.Error.error_msg);
                    break;
                default:
                    break;
            }
        }
Exemple #9
0
        private void UploadFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    FileManagerResponse response = new FileManagerResponse();

                    if (!string.IsNullOrEmpty(arg.Response))
                    {
                        response = JsonHelper.DeserializeObject<FileManagerResponse>(arg.Response);

                        response.RawResponse = arg.Response;

                        BaseResponse resp = JsonConvert.DeserializeObject<BaseResponse>(arg.Response);

                        if (resp.Status == 1)
                        {
                            SyncFileViewState();

                            UiLog.Log("上传文件成功");
                        }
                        else
                        {
                            UiLog.Log("上传文件失败");
                        }
                    }

                    break;
                case FileSyncAPIRequestResult.Fail:
                    MessageBox.Show("调用API时发生错误, 错误消息:" + arg.Error.error_msg);
                    break;
                default:
                    break;
            }
        }
        private void GetStatusFinish(object obj, FileSyncRequestResultEventArgs arg)
        {
            switch (arg.Result)
            {
                case FileSyncAPIRequestResult.Success:

                    if (listView1.InvokeRequired)
                    {
                        listView1.Invoke((EventHandler)delegate
                        {
                            FileListResponse fileList = JsonHelper.DeserializeObject<FileListResponse>(arg.Response);

                            listView1.Items.Clear();
                            listView1.Items.Add(new ListViewItem(string.Format("acl:{0}", fileList.acl)));
                            listView1.Items.Add(new ListViewItem(string.Format("is_acl_enable:{0}", fileList.is_acl_enable)));
                            listView1.Items.Add(new ListViewItem(string.Format("is_winacl_enable:{0}", fileList.is_winacl_enable)));
                            listView1.Items.Add(new ListViewItem(string.Format("is_winacl_support:{0}", fileList.is_winacl_support)));
                            listView1.Items.Add(new ListViewItem(string.Format("rtt_support:{0}", fileList.rtt_support)));

                            if (fileList.datas != null && fileList.datas.Length > 0)
                            {
                                listView1.Items.Add(new ListViewItem(string.Format("filename:{0}", fileList.datas[0].filename)));
                                listView1.Items.Add(new ListViewItem(string.Format("FilePath:{0}", FileMeta.FilePath)));
                                listView1.Items.Add(new ListViewItem(string.Format("filesize:{0}", fileList.datas[0].filesize)));
                                listView1.Items.Add(new ListViewItem(string.Format("filetype:{0}", fileList.datas[0].filetype)));
                                listView1.Items.Add(new ListViewItem(string.Format("group:{0}", fileList.datas[0].group)));
                                listView1.Items.Add(new ListViewItem(string.Format("iscommpressed:{0}", fileList.datas[0].iscommpressed)));
                                listView1.Items.Add(new ListViewItem(string.Format("isfolder:{0}", fileList.datas[0].isfolder)));
                                listView1.Items.Add(new ListViewItem(string.Format("mt:{0}", fileList.datas[0].mt)));
                                listView1.Items.Add(new ListViewItem(string.Format("owner:{0}", fileList.datas[0].owner)));
                                listView1.Items.Add(new ListViewItem(string.Format("privilege:{0}", fileList.datas[0].privilege)));
                            }
                        });
                    }
                    else
                    {
                        FileListResponse fileList = JsonHelper.DeserializeObject<FileListResponse>(arg.Response);

                        listView1.Items.Clear();
                        listView1.Items.Add(new ListViewItem(string.Format("acl:{0}", fileList.acl)));
                        listView1.Items.Add(new ListViewItem(string.Format("is_acl_enable:{0}", fileList.is_acl_enable)));
                        listView1.Items.Add(new ListViewItem(string.Format("is_winacl_enable:{0}", fileList.is_winacl_enable)));
                        listView1.Items.Add(new ListViewItem(string.Format("is_winacl_support:{0}", fileList.is_winacl_support)));
                        listView1.Items.Add(new ListViewItem(string.Format("rtt_support:{0}", fileList.rtt_support)));

                        if (fileList.datas != null && fileList.datas.Length > 0)
                        {
                            listView1.Items.Add(new ListViewItem(string.Format("filename:{0}", fileList.datas[0].filename)));
                            listView1.Items.Add(new ListViewItem(string.Format("FilePath:{0}", fileList.datas[0].FilePath)));
                            listView1.Items.Add(new ListViewItem(string.Format("filesize:{0}", fileList.datas[0].filesize)));
                            listView1.Items.Add(new ListViewItem(string.Format("filetype:{0}", fileList.datas[0].filetype)));
                            listView1.Items.Add(new ListViewItem(string.Format("group:{0}", fileList.datas[0].group)));
                            listView1.Items.Add(new ListViewItem(string.Format("iscommpressed:{0}", fileList.datas[0].iscommpressed)));
                            listView1.Items.Add(new ListViewItem(string.Format("isfolder:{0}", fileList.datas[0].isfolder)));
                            listView1.Items.Add(new ListViewItem(string.Format("mt:{0}", fileList.datas[0].mt)));
                            listView1.Items.Add(new ListViewItem(string.Format("owner:{0}", fileList.datas[0].owner)));
                            listView1.Items.Add(new ListViewItem(string.Format("privilege:{0}", fileList.datas[0].privilege)));

                        }
                    }
                    break;
                case FileSyncAPIRequestResult.Fail:

                    MessageBox.Show(arg.Error.error_msg);

                    break;
                default:
                    break;
            }
        }