Example #1
0
 public ActionResult Login(AuthLogin form)
 {
     return(Content("Hey there, " + form.Username));
 }
Example #2
0
    private IEnumerator Start()
    {
        this.name = Name.text = IpAddr;

        RequestTaskQue = new Queue <IHttpRequester>();

        LoginButton.onClick.AddListener(() =>
        {
            System.Action handShakeSetup = () => { };
            handShakeSetup = () =>
            {
                var handShake        = HandShake.Create(Requesters);
                handShake.PostAction = (res) =>
                {
                    LogDisplay.Instance.Push("[" + res.pushCode + "]");

                    if (res.pushCode == typeof(HandShake.ChangeBattlePhase).Name)
                    {
                        var changeBattlePhase = handShake.ConvertResponse <HandShake.ChangeBattlePhase>();
                        LogDisplay.Instance.Push(changeBattlePhase.phase);
                    }

                    if (res.pushCode == typeof(HandShake.Close).Name)
                    {
                        var close = handShake.ConvertResponse <HandShake.Close>();
                        LogDisplay.Instance.Push(close.pushCode + " : " + close.reason);
                        return;
                    }

                    if (res.pushCode == typeof(HandShake.ExecCommand).Name)
                    {
                        var execCommand = handShake.ConvertResponse <HandShake.ExecCommand>();
                        LogDisplay.Instance.Push(execCommand.command);
                    }

                    if (res.pushCode == typeof(HandShake.MatchInfo).Name)
                    {
                        var matchInfo = handShake.ConvertResponse <HandShake.MatchInfo>();
                        LogDisplay.Instance.Push("matchId:" + matchInfo.matchId + "/matchType: " + matchInfo.matchType);
                    }

                    handShakeSetup();
                };
                StartCoroutine(handShake.RequestCoroutine(AuthToken));
            };

            var authLogin       = AuthLogin.Create(Requesters);
            authLogin.PreAction = (req) =>
            {
                req.account  = Account;
                req.password = Password;
                return(null);
            };
            authLogin.PostAction = (res) =>
            {
                AuthToken = res.token;
                handShakeSetup();
            };
            RequestTaskQue.Enqueue(authLogin);
        });

        LogoutButton.onClick.AddListener(() =>
        {
            var authLogout = AuthLogout.Create(Requesters);
            RequestTaskQue.Enqueue(authLogout);
        });

        MatchingEntryButton.onClick.AddListener(() =>
        {
            var matchingEntry       = MatchingEntryBattleServer.Create(Requesters);
            matchingEntry.PreAction = (req) =>
            {
                req.ipAddr              = IpAddr;
                req.port                = 12345;
                req.rule                = "PointCapture";
                req.mapId               = "Lv909";
                req.label               = "ビルドラベルゥ";
                req.description         = "おれサーバー";
                req.autoMatchmakeTarget = true;
                req.serverName          = "サバ太郎";
                req.region              = "ap-east-1";
                req.owner               = "yoshimura";
                return(null);
            };
            RequestTaskQue.Enqueue(matchingEntry);
        });

        DisconnectPlayersButton.onClick.AddListener(() =>
        {
            AcceptedPlayers.ForEach(playerId =>
            {
                var reportDisconnectPlayer       = ReportDisconnectPlayer.Create(Requesters);
                reportDisconnectPlayer.PreAction = (req) =>
                {
                    req.playerId = playerId;
                    return(null);
                };
                RequestTaskQue.Enqueue(reportDisconnectPlayer);
            });
            AcceptedPlayers.Clear();
        });


        while (true)
        {
            while (RequestTaskQue.Count != 0)
            {
                var requester = RequestTaskQue.Dequeue();

                yield return(requester.RequestCoroutine(AuthToken));
            }

            yield return(new WaitForSeconds(1));
        }
    }
        private string SelWhere(System.Collections.Specialized.NameValueCollection parames)
        {
            var           loginUser = AuthLogin.GetUserInfo(Username);
            StringBuilder StrWhere  = new StringBuilder(" A1=1 ");

            if (loginUser.Company.RoleType == 1)
            {
                if (parames["GYList"] != "")                                                                          //出票公司编码
                {
                    StrWhere.AppendFormat(" and (CPCpyNo='{0}' or left(OwnerCpyNo,12)= '{0}' ) ", parames["GYList"]); //可查询共享
                }
            }
            else if (loginUser.Company.RoleType == 2)
            {
                StrWhere.Append(" and (CPCpyNo='" + loginUser.User.CpyNo + "' or left(OwnerCpyNo,12)= '" + loginUser.User.CpyNo + "' ) "); //可查询共享
            }
            else if (loginUser.Company.RoleType == 3)
            {
                StrWhere.Append(" and CPCpyNo='" + loginUser.User.CpyNo + "' ");
            }
            else if (loginUser.Company.RoleType == 4 || loginUser.Company.RoleType == 5)
            {
                StrWhere.Append(" and OwnerCpyNo='" + loginUser.User.CpyNo + "' ");
            }
            try
            {
                //订单号或者票号
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["orderid"])))
                {
                    string OrderIdAndTicketNumber = CommonManage.TrimSQL(parames["orderid"]);
                    string pattern = @"^\d{3,4}(\-?|\s+)\d{10}$";
                    if (Regex.Match(OrderIdAndTicketNumber, pattern, RegexOptions.IgnoreCase).Success)
                    {
                        //票号
                        StrWhere.AppendFormat(" and  dbo.GetTicketNumber(OrderId) like '%|{0}|%' ", OrderIdAndTicketNumber);
                    }
                    else
                    {
                        //订单号
                        StrWhere.AppendFormat(" and OrderId='{0}' ", OrderIdAndTicketNumber);
                    }
                }
                //pnr
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["pnr"])))
                {
                    StrWhere.Append(" and PNR='" + CommonManage.TrimSQL(parames["pnr"]) + "' ");
                }
                //乘机人
                if (!string.IsNullOrEmpty(parames["passengerName"]))
                {
                    StrWhere.Append(" and PassengerName like'%" + CommonManage.TrimSQL(parames["passengerName"]) + "%' ");
                }
                //客户名称
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["corporationName"])))
                {
                    StrWhere.Append(" and CreateCpyName like'%" + CommonManage.TrimSQL(parames["corporationName"]) + "%' ");
                }
                //航班号
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["flightCode"])))
                {
                    StrWhere.Append(" and FlightCode ='" + CommonManage.TrimSQL(parames["flightCode"]) + "' ");
                }
                //航空公司
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["airCode"])))
                {
                    StrWhere.Append(" and CarryCode ='" + CommonManage.TrimSQL(parames["airCode"]) + "' ");
                }

                //订单状态
                if (!string.IsNullOrEmpty(parames["status"]) && parames["status"] != "0")
                {
                    StrWhere.Append(" and OrderStatusCode= " + CommonManage.TrimSQL(parames["status"]));
                }


                //乘机日期
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["airFTimeDate"])))
                {
                    StrWhere.Append(" and AirTime >'" + CommonManage.TrimSQL(parames["airFTimeDate"]) + " 00:00:00'");
                }
                //乘机日期
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["airETimeDate"])))
                {
                    StrWhere.Append(" and AirTime <'" + CommonManage.TrimSQL(parames["airETimeDate"]) + " 23:59:59'");
                }

                //创建日期
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["createFTimeDate"])))
                {
                    StrWhere.Append(" and CreateTime >'" + CommonManage.TrimSQL(parames["createFTimeDate"]) + " 00:00:00'");
                }
                //创建日期
                if (!string.IsNullOrEmpty(CommonManage.TrimSQL(parames["createETimeDate"])))
                {
                    StrWhere.Append(" and CreateTime <'" + CommonManage.TrimSQL(parames["createETimeDate"]) + " 23:59:59'");
                }

                ////城市控件
                //if (txtFromCity.Value.Trim() != "" && txtFromCity.Value.Trim() != "中文/拼音" && txtFromCity.Value.Trim() != "中文/英文")
                //    StrWhere.Append(" and Travel like '" + CommonManage.TrimSQL(txtFromCity.Value.Trim()) + "%'");
                //if (txtToCity.Value.Trim() != "" && txtToCity.Value.Trim() != "中文/拼音" && txtToCity.Value.Trim() != "中文/英文")
                //    StrWhere.Append(" and Travel like '%" + CommonManage.TrimSQL(txtToCity.Value.Trim()) + "'");

                ////城市控件
                if (!string.IsNullOrEmpty(parames["fcity"]))
                {
                    StrWhere.Append(" and TravelCode like '" + CommonManage.TrimSQL(parames["fcity"]) + "%'");
                }
                if (!string.IsNullOrEmpty(parames["tcity"]))
                {
                    StrWhere.Append(" and TravelCode like '%" + CommonManage.TrimSQL(parames["tcity"]) + "'");
                }
            }
            catch (Exception)
            {
            }
            return(StrWhere.ToString());
        }
