コード例 #1
0
        public EventEditor(UiMain origin, EventFull @event, bool draft = false)
        {
            this.origin = origin;
            this.draft  = draft;

            InitializeComponent();

            this.Text             = "Edit event";
            this.@event           = @event;
            this.headerLabel.Text = "Edit event information.";
            this.FillInSports();
            this.FillInBoxes();
            this.FillInPhotos();

            if (draft)
            {
                finishButton.Text        = "Create";
                this.finishButton.Click += CreateEvent;

                /*deleteEventButton.Visible = false;
                 * saveDraftButton.Visible = true;*/
                deleteordraftEventButton.Text   = "Save as draft";
                deleteordraftEventButton.Click += SaveDraft;
            }
            else
            {
                finishButton.Text        = "Save";
                this.finishButton.Click += EditEvent;

                /*deleteEventButton.Visible = true;
                 * saveDraftButton.Visible = false;*/
                deleteordraftEventButton.Text   = "Delete";
                deleteordraftEventButton.Click += DeleteEvent;
            }
        }
コード例 #2
0
        public EventEditorPanel(IPanel caller, EventFull @event, bool draft = false)
        {
            this.draft  = draft;
            this.caller = caller;

            InitializeComponent();

            Text             = "Edit event";
            this.@event      = @event;
            headerLabel.Text = "Edit event information";

            FillInSports();
            FillInBoxes();
            FillInPhotos();

            UserAccount acc = Program.UserDataManager.UserAccount;

            if (draft)
            {
                finishButton.Text        = "Create";
                finishButton.Click      += CreateEvent;
                deleteEventButton.Text   = "Save as draft";
                deleteEventButton.Click += SaveDraft;

                if (!acc.Can((uint)Permissions.MANAGE_SELF_EVENT))
                {
                    finishButton.Visible = false;
                }
            }
            else
            {
                finishButton.Text           = "Save";
                finishButton.Click         += EditEvent;
                deleteEventButton.Text      = "Delete event";
                deleteEventButton.Click    += DeleteEvent;
                deleteEventButton.BackColor = Color.Tomato;

                if (@event.Author == acc.Id)
                {
                    if (!acc.Can((uint)Permissions.MANAGE_SELF_EVENT))
                    {
                        finishButton.Visible = false;
                    }
                }
                else
                {
                    if (!acc.Can((uint)Permissions.EDIT_OTHER_EVENTS))
                    {
                        finishButton.Visible = false;
                    }
                    if (!acc.Can((uint)Permissions.DELETE_OTHER_EVENTS))
                    {
                        deleteEventButton.Visible = false;
                    }
                }
            }

            // Set maps button image
            checkAddressButton.BackgroundImage = Properties.Resources.MapsButton;
        }
