private void ExpiringProductRefreshScenario()
 {
     LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
     if (licenseInformation.IsActive)
     {
         if (licenseInformation.IsTrial)
         {
             rootPage.NotifyUser("You don't have full license", NotifyType.ErrorMessage);
         }
         else
         {
             var productLicense1 = licenseInformation.ProductLicenses["product1"];
             if (productLicense1.IsActive)
             {
                 var longdateTemplate = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longdate");
                 Product1Message.Text = "Product 1 expires on: " + longdateTemplate.Format(productLicense1.ExpirationDate);
                 var remainingDays = (productLicense1.ExpirationDate - DateTime.Now).Days;
                 rootPage.NotifyUser("Product 1 expires in: " + remainingDays + " days.", NotifyType.StatusMessage);
             }
             else
             {
                 rootPage.NotifyUser("Product 1 is not available.", NotifyType.ErrorMessage);
             }
         }
     }
     else
     {
         rootPage.NotifyUser("You don't have active license.", NotifyType.ErrorMessage);
     }
 }
Ejemplo n.º 2
0
        private void PopToast(string text)
        {
            // create and send local notificatio  with new app version
            var xmlString = string.Format(@"
                            <toast>  
                                <visual>
                                    <binding template='ToastGeneric'>                                        
                                        <text>BG task result: {0}</text>
                                    </binding>      
                                </visual>
                            </toast>",
                                          text);

            var            longTime         = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            DateTimeOffset expiryTime       = DateTime.Now.AddSeconds(8);
            string         expiryTimeString = longTime.Format(expiryTime);

            XmlDocument toastXml = new XmlDocument();

            toastXml.LoadXml(xmlString);

            // Set the duration on the toast
            IXmlNode toastNode = toastXml.SelectSingleNode("/toast");

            ((XmlElement)toastNode).SetAttribute("duration", "long");

            // Create the actual toast object using this toast specification.
            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = expiryTime;

            // Send the toast
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Ejemplo n.º 3
0
        string getTimeStampedMessage(string eventText)
        {
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter dateTimeFormat = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            string dateTime = dateTimeFormat.Format(DateTime.Now);

            return(eventText + "   " + dateTime);
        }
Ejemplo n.º 4
0
        private async void WriteAppdata_Click(object sender, RoutedEventArgs e)
        {
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            StorageFile sampleFile = await localFolder.CreateFileAsync(dataFileName, CreationCollisionOption.OpenIfExists);

            await FileIO.AppendLinesAsync(sampleFile, new string[] { formatter.Format(DateTime.Now) });
        }
        private void ExpiringProductRefreshScenario()
        {
            LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;

            if (licenseInformation.IsActive)
            {
                if (licenseInformation.IsTrial)
                {
                    rootPage.NotifyUser("You don't have full license", NotifyType.ErrorMessage);
                }
                else
                {
                    var productLicense1 = licenseInformation.ProductLicenses["product1"];
                    if (productLicense1.IsActive)
                    {
                        var longdateTemplate = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longdate");
                        Product1Message.Text = "Product 1 expires on: " + longdateTemplate.Format(productLicense1.ExpirationDate);
                        var remainingDays = (productLicense1.ExpirationDate - DateTime.Now).Days;
                        rootPage.NotifyUser("Product 1 expires in: " + remainingDays + " days.", NotifyType.StatusMessage);
                    }
                    else
                    {
                        rootPage.NotifyUser("Product 1 is not available.", NotifyType.ErrorMessage);
                    }
                }
            }
            else
            {
                rootPage.NotifyUser("You don't have active license.", NotifyType.ErrorMessage);
            }
        }
Ejemplo n.º 6
0
        // Method to update the Live Tile with the latest Score information
        private void UpdateLiveTile()
        {
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter _formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            string _timePlayed = _formatter.Format(DateTime.Now).ToString();

            // Get tile template - small tile
            XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText04);

            // Set tile info
            XmlNodeList tileText = tileXml.GetElementsByTagName("text");

            tileText[0].InnerText = "Last Played: " + _timePlayed;

            // Wide tile
            XmlDocument wideTileXml  = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideImageAndText02);
            XmlNodeList wideTileText = wideTileXml.GetElementsByTagName("text");

            wideTileText[0].InnerText = "Last Played: " + _timePlayed;
            wideTileText[1].InnerText = "Highest Score: " + m_highScores[0].ToString();

            // Add the wide tile to the square tiles payload by retrieving the binding element
            IXmlNode node = tileXml.ImportNode(wideTileXml.GetElementsByTagName("binding").Item(0), true);

            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

            // Apply the tile
            TileNotification tileNotification = new TileNotification(tileXml);

            // Update the app tile
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
        void UpdateTileExpiring_Click(object sender, RoutedEventArgs e)
        {
            int seconds;

            if (!Int32.TryParse(Time.Text, out seconds))
            {
                seconds = 10;
            }

            Windows.Globalization.Calendar cal = new Windows.Globalization.Calendar();
            cal.SetToNow();
            cal.AddSeconds(seconds);

            var            longTime         = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            DateTimeOffset expiryTime       = cal.GetDateTime();
            string         expiryTimeString = longTime.Format(expiryTime);

            ITileWideText04 tileContent = TileContentFactory.CreateTileWideText04();

            tileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;

            ITileSquareText04 squareTileContent = TileContentFactory.CreateTileSquareText04();

            squareTileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;
            tileContent.SquareContent           = squareTileContent;

            TileNotification tileNotification = tileContent.CreateNotification();

            // set the expirationTime
            tileNotification.ExpirationTime = expiryTime;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            OutputTextBlock.Text = "Tile notification sent. It will expire at " + expiryTimeString;
        }
Ejemplo n.º 8
0
 private void ExpiringProductRefreshScenario()
 {
     var task = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
         if (licenseInformation.IsActive)
         {
             if (licenseInformation.IsTrial)
             {
                 rootPage.NotifyUser("You don't have a full license to this app.", NotifyType.ErrorMessage);
             }
             else
             {
                 var productLicense1 = licenseInformation.ProductLicenses["product1"];
                 if (productLicense1.IsActive)
                 {
                     var longdateTemplate = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longdate");
                     Product1Message.Text = "Product 1 expires on " + longdateTemplate.Format(productLicense1.ExpirationDate) + ". Days remaining: " + (productLicense1.ExpirationDate - DateTime.Now).Days;
                 }
                 else
                 {
                     rootPage.NotifyUser("Product 1 is not available.", NotifyType.ErrorMessage);
                 }
             }
         }
         else
         {
             rootPage.NotifyUser("You don't have active license.", NotifyType.ErrorMessage);
         }
     });
 }
 private void ExpiringProductRefreshScenario()
 {
     var task = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
         if (licenseInformation.IsActive)
         {
             if (licenseInformation.IsTrial)
             {
                 rootPage.NotifyUser("You don't have a full license to this app.", NotifyType.ErrorMessage);
             }
             else
             {
                 var productLicense1 = licenseInformation.ProductLicenses["product1"];
                 if (productLicense1.IsActive)
                 {
                     var longdateTemplate = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longdate");
                     Product1Message.Text = "Product 1 expires on " + longdateTemplate.Format(productLicense1.ExpirationDate) + ". Days remaining: " + (productLicense1.ExpirationDate - DateTime.Now).Days;
                 }
                 else
                 {
                     rootPage.NotifyUser("Product 1 is not available.", NotifyType.ErrorMessage);
                 }
             }
         }
         else
         {
             rootPage.NotifyUser("You don't have active license.", NotifyType.ErrorMessage);
         }
     });
 }
        private void Initialize()
        {
            // Clear all existing notifications
            ToastNotificationManager.History.Clear();

            var longTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            DateTimeOffset expiryTime = DateTime.Now.AddSeconds(30);
            string expiryTimeString = longTime.Format(expiryTime);

            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            //Find the text component of the content
            XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");

            // Set the text on the toast. 
            // The first line of text in the ToastText02 template is treated as header text, and will be bold.
            toastTextElements[0].AppendChild(toastXml.CreateTextNode("Expiring Toast"));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode("It will expire at " +  expiryTimeString));

            // Set the duration on the toast
            IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
            ((XmlElement)toastNode).SetAttribute("duration", "long");

            // Create the actual toast object using this toast specification.
            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = expiryTime;

            // Send the toast.
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Ejemplo n.º 11
0
        private void Initialize()
        {
            // Clear all existing notifications
            ToastNotificationManager.History.Clear();

            var            longTime         = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            DateTimeOffset expiryTime       = DateTime.Now.AddSeconds(30);
            string         expiryTimeString = longTime.Format(expiryTime);

            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            //Find the text component of the content
            XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");

            // Set the text on the toast.
            // The first line of text in the ToastText02 template is treated as header text, and will be bold.
            toastTextElements[0].AppendChild(toastXml.CreateTextNode("Expiring Toast"));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode("It will expire at " + expiryTimeString));

            // Set the duration on the toast
            IXmlNode toastNode = toastXml.SelectSingleNode("/toast");

            ((XmlElement)toastNode).SetAttribute("duration", "long");

            // Create the actual toast object using this toast specification.
            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = expiryTime;

            // Send the toast.
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Ejemplo n.º 12
0
        public void setTime()
        {
            var      formatter    = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("month day dayofweek year hour minute second");
            DateTime dateToFormat = DateTime.Now;
            var      mydate       = formatter.Format(dateToFormat);

            textBlock1.Text = mydate.ToString();
        }
