private void OnShowChangeName(ChangeNameType NameType)
 {
     if (m_ChangeNameTitleLable != null)
     {
         m_ChangeNameTitleLable.text = "";
     }
     if (NameType < ChangeNameType.ChangeNameType_PlayerName || NameType > ChangeNameType.ChangeNameType_PlayerName_CombineServer)
     {
         LogModule.ErrorLog("OnShowChangeName::NameType is invalid");
         return;
     }
     m_NameType = NameType;
     if (ChangeNameType.ChangeNameType_PlayerName == m_NameType || ChangeNameType.ChangeNameType_PlayerName_CombineServer == m_NameType)
     {
         m_ChangeNameTitleLable.text = StrDictionary.GetClientDictionaryString("#{3054}");
     }
     else if (ChangeNameType.ChangeNameType_GuildName == m_NameType)
     {
         m_ChangeNameTitleLable.text = StrDictionary.GetClientDictionaryString("#{3055}");
     }
     else if (ChangeNameType.ChangeNameType_MasterName == m_NameType)
     {
         m_ChangeNameTitleLable.text = StrDictionary.GetClientDictionaryString("#{3056}");
     }
 }
        /**
         * Create Program Details Broadcast.
         * XML Message sent to the Hub broadcasting the details of the new cannabis licence issued.
         * The purpose is to broadcast licence details to partners subscribed to the Hub
         */
        public string CreateXML(MicrosoftDynamicsCRMadoxioLicences licence, ChangeNameType changeNameType, string targetBusinessNumber)
        {
            if (licence == null)
            {
                throw new Exception("The licence can not be null");
            }

            if (licence.AdoxioLicencee == null)
            {
                throw new Exception("The licence must have an AdoxioLicencee");
            }

            if (licence.AdoxioBusinessprogramaccountreferencenumber == null)
            {
                // set to 1 and handle errors as encountered.
                licence.AdoxioBusinessprogramaccountreferencenumber = "1";
            }
            var sbnChangeStatus = new SBNChangeName();

            sbnChangeStatus.header = GetHeader(licence, changeNameType);


            sbnChangeStatus.body = GetBody(licence, changeNameType, targetBusinessNumber);

            var serializer = new XmlSerializer(typeof(SBNChangeName));

            using (StringWriter textWriter = new StringWriter())
            {
                serializer.Serialize(textWriter, sbnChangeStatus);
                return(textWriter.ToString());
            }
        }
 public static void ShowChangeName(ChangeNameType NameType)
 {
     if (NameType < ChangeNameType.ChangeNameType_PlayerName || NameType > ChangeNameType.ChangeNameType_PlayerName_CombineServer)
     {
         LogModule.ErrorLog("ShowChangeName:NnameType is invalid");
         return;
     }
     UIManager.ShowUI(UIInfo.ChangeName, ChangeNameLogic.OnShowChangeName, NameType);
 }
    private static void OnShowChangeName(bool bSuccess, object param)
    {
        if (!bSuccess)
        {
            LogModule.ErrorLog("load ChangeName error");
            return;
        }
        ChangeNameType NameType = (ChangeNameType)param;

        if (null != ChangeNameLogic.Instance())
        {
            ChangeNameLogic.Instance().OnShowChangeName(NameType);
        }
    }
        private SBNChangeNameHeader GetHeader(MicrosoftDynamicsCRMadoxioLicences licence, ChangeNameType changeNameType)
        {
            var header = new SBNChangeNameHeader();

            header.requestMode = OneStopUtils.ASYNCHRONOUS;
            switch (changeNameType)
            {
            case ChangeNameType.ChangeName:
                header.documentSubType = OneStopUtils.DOCUMENT_SUBTYPE_CHANGENAME;
                break;

            case ChangeNameType.ThirdPartyOperator:
                header.documentSubType = OneStopUtils.DOCUMENT_SUBTYPE_CHANGENAME_THIRDPARTY;
                break;

            case ChangeNameType.Transfer:
                header.documentSubType = OneStopUtils.DOCUMENT_SUBTYPE_CHANGENAME_TRANSFER;
                break;
            }

            header.senderID   = OneStopUtils.SENDER_ID;
            header.receiverID = OneStopUtils.RECEIVER_ID;
            //any note wanted by LCRB. Currently in liquor is: licence Id, licence number - sequence number
            header.partnerNote = licence.AdoxioLicencenumber + "-" + DateTime.Now.Ticks;

            header.CCRAHeader = GetCCRAHeader(licence);

            return(header);
        }
        private SBNChangeNameBody GetBody(MicrosoftDynamicsCRMadoxioLicences licence, ChangeNameType changeNameType, string targetBusinessNumber)
        {
            var body = new SBNChangeNameBody();

            body.name = new SBNChangeNameBodyName();
            body.name.clientNameTypeCode = OneStopUtils.CLIENT_NAME_TYPE_CODE;
            if (licence.AdoxioEstablishment != null)
            {
                body.name.name = licence.AdoxioEstablishment.AdoxioName;
            }

            body.name.operatingNamesequenceNumber = 1;
            body.name.updateReasonCode            = OneStopUtils.UPDATE_REASON_CODE;

            body.businessRegistrationNumber = licence.AdoxioLicencee.Accountnumber;
            body.businessProgramIdentifier  = OneStopUtils.BUSINESS_PROGRAM_IDENTIFIER;

            body.businessProgramAccountReferenceNumber = licence.AdoxioBusinessprogramaccountreferencenumber;

            // partnerInfo1
            body.partnerInfo1 = licence.AdoxioLicencenumber;

            if (changeNameType == ChangeNameType.Transfer)
            {
                body.partnerInfo2 = targetBusinessNumber;
            }

            //
            body.timeStamp = Utils.GetTimeStamp();

            return(body);
        }
 void CloseWindow()
 {
     m_NameType = ChangeNameType.ChangeNameType_Invalid;
     UIManager.CloseUI(UIInfo.ChangeName);
 }
