⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 importform.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 4 页
字号:
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void DoNext()
        {
            if (!base.IsDisposed)
            {
                this.progressOutLook.Visible = false;
                if (this._step == this._maxStep)
                {
                    return;
                }
                this._step++;
                if (this._step == 2)
                {
                    if (this.ImportObject.Type == ImportContactType.Outlook)
                    {
                        this.btnNext.Enabled = false;
                        this.progressOutLook.Visible = true;
                        ThreadPool.QueueUserWorkItem(new WaitCallback(this.ImportOutLook), this.ImportObject);
                        return;
                    }
                    goto Label_0240;
                }
                if (this._step != 3)
                {
                    if (this._step == 4)
                    {
                        List<XmlNode> list = new List<XmlNode>();
                        foreach (ListViewItem item in this.lstContacts.Items)
                        {
                            if (item.Checked)
                            {
                                list.Add(item.Tag as XmlNode);
                            }
                        }
                        if (list.Count == 0)
                        {
                            this._frameworkWin.UnifiedMessageBox.ShowInfo(this, "没有数据导入!");
                            this.DoPrevious();
                            return;
                        }
                    }
                    else if (this._step == 5)
                    {
                        if (this.textBoxMyName.Text.Trim().Length == 0)
                        {
                            this._frameworkWin.UnifiedMessageBox.ShowInfo(this, "请输入您的姓名!");
                            this.DoPrevious();
                            return;
                        }
                        FormConfirm confirm = new FormConfirm(this._totalChecked);
                        if (confirm.ShowDialog(this) != DialogResult.OK)
                        {
                            this.DoPrevious();
                            return;
                        }
                    }
                    goto Label_0240;
                }
                if (this.CanImport())
                {
                    if (this.ImportObject.Type != ImportContactType.Outlook)
                    {
                        try
                        {
                            this._importXMLContent = this.ImportObject.GetContactsXML(this, this.txtFilePath.Text);
                        }
                        catch (IOException)
                        {
                            this.DoNextError("导入失败,请确认文件是否正在被使用!");
                            return;
                        }
                        catch (Exception exception)
                        {
                            ClientLogger.WriteException("导入失败", exception);
                            this.DoNextError("导入失败,请检查文件格式是否正确!");
                            return;
                        }
                    }
                    if (this._importXMLContent.Length == 0)
                    {
                        this.DoNextError("没有联系人可以导入。");
                        return;
                    }
                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(this._importXMLContent);
                        this.BindDatas(doc);
                        goto Label_0240;
                    }
                    catch (Exception exception2)
                    {
                        this.lstContacts.Tag = null;
                        ClientLogger.WriteException("导入失败", exception2);
                        this.DoNextError("导入失败,请检查文件格式是否正确。");
                        return;
                    }
                }
                this.DoNextError("确认文件路径是否正确。");
            }
            return;
        Label_0240:
            this.FormatForm();
            if (this._step == 2)
            {
                this.btnNext.Enabled = this.CanImport();
            }
            else if ((this._step != 3) && (this._step == this._maxStep))
            {
                this.Import();
            }
        }

        private void DoNextError(string message)
        {
            if (!base.IsDisposed)
            {
                this.progressOutLook.Visible = false;
                this._step--;
                if (this.ImportObject.Type == ImportContactType.Outlook)
                {
                    this._step = 1;
                }
                this._frameworkWin.UnifiedMessageBox.ShowInfo(this, message);
            }
        }

        private void DoPrevious()
        {
            this._step--;
            if ((this.ImportObject.Type == ImportContactType.Outlook) && (this._step == 2))
            {
                this._step--;
            }
            this.FormatForm();
        }

        private void FormatForm()
        {
            this.btnPrevious.Visible = this._step != 1;
            if (this._step == this._maxStep)
            {
                this.btnNext.Enabled = false;
                this.btnPrevious.Enabled = false;
            }
            else if (this._step == (this._maxStep - 1))
            {
                this.btnNext.Text = "导入(&I)";
                this.btnNext.Enabled = true;
            }
            else if (this._step == 3)
            {
                this.btnNext.Enabled = this._totalChecked > 0;
            }
            else
            {
                if (this._step == 1)
                {
                    this.checkBoxSelAll.Checked = false;
                    this.txtFilePath.Text = string.Empty;
                }
                this.btnNext.Text = "下一步(&N)";
                this.btnNext.Enabled = true;
            }
            for (int i = 1; i <= this._maxStep; i++)
            {
                Panel panel = this.pnlContainer.Controls.Find("pnlStep" + i, false)[0] as Panel;
                panel.Visible = this._step == i;
                if (panel.Dock != DockStyle.Fill)
                {
                    panel.Dock = DockStyle.Fill;
                }
            }
        }

        private void FormatSelectInfo()
        {
            this.xLabelFind.Text = string.Format("找到 {0} 个可以导入的联系人。", this._totalUsers);
            this.lblSelectInfo.Text = string.Format("已选定人数 {0}/{1}", this._totalChecked, this._totalUsers);
        }

        private string GetNodeValue(XmlNode node, string name)
        {
            XmlNode node2 = node.SelectSingleNode(name);
            if (node2 != null)
            {
                return node2.InnerText;
            }
            return null;
        }

        private void Import()
        {
            try
            {
                if (this.lstContacts.Items.Count != 0)
                {
                    this.lst = new List<XmlNode>();
                    foreach (ListViewItem item in this.lstContacts.Items)
                    {
                        if (item.Checked)
                        {
                            this.lst.Add(item.Tag as XmlNode);
                        }
                    }
                    this.progressBarExport.Maximum = this.lst.Count;
                    this.progressBarExport.Minimum = 0;
                    if (this.comboBoxGroup.SelectedItem != null)
                    {
                        this.groupID = new int?(Convert.ToInt32((this.comboBoxGroup.SelectedItem as ComboBoxItem).Value.ToString()));
                    }
                    ThreadPool.QueueUserWorkItem(new WaitCallback(this.ImportContactsInThread));
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void ImportContact(XmlNode node)
        {
            string nodeValue = this.GetNodeValue(node, "FetionId");
            string str2 = this.GetNodeValue(node, "MobileNo");
            string str3 = this.GetNodeValue(node, "Name");
            string str4 = this.GetNodeValue(node, "Nickname");
            string localName = string.IsNullOrEmpty(str3) ? (str4 ?? string.Empty) : str3;
            Info contextForUi = new Info();
            AsyncBizOperation op = new AsyncBizOperation(contextForUi);
            op.IsImpsErrorHandled = true;
            op.ImpsError += new EventHandler<ImpsErrorEventArgs>(this.op_ImpsError);
            op.Successed += new EventHandler(this.op_Successed);
            if (!string.IsNullOrEmpty(str2))
            {
                contextForUi.IsMobileNo = true;
                contextForUi.DispalyName = localName;
                contextForUi.Id = str2;
                this._frameworkWin.ContactManager.AddBuddyByMobileNo(str2, string.Empty, this.groupID, localName, this.textBoxMyName.Text, false, true, new bool?(this.chkInviteStartService.Checked), op);
            }
            else
            {
                long num;
                if (!string.IsNullOrEmpty(nodeValue) && long.TryParse(nodeValue, out num))
                {
                    contextForUi.IsMobileNo = false;
                    contextForUi.DispalyName = localName;
                    contextForUi.Id = num.ToString();
                    this._frameworkWin.ContactManager.AddBuddyBySid(num, string.Empty, this.groupID, localName, this.textBoxMyName.Text, false, true, op);
                }
            }
        }

        private void ImportContactsInThread(object state)
        {
            if ((this.lst != null) && (this.lst.Count > 0))
            {
                try
                {
                    if (!base.IsDisposed)
                    {
                        XmlNode node = this.lst[this.i];
                        this.ImportContact(node);
                    }
                }
                catch (Exception)
                {
                }
            }
        }

        private void ImportForm_Load(object sender, EventArgs e)
        {
            this.pbImportExport.Image = ImpsResources.GetImage("Images.ImportExport.jpg");
        }

        private void ImportOutLook(object context)
        {
            try
            {
                this._importXMLContent = (context as IImportContacts).GetContactsXML(this, null);
                if (this._importXMLContent.Length != 0)
                {
                    if (!base.IsDisposed)
                    {
                        base.Invoke(new ImportOutlookSuccess(this.DoNext));
                    }
                }
                else if (!base.IsDisposed)
                {
                    base.Invoke(new ImportOutLookFailed(this.DoNextError), new object[] { "Microsoft Outlook 中没有联系人导入!" });
                }
            }
            catch (Exception exception)
            {
                if (!base.IsDisposed)
                {
                    base.Invoke(new ImportOutLookFailed(this.DoNextError), new object[] { "确认是否安装Microsoft Outlook!" });
                    base.Invoke(new SetButtonEnabled(this.setButton), new object[] { this.btnNext, true });
                }
                ClientLogger.WriteException("导入Outlook失败", exception);
            }
        }

        private void initGroup()
        {
            this.comboBoxGroup.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBoxGroup.Items.Clear();
            lock (this.CurrentUser.ContactList.Groups.SyncRoot)
            {
                foreach (ContactGroup group in this.CurrentUser.ContactList.Groups)
                {
                    if (group.Id != -1)
                    {
                        ComboBoxItem item = new ComboBoxItem(group.Name, group.Id);
                        this.comboBoxGroup.Items.Add(item);
                        if (this._initTargetGroupId.HasValue && (this._initTargetGroupId == group.Id))
                        {
                            this.comboBoxGroup.SelectedItem = item;
                        }
                    }
                }
            }
            if ((!this._initTargetGroupId.HasValue || (this._initTargetGroupId == -1)) && (this.comboBoxGroup.Items.Count > 0))
            {
                this.comboBoxGroup.SelectedIndex = 0;
            }
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ImportForm));
            this.lblDescription = new XLabel();
            this.lstPlugins = new ListBox();
            this.lblSelectPlugin = new XLabel();
            this.pnlStep1 = new Panel();
            this.linkLabelHelp = new LinkLabel();
            this.xLabel3 = new XLabel();
            this.xLabel2 = new XLabel();
            this.xLabel1 = new XLabel();
            this.btnCancel = new XButton();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -