public Framework.DataServices.Model.EntityBaseData Load(string currentUser, Framework.DataServices.Model.EntityBaseData entry, out int errorNumber, out string errorDescription) { errorNumber = 0; errorDescription = null; Model.Boloes.JogoUsuario entryData = (Model.Boloes.JogoUsuario)entry; DataTable table = base.ExecuteFill(CommandType.StoredProcedure, base._commandSelect, true, currentUser, base.Parameters.Create("@IDJogo", DbType.String, entryData.IDJogo), base.Parameters.Create("@NomeCampeonato", DbType.String, entryData.Campeonato.Nome), base.Parameters.Create("@UserName", DbType.String, entryData.UserName), base.Parameters.Create("@NomeBolao", DbType.String, entryData.Bolao.Nome), base.Parameters.Create("@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null) ); int rowsFound = Convert.ToInt32(base.ExecutionStatus.Command.Parameters["@ReturnValue"].Value); if (rowsFound == 0) { return(null); } //throw new Exception("There is no item found in database with this ID."); return(ConvertToObject(table.Rows[0])); }
public JogoUsuario(string currentLogin, Model.Boloes.JogoUsuario entry) { _currentLogin = currentLogin; _daoBase = new Dao.Boloes.SQLSupport.JogoUsuario(); base.CopyAposta(entry); }
public bool Update(string currentUser, Framework.DataServices.Model.EntityBaseData entry, out int errorNumber, out string errorDescription) { errorNumber = 0; errorDescription = null; Model.Boloes.JogoUsuario entryData = (Model.Boloes.JogoUsuario)entry; return(Insert(currentUser, entryData, out errorNumber, out errorDescription)); }
public Model.Boloes.JogoUsuario SetValue(Model.Campeonatos.Jogo jogo, Model.Boloes.JogoUsuario Apostas) { Model.Boloes.JogoUsuario entry = new BolaoNet.Model.Boloes.JogoUsuario(); entry.Copy(jogo); entry.ApostaTime1 = Apostas.ApostaTime1; entry.ApostaTime2 = Apostas.ApostaTime2; entry.Time1 = Apostas.Time1; entry.Time2 = Apostas.Time2; return(entry); }
private bool IsEnabledToAposta(Model.Boloes.JogoUsuario jogo, Model.Boloes.Bolao bolao) { //Se o jogo já aconteceu if (jogo.PartidaValida) { return(false); } if (!IsUserInBolao) { return(false); } //Se deve ser feita aposta dos jogos antes do bolão começar if (bolao.ApostasApenasAntes) { //Se o bolão ainda não foi iniciado if (bolao.IsIniciado) { return(false); } else { return(true); } } //Se pode fazer a aposta depois do campeonato começado else { //Carregando a data possível para mudar o valor da aposta DateTime dateAllowed = jogo.DataJogo.AddHours(-bolao.HorasLimiteAposta); //Se ultrapassou a data permitida para a aposta if (DateTime.Compare(DateTime.Now, dateAllowed) > 0) { return(false); } else { return(true); } }//endif campeonato campeonato começado //return false; }
private Model.Boloes.JogoUsuario GetJogoByLabel(string label, IList <Model.Boloes.JogoUsuario> list) { for (int c = 0; c < list.Count; c++) { //Se encontrou o titulo do jogo if (string.Compare(list[c].JogoLabel, label, true) == 0) { Model.Boloes.JogoUsuario jogoResult = list[c]; list.RemoveAt(c); return(jogoResult); } //ednif titulo } //end for jogo return(new Model.Boloes.JogoUsuario()); }
public void CopyAposta(Model.Boloes.JogoUsuario jogoUsuario) { base.Copy(jogoUsuario); this._apostaPontos = jogoUsuario._apostaPontos; this._apostaTime1 = jogoUsuario._apostaTime1; this._apostaTime2 = jogoUsuario._apostaTime2; this._automatico = jogoUsuario._automatico; this._bolao = jogoUsuario._bolao; this._dataAposta = jogoUsuario._dataAposta; this._userName = jogoUsuario._userName; this._valido = jogoUsuario._valido; this._timeResult1 = jogoUsuario._timeResult1; this._timeResult2 = jogoUsuario._timeResult2; this._ganhador = jogoUsuario._ganhador; }
public List <Model.Boloes.JogoUsuario> ConvertToList(DataTable table) { List <Model.Boloes.JogoUsuario> list = new List <Model.Boloes.JogoUsuario>(); foreach (DataRow row in table.Rows) { Model.Boloes.JogoUsuario dataObject = ConvertToObject(row); if (dataObject != null) { list.Add(dataObject); } } return(list); }
public bool Delete(string currentUser, Framework.DataServices.Model.EntityBaseData entry, out int errorNumber, out string errorDescription) { errorNumber = 0; errorDescription = null; Model.Boloes.JogoUsuario entryData = (Model.Boloes.JogoUsuario)entry; base.ExecuteNonQuery(CommandType.StoredProcedure, base._commandDelete, true, currentUser, base.Parameters.Create("@IDJogo", DbType.String, entryData.IDJogo), base.Parameters.Create("@NomeCampeonato", DbType.String, entryData.Campeonato.Nome), base.Parameters.Create("@UserName", DbType.String, entryData.UserName), base.Parameters.Create("@NomeBolao", DbType.String, entryData.Bolao.Nome), base.Parameters.Create("@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null) ); return(Convert.ToInt32(base.ExecutionStatus.Command.Parameters["@ReturnValue"].Value) >= 1 ? true : false); }
public bool Load() { int errorNumber = 0; string errorDescription = null; Framework.DataServices.Model.EntityBaseData result = _daoBase.Load( _currentLogin, this, out errorNumber, out errorDescription); if (errorNumber != 0 || !string.IsNullOrEmpty(errorDescription)) { return(false); } Model.Boloes.JogoUsuario model = (Model.Boloes.JogoUsuario)result; this.Copy(model); return(errorNumber == 0 ? true : false); }
protected void grdJogosUsuarios_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) { return; } Model.Boloes.JogoUsuario jogoUsuario = (Model.Boloes.JogoUsuario)e.Row.DataItem; string time1 = e.Row.Cells[GridPosTime1].Text; string time2 = e.Row.Cells[GridPosTime2].Text; if (!string.IsNullOrEmpty(time1) && !string.IsNullOrEmpty(time2)) { int value1 = int.Parse(time1); int value2 = int.Parse(time2); if (value1 == value2) { //e.Row.Cells[GridPosTime1].BackColor = System.Drawing.Color.Cyan; //e.Row.Cells[GridPosTime2].BackColor = System.Drawing.Color.Cyan; e.Row.Cells[GridPosTime1].Font.Bold = true; e.Row.Cells[GridPosTime2].Font.Bold = true; } else if (value1 > value2) { e.Row.Cells[GridPosTime1].BackColor = System.Drawing.Color.LightCyan; e.Row.Cells[GridPosTime1].Font.Bold = true; } else { e.Row.Cells[GridPosTime2].BackColor = System.Drawing.Color.LightCyan; e.Row.Cells[GridPosTime2].Font.Bold = true; } } SetColumnColor(e.Row.Cells[GridPosPontos], jogoUsuario.Pontos, Pontuacoes); }
public VerifyJogoUsuario(Model.Campeonatos.Jogo jogo, Model.Boloes.JogoUsuario jogoUsuario) { _jogo = jogo; _jogoUsuario = jogoUsuario; }
protected void grdJogos_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) { return; } Label lblGolsTime1 = (Label)e.Row.FindControl("lblGolsTime1"); Label lblGolsTime2 = (Label)e.Row.FindControl("lblGolsTime2"); //Verificando o tipo de lista que está sendo mostrado switch (ModeList) { case Mode.All: case Mode.JogosBolao: Model.Campeonatos.Jogo jogo = (Model.Campeonatos.Jogo)e.Row.DataItem; RadioButton rdoTime1Jogo = (RadioButton)e.Row.FindControl("rdoTime1"); RadioButton rdoTime2Jogo = (RadioButton)e.Row.FindControl("rdoTime2"); rdoTime1Jogo.Visible = false; rdoTime2Jogo.Visible = false; if (!jogo.PartidaValida) { lblGolsTime1.Text = "-"; lblGolsTime2.Text = "-"; } else { e.Row.Cells[GridPosSimulacao].Visible = false; } break; case Mode.Apostas: Model.Boloes.JogoUsuario jogoUsuario = (Model.Boloes.JogoUsuario)e.Row.DataItem; TextBox txtAposta1 = (TextBox)e.Row.FindControl("txtAposta1"); TextBox txtAposta2 = (TextBox)e.Row.FindControl("txtAposta2"); Label lblID = (Label)e.Row.FindControl("lblID"); Label lblAposta1 = (Label)e.Row.FindControl("lblAposta1"); Label lblAposta2 = (Label)e.Row.FindControl("lblAposta2"); Label lblPontos = (Label)e.Row.FindControl("lblPontos"); Label lblDataAposta = (Label)e.Row.FindControl("lblDataAposta"); CheckBox chkApostaAuto = (CheckBox)e.Row.FindControl("chkApostaAuto"); Label lblGrupo = (Label)e.Row.FindControl("lblGrupo"); RadioButton rdoTime1 = (RadioButton)e.Row.FindControl("rdoTime1"); RadioButton rdoTime2 = (RadioButton)e.Row.FindControl("rdoTime2"); rdoTime1.Style.Add("visibility", "hidden"); rdoTime2.Style.Add("visibility", "hidden"); rdoTime1.Style.Add("display", "inline"); rdoTime2.Style.Add("display", "inline"); txtAposta1.Attributes.Add("onChange", "JavaScript:onChangeText('" + txtAposta1.ClientID + "','" + txtAposta2.ClientID + "','" + rdoTime1.ClientID + "','" + rdoTime2.ClientID + "','" + lblGrupo.ClientID + "')"); txtAposta2.Attributes.Add("onChange", "JavaScript:onChangeText('" + txtAposta1.ClientID + "','" + txtAposta2.ClientID + "','" + rdoTime1.ClientID + "','" + rdoTime2.ClientID + "','" + lblGrupo.ClientID + "')"); chkApostaAuto.Checked = jogoUsuario.Automatico; //Verificando se é jogo de eliminatórias if (jogoUsuario.Grupo == null || string.IsNullOrEmpty(jogoUsuario.Grupo.Nome.Trim())) { //Se a aposta do usuário é de empate if (jogoUsuario.ApostaTime1 == jogoUsuario.ApostaTime2) { rdoTime1.Style["visibility"] = "visible"; rdoTime2.Style["visibility"] = "visible"; if (jogoUsuario.Ganhador == 1) { rdoTime1.Checked = true; } else if (jogoUsuario.Ganhador == 2) { rdoTime2.Checked = true; } } //endif aposta empate } //endif eliminatórias if (!IsEnabledToAposta(jogoUsuario, BolaoUserBasePage.CurrentBolao)) { lblAposta1.Visible = true; lblAposta2.Visible = true; txtAposta1.Visible = false; txtAposta2.Visible = false; rdoTime1.Enabled = false; rdoTime2.Enabled = false; //Se o jogo já aconteceu if (jogoUsuario.PartidaValida) { rdoTime1.Enabled = false; rdoTime2.Enabled = false; lblPontos.Text = jogoUsuario.ApostaPontos.Pontos.ToString(); SetColumnColor(e.Row.Cells[GridPosPontos], jogoUsuario.Pontos, Pontuacoes); } //Se o jogo não aconteceu ainda else { lblPontos.Text = "-"; } //endif jogo aconteceu //Se não houve apostas if (jogoUsuario.DataAposta == DateTime.MinValue) { lblAposta1.Text = "-"; lblAposta2.Text = "-"; } else { lblAposta1.Text = jogoUsuario.ApostaTime1.ToString(); lblAposta2.Text = jogoUsuario.ApostaTime2.ToString(); } //endif houve apostas } else { txtAposta1.Text = jogoUsuario.ApostaTime1.ToString(); txtAposta2.Text = jogoUsuario.ApostaTime2.ToString(); lblAposta1.Visible = false; lblAposta2.Visible = false; txtAposta1.Visible = true; txtAposta2.Visible = true; lblGolsTime1.Text = "-"; lblGolsTime2.Text = "-"; lblPontos.Text = "-"; } //Alteração para validar a aposta if (jogoUsuario.DataAposta == DateTime.MinValue) { lblDataAposta.Text = "-"; txtAposta1.Text = ""; txtAposta2.Text = ""; } else { lblDataAposta.Text = jogoUsuario.DataAposta.ToString("dd/MM/yy HH:mm:ss"); } break; case Mode.JogoByTime: break; case Mode.ApostasReadOnly: Model.Boloes.JogoUsuario jogoUsuarioReadOnly = (Model.Boloes.JogoUsuario)e.Row.DataItem; TextBox txtAposta1ReadOnly = (TextBox)e.Row.FindControl("txtAposta1"); TextBox txtAposta2ReadOnly = (TextBox)e.Row.FindControl("txtAposta2"); Label lblAposta1ReadOnly = (Label)e.Row.FindControl("lblAposta1"); Label lblAposta2ReadOnly = (Label)e.Row.FindControl("lblAposta2"); Label lblPontosReadOnly = (Label)e.Row.FindControl("lblPontos"); Label lblDataApostaReadOnly = (Label)e.Row.FindControl("lblDataAposta"); CheckBox chkApostaAutoReadOnly = (CheckBox)e.Row.FindControl("chkApostaAuto"); RadioButton rdoTime_1 = (RadioButton)e.Row.FindControl("rdoTime1"); RadioButton rdoTime_2 = (RadioButton)e.Row.FindControl("rdoTime2"); rdoTime_1.Enabled = false; rdoTime_2.Enabled = false; if (jogoUsuarioReadOnly.Grupo == null || string.IsNullOrEmpty(jogoUsuarioReadOnly.Grupo.Nome.Trim())) { if (jogoUsuarioReadOnly.ApostaTime1 == jogoUsuarioReadOnly.ApostaTime2) { rdoTime_1.Style.Add("visibility", "visible"); rdoTime_2.Style.Add("visibility", "visible"); if (jogoUsuarioReadOnly.Ganhador == 1) { rdoTime_1.Checked = true; } else if (jogoUsuarioReadOnly.Ganhador == 2) { rdoTime_2.Checked = true; } } else { rdoTime_1.Style.Add("visibility", "hidden"); rdoTime_2.Style.Add("visibility", "hidden"); } } else { rdoTime_1.Style.Add("visibility", "hidden"); rdoTime_2.Style.Add("visibility", "hidden"); } if (jogoUsuarioReadOnly.DataAposta == DateTime.MinValue) { lblDataApostaReadOnly.Text = "-"; } else { lblDataApostaReadOnly.Text = jogoUsuarioReadOnly.DataAposta.ToString("dd/MM/yy HH:mm:ss"); } chkApostaAutoReadOnly.Checked = jogoUsuarioReadOnly.Automatico; if (jogoUsuarioReadOnly.PartidaValida) { lblAposta1ReadOnly.Text = jogoUsuarioReadOnly.ApostaTime1.ToString(); lblAposta2ReadOnly.Text = jogoUsuarioReadOnly.ApostaTime2.ToString(); lblAposta1ReadOnly.Visible = true; lblAposta2ReadOnly.Visible = true; txtAposta1ReadOnly.Visible = false; txtAposta2ReadOnly.Visible = false; lblPontosReadOnly.Text = jogoUsuarioReadOnly.ApostaPontos.Pontos.ToString(); SetColumnColor(e.Row.Cells[GridPosPontos], jogoUsuarioReadOnly.Pontos, Pontuacoes); } else { lblAposta1ReadOnly.Text = jogoUsuarioReadOnly.ApostaTime1.ToString(); lblAposta2ReadOnly.Text = jogoUsuarioReadOnly.ApostaTime2.ToString(); lblAposta1ReadOnly.Visible = true; lblAposta2ReadOnly.Visible = true; txtAposta1ReadOnly.Visible = false; txtAposta2ReadOnly.Visible = false; lblGolsTime1.Text = "-"; lblGolsTime2.Text = "-"; lblPontosReadOnly.Text = "-"; } break; }//end switch tipo de list }
public List <Model.Boloes.JogoUsuario> LoadApostasChanged() { List <Framework.DataServices.Model.EntityBaseData> list = (List <Framework.DataServices.Model.EntityBaseData>)ViewState["JogosSourceFilter"]; //IList<Framework.DataServices.Model.EntityBaseData> list = // LoadData(false, this.ctlFilterJogo.Rodada, // this.ctlFilterJogo.DataInicial, // this.ctlFilterJogo.DataFinal, // this.ctlFilterJogo.Time, // this.ctlFilterJogo.Fase, // this.ctlFilterJogo.Grupo); List <Model.Boloes.JogoUsuario> listChanged = new List <BolaoNet.Model.Boloes.JogoUsuario>(); //Para cada item na tela for (int c = 0; c < list.Count; c++) { Model.Boloes.JogoUsuario jogo = (Model.Boloes.JogoUsuario)list[c]; //Buscando os dados da tela TextBox txtAposta1 = (TextBox)this.grdJogos.Rows[c].FindControl("txtAposta1"); TextBox txtAposta2 = (TextBox)this.grdJogos.Rows[c].FindControl("txtAposta2"); TextBox txtAposta1Debug = (TextBox)this.grdJogos.Rows[c].Cells[11].Controls[3]; TextBox txtAposta2Debug = (TextBox)this.grdJogos.Rows[c].Cells[13].Controls[3]; Label lblIDDebug = (Label)this.grdJogos.Rows[c].Cells[0].Controls[1]; CheckBox chkValido = (CheckBox)this.grdJogos.Rows[c].FindControl("chkValido"); Label lblID = (Label)this.grdJogos.Rows[c].FindControl("lblID"); RadioButton rdoTime1 = (RadioButton)this.grdJogos.Rows[c].FindControl("rdoTime1"); RadioButton rdoTime2 = (RadioButton)this.grdJogos.Rows[c].FindControl("rdoTime2"); if (txtAposta1.Text != txtAposta1Debug.Text && txtAposta2.Text != txtAposta2Debug.Text && lblID.Text != jogo.IDJogo.ToString()) { } //Se ainda não foi validado o jogo if (!chkValido.Checked) { //Se os items de apostas estão visíveis if (txtAposta1.Visible && txtAposta2.Visible && txtAposta1.Text.Length > 0 && txtAposta2.Text.Length > 0) { try { //Convertendo os dados int aposta1 = int.Parse(txtAposta1.Text); int aposta2 = int.Parse(txtAposta2.Text); int ganhador = 0; if (aposta1 == aposta2 && string.IsNullOrEmpty(jogo.Grupo.Nome.Trim())) { if (rdoTime1.Checked) { ganhador = 1; } else if (rdoTime2.Checked) { ganhador = 2; } } //Se a aposta do jogo é diferente if (jogo.ApostaTime1 != aposta1 || jogo.ApostaTime2 != aposta2 || jogo.DataAposta == DateTime.MinValue || ganhador != jogo.Ganhador) { jogo.ApostaTime1 = aposta1; jogo.ApostaTime2 = aposta2; jogo.Ganhador = ganhador; listChanged.Add(jogo); } else { if (jogo.ApostaTime1 != aposta1 && jogo.ApostaTime2 != aposta2) { } }//endif aposta diferente } catch (Exception ex) { } } } //endif jogo ainda não validado } //end for items return(listChanged); }
private PdfPTable CreateTimeEliminatoriaFormat(bool showOnlyPartidaValida, bool fim, bool showTitle, string imagePath, bool timeCasa, Model.Boloes.JogoUsuario jogo) { float[] relative = null; if (showTitle) { relative = new float[] { 20, 20, 40, 20 }; if (fim) { relative = new float[] { 20, 20, 40, 20, 10, 20 } } ; } else { relative = new float[] { 20, 60, 20 }; if (fim) { relative = new float[] { 20, 60, 20, 10, 20 } } ; } PdfPTable time = new PdfPTable(relative); time.DefaultCell.Padding = 0; if (showTitle) { PdfPCell cellDescription = new PdfPCell(new Phrase((timeCasa ? jogo.DescricaoTime1 : jogo.DescricaoTime2), new Font(Font.HELVETICA, 5f, Font.BOLD, Color.BLACK))); cellDescription.HorizontalAlignment = Element.ALIGN_CENTER; cellDescription.VerticalAlignment = Element.ALIGN_MIDDLE; cellDescription.BorderWidth = 0; time.AddCell(cellDescription); } //Criando a imagem do time PdfPCell cellImageTime = new PdfPCell(); string timeFileImage = System.IO.Path.Combine(imagePath, (timeCasa ? jogo.Time1.Nome : jogo.Time2.Nome) + ".gif"); if (System.IO.File.Exists(timeFileImage)) { Image imgTime = Image.GetInstance(timeFileImage); cellImageTime.AddElement(imgTime); } cellImageTime.BorderWidth = 0; //Criando a descrição do time de fora string strTimeCasa = timeCasa ? jogo.Time1.Nome : jogo.Time2.Nome; if (string.IsNullOrEmpty(strTimeCasa)) { strTimeCasa = " ? "; } //PdfPCell cellTime = new PdfPCell(new Phrase((timeCasa ? jogo.Time1.Nome : jogo.Time2.Nome), PdfPCell cellTime = new PdfPCell(new Phrase((strTimeCasa), new Font(Font.HELVETICA, 4.5f, Font.NORMAL, Color.BLACK))); cellTime.HorizontalAlignment = Element.ALIGN_CENTER; cellTime.VerticalAlignment = Element.ALIGN_MIDDLE; cellTime.BorderWidth = 0; //Criando o resultado do time PdfPCell cellResult = new PdfPCell(); if ((showOnlyPartidaValida && jogo.PartidaValida) || !showOnlyPartidaValida) { cellResult.AddElement(new Phrase((timeCasa ? jogo.ApostaTime1.ToString() : jogo.ApostaTime2.ToString()), //cellResult = new PdfPCell(new Phrase((timeCasa ? jogo.ApostaTime1.ToString() : jogo.ApostaTime2.ToString()), new Font(Font.HELVETICA, 6f, Font.BOLD, Color.BLACK))); } else { cellResult.AddElement(new Phrase((""), //cellResult = new PdfPCell(new Phrase((timeCasa ? jogo.ApostaTime1.ToString() : jogo.ApostaTime2.ToString()), new Font(Font.HELVETICA, 6f, Font.BOLD, Color.BLACK))); } cellResult.HorizontalAlignment = Element.ALIGN_CENTER; cellResult.VerticalAlignment = Element.ALIGN_MIDDLE; cellResult.BorderWidth = 0; cellResult.BackgroundColor = Color.YELLOW; time.AddCell(cellImageTime); time.AddCell(cellTime); time.AddCell(cellResult); if (fim) { PdfPCell cellGols = new PdfPCell(new Phrase((timeCasa ? jogo.GolsTime1.ToString() : jogo.GolsTime2.ToString()), new Font(Font.HELVETICA, 5f, Font.NORMAL, Color.BLACK))); cellGols.HorizontalAlignment = Element.ALIGN_CENTER; cellGols.VerticalAlignment = Element.ALIGN_MIDDLE; cellGols.BorderWidth = 0; time.AddCell(cellGols); PdfPCell cellPontos = new PdfPCell(new Phrase((timeCasa ? jogo.Pontos.ToString() : ""), new Font(Font.HELVETICA, 8f, Font.BOLD, Color.BLACK))); cellPontos.HorizontalAlignment = Element.ALIGN_CENTER; cellPontos.VerticalAlignment = Element.ALIGN_MIDDLE; cellPontos.BorderWidth = 0; if (jogo.PartidaValida) { if (jogo.Pontos == 0 && timeCasa) { cellPontos.BackgroundColor = Color.RED; } } else if (timeCasa) { cellPontos.BackgroundColor = Color.YELLOW; } time.AddCell(cellPontos); } return(time); }
private PdfPTable CreateJogoInEliminatoriaFormat(bool showOnlyPartidaValida, bool fim, Color backColor, bool showTitle, string imagePath, Model.Boloes.JogoUsuario jogo) { PdfPTable jogoTable = new PdfPTable(1); jogoTable.DefaultCell.Padding = 0; //jogoTable.DefaultCell.BorderWidth = 0; jogoTable.DefaultCell.BackgroundColor = backColor; jogoTable.AddCell(CreateTimeEliminatoriaFormat(showOnlyPartidaValida, fim, showTitle, imagePath, true, jogo)); jogoTable.AddCell(CreateTimeEliminatoriaFormat(showOnlyPartidaValida, fim, showTitle, imagePath, false, jogo)); string dateDescription = jogo.DataJogo.ToString("dd/MM - HH:mm") + " - " + jogo.Estadio.Nome; //Adicionando o local do jogo PdfPCell dateJogo = new PdfPCell(new Phrase(dateDescription, new Font(Font.HELVETICA, 5f, Font.NORMAL, Color.BLACK))); dateJogo.Padding = 0; dateJogo.BorderWidth = 0; dateJogo.HorizontalAlignment = Element.ALIGN_CENTER; dateJogo.VerticalAlignment = Element.ALIGN_MIDDLE; dateJogo.BackgroundColor = backColor; dateJogo.PaddingBottom = 2; //Adicionando o local do jogo na tabela principal jogoTable.AddCell(dateJogo); return(jogoTable); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Business.Campeonatos.Support.Jogo jogo = null; //Se estiver passando o id do jogo if (Request.QueryString["IDJogo"] != null) { long idJogo = Convert.ToInt64(Request.QueryString["IDJogo"].ToString()); jogo = new BolaoNet.Business.Campeonatos.Support.Jogo(base.UserName); jogo.Campeonato = CurrentCampeonato; jogo.IDJogo = idJogo; jogo.Load(); this.ctlJogoDetail.Jogo = jogo; if (jogo.PartidaValida) { Model.Boloes.JogoUsuario social = new Business.Boloes.Support.JogoUsuario(base.UserName).LoadSocialNetwork(base.BaseCurrentBolao, base.UserName, jogo); if (social.DataFacebook == DateTime.MinValue) { this.ctlMenuTools.FaceVisible = true; } } }//endif passando id do jogo //Adicionando os dados do facebook if (Request["code"] != null) { Model.Boloes.JogoUsuario jogoUsuario = new Model.Boloes.JogoUsuario(); jogoUsuario.Copy(jogo); jogoUsuario.Bolao = base.BaseCurrentBolao; jogoUsuario.UserName = base.UserName; IList <Framework.DataServices.Model.EntityBaseData> res = new Business.Boloes.Support.JogoUsuario(base.UserName, jogoUsuario).SelectAll("JogosUsuarios.IdJogo='" + jogo.IDJogo + "' and JogosUsuarios.UserName='******'"); jogoUsuario = (Model.Boloes.JogoUsuario)res[0]; string message = ""; string caption = "Resultado: " + jogo.Time1.Nome + " " + jogo.GolsTime1.ToString() + " x " + jogo.GolsTime2.ToString() + " " + jogo.Time2.Nome; string description = "Minha Aposta: " + jogo.Time1.Nome + " " + jogoUsuario.ApostaTime1.ToString() + " x " + jogoUsuario.ApostaTime2.ToString() + " " + jogo.Time2.Nome + " - Pontos: " + jogoUsuario.Pontos; string imagePontos = ""; message = ConfigurationManager.AppSettings["Facebook_Pontos_" + jogoUsuario.Pontos.ToString()]; imagePontos = ConfigurationManager.AppSettings["Facebook_images"] + "pontos" + jogoUsuario.Pontos + ".gif"; if (jogoUsuario.Pontos == 10 && (string.Compare(jogo.Time1.Nome, "Brasil", true) == 0 || string.Compare(jogo.Time2.Nome, "Brasil", true) == 0)) { message = ConfigurationManager.AppSettings["Facebook_Pontos_10_Brasil"]; imagePontos = ConfigurationManager.AppSettings["Facebook_images"] + "pontos" + jogoUsuario.Pontos + "_Brasil.gif"; } if (string.IsNullOrEmpty(message)) { switch (jogoUsuario.Pontos) { case 0: message = "Não tive sorte neste jogo, que zebra, não acertei nada!"; break; case 1: message = "Consegui acertar pelo menos o gol de uma das duas seleções."; break; case 2: message = "Que chance eu perdi...pelo menos acertei o gol de uma das duas seleções"; break; case 3: message = "Acertei o ganhador do jogo!"; break; case 4: message = "Quase, acertei a vitória de uma das seleções e o gol de uma delas!"; break; case 5: message = "Resultado difícil, mas acertei o empate!"; break; case 6: message = "Já que é jogo do Brasil, consegui acertar a vitória da seleção."; break; case 8: message = "Quase em cheio! Acertei a vitória da seleção e quantidade de gols de uma delas! Mas como é jogo do Brasil, perdi uma chance boa!"; break; case 10: if (string.Compare(jogo.Time1.Nome, "Brasil") == 0 || string.Compare(jogo.Time2.Nome, "Brasil") == 0) { message = "Jogo do Brasil é sempre difícil, ainda mais quando ocorre empate."; } else { message = "Na mosca! Muito fácil ... rs"; } break; case 20: message = "No jogo do Brasil é melhor ainda, consegui acertar em cheio!!!"; break; } } Dictionary <string, string> tokens = new Dictionary <string, string>(); string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", _applicationKey, Request.Url.AbsoluteUri, _scope, Request["code"].ToString(), _applicationSecret); HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(response.GetResponseStream()); string vals = reader.ReadToEnd(); foreach (string token in vals.Split('&')) { //meh.aspx?token1=steve&token2=jake&... tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1)); } } string access_token = tokens["access_token"]; var client = new FacebookClient(access_token); string originalQuery = "/Boloes/ApostasJogos.aspx?IdJogo=" + Request.QueryString["IDJogo"].ToString(); var postParams = new { name = "BolãoNET", caption = caption, description = description, message = message, link = Request.Url.Host + originalQuery, picture = imagePontos, }; object resultFacebook = client.Post("/me/feed", postParams); bool result = new Business.Boloes.Support.JogoUsuario(base.UserName).UpdateFacebook(base.BaseCurrentBolao, base.UserName, jogo); Response.Redirect("~" + originalQuery); } //endif code (Facebook) } //end if IsPostBack BindGrid(); }
public void GenerateApostasUsuariosFim(Stream outputStream, Document document, string imagePath, Model.Campeonatos.Campeonato campeonato, Model.Boloes.Bolao bolao, List <Framework.Security.Model.UserData> users) { PdfWriter writer = PdfWriter.GetInstance(document, outputStream); // we Add a Footer that will show up on PAGE 1 HeaderFooter footer = new HeaderFooter(new Phrase("Página: "), true); footer.Border = Rectangle.NO_BORDER; document.Footer = footer; // we Add a Header that will show up on PAGE 2 HeaderFooter header = new HeaderFooter(new Phrase("Bolão: " + bolao.Nome), false); document.Header = header; document.Open(); document.NewPage(); _businessBolao = new Business.Boloes.Support.Bolao(_currentLogin, bolao.Nome); IList <Model.Boloes.BolaoMembros> classificacao = _businessBolao.LoadClassificacao(0); IList <Framework.DataServices.Model.EntityBaseData> listPosicoes = _businessBolao.SelectPremios(); PdfPTable titulo = new PdfPTable(1); PdfPCell cell = new PdfPCell(new Phrase("Classificação", new Font(Font.HELVETICA, 12f, Font.BOLD, Color.BLACK))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_CENTER; cell.BackgroundColor = Color.YELLOW; titulo.AddCell(cell); titulo.TotalWidth = 250; titulo.WriteSelectedRows(0, -1, 175, 790, writer.DirectContent); int max = 55; PdfPTable class1 = base.CreateClassificacao(writer, imagePath, 0, max, classificacao, listPosicoes); if (classificacao.Count >= max) { class1.WriteSelectedRows(0, -1, 30, 765, writer.DirectContent); PdfPTable class2 = base.CreateClassificacao(writer, imagePath, max, max * 2, classificacao, listPosicoes); class2.WriteSelectedRows(0, -1, 315, 765, writer.DirectContent); } else { class1.TotalWidth = 535; class1.WriteSelectedRows(0, -1, 30, 765, writer.DirectContent); } PdfPTable legendas = new PdfPTable(1); cell = new PdfPCell(new Phrase( "Pontos = Total de Pontos, E = Total de Empates, VDE = Total de Vitórias/Derrotas/Empates, GT1 = Total de Gols do time 1, GT2 = Total de Gols do time 2, C = Acertos em cheio, EX = Pontuação extra." , new Font(Font.HELVETICA, 7f, Font.NORMAL, Color.BLACK))); cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_TOP; legendas.AddCell(cell); legendas.TotalWidth = 550; legendas.WriteSelectedRows(0, -1, 23, 70, writer.DirectContent); document.NewPage(); IList <Framework.DataServices.Model.EntityBaseData> listExtra1 = new List <Framework.DataServices.Model.EntityBaseData>();//_businessApostaExtra.SelectByUser(bolao, user.UserName, null); IList <Framework.DataServices.Model.EntityBaseData> listAux = _businessJogo.SelectAllByPeriod( campeonato, 0, DateTime.MinValue, DateTime.MaxValue, null, null, null, null, null); IList <Framework.DataServices.Model.EntityBaseData> listJogos = new List <Framework.DataServices.Model.EntityBaseData>(); foreach (Model.Campeonatos.Jogo jogo in listAux) { Model.Boloes.JogoUsuario jogoUsr = new Model.Boloes.JogoUsuario(); jogoUsr.ApostaTime1 = jogo.GolsTime1; jogoUsr.ApostaTime2 = jogo.GolsTime2; jogoUsr.Campeonato = jogo.Campeonato; jogoUsr.DataJogo = jogo.DataJogo; jogoUsr.DescricaoTime1 = jogo.DescricaoTime1; jogoUsr.DescricaoTime2 = jogo.DescricaoTime2; jogoUsr.Estadio = jogo.Estadio; jogoUsr.Fase = jogo.Fase; jogoUsr.GolsTime1 = jogo.GolsTime1; jogoUsr.GolsTime2 = jogo.GolsTime2; jogoUsr.Grupo = jogo.Grupo; jogoUsr.IDJogo = jogo.IDJogo; jogoUsr.JogoLabel = jogo.JogoLabel; jogoUsr.PenaltisTime1 = jogo.PenaltisTime1; jogoUsr.PenaltisTime2 = jogo.PenaltisTime2; jogoUsr.Rodada = jogo.Rodada; jogoUsr.Time1 = jogo.Time1; jogoUsr.Time2 = jogo.Time2; jogoUsr.Titulo = jogo.Titulo; listJogos.Add(jogoUsr); //Campão e vice if (jogo.PendenteIdTime1 > 0 && jogo.PendenteIdTime1 > 0 && jogo.PendenteTime1Ganhador && jogo.PendenteTime2Ganhador && jogo.PartidaValida && string.Compare(jogo.Fase.Nome, "Final", true) == 0) { string timeGanhador; string timePerdedor; if (jogo.GolsTime1 >= jogo.GolsTime2) { timeGanhador = jogo.Time1.Nome; timePerdedor = jogo.Time2.Nome; } else { timeGanhador = jogo.Time2.Nome; timePerdedor = jogo.Time1.Nome; } Model.Boloes.ApostaExtraUsuario extra = new Model.Boloes.ApostaExtraUsuario(1, jogoUsr.Bolao.Nome, ""); extra.NomeTime = timeGanhador; extra.Posicao = 1; extra.Titulo = "Campeão"; listExtra1.Add(extra); extra = new Model.Boloes.ApostaExtraUsuario(2, jogoUsr.Bolao.Nome, ""); extra.NomeTime = timePerdedor; extra.Posicao = 2; extra.Titulo = "Vice Campeão"; listExtra1.Add(extra); } //Terceiro e quarto if (jogo.PendenteIdTime1 > 0 && jogo.PendenteIdTime1 > 0 && !jogo.PendenteTime1Ganhador && !jogo.PendenteTime2Ganhador && jogo.PartidaValida && string.Compare(jogo.Fase.Nome, "Final", true) == 0) { string timeGanhador; string timePerdedor; if (jogo.GolsTime1 >= jogo.GolsTime2) { timeGanhador = jogo.Time1.Nome; timePerdedor = jogo.Time2.Nome; } else { timeGanhador = jogo.Time2.Nome; timePerdedor = jogo.Time1.Nome; } Model.Boloes.ApostaExtraUsuario extra = new Model.Boloes.ApostaExtraUsuario(3, jogoUsr.Bolao.Nome, ""); extra.NomeTime = timeGanhador; extra.Posicao = 3; extra.Titulo = "Terceiro"; listExtra1.Add(extra); extra = new Model.Boloes.ApostaExtraUsuario(4, jogoUsr.Bolao.Nome, ""); extra.NomeTime = timePerdedor; extra.Posicao = 4; extra.Titulo = "Quarto"; listExtra1.Add(extra); } } //Criando a página com a lista dos dados base.CreatePage(false, false, 0, 0, writer, imagePath, null, listJogos, listExtra1); foreach (Framework.Security.Model.UserData user in users) { document.NewPage(); //Buscando as apostas auxiliares do usuário IList <Framework.DataServices.Model.EntityBaseData> listExtra = _businessApostaExtra.SelectByUser(bolao, user.UserName, null); //Buscando as apostas dos jogos do usuário IList <Framework.DataServices.Model.EntityBaseData> list = _businessJogoUsuario.SelectAllByPeriod( bolao, user.UserName, 0, DateTime.MinValue, DateTime.MinValue, null, null, null, null); int posicao = 0; int pontos = 0; for (int c = 0; c < classificacao.Count; c++) { if (string.Compare(classificacao[c].UserName, user.UserName, true) == 0) { posicao = classificacao[c].Posicao; pontos = classificacao[c].TotalPontos; break; } } //Criando a página com a lista dos dados base.CreatePage(false, true, posicao, pontos, writer, imagePath, user, list, listExtra); } document.Close(); }
public void CreateJogos(Stream outputStream, string imagePath, Model.Campeonatos.Campeonato campeonato) { Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, outputStream); // we Add a Footer that will show up on PAGE 1 HeaderFooter footer = new HeaderFooter(new Phrase("Página: "), true); footer.Border = Rectangle.NO_BORDER; document.Footer = footer; // we Add a Header that will show up on PAGE 2 HeaderFooter header = new HeaderFooter(new Phrase(campeonato.Nome), false); document.Header = header; document.Open(); document.NewPage(); //Buscando as apostas auxiliares do usuário IList <Framework.DataServices.Model.EntityBaseData> listExtra = new List <Framework.DataServices.Model.EntityBaseData>();//_businessApostaExtra.SelectByUser(bolao, user.UserName, null); IList <Framework.DataServices.Model.EntityBaseData> listAux = _businessJogo.SelectAllByPeriod( campeonato, 0, DateTime.MinValue, DateTime.MaxValue, null, null, null, null, null); IList <Framework.DataServices.Model.EntityBaseData> list = new List <Framework.DataServices.Model.EntityBaseData>(); foreach (Model.Campeonatos.Jogo jogo in listAux) { Model.Boloes.JogoUsuario jogoUsr = new Model.Boloes.JogoUsuario(); jogoUsr.ApostaTime1 = jogo.GolsTime1; jogoUsr.ApostaTime2 = jogo.GolsTime2; jogoUsr.Campeonato = jogo.Campeonato; jogoUsr.DataJogo = jogo.DataJogo; jogoUsr.DescricaoTime1 = jogo.DescricaoTime1; jogoUsr.DescricaoTime2 = jogo.DescricaoTime2; jogoUsr.Estadio = jogo.Estadio; jogoUsr.Fase = jogo.Fase; jogoUsr.GolsTime1 = jogo.GolsTime1; jogoUsr.GolsTime2 = jogo.GolsTime2; jogoUsr.Grupo = jogo.Grupo; jogoUsr.IDJogo = jogo.IDJogo; jogoUsr.JogoLabel = jogo.JogoLabel; jogoUsr.PenaltisTime1 = jogo.PenaltisTime1; jogoUsr.PenaltisTime2 = jogo.PenaltisTime2; jogoUsr.Rodada = jogo.Rodada; jogoUsr.Time1 = jogo.Time1; jogoUsr.Time2 = jogo.Time2; jogoUsr.Titulo = jogo.Titulo; jogoUsr.PartidaValida = jogo.PartidaValida; jogoUsr.Valido = jogo.PartidaValida; list.Add(jogoUsr); } ////Buscando as apostas dos jogos do usuário //IList<Framework.DataServices.Model.EntityBaseData> list = _businessJogoUsuario.SelectAllByPeriod( // bolao, user.UserName, 0, DateTime.MinValue, DateTime.MinValue, null, null, null, null); //Criando a página com a lista dos dados base.CreatePage(true, false, 0, 0, writer, imagePath, null, list, listExtra); document.Close(); }
private Log CheckJogo(Model.Campeonatos.Jogo jogo, Model.Boloes.JogoUsuario jogoUsuario, out int atual, out int expected) { atual = 0; expected = 0; int value = 1; if (!jogo.PartidaValida) { return(Log.Warning); } if (string.Compare(jogo.Time1.Nome, "Brasil", true) == 0 || string.Compare(jogo.Time2.Nome, "Brasil", true) == 0) { value = 2; } int pontos = 0; //Aposta em cheio if (jogo.GolsTime1 == jogoUsuario.ApostaTime1 && jogo.GolsTime2 == jogoUsuario.ApostaTime2) { pontos = 10; } //Empate else if (jogo.GolsTime1 == jogo.GolsTime2 && jogoUsuario.ApostaTime1 == jogoUsuario.ApostaTime2) { pontos = 5; } //Time 1 Ganhador else if (jogo.GolsTime1 > jogo.GolsTime2 && jogoUsuario.ApostaTime1 > jogoUsuario.ApostaTime2) { pontos = 3; if (jogo.GolsTime1 == jogoUsuario.ApostaTime1) { pontos++; } if (jogo.GolsTime2 == jogoUsuario.ApostaTime2) { pontos++; } } //Time 2 Ganhador else if (jogo.GolsTime1 < jogo.GolsTime2 && jogoUsuario.ApostaTime1 < jogoUsuario.ApostaTime2) { pontos = 3; if (jogo.GolsTime1 == jogoUsuario.ApostaTime1) { pontos++; } if (jogo.GolsTime2 == jogoUsuario.ApostaTime2) { pontos++; } } else { if (jogo.GolsTime1 == jogoUsuario.ApostaTime1) { pontos++; } if (jogo.GolsTime2 == jogoUsuario.ApostaTime2) { pontos++; } } pontos *= value; expected = pontos; atual = jogoUsuario.Pontos; if (jogoUsuario.Pontos != pontos) { return(Log.Error); } return(Log.Info); }
private void ApplyLine(int line, int gols1, int gols2, int desempate, int posTime1, int posTime2, ref IList <BolaoNet.Model.Boloes.BolaoMembros> membros, IList <Framework.DataServices.Model.EntityBaseData> jogosUsuarios, IList <Framework.DataServices.Model.EntityBaseData> apostasExtras, bool somaJogo) { int[] pt = new int[membros.Count]; for (int c = 0; c < membros.Count; c++) { int totalPontos = 0; int pontosExtras = 0; int multiplo = 1; string nomeTime1 = ""; string nomeTime2 = ""; int total = membros[c].TotalPontos; Model.Boloes.JogoUsuario jogo = SearchJogoUsuario(jogosUsuarios, membros[c].UserName); Model.Boloes.ApostaExtraUsuario aposta1 = SearchApostaExtra(apostasExtras, membros[c].UserName, posTime1); Model.Boloes.ApostaExtraUsuario aposta2 = SearchApostaExtra(apostasExtras, membros[c].UserName, posTime2); if (string.Compare(jogo.Time1Classificado.Nome, "Brasil", true) == 0 || string.Compare(jogo.Time2Classificado.Nome, "Brasil", true) == 0) { multiplo = 2; } //Verificando o vencedor válido if (gols1 == gols2) { if (desempate == 1) { nomeTime1 = jogo.Time1Classificado.Nome; nomeTime2 = jogo.Time2Classificado.Nome; } else { nomeTime1 = jogo.Time2Classificado.Nome; nomeTime2 = jogo.Time1Classificado.Nome; } } else if (gols1 > gols2) { nomeTime1 = jogo.Time1Classificado.Nome; nomeTime2 = jogo.Time2Classificado.Nome; } else if (gols1 < gols2) { nomeTime1 = jogo.Time2Classificado.Nome; nomeTime2 = jogo.Time1Classificado.Nome; } //Verificando o vencedor da aposta do usuário if (string.Compare(aposta1.NomeTime, nomeTime1, true) == 0) { pontosExtras += 10; } if (string.Compare(aposta2.NomeTime, nomeTime2, true) == 0) { pontosExtras += 10; } if (jogo.ApostaTime1 == gols1 && jogo.ApostaTime2 == gols2) { totalPontos += 10; } else { if (gols1 == jogo.ApostaTime1 || gols2 == jogo.ApostaTime2) { totalPontos += 1; } if (gols1 > gols2 && jogo.ApostaTime1 > jogo.ApostaTime2) { totalPontos += 3; } else if (gols1 < gols2 && jogo.ApostaTime1 < jogo.ApostaTime2) { totalPontos += 3; } else if (gols1 == gols2 && jogo.ApostaTime1 == jogo.ApostaTime2) { totalPontos += 5; } } if (somaJogo) { total += (totalPontos * multiplo) + pontosExtras; } else { total += pontosExtras; } if (pontosExtras > 0 && !somaJogo) { membros[c].TotalPontos += pontosExtras; } excel.SetNumber(line, PosGols1, gols1); excel.SetNumber(line, PosGols2, gols2); excel.SetNumber(line, PosDesempate, desempate); excel.SetNumber(line, PosStartName + 1 + (c * 4), total); //if (somaJogo) // excel.SetNumber(line, PosStartName + 2 + (c * 4), (totalPontos * multiplo) + pontosExtras); //else // excel.SetNumber(line, PosStartName + 2 + (c * 4), pontosExtras); excel.SetNumber(line, PosStartName + 2 + (c * 4), (totalPontos * multiplo)); excel.SetNumber(line, PosStartName + 3 + (c * 4), pontosExtras); pt[c] = total; } int currentMax; int posMax = -1; int currentPosition = 1; int countPosition = 1; do { posMax = -1; currentMax = 0; currentPosition = countPosition; for (int c = 0; c < pt.Length; c++) { if (pt[c] > currentMax) { currentMax = pt[c]; posMax = c; } } if (posMax != -1) { for (int c = 0; c < pt.Length; c++) { if (currentMax == pt[c]) { excel.SetNumber(line, PosStartName + (c * 4), currentPosition); countPosition++; pt[c] = 0; } } } } while (posMax != -1); }