Esempio n. 1
0
 static public async Task<bool> DeleteDiagramAsync(string diagramId)
 {
     var rtnValue = false;
     try
     {
         using (DocumentDBContext docdb = new DocumentDBContext())
         {
             rtnValue = await docdb.DeleteItemAsync(DiagramCollection, diagramId);
         }
     }
     catch
     {
         // handle exception...                
     }
     return rtnValue;
 }
Esempio n. 2
0
        static public async Task <bool> DeleteDiagramAsync(string diagramId)
        {
            var rtnValue = false;

            try
            {
                using (DocumentDBContext docdb = new DocumentDBContext())
                {
                    rtnValue = await docdb.DeleteItemAsync(DiagramCollection, diagramId);
                }
            }
            catch
            {
                // handle exception...
            }
            return(rtnValue);
        }
Esempio n. 3
0
        private static async Task ClearDownloadedListsData(string appDataPath)
        {
            try
            {
                Console.WriteLine("Releasing downloaded lists...");
                string settingsFile    = appDataPath + "\\Truck\\settings.txt";
                string encryptedString = System.IO.File.ReadAllText(settingsFile);
                string decryptedString = CottonDBMS.Helpers.EncryptionHelper.Decrypt(encryptedString);
                var    parms           = Newtonsoft.Json.JsonConvert.DeserializeObject <TruckAppInstallParams>(decryptedString);

                if (!string.IsNullOrEmpty(parms.EndPoint) &&
                    !string.IsNullOrEmpty(parms.Key) &&
                    !string.IsNullOrEmpty(parms.TruckID))
                {
                    DocumentDBContext.Initialize(parms.EndPoint, parms.Key);

                    Console.WriteLine("Looking for downloaded lists...");
                    var docs = await DocumentDBContext.GetAllItemsAsync <TruckListsDownloaded>(p => p.Id == "TRUCKDOWNLOADS_" + parms.TruckID);

                    if (docs.Count() > 0)
                    {
                        Console.WriteLine("Releasing lists...");
                        //remove document tracking lists this truck has downloaded
                        //this allows them to be released for delete etc at the gin
                        await DocumentDBContext.DeleteItemAsync <TruckListsDownloaded>("TRUCKDOWNLOADS_" + parms.TruckID);
                    }
                }
                else
                {
                    Console.WriteLine("One or more settings null.");
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                Console.WriteLine(exc.StackTrace);
                Console.WriteLine("Press enter to continue.");
                Console.ReadLine();
            }
        }
Esempio n. 4
0
        private void ExecuteClearModuleDataCommand()
        {
            Task.Run(async() => {
                System.Windows.MessageBoxResult msgResult = System.Windows.MessageBoxResult.No;

                System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                {
                    msgResult = System.Windows.MessageBox.Show("Are you sure you want to clear all module history and pickup lists from this truck?  Data already sent to gin will not be deleted from the gin database.", "Confirm", System.Windows.MessageBoxButton.YesNo);
                }));

                if (msgResult == System.Windows.MessageBoxResult.Yes)
                {
                    if (CottonDBMS.DataModels.Helpers.NetworkHelper.HasNetwork())
                    {
                        if (CottonDBMS.DataModels.Helpers.NetworkHelper.SyncProcessRunning())
                        {
                            Messenger.Default.Send <BusyMessage>(new Messages.BusyMessage {
                                IsBusy = true, Message = "Waiting for background sync to complete."
                            });
                            CottonDBMS.DataModels.Helpers.NetworkHelper.WaitForSyncToStop();
                        }
                        else
                        {
                            //run the sync to send data collected this also ensure after it completes
                            //it will not start again during the reset operation
                            Messenger.Default.Send <BusyMessage>(new Messages.BusyMessage {
                                IsBusy = true, Message = "Sending collected data."
                            });
                            CottonDBMS.DataModels.Helpers.NetworkHelper.RunSync(System.Reflection.Assembly.GetExecutingAssembly().Location, false);
                            CottonDBMS.DataModels.Helpers.NetworkHelper.WaitForSyncToStop();
                        }

                        Messenger.Default.Send <BusyMessage>(new Messages.BusyMessage {
                            IsBusy = true, Message = "Clearing data..."
                        });
                        using (var dp = SimpleIoc.Default.GetInstance <IUnitOfWorkFactory>().CreateUnitOfWork())
                        {
                            dp.TruckRepository.ClearTruckData();
                            AggregateDataProvider.Reset();
                            var truck = dp.SettingsRepository.GetCurrentTruck();

                            if (truck != null)
                            {
                                await DocumentDBContext.DeleteItemAsync <TruckListsDownloaded>("TRUCKDOWNLOADS_" + truck.Id);
                            }
                        }

                        Messenger.Default.Send <BusyMessage>(new Messages.BusyMessage {
                            IsBusy = false, Message = ""
                        });
                        Messenger.Default.Send <DataRefreshedMessage>(new DataRefreshedMessage());
                    }
                    else
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            msgResult = System.Windows.MessageBox.Show("Cannot clear data no network connection");
                        }));
                    }
                }
            });
        }