Exemplo n.º 1
0
        /// <summary>
        /// 登录成功保存数据
        /// </summary>
        private void LoginSuccess()
        {
            if (m_loginUser != null)
            {
                if (cbUserName.Text != m_loginUser.UserName || m_nSelectedPlatformId != m_loginUser.PlatformId)
                {
                    //登录用户名不同或者平台不同,则原登录用户最近一次登录置为false并更新
                    m_loginUser.RecentLogin = false;
                    m_bllUser.Update(m_loginUser);
                }
            }

            User user  = m_bllUser.GetUserForName(cbUserName.Text, m_nSelectedPlatformId);
            bool IsNew = false;      //是否是新建用户

            if (user == null)
            {
                //没有该用户,则新建
                IsNew = true;
                user  = new User();
            }

            user.UserName    = cbUserName.Text;
            user.PlatformId  = m_nSelectedPlatformId;
            user.RememberPwd = cbkRememberPwd.Checked;
            if (cbkRememberPwd.Checked)
            {
                user.UserPwd = Encrypt.DES3Encrypt(tbUserPwd.Text, Encrypt.MD5Encrypt(cbUserName.Text));
            }
            else
            {
                user.UserPwd = string.Empty;
            }
            user.AutoLogin   = cbkAutoLogin.Checked;
            user.RecentLogin = true;

            if (IsNew)
            {
                m_bllUser.Add(user);
            }
            else
            {
                m_bllUser.Update(user);
            }
        }
Exemplo n.º 2
0
 private byte[] TripleDesEncrypt(byte[] originalData, byte[] key)
 {
     byte[] encryptData = new byte[0];
     encryptData = Encrypt.DES3Encrypt(originalData, key);
     return(encryptData);
 }
Exemplo n.º 3
0
        private TransResult PackBankBag()
        {
            var    ret = TransResult.E_PACKET_FAIL;
            string str = PackSendBag();

            if (str == null)
            {
                return(ret);
            }
            try
            {
                int    sendLen  = str.Length;
                byte[] SendData = Encoding.GetEncoding("GBK").GetBytes(str);
                int    len      = (SendData.Length % 8 == 0 ? SendData.Length : SendData.Length + 8 - SendData.Length % 8);
                byte[] cData    = new byte[len];
                for (int i = 0; i < len; i++)
                {
                    cData[i] = (byte)(len - SendData.Length);
                }
                Array.Copy(SendData, cData, SendData.Length);
                byte[] bkey     = Convert.FromBase64String(mainKey);
                byte[] Senddata = Encrypt.DES3Encrypt(cData, bkey);
                string sendstr  = Convert.ToBase64String(Senddata);

                sendLen = sendstr.Length;
                byte[] Baghead = PackBagHead(sendLen);
                byte[] BagData = new byte[Baghead.Length + sendLen];
                byte[] sendbag = Encoding.GetEncoding("GBK").GetBytes(sendstr);

                Array.Copy(Baghead, BagData, Baghead.Length);
                Array.Copy(sendbag, 0, BagData, Baghead.Length, sendLen);

                #region Json复合8583包打包(子类中重写PackSendObject())方法
                SendObject = PackSendObject();
                string strJson = "";
                BaseCommunicateSendJson send = SendObject as BaseCommunicateSendJson;
                if (send != null) //对象必须是继承基类型的才采用json发送
                {
                    send.rowCount = send.DS.Length;
                    strJson       = JsonConvert.SerializeObject(SendObject);
                }
                #endregion


                //if (!string.IsNullOrEmpty(strJson))
                //{
                byte[] json = Encoding.GetEncoding("GBK").GetBytes(strJson);
                //}
                byte[] head = PackHead(BagData.Length + json.Length);
                headLen     = head.Length;
                sendstr_all = new byte[headLen + BagData.Length + json.Length];
                Array.Copy(head, sendstr_all, head.Length);
                Array.Copy(BagData, 0, sendstr_all, head.Length, BagData.Length);
                Array.Copy(json, 0, sendstr_all, headLen + BagData.Length, json.Length);

                ret = TransResult.E_SUCC;
            }
            catch (Exception ex)
            {
                ret = TransResult.E_PACKET_FAIL;
                Log.Error(GetType().Name, ex);
            }
            return(ret);
        }