Example #4
0
        /// <summary>
        /// 创建PNR时 生成一个没有政策的订单信息
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="parames"></param>
        public override void Create(ResponseWriter writer, System.Collections.Specialized.NameValueCollection parames)
        {
            List <Tb_Ticket_Passenger> pList      = new List <Tb_Ticket_Passenger>();
            List <Tb_Ticket_SkyWay>    skywaylist = new List <Tb_Ticket_SkyWay>();

            #region 取提交的参数信息

            string adultPnr      = parames["adultPnr"];                         //只是儿童时需要备注的成人编码
            string pListStr      = parames["pList"];                            //乘机人信息 名称,类型,证件ID,儿童生日/名称,类型,证件ID,儿童生日
            string skywaylistStr = parames["skywaylist"];                       //航段信息 承运人,航班号,起飞日期,到达日期,起飞三字码,到达三字码,起飞城市,到达城市,舱位,折扣/航段信息 承运人,航班号,起飞日期,到达日期,起飞三字码,到达三字码,起飞城市,到达城市,舱位,折扣
            allowChangePNRFlag         = parames["allowChangePNRFlag"] == "1";  //是否允许换编码出票
            isAsAdultOrder             = parames["isAsAdultOrder"] == "1";      //是否关联成人订单号
            cHDAssociationAdultOrderId = parames["cHDAssociationAdultOrderId"]; //关联成人定单号
            isCHDToAudltTK             = parames["isCHDToAudltTK"] == "1";      //儿童票出成人票
            linkMan      = parames["linkMan"];                                  //联系人
            linkManPhone = parames["linkManPhone"];                             //联系人电话
            travelType   = parames["travelType"];                               //航班类型  1=单程,2=往返,3=中转联程 4=多程
            foreach (var pStr in pListStr.Split('/'))
            {
                var ps = pStr.Split(',');
                if (ps[1] == "2" && ps.Count() == 4)
                {
                    pList.Add(new Tb_Ticket_Passenger()
                    {
                        PassengerName = ps[0],
                        PassengerType = int.Parse(ps[1]),
                        Cid           = ps[2],
                        A7            = ps[3]
                    });
                }
                else if (ps[1] != "2")
                {
                    pList.Add(new Tb_Ticket_Passenger()
                    {
                        PassengerName = ps[0],
                        PassengerType = int.Parse(ps[1]),
                        Cid           = ps[2]
                    });
                }

                else
                {
                    writer.WriteEx(550, "passenger format error", "乘机人格式有误");
                }
            }
            foreach (var kStr in skywaylistStr.Split('/'))
            {
                var ks = kStr.Split(',');
                if (ks.Count() == 10)
                {
                    skywaylist.Add(new Tb_Ticket_SkyWay()
                    {
                        CarryCode    = ks[0],
                        FlightCode   = ks[1],
                        FromDate     = DateTime.Parse(ks[2]),
                        ToDate       = DateTime.Parse(ks[3]),
                        FromCityCode = ks[4],
                        ToCityCode   = ks[5],
                        FromCityName = ks[6],
                        ToCityName   = ks[7],
                        Space        = ks[8],
                        Discount     = ks[9]
                    });
                }
                else
                {
                    writer.WriteEx(550, "skyway format error", "航段格式有误");
                }
            }
            #endregion

            UserLoginInfo     userLogin = AuthLogin.GetUserInfo(Username);
            List <IPassenger> pasList   = new List <IPassenger>();
            List <ISkyLeg>    skyList   = new List <ISkyLeg>();
            SendNewPID        pid       = new SendNewPID();
            PnrParamObj       PnrParam  = new PnrParamObj();
            //必填项 是否开启新版PID发送指令
            PnrParam.UsePIDChannel = userLogin.FQP.KongZhiXiTong != null && userLogin.FQP.KongZhiXiTong.Contains("|48|") ? 2 : 0;  //2;
            PnrParam.ServerIP      = userLogin.Configparam.WhiteScreenIP;
            PnrParam.ServerPort    = int.Parse(string.IsNullOrEmpty(userLogin.Configparam.WhiteScreenPort) ? "0" : userLogin.Configparam.WhiteScreenPort);
            PnrParam.Office        = userLogin.Configparam.Office;
            PnrParam.CarryCode     = skywaylist[0].CarryCode;
            PnrParam.PasList       = pasList;
            PnrParam.SkyList       = skyList;
            //只是儿童时需要备注的成人编码
            PnrParam.AdultPnr = adultPnr;
            //是否儿童出成人票
            PnrParam.ChildIsAdultEtdz = isCHDToAudltTK ? "1" : "0";;
            //可选项
            PnrParam.UserName = Username;



            //输入的手机号码 预订编码CT项电话
            if (userLogin.FQP.KongZhiXiTong == null || !userLogin.FQP.KongZhiXiTong.Contains("|19|"))
            {
                PnrParam.CTTel     = userLogin.User != null ? userLogin.User.Tel : "";
                PnrParam.CTCTPhone = linkManPhone != "" ? linkManPhone : (userLogin.Company != null && userLogin.Company.ContactTel.Trim() != "" ? userLogin.Company.ContactTel.Trim() : "");
            }
            else
            {
                PnrParam.CTTel     = userLogin.mSupCompany.Tel != null ? userLogin.mSupCompany.Tel : "";
                PnrParam.CTCTPhone = linkManPhone != "" ? linkManPhone : (userLogin.mSupCompany != null && userLogin.mSupCompany.ContactTel.Trim() != "" ? userLogin.mSupCompany.ContactTel.Trim() : "");
            }

            //关闭生成订单联系人默认值   生成订单时,联系人不需要默认值,让用户自己填写
            if (userLogin.FQP.KongZhiXiTong != null && userLogin.FQP.KongZhiXiTong.Contains("|55|"))
            {
                PnrParam.CTTel     = userLogin.User != null ? userLogin.User.Tel : "";
                PnrParam.CTCTPhone = linkManPhone;
            }


            PnrParam.PID   = userLogin.Configparam.Pid;
            PnrParam.KeyNo = userLogin.Configparam.KeyNo;
            //乘机人
            foreach (Tb_Ticket_Passenger pas in pList)
            {
                IPassenger p1 = new IPassenger();
                pasList.Add(p1);
                p1.PassengerName = pas.PassengerName;
                p1.PassengerType = pas.PassengerType;
                p1.PasSsrCardID  = pas.Cid;
                p1.ChdBirthday   = pas.A7;
            }
            //航段
            foreach (Tb_Ticket_SkyWay skyway in skywaylist)
            {
                ISkyLeg leg1 = new ISkyLeg();
                skyList.Add(leg1);
                leg1.CarryCode    = skyway.CarryCode;
                leg1.FlightCode   = skyway.FlightCode;
                leg1.FlyStartTime = skyway.FromDate.ToString("HHmm");
                leg1.FlyEndTime   = skyway.ToDate.ToString("HHmm");
                leg1.FlyStartDate = skyway.FromDate.ToString("yyyy-MM-dd");
                leg1.fromCode     = skyway.FromCityCode;
                leg1.toCode       = skyway.ToCityCode;
                leg1.Space        = skyway.Space;
                leg1.Discount     = skyway.Discount;
            }
            RePnrObj pObj = pid.ISendIns(PnrParam);
            string   msg  = "";
            if (GenerationOrder(userLogin, skywaylist, pList, pObj, out msg))
            {
                writer.Write(new { pnr = pObj, orderID = msg });
            }
            else
            {
                writer.WriteEx(565, "create order error", "创建空白定单失败:" + msg);
            }
        }