コード例 #3
0
        public JsonResult SaveEvent(HttpPostedFileBase filePost)
        {
            int res = 0;

            if (filePost.ContentLength > 0)
            {
                string title       = Convert.ToString(Request["title"]);
                string url         = Convert.ToString(Request["url"]);
                string description = Convert.ToString(Request["description"]);
                string _FileName   = Path.GetFileName(filePost.FileName);

                StringBuilder builder = new StringBuilder();
                Random        random  = new Random();
                char          ch;
                for (int i = 0; i < _FileName.Length; i++)
                {
                    ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                    builder.Append(ch);
                }

                string fileName = builder.ToString().ToLower();
                fileName = fileName + ".jpg";
                //System.Diagnostics.Debug.WriteLine(fileName);

                string _path = Path.Combine(Server.MapPath("~/UploadedFiles/events"), fileName);
                filePost.SaveAs(_path);

                EventFull evt = new EventFull
                {
                    Title       = title,
                    Description = description,
                    FileName    = fileName,
                    Path        = "~/UploadedFiles/events/" + fileName,
                    Url         = url
                };

                EventHelper eh = new EventHelper();
                res = eh.CreateActivity(evt);

                if (res == 1)
                {
                    model = (SessionModel)this.Session["SessionData"];
                    logger.Info("Evento create for username: "******"El evento " + title + " se ha creado correctamente." }));
                }
                else
                {
                    logger.Error("Error al intentar crear un evento en la db. " + Environment.NewLine + DateTime.Now);
                    return(Json(new { success = false, msgError = "Error, no se pudo crear el evento." }));
                }
            }
            else
            {
                logger.Error("Error al intentar crear un evento. filePost < 0" + Environment.NewLine + DateTime.Now);
                return(Json(new { success = false, msgError = "Error, nose pudo crear el evento." }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
        //save activity
        public int CreateActivity(EventFull evt)
        {
            int n = 0;

            Conectar();

            try
            {
                string     query       = "INSERT INTO Activity(title, description, date) VALUES (@title, @description, @date);";
                SqlCommand addActivity = new SqlCommand(query, con);
                addActivity.Parameters.Add("@title", SqlDbType.VarChar);
                addActivity.Parameters.Add("@description", SqlDbType.VarChar);
                addActivity.Parameters.Add("@date", SqlDbType.DateTime);

                addActivity.Parameters["@title"].Value       = evt.Title;
                addActivity.Parameters["@description"].Value = evt.Description;
                addActivity.Parameters["@date"].Value        = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                con.Open();
                int i = addActivity.ExecuteNonQuery();
                con.Close();

                if (i == 1)
                {
                    SqlCommand com = new SqlCommand("SELECT MAX(idActivity) FROM Activity", con);
                    con.Open();
                    evt.IdActivity = Convert.ToInt32(com.ExecuteScalar());
                    con.Close();

                    n = CreateEvent(evt);
                }
                else
                {
                    return(0);
                }
            }
            catch (NullReferenceException ex)
            {
                string errMsg = ex.Message;
                logger.Error(errMsg + " ConnectionString no encontrado en EventHelper->GetAllEvent." + Environment.NewLine + DateTime.Now);
            }
            catch (SqlException ex)
            {
                string errMsg = ex.Message;
                logger.Error(errMsg + Environment.NewLine + DateTime.Now);
                return(0);
            }

            return(n);
        }
コード例 #5
0
        //save event
        public int CreateEvent(EventFull evt)
        {
            Event evnt = new Event()
            {
                FileName   = evt.FileName,
                Path       = evt.Path,
                Url        = evt.Url,
                IdActivity = evt.IdActivity,
            };

            db.Event.Add(evnt);
            int r = db.SaveChanges();

            return(r);
        }
コード例 #6
0
        public void CreateEvent(EventFull @event)
        {
            SendVfid();

            string jsonStr = Json.FromList(DataList.ToList(@event.ToDataList()));

            Packet pack = new Packet
            {
                PacketId = (uint)PacketType.CREATE_EVENT,
                Data     = Encoding.ASCII.GetBytes(jsonStr)
            };

            client.AddToSendQueue(pack);
            client.SendQueue();
        }
コード例 #7
0
        //get all event
        public List <EventFull> GetAllEvent()
        {
            Conectar();
            List <EventFull> events = new List <EventFull>();

            try
            {
                string query = @"SELECT e.idEvent, a.title, a.description, e.fileName, e.path, e.url 
                            FROM Event as e
                            INNER JOIN Activity as a
                            ON e.idActivity = a.idActivity;";

                SqlCommand com = new SqlCommand(query, con);
                con.Open();
                SqlDataReader registros = com.ExecuteReader();

                while (registros.Read())
                {
                    EventFull evt = new EventFull
                    {
                        IdEvent     = int.Parse(registros["idEvent"].ToString()),
                        Title       = registros["title"].ToString(),
                        Description = registros["description"].ToString(),
                        FileName    = registros["fileName"].ToString(),
                        Path        = registros["path"].ToString(),
                        Url         = registros["url"].ToString(),
                    };
                    events.Add(evt);
                }
                con.Close();
            }
            catch (NullReferenceException ex)
            {
                string errMsg = ex.Message;
                logger.Error(errMsg + " ConnectionString no encontrado en EventHelper->GetAllEvent." + Environment.NewLine + DateTime.Now);
            }
            catch (SqlException ex)
            {
                string errMsg = ex.Message;
                logger.Error(errMsg + Environment.NewLine + DateTime.Now);
                return(null);
            }

            return(events);
        }
コード例 #8
0
        public void EditEvent(EventFull @event)
        {
            SendVfid();

            string jsonStr = Json.FromList(DataList.ToList(@event.ToDataList()));

            Packet pack1 = new Packet
            {
                PacketId = (uint)PacketType.EDIT_EVENT,
                Data     = BitConverter.GetBytes(@event.Id)
            };

            Packet pack2 = new Packet
            {
                PacketId = (uint)PacketType.EDIT_EVENT_DATA,
                Data     = Encoding.ASCII.GetBytes(jsonStr)
            };

            client.AddToSendQueue(pack1);
            client.AddToSendQueue(pack2);
            client.SendQueue();
        }
コード例 #9
0
        public static EventFull GetFullLine(long id, WebProxy proxy, string host)
        {
            EventFull e     = null;
            var       retry = 0;

            while (retry < 3)
            {
                try
                {
                    using (var wc = new GetWebClient(proxy))
                    {
                        var response = wc.DownloadString($"{host}offering/v2018/888/betoffer/event/{id}.json?lang=en_GB&market=En");
                        e     = JsonConvert.DeserializeObject <EventFull>(response);
                        retry = 3;
                    }
                }
                catch (WebException)
                {
                    retry++;
                }
                catch (Exception exception)
                {
                    Log.Info("S888 GetFullLine exception " + JsonConvert.SerializeObject(exception));
                    retry = 3;
                }
            }

            //foreach (var offer in e.BetOffers)
            //{
            //    foreach (var outcome in offer.outcomes)
            //    {
            //        ProxyHelper.Update888Events(e.Event[0].sport + " | " + offer.criterion.englishLabel + " | " + offer.betOfferType.englishName + " | " + outcome.englishLabel + " | "+ outcome.line);
            //    }
            //}

            return(e);
        }
コード例 #10
0
        public UiEventDisplayPanel(int eventId, IPanel caller)
        {
            // Get full event data from database
            List <EventFull> events = Program.Client.SelectEventsFull(eventId);

            try
            {
                @event = events[0];
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine($"ERROR: Event with id {eventId} not found");
                throw;
            }

            UserAccount acc = Program.UserDataManager.UserAccount;

            this.caller = caller;

            InitializeComponent();

            // Set return button image
            returnButton.BackgroundImage = Properties.Resources.BackButtonGreen;

            // Enforce permissions
            if (!acc.Can((uint)Permissions.CREATE_REPORTS))
            {
                reportButton.Visible = false;
            }
            if (acc.Can((uint)Permissions.SET_EVENT_VISIBILITY))
            {
                setVisibilityButton.Visible = true;
                if ([email protected])
                {
                    setVisibilityButton.BackColor = Color.FromArgb(109, 168, 135);
                    setVisibilityButton.Text      = "Make visible";
                }
                else
                {
                    setVisibilityButton.BackColor = Color.Tomato;
                    setVisibilityButton.Text      = "Make invisible";
                }
            }
            if (!acc.Can((uint)Permissions.SEND_CHAT_MESSAGES))
            {
                if (acc.Id == -1)
                {
                    chatMessageTextBox.PlaceholderText = "Log in to comment";
                    chatMessageTextBox.Enabled         = false;
                }
                else
                {
                    chatMessageTextBox.PlaceholderText = "You don't have the permission to comment";
                    chatMessageTextBox.Enabled         = false;
                }
            }

            // Title
            eventName.Text = @event.Name;

            // Sports
            foreach (var sport in @event.Sports)
            {
                Label sportLabel = new Label();
                sportLabel.AutoSize  = true;
                sportLabel.Text      = sport;
                sportLabel.BackColor = Color.FromArgb(230, 230, 230);
                sportLabel.Font      = new Font("Arial", 12, FontStyle.Bold);
                //sportDisplayBar.Controls.Add(sportLabel);
            }

            // Distance
            UserData user     = Program.UserDataManager.GetData();
            double   distance = MathSupplement.Distance(@event.Latitude, @event.Longitude, user.Latitude, user.Longitude);

            if (distance < 1000.0)
            {
                distanceLabel.Text = $"{distance:0}m";
            }
            else
            {
                distanceLabel.Text = $"{distance / 1000.0:0.0}km";
            }

            // Distance and address separator
            Size distanceLabelSize = Helper.CalculateLabelSize(distanceLabel, 100);

            separatorPanel1.Location = new Point(distanceLabel.Location.X + distanceLabelSize.Width, separatorPanel1.Location.Y);

            // Address
            addressLabel.Location = new Point(distanceLabel.Location.X + distanceLabelSize.Width + 10, addressLabel.Location.Y);
            addressLabel.Text     = @event.Address.ToStringNormal();

            // Show map button
            Size addressLabelSize = Helper.CalculateLabelSize(addressLabel, 500);

            showMapsButton.Location        = new Point(addressLabel.Location.X + addressLabelSize.Width + 5, showMapsButton.Location.Y);
            showMapsButton.BackgroundImage = Properties.Resources.MapsButton;

            // Load images
            List <string> imageLinks = @event.Images;
            int           counter    = 0;

            foreach (var image in @event.Images)
            {
                int IMAGE_WIDTH  = 180;
                int IMAGE_HEIGHT = 180;
                int MARGINS      = 10;

                PictureBox picture = new PictureBox();
                picture.Size        = new Size(IMAGE_WIDTH, IMAGE_HEIGHT);
                picture.Location    = new Point((IMAGE_WIDTH + MARGINS) * counter, 0);
                picture.BorderStyle = BorderStyle.None;

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (s, e) =>
                {
                    try
                    {
                        using (WebClient client = new WebClient())
                        {
                            Stream stream = client.OpenRead(image);
                            Bitmap bitmap = new Bitmap(stream);

                            picture.Image = Helper.ScaleBitmap(bitmap, IMAGE_WIDTH, IMAGE_HEIGHT, 1.0f);

                            stream.Flush();
                            stream.Close();
                        }
                    }
                    catch { }
                };
                worker.RunWorkerAsync();

                picturePanel.Controls.Add(picture);
                counter++;
            }

            picturePanel.VerticalScroll.Maximum   = 0;
            picturePanel.AutoScroll               = false;
            picturePanel.HorizontalScroll.Visible = false;
            picturePanel.AutoScroll               = true;

            // Description
            descriptionLabel.Text = @event.Description;
            Size descriptionLabelSize = Helper.CalculateLabelSize(descriptionLabel, descriptionLabel.MaximumSize.Width);

            // Description and comment separator
            separatorPanel4.Location = new Point(separatorPanel4.Location.X, descriptionLabel.Location.Y + descriptionLabelSize.Height + 28);

            // Show reports
            List <Report> reports = Program.Client.SelectReports(eventId);

            int height = 0;

            if (reports.Count > 0)
            {
                reportsPanel.Visible   = true;
                reportsPanel.Location  = new Point(reportsPanel.Location.X, separatorPanel4.Location.Y + 10);
                reportsPanel.BackColor = Color.FromArgb(255, 200, 200);

                reportsPanel.HorizontalScroll.Maximum = 0;
                reportsPanel.AutoScroll             = false;
                reportsPanel.VerticalScroll.Visible = false;
                reportsPanel.AutoScroll             = true;

                height = 20;

                foreach (var report in reports)
                {
                    Label reportType = new Label();
                    reportType.Text      = report.Type;
                    reportType.Font      = new Font("Arial", 12, FontStyle.Bold);
                    reportType.ForeColor = Color.FromArgb(64, 64, 64);
                    reportType.Location  = new Point(0, 0);
                    reportType.AutoSize  = false;
                    reportType.Size      = new Size(940, 26);
                    reportType.TextAlign = ContentAlignment.MiddleLeft;

                    Label reportComment = new Label();
                    reportComment.Text      = report.Comment;
                    reportComment.Font      = new Font("Arial", 12);
                    reportComment.ForeColor = Color.FromArgb(64, 64, 64);
                    reportComment.Location  = new Point(0, 26);
                    reportComment.AutoSize  = false;
                    Size reportSize = Helper.CalculateLabelSize(reportComment, 940);
                    reportComment.Size      = new Size(940, reportSize.Height);
                    reportComment.TextAlign = ContentAlignment.MiddleLeft;

                    Panel reportPanel = new Panel();
                    reportPanel.Size     = new Size(940, 26 + reportComment.Size.Height);
                    reportPanel.Location = new Point(20, height);

                    height += reportPanel.Size.Height + 20;

                    reportPanel.Controls.Add(reportType);
                    reportPanel.Controls.Add(reportComment);
                    reportsPanel.Controls.Add(reportPanel);
                }

                if (height > 150)
                {
                    height = 150;
                }

                reportsPanel.Size = new Size(reportsPanel.Size.Width, height);
            }

            // Comments panel
            commentsPanel.Location = new Point(commentsPanel.Location.X, separatorPanel4.Location.Y + 10 + height + 10 * (height > 0 ? 1 : 0));

            // New comment
            chatMessageTextBox.Location = new Point(0, 0);

            // Submit new comment
            sendMessageButton.Location = new Point(sendMessageButton.Location.X, chatMessageTextBox.Location.Y + chatMessageTextBox.Size.Height + 6);

            // Chat panel
            chatPanel.Location = new Point(chatPanel.Location.X, sendMessageButton.Location.Y + sendMessageButton.Size.Height + 6);

            // Load comments
            List <Backend.Message> messages = Program.Client.SelectEventComments(@event.Id);

            messages.Reverse();

            /*
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi" +
             *  "lietuva hujon eina o algos tai irgi po jevrejo nebekyla, o vat maisto kainos tai ojojoj" +
             *  "kaip i virsu skuodzia ir va kaip man uz minimuma pragyvent blyat kai reika nauja telef" +
             *  "ona pirk kiekviena meta nu blet negerai cia",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 1,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 2,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 3,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             * messages.Add(new Backend.Message()
             * {
             *  Sender = 0,
             *  Content = "Gražulis blet sake kad ne gejus tai kuo ,man dabar tiket nx pasaulis ritasi",
             *  SendTime = DateTime.Now
             * });
             */

            height = 0;
            if (messages.Count > 0)
            {
                chatPanel.Controls.Clear();

                height = 20;

                foreach (var msg in messages)
                {
                    string username = Program.Client.SelectAccountUsername(msg.Sender);

                    Label senderInfoLabel = new Label();
                    senderInfoLabel.Text      = $"By {username} at {msg.SendTime:yyyy-MM-dd HH:mm}";
                    senderInfoLabel.Font      = new Font("Arial", 10, FontStyle.Italic);
                    senderInfoLabel.ForeColor = Color.Gray;
                    senderInfoLabel.Location  = new Point(0, 0);
                    senderInfoLabel.AutoSize  = false;
                    senderInfoLabel.Size      = new Size(920, 20);
                    senderInfoLabel.TextAlign = ContentAlignment.MiddleLeft;

                    Label commentLabel = new Label();
                    commentLabel.Text      = msg.Content;
                    commentLabel.Font      = new Font("Arial", 12);
                    commentLabel.ForeColor = Color.FromArgb(64, 64, 64);
                    commentLabel.BackColor = Color.White;
                    commentLabel.Location  = new Point(0, 20);
                    commentLabel.Padding   = new Padding(10);
                    commentLabel.AutoSize  = false;
                    Size reportSize = Helper.CalculateLabelSize(commentLabel, 920);
                    commentLabel.Size      = new Size(920, reportSize.Height + 20);
                    commentLabel.TextAlign = ContentAlignment.MiddleLeft;

                    Panel commentPanel = new Panel();
                    commentPanel.Size     = new Size(920, 20 + commentLabel.Size.Height);
                    commentPanel.Location = new Point(20, height);

                    height += commentPanel.Size.Height + 20;

                    commentPanel.Controls.Add(senderInfoLabel);
                    commentPanel.Controls.Add(commentLabel);
                    chatPanel.Controls.Add(commentPanel);
                }

                chatPanel.Size = new Size(chatPanel.Size.Width, height);
            }
            commentsPanel.Size = new Size(commentsPanel.Size.Width, chatPanel.Location.Y + chatPanel.Size.Height);

            mainPanel.Size = new Size(1000, commentsPanel.Location.Y + commentsPanel.Size.Height + 20);

            // Chat
            chatMessageTextBox.KeyPress += new KeyPressEventHandler(Key_Press);

            // Start chat
            //chatManager = new ChatManager();
            //chatManager.Connect(@event.Id, chatPanel);

            // Links
            //List<string> links = @event.Links;
            //for (int i = 0; i < links.Count; i++)
            //{
            //    string[] linkSplit = links[i].Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
            //    if (linkSplit.Length != 2) continue;

            //    LinkLabel linkText = new LinkLabel();
            //    linkText.Text = linkSplit[1];
            //    linkText.LinkClicked += (sender, e) =>
            //    {
            //        Process.Start(new ProcessStartInfo("cmd", $"/c start {linkSplit[0]}"));
            //    };
            //    linkText.Location = new Point(426, 370 + (i * 20));

            //    Controls.Add(linkText);
            //}
        }
コード例 #11
0
 public void AddEvent(EventFull eventFull)
 {
     events.Add(eventFull);
 }
コード例 #12
0
        public UiEventDisplay(int eventId, Form caller)
        {
            this.caller = caller;

            InitializeComponent();

            // Get full event data from database
            List <EventFull> events = Program.Client.SelectEventsFull(eventId);

            try
            {
                @event = events[0];
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine($"ERROR: Event with id {eventId} not found");
                throw;
            }

            // Title
            eventName.Text = @event.Name;

            // Sports
            foreach (var sport in @event.Sports)
            {
                Label sportLabel = new Label();
                sportLabel.AutoSize  = true;
                sportLabel.Text      = sport;
                sportLabel.BackColor = Color.FromArgb(230, 230, 230);
                sportLabel.Font      = new Font("Arial Rounded", 12, FontStyle.Bold);
                sportDisplayBar.Controls.Add(sportLabel);
            }

            // Address
            addressLabel.Text = @event.Address.ToStringNormal();

            // Distance
            UserData user     = Program.UserDataManager.GetData();
            double   distance = MathSupplement.Distance(@event.Latitude, @event.Longitude, user.Latitude, user.Longitude);

            if (distance < 1000.0)
            {
                distanceLabel.Text = $"{distance:0}m";
            }
            else
            {
                distanceLabel.Text = $"{distance / 1000.0:0.0}km";
            }

            // Description
            descriptionLabel.Text = @event.Description;

            // Links
            List <string> links = @event.Links;

            for (int i = 0; i < links.Count; i++)
            {
                string[] linkSplit = links[i].Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
                if (linkSplit.Length != 2)
                {
                    continue;
                }

                LinkLabel linkText = new LinkLabel();
                linkText.Text         = linkSplit[1];
                linkText.LinkClicked += (sender, e) =>
                {
                    Process.Start(new ProcessStartInfo("cmd", $"/c start {linkSplit[0]}"));
                };
                linkText.Location = new Point(426, 370 + (i * 20));

                Controls.Add(linkText);
            }

            // Load images
            List <string> imageLinks = @event.Images;

            for (int i = 0; i < imageLinks.Count; i++)
            {
                PictureBox picture = new PictureBox();
                picture.Size        = new Size(240, 180);
                picture.Location    = new Point(0, 200 * i);
                picture.BorderStyle = BorderStyle.Fixed3D;
                try
                {
                    using (WebClient client = new WebClient())
                    {
                        Stream stream       = client.OpenRead(imageLinks[i]);
                        Bitmap bitmap       = new Bitmap(stream);
                        Bitmap bitmapScaled = new Bitmap(bitmap, new Size(240, 180));
                        picture.Image = bitmapScaled;

                        stream.Flush();
                        stream.Close();
                    }
                }
                catch { }
                picturePanel.Controls.Add(picture);
            }

            picturePanel.HorizontalScroll.Maximum = 0;
            picturePanel.AutoScroll             = false;
            picturePanel.VerticalScroll.Visible = false;
            picturePanel.AutoScroll             = true;

            // Chat
            chatMessageTextBox.KeyPress += new KeyPressEventHandler(Key_Press);

            chatPanel.HorizontalScroll.Maximum = 0;
            chatPanel.AutoScroll             = false;
            chatPanel.VerticalScroll.Visible = false;
            chatPanel.AutoScroll             = true;

            // Start chat
            chatManager = new ChatManager();
            chatManager.Connect(@event.Id, chatPanel);
        }
コード例 #13
0
        public List <LineDTO> GetLinesFromEvent(LineDTO template, EventFull @event)
        {
            var localLines = new List <LineDTO>();

            var simpleMap = new Dictionary <string, string>
            {
                { template.Team1, "1" },
                { template.Team2, "2" },
            };

            foreach (var offer in @event.BetOffers.Where(bo => !bo.suspended))
            {
                var copy = template.Clone();

                // Извлекаем тип игры: угловые, (желтые, красные карты), картер, и т.д.

                //if (!ConverterHelper.CheckCriterion(offer.criterion, out var period)) continue;

                foreach (var outcome in offer.outcomes)
                {
                    if (outcome.status != "OPEN")
                    {
                        continue;
                    }

                    var line = copy.Clone();


                    switch (offer.betOfferType.englishName)
                    {
                    case "Match":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Full Time":
                        case "1st Half":
                        case "2nd Half":
                        case "Half Time":
                        case "Period 1":
                        case "Period 2":
                        case "Period 3":
                        case "2nd Half (3-way)":
                        case "Including Overtime":
                        case "Quarter 1":
                        case "Quarter 2":
                        case "Quarter 3":
                        case "Quarter 4":

                            line.CoeffKind = outcome.englishLabel;
                            break;

                        case "Draw No Bet":
                        case "Draw No Bet - 1st Half":
                        case "Draw No Bet - 2nd Half":
                        case "Draw No Bet - Regular Time":
                        case "Draw No Bet - Quarter 1":
                        case "Draw No Bet - Quarter 2":
                        case "Draw No Bet - Quarter 3":
                        case "Draw No Bet - Quarter 4":
                        case "Draw No Bet - Period 1":
                        case "Draw No Bet - Period 2":
                        case "Draw No Bet - Period 3":

                            line.CoeffKind = "W" + outcome.englishLabel;
                            break;

                        default:
                            continue;
                        }
                        break;

                    case "Handicap":
                    case "Asian Handicap":
                        if (offer.criterion.englishLabel == "Handicap" ||
                            offer.criterion.englishLabel == "Handicap - 1st Half" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 1" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 2" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 3" ||
                            offer.criterion.englishLabel == "Handicap - Quarter 4" ||
                            offer.criterion.englishLabel == "Handicap - Including Overtime" ||
                            offer.criterion.englishLabel == "Handicap - Period 1" ||
                            offer.criterion.englishLabel == "Handicap - Period 2" ||
                            offer.criterion.englishLabel == "Handicap - Period 3" ||
                            offer.criterion.englishLabel == "Handicap - Regular Time")
                        {
                            line.CoeffKind = "HANDICAP" + simpleMap[outcome.englishLabel];
                        }
                        else if (Regex.IsMatch(offer.criterion.englishLabel, "Asian Handicap \\([0-9] - [0-9]\\)"))
                        {
                            line.CoeffKind = "HANDICAP" + simpleMap[outcome.englishLabel];
                        }
                        else
                        {
                            continue;
                        }
                        break;

                    case "Over/Under":
                    case "Asian Over/Under":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Total Points - 1st Half":
                        case "Total Points - Quarter 1":
                        case "Total Points - Quarter 2":
                        case "Total Points - Quarter 3":
                        case "Total Points - Quarter 4":
                        case "Total Points - Including Overtime":
                        case "Total Goals":
                        case "Total Goals - 1st Half":
                        case "Total Goals - Period 1":
                        case "Total Goals - Period 2":
                        case "Total Goals - Period 3":
                        case "Total Goals - Regular Time":
                            line.CoeffKind = "TOTAL" + outcome.englishLabel;
                            break;

                        case "Asian Total":
                        case "Asian Total - 1st Half":
                            line.CoeffKind = "TOTAL" + outcome.englishLabel;
                            break;

                        case "Total Goals by Away Team":
                        case "Total Goals by Away Team - 1st Half":
                        case "Total Goals by Away Team - 2nd Half":
                        case "Total Goals by Away Team - Period 1":
                        case "Total Goals by Away Team - Period 2":
                        case "Total Goals by Away Team - Period 3":
                        case "Total Goals by Away Team - Regular Time":
                            line.CoeffKind = "ITOTAL" + outcome.englishLabel + "2";
                            break;

                        case "Total Goals by Home Team":
                        case "Total Goals by Home Team - 1st Half":
                        case "Total Goals by Home Team - 2nd Half":
                        case "Total Goals by Home Team - Period 1":
                        case "Total Goals by Home Team - Period 2":
                        case "Total Goals by Home Team - Period 3":
                        case "Total Goals by Home Team - Regular Time":
                            line.CoeffKind = "ITOTAL" + outcome.englishLabel + "1";
                            break;

                        default:
                            continue;
                        }
                        break;

                    case "Double Chance":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Double Chance":
                        case "Double Chance - Period 1":
                        case "Double Chance - Period 2":
                        case "Double Chance - Period 3":
                            line.CoeffKind = outcome.englishLabel;
                            break;

                        default:
                            continue;
                        }
                        break;

                    case "Odd/Even":
                        switch (offer.criterion.englishLabel)
                        {
                        case "Total Goals Odd/Even":
                        case "Total Goals Odd/Even - 1st Half":
                        case "Total Goals Odd/Even - 2nd Half":
                        case "Total Points Odd/Even - Including Overtime":
                            line.CoeffKind = outcome.englishLabel;
                            break;

                        default:
                            continue;
                        }
                        break;

                    default:
                        continue;
                    }

                    //Параметр
                    if (outcome.line != null)
                    {
                        line.CoeffParam = Math.Round(outcome.line.Value / 1000m, 2);
                    }

                    line.CoeffType = ConverterHelper.GetPeriod(offer.criterion.englishLabel);

                    line.CoeffValue = Math.Round(outcome.odds / 1000m, 2);
                    line.LineData   = outcome.odds + ";" + outcome.id;
                    line.LineObject = "| Outcome | " + JsonConvert.SerializeObject(outcome) + " | Offer | " + JsonConvert.SerializeObject(offer);
                    line.UpdateName();
                    localLines.Add(line);
                }
            }

            return(localLines);
        }