Ejemplo n.º 13
0
        private async void WriteTimestamp()
        {
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter =
                new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");

            StorageFile sampleFile = await localFolder.CreateFileAsync("dataFile.txt", CreationCollisionOption.OpenIfExists);

            await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTimeOffset.Now));
        }
Ejemplo n.º 14
0
        async void WriteTimestamp()
        {
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");

            StorageFile sampleFile = await localFolder.CreateFileAsync("favoris.txt", CreationCollisionOption.ReplaceExisting);
            await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));
        }
Ejemplo n.º 15
0
        async void WriteTimestamp()
        {
            Debug.WriteLine("\nTrying!!");

            StorageFolder localFolder = ApplicationData.Current.LocalFolder;

            Debug.WriteLine("Local Folder: " + localFolder.ToString());

            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            Debug.WriteLine("Created DateTime: " + formatter.Format(DateTimeOffset.Now));

            StorageFile configFile = await localFolder.CreateFileAsync("dataFile.txt", CreationCollisionOption.ReplaceExisting);

            Debug.WriteLine("Created Sample file: " + configFile.ToString());

            await FileIO.WriteTextAsync(configFile, formatter.Format(DateTimeOffset.Now));

            Debug.WriteLine("Finished Writing the timestamp!\n");
        }
 public MainPage()
 {
     this.InitializeComponent();
     //Get Date time in the format we need
     var dateTimeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("month day dayofweek year");
     dateLbl.Text = dateTimeFormatter.Format(DateTime.Now);
     //Get currency, get the current user one
     var userCurrency = Windows.System.UserProfile.GlobalizationPreferences.Currencies;
     var currencyFormatter = new Windows.Globalization.NumberFormatting.CurrencyFormatter(userCurrency[0]);
     currencyLbl.Text=currencyFormatter.Format(10.57);
 }
Ejemplo n.º 17
0
        public static string GetDateTime()
        {
            var shortDateFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
            var shortTimeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");

            var dateTimeToFormat = DateTime.Now;

            var shortDate = shortDateFormatter.Format(dateTimeToFormat);
            var shortTime = shortTimeFormatter.Format(dateTimeToFormat);

            return(shortDate + " " + shortTime);
        }
Ejemplo n.º 18
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            Windows.Storage.StorageFolder            localFolder   = Windows.Storage.ApplicationData.Current.LocalFolder;
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter =
                new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");

            StorageFile sampleFile = await localFolder.CreateFileAsync("dataFile.txt",
                                                                       CreationCollisionOption.ReplaceExisting);

            await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));
        }
        private async void Button_Click_10(object sender, RoutedEventArgs e)
        {
            var      dtf = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("dayofweek day month year");
            DateTime now = DateTime.Now;

            tbTime.Text = dtf.Format(now);
            //var rass = RandomAccessStreamReference.CreateFromUri(new Uri(this.baseUri, "/Images/6dc470d7jw1dse92lrac2g.gif"));
            //var rass = RandomAccessStreamReference.CreateFromUri(new Uri(this.baseUri, "Images/amy.jpg"));
            var rass         = RandomAccessStreamReference.CreateFromUri(new Uri(this.baseUri, "/Images/ceshi123.gif"));
            var streamRandom = await rass.OpenReadAsync();

            await imageGif.SetSourceAsync(streamRandom);
        }
Ejemplo n.º 20
0
        private void Draw(object sender, object e)
        {
            //var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            //DateTime dateToFormat = DateTime.Now;
            //TimeTxt.Text = formatter.Format(dateToFormat);
            //TimeTxt.Text = DateTime.Now.ToString("HH:mm:ss");

            //DateTime myTime = DateTime.Now;
            //TimeTxt.Text = myTime.ToLongTimeString();//ToString("t");

            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}");
            DateTime dateToFormat = DateTime.Now;
            TimeTxt.Text = formatter.Format(dateToFormat);
        }