Example #5
0
    private IEnumerator Start()
    {
        this.name = Name.text = Password;

        RequestTaskQue = new Queue <IHttpRequester>();

        LoginButton.onClick.AddListener(() =>
        {
            System.Action handShakeSetup = () => { };
            handShakeSetup = () =>
            {
                var handShake        = HandShake.Create(Requesters);
                handShake.PostAction = (res) =>
                {
                    var masterDataVersion = "";
                    if (res.masterDataVersion != null)
                    {
                        if (0 < res.masterDataVersion.Length)
                        {
                            masterDataVersion += res.masterDataVersion[0] + "-";
                        }
                        if (1 < res.masterDataVersion.Length)
                        {
                            masterDataVersion += "-" + res.masterDataVersion[1];
                        }
                        if (2 < res.masterDataVersion.Length)
                        {
                            masterDataVersion += "-" + res.masterDataVersion[2];
                        }
                    }

                    var noticeCodes = "";
                    foreach (var code in res.opsNoticeCodes)
                    {
                        noticeCodes += "[" + code + "]";
                    }

                    var disabledMS = "";
                    foreach (var ms in res.disabledMobileSuits)
                    {
                        disabledMS += "{" + ms + "}";
                    }

                    LogDisplay.Instance.Push("["
                                             + res.pushCode
                                             + "(" + masterDataVersion + ")"
                                             + " matchmake:" + res.enabledMatchmake
                                             + noticeCodes
                                             + disabledMS
                                             + "]");

                    if (res.pushCode == typeof(HandShake.JoinBattle).Name)
                    {
                        var joinBattle = handShake.ConvertResponse <HandShake.JoinBattle>();

                        var battleServer = GameObject.Find(joinBattle.ipAddr).GetComponent <BattleServer>();
                        battleServer.AcceptClient(PlayerId, joinBattle.ipAddr, joinBattle.port, joinBattle.joinPassword);

                        LogDisplay.Instance.Push(
                            joinBattle.ipAddr + ":" +
                            joinBattle.port + ":" +
                            joinBattle.joinPassword);

                        Debug.Log("token:" + joinBattle.token);
                        Debug.Log("encryptionKey:" + joinBattle.newEncryptionKey);
                    }

                    if (res.pushCode == typeof(HandShake.Close).Name)
                    {
                        var close = handShake.ConvertResponse <HandShake.Close>();
                        LogDisplay.Instance.Push(close.pushCode + " : " + close.reason);
                        return;
                    }

                    if (res.pushCode == typeof(HandShake.Chat).Name)
                    {
                        var chat = handShake.ConvertResponse <HandShake.Chat>();
                        LogDisplay.Instance.Push(chat.playerId + ":" + chat.playerName + " : " + chat.text);
                    }

                    handShakeSetup();
                };
                StartCoroutine(handShake.RequestCoroutine(AuthToken));
            };

            var authLogin       = AuthLogin.Create(Requesters);
            authLogin.PreAction = (req) =>
            {
                req.account        = Account;
                req.password       = Password;
                req.packageVersion = new int[] { 1, 1, 1, 1, };
                return(null);
            };
            authLogin.PostAction = (res) =>
            {
                AuthToken = res.token;
                PlayerId  = res.playerId;
                LogDisplay.Instance.Push("initialLevel: " + res.initialLevel);
                handShakeSetup();
            };
            RequestTaskQue.Enqueue(authLogin);
        });

        SetFirstOnetimeButton.onClick.AddListener(() =>
        {
            var setFirstOnetime       = SetFirstOnetime.Create(Requesters);
            setFirstOnetime.PreAction = (req) =>
            {
                req.playerName = PlayerName;
                return(null);
            };
            RequestTaskQue.Enqueue(setFirstOnetime);
        });

        LogoutButton.onClick.AddListener(() =>
        {
            var authLogout = AuthLogout.Create(Requesters);
            RequestTaskQue.Enqueue(authLogout);
        });

        MatchingEntryButton.onClick.AddListener(() =>
        {
            var matchingEntry       = MatchingEntryPlayer.Create(Requesters);
            matchingEntry.PreAction = (req) =>
            {
                req.matchType = (CasualMatch.isOn) ? 0 : 1;
                return(null);
            };
            RequestTaskQue.Enqueue(matchingEntry);
        });

        MatchingCancelButton.onClick.AddListener(() =>
        {
            var matchingCancel = MatchingCancelPlayer.Create(Requesters);
            RequestTaskQue.Enqueue(matchingCancel);
        });

        GetBattlesListButton.onClick.AddListener(() =>
        {
            var getBattlesList        = GetBattlesList.Create(Requesters);
            getBattlesList.PostAction = (res) =>
            {
                var list = new List <string>();
                res.battlesList.ForEach(bs => list.Add(bs.battleId));
                BattlesListDropdown.ClearOptions();
                BattlesListDropdown.AddOptions(list);
            };

            RequestTaskQue.Enqueue(getBattlesList);
        });

        RequestJoinBattleButton.onClick.AddListener(() =>
        {
            var idx     = BattlesListDropdown.value;
            var options = BattlesListDropdown.options;
            if (idx < options.Count)
            {
                var requestJoinBattle       = RequestJoinBattle.Create(Requesters);
                requestJoinBattle.PreAction = (req) =>
                {
                    req.battleId = options[idx].text;
                    return(null);
                };

                RequestTaskQue.Enqueue(requestJoinBattle);
            }
        });

        DioramaSaveButton.onClick.AddListener(() =>
        {
            var dioramaSave       = DioramaSave.Create(Requesters);
            dioramaSave.PreAction = (req) =>
            {
                var fs = System.IO.File.Open("C:/Users/t-yoshimura/Desktop/img_2_m.jpg",
                                             System.IO.FileMode.Open,
                                             System.IO.FileAccess.Read);
                var bytes = new byte[fs.Length];
                fs.Read(bytes, 0, bytes.Length);
                fs.Close();

                var form = new WWWForm();
                form.AddBinaryData("sceneData", bytes, "filename1", "application/octet-stream");
                form.AddField("index", 3);
                form.AddField("hashCode", Random.rotation.ToString("F4"));
                return(form);
            };
            RequestTaskQue.Enqueue(dioramaSave);
        });

        DioramaUploadButton.onClick.AddListener(() =>
        {
            var dioramaUpload       = DioramaUpload.Create(Requesters);
            dioramaUpload.PreAction = (req) =>
            {
                var form = new WWWForm();
                {
                    var fs = System.IO.File.Open("C:/Users/t-yoshimura/Desktop/kinniku_ude.png",
                                                 System.IO.FileMode.Open,
                                                 System.IO.FileAccess.Read);
                    var bytes = new byte[fs.Length];
                    fs.Read(bytes, 0, bytes.Length);
                    fs.Close();

                    form.AddBinaryData("sceneData", bytes, "filename1", "application/octet-stream");
                }
                {
                    var fs = System.IO.File.Open("C:/Users/t-yoshimura/Desktop/diet_before_man.png",
                                                 System.IO.FileMode.Open,
                                                 System.IO.FileAccess.Read);
                    var bytes = new byte[fs.Length];
                    fs.Read(bytes, 0, bytes.Length);
                    fs.Close();

                    form.AddBinaryData("visual", bytes, "filename2", "application/octet-stream");
                }

                form.AddField("hashCode", Random.rotation.ToString("F4"));

                return(form);
            };
            RequestTaskQue.Enqueue(dioramaUpload);
        });


        while (true)
        {
            while (RequestTaskQue.Count != 0)
            {
                var requester = RequestTaskQue.Dequeue();

                yield return(requester.RequestCoroutine(AuthToken));
            }

            yield return(new WaitForSeconds(1));
        }
    }
        public bool IsAuthenticatingInLegacyOdiss(string username, string password)
        {
            AuthLogin login = new AuthLogin();

            return(login.ValidateUser(username, password));
        }
