Example #1
0
        private static Kv GetGuest(Cxt cxt, string applicationCode)
        {
            User item = new User();

            item.UserName      = "******" + applicationCode;
            item.Password      = "******";
            item.FirstName     = "Guest";
            item.HumanRankIDE  = RankE.Guest;
            item.EngineID      = 1;
            item.UserStatusIDE = UserStatusE.Blank;
            item.RoomID        = 3;
            item.DateLastLogin = DateTime.Now;
            item.StatusIDE     = StatusE.Active;
            item.Save();

            item.UserName = "******" + item.ID;
            item.Save();

            DataTable roles = User.GetRolesTable(item.UserID);

            Kv kv1 = new Kv();

            kv1.Set("Msg", -1);
            kv1.Set("UserData", UData.ToString(item.DataRow.Table));
            kv1.Set("RolesData", UData.ToString(roles.Copy()));

            return(kv1);
        }
Example #2
0
        public static DataTable LoginKv(Kv kv)
        {
            DataSet ds    = Login(kv.Cxt, kv.Get("LoginID"), kv.Get("Password"), kv.Get("AccessCode"), kv.Get("Ip"), kv.Get("MachineCode"), Convert.ToDateTime(kv.Get("ServerDate")));
            int     msgId = UData.ToInt32(ds.Tables[0].Rows[0]["MsgId"]);

            kv = new Kv();
            kv.Set("Msg", UData.ToString(ds.Tables[0]));

            if (ds.Tables.Count > 1)
            {
                kv.Set("UserData", UData.ToString(ds.Tables[1]));
                kv.Set("RolesData", UData.ToString(ds.Tables[2]));
            }

            return(kv.DataTable);
        }
Example #3
0
        public static Kv UpdateTournamentMatchStatus(Cxt cxt, int tournamentID, TournamentMatchStatusE tournamentMatchStatusID, TournamentMatches matches)
        {
            Kv  kv     = new Kv();
            int result = 0;

            if (tournamentMatchStatusID == TournamentMatchStatusE.InProgress)
            {
                result = GetRoundInprogress(cxt, tournamentID, matches);
                if (result > 0)
                {
                    kv.Set("Result", result);
                    return(kv);
                }
            }
            DataTable dt = new DataTable("TournamentMatchResult");

            dt.Columns.Add("Round", typeof(Int32));
            dt.Columns.Add("TournamentMatchID", typeof(Int32));
            dt.Columns.Add("Player1", typeof(Int32));
            dt.Columns.Add("Player2", typeof(Int32));

            for (int i = 0; i < matches.Count; i++)
            {
                result = 0;

                TournamentMatch item = matches[i];


                if (tournamentMatchStatusID == TournamentMatchStatusE.InProgress)
                {
                    result = IsPlayerAvailable(cxt, item);
                }

                if (result == 0)
                {
                    UpdateTournamentMatchStatus(cxt, tournamentMatchStatusID, item);
                    dt.Rows.Add(item.Round, item.TournamentMatchID, item.WhiteUserID, item.BlackUserID);
                }
            }
            kv.Set("TournamentMatchResult", UData.ToString(dt));
            kv.Set("Result", result);

            return(kv);
        }
Example #4
0
        public static Game RestartGameByMoveID(Cxt cxt, int gameID, int moveID, int wMin, int wSec, int bMin, int bSec)
        {
            Game g = new Game(cxt, gameID);

            Moves moves = new Moves(g.GameXml);

            moves.TruncateAfter(moveID);

            Move ml = moves.Last;

            ml.MoveTimeWhite = wMin + wSec;
            ml.MoveTimeBlack = bMin + bSec;

            g.GameXml = GetGameXML(UData.ToString(moves.DataTable));

            g.Save();

            return(g);
        }
Example #5
0
        private void toolStripButtonDeleteDisable_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (editor1.DocumentText == "clear")
                {
                    editor1.DocumentText = "";
                }
                else
                {
                    DataSet ds = SocketClient.GetKeyValue(Ap.CurrentUser.PersonalNotes);

                    editor1.Document.Body.InnerText = UData.ToString(ds);
                }
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
            }
        }