Ejemplo n.º 21
0
        private void Draw(object sender, object e)
        {
            //var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            //DateTime dateToFormat = DateTime.Now;
            //TimeTxt.Text = formatter.Format(dateToFormat);
            //TimeTxt.Text = DateTime.Now.ToString("HH:mm:ss");

            //DateTime myTime = DateTime.Now;
            //TimeTxt.Text = myTime.ToLongTimeString();//ToString("t");

            var      formatter    = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}");
            DateTime dateToFormat = DateTime.Now;

            TimeTxt.Text = formatter.Format(dateToFormat);
        }
        public MainPage()
        {
            this.InitializeComponent();

            // My code
            //IReadOnlyList<string> userLanguages = GlobalizationPreferences.Languages;
            var userLanguages      = GlobalizationPreferences.Languages[0];
            var shortDateFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
            var shortTimeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
            var userCurrency       = GlobalizationPreferences.Currencies[0];
            var userRegion         = GlobalizationPreferences.HomeGeographicRegion;
            var userCalendar       = GlobalizationPreferences.Calendars[0];
            var userWeekStart      = GlobalizationPreferences.WeekStartsOn;
            var userClock          = GlobalizationPreferences.Clocks[0];
            var langDetails        = GlobalizationPreferences.Languages[1];
            var dateTimeToFormat   = DateTime.Now;

            string results = $"Short Date: {shortDateFormatter.Format(dateTimeToFormat)}\n" +
                             $"Short Time: {shortTimeFormatter.Format(dateTimeToFormat)}";

            // Get the user's geographic region and its display name.
            var displayGeo = new GeographicRegion().DisplayName;

            // Loading resources from Resources.resw
            var loader   = new Windows.ApplicationModel.Resources.ResourceLoader();
            var lang     = loader.GetString("chosen_lang");
            var home     = loader.GetString("home_region");
            var calendar = loader.GetString("calendar_setting");
            var clock    = loader.GetString("clock_setting");
            var week     = loader.GetString("week_start");
            var lang_d   = loader.GetString("lang_details");
            var geo      = loader.GetString("geo_details");

            //Globalization Preferences
            chosen_lang.Text      += $"{lang}: {userLanguages}\n";
            home_region.Text      += $"{home}: {userRegion}\n";
            calendar_setting.Text += $"{calendar}: {userCalendar}\n";
            clock_setting.Text    += $"{clock}: {userClock}\n";
            week_start.Text       += $"{week}: {userWeekStart}\n";

            //Language Specifics
            lang_details.Text = $"{lang_d}: {langDetails}\n";

            //Geo Region Specifics
            geo_details.Text = $"{geo}: {displayGeo}\n" +
                               $"User currency: {userCurrency}\n" +
                               results;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            navigationHelper.OnNavigatedTo(e);
            person = e.Parameter as XElement;
            txtPersonInfo.Text = person.Element("Last-Name").Value.ToString() + ", " + person.Element("First-Name").Value.ToString();
            txtCompany.Text = person.Element("Company-Represented").Value.ToString();

            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
            var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
            DateTime dateToFormat = DateTime.Now;

            var thedate = formatter.Format(dateToFormat);
            var thetime = formatterTime.Format(dateToFormat);

            txtDatetime.Text = thedate + " " + thetime;
        }
        void UpdateTileExpiring_Click(object sender, RoutedEventArgs e)
        {
            int seconds;

            if (!Int32.TryParse(Time.Text, out seconds))
            {
                seconds = 10;
            }

            Windows.Globalization.Calendar cal = new Windows.Globalization.Calendar();
            cal.SetToNow();
            cal.AddSeconds(seconds);

            var            longTime         = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            DateTimeOffset expiryTime       = cal.GetDateTime();
            string         expiryTimeString = longTime.Format(expiryTime);

            // Create a notification for the Square310x310 tile using one of the available templates for the size.
            ITileSquare310x310Text09 tileSquare310x310Content = TileContentFactory.CreateTileSquare310x310Text09();

            tileSquare310x310Content.TextHeadingWrap.Text = "This notification will expire at " + expiryTimeString;

            // Create a notification for the Wide310x150 tile using one of the available templates for the size.
            ITileWide310x150Text04 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text04();

            wide310x150TileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;

            // Create a notification for the Square150x150 tile using one of the available templates for the size.
            ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04();

            square150x150TileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;

            // Attach the Square150x150 template to the Wide310x150 template.
            wide310x150TileContent.Square150x150Content = square150x150TileContent;

            // Attach the Wide310x150 template to the Square310x310 template.
            tileSquare310x310Content.Wide310x150Content = wide310x150TileContent;

            TileNotification tileNotification = tileSquare310x310Content.CreateNotification();

            // Set the expiration time and update the tile.
            tileNotification.ExpirationTime = expiryTime;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            rootPage.NotifyUser("Tile notification sent. It will expire at " + expiryTime, NotifyType.StatusMessage);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Converts date to string
 /// </summary>
 /// <param name="value">The source data being passed to the target.</param>
 /// <param name="targetType">The type of the target property, as a type reference </param>
 /// <param name="parameter">An optional parameter to be used in the converter logic.</param>
 /// <param name="language">The language of the conversion.</param>
 /// <returns>The value to be passed to the target dependency property.</returns>
 public object Convert( object value, Type targetType, object parameter, string language )
 {
     string twString = "";
     if( (DateTime)value >= DateTime.Today )
     {
         twString = this._resourceLoader.GetString( "TimeWindow/Today" );
     }
     else if( (DateTime)value >= (DateTime.Today - TimeSpan.FromDays( 1) ) )
     {
         twString = this._resourceLoader.GetString( "TimeWindow/Yesterday" );
     }
     else
     {
         var sdatefmt = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter( "shortdate" );
         twString = sdatefmt.Format( (DateTime)value );
     }
     return twString;
 }
Ejemplo n.º 26
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var loader = ResourceLoader.GetForCurrentView();

            DynamicText.Text = loader.GetString("Dynamic");

            var currencyText      = loader.GetString("Dollars");
            var currencyFormatter =
                new CurrencyFormatter(Windows.System.UserProfile.GlobalizationPreferences.Currencies[0]);

            Currency.Text = string.Format(currencyText, currencyFormatter.Format(CurrencyValue));

            var dateFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
            var timeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");

            Date.Text = dateFormatter.Format(DateTime.Now);
            Time.Text = timeFormatter.Format(DateTime.Now);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Converts date to string
        /// </summary>
        /// <param name="value">The source data being passed to the target.</param>
        /// <param name="targetType">The type of the target property, as a type reference </param>
        /// <param name="parameter">An optional parameter to be used in the converter logic.</param>
        /// <param name="language">The language of the conversion.</param>
        /// <returns>The value to be passed to the target dependency property.</returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            string twString = "";

            if ((DateTime)value >= DateTime.Today)
            {
                twString = this._resourceLoader.GetString("TimeWindow/Today");
            }
            else if ((DateTime)value >= (DateTime.Today - TimeSpan.FromDays(1)))
            {
                twString = this._resourceLoader.GetString("TimeWindow/Yesterday");
            }
            else
            {
                var sdatefmt = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                twString = sdatefmt.Format((DateTime)value);
            }
            return(twString);
        }
Ejemplo n.º 28
0
        async void txtName_KeyUp(object sender, KeyRoutedEventArgs e)
        {

            StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("logdata.xml");

            lvItems.Items.Clear();

            //   Debug.WriteLine("Attempting to read file  " + file.Path + " into xdocument");
            XDocument doc = XDocument.Load(file.Path);
            var ps = (
                from actions in doc.Root.Elements("Action").Elements("Person")
                select actions
            );
            if(txtName.Text.Count() > 0 ) {
                    IEnumerable<XElement> persons = (
                        from actions in doc.Root.Elements("Action")
                        where (string)actions.Attribute("type") == "Scheduled Visit"
                        from person in actions.Elements("Person")
                        where (person.Element("First-Name").Value.ToUpper().Contains(txtName.Text.ToUpper()) || person.Element("Last-Name").Value.ToUpper().Contains(txtName.Text.ToUpper()))

                        from dates in person.Elements("Date")
                        orderby DateTime.Parse(person.Element("Time-In").Value) ascending
                         where Convert.ToDateTime(dates.Value).Date == DateTime.Now.Date
                        select person
                    );

                    foreach (XElement signin in persons)
                    {
                        ScheduledVisitTile tile = new ScheduledVisitTile();
                        tile.person = signin;
                        tile.txtName.Text = signin.Element("Last-Name").Value.ToString() + ", " + signin.Element("First-Name").Value.ToString();
                        tile.txtCompany.Text = signin.Element("Company-Represented").Value.ToString();
                        var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                        var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
                        DateTime dateToFormat = Convert.ToDateTime(signin.Element("Time-In").Value.ToString());
                        var thedate = formatter.Format(dateToFormat);
                        var thetime = formatterTime.Format(dateToFormat);
                        tile.txtDate.Text = thedate + " " + thetime;
                        lvItems.Items.Add(tile);
                    }
                }

        }
        void UpdateTileExpiring_Click(object sender, RoutedEventArgs e)
        {
            int seconds;
            if (!Int32.TryParse(Time.Text, out seconds))
            {
                seconds = 10;
            }

            Windows.Globalization.Calendar cal = new Windows.Globalization.Calendar();
            cal.SetToNow();
            cal.AddSeconds(seconds);

            var longTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
            DateTimeOffset expiryTime = cal.GetDateTime();
            string expiryTimeString = longTime.Format(expiryTime);

            // Create a notification for the Square310x310 tile using one of the available templates for the size.
            ITileSquare310x310Text09 tileSquare310x310Content = TileContentFactory.CreateTileSquare310x310Text09();
            tileSquare310x310Content.TextHeadingWrap.Text = "This notification will expire at " + expiryTimeString;

            // Create a notification for the Wide310x150 tile using one of the available templates for the size.
            ITileWide310x150Text04 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text04();
            wide310x150TileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;

            // Create a notification for the Square150x150 tile using one of the available templates for the size.
            ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04();
            square150x150TileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString;

            // Attach the Square150x150 template to the Wide310x150 template.
            wide310x150TileContent.Square150x150Content = square150x150TileContent;

            // Attach the Wide310x150 template to the Square310x310 template.
            tileSquare310x310Content.Wide310x150Content = wide310x150TileContent;

            TileNotification tileNotification = tileSquare310x310Content.CreateNotification();

            // Set the expiration time and update the tile.
            tileNotification.ExpirationTime = expiryTime;
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

            rootPage.NotifyUser("Tile notification sent. It will expire at " + expiryTime, NotifyType.StatusMessage);
        }