Exemple #8
0
        /// <summary>
        /// Hangfire job to send Change Status message to One stop.
        /// </summary>
        public async Task SendChangeNameRest(PerformContext hangfireContext, string licenceGuidRaw, string queueItemId, bool isTransfer)
        {
            IDynamicsClient dynamicsClient = DynamicsSetupUtil.SetupDynamics(_configuration);

            if (hangfireContext != null)
            {
                hangfireContext.WriteLine("Starting OneStop REST ChangeName Job.");
            }

            string licenceGuid = Utils.ParseGuid(licenceGuidRaw);

            //prepare soap content
            var req     = new ChangeName();
            var licence = dynamicsClient.GetLicenceByIdWithChildren(licenceGuid);

            if (hangfireContext != null && licence != null)
            {
                hangfireContext.WriteLine($"Got Licence {licenceGuid}.");
            }

            if (licence == null || licence.AdoxioEstablishment == null)
            {
                if (hangfireContext != null)
                {
                    hangfireContext.WriteLine($"Unable to get licence {licenceGuid}.");
                }

                if (Log.Logger != null)
                {
                    Log.Logger.Error($"Unable to get licence {licenceGuid}.");
                }
            }
            else
            {
                string targetBusinessNumber = null;

                ChangeNameType changeNameType = ChangeNameType.ChangeName;
                if (isTransfer && !string.IsNullOrEmpty(licence._adoxioProposedownerValue))
                {
                    changeNameType = ChangeNameType.Transfer;
                    var targetOwner = dynamicsClient.GetAccountById(licence._adoxioProposedownerValue);
                    if (targetOwner != null)
                    {
                        targetBusinessNumber = targetOwner.Accountnumber;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(licence._adoxioThirdpartyoperatoridValue))
                    {
                        changeNameType = ChangeNameType.ThirdPartyOperator;
                    }
                }

                var innerXml = req.CreateXML(licence, changeNameType, targetBusinessNumber);

                innerXml = _onestopRestClient.CleanXML(innerXml);

                if (Log.Logger != null)
                {
                    Log.Logger.Information(innerXml);
                }

                if (hangfireContext != null)
                {
                    hangfireContext.WriteLine(innerXml);
                }

                //send message to Onestop hub
                var outputXML = await _onestopRestClient.ReceiveFromPartner(innerXml);

                UpdateQueueItemForSend(dynamicsClient, hangfireContext, queueItemId, innerXml, outputXML);

                if (hangfireContext != null)
                {
                    hangfireContext.WriteLine(outputXML);
                    hangfireContext.WriteLine("End of OneStop REST ChangeName  Job.");
                }
            }
        }
