📄 importform.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Pc.UIContactList.AddBuddy;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Common;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
public class ImportForm : XIMDialog
{
private bool _checkByFunction;
private int _countFail;
private int _countOK;
private IFrameworkWindow _frameworkWin;
private IImportContacts _importObject;
private string _importXMLContent = "";
private int? _initTargetGroupId;
private Dictionary<long, object> _items = new Dictionary<long, object>();
private List<ImportExportManager.ImportExportPlugin> _list;
private ImportExportManager _manager;
private int _maxStep = 5;
private int _step = 1;
private int _totalChecked;
private int _totalUsers;
private XButton btnBrowse;
private XButton btnCancel;
private XButton btnNext;
private XButton btnPrevious;
private UButton buttonNewGrp;
private ColumnHeader chCheckBox;
private CheckBox checkBoxSelAll;
private ColumnHeader chFetionNo;
private CheckBox chkInviteStartService;
private ColumnHeader chMobileNo;
private ColumnHeader chName;
private ColumnHeader chNickname;
private ColumnHeader columnHeader1;
private ComboBox comboBoxGroup;
private IContainer components;
private GroupBox groupBox1;
private int? groupID = null;
private int i;
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private XLabel labelName;
private HtmlLabel labelRealName;
private XLabel lblDescription;
private XLabel lblImportContactName;
private XLabel lblSelectInfo;
private XLabel lblSelectPlugin;
private LinkLabel linkLabelHelp;
private ListBox listBox1;
private List<XmlNode> lst;
private ListView lstContacts;
private OpenFileDialog openFileDialog;
private Panel panelFileSel;
private Panel panelOutlookDes;
private Panel panelOutlookRead;
private PictureBox pbImportExport;
private Panel pnlContainer;
private Panel pnlMainContainer;
private Panel pnlStep_MyInfo;
private Panel pnlStep_Result;
private Panel pnlStep_SelContact;
private Panel pnlStep_SelSource;
private ProgressBar progressBarExport;
private ProgressBar progressOutLook;
private RadioButton rbFile;
private RadioButton rbOutlook;
private XTextBox textBoxMyName;
private TextBox txtFilePath;
private XLabel xLabel2;
private XLabel xLabelFind;
public ImportForm(IFrameworkWindow frameworkWin, ImportExportManager manager)
{
this.InitializeComponent();
this._frameworkWin = frameworkWin;
this._manager = manager;
this.initComponentRegion();
this.CurrentUser.ContactList.ContactGroupChanged += new EventHandler<ContactGroupChangedEventArgs>(this, (IntPtr) this.ContactList_ContactGroupChanged);
this.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this, (IntPtr) this.CurrentUser_StatusChanged);
}
private void BindDatas(XmlDocument doc)
{
if ((doc != null) && ((this.lstContacts.Tag == null) || (this.lstContacts.Tag.ToString() != doc.InnerXml)))
{
this.lstContacts.Tag = doc.InnerXml;
this.lstContacts.Items.Clear();
this._items.Clear();
this._totalUsers = 0;
this._totalChecked = 0;
List<ListViewItem> list = new List<ListViewItem>();
this._checkByFunction = true;
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
{
try
{
string nodeValue = this.GetNodeValue(node, "FetionId");
string s = this.GetNodeValue(node, "MobileNo");
string text3 = StringHelper.EncodString(this.GetNodeValue(node, "Name"));
string text4 = StringHelper.EncodString(this.GetNodeValue(node, "Nickname"));
if (((!string.IsNullOrEmpty(nodeValue) || !string.IsNullOrEmpty(s)) && (this.CurrentUser.Sid.ToString() != nodeValue)) && (this.CurrentUser.MobileNo != s))
{
if (s == "0")
{
s = string.Empty;
}
long mobileNo = 0;
long id = 0;
if (string.IsNullOrEmpty(s) || ((ImpsHelper.TryParseMobileNoExtend(s, out mobileNo) && (this.CurrentUser.ContactList.FindContactByMsisdnEx(mobileNo.ToString()) == null)) && (!this._items.ContainsKey(mobileNo) && ImpsHelper.IsCmccMobileNo(s))))
{
if (!string.IsNullOrEmpty(nodeValue))
{
if (!long.TryParse(nodeValue, ref id) || !ImpsHelper.IsSid(id))
{
continue;
}
IicUri uri = IicUri.CreateSidUri(id);
if ((this.CurrentUser.ContactList.Contacts.FindContact(uri) != null) || this._items.ContainsKey(id))
{
continue;
}
}
if (mobileNo != 0)
{
this._items.Add(mobileNo, null);
}
else
{
if (id == 0)
{
continue;
}
this._items.Add(id, null);
}
string[] items = new string[] { string.Empty, text3 ?? string.Empty, text4 ?? string.Empty, s, nodeValue };
ListViewItem item = new ListViewItem(items);
item.Tag = node;
list.Add(item);
}
}
continue;
}
catch (Exception exception)
{
ClientLogger.WriteGeneral("导入绑定单行数据时错误", exception.ToString(), 20);
continue;
}
}
list.Sort(new ImportDatasCompare());
List<ListViewItem>.Enumerator enumerator = list.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
ListViewItem item2 = enumerator.get_Current();
this.lstContacts.Items.Add(item2);
this._totalUsers++;
}
}
finally
{
enumerator.Dispose();
}
this.FormatSelectInfo();
this._checkByFunction = false;
}
}
private void btnBrowse_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWin, delegate {
this.openFileDialog.Filter = "联系人数据文件 (csv,vcf,fcl)|*.csv;*.vcf;*.fcl|csv files (*.csv)|*.csv|vcf files (*.vcf)|*.vcf|" + string.Format("{0} files (*.fcl)|*.fcl", AppDictionary.ShortEnglishName);
if ((this.txtFilePath.Text.Length != 0) && File.Exists(this.txtFilePath.Text))
{
this.openFileDialog.FileName = this.txtFilePath.Text;
}
if (this.openFileDialog.ShowDialog(this) == DialogResult.OK)
{
this.txtFilePath.Text = this.openFileDialog.FileName;
this.btnNext.Enabled = this.CanImport();
}
});
}
private void btnCancel_Click(object sender, EventArgs e)
{
base.Close();
}
private void btnNext_Click(object sender, EventArgs e)
{
try
{
this.DoNext();
}
catch (Exception exception)
{
UiErrorHelper.HandExceptionSafely(this._frameworkWin, exception);
}
}
private void btnPrevious_Click(object sender, EventArgs e)
{
try
{
this.DoPrevious();
}
catch (Exception exception)
{
UiErrorHelper.HandExceptionSafely(this._frameworkWin, exception);
}
}
private void buttonNewGrp_Click(object sender, EventArgs e)
{
try
{
this._frameworkWin.ContactManager.ShowGroupCreateWindow(this);
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private bool CanImport()
{
if (this.ImportObject.Type == ImportContactType.Outlook)
{
return true;
}
string path = this.txtFilePath.Text;
if (path == "")
{
return false;
}
if (path.IndexOf(@"\") == -1)
{
return false;
}
return File.Exists(path);
}
private void changeType()
{
if (this.rbOutlook.Checked)
{
this.panelOutlookDes.Dock = DockStyle.Fill;
this.panelOutlookDes.BringToFront();
this._importObject = this._list.get_Item(3).ImportExportObject as ImportContactsFromOutlook;
}
else
{
this.panelFileSel.Dock = DockStyle.Fill;
this.panelFileSel.BringToFront();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -