protected void btnSave_Click(object sender, EventArgs e)
        {
            ApiControl oTournament = Config.GetApIEngine();
            int        engineID;

            try
            {
                //1. Create new xml
                if (comboEngine.Items.Count <= 0)
                {
                    return;
                }

                engineID = Convert.ToInt32(comboEngine.Items[comboEngine.SelectedIndex].Value);
                string xmlString = oTournament.GetDefaultProperty(engineID,
                                                                  (enType == TrnType.Tornament ?  ApiMsg.enProcessFormTarget.Tournament : ApiMsg.enProcessFormTarget.SitAndGo));

                xmlString = oCom.getFormXml(xmlString, Page);
                xmlString = oCom.setAttributeValue(xmlString, "properties/property", "Tournament Type", (string)Session["Tournament Type Maintenance"]);
                xmlString = oCom.setAttributeValue(xmlString, "properties/property", "Category", Utils.GetInt(enType).ToString());

                if (xmlString == null)
                {
                    Log.Write(this, "Some error occured. Object does not return error description");
                    ShowError("Error occured while creating xml.");
                    return;
                }

                //2. Call InitGameProcess method of Com
                //int sEngineID = Utils.GetInt(comboEngine.Items[comboEngine.SelectedIndex].Value);
                int sADispID     = Utils.GetInt(comboActDisp.Items[comboActDisp.SelectedIndex].Value);
                int tournamentID = 0;
                oTournament.InitGameProcess(engineID, (int)(enType == TrnType.Tornament ?
                                                            ApiMsg.enProcessFormTarget.Tournament : ApiMsg.enProcessFormTarget.SitAndGo), ref tournamentID, xmlString, sADispID);
                if (tournamentID <= 0)
                {
                    Log.Write(this, "Some error occured. Object does not return error description");
                    ShowError("Object error. Tournament wasn't created.");
                    Log.Write(this, "Object error. Tournament wasn't created.");
                    return;
                }

                //3. Save xml in DB
                nTournamentID = tournamentID;
                DBase.Execute(Config.DbUpdateTournamentSettings, "@ID", nTournamentID, "@SettingsXml", xmlString);                 //delete game process in com error case


                //4. Success message
                //		StoreBackID(nTournamentID);
                hdnTournamentID.Value = nTournamentID.ToString();
                lblInfo.Text          = "Tournament was created";
                lblInfo.ForeColor     = Color.Green;
                GetData();
            }
            finally{ oTournament = null; }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //1. Create new xml
            string     xmlString = "";
            ApiControl oEngine   = Config.GetApIEngine();

            try
            {
                DateTime actTime;
                try
                {
                    actTime = DateTime.Parse(txtActivatedTime.Text, new CultureInfo("en-US"));
                }
                catch
                {
                    lblInfo.Text = "Incorrect value for Activated Time. Please enter valid date.";
                    return;
                }

                nEngineID = Core.GetSelectedValueInt(comboEngine);

                xmlString = oEngine.GetDefaultProperty(nEngineID, ApiMsg.enProcessFormTarget.Process);

                xmlString = oCom.getFormXml(xmlString, "gameengine/properties/property", Page);
                xmlString = oCom.setAttributeValue(xmlString, "gameengine/properties/property", "Tournament Type", (string)Session["Tournament Type Process"]);
                if (xmlString == null)
                {
                    return;
                }

                //2. Save values in DB
                nCurrencyID    = Core.GetSelectedValueInt(comboCurrency);
                nSubCategoryID = Core.GetSelectedValueInt(comboSubCategory);
                nActDispID     = Core.GetSelectedValueInt(comboActDisp);


                SqlCommand             oCmd    = DBase.GetCommand(Config.DbCreateFirstGameProcess);
                SqlParameterCollection oParams = oCmd.Parameters;

                oParams.Add("@Name", txtName.Text);
                oParams.Add("@GameEngineID", nEngineID);
                oParams.Add("@CurrencyTypeID", nCurrencyID);
                oParams.Add("@SubCategoryID", nSubCategoryID);
                oParams.Add("@SettingsXml", xmlString);
                oParams.Add("@ActionDispatcherID", nActDispID);
                oParams.Add("@ActivatedTime", actTime);
                oParams.Add("@ProtectedCode", txtProtCode.Text);
                oParams.Add("@RewardID", txtReward.Text);
                oParams.Add("@Visible", chVisible.Checked ? 1:0);
                oParams.Add("@CreatorUserID", SqlDbType.Int);
                oParams["@CreatorUserID"].Value = 0;
                oParams.Add("@ProtectedMode", Utils.GetInt(ddProtectedM.SelectedValue));
                oParams.Add("@IsHighlighted", Utils.GetInt(ddHighlightedM.SelectedValue));
                oParams.Add("@IsMassWatchingAllowed", Utils.GetInt(ddMassWatchingAllowed.SelectedValue));

                SqlParameter oParam = new SqlParameter("@GameProcessID", SqlDbType.Int);
                oParam.Direction = ParameterDirection.Output;
                oParams.Add(oParam);
                int Return = DBase.ExecuteReturnInt(oCmd);

                if (Return <= 0)
                {
                    if (Return < 0)
                    {
                        lblInfo.Text = "Such game process name already exists. Please try another one.";
                    }
                    else
                    {
                        lblInfo.Text = "Database error occured";
                    }
                    oCom.FillTable(xmlString, "gameengine/properties/property", true, ref table);
                    return;
                }

                int processID = Utils.GetInt(oParams["@GameProcessID"].Value);

                //3. Call InitGameProcess method of Com
                int pID = processID;
                if (!oEngine.InitGameProcess(nEngineID, (int)ApiMsg.enProcessFormTarget.Process, ref pID, xmlString, nActDispID))
                {
                    Log.Write(this, "Init game process error");
                    ShowError("Error occured. Game process wasn't created.");
                    oCom.FillTable(xmlString, "gameengine/properties/property", true, ref table);
                    return;
                }

                //4. Success message
                nGameProcessID         = processID;
                hdnGameProcessID.Value = nGameProcessID.ToString();
                lblInfo.Text           = "Game process was created";
                lblInfo.ForeColor      = Color.Green;
                oCom.FillTable(xmlString, "gameengine/properties/property", false, ref table);
                ShowControls();
            }
            finally
            { oEngine = null; }
        }