Ejemplo n.º 30
0
        public EventHome()
        {
            db      = new MyDatabase();
            _events = new List <EventModel>();

            string sid = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

            Debug.WriteLine(sid);
            InitializeComponent();
            DataContext = App.EventModel;


            FBSession session = FBSession.ActiveSession;

            if (session != null && App.username_sqlite == null)
            {
                try
                {
                    string username = session.User.Name;
                    Debug.WriteLine("hi" + username);
                    usernameTxt.Text = "Hi " + username + " Welcome To the Event Manager";
                }
                catch
                {
                }
            }
            else
            {
                usernameTxt.Text = "Hi " + App.username_sqlite + " : Welcome To the Event Manager";
            }



            if (App.EventModel.EventAddress != null && App.EventModel.EventStartTime != null && App.EventModel.EventName != null)
            {
                ev_address.Text = App.EventModel.EventName + "  @  " + App.EventModel.EventAddress;
                var dateFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{month.full} {day.integer}");
                var eventdate     = dateFormatter.Format(App.EventModel.EventStartTime);
                ev_time.Text = eventdate + "  At  " + App.EventModel.EventDuration;
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Populate day selection list
        /// </summary>
        private void PopulateDaySelectionList()
        {
            GeographicRegion userRegion = new GeographicRegion();
            var userDateFormat          = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate", new[] { userRegion.Code });

            for (int i = 0; i < 7; i++)
            {
                var nameOfDay = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[((int)DateTime.Now.DayOfWeek + 7 - i) % 7];
                if (i == 0)
                {
                    nameOfDay += " " + _resourceLoader.GetString("Today");
                }
                DateTime itemDate = DateTime.Now.Date - TimeSpan.FromDays(i);
                _daySelectionList.Add(
                    new DaySelectionItem(
                        nameOfDay + " " + userDateFormat.Format(itemDate),
                        itemDate));
            }
            // Add the option to show everything
            _daySelectionList.Add(new DaySelectionItem(_resourceLoader.GetString("All"), null));
        }
Ejemplo n.º 32
0
        public static async Task RefreshJumplistAsync()
        {
            if (!JumpList.IsSupported())
            {
                return;
            }
            var jl = await JumpList.LoadCurrentAsync();

            foreach (var item in jl.Items)
            {
                if (item.RemovedByUser && item.GroupName == RECENT_GROUP_NAME)
                {
                    HistoryDb.Remove(new Uri(item.Arguments));
                }
            }
            jl.Items.Clear();
            using (var db = new HistoryDb())
            {
                var          records     = db.HistorySet.OrderByDescending(r => r.TimeStamp).Take(50).ToArray();
                var          added       = new HashSet <HistoryRecord>(HistoryRecordComparer.Instance);
                var          dtformatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate shorttime");
                const string sep         = " - ";
                foreach (var record in records)
                {
                    if (!added.Add(record))
                    {
                        continue;
                    }
                    var item = JumpListItem.CreateWithArguments(record.Uri.ToString(), record.ToDisplayString());
                    item.GroupName   = RECENT_GROUP_NAME;
                    item.Logo        = new Uri($"ms-appx:///Assets/JumpList/{record.Type.ToString()}.png");
                    item.Description = item.DisplayName + sep + dtformatter.Format(record.Time);
                    jl.Items.Add(item);
                }
            }
            await jl.SaveAsync();
        }
        private async void ButtonSendNotification_Click(object sender, RoutedEventArgs e)
        {
            base.IsEnabled = false;

            try
            {
                if (_tileId == null)
                {
                    await new MessageDialog("No secondary tile was pinned. In the previous step, you had to pin the tile.", "Error").ShowAsync();
                    return;
                }

                SecondaryTile tile = (await SecondaryTile.FindAllAsync()).FirstOrDefault(i => i.TileId.Equals(_tileId));
                if (tile == null)
                {
                    await new MessageDialog("The secondary tile that was previously pinned could not be found. Has it been removed from Start?", "Error").ShowAsync();
                    return;
                }

                // Decide expiration time
                Windows.Globalization.Calendar cal = new Windows.Globalization.Calendar();
                cal.SetToNow();
                cal.AddSeconds(20);

                // Get expiration time and date
                var longTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
                DateTimeOffset expiryTime = cal.GetDateTime();
                string expiryTimeString = longTime.Format(expiryTime);

                // Create the custom tile that will expire
                string tileXmlString = 
                "<tile>"
                + "<visual>"
                + "<binding template='TileMedium'>"
                + "<text hint-wrap='true'>This notification will expire at " + expiryTimeString + "</text>"
                + "</binding>"
                + "<binding template='TileWide'>"
                + "<text hint-wrap='true'>This notification will expire at " + expiryTimeString + "</text>"
                + "</binding>"
                + "<binding template='TileLarge'>"
                + "<text hint-wrap='true'>This notification will expire at " + expiryTimeString + "</text>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(tileXmlString);

                // Create the notification
                TileNotification notifyTile = new TileNotification(xmlDoc);

                // Set expiration time for the notification
                notifyTile.ExpirationTime = expiryTime;

                // And send the notification to the tile
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notifyTile);
            }

            catch (Exception ex)
            {
                await new MessageDialog(ex.ToString(), "Error updating tile").ShowAsync();
            }

            finally
            {
                base.IsEnabled = true;
            }
        }
        private async void ButtonSendNotification_Click(object sender, RoutedEventArgs e)
        {
            base.IsEnabled = false;

            try
            {
                if (_tileId == null)
                {
                    await new MessageDialog("No secondary tile was pinned. In the previous step, you had to pin the tile.", "Error").ShowAsync();
                    return;
                }

                SecondaryTile tile = (await SecondaryTile.FindAllAsync()).FirstOrDefault(i => i.TileId.Equals(_tileId));
                if (tile == null)
                {
                    await new MessageDialog("The secondary tile that was previously pinned could not be found. Has it been removed from Start?", "Error").ShowAsync();
                    return;
                }

                // Decide expiration time
                Windows.Globalization.Calendar cal = new Windows.Globalization.Calendar();
                cal.SetToNow();
                cal.AddSeconds(20);

                // Get expiration time and date
                var            longTime         = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
                DateTimeOffset expiryTime       = cal.GetDateTime();
                string         expiryTimeString = longTime.Format(expiryTime);

                // Create the custom tile that will expire
                string tileXmlString =
                    "<tile>"
                    + "<visual>"
                    + "<binding template='TileMedium'>"
                    + "<text hint-wrap='true'>This notification will expire at " + expiryTimeString + "</text>"
                    + "</binding>"
                    + "<binding template='TileWide'>"
                    + "<text hint-wrap='true'>This notification will expire at " + expiryTimeString + "</text>"
                    + "</binding>"
                    + "<binding template='TileLarge'>"
                    + "<text hint-wrap='true'>This notification will expire at " + expiryTimeString + "</text>"
                    + "</binding>"
                    + "</visual>"
                    + "</tile>";

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(tileXmlString);

                // Create the notification
                TileNotification notifyTile = new TileNotification(xmlDoc);

                // Set expiration time for the notification
                notifyTile.ExpirationTime = expiryTime;

                // And send the notification to the tile
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notifyTile);
            }

            catch (Exception ex)
            {
                await new MessageDialog(ex.ToString(), "Error updating tile").ShowAsync();
            }

            finally
            {
                base.IsEnabled = true;
            }
        }
