public TelegramChecker(ref IStorage storage, ref TelegramBot bot, ref EventViews viewer, ref ILogger loger)
 {
     this.storage     = storage;
     this.telegramBot = bot;
     this.viewer      = viewer;
     this.loger       = loger;
 }
        //RecordView
        public bool RecordView(EventViews _views)
        {
            string response = null;
            string data     = null;
            bool   isAdded  = false;

            DataContractJsonSerializer ser = new DataContractJsonSerializer(
                typeof(EventViews));
            MemoryStream mem = new MemoryStream();

            ser.WriteObject(mem, _views);
            data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
            WebClient webClient = new WebClient();

            webClient.Headers["Content-type"] = "application/json";
            webClient.Encoding = Encoding.UTF8;
            response           = webClient.UploadString(BASE_URL + "RecordView", "PUT", data);
            if (response.ToLower().Contains("true"))
            {
                isAdded = true;
            }
            else
            {
                isAdded = false;
            }
            return(isAdded);
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            ILogger     logger           = new ConsoleLoger();
            TelegramBot bot              = new TelegramBot();
            string      connectionString = ConfigurationManager.ConnectionStrings["TelegramApp"].ConnectionString;
            IStorage    storage          = new DapStorageDB(logger, connectionString);
            EventViews  viewer           = new EventViews();

            try
            {
                TelegramChecker telegramBot     = new TelegramChecker(ref storage, ref bot, ref viewer, ref logger);
                Thread          telegramChecker = new Thread(telegramBot.Run);
                telegramChecker.Start();
            }
            catch (AggregateException ex)
            {
                foreach (var x in ex.InnerExceptions)
                {
                    logger.WriteLog(x.Message);
                    bot.SendMessageMe(x.Message);
                }
                Console.ReadKey();
            }
        }
        public void Shutdown()
        {
            UnbindStep();

            foreach (var eventView in EventViews.ToList())
            {
                RemoveEventView(eventView.Event);
            }
        }
        private void AddEventView(StepEvent @event)
        {
            var eventViewGo = Instantiate(EventViewPrefab);
            var eventView   = eventViewGo.GetComponent <TimelineEventViewBehaviour>();

            eventView.RectTransform.SetParent(EventAttachmentPoint, false);

            EventViews.Add(eventView);

            eventView.Event = @event;
        }
        public float Arrange()
        {
            if (!EventViews.Any())
            {
                var height = RectTransform.sizeDelta.y;

                return(height);
            }

            var eventPosX = 0.0f;

            // Start by counting our own height from our top to the event attachement point
            var cumulativeHeight = 9.0f;

            // Then increment by space between bottom of step and top of event.
            cumulativeHeight += TimelineViewBehaviour.SpaceBetweenStepAndEventBadge;

            foreach (var eventView in EventViews)
            {
                // This positions the /attachment point/
                eventView.RectTransform.anchoredPosition = new Vector2(eventPosX, 0.0f);
                eventPosX += TimelineViewBehaviour.HorizontalEventSpacing;

                // Ensure hierarchy order is synced with EventViews collection order.
                eventView.RectTransform.SetAsFirstSibling();


                // Add height of iterated event and its steps recursive
                cumulativeHeight += eventView.Arrange(cumulativeHeight);

                if (eventView != EventViews.Last())
                {
                    if (eventView.StepViewsEnumerable.Any())
                    {
                        cumulativeHeight += TimelineViewBehaviour.SpaceBetweenStepAndEventBadge;
                    }
                    else
                    {
                        cumulativeHeight += TimelineViewBehaviour.SpaceBetweenEventAndEvent;
                    }
                }
            }

            // Make sure workspace fits this step
            var xFromWorkspaceEdge = RectTransform.sizeDelta.x - TimelineViewBehaviour.GetStepViewPositionRelativeToWorkspace(this).x;

            TimelineViewBehaviour.BoostWorkspaceMax(new Vector2(xFromWorkspaceEdge + 40, cumulativeHeight + 40));

            // Finish by counting the height from the attachment point to the bottom.
            return(cumulativeHeight + 9.0f);
        }
        private void RemoveEventView(StepEvent @event)
        {
            var eventView = EventViews.FirstOrDefault(view => view.Event == @event);

            if (eventView == null)
            {
                return;
            }

            EventViews.Remove(eventView);

            eventView.Shutdown();

            Destroy(eventView.gameObject);
        }
        public bool RecordView(EventViews _views)
        {
                using (EventrixDBDataContext db = new EventrixDBDataContext())
                {
                    var query = (from views in db.EventViews where views.eventID.Equals(_views.E_ID)
                                 && views.G_ID.Equals(_views.G_ID) select views);
                    if (query.Count() == 0)
                    {
                    EventView toinsert = new EventView();
                    toinsert.eventID = _views.E_ID;
                    toinsert.G_ID = _views.G_ID;
                    toinsert.EH_ID = _views.EH_ID;

                    db.EventViews.InsertOnSubmit(toinsert);
                    db.SubmitChanges();
                    return true;
                    }
                    else
                    {
                    return false;
                    }
                };
            }