Example #6
0
        private void SaveGame(string P1, string P2, int MatchID)
        {
            App.Model.GameData _GameData = new App.Model.GameData(this.Game);

            // Players and Result
            _GameData.White1         = P1;
            _GameData.White2         = P1;
            _GameData.Black1         = P2;
            _GameData.Black2         = P2;
            _GameData.Tournament     = Title;
            _GameData.TournamentGuid = TournamentGuid;
            _GameData.IsECO          = false;
            _GameData.EcoCode        = "344";
            _GameData.IsEloWhite     = false;
            _GameData.EloWhite       = 0;
            _GameData.IsEloBlack     = false;
            _GameData.EloBlack       = 0;

            _GameData.Result = "";

            _GameData.ResultSymbol = "";

            _GameData.IsYear  = false;
            _GameData.Year    = 0;
            _GameData.IsMonth = false;
            _GameData.Month   = 0;
            _GameData.IsDay   = false;
            _GameData.Day     = 0;

            _GameData.TournamentMatchID = MatchID;

            string gameXml  = UData.ToString(_GameData.Kv.DataTable);
            string fileName = "uba.icd";// InfinityChess.Offline.Forms.GlobalSet.Default.CurrentGameFile;

            if (gameXml != "")
            {
                Ap.LoadDatabase(fileName);
                Ap.Database.AppendGame(gameXml);
                Ap.Database.Save();
            }
        }
Example #7
0
        public static DataTable LoginGuest(Kv kv)
        {
            DataSet ds = Login(kv.Cxt, kv.Get("LoginID"), kv.Get("Password"), kv.Get("AccessCode"), kv.Get("Ip"),
                               kv.Get("MachineCode"), DateTime.Now);
            int msgId = UData.ToInt32(ds.Tables[0].Rows[0]["MsgId"]);

            Kv kvOut = new Kv();

            kvOut.Cxt = kv.Cxt;
            kvOut.Set("MsgId", msgId);
            kvOut.Set("ServerDateTime", DateTime.Now.ToString());

            if ((SignInMsgE)msgId == SignInMsgE.UserNotFound)
            {
                kvOut = GetGuest(kvOut.Cxt, kv.Get("AccessCode"));
            }
            else
            {
                if (ds.Tables.Count > 1)
                {
                    kvOut.Set("UserData", UData.ToString(ds.Tables[1]));
                    kvOut.Set("RolesData", UData.ToString(ds.Tables[2]));
                }
            }

            System.Diagnostics.Debug.WriteLine("**************** S T A R T **************");

            string s = UData.ToString(ds);

            if (String.IsNullOrEmpty(s))
            {
                System.Diagnostics.Debug.WriteLine("<EMPTY DATASET>");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("ROWS=" + kvOut.DataTable.Rows.Count);
            }

            return(kvOut.DataTable);
        }
Example #8
0
        private void GeUserImageBytes()
        {
            DataTable  userImageTable = new DataTable("UserImageTable");
            DataColumn nameColumn;

            nameColumn            = new DataColumn();
            nameColumn.DataType   = System.Type.GetType("System.String");
            nameColumn.ColumnName = "ImageName";
            userImageTable.Columns.Add(nameColumn);
            DataColumn imageColumn;

            imageColumn            = new DataColumn();
            imageColumn.DataType   = System.Type.GetType("System.Byte[]");
            imageColumn.ColumnName = "ImageBytes";
            userImageTable.Columns.Add(imageColumn);
            DataRow dr = userImageTable.NewRow();

            dr["ImageName"]  = "UserImage";
            dr["ImageBytes"] = UserImage;
            userImageTable.Rows.Add(dr);

            Kv.UserImageType = ImageType;
            Kv.UserImage     = UData.ToString(userImageTable);
        }
Example #9
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            DataSet ds = SocketClient.GetKeyValue("select * from [User]");

            MessageForm.Show(UData.ToString(ds));
        }