C#对RTX二次开发

C#语言 同时被 2 个专栏收录
30 篇文章 0 订阅
1 篇文章 0 订阅

自己写了一点,然后项目死了,留着代码做纪念吧,以后如果做消息发送可能用得到

代码:

    public class RtxHelper
    {
        private RTXObjectClass _rootObj;

        public RtxHelper()
        {
            _rootObj = new RTXObjectClass();
        }

        public RtxHelper(string ip, short port)
        {
            _rootObj = new RTXObjectClass();
            _rootObj.ServerIP = ip;
            _rootObj.ServerPort = port;
        }

        #region 用户

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="Dpmid">用户所属部门的ID号</param>
        /// <param name="Nick">用户的登陆名</param>
        /// <param name="pwd">用户的登陆密码</param>
        /// <param name="name">用户名</param>
        /// <param name="sex">性别:1为女,0为男</param>
        /// <param name="rtxnumber">用户的RTX号码</param>
        /// <param name="mobile">用户的手机号码</param>
        /// <returns></returns>
        public string AddUser(string Dpmid, string Nick, string pwd, string name,int sex, string rtxnumber = null, string mobile = null)
        {
            try
            {
                RTXCollectionClass RTXParams = new RTXCollectionClass();
                _rootObj.Name = "USERMANAGER";
                RTXParams.Add("DEPTID", Dpmid);
                RTXParams.Add("NICK", Nick);
                RTXParams.Add("PWD", pwd);
                RTXParams.Add("NAME", name);
                RTXParams.Add("UIN", rtxnumber);
                RTXParams.Add("MOBILE", mobile);
                RTXParams.Add("GENDER", sex);
                Object iStatus = new Object();
                iStatus = _rootObj.Call2(RTXServerApi.enumCommand_.PRO_ADDUSER, RTXParams);

                return "OK";
            }
            catch (Exception E)
            {
                return E.Message;
            }
        }

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="unick">用户的登陆名或用户的RTX号码都可 </param>
        /// <returns></returns>
        public string DelUser(string unick)
        {
            try
            {
                RTXCollectionClass RTXParams = new RTXCollectionClass();
                _rootObj.Name = "USERMANAGER";
                RTXParams.Add("USERNAME", unick);
                Object iStatus = new Object();
                iStatus = _rootObj.Call2(RTXServerApi.enumCommand_.PRO_DELUSER, RTXParams);
                return "OK";
            }
            catch (Exception E)
            {
                return E.Message;
            }
        }

        /// <summary>
        /// 更改用户简单信息
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="ChsName"></param>
        /// <param name="Sex"></param>
        /// <param name="Cell"></param>
        /// <param name="Email"></param>
        /// <param name="Phone"></param>
        /// <param name="AuthTYpe"></param>
        /// <returns></returns>
        public string UpdateUserDatil(string nick,string name,string pwd,int Sex,string deptid,string mobile)
        {
            try
            {
                RTXCollectionClass Params = new RTXCollectionClass();
                _rootObj.Name = "USERMANAGER";
                Params.Add("DEPTID", deptid);
                Params.Add("NICK", nick);
                Params.Add("PWD", pwd);
                Params.Add("NAME", name);
                Params.Add("MOBILE", mobile);
                Params.Add("SEX", Sex);
                Object iStatus = new Object();
                iStatus = _rootObj.Call2(RTXServerApi.enumCommand_.PRO_SETUSERSMPLINFO, Params);
                return "OK";
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }

        #endregion

        #region 部门

        /// <summary>
        /// 添加部门
        /// </summary>
        /// <param name="Pdeptid">Pdeptid:所属部门()上级部门的ID </param>
        /// <param name="Deptid">增加的该部门的ID</param>
        /// <param name="name">该增加部门的名称</param>
        /// <param name="info">该增加部门的相关信息</param>
        /// <returns></returns>
        public string AddDept(int Pdeptid, string Deptid, string name, string info)
        {
            try
            {
                RTXCollectionClass RTXParams = new RTXCollectionClass();
                _rootObj.Name = "USERMANAGER";
                RTXParams.Add("PDEPTID", Pdeptid);
                RTXParams.Add("DEPTID", Deptid);
                RTXParams.Add("NAME", name);
                RTXParams.Add("INFO", info);
                Object iStatus = new Object();
                iStatus = _rootObj.Call2(RTXServerApi.enumCommand_.PRO_ADDDEPT, RTXParams);

                return "OK";
            }
            catch (Exception E)
            {
                return E.Message;
            }
        }

        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="dpmtid">要删除部门的ID号</param>
        /// <param name="delall">删除部门的下属部门的选择(0为不删除,为删除)</param>
        /// <returns></returns>
        public string DelDept(string dpmtid, string delall)
        {
            try
            {
                RTXCollectionClass RTXParams = new RTXCollectionClass();
                _rootObj.Name = "USERMANAGER";
                RTXParams.Add("DEPTID", dpmtid);
                RTXParams.Add("COMPLETEDELBS", delall);
                Object iStatus = new Object();
                iStatus = _rootObj.Call2(RTXServerApi.enumCommand_.PRO_DELDEPT, RTXParams);
                return "OK";
            }
            catch (Exception E)
            {
                return E.Message;
            }
        }

        #endregion

        #region 消息

        /// <summary>
        /// 发送即时消息
        /// 竟然超简单,不要用那种复杂的,那个不可以用,设置好ip和端口后只要两行
        /// </summary>
        /// <param name="Sender">发送者</param>
        /// <param name="pwd">发送者密码</param>
        /// <param name="RECVUsers">接收者,多个中间用,间隔</param>
        /// <param name="IMMsg">发送的消息内容</param>
        /// <returns></returns>
        public voidSendIM(string Sender, string pwd, string RecvUsers, string IMMsg)
        {
            try
            {
                 string sessionKey = "{45E974F3-B242-486b-8487-56C23D37FF51}";
                _rootObj.SendIM(Sender, pwd, Receivers, IMMsg, sessionKey);
            }
            catch (Exception E)
            {
                return;
            }
        }

        /// <summary>
        /// 发送广播信息
        /// </summary>
        /// <returns></returns>
        public string SendMsg( string msg)
        {
            try
            {
                var RootObj = new RTXSAPIRootObj();
                RootObj.ServerIP = serverIP;
                RootObj.ServerPort = serverPort;
                string sessionId = "{45E974F3-B242-486b-8487-56C23D37FF51}";
                RootObj.SendNotify("Dong", "", 0,msg);
                return "OK";
            }
            catch (Exception E)
            {
                return E.Message;
            }
        }

        #endregion

        #region Session

//        /// <summary>
//        /// Session
//        /// </summary>
//        /// <param name="Account"></param>
//        /// <param name="ip"></param>
//        /// <param name="port"></param>
//        /// <returns></returns>
//        public string GetSessionKey(string Account,string ip,short port)  //服务器端代码
//        {
//            RTXSAPILib.IRTXSAPIRootObj RootObj = new RTXSAPIRootObj();
//            //创建根对象
//            RootObj.ServerIP = ip;
//            RootObj.ServerPort = port; //设置服务器端口
//            string SessionKey = "";
//            RTXSAPILib.RTXSAPIUserAuthObj UserAuthObj = RootObj.UserAuthObj; //创建一个用户认证对象
//            try
//            {
//                SessionKey = "{" + UserAuthObj.GetSessionKey(Account) + "}";  //通过用户认证对象获取SessionKey
//            }
//            catch (Exception ex)
//            {
//                return ex.Message;
//            }
//            return SessionKey; //返回SessionKey
//1       }

        #endregion





        / <summary>
        / 修改用户密码
        / </summary>
        / <param name="staffName"></param>
        / <param name="staffPwd"></param>
        / <returns></returns>
        //public string UpdatePassword(string staffName, string staffPwd)
        //{
        //    IRTXSAPIRootObj RootObj = new 
        //    RTXSAPILib.RTXSAPIUserManager UserManagerObj = RootObj.UserManager;
        //    string result = "OK";
        //    //try
        //    //{
        //    //    UserManagerObj.SetUserPwd(staffName, staffPwd);//修改用户密码;
        //    //    result = "OK";
        //    //}
        //    //catch (Exception e)
        //    //{
        //    //    return result = e.Message;
        //    //}
        //    return result;
        //}

    }
  • 0
    点赞
  • 0
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 精致技术 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值