示例#9
0
        public void ExecuteCommand(Result result, ref IStorage storage, ref TelegramBot bot, ref EventViews viewer)
        {
            DevByParser  parser     = new DevByParser();
            List <Event> currEvents = parser.GetEvents(2);

            storage.SaveNewEventsToStorage(currEvents);
            List <Event> newEvents = storage.GetNewEventsFromStorageForUser(result.message.from.ID.ToString());

            storage.SaveUserCheckDate(result.message.from.ID.ToString());
            if (newEvents.Capacity > 0)
            {
                foreach (var sub in newEvents)
                {
                    bot.SendMessageMDCustom(viewer.ToMdFormat(sub), result.message.chat.Id);
                }
            }
            else
            {
                bot.SendMessageMDCustom($"*No new events for you, {result.message.from.first_name}!*", result.message.chat.Id);
            }
        }
示例#10
0
 public void ExecuteCommand(Result result, ref IStorage storage, ref TelegramBot bot, ref EventViews views)
 {
 }
示例#11
0
        public void ExecuteCommand(Result result, ref IStorage storage, ref TelegramBot bot, ref EventViews viewer)
        {
            DevByParser  parser     = new DevByParser();
            List <Event> currEvents = parser.GetEvents(2);

            storage.SaveNewEventsToStorage(currEvents);
            storage.SaveUserCheckDate(result.message.from.ID.ToString());
            foreach (var sub in currEvents)
            {
                bot.SendMessageMDCustom(viewer.ToMdFormat(sub), result.message.chat.Id);
            }
        }
示例#12
0
        public void ExecuteCommand(Result result, ref IStorage storage, ref TelegramBot bot, ref EventViews viewer)
        {
            string message = $"Dear {result.message.from.first_name}, you entered unknown command!\nPlease Chose command from list:\n" +
                             $"/ShowEvents@JonnWickbot -show all events\n" +
                             $"/ShowNewEvents@JonnWickbot- show only new events for you";

            bot.SendMessageCustom(message, result.message.chat.Id);
        }