Exemple #9
0
        private bool AddChangeNameDBRecord(DBManager dbMgr, int roleid, string oldName, string newName, ChangeNameType cnt, int costDiamond)
        {
            bool bRet = false;

            using (MyDbConnection3 conn = new MyDbConnection3(false))
            {
                string sql = string.Format("INSERT INTO t_change_name(roleid,oldname,newname,type,cost_diamond,time) VALUES({0},'{1}','{2}',{3},{4},'{5}')", new object[]
                {
                    roleid,
                    oldName,
                    newName,
                    (int)cnt,
                    costDiamond,
                    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                });
                bRet = conn.ExecuteNonQueryBool(sql, 0);
            }
            return(bRet);
        }
Exemple #10
0
        public TCPProcessCmdResults ProcChangeName(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 8)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                string          uid                     = fields[0];
                int             zoneId                  = Convert.ToInt32(fields[1]);
                int             roleId                  = Convert.ToInt32(fields[2]);
                string          newName                 = fields[3];
                int             costZuanShiBase         = Convert.ToInt32(fields[4]);
                int             costZuanShiMax          = Convert.ToInt32(fields[5]);
                int             canFreeMod              = Convert.ToInt32(fields[6]);
                int             canZuanShiMod           = Convert.ToInt32(fields[7]);
                string          oldName                 = "";
                string          failedMsg               = "";
                int             needZuanShi             = 0;
                DBUserInfo      userInfo                = null;
                DBRoleInfo      roleInfo                = null;
                ChangeNameType  cnt                     = ChangeNameType.CNT_Unknown;
                ChangeNameError cne                     = ChangeNameError.Success;
                bool            bNewNameTakePlaceHolder = false;
                userInfo = dbMgr.GetDBUserInfo(uid);
                if (userInfo == null)
                {
                    failedMsg = "账号找不到 : " + uid;
                    cne       = ChangeNameError.DBFailed;
                }
                else
                {
                    lock (userInfo)
                    {
                        int i;
                        for (i = 0; i < userInfo.ListRoleIDs.Count; i++)
                        {
                            if (userInfo.ListRoleZoneIDs[i] == zoneId && userInfo.ListRoleIDs[i] == roleId)
                            {
                                break;
                            }
                        }
                        if (i == userInfo.ListRoleIDs.Count)
                        {
                            failedMsg = string.Concat(new object[]
                            {
                                "账号: ",
                                uid,
                                " 在 ",
                                zoneId.ToString(),
                                " 区,不包含角色 ",
                                roleId
                            });
                            cne = ChangeNameError.NotContainRole;
                            goto IL_641;
                        }
                    }
                    roleInfo = dbMgr.GetDBRoleInfo(ref roleId);
                    if (null == roleInfo)
                    {
                        failedMsg = "查找不到dbroleinfo,roleid=" + roleId.ToString();
                        cne       = ChangeNameError.DBFailed;
                    }
                    else if (GameDBManager.PreDelRoleMgr.IfInPreDeleteState(roleId))
                    {
                        failedMsg = "处在预删除状态dbroleinfo,roleid=" + roleId.ToString();
                        cne       = ChangeNameError.DBFailed;
                    }
                    else
                    {
                        oldName = roleInfo.RoleName;
                        int leftFreeTimes = Global.GetRoleParamsInt32(roleInfo, "LeftFreeChangeNameTimes");
                        if (leftFreeTimes > 0 && 1 == canFreeMod)
                        {
                            cnt = ChangeNameType.CNT_Free;
                        }
                        else
                        {
                            cnt = ChangeNameType.CNT_ZuanShi;
                        }
                        if ((cnt == ChangeNameType.CNT_Free && 1 != canFreeMod) || (cnt == ChangeNameType.CNT_ZuanShi && 1 != canZuanShiMod))
                        {
                            failedMsg = "服务器没有开放改名功能, " + cnt.ToString();
                            cne       = ChangeNameError.ServerDenied;
                        }
                        else
                        {
                            SingletonTemplate <NameUsedMgr> .Instance().AddCannotUse_Ex(oldName);

                            if (!SingletonTemplate <NameUsedMgr> .Instance().AddCannotUse_Ex(newName) || dbMgr.IsRolenameExist(newName) || !SingletonTemplate <NameManager> .Instance().IsNameCanUseInDb(dbMgr, newName))
                            {
                                failedMsg = "新名字: " + newName + " 已被占用";
                                cne       = ChangeNameError.NameAlreayUsed;
                            }
                            else
                            {
                                bNewNameTakePlaceHolder = true;
                                if (PreNamesManager.SetUsedPreName(newName))
                                {
                                    DBWriter.UpdatePreNameUsedState(dbMgr, newName, 1);
                                }
                                string updateKey = "";
                                string updateVal = "";
                                if (cnt == ChangeNameType.CNT_Free)
                                {
                                    LogManager.WriteLog(LogTypes.Error, string.Format("角色请求免费改名,roleid={0}, old name={1}, new name={2}", roleId, oldName, newName), null, true);
                                    leftFreeTimes = Math.Max(0, leftFreeTimes - 1);
                                    updateKey     = "LeftFreeChangeNameTimes";
                                    updateVal     = leftFreeTimes.ToString();
                                }
                                else if (cnt == ChangeNameType.CNT_ZuanShi)
                                {
                                    int alreadyZuanShiTimes = Global.GetRoleParamsInt32(roleInfo, "AlreadyZuanShiChangeNameTimes");
                                    needZuanShi = Math.Min(costZuanShiMax, costZuanShiBase * (alreadyZuanShiTimes + 1));
                                    LogManager.WriteLog(LogTypes.Error, string.Format("角色请求钻石改名,roleid={0}, old name={1}, new name={2}, costzuanshi={3}", new object[]
                                    {
                                        roleId,
                                        oldName,
                                        newName,
                                        needZuanShi
                                    }), null, true);
                                    lock (userInfo)
                                    {
                                        if (userInfo.Money < needZuanShi)
                                        {
                                            failedMsg = "钻石不足";
                                            cne       = ChangeNameError.ZuanShiNotEnough;
                                            goto IL_641;
                                        }
                                        int tmpMoney = userInfo.Money;
                                        userInfo.Money -= needZuanShi;
                                        if (!DBWriter.UpdateUserInfo(dbMgr, userInfo))
                                        {
                                            userInfo.Money = tmpMoney;
                                            failedMsg      = string.Format("改名时更新用户的元宝失败,UserID={0}", userInfo.UserID);
                                            cne            = ChangeNameError.DBFailed;
                                            goto IL_641;
                                        }
                                        alreadyZuanShiTimes++;
                                        updateKey = "AlreadyZuanShiChangeNameTimes";
                                        updateVal = alreadyZuanShiTimes.ToString();
                                    }
                                }
                                Global.UpdateRoleParamByName(dbMgr, roleInfo, updateKey, updateVal, null);
                                string cmdText = string.Format("UPDATE t_roles SET rname='{0}' WHERE rid={1} AND userid='{2}' AND zoneid={3}", new object[]
                                {
                                    newName,
                                    roleId,
                                    uid,
                                    zoneId
                                });
                                if (!this._Util_ExecNonQuery(dbMgr, cmdText))
                                {
                                    failedMsg = "更新t_roles的名字失败";
                                    cne       = ChangeNameError.DBFailed;
                                }
                                else
                                {
                                    lock (userInfo)
                                    {
                                        for (int i = 0; i < userInfo.ListRoleIDs.Count; i++)
                                        {
                                            if (userInfo.ListRoleZoneIDs[i] == zoneId && userInfo.ListRoleIDs[i] == roleId)
                                            {
                                                userInfo.ListRoleNames[i] = newName;
                                                break;
                                            }
                                        }
                                    }
                                    lock (roleInfo)
                                    {
                                        oldName           = roleInfo.RoleName;
                                        roleInfo.RoleName = newName;
                                    }
                                    cne = ChangeNameError.Success;
                                }
                            }
                        }
                    }
                }
IL_641:
                if (cne == ChangeNameError.Success)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("角色改名成功,roleid={0}, old name={1},new name={2}", roleId, oldName, newName), null, true);
                    this.AddChangeNameDBRecord(dbMgr, roleId, oldName, newName, cnt, needZuanShi);
                    this._OnChangeNameSuccess(dbMgr, roleId, zoneId, oldName, newName);
                }
                else
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("角色改名失败,roleid={0}, name={1}, reason={2}", roleId, oldName, failedMsg), null, true);
                    if (bNewNameTakePlaceHolder)
                    {
                        SingletonTemplate <NameUsedMgr> .Instance().DelCannotUse_Ex(newName);
                    }
                }
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, string.Format("{0}:{1}:{2}:{3}", new object[]
                {
                    (int)cne,
                    oldName,
                    needZuanShi,
                    userInfo.Money
                }), nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }