Ejemplo n.º 1
0
        /// <summary>
        /// 批量导入账号(txt文件)
        /// 内容格式为(用制表符或空格隔开即可):账号 密码
        /// </summary>
        /// <param name="txtFile">文件保存地址</param>
        /// <param name="appClientID"></param>
        /// <param name="appClientSecret"></param>
        /// <param name="appName"></param>
        /// <param name="orgName"></param>
        public void ImportUserToHX(string txtFile, string appClientID, string appClientSecret, string appName, string orgName)
        {
            using (StreamReader sr = new StreamReader(txtFile))
            {
                string      line    = sr.ReadLine();
                EaseMobDemo easeMob = new EaseMobDemo(appClientID, appClientSecret, appName, orgName);
                System.Text.StringBuilder _build = new StringBuilder();
                while (line != null)
                {
                    string[] arr = line.Split(new string[] { "\t", " " }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr != null && arr.Length == 2)
                    {
                        string u = arr[0], p = arr[1];
                        string returnMsg = easeMob.AccountCreate(u, p);
                        _build.AppendFormat("{0}\r\n\r\n", returnMsg);
                        Console.WriteLine(returnMsg);
                    }
                    line = sr.ReadLine();
                }

                string logPath = AppDomain.CurrentDomain.BaseDirectory + "Log" + DateTime.Now.Ticks.ToString() + ".txt";
                using (StreamWriter sw = new StreamWriter(logPath, false, Encoding.UTF8))
                {
                    sw.Write(_build.ToString());
                    sw.Flush();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 使用范例
        /// HXComm.SampleUse mySample = new HXComm.SampleUse();
        /// mySample.Test(appClientID, appClientSecret, appName, orgName);
        /// </summary>
        /// <param name="appClientID"></param>
        /// <param name="appClientSecret"></param>
        /// <param name="appName"></param>
        /// <param name="orgName"></param>
        public void Test(string appClientID, string appClientSecret, string appName, string orgName)
        {
            EaseMobDemo myEaseMobDemo = new EaseMobDemo(appClientID, appClientSecret, appName, orgName);
            string      userName = "******", password = "******", newPassword = "******";//此处我们要进行加密处理,如果在实际项目中,建议加密

            Console.WriteLine("{0}", myEaseMobDemo.AccountCreate(userName, password));
            Console.WriteLine("{0}", myEaseMobDemo.AccountGet(password));
            Console.WriteLine("{0}", myEaseMobDemo.AccountResetPwd(userName, newPassword));
            Console.WriteLine("{0}", myEaseMobDemo.AccountDel(password));
        }
        /// <summary>
        /// 批量导入账号(txt文件)
        /// 内容格式为(用制表符或空格隔开即可):账号 密码
        /// </summary>
        /// <param name="txtFile">文件保存地址</param>
        /// <param name="appClientID"></param>
        /// <param name="appClientSecret"></param>
        /// <param name="appName"></param>
        /// <param name="orgName"></param>
        public void ImportUserToHX(string txtFile, string appClientID, string appClientSecret, string appName, string orgName)
        {
            using (StreamReader sr = new StreamReader(txtFile))
            {
                string line = sr.ReadLine();
                EaseMobDemo easeMob = new EaseMobDemo(appClientID, appClientSecret, appName, orgName);
                System.Text.StringBuilder _build = new StringBuilder();
                while (line != null)
                {
                    string[] arr = line.Split(new string[] { "\t", " " }, StringSplitOptions.RemoveEmptyEntries);
                    if (arr != null && arr.Length == 2)
                    {
                        string u = arr[0], p = arr[1];
                        string returnMsg = easeMob.AccountCreate(u, p);
                        _build.AppendFormat("{0}\r\n\r\n", returnMsg);
                        Console.WriteLine(returnMsg);
                    }
                    line = sr.ReadLine();
                }

                string logPath = AppDomain.CurrentDomain.BaseDirectory + "Log" + DateTime.Now.Ticks.ToString() + ".txt";
                using (StreamWriter sw = new StreamWriter(logPath, false, Encoding.UTF8))
                {
                    sw.Write(_build.ToString());
                    sw.Flush();
                }
            }
        }
        /// <summary>
        /// 使用范例
        /// HXComm.SampleUse mySample = new HXComm.SampleUse();
        /// mySample.Test(appClientID, appClientSecret, appName, orgName);
        /// </summary>
        /// <param name="appClientID"></param>
        /// <param name="appClientSecret"></param>
        /// <param name="appName"></param>
        /// <param name="orgName"></param>
        public void Test(string appClientID, string appClientSecret, string appName, string orgName)
        {
            EaseMobDemo myEaseMobDemo = new EaseMobDemo(appClientID, appClientSecret, appName, orgName);
            string userName = "******", password = "******", newPassword = "******";//此处我们要进行加密处理,如果在实际项目中,建议加密

            Console.WriteLine("{0}", myEaseMobDemo.AccountCreate(userName, password));
            Console.WriteLine("{0}", myEaseMobDemo.AccountGet(password));
            Console.WriteLine("{0}", myEaseMobDemo.AccountResetPwd(userName, newPassword));
            Console.WriteLine("{0}", myEaseMobDemo.AccountDel(password));
        }