Example #7
0
        /// <summary>
        /// Packets handled in this function are 'internal' cannot be overriden.
        /// </summary>
        internal bool HandlePacket(PacketEventArgs e)
        {
            if (IsCaptcha)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    fastping = true;
                    break;

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN:
                    AutoLogin login = (AutoLogin)e.Packet;
                    Commands.HandleAutoLogin(server, this, login.Sha1Password);
                    break;

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;
                    FinishCaptcha(pub.Message);
                    break;

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;
                    FinishCaptcha(emote.Message);
                    break;

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    SharedFile addfile = (SharedFile)e.Packet;

                    if (server.PluginManager.OnFileReceived(this, addfile))
                    {
                        lock (files) files.Add(addfile);
                    }

                    break;

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    lastupdate = TimeBank.CurrentTime;

                    NodeIp   = update.NodeIp;
                    NodePort = update.NodePort;
                    Age      = (update.Age != 0) ? update.Age : Age;
                    Gender   = (update.Gender != 0) ? update.Gender : Gender;
                    Country  = (update.Country != 0) ? update.Country : Country;
                    Region   = !String.IsNullOrEmpty(update.Region) ? update.Region : Region;

                    break;
                }

                return(true); //don't handle any other packets yet
            }
            else if (LoggedIn)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    fastping = true;
                    return(true);

                case AresId.MSG_CHAT_CLIENT_DUMMY:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;

                    if (!String.IsNullOrEmpty(pub.Message))
                    {
                        if (pub.Message.StartsWith("#") && Commands.HandlePreCommand(server, this, pub.Message.Substring(1)))
                        {
                            return(true);
                        }
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;

                    if (!String.IsNullOrEmpty(emote.Message))
                    {
                        if (emote.Message.StartsWith("#") && Commands.HandlePreCommand(server, this, emote.Message.Substring(1)))
                        {
                            return(true);
                        }
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_COMMAND:
                    Command cmd = (Command)e.Packet;
                    Commands.HandlePreCommand(server, this, cmd.Message);
                    break;

                case AresId.MSG_CHAT_CLIENT_PVT:
                    Private pvt = (Private)e.Packet;

                    if (Muzzled && !server.Config.MuzzledPMs)
                    {
                        pvt.Message = "[" + Strings.AreMuzzled + "]";
                        server.SendPacket(this, pvt);

                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_AUTHREGISTER: {
                    AuthRegister reg = (AuthRegister)e.Packet;
                    Commands.HandleRegister(server, this, reg.Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTHLOGIN: {
                    AuthLogin login = (AuthLogin)e.Packet;
                    Commands.HandleLogin(server, this, login.Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN: {
                    AutoLogin login = (AutoLogin)e.Packet;
                    Commands.HandleAutoLogin(server, this, login.Sha1Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    SharedFile addfile = (SharedFile)e.Packet;

                    if (server.PluginManager.OnFileReceived(this, addfile))
                    {
                        lock (files) files.Add(addfile);
                    }

                    return(true);

                case AresId.MSG_CHAT_CLIENT_IGNORELIST:
                    Ignored ignore = (Ignored)e.Packet;

                    if (ignore.Ignore)
                    {
                        lock (ignored) {
                            if (!ignored.Contains(ignore.Username))
                            {
                                ignored.Add(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Ignored, ignore.Username));
                            }
                        }
                    }
                    else
                    {
                        lock (ignored) {
                            if (ignored.Contains(ignore.Username))
                            {
                                ignored.Remove(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Unignored, ignore.Username));
                            }
                        }
                    }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    lastupdate = TimeBank.CurrentTime;

                    NodeIp   = update.NodeIp;
                    NodePort = update.NodePort;
                    Age      = (update.Age != 0) ? update.Age : Age;
                    Gender   = (update.Gender != 0) ? update.Gender : Gender;
                    Country  = (update.Country != 0) ? update.Country : Country;
                    Region   = !String.IsNullOrEmpty(update.Region) ? update.Region : Region;

                    server.SendPacket((s) => s.Vroom == Vroom, new ServerUpdate(this));
                    return(true);

                case AresId.MSG_CHAT_CLIENT_DIRCHATPUSH:
                    ClientDirectPush push = (ClientDirectPush)e.Packet;

                    if (Encoding.UTF8.GetByteCount(push.Username) < 2)
                    {
                        server.SendPacket(this, new DirectPushError(4));
                        return(true);
                    }

                    if (push.TextSync.Length < 16)
                    {
                        server.SendPacket(this, new DirectPushError(3));
                        return(true);
                    }

                    IClient target = server.FindUser(s => s.Name == push.Username);

                    if (target == null)
                    {
                        server.SendPacket(this, new DirectPushError(1));
                        return(true);
                    }

                    if (target.Ignored.Contains(Name))
                    {
                        server.SendPacket(this, new DirectPushError(2));
                        return(true);
                    }

                    server.SendPacket(this, new DirectPushError(0));
                    server.SendPacket(target, new ServerDirectPush(this, push));

                    return(true);

                case AresId.MSG_CHAT_CLIENT_BROWSE:
                    Browse browse = (Browse)e.Packet;

                    browse.Type = (byte)((browse.Type == 0) ? (byte)255 : browse.Type);
                    browse.Type = (byte)((browse.Type == 8) ? (byte)0 : browse.Type);

                    IClient browse_target = server.FindUser(s => s.Vroom == Vroom && s.Name == browse.Username);

                    if (browse_target == null)
                    {
                        return(true);
                    }

                    else if (browse_target.Files.Count == 0)
                    {
                        server.SendPacket(this, new BrowseError(browse.BrowseId));
                    }

                    else
                    {
                        server.SendPacket(this, new BrowseStart(browse.BrowseId, (ushort)browse_target.Files.Count));

                        foreach (var file in browse_target.Files)
                        {
                            if (browse.Type == 255 || browse.Type == file.Type)
                            {
                                server.SendPacket(this, new BrowseItem(browse.BrowseId, file));
                            }
                        }

                        server.SendPacket(this, new BrowseEnd(browse.BrowseId));
                    }

                    return(true);

                case AresId.MSG_CHAT_CLIENT_SEARCH:
                    Search search = (Search)e.Packet;

                    search.Type = (byte)((search.Type == 0) ? (byte)255 : search.Type);
                    search.Type = (byte)((search.Type == 8) ? (byte)0 : search.Type);

                    foreach (var user in server.Users)
                    {
                        if (user != this && user.Vroom == Vroom)
                        {
                            foreach (var file in user.Files)
                            {
                                if (file.SearchWords.ContainsAny(search.SearchWords.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries)))
                                {
                                    server.SendPacket(this, new SearchHit(search.SearchId, user, file));
                                }
                            }
                        }
                    }

                    server.SendPacket(this, new SearchEnd(search.SearchId));
                    return(true);
                }

                return(false);//wasn't handled
            }
            else
            {
                return(true);//not captcha, not logged, error
            }
        }
Example #8
0
        /// <summary>
        /// Packets handled in this function are 'internal' and cannot be overriden.
        /// </summary>
        internal bool HandlePacket(PacketEventArgs e)
        {
            if (IsCaptcha)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    fastping = true;
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN:
                    AutoLogin login = (AutoLogin)e.Packet;
                    Commands.HandleAutoLogin(server, this, login.Sha1Password);
                    return(true);

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;
                    FinishCaptcha(pub.Message);
                    return(true);

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;
                    FinishCaptcha(emote.Message);
                    return(true);

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    lastupdate = DateTime.Now;

                    NodeIp   = update.NodeIp;
                    NodePort = update.NodePort;
                    Age      = (update.Age != 0) ? update.Age : Age;
                    Gender   = (update.Gender != 0) ? update.Gender : Gender;
                    Country  = (update.Country != 0) ? update.Country : Country;
                    //Region = !String.IsNullOrEmpty(update.Region) ? update.Region : Region;
                    return(true);

                default:
                    break;
                }
                return(false);
            }
            else if (LoggedIn)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    fastping = true;
                    return(true);

                case AresId.MSG_CHAT_CLIENT_DUMMY:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;

                    if (!String.IsNullOrEmpty(pub.Message))
                    {
                        if (pub.Message.StartsWith("#") && Commands.HandlePreCommand(server, this, pub.Message.Substring(1)))
                        {
                            return(true);
                        }
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;

                    if (!String.IsNullOrEmpty(emote.Message))
                    {
                        if (emote.Message.StartsWith("#") && Commands.HandlePreCommand(server, this, emote.Message.Substring(1)))
                        {
                            return(true);
                        }
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_COMMAND:
                    Command cmd = (Command)e.Packet;
                    Commands.HandlePreCommand(server, this, cmd.Message);
                    break;

                case AresId.MSG_CHAT_CLIENT_PVT:
                    Private pvt = (Private)e.Packet;

                    if (Muzzled && !server.Config.MuzzledPMs)
                    {
                        pvt.Message = "[" + Strings.AreMuzzled + "]";
                        server.SendPacket(this, pvt);

                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_AUTHREGISTER: {
                    AuthRegister reg = (AuthRegister)e.Packet;
                    Commands.HandleRegister(server, this, reg.Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTHLOGIN: {
                    AuthLogin login = (AuthLogin)e.Packet;
                    Commands.HandleLogin(server, this, login.Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN: {
                    AutoLogin login = (AutoLogin)e.Packet;
                    Commands.HandleAutoLogin(server, this, login.Sha1Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_IGNORELIST:
                    Ignored ignore = (Ignored)e.Packet;

                    if (ignore.Ignore)
                    {
                        lock (ignored) {
                            if (!ignored.Contains(ignore.Username))
                            {
                                ignored.Add(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Ignored, ignore.Username));
                            }
                        }
                    }
                    else
                    {
                        lock (ignored) {
                            if (ignored.Contains(ignore.Username))
                            {
                                ignored.Remove(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Unignored, ignore.Username));
                            }
                        }
                    }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    lastupdate = DateTime.Now;

                    NodeIp   = update.NodeIp;
                    NodePort = update.NodePort;
                    Age      = (update.Age != 0) ? update.Age : Age;
                    Gender   = (update.Gender != 0) ? update.Gender : Gender;
                    Country  = (update.Country != 0) ? update.Country : Country;
                    //Region = !String.IsNullOrEmpty(update.Region) ? update.Region : Region;
                    server.SendPacket((s) => s.Vroom == Vroom, new ServerUpdate(this));

                    return(true);

                case AresId.MSG_CHAT_CLIENT_DIRCHATPUSH:
                    ClientDirectPush push = (ClientDirectPush)e.Packet;

                    if (Encoding.UTF8.GetByteCount(push.Username) < 2)
                    {
                        server.SendPacket(this, new DirectPushError(4));
                        return(true);
                    }

                    if (push.TextSync.Length < 16)
                    {
                        server.SendPacket(this, new DirectPushError(3));
                        return(true);
                    }

                    IClient target = server.FindUser(s => s.Name == push.Username);

                    if (target == null)
                    {
                        server.SendPacket(this, new DirectPushError(1));
                        return(true);
                    }

                    if (target.Ignored.Contains(Name))
                    {
                        server.SendPacket(this, new DirectPushError(2));
                        return(true);
                    }

                    server.SendPacket(this, new DirectPushError(0));
                    server.SendPacket(target, new ServerDirectPush(this, push));

                    return(true);

                case AresId.MSG_CHAT_CLIENT_BROWSE:
                    server.SendPacket(this, new BrowseError(((Browse)e.Packet).BrowseId));
                    return(true);

                case AresId.MSG_CHAT_CLIENT_SEARCH:
                    server.SendPacket(this, new SearchEnd(((Search)e.Packet).SearchId));
                    return(true);

                case AresId.MSG_CHAT_CLIENTCOMPRESSED: {
                    Compressed packet  = (Compressed)e.Packet;
                    byte[]     payload = Zlib.Decompress(packet.Data);

                    var reader = new PacketReader(payload)
                    {
                        Position = 0L
                    };

                    while (reader.Remaining >= 3)
                    {
                        ushort count = reader.ReadUInt16();
                        byte   id    = reader.ReadByte();

                        IPacket msg = Socket.Formatter.Unformat(id, reader.ReadBytes(count));
                        OnPacketReceived(Socket, new PacketEventArgs(msg, WebSocketMessageType.Binary, 0));
                    }
                    break;
                }

                default:
                    break;
                }

                return(false);//wasn't handled
            }
            else
            {
                //not captcha, not logged, error?
                Logging.Info("AresClient", "Client {0} sent {1} before logging in.", this.ExternalIp, e.Packet.Id);
                return(true);
            }
        }
        /// <summary>
        /// Logs in a user. Returns access token and refresh token. Note: UPN(e.g. [email protected]) based login is not supported.&lt;br/&gt; Only Administrators on Root access group are allowed to login.
        /// </summary>
        /// <exception cref="VMware.Horizon.RESTAPI.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Login credentials needed for Authentication</param>
        /// <returns>Task of AuthTokens</returns>
        public async System.Threading.Tasks.Task <AuthTokens> LoginUserAsync(AuthLogin body)
        {
            ApiResponse <AuthTokens> localVarResponse = await LoginUserAsyncWithHttpInfo(body);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// Logs in a user. Returns access token and refresh token. Note: UPN(e.g. [email protected]) based login is not supported.&lt;br/&gt; Only Administrators on Root access group are allowed to login.
        /// </summary>
        /// <exception cref="VMware.Horizon.RESTAPI.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Login credentials needed for Authentication</param>
        /// <returns>Task of ApiResponse (AuthTokens)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <AuthTokens> > LoginUserAsyncWithHttpInfo(AuthLogin body)
        {
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling AuthApi->LoginUser");
            }

            var    localVarPath         = "./login";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "*/*"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("LoginUser", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <AuthTokens>(localVarStatusCode,
                                                localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()),
                                                (AuthTokens)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(AuthTokens))));
        }
        /// <summary>
        /// Logs in a user. Returns access token and refresh token. Note: UPN(e.g. [email protected]) based login is not supported.&lt;br/&gt; Only Administrators on Root access group are allowed to login.
        /// </summary>
        /// <exception cref="VMware.Horizon.RESTAPI.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Login credentials needed for Authentication</param>
        /// <returns>AuthTokens</returns>
        public AuthTokens LoginUser(AuthLogin body)
        {
            ApiResponse <AuthTokens> localVarResponse = LoginUserWithHttpInfo(body);

            return(localVarResponse.Data);
        }
Example #12
0
        public override void Query(ResponseWriter writer, System.Collections.Specialized.NameValueCollection parames)
        {
            var user = AuthLogin.GetUserInfo(Username);

            writer.Write("GET提交 查询资源");
        }
Example #13
0
 public ActionResult Login(AuthLogin form)
 {
     return(Content("Hi " + form.Username + " your password =" + form.Password));
 }
Example #14
0
        public ApiResponse <UserDetail> GetUserDetails(AuthLogin req)
        {
            var result = null as UserDetail;

            using (var connection = new SqlConnection(_connectionString.HotelManagement))
            {
                var cmd = new SqlCommand(p_Login_Auth, connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("@UserName", req.UserName);
                cmd.Parameters.AddWithValue("@Password", req.Password);

                cmd.Parameters.Add("@RetVal", SqlDbType.Int).Direction          = ParameterDirection.Output;
                cmd.Parameters.Add("@RetMsg", SqlDbType.VarChar, 500).Direction = ParameterDirection.Output;


                connection.Open();

                using (var dr = cmd.ExecuteReader())
                {
                    result = new UserDetail();
                    while (dr.Read())
                    {
                        result.UserInfo = new Employee
                        {
                            EmployeeId         = dr["EmployeeID"].ToSafeInt32(),
                            UserName           = dr["UserName"].ToSafeString(),
                            FirstName          = dr["FirstName"].ToSafeString(),
                            MidName            = dr["MidName"].ToSafeString(),
                            LastName1          = dr["LastName1"].ToSafeString(),
                            LastName2          = dr["LastName2"].ToSafeString(),
                            Locked             = dr["Locked"].ToSafeBool(),
                            LockedDateTime     = dr["LockedDateTime"].ToSafeDateTime(),
                            RequiresReset      = dr["RequiresReset"].ToSafeBool(),
                            EmployeeTypeId     = dr["EmployeeTypeID"].ToSafeInt32(),
                            StartDateTime      = dr["StartDateTime"].ToSafeDateTime(),
                            LastLoginDateTime  = dr["LastLoginDateTime"].ToSafeDateTime(),
                            Terminated         = dr["IncludeTerminated"].ToSafeBool(),
                            TerminatedDateTime = dr["TerminatedDateTime"].ToSafeDateTime(),

                            CreatedId        = dr["CreatedID"].ToSafeInt32(),
                            CreatedBy        = dr["CreatedBy"].ToSafeString(),
                            CreatedDateTime  = dr["CreatedDateTime"].ToSafeDateTime(),
                            ModifiedId       = dr["ModifiedID"].ToSafeInt32(),
                            ModifiedBy       = dr["ModifiedBy"].ToSafeString(),
                            ModifiedDateTime = dr["ModifiedDateTime"].ToSafeDateTime()
                        };
                    }
                    dr.NextResult();
                    while (dr.Read())
                    {
                        result.UserPermissions.Add(new EmployeePermission
                        {
                            EmployeeId   = dr["EmployeeID"].ToSafeInt32(),
                            PermissionId = dr["PermissionID"].ToSafeInt32(),
                            Name         = dr["Name"].ToSafeString(),

                            CreatedId        = dr["CreatedID"].ToSafeInt32(),
                            CreatedBy        = dr["CreatedBy"].ToSafeString(),
                            CreatedDateTime  = dr["CreatedDateTime"].ToSafeDateTime(),
                            ModifiedId       = dr["ModifiedID"].ToSafeInt32(),
                            ModifiedBy       = dr["ModifiedBy"].ToSafeString(),
                            ModifiedDateTime = dr["ModifiedDateTime"].ToSafeDateTime()
                        });
                    }
                }
                return(new ApiResponse <UserDetail>
                {
                    Content = result,
                    Status = new ReturnStatus(cmd.Parameters["@RetVal"].Value.ToSafeInt32(),
                                              cmd.Parameters["@RetMsg"].Value.ToSafeString())
                });
            }
        }
Example #15
0
        public virtual Pop3Response Login()
        {
            Pop3Client client7;

            this._connection = this._connectionFactory.GetConnection(this._configurationProvider);
            lock (this)
            {
                if (this.State != EPop3ClientState.Awaiting)
                {
                    throw new InvalidOperationException("Pop3Client doesn't allow executing multiple operations simulteneously in a few threads using one object");
                }
                this.State = EPop3ClientState.Busy;
            }
            if (this.ConnectionState == EPop3ConnectionState.Connected)
            {
                lock (this)
                {
                    this.State = EPop3ClientState.Awaiting;
                }
                return(new Pop3Response("+OK"));
            }
            try
            {
                this._connection.Open();
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
                throw;
            }
            if (this._connection.State == EConnectionState.Connected)
            {
                this.ConnectionState = EPop3ConnectionState.Connected;
                if (this.Connected != null)
                {
                    this.Connected(this);
                }
            }
            Pop3Response response = new Pop3Response(this._connection.ReceiveLine());

            if (response.Type != EPop3ResponseType.OK)
            {
                goto Label_03F9;
            }
            CAPA         capa      = new CAPA();
            Pop3Response response2 = this.DoCommand(capa);

            if (this._configurationProvider.SSLInteractionType == EInteractionType.StartTLS)
            {
                Pop3Response response3 = this.DoCommand(new STLS());
                if (response3.Type != EPop3ResponseType.OK)
                {
                    return(response3);
                }
            }
            IPOP3Command command = null;

            if ((this.AuthenticationType == EAuthenticationType.Auto) && ((response2.Type == EPop3ResponseType.ERR) || !capa.Commands.ContainsKey("SASL")))
            {
                command = new AuthStandart(this.Username, this.Password);
            }
            else
            {
                string str2 = string.Empty;
                switch (this.AuthenticationType)
                {
                case EAuthenticationType.Auto:
                {
                    bool flag = false;
                    if (str2.Contains("PLAIN"))
                    {
                        command = new AuthPlain(this.Username, this.Password);
                        flag    = true;
                    }
                    if (str2.Contains("LOGIN"))
                    {
                        command = new AuthStandart(this.Username, this.Password);
                        flag    = true;
                    }
                    if (!flag)
                    {
                        command = new AuthStandart(this.Username, this.Password);
                    }
                    goto Label_03C9;
                }

                case EAuthenticationType.Plain:
                    if (!str2.Contains("PLAIN"))
                    {
                        lock (this)
                        {
                            this.State = EPop3ClientState.Awaiting;
                        }
                        throw new AuthenticationMethodNotSupportedException("Selected authentication method is not supported by the server");
                    }
                    command = new AuthPlain(this.Username, this.Password);
                    goto Label_03C9;

                case EAuthenticationType.Login:
                    if (!str2.Contains("LOGIN"))
                    {
                        lock (this)
                        {
                            this.State = EPop3ClientState.Awaiting;
                        }
                        throw new AuthenticationMethodNotSupportedException("Selected authentication method is not supported by the server");
                    }
                    command = new AuthLogin(this.Username, this.Password);
                    goto Label_03C9;
                }
            }
Label_03C9:
            if (command != null)
            {
                response = this.DoCommand(command);
            }
            if (response.Type == EPop3ResponseType.OK)
            {
                this.ConnectionState = EPop3ConnectionState.Authenticated;
                if (this.Authenticated != null)
                {
                    this.Authenticated(this);
                }
            }
Label_03F9:
            Monitor.Enter(client7 = this);
            try
            {
                this.State = EPop3ClientState.Awaiting;
            }
            finally
            {
                Monitor.Exit(client7);
            }
            return(response);
        }
Example #16
0
        public static void handlePacket(GameClient client, byte[] buff)
        {
            byte   id     = buff[0];
            string cninfo = "handlepacket: request " + id.ToString("x2") + " size " + buff.Length;

            string str = "header: " + buff[0].ToString("x2") + "\n";

            foreach (byte b in buff)
            {
                str += b.ToString("x2") + " ";
            }

            Console.WriteLine(str);
            GameServerNetworkRequest msg = null;

            switch (id)
            {
            case 0x00:
                msg = new ProtocolVersion(client, buff);
                break;

            case 0x08:
                msg = new AuthLogin(client, buff);
                break;

            case 0x09:
                msg = new Logout(client, buff);
                break;

            case 0x0b:
                msg = new CharacterCreate(client, buff);
                break;

            //case 0x0c:
            //    msg = new CharacterDelete(client, buff);
            //    break;
            case 0x0d:
                msg = new CharacterSelected(client, buff);
                break;

            case 0x0e:
                msg = new NewCharacter(client, buff);
                break;
            //case 0x62:
            //    msg = new CharacterRestore(client, buff);
            //    break;
            //case 0x68:
            //    msg = new RequestPledgeCrest(client, buff);
            //    break;

            //case 0x0c:
            //    msg = new CharacterCreate(client, buff);
            //    break;
            //case 0x00:
            //    msg = new ProtocolVersion(client, buff);
            //    break;
            //case 0x09:
            //    msg = new RequestSetPledgeCrest(client, buff);
            //    break;
            case 0x01:
                msg = new MoveBackwardToLocation(client, buff);
                break;

            case 0x03:
                msg = new EnterWorld(client, buff);
                break;

            case 0x0f:
                msg = new RequestItemList(client, buff);
                break;

            case 0x11:
                msg = new RequestUnEquipItem(client, buff);
                break;

            case 0x14:
                msg = new RequestUseItem(client, buff);
                break;

            case 0x1A:
                msg = new RequestStartTrade(client, buff);
                break;

            case 0x16:
                msg = new RequestAddTradeItem(client, buff);
                break;

            case 0x17:
                msg = new RequestTradeDone(client, buff);
                break;

            case 0x04:
                msg = new RequestAction(client, buff);
                break;

            case 0x20:
                msg = new RequestLinkHtml(client, buff);
                break;

            case 0x21:
                msg = new RequestBypassToServer(client, buff);
                break;

            case 0x26:
                msg = new RequestWithdrawalPledge(client, buff);
                break;

            case 0x8c:
                msg = new RequestGetItemFromPet(client, buff);
                break;

            case 0x1b:
                msg = new RequestSocialAction(client, buff);
                break;

            case 0x1e:
                msg = new RequestSellItem(client, buff);
                break;

            case 0x2f:
                msg = new RequestMagicSkillUse(client, buff);
                break;

            case 0x30:
                msg = new Appearing(client, buff);
                break;

            case 0x3B:
                msg = new RequestWarehouseDeposit(client, buff);
                break;

            case 0x32:
                msg = new RequestWarehouseWithdraw(client, buff);
                break;

            case 0x33:
                msg = new RequestShortCutReg(client, buff);
                break;

            case 0x35:
                msg = new RequestShortCutDel(client, buff);
                break;

            case 0x1f:
                msg = new RequestBuyItem(client, buff);
                break;

            case 0x29:
                msg = new RequestJoinParty(client, buff);
                break;

            case 0x2a:
                msg = new RequestAnswerJoinParty(client, buff);
                break;

            case 0x2b:
                msg = new RequestWithDrawalParty(client, buff);
                break;

            case 0x2c:
                msg = new RequestOustPartyMember(client, buff);
                break;

            case 0x36:
                msg = new CannotMoveAnymore(client, buff);
                break;

            case 0x37:
                msg = new RequestTargetCanceld(client, buff);
                break;

            case 0x38:
                msg = new Say2(client, buff);
                break;

            case 0x42:
                msg = new RequestGetOnVehicle(client, buff);
                break;

            case 0x43:
                msg = new RequestGetOffVehicle(client, buff);
                break;

            case 0x44:
                msg = new AnswerTradeRequest(client, buff);
                break;

            case 0x45:
                msg = new RequestActionUse(client, buff);
                break;

            case 0x46:
                msg = new RequestRestart(client, buff);
                break;

            case 0x48:
                msg = new ValidatePosition(client, buff);
                break;

            case 0x4a:
                msg = new StartRotating(client, buff);
                break;

            case 0x4b:
                msg = new FinishRotating(client, buff);
                break;

            case 0x57:
                msg = new RequestShowBoard(client, buff);
                break;

            case 0x58:
                msg = new RequestEnchantItem(client, buff);
                break;

            case 0x59:
                msg = new RequestDestroyItem(client, buff);
                break;

            case 0x64:
                msg = new RequestQuestAbort(client, buff);
                break;

            case 0x66:
                msg = new RequestPledgeInfo(client, buff);
                break;

            case 0xcd:
                msg = new RequestShowMiniMap(client, buff);
                break;

            case 0x6D:
                msg = new RequestSendMsnChatLog(client, buff);
                break;

            case 0xcf:
                msg = new RequestRecordInfo(client, buff);
                break;

            case 0x73:
                msg = new RequestAcquireSkillInfo(client, buff);
                break;

            case 0x74:
                msg = new SendBypassBuildCmd(client, buff);
                break;

            case 0x75:
                msg = new RequestMoveToLocationInVehicle(client, buff);
                break;

            case 0x7C:
                msg = new RequestAcquireSkill(client, buff);
                break;

            case 0x7D:
                msg = new RequestRestartPoint(client, buff);
                break;

            case 0x80:
                msg = new RequestPartyMatchList(client, buff);
                break;

            case 0x85:
                msg = new RequestTutorialLinkHtml(client, buff);
                break;

            case 0x86:
                msg = new RequestTutorialPassCmdToServer(client, buff);
                break;
            //  case 0x87:
            //      msg = new RequestTutorialQuestionMark();
            //     break;

            case 0x93:
                msg = new RequestChangePetName(client, buff);
                break;

            case 0x94:
                msg = new RequestPetUseItem(client, buff);
                break;

            case 0x95:
                msg = new RequestGiveItemToPet(client, buff);
                break;

            case 0xB0:
                msg = new MultiSellChoose(client, buff);
                break;

            case 0xB1:
                msg = new NetPingResponse(client, buff);
                break;

            case 0xaa:
                msg = new BypassUserCmd(client, buff);
                break;

            case 0xB5:
                msg = new RequestRecipeBookOpen(client, buff);
                break;

            case 0xB6:
                msg = new RequestRecipeBookDestroy(client, buff);
                break;

            case 0xB7:
                msg = new RequestRecipeItemMakeInfo(client, buff);
                break;

            case 0xB8:
                msg = new RequestRecipeItemMakeSelf(client, buff);
                break;

            case 0xC1:
                msg = new ObserverReturn(client, buff);
                break;

            case 0xC7:
                msg = new RequestWearItem(client, buff);
                break;

            case 0xD0:
                byte id2 = buff[1];
                cninfo = "handlepacket: request unk id2 " + id2.ToString("x2") + " size " + buff.Length;
                switch (id2)
                {
                case 8:
                    msg = new RequestManorList(client, buff);
                    break;

                case 0x11:
                    msg = new RequestExSetPledgeCrestLarge(client, buff);
                    break;

                case 5:
                    msg = new RequestAutoSoulShot(client, buff);
                    break;

                case 0x16:
                    msg = new RequestPledgeMemberInfo(client, buff);
                    break;


                case 0x1E:
                    msg = new RequestExRqItemLink(client, buff);
                    break;

                case 0x24:
                    msg = new RequestSaveInventoryOrder(client, buff);
                    break;

                case 0x22:
                    msg = new RequestCursedWeaponList(client, buff);
                    break;

                case 0x4B:
                    msg = new RequestDispel(client, buff);
                    break;

                case 0x4C:
                    msg = new RequestExTryToPutEnchantTargetItem(client, buff);
                    break;

                case 0x4D:
                    msg = new RequestExTryToPutEnchantSupportItem(client, buff);
                    break;

                case 0x4E:
                    msg = new RequestExCancelEnchantItem(client, buff);
                    break;

                case 0x58:
                    msg = new RequestDominionInfo(client, buff);
                    break;

                case 0x76:
                    msg = new RequestBuySellUIClose(client, buff);
                    break;

                case 0x78:
                    msg = new RequestPartyLootModification(client, buff);
                    break;

                case 0x79:
                    msg = new AnswerPartyLootModification(client, buff);
                    break;

                case 0x84:
                    msg = new RequestBR_MinigameLoadScores(client, buff);
                    break;

                case 0x85:
                    msg = new RequestBR_MinigameInsertScore(client, buff);
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
            if (msg == null)
            {
                Console.WriteLine(cninfo + ", " + cnt);
                return;
            }

            if (msg.Client.IsTerminated)
            {
                return;
            }

            new Thread(new ThreadStart(msg.run)).Start();
        }
Example #17
0
        private bool isAuthorize(string Token, string IpAddress)
        {
            bool _result = true;

            try
            {
                var encodeString = Token;//values.First();//req.Request.Headers.GetValues("Token").First();
                if (string.IsNullOrEmpty(encodeString))
                {
                    _Message = "Invalid Token";
                    return(false);
                }

                var      Key   = EncryptionLibrary.DecryptText(encodeString);
                string[] Parts = Key.Split(new string[] { ":~!@#" }, StringSplitOptions.None);
                if (Parts.Count() < 6)
                {
                    _Message = "Invalid Token";
                    return(false);
                }
                var      UserName  = Parts[0];
                var      RandomKey = Parts[1];
                var      IdMachine = Parts[2];
                long     tik       = long.Parse(Parts[3]);
                DateTime ExpireOn  = new DateTime(tik);
                var      Psswd     = Parts[4];
                var      Ip        = Parts[5];

                if (Ip != IpAddress)
                {
                    _Message = "Invalid Ip Address";
                    return(false);
                }

                var Auth = new AuthLogin();
                Auth.Account = UserName;
                Auth.Psswd   = Psswd;
                var don = this.getDataAuth(Auth);
                if (don.Count == 0)
                {
                    _Message = "Invalid User";
                    return(false);
                }
                else
                {
                    UserLogs uslog = _userlogsRepo.GetDataBy(Auth.Account, Token);
                    if (DateTime.Now > uslog.ExpireOn)
                    {
                        _Message = "Your Session Has Expired";
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                _result  = false;
                _Message = ex.Message;
                //throw (ex);
            }
            return(_result);
        }