Exemplo n.º 1
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();

            statusUpdateDb = new StatusUpdateDataContext(StatusUpdateDataContext.DBConnectionString);

            // Data context and observable collection are children of the main page.
            this.DataContext = this;

            serviceUpload            = new UploadService();
            serviceUpload.dispatcher = Dispatcher;

            serviceUpload.RefreshTransfers();

            var statusItemsInDB = from statusUpdateItem statusItem in statusUpdateDb.StatusUpdateItems
                                  select statusItem;

            // Execute the query and place the results into a collection.
            StatusUpdateItems = new ObservableCollection <statusUpdateItem>(statusItemsInDB);

            queuedCount.Text = StatusUpdateItems.Count.ToString();

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(2)
            };

            timer.Tick += (sender, args) => { updateTile(); };

            timer.Start();


            StartPeriodicTask();

            //SendPost();

            /*serverFolder folderInfo = new serverFolder();
             * if (folderInfo.status == 0)
             * {
             *  folderInfo.serverFolderUpdateInfo(1);
             *  ServerFolderHandler serverHandler = new ServerFolderHandler();
             *  serverHandler.dispatcher = Dispatcher;
             *  serverHandler.StartUpload();
             * }
             * else
             * {
             *  if (folderInfo.status == 1)
             *  {
             *      ServerFolderHandler serverHandler = new ServerFolderHandler();
             *      serverHandler.dispatcher = Dispatcher;
             *      serverHandler.RefreshTransfers();
             *  }
             * }
             */
        }
Exemplo n.º 2
0
        public void CustomMessageBox()
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                CustomMessageBox messageBox = new CustomMessageBox()
                {
                    Caption            = "Queue update on server?",
                    Message            = "You can queue update on our server for quick update or via half an hour scheduler on phone",
                    LeftButtonContent  = "Yes",
                    RightButtonContent = "No"
                };

                int selected = 0;
                if (App.fb_selected)
                {
                    selected += 1;
                }
                if (App.tw_selected)
                {
                    selected += 10;
                }
                if (App.ld_selected)
                {
                    selected += 100;
                }
                statusUpdateItem newitem = new statusUpdateItem
                {
                    status              = statusString,
                    startTime           = App.finalStartTime,
                    endTime             = App.finalExpTime,
                    selected            = selected,
                    picFolder           = "",
                    uploadStatus        = 0,
                    fbAccessToken       = App.fbaccesstokenkey,
                    twAccessToken       = App.twaccesstokenkey,
                    twAccessTokenSecret = App.twaccesstokensecret,
                    ldAccessToken       = App.ldaccesstokenkey
                };
                messageBox.Dismissed += (s1, e1) =>
                {
                    switch (e1.Result)
                    {
                    case CustomMessageBoxResult.LeftButton:
                        UploadService serverUpload = new UploadService();
                        serverUpload.dispatcher    = Dispatcher;
                        serverUpload.item          = newitem;
                        serverUpload.StartUpload();
                        break;

                    case CustomMessageBoxResult.RightButton:
                        StatusUpdateItems.Add(newitem);
                        statusUpdateDb.StatusUpdateItems.InsertOnSubmit(newitem);
                        statusUpdateDb.SubmitChanges();

                        break;

                    case CustomMessageBoxResult.None:
                        StatusUpdateItems.Add(newitem);
                        statusUpdateDb.StatusUpdateItems.InsertOnSubmit(newitem);
                        statusUpdateDb.SubmitChanges();

                        StartPeriodicTask();
                        break;

                    default:
                        StatusUpdateItems.Add(newitem);
                        statusUpdateDb.StatusUpdateItems.InsertOnSubmit(newitem);
                        statusUpdateDb.SubmitChanges();

                        StartPeriodicTask();
                        break;
                    }
                };

                messageBox.Show();
            });
        }