示例#13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string eventID = Request.QueryString["ev"];

            // GetNumViews(string eventID, string Type)
            EventServiceClient  esv          = new EventServiceClient();
            ReportServiceClient reportClient = new ReportServiceClient();
            EventModel          myEvent      = new EventModel();
            //Get Number of Event Vies
            int    EventViews      = esv.GetNumViews(eventID, "Views");
            int    EventShares     = esv.GetNumViews(eventID, "Shares");
            string RecentShareDate = reportClient.GetLatestView(eventID, "Shares");
            string RecentViewDate  = reportClient.GetLatestView(eventID, "Views");

            numViews.InnerHtml  = Convert.ToString(EventViews);
            numShares.InnerHtml = Convert.ToString(EventShares);
            ViewDate.InnerHtml  = RecentViewDate;
            shareDate.InnerHtml = RecentShareDate;



            String request   = (Request.QueryString["ev"]);
            string HostLevel = Convert.ToString(Session["Level"]);
            int    HostID    = Convert.ToInt32(Session["ID"]);

            //Trigger event views
            EventServiceClient evsc    = new EventServiceClient();
            EventViews         newView = new EventViews();

            newView.E_ID = Convert.ToInt32(request);
            if (HostLevel.ToLower().Equals("host"))
            {
                MapVsReportContainer.InnerHtml = "<span class='title' style='text-align:center;'>Ticket Statistics</span>";
                EventServiceClient Service_Client = new EventServiceClient();
                EventModel         _event         = new EventModel();
                _event = Service_Client.findByEventID(request);
                if (_event.HostID == HostID)
                {
                    btnDelete.Visible = true;
                    btnEdit.Visible   = true;
                    btnReport.Visible = true;


                    googleMap.Visible = false;
                    PieChart.Visible  = true;
                    market.Visible    = true;
                    ticket.Visible    = false;
                }
                else
                {
                    btnDelete.Visible = false;
                    btnEdit.Visible   = false;
                    btnReport.Visible = false;


                    googleMap.Visible = true;
                    PieChart.Visible  = false;
                    market.Visible    = false;
                    ticket.Visible    = true;
                }


                EventModel view = new EventModel();
                view.EventID = Convert.ToInt32(request);
                view.HostID  = Convert.ToInt32(HostID);
                view.Type    = "Views";
                evsc.addEventView(view);
            }
            else if (HostLevel.ToLower().Equals("guest"))
            {
                MapVsReportContainer.InnerHtml = "<span class='title' style='text-align:center;'>Get Directions</span>";
                btnDelete.Visible = false;
                btnEdit.Visible   = false;
                btnReport.Visible = false;

                googleMap.Visible = true;
                PieChart.Visible  = false;
                market.Visible    = false;
                ticket.Visible    = true;

                EventModel view = new EventModel();
                view.EventID = Convert.ToInt32(request);
                view.GuestID = Convert.ToInt32(HostID);
                view.Type    = "View";
                evsc.addEventView(view);
            }
            else
            {
                MapVsReportContainer.InnerHtml = "<span class='title' style='text-align:center;'>Get Directions</span>";
                btnDelete.Visible = false;
                btnEdit.Visible   = false;
                btnReport.Visible = false;

                googleMap.Visible = true;
                PieChart.Visible  = false;
                market.Visible    = false;
                ticket.Visible    = true;
            }

            //bool addViews = false;
            EventModel _View = new EventModel();

            _View.EventID   = Convert.ToInt32(request);
            _View.EventView = EventViews;
            DateTime dummyTime = new DateTime();

            dummyTime   = DateTime.Now;
            _View.sDate = Convert.ToString(dummyTime);
            _View.eDate = Convert.ToString(dummyTime);

            int EventID = Convert.ToInt32(request);

            strEventID = EventID;
            EventModel           em           = new EventModel();
            ImageFile            img          = new ImageFile();
            List <ImageFile>     listimages   = new List <ImageFile>();
            List <EventProduct>  products     = new List <EventProduct>();
            EventTicket          EB_tickets   = new EventTicket();
            EventTicket          REG_tickets  = new EventTicket();
            EventTicket          VIP_tickets  = new EventTicket();
            EventTicket          VVIP_tickets = new EventTicket();
            EventServiceClient   eventClient  = new EventServiceClient();
            FileUploadClient     fuc          = new FileUploadClient();
            TicketServiceClient  tsc          = new TicketServiceClient();
            ProductServiceClient psc          = new ProductServiceClient();

            em         = eventClient.findByEventID(request);
            img        = fuc.getImageById(request);
            listimages = fuc.getMultipleImagesById(request);
            string    output      = "";
            string    imgLocation = "";
            ImageFile mainPic     = new ImageFile();

            if (listimages.Count == 0)
            {
                output = "/Events/Eventrix_Default_Image.png";
                string strIhtml = "<img src='" + output + "' class='img-responsive' alt=''/>";
                divImageSlider.InnerHtml = strIhtml;
                //secondaryImageSlider.Visible = false;
            }
            else
            if (listimages.Count == 1)  //one pic uploaded
            {
                imgLocation = img.Location;
                output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                                                                               //image slider
                string strIhtml = "<img src='" + output + "' class='img-responsive' alt=''/>";
                divImageSlider.InnerHtml = strIhtml;
                //  secondaryImageSlider.Visible = false;
            }
            string htmltag = "";

            htmltag         = "Event Name: " + em.Name;
            EName.InnerHtml = htmltag;

            htmltag             = "<span class='title'>Start Date : </span>" + em.sDate;
            StartDate.InnerHtml = htmltag;

            htmltag           = "<span class='title'>End Date : </span>" + em.eDate;
            EndDate.InnerHtml = htmltag;

            htmltag = em.Desc;
            Description.InnerHtml = htmltag;

            htmltag      = ""; //clean string
            EB_tickets   = tsc.getEBTicket(request);
            REG_tickets  = tsc.getRegularTicket(request);
            VIP_tickets  = tsc.getVIPTicket(request);
            VVIP_tickets = tsc.getVVIPTicket(request);
            if (EB_tickets != null)
            {
                if (EB_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>Early Bird Tickets :Available  " + em.EB_Quantity + " </span> Price: For Free!, Available Till: " + EB_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>Early Bird Tickets :Available  " + em.EB_Quantity + "  </span> Price: R" + EB_tickets._Price + ", Available Till: " + EB_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?EBT_ID=" + EB_tickets._TicketID + "&E_ID=" + request + "'>Buy Early Bird Ticket</a></li><hr/>";
            }

            if (REG_tickets != null)
            {
                if (REG_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>Regular Tickets :Available " + em.Reg_Quantity + " </span> Price: For Free!, Available Till: " + REG_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>Regular Tickets :Available " + em.Reg_Quantity + " </span> Price: R" + REG_tickets._Price + ", Available Till: " + REG_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?RBT_ID=" + REG_tickets._TicketID + "&E_ID=" + request + "'>Buy Regular Ticket</a></li><hr/>";
            }
            if (VIP_tickets != null)
            {
                if (VIP_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>VIP Tickets :Available " + em.VIP_Quantity + " </span> Price: For Free!, Available Till: " + VIP_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>VIP Tickets :Available " + em.VIP_Quantity + " </span> Price: R" + VIP_tickets._Price + ", Available Till: " + VIP_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?VT_ID=" + VIP_tickets._TicketID + "&E_ID=" + request + "'>Buy VIP Ticket</a></li><hr/>";
            }
            if (VVIP_tickets != null)
            {
                if (VVIP_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>VVIP Tickets :Available " + em.VVIP_Quantity + " </span> Price: For Free!, Available Till: " + VVIP_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>VVIP Tickets :Available " + em.VVIP_Quantity + " </span> Price: R" + VVIP_tickets._Price + ", Available Till: " + VVIP_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?VVT_ID=" + VVIP_tickets._TicketID + "&E_ID=" + request + "'>Buy VVIP Ticket</a></li><hr/>";
            }
            ticketInfo.InnerHtml = htmltag;

            //check if ticket entrance is for free
            if (EB_tickets == null && REG_tickets == null && VIP_tickets == null && VVIP_tickets == null)
            {
                AttendEvent.Visible = true;
            }
            else
            {
                AttendEvent.Visible = false;
            }

            htmltag  = ""; //clean string
            products = psc.getProductByEventID(request);
            int PC = products.Count();

            int count = 1;

            if (products != null)
            {
                if (PC != 0)
                {
                    htmltag = "<span class='title'>Products Sold</span>";
                    //    ProductsHeading.InnerHtml = htmltag;
                    htmltag = "";
                }
                foreach (EventProduct ep in products)
                {
                    htmltag += "<li><span class='title'>" + count + ". " + ep._Name + "</span>Price: R" + ep._Price + "</li>";
                    count++;
                }
                Products.InnerHtml = htmltag;
            }
        }