Ejemplo n.º 35
0
        private async void ReserveEvent(object sender, RoutedEventArgs e)
        {
            if (control_calendar.Date != null)
            {
                var new_event = new EventModel()
                {
                    EventStartTime = control_calendar.Date.Value.Date,
                    EventDuration  = control_time.Time,
                    //EventName = control_name.Text,
                    EventName = (_linedUpEvents.SelectedItem
                                 as ComboBoxItem).Content as string,
                    EventAddress    = "",
                    EventInviteText = "",
                    RSVPEmail       = "",
                };



                App.EventModel = new_event;
                if (new_event.EventName == "John's Band Night")
                {
                    new_event.EventAddress = "Pike Place Market, Vancouver";

                    new_event.RSVPEmail = "*****@*****.**";
                }
                if (new_event.EventName == "Hackathon")
                {
                    new_event.EventAddress = "NewFoundland Place Market, Montreal";
                    new_event.RSVPEmail    = "*****@*****.**";
                }
                if (new_event.EventName == "Ariana Grande Musical")
                {
                    new_event.EventAddress = "Playdium Centre, Toronto";
                    new_event.RSVPEmail    = "*****@*****.**";
                }
                if (new_event.EventName == "Microsoft Ignite")
                {
                    new_event.EventAddress = "Celebration Centre, Ottawa";
                    new_event.RSVPEmail    = "*****@*****.**";
                }
                _events.Add(new_event);
                MessageDialog md =
                    new MessageDialog($"{_events.Count} event reserved\n" +
                                      "You have your event booked on " + $"{new_event.EventStartTime.Month}/" +
                                      $"{new_event.EventStartTime.Day}/" +
                                      $"{new_event.EventStartTime.Year}" +
                                      $" at {new_event.EventDuration}" +
                                      $"for {new_event.EventName}");
                await md.ShowAsync();

                ev_address.Text = new_event.EventName + "  @  " + new_event.EventAddress;
                var dateFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{month.full} {day.integer}");
                var eventdate     = dateFormatter.Format(new_event.EventStartTime);
                ev_time.Text          = eventdate + "  At  " + new_event.EventDuration;
                control_calendar.Date = null;
            }
            else
            {
                MessageDialog md =
                    new MessageDialog("Select a day first");
                await md.ShowAsync();
            }
        }
