public static bool getOnlieDate(eventVar _event)
        {
            bool check = false;

            String eventDate = _event.eventDate.ToShortDateString();

            String nowDate = DateTime.Now.ToShortDateString();

            DateTime _eventDate = new DateTime();

            _eventDate = DateTime.Parse(eventDate);

            DateTime _nowDate = new DateTime();

            _nowDate = DateTime.Parse(nowDate);

            TimeSpan difference = _eventDate - _nowDate;
            double   days       = difference.TotalDays;


            if (days > 0)
            {
                check = true;
            }
            else if (days == 0)
            {
                /*DateTime dt = DateTime.Parse("1/1/1111 21:00:00");
                 * DateTime _dt = new DateTime();
                 * _dt = DateTime.Parse(dt.ToString("H:mm"));
                 * String nowTime = DateTime.Now.ToShortTimeString();
                 * DateTime _nowTime = new DateTime();
                 * _nowDate = DateTime.Parse(nowTime.ToString());
                 *
                 * TimeSpan timeDiff = _dt - _nowDate;
                 *
                 * double hours = timeDiff.TotalHours;
                 *
                 * if(hours > 0)
                 * {
                 *  check = true;
                 * }
                 * else if(hours == 0 || hours < 0)
                 * {
                 *  check = false;
                 * }*/
                check = false;
            }
            else if (days < 0)
            {
                check = false;
            }

            return(check);
        }
        public static bool getOnlieDate(eventVar _event)
        {
            bool check = false;

            String eventDate = _event.eventDate.ToShortDateString();

            String nowDate = DateTime.Now.ToShortDateString();

            DateTime _eventDate = new DateTime();
            _eventDate = DateTime.Parse(eventDate);

            DateTime _nowDate = new DateTime();
            _nowDate = DateTime.Parse(nowDate);

            TimeSpan difference = _eventDate - _nowDate;
            double days = difference.TotalDays;

            if (days > 0)
            {
                check = true;

            }
            else if(days == 0)
            {
                /*DateTime dt = DateTime.Parse("1/1/1111 21:00:00");
                DateTime _dt = new DateTime();
                _dt = DateTime.Parse(dt.ToString("H:mm"));
                String nowTime = DateTime.Now.ToShortTimeString();
                DateTime _nowTime = new DateTime();
                _nowDate = DateTime.Parse(nowTime.ToString());

                TimeSpan timeDiff = _dt - _nowDate;

                double hours = timeDiff.TotalHours;

                if(hours > 0)
                {
                    check = true;
                }
                else if(hours == 0 || hours < 0)
                {
                    check = false;
                }*/
                check = false;
            }
            else if(days < 0)
            {
                check = false;
            }

            return check;
        }
예제 #3
0
        private async void eventMod_Click(object sender, RoutedEventArgs e)
        {
            if (!config.Administrators.Contains(txt_User.Text))
            {
                MsgBox("Error", "You MUST be and Administrator to complete this action!");
                return;
            }

            if (string.IsNullOrEmpty(txtmissionNameMod.Text) ||
               string.IsNullOrEmpty(comboMapMod.SelectedItem.ToString()) ||
               string.IsNullOrEmpty(Convert.ToString(nudPlayersMod.Value)) ||
               string.IsNullOrEmpty(txtmissionDescriptionMod.Text))
            {
                MsgBox("Error", "Please compile all field before create the event!");
                return;
            }

            BackgroundWorker bgWorker = new BackgroundWorker() { WorkerReportsProgress = true };
            bgWorker.DoWork += (s, ee) =>
            {
                try
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
                    {
                        _eventVar = new eventVar();
                        List<string> _modList = new List<string>();
                        foreach (string item in modListMod.SelectedItems)
                        {
                            _modList.Add(item);
                        }
                        _eventVar.eventName = txtmissionNameMod.Text;
                        _eventVar.eventDate = Convert.ToDateTime(eventCalendarMod.SelectedDate);
                        _eventVar.eventMap = comboMapMod.SelectedItem.ToString();
                        _eventVar.eventType = comboTypeMod.SelectedItem.ToString();
                        _eventVar.eventMinPlayers = Convert.ToInt16(nudPlayersMod.Value);
                        _eventVar.eventDescription = txtmissionDescriptionMod.Text;
                        _eventVar.eventMods = _modList.ToArray();
                        List<string> subs = new List<string>();
                        string[] _subs = null;
                        foreach (string sub in eventListViewSubs.Items)
                        {
                            subs.Add(sub);
                        }

                        _subs = subs.ToArray();

                        _eventVar.eventSubscribers = _subs;

                        string eventFileName = txtmissionNameMod.Text.Replace(" ", "_") + "_" + Convert.ToString(_eventVar.eventDate).Replace(" 00:00:00", "").Replace("/", "-") + "_" + _eventVar.eventMap;

                        if (System.IO.File.Exists(workingDir + "\\Config\\" + _eventFileName))
                        {
                            System.IO.File.Delete(workingDir + "\\Config\\" + _eventFileName);
                        }
                        Core.Events.MissionFile.Create.File(eventFileName, _eventVar);
                        Core.Events.MissionFile.Upload.File(eventFileName);
                        List<string> eventsList = new List<string>();
                        if (config.events != null)
                        {
                            foreach (string item in config.events)
                            {
                                eventsList.Add(item);
                            }
                            if (config.events.Contains(_eventFileName))
                            {
                                eventsList.Remove(_eventFileName);

                            }
                        }
                        eventsList.Add(eventFileName);
                        config.events = eventsList.ToArray();
                        Core.JsonUpdate.Create.File();
                        Core.JsonUpdate.Upload.File();


                    }));

                }
                catch (Exception ex)
                { System.Windows.MessageBox.Show(ex.ToString()); }
            };
            bgWorker.RunWorkerCompleted += async (s, ee) =>
            {
                pause(5);
                await _controller.CloseAsync();
                eventUpdating = true;
                this.eventListView.Items.Clear();
                this.eventListView.Items.Refresh();

                eventloadBase();
                eventUpdating = false;
            };

            bgWorker.RunWorkerAsync();
            _controller = await this.ShowProgressAsync("Please wait...", "Creating Online Event...");
            _controller.SetCancelable(false);
            _controller.SetIndeterminate();
        }
예제 #4
0
 void modEventCompile(eventVar _event)
 {
     txtmissionNameMod.Text = _event.eventName.ToString();
     eventCalendarMod.SelectedDate = Convert.ToDateTime(_event.eventDate);
     comboMapMod.SelectedItem = _event.eventMap;
     comboTypeMod.SelectedItem = _event.eventType;
     nudPlayersMod.Value = Convert.ToInt16(_event.eventMinPlayers);
     txtmissionDescriptionMod.Text = _event.eventDescription;
     foreach(string item in _event.eventMods)
     {
         modListMod.SelectedItems.Add(item);
     }
 }