Ejemplo n.º 36
0
        private async Task GetGeofenceStateChangedReports(Geoposition pos)
        {
            _geofenceBackgroundEvents.Clear();
            FillEventCollectionWithExistingEvents();

            GeofenceMonitor monitor      = GeofenceMonitor.Current;
            Geoposition     posLastKnown = monitor.LastKnownGeoposition;

            Windows.Globalization.Calendar calendar = new Windows.Globalization.Calendar();
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatterLongTime;
            formatterLongTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", new[] { "hr-HR" }, "HR", Windows.Globalization.CalendarIdentifiers.Gregorian, Windows.Globalization.ClockIdentifiers.TwentyFourHour);

            bool eventOfInterest = true;

            // NOTE TO DEVELOPER:
            // Registered geofence events can be filtered out if the
            // geofence event time is stale.
            var eventDateTime = pos.Coordinate.Timestamp;

            calendar.SetToNow();
            var nowDateTime  = calendar.GetDateTime();
            var diffTimeSpan = nowDateTime - eventDateTime;

            var deltaInSeconds = diffTimeSpan.TotalSeconds;

            if (deltaInSeconds > 120)
            {
                eventOfInterest = false;
            }

            if (eventOfInterest)
            {
                // NOTE TO DEVELOPER:
                // This event can be filtered out if the
                // geofence event location is too far away.
                var distance = 0.0d;

                if ((posLastKnown.Coordinate.Point.Position.Latitude != pos.Coordinate.Point.Position.Latitude) ||
                    (posLastKnown.Coordinate.Point.Position.Longitude != pos.Coordinate.Point.Position.Longitude))
                {
                    distance = new HaversineFormula().Distance(posLastKnown.Coordinate.Point.Position, pos.Coordinate.Point.Position, HaversineFormula.DistanceType.Kilometers);

                    // NOTE TO DEVELOPER:
                    // Use an algorithm like the Haversine formula or Vincenty's formulae to determine
                    // the distance between the current location (pos.Coordinate)
                    // and the location of the geofence event (latitudeEvent/longitudeEvent).
                    // If too far apart set eventOfInterest to false to
                    // filter the event out.
                }

                if (eventOfInterest)
                {
                    string geofenceItemEvent   = null;
                    int    numEventsOfInterest = 0;

                    // Retrieve a vector of state change reports
                    var reports = GeofenceMonitor.Current.ReadReports();

                    foreach (var report in reports)
                    {
                        GeofenceState state = report.NewState;
                        geofenceItemEvent = report.Geofence.Id + " " + formatterLongTime.Format(eventDateTime);

                        if (state == GeofenceState.Removed)
                        {
                            GeofenceRemovalReason reason = report.RemovalReason;
                            if (reason == GeofenceRemovalReason.Expired)
                            {
                                geofenceItemEvent += " (Removed/Expired)";
                            }
                            else if (reason == GeofenceRemovalReason.Used)
                            {
                                geofenceItemEvent += " (Removed/Used)";
                            }
                        }
                        else if (state == GeofenceState.Entered)
                        {
                            geofenceItemEvent += " (Entered)";
                        }
                        else if (state == GeofenceState.Exited)
                        {
                            geofenceItemEvent += " (Exited)";
                        }

                        geofenceItemEvent += $" - {deltaInSeconds}";
                        geofenceItemEvent += $"\nDistance - {distance}";

                        AddGeofenceEvent(geofenceItemEvent);
                        ++numEventsOfInterest;

                        var userLocation = new UserLocation()
                        {
                            Latitude   = report.Geoposition.Coordinate.Point.Position.Latitude,
                            Longitude  = report.Geoposition.Coordinate.Point.Position.Longitude,
                            Name       = report.Geofence.Id,
                            UpdatedUtc = eventDateTime.UtcDateTime,
                            Status     = (LocationStatus)(int)state
                        };

                        await UploadDataToCloud(userLocation);
                    }

                    if (eventOfInterest == true && numEventsOfInterest != 0)
                    {
                        SaveExistingEvents();
                        // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates.
                        //DoToast(numEventsOfInterest, geofenceItemEvent);
                    }
                }
            }
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Fill the list with current day of week, and in descending order rest of the weekdays
 /// </summary>
 private void FillDateList()
 {
     GeographicRegion userRegion = new GeographicRegion();
     var userDateFormat = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter( "shortdate", new[] { userRegion.Code } );
     for( int i = 0; i < 7; i++ )
     {
         var nameOfDay = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[ ( (int)DateTime.Now.DayOfWeek + 7 - i ) % 7 ];
         if( i == 0 )
         {
             nameOfDay += " " + _resourceLoader.GetString( "Today" );
         }
         DateTime itemDate = DateTime.Now.Date - TimeSpan.FromDays( i );
         _daySelectionList.Add( 
             new DaySelectionItem( 
                 nameOfDay + " " + userDateFormat.Format( itemDate ), 
                 itemDate ) );
     }
     // Add the option to show everything
     _daySelectionList.Add( new DaySelectionItem( _resourceLoader.GetString( "All" ), null ) );
 }
Ejemplo n.º 38
0
        private void GetGeofenceStateChangedReports(Geoposition pos)
        {
            geofenceBackgroundEvents.Clear();

            FillEventCollectionWithExistingEvents();

            GeofenceMonitor monitor = GeofenceMonitor.Current;

            Geoposition posLastKnown = monitor.LastKnownGeoposition;

            Windows.Globalization.Calendar calendar = new Windows.Globalization.Calendar();
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatterLongTime;
            formatterLongTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", new[] { "en-US" }, "US", Windows.Globalization.CalendarIdentifiers.Gregorian, Windows.Globalization.ClockIdentifiers.TwentyFourHour);

            bool eventOfInterest = true;

            // NOTE TO DEVELOPER:
            // These events can be filtered out if the
            // geofence event time is stale.
            DateTimeOffset eventDateTime = pos.Coordinate.Timestamp;

            calendar.SetToNow();
            DateTimeOffset nowDateTime = calendar.GetDateTime();

            TimeSpan diffTimeSpan = nowDateTime - eventDateTime;

            long deltaInSeconds = diffTimeSpan.Ticks / oneHundredNanosecondsPerSecond;

            // NOTE TO DEVELOPER:
            // If the time difference between the geofence event and now is too large
            // the eventOfInterest should be set to false.

            if (eventOfInterest)
            {
                // NOTE TO DEVELOPER:
                // This event can be filtered out if the
                // geofence event location is too far away.
                if ((posLastKnown.Coordinate.Point.Position.Latitude != pos.Coordinate.Point.Position.Latitude) ||
                    (posLastKnown.Coordinate.Point.Position.Longitude != pos.Coordinate.Point.Position.Longitude))
                {
                    // NOTE TO DEVELOPER:
                    // Use an algorithm like the Haversine formula or Vincenty's formulae to determine
                    // the distance between the current location (pos.Coordinate)
                    // and the location of the geofence event (latitudeEvent/longitudeEvent).
                    // If too far apart set eventOfInterest to false to
                    // filter the event out.
                }

                if (eventOfInterest)
                {
                    string geofenceItemEvent = null;

                    int numEventsOfInterest = 0;

                    // Retrieve a vector of state change reports
                    var reports = GeofenceMonitor.Current.ReadReports();

                    foreach (GeofenceStateChangeReport report in reports)
                    {
                        GeofenceState state = report.NewState;

                        geofenceItemEvent = report.Geofence.Id + " " + formatterLongTime.Format(eventDateTime);

                        if (state == GeofenceState.Removed)
                        {
                            GeofenceRemovalReason reason = report.RemovalReason;

                            if (reason == GeofenceRemovalReason.Expired)
                            {
                                geofenceItemEvent += " (Removed/Expired)";
                            }
                            else if (reason == GeofenceRemovalReason.Used)
                            {
                                geofenceItemEvent += " (Removed/Used)";
                            }
                        }
                        else if (state == GeofenceState.Entered)
                        {
                            geofenceItemEvent += " (Entered)";
                        }
                        else if (state == GeofenceState.Exited)
                        {
                            geofenceItemEvent += " (Exited)";
                        }

                        AddGeofenceEvent(geofenceItemEvent);

                        ++numEventsOfInterest;
                    }

                    if (eventOfInterest && (0 != numEventsOfInterest))
                    {
                        SaveExistingEvents();

                        // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates.
                        DoToast(numEventsOfInterest, geofenceItemEvent);
                    }
                }
            }
        }
Ejemplo n.º 39
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {

            DateTimeOffset sd = startDate.Date;
            DateTimeOffset ed = endDate.Date;
            string searchStr = txtSearchString.Text;

            Debug.WriteLine("Applying Filter...");
         

            StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("logdata.xml");
            Debug.WriteLine("Attempting to read file  " + file.Path + " into xdocument");
            XDocument doc = XDocument.Load(file.Path);
            var ps = (
                    from nodes in doc.Root.Elements("Action").Elements("Person")
                    select nodes
                );

            IEnumerable<XElement> actions = (
                  from nodes in doc.Root.Elements("Action")
                  from person in nodes.Elements("Person")
                  from dates in person.Elements("Date")
                  where (Convert.ToDateTime(person.Element("Time-In").Value) < ed.ToUniversalTime())
                  where (Convert.ToDateTime(person.Element("Time-In").Value) > sd.ToUniversalTime())
                  orderby (Convert.ToDateTime(person.Element("Date").Value)) descending
                  select nodes
              );

            Debug.WriteLine("found " + actions.Count() + "matching records.");

            theGrid.Items.Clear();

            foreach (XElement action in actions)
            {

                if (txtSearchString.Text != "" || txtCompany.Text != "" || txtHost.Text != "")
                {
                    if (txtSearchString.Text != "")
                    {
                        string filter = action.Element("Person").Element("First-Name").Value + " " + action.Element("Person").Element("Last-Name").Value;
                        if (filter.ToUpper().Contains(txtSearchString.Text.ToUpper()))
                        {
                            LogRecordTile tile = new LogRecordTile();
                            tile.txtAction.Text = action.Attribute("type").Value;
                            tile.txtName.Text = action.Element("Person").Element("First-Name").Value + " " + action.Element("Person").Element("Last-Name").Value;
                            tile.txtCompany.Text = action.Element("Person").Element("Company-Represented").Value;
                            tile.txtHost.Text = action.Element("Person").Element("Boeing-Host-Name").Value;
                            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                            var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
                            DateTime dateToFormat = Convert.ToDateTime(action.Element("Person").Element("Time-In").Value.ToString());
                            var thedate = formatter.Format(dateToFormat);
                            var thetime = formatterTime.Format(dateToFormat);
                            tile.txtDate.Text = thedate + " " + thetime;
                            theGrid.Items.Add(tile);
                        }
                    }

                    if(txtCompany.Text != ""){
                        string filter = action.Element("Person").Element("Company-Represented").Value;
                        if (filter.ToUpper().Contains(txtCompany.Text.ToUpper()))
                        {
                            LogRecordTile tile = new LogRecordTile();
                            tile.txtAction.Text = action.Attribute("type").Value;
                            tile.txtName.Text = action.Element("Person").Element("First-Name").Value + " " + action.Element("Person").Element("Last-Name").Value;
                            tile.txtCompany.Text = action.Element("Person").Element("Company-Represented").Value;
                            tile.txtHost.Text = action.Element("Person").Element("Boeing-Host-Name").Value;
                            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                            var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
                            DateTime dateToFormat = Convert.ToDateTime(action.Element("Person").Element("Time-In").Value.ToString());
                            var thedate = formatter.Format(dateToFormat);
                            var thetime = formatterTime.Format(dateToFormat);
                            tile.txtDate.Text = thedate + " " + thetime;
                            theGrid.Items.Add(tile);
                        }
                    }

                    if (txtHost.Text != "")
                    {
                        string filter = action.Element("Person").Element("Boeing-Host-Name").Value;
                        if (filter.ToUpper().Contains(txtHost.Text.ToUpper()))
                        {
                            LogRecordTile tile = new LogRecordTile();
                            tile.txtAction.Text = action.Attribute("type").Value;
                            tile.txtName.Text = action.Element("Person").Element("First-Name").Value + " " + action.Element("Person").Element("Last-Name").Value;
                            tile.txtCompany.Text = action.Element("Person").Element("Company-Represented").Value;
                            tile.txtHost.Text = action.Element("Person").Element("Boeing-Host-Name").Value;
                            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                            var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
                            DateTime dateToFormat = Convert.ToDateTime(action.Element("Person").Element("Time-In").Value.ToString());
                            var thedate = formatter.Format(dateToFormat);
                            var thetime = formatterTime.Format(dateToFormat);
                            tile.txtDate.Text = thedate + " " + thetime;
                            theGrid.Items.Add(tile);
                        }
                    }

                }
                else
                {
                    LogRecordTile tile = new LogRecordTile();
                    tile.txtAction.Text = action.Attribute("type").Value;
                    tile.txtName.Text = action.Element("Person").Element("First-Name").Value + " " + action.Element("Person").Element("Last-Name").Value;
                    tile.txtCompany.Text = action.Element("Person").Element("Company-Represented").Value;
                    tile.txtHost.Text = action.Element("Person").Element("Boeing-Host-Name").Value;
                    var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                    var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
                    DateTime dateToFormat = Convert.ToDateTime(action.Element("Person").Element("Time-In").Value.ToString());
                    var thedate = formatter.Format(dateToFormat);
                    var thetime = formatterTime.Format(dateToFormat);
                    tile.txtDate.Text = thedate + " " + thetime;
                    theGrid.Items.Add(tile);

                }

            }

        }
Ejemplo n.º 40
0
        public async Task loadLog()
        {
            StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("logdata.xml");
            Debug.WriteLine("Attempting to read file  " + file.Path + " into xdocument");
            XDocument doc = XDocument.Load(file.Path);
            var ps = (
                    from actions in doc.Root.Elements("Action").Elements("Person")
                    select actions
                );

            IEnumerable<XElement> nactions = (
                  from actionsa in doc.Root.Elements("Action")
                 // where (string)actions.Attribute("type") == "Sign In"
                  from person in actionsa.Elements("Person")
                  from dates in person.Elements("Date")
                  orderby (Convert.ToDateTime(person.Element("Date").Value)) descending
                  select actionsa
              );

            foreach (XElement action in nactions)
            {
                LogRecordTile tile = new LogRecordTile();
                tile.txtName.Text = action.Element("Person").Element("First-Name").Value + " " + action.Element("Person").Element("Last-Name").Value;
                tile.txtCompany.Text = action.Element("Person").Element("Company-Represented").Value;
                tile.txtHost.Text = action.Element("Person").Element("Boeing-Host-Name").Value;
                tile.txtAction.Text = action.Attribute("type").Value;
                var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
                DateTime dateToFormat = Convert.ToDateTime(action.Element("Person").Element("Time-In").Value.ToString());
                var thedate = formatter.Format(dateToFormat);
                var thetime = formatterTime.Format(dateToFormat);
                tile.txtDate.Text = thedate + " " + thetime; 
                theGrid.Items.Add(tile);
            }
        }
Ejemplo n.º 41
0
        private void getData()
        {
            try
            {
                VisitorList = new List <VisitorGlobal>();
                guestList   = new List <GuestGlobal>();

                VisitorDataPayLoad payload = new VisitorDataPayLoad {
                    CompanyId = _activePage.CompanyId
                };

                //var response = service.GuestStillCheckInListControllerService(payload);
                //VisitorList = response.VisitorList;

                var response = service.GuestListControllerService(payload);
                guestList = response.GuestList;

                DisplayGuestList = new List <DisplayDetails>();
                var serialNo = 0;

                int GuestCheckedInToday      = 0;
                int GuestStillCheckedInToday = 0;
                int GuestThisWeek            = 0;
                int GuestThisMonth           = 0;
                int GuestThisYear            = 0;

                foreach (var item in guestList)
                {
                    if (item.CheckInTime == item.CheckOutTime)
                    {
                        GuestStillCheckedInToday += 1;
                    }

                    if (item.CheckInTime.Date == DateTime.Today)
                    {
                        GuestCheckedInToday += 1;
                    }

                    DayOfWeek fdow      = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek; //First Day of the Week
                    int       offset    = fdow - DateTime.Now.DayOfWeek;
                    DateTime  fdowDate  = DateTime.Now.AddDays(offset);                             //Date of First Day of the Week
                    DateTime  LdowDate  = fdowDate.AddDays(6);                                      //Date of Last Day of the Week
                    DayOfWeek Ldow      = LdowDate.DayOfWeek;                                       //Last Day of the Week
                    var       thisMonth = DateTime.Today.Month;
                    var       thisYear  = DateTime.Today.Year;

                    if ((item.CheckInTime.Date >= fdowDate.Date) && (item.CheckInTime.Date <= LdowDate.Date))
                    {
                        GuestThisWeek += 1;
                    }

                    if ((item.CheckInTime.Month == thisMonth) && (item.CheckInTime.Year == thisYear))
                    {
                        GuestThisMonth += 1;
                    }

                    if (item.CheckInTime.Year == thisYear)
                    {
                        GuestThisYear += 1;
                    }
                }

                txbGuestToday.Text             = GuestCheckedInToday.ToString();
                txbStillCheckinGuestToday.Text = GuestStillCheckedInToday.ToString();
                txbGuestthisWeek.Text          = GuestThisWeek.ToString();
                txbGuestthisMonth.Text         = GuestThisMonth.ToString();
                txbGuestthisYear.Text          = GuestThisYear.ToString();

                var dateFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("day month year");
                txbToday.Text = dateFormatter.Format(DateTime.Today).ToString();
            }
            catch (Exception ex)
            {
                checkInternet();
                MessageDialog msg = new MessageDialog(ex.Message + " Void - getData()");
                //msg.ShowAsync();
            }
        }
Ejemplo n.º 42
0
        private void GetGeofenceStateChangedReports(Geoposition pos)
        {
            _geofenceBackgroundEvents.Clear();

            FillEventCollectionWithExistingEvents();

            GeofenceMonitor monitor = GeofenceMonitor.Current;

            Geoposition posLastKnown = monitor.LastKnownGeoposition;

            Windows.Globalization.Calendar calendar = new Windows.Globalization.Calendar();
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatterLongTime;
            formatterLongTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", new[] { "en-US" }, "US", Windows.Globalization.CalendarIdentifiers.Gregorian, Windows.Globalization.ClockIdentifiers.TwentyFourHour);

            bool eventOfInterest = true;

            // NOTE TO DEVELOPER:
            // Registered geofence events can be filtered out if the
            // geofence event time is stale.
            DateTimeOffset eventDateTime = pos.Coordinate.Timestamp;

            calendar.SetToNow();
            DateTimeOffset nowDateTime  = calendar.GetDateTime();
            TimeSpan       diffTimeSpan = nowDateTime - eventDateTime;

            long deltaInSeconds = diffTimeSpan.Ticks / oneHundredNanosecondsPerSecond;

            if (true == eventOfInterest)
            {
                if ((posLastKnown.Coordinate.Point.Position.Latitude != pos.Coordinate.Point.Position.Latitude) ||
                    (posLastKnown.Coordinate.Point.Position.Longitude != pos.Coordinate.Point.Position.Longitude))
                {
                    UpdateInforamtion.WipeGeolocDataFromAppData();
                }

                if (true == eventOfInterest)
                {
                    string geofenceItemEvent   = null;
                    int    numEventsOfInterest = 0;

                    // Retrieve a vector of state change reports
                    var reports = GeofenceMonitor.Current.ReadReports();

                    foreach (var report in reports)
                    {
                        GeofenceState state = report.NewState;
                        geofenceItemEvent = report.Geofence.Id + " " + formatterLongTime.Format(eventDateTime);

                        if (state == GeofenceState.Removed)
                        {
                            GeofenceRemovalReason reason = report.RemovalReason;
                            if (reason == GeofenceRemovalReason.Expired)
                            {
                                geofenceItemEvent += " (Removed/Expired)";
                            }
                            else if (reason == GeofenceRemovalReason.Used)
                            {
                                geofenceItemEvent += " (Removed/Used)";
                            }
                        }
                        else if (state == GeofenceState.Entered)
                        {
                            geofenceItemEvent += " (Entered)";
                        }
                        else if (state == GeofenceState.Exited)
                        {
                            geofenceItemEvent += " (Exited)";
                        }

                        AddGeofenceEvent(geofenceItemEvent);

                        ++numEventsOfInterest;
                    }

                    if (true == eventOfInterest && 0 != numEventsOfInterest)
                    {
                        SaveExistingEvents();

                        // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates.
                        DoToast(numEventsOfInterest, geofenceItemEvent);
                    }
                }
            }
        }
 string getTimeStampedMessage(string eventText)
 {
     Windows.Globalization.DateTimeFormatting.DateTimeFormatter dateTimeFormat = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
     string dateTime = dateTimeFormat.Format(DateTime.Now);
     return eventText + "   " + dateTime;
 }
Ejemplo n.º 44
0
        private async Task loadSignIns()
        {
            Debug.WriteLine("loading sign ins.");
            StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("logdata.xml");
            Debug.WriteLine("Attempting to read file  " + file.Path + " into xdocument");
            XDocument doc = XDocument.Load(file.Path);
            var ps = (
                    from actions in doc.Root.Elements("Action").Elements("Person")
                    select actions
                );

            var normalized = ps.Select(x => new
            {
                FullName = (string)x.Element("First-Name") + " " + (string)x.Element("Last-Name"),
                id = x.Descendants("ID").Max(y => (int)y)
            });

            var maxids = (from t in normalized
                          group t by t.FullName
                              into g
                              select new
                              {
                                  //FullName = g.Key,
                                  ID = (from t2 in g select t2.id).Max()
                              }
                            );



            List<string> mylist = new List<string>();
            foreach (var i in maxids)
            {
                mylist.Add(i.ID.ToString());
            }



            IEnumerable<XElement> persons = (
                    from actions in doc.Root.Elements("Action")
                    where (string)actions.Attribute("type") == "Sign In"
                    from person in actions.Elements("Person")
                    where mylist.Contains(person.Element("ID").Value)
                    from dates in person.Elements("Date")
                    where Convert.ToDateTime(dates.Value).Date == DateTime.Now.Date //just signins for today - uncertain about this..
                    select person
                );

            Debug.WriteLine(persons.Count());
            Debug.WriteLine(persons);

            //for (var i = 0; i <= 25; i++)
            //{
            //    VisitorTile tile = new VisitorTile();
            //    tile.txtName.Text = "TEst";
            //    tile.txtCompany.Text = "Bobs Butrgers";
            //    tile.txtTimeIn.Text = DateTime.Now.TimeOfDay.ToString();
            //    lvSignIns.Items.Add(tile);

            //}


                foreach (XElement signin in persons)
                {
                    Debug.WriteLine("Adding Tile.");
                    VisitorTile tile = new VisitorTile();
                    tile.person = signin;
                    tile.txtName.Text = signin.Element("Last-Name").Value.ToString() + ", " + signin.Element("First-Name").Value.ToString();
                    tile.txtCompany.Text = signin.Element("Company-Represented").Value.ToString();

                    var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate");
                    var formatterTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shorttime");
                    DateTime dateToFormat = Convert.ToDateTime(signin.Element("Time-In").Value.ToString());

                    var thedate = formatter.Format(dateToFormat);
                    var thetime = formatterTime.Format(dateToFormat);

                    tile.txtTimeIn.Text = thedate + " " + thetime; 
                    
                    lvSignIns.Items.Add(tile);
                }

            if(persons.Count() == 0){
                VisitorTile tile = new VisitorTile();

                tile.txtName.Text = "No current visitors";
                tile.txtCompany.Text = "";
                tile.txtTimeIn.Text = "";
                lvSignIns.Items.Add(tile);
            }
        }
        private void GetGeofenceStateChangedReports(Geoposition pos)
        {
            _geofenceBackgroundEvents.Clear();

            FillEventCollectionWithExistingEvents();

            GeofenceMonitor monitor = GeofenceMonitor.Current;

            Geoposition posLastKnown = monitor.LastKnownGeoposition;

            Windows.Globalization.Calendar calendar = new Windows.Globalization.Calendar();
            Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatterLongTime;
            formatterLongTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", new[] { "en-US" }, "US", Windows.Globalization.CalendarIdentifiers.Gregorian, Windows.Globalization.ClockIdentifiers.TwentyFourHour);

            bool eventOfInterest = true;

            // NOTE TO DEVELOPER:
            // Registered geofence events can be filtered out if the
            // geofence event time is stale.
            DateTimeOffset eventDateTime = pos.Coordinate.Timestamp;

            calendar.SetToNow();
            DateTimeOffset nowDateTime = calendar.GetDateTime();
            TimeSpan diffTimeSpan = nowDateTime - eventDateTime;

            long deltaInSeconds = diffTimeSpan.Ticks / oneHundredNanosecondsPerSecond;

            // NOTE TO DEVELOPER:
            // If the time difference between the geofence event and now is too large
            // the eventOfInterest should be set to false.

            if (true == eventOfInterest)
            {
                // NOTE TO DEVELOPER:
                // This event can be filtered out if the
                // geofence event location is too far away.
                if ((posLastKnown.Coordinate.Point.Position.Latitude != pos.Coordinate.Point.Position.Latitude) ||
                    (posLastKnown.Coordinate.Point.Position.Longitude != pos.Coordinate.Point.Position.Longitude))
                {
                    // NOTE TO DEVELOPER:
                    // Use an algorithm like the Haversine formula or Vincenty's formulae to determine
                    // the distance between the current location (pos.Coordinate)
                    // and the location of the geofence event (latitudeEvent/longitudeEvent).
                    // If too far apart set eventOfInterest to false to
                    // filter the event out.
                }

                if (true == eventOfInterest)
                {
                    string geofenceItemEvent = null;
                    int numEventsOfInterest = 0;

                    // Retrieve a vector of state change reports
                    var reports = GeofenceMonitor.Current.ReadReports();

                    foreach (var report in reports)
                    {
                        GeofenceState state = report.NewState;
                        geofenceItemEvent = report.Geofence.Id + " " + formatterLongTime.Format(eventDateTime);

                        if (state == GeofenceState.Removed)
                        {
                            GeofenceRemovalReason reason = report.RemovalReason;
                            if (reason == GeofenceRemovalReason.Expired)
                            {
                                geofenceItemEvent += " (Removed/Expired)";
                            }
                            else if (reason == GeofenceRemovalReason.Used)
                            {
                                geofenceItemEvent += " (Removed/Used)";
                            }
                        }
                        else if (state == GeofenceState.Entered)
                        {
                            geofenceItemEvent += " (Entered)";
                        }
                        else if (state == GeofenceState.Exited)
                        {
                            geofenceItemEvent += " (Exited)";
                        }

                        AddGeofenceEvent(geofenceItemEvent);

                        ++numEventsOfInterest;
                    }

                    if (true == eventOfInterest && 0 != numEventsOfInterest)
                    {
                        SaveExistingEvents();

                        // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates.
                        DoToast(numEventsOfInterest, geofenceItemEvent);
                    }
                }
            }
        }