コード例 #1
0
 private void mapBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     if (!documentCompleted)
     {
         documentCompleted = true;
         try
         {
             List <object> parms = new List <object>();
             parms.Add(modulePoints.Average(x => x.Latitude));
             parms.Add(modulePoints.Average(x => x.Longitude));
             parms.Add(18);
             mapBrowser.Document.InvokeScript("initMap", parms.ToArray());
             mapBrowser.Visible = true;
             //iterate all datapoints and add to map
             foreach (var point in modulePoints)
             {
                 parms.Clear();
                 parms.Add(point.Latitude);
                 parms.Add(point.Longitude);
                 parms.Add(point.SerialNumber);
                 parms.Add(point.ModuleStatus);
                 mapBrowser.Document.InvokeScript("addPoint", parms.ToArray());
             }
             mapBrowser.Document.InvokeScript("fitBounds");
             BusyMessage.Close();
         }
         catch (Exception exc)
         {
             MessageBox.Show(exc.Message);
             BusyMessage.Close();
         }
         this.Focus();
         this.BringToFront();
     }
 }
コード例 #2
0
        private void refresh()
        {
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate
                {
                    refresh();
                });
            }
            else                      //load filters

            {
                var filter = baleFilterBar.Filter;
                baleFilterBar.Enabled = false;
                BusyMessage.Show("Loading...", this.FindForm());
                using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                {
                    lastResult = uow.BalesRepository.GetBales(filter, pageSize, 1);
                    bindingSource.DataSource          = lastResult.ResultData;
                    dataGridBales.DataSource          = bindingSource;
                    dataGridBales.AutoGenerateColumns = false;
                    dataGridBales.Columns[0].ReadOnly = false;
                    checkbox.Checked      = false;
                    baleFilterBar.Enabled = true;
                    BusyMessage.Close();
                }
            }
        }
コード例 #3
0
        private void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            List <DriverEntity> docsToDelete = new List <DriverEntity>();

            foreach (DataGridViewRow row in dataGridDrivers.Rows)
            {
                DriverEntity doc = (DriverEntity)row.DataBoundItem;
                if (Convert.ToBoolean(row.Cells[0].Value))
                {
                    docsToDelete.Add(doc);
                }
            }

            if (docsToDelete.Count() > 0)
            {
                if (MessageBox.Show("Are you sure you want to delete the " + docsToDelete.Count.ToString() + " selected driver(s)?", "Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    BusyMessage.Show("Deleting...", this.FindForm());
                    using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                    {
                        uow.DriverRepository.BulkDelete(docsToDelete);
                        uow.SaveChanges();
                    }
                    BusyMessage.Close();
                    refresh();
                }
            }
            else
            {
                MessageBox.Show("No records were selected to delete.");
            }
        }
コード例 #4
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                fileDialog.Title           = "Import File";
                fileDialog.Multiselect     = false;
                fileDialog.CheckFileExists = true;
                fileDialog.CheckPathExists = true;

                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    FileInfo info = new FileInfo(fileDialog.FileName);

                    Task.Run(() =>
                    {
                        BusyMessage.Show("Importing file...", this.FindForm());
                        ClassingFileImportTask import = new ClassingFileImportTask();
                        import.processFile(info);
                        BusyMessage.Close();


                        refresh();
                    });
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
                MessageBox.Show("An error occurred importing file. " + exc.Message);
            }
        }
コード例 #5
0
 private object ReceiveBusyMessage(BusyMessage msg)
 {
     BusyMessage = msg.Message;
     IsBusy      = msg.IsBusy;
     DialogOpen  = msg.IsBusy;
     return(null);
 }
コード例 #6
0
        private void refresh()
        {
            splitContainer1.Visible = true;
            BusyMessage.Show("Loading modules scanned in time range...", this.FindForm());
            using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
            {
                List <ModuleEntity> modules = uow.ModuleRepository.GetModulesScannedAtFeederInRange(dpStartTime.Value.ToUniversalTime(), dpEndTime.Value.ToUniversalTime());
                var sorted = modules.OrderBy(t => t.LastFeederScanTime).ToList();

                modulesBound = false;
                gridViewModules.DataSource          = null;
                gridViewModules.AutoGenerateColumns = false;
                gridViewModules.DataSource          = sorted;
                gridViewModules.Visible             = true;
                gridViewPBIScans.Visible            = false;
                pnlBottomButtons.Visible            = false;
                modulesBound = true;
                gridViewModules.ClearSelection();
                gridViewModules.CurrentCell = null;
                pbisBound = false;
                gridViewPBIScans.DataSource = null;
                lblPBIMessage.Visible       = true;
            }
            BusyMessage.Close();
        }
コード例 #7
0
        private async void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            List <FieldEntity> itemsToDelete = new List <FieldEntity>();

            foreach (DataGridViewRow row in dataGridFields.Rows)
            {
                FieldEntity doc = (FieldEntity)row.DataBoundItem;
                if (Convert.ToBoolean(row.Cells[0].Value))
                {
                    itemsToDelete.Add(doc);
                }
            }

            if (itemsToDelete.Count() > 0)
            {
                using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                {
                    BusyMessage.Show("Checking fields for assigned modules...", this.FindForm());
                    var undeletableFieldIds = uow.FieldRepository.GetUndeletableFieldIds(itemsToDelete);
                    int undeletableCount    = 0;
                    BusyMessage.Close();
                    foreach (DataGridViewRow row in dataGridFields.Rows)
                    {
                        FieldEntity doc = (FieldEntity)row.DataBoundItem;
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            if (undeletableFieldIds.Contains(doc.Id))
                            {
                                undeletableCount++;
                            }
                        }
                    }


                    if (undeletableCount > 0)
                    {
                        if (MessageBox.Show(string.Format("{0} field(s) cannot be deleted because they are linked to one or modules, gin loads, or pickup lists. Would you like to continue?", undeletableCount), "Info", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                        itemsToDelete.RemoveAll(item => undeletableFieldIds.Contains(item.Id));
                    }

                    if (itemsToDelete.Count() > 0 && MessageBox.Show("Are you sure you want to delete the " + itemsToDelete.Count.ToString() + " selected fields(s)?", "Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        BusyMessage.Show("Deleting...", this.FindForm());

                        uow.FieldRepository.BulkDelete(itemsToDelete);
                        uow.SaveChanges();

                        BusyMessage.Close();
                        refresh();
                    }
                }
            }
            else
            {
                MessageBox.Show("No records were selected to delete.");
            }
        }
コード例 #8
0
        private void loadPBIScans()
        {
            if (gridViewModules.SelectedRows.Count == 0)
            {
                return;
            }

            DateTime start = DateTime.Now.AddYears(100);
            DateTime end   = DateTime.Now.AddYears(-100);

            foreach (DataGridViewRow item in gridViewModules.SelectedRows)
            {
                var thisModule = (ModuleEntity)item.DataBoundItem;
                if (thisModule.LastFeederScanTime.HasValue)
                {
                    if (thisModule.LastFeederScanTime < start)
                    {
                        start = thisModule.LastFeederScanTime.Value;
                    }
                    if (thisModule.LastFeederScanTime > end)
                    {
                        end = thisModule.LastFeederScanTime.Value;
                    }
                }
            }


            BusyMessage.Show("Loading bales scanned in time range...", this.FindForm());
            Task.Run(() =>
            {
                using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                {
                    var startTime = start.AddMinutes(-30);
                    var endTime   = end.AddMinutes(90);

                    List <BaleEntity> bales = uow.BalesRepository.FindMatching(x => x.Created >= startTime && x.Created <= endTime).OrderBy(x => x.Created).ThenBy(x => x.PbiNumber).ToList();

                    this.Invoke((MethodInvoker) delegate
                    {
                        lblPBIScanHeader.Text    = "Bales";
                        lblFeederScanHeader.Text = string.Format("Modules - {0} Selected - Time Range {1} to {2}",
                                                                 gridViewModules.SelectedRows.Count,
                                                                 startTime.ToLocalTime().ToString("MM/dd/yyyy hh:mm:ss tt"),
                                                                 endTime.ToLocalTime().ToString("MM/dd/yyyy hh:mm:ss tt"));

                        pbisBound = false;
                        gridViewPBIScans.DataSource          = null;
                        gridViewPBIScans.AutoGenerateColumns = false;
                        gridViewPBIScans.DataSource          = bales;
                        gridViewPBIScans.Visible             = true;
                        pbisBound = true;
                        gridViewPBIScans.ClearSelection();
                        gridViewPBIScans.CurrentCell = null;
                        pnlBottomButtons.Visible     = false;
                        lblPBIMessage.Visible        = false;
                        BusyMessage.Close();
                    });
                }
            });
        }
コード例 #9
0
        private async void MapReportDialog_Shown(object sender, EventArgs e)
        {
            BusyMessage.Show("Loading...", this.FindForm());
            try
            {
                using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                {
                    mapBrowser.Visible = false;
                    downloaded         = 0;
                    total = 0;
                    modulePoints.Clear();

                    BusyMessage.UpdateMessage("Loading module locations");

                    if (filter.RecentOnly)
                    {
                        modulePoints.AddRange(uow.ModuleRepository.GetModulePoints(filter));
                    }
                    else
                    {
                        modulePoints.AddRange(uow.ModuleRepository.GetModulePointHistory(filter));
                    }

                    BusyMessage.UpdateMessage("Plotting module locations");
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
                BusyMessage.Close();
            }

            RenderMap();
        }
コード例 #10
0
        public void LoadData()
        {
            try
            {
                loadFilterBar.ShowApplyButton = true;
                loadFilterBar.ShowSort1       = true;
                loadFilterBar.ShowSort2       = false;
                loadFilterBar.ShowSort3       = false;

                if (!initialized)
                {
                    initialized           = true;
                    loadFilterBar.Enabled = false;
                    BusyMessage.Show("Loading...", this.FindForm());
                    loadFilterBar.Initialize();
                    BusyMessage.Close();
                    refresh();
                    loadFilterBar.Enabled = true;
                }
                else
                {
                    loadFilterBar.RefreshAutocompletes();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("An error occurred trying to load gin loads.");
                Logging.Logger.Log(exc);
            }
        }
コード例 #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            BusyMessage.Show("Saving...", this.FindForm());
            try
            {
                ValidateForm();
                if (!hasError)
                {
                    using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                    {
                        BaseEntity   selectedStatus       = (BaseEntity)tbStatus.SelectedItem;
                        ModuleStatus selectedModuleStatus = (ModuleStatus)int.Parse(selectedStatus.Id);

                        //ensure client, farm, and field are created
                        var client = clientSelector1.GetOrCreateClientEntity();
                        var farm   = farmSelector1.GetOrCreateFarmEntity(client);
                        var field  = fieldSelector1.GetOrCreateFieldEntity(farm);

                        foreach (var sn in _serialNumbers)
                        {
                            ModuleEntity existingModule = uow.ModuleRepository.FindSingle(x => x.Name == sn, "ModuleHistory");
                            existingModule.ModuleStatus = selectedModuleStatus;
                            existingModule.FieldId      = field.Id;
                            ModuleHistoryEntity historyItem = new ModuleHistoryEntity
                            {
                                Id              = Guid.NewGuid().ToString(),
                                Created         = DateTime.UtcNow,
                                Driver          = existingModule.Driver,
                                TruckID         = existingModule.TruckID,
                                Latitude        = existingModule.Latitude,
                                Longitude       = existingModule.Longitude,
                                ModuleStatus    = existingModule.ModuleStatus,
                                ModuleEventType = ModuleEventType.MANUAL_EDIT
                            };
                            existingModule.ModuleHistory.Add(historyItem);
                            existingModule.SyncedToCloud = false;
                            uow.ModuleRepository.Save(existingModule);
                        }
                        uow.SaveChanges();
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                else
                {
                    this.Activate();
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
                MessageBox.Show("An error occurred trying to save module.");
            }
            finally
            {
                BusyMessage.Close();
            }
        }
コード例 #12
0
        private void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            try
            {
                using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                {
                    List <ModuleEntity> itemsToDelete = new List <ModuleEntity>();
                    BusyMessage.Show("Looking for modules on pickup lists.", this.FindForm());
                    IEnumerable <string> moduleIdsOnPickupList = uow.PickupListRepository.GetModuleIdsOnPickupList();
                    int undeletableCount = 0;
                    foreach (DataGridViewRow row in modulesGridView.Rows)
                    {
                        ModuleEntity module = (ModuleEntity)row.DataBoundItem;
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            itemsToDelete.Add(module);
                            if (moduleIdsOnPickupList.Contains(module.Id))
                            {
                                undeletableCount++;
                            }
                        }
                    }
                    BusyMessage.Close();

                    if (itemsToDelete.Count() > 0)
                    {
                        if (undeletableCount > 0)
                        {
                            if (MessageBox.Show(string.Format("{0} module(s) cannot be deleted because they have been added to a pickup list. Would you like to continue and delete modules not linked?", undeletableCount), "Info", MessageBoxButtons.YesNo) == DialogResult.No)
                            {
                                return;
                            }
                            itemsToDelete.RemoveAll(doc => moduleIdsOnPickupList.Contains(doc.Id));
                        }

                        if (itemsToDelete.Count() > 0 && MessageBox.Show("Modules will be unlinked from associated gin loads and bales.  Are you sure you want to delete the " + itemsToDelete.Count.ToString() + " selected module(s)? ", "Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            BusyMessage.Show("Deleting...", this.FindForm());

                            uow.ModuleRepository.BulkDeleteAndClearLinkedLoadsAndBales(itemsToDelete);
                            uow.SaveChanges();
                            BusyMessage.Close();
                            refresh();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No records were selected to delete.");
                    }
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
                MessageBox.Show("An error occurred deleting module(s).");
            }
        }
コード例 #13
0
 private List <ModuleHistoryEntity> getAllLocationRecordsAsync()
 {
     using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
     {
         BusyMessage.UpdateMessage("Retrieving results");
         var results = uow.ModuleRepository.GetAllMatchingLocations(filterBar.Filter);
         return(results.ToList());
     }
 }
コード例 #14
0
        private async void btnShowQRCode_Click(object sender, EventArgs e)
        {
            QRCodeDialog dialog = new QRCodeDialog();

            BusyMessage.Show("Please wait...", this.FindForm());
            await dialog.LoadDialogAsync();

            BusyMessage.Close();
            var result = dialog.ShowDialog();
        }
コード例 #15
0
        private void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            try
            {
                using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                {
                    var idsDownloaded = uow.PickupListRepository.GetDownloadedPickupListIds();

                    List <PickupListEntity> itemsToDelete = new List <PickupListEntity>();
                    int undeletableCount = 0;
                    foreach (DataGridViewRow row in gridView.Rows)
                    {
                        var list = (PickupListEntity)row.DataBoundItem;
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            itemsToDelete.Add(list);
                            if (idsDownloaded.Contains(list.Id))
                            {
                                undeletableCount++;
                            }
                        }
                    }

                    if (itemsToDelete.Count() > 0)
                    {
                        if (undeletableCount > 0)
                        {
                            if (MessageBox.Show(string.Format("{0} list(s) cannot be deleted because they have been downloaded to one or more trucks. Would you like to continue and delete the checked lists that have not been downloaded?", undeletableCount), "Info", MessageBoxButtons.YesNo) == DialogResult.No)
                            {
                                return;
                            }
                            itemsToDelete.RemoveAll(p => idsDownloaded.Contains(p.Id));
                        }

                        if (itemsToDelete.Count() > 0 && MessageBox.Show("Are you sure you want to delete " + itemsToDelete.Count.ToString() + " lists(s)?", "Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            BusyMessage.Show("Deleting...", this.FindForm());
                            uow.PickupListRepository.BulkDelete(itemsToDelete);
                            uow.SaveChanges();
                            BusyMessage.Close();
                            refresh();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No records were selected to delete.");
                    }
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
                MessageBox.Show("An error occurred deleting list(s).");
            }
        }
コード例 #16
0
        private List <ModuleEntity> getRecentModuleDocsAsync()
        {
            List <ModuleEntity> outputDocs = new List <ModuleEntity>();

            using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
            {
                BusyMessage.UpdateMessage("Retrieving results");
                var results = uow.ModuleRepository.GetAllMatchingModules(filterBar.Filter);
                return(results.ToList());
            }
        }
コード例 #17
0
 private void OnBusyMessage(BusyMessage m)
 {
     if (m.IsBusy)
     {
         _registry.Add($"{m.CallerType}.{m.CallerMember}");
     }
     else
     {
         _registry.Remove($"{m.CallerType}.{m.CallerMember}");
     }
     RaisePropertyChanged(nameof(IsBusy));
 }
コード例 #18
0
        private void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            try
            {
                using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                {
                    List <GinLoadEntity> itemsToDelete = new List <GinLoadEntity>();
                    BusyMessage.Show("Verifying loads can be deleted.", this.FindForm());
                    IEnumerable <string> undeletableIds = uow.GinLoadRepository.GetUndeletableIds();
                    int undeletableCount = undeletableIds.Count();
                    foreach (DataGridViewRow row in this.dataGridLoads.Rows)
                    {
                        GinLoadEntity item = (GinLoadEntity)row.DataBoundItem;
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            itemsToDelete.Add(item);
                        }
                    }
                    BusyMessage.Close();

                    if (itemsToDelete.Count() > 0)
                    {
                        if (undeletableCount > 0)
                        {
                            if (MessageBox.Show(string.Format("{0} load(s) cannot be deleted because they are linked to other records. Would you like to continue and delete loads not linked?", undeletableCount), "Info", MessageBoxButtons.YesNo) == DialogResult.No)
                            {
                                return;
                            }
                            itemsToDelete.RemoveAll(doc => undeletableIds.Contains(doc.Id));
                        }

                        if (itemsToDelete.Count() > 0 && MessageBox.Show("Are you sure you want to delete the " + itemsToDelete.Count.ToString() + " selected load(s)? All modules and bales from this load will have load information removed and will no longer be linked to a load.", "Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            BusyMessage.Show("Deleting...", this.FindForm());

                            uow.GinLoadRepository.BulkDelete(itemsToDelete);
                            uow.SaveChanges();
                            BusyMessage.Close();
                            refresh();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No records were selected to delete.");
                    }
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
                MessageBox.Show("An error occurred deleting gin load(s).");
            }
        }
コード例 #19
0
 private void refresh()
 {
     BusyMessage.Show("Loading...", this.FindForm());
     using (var uow = UnitOfWorkFactory.CreateUnitOfWork()) {
         IEnumerable <TruckEntity> trucks = uow.TruckRepository.GetAll();
         var sorted = trucks.OrderBy(t => t.Name).ToList();
         dataGridTrucks.DataSource          = null;
         dataGridTrucks.AutoGenerateColumns = false;
         dataGridTrucks.DataSource          = sorted;
         dataGridTrucks.Columns[0].ReadOnly = false;
         BusyMessage.Close();
     }
 }
コード例 #20
0
        public void LoadData()
        {
            try
            {
                filterBar.ShowApplyButton     = false;
                filterBar.ShowLocationOptions = true;
                filterBar.ShowSort1           = true;
                filterBar.ShowSort2           = true;
                filterBar.ShowSort3           = true;

                if (!initialized)
                {
                    initialized       = true;
                    filterBar.Enabled = false;
                    BusyMessage.Show("Loading...", this.FindForm());
                    filterBar.Initialize();
                    BusyMessage.Close();
                    filterBar.Enabled = true;
                    try
                    {
                        //load export templates
                        string currentDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        currentDir = currentDir.TrimEnd('\\') + "\\ExportTemplates";

                        cboOutputType.Items.Clear();
                        foreach (var file in System.IO.Directory.EnumerateFiles(currentDir))
                        {
                            var info = new System.IO.FileInfo(file);
                            cboOutputType.Items.Add(info.Name.Replace(info.Extension, ""));
                        }
                        cboOutputType.SelectedIndex = 0;
                    }
                    catch (Exception exc)
                    {
                        Logging.Logger.Log(exc);
                        MessageBox.Show("Unable to load export templates.");
                    }

                    cboExportType.SelectedIndex = 0;
                }
                else
                {
                    filterBar.RefreshAutocompletes();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("An error occurred trying to load filters.");
                Logging.Logger.Log(exc);
            }
        }
コード例 #21
0
        private void generateCSVAsync(string outputFilename)
        {
            //apply filters to get all records using paging - streaming records into a temporary database table
            BusyMessage.Show("Downloading data...", this.FindForm());
            string[] templateLines = GetTemplateFileLines();
            bool     hasError      = false;

            try
            {
                if (filterBar.Filter.RecentOnly)
                {
                    using (StreamWriter sr = new StreamWriter(outputFilename, false))
                    {
                        var outputDocs = getRecentModuleDocsAsync();
                        sr.WriteLine(templateLines[0]);
                        string outputLine = "";
                        foreach (var doc in outputDocs)
                        {
                            outputLine = getOutputLine(templateLines[1], doc);
                            sr.WriteLine(outputLine);
                        }
                    }
                }
                else
                {
                    using (StreamWriter sr = new StreamWriter(outputFilename, false))
                    {
                        var historyDocs = getAllLocationRecordsAsync();
                        sr.WriteLine(templateLines[0]);
                        string outputLine = "";
                        foreach (var doc in historyDocs)
                        {
                            outputLine = getHistoryOutputLine(templateLines[1], doc);
                            sr.WriteLine(outputLine);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
                hasError = true;
                MessageBox.Show(exc.Message);
            }
            BusyMessage.Close();
            if (!hasError)
            {
                MessageBox.Show("File saved successfully.");
            }
        }
コード例 #22
0
 private void refresh()
 {
     refreshFilter();
     BusyMessage.Show("Loading...", this.FindForm());
     using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
     {
         IEnumerable <FieldEntity> fields = uow.FieldRepository.GetAllMatchingFields(tbClientFilter.Text.Trim(), tbFarm.Text.Trim(), "");
         dataGridFields.DataSource          = null;
         dataGridFields.AutoGenerateColumns = false;
         dataGridFields.DataSource          = fields;
         dataGridFields.Columns[0].ReadOnly = false;
     }
     BusyMessage.Close();
 }
コード例 #23
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            if (validateForm())
            {
                BusyMessage.Show("Saving.", this.FindForm());

                ConfigHelper.SaveSettingsFromUIControls(lblImportFilesFolderValue, lblArchiveFolderValue, tbIMAPHostname, tbIMAPPort, tbIMAPUsername, tbIMAPPassword,
                                                        tbYardNWLatitude, tbYardNWLongitude, tbYardSELatitude, tbYardSELongitude, tbFeederLatitude, tbFeederLongitude, tbFeederDetectionRadius,
                                                        tbMapsAPIKey, tbImportInterval, tbAzureCosmosEndpoint, tbAzureKey, tbAzureCosmosReadOnlyEndPoint, tbAzureReadOnlyKey, tbLoadPrefix, tbStartingLoadNumber, tbModulesPerLoad, tbGinName);

                System.Threading.Thread.Sleep(1000);
                BusyMessage.Close();
            }
        }
コード例 #24
0
        /*private void btnClearAllData_Click(object sender, EventArgs e)
         * {
         *  if (MessageBox.Show("Are you sure you want to clear all data?  This will delete all data in the system.  Data stored on truck and bridge computers should be cleared on each computer.", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
         *  {
         *      using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
         *      {
         *          uow.TruckRepository.ClearTruckData();
         *          uow.LoadScanRepository.ClearBridgeScanData();
         *          uow.FeederScanRepository.ClearBridgeScanData();
         *      }
         *  }
         * }*/

        private async void btnClearModuleData_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete ALL pickup lists, modules, gin loads, bales, and all module location history?", "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
                    {
                        BusyMessage.Show("Suspending background sync", this.FindForm());
                        CottonDBMS.EF.Tasks.GinSyncWithCloudTask.Cancel();
                        CottonDBMS.EF.Tasks.GinSyncWithCloudTask.WaitForSyncToFinish();

                        BusyMessage.UpdateMessage("Clearing module data");
                        uow.ModuleRepository.ClearGinModuleData();

                        await CottonDBMS.Cloud.DocumentDBContext.DeleteCollectionAsync();

                        await CottonDBMS.Cloud.DocumentDBContext.CreateCollectionAsync();

                        await CottonDBMS.Cloud.DocumentDBContext.CreateStoredProceduresAsync();

                        var docsToProcess = uow.DocumentsToProcessRepository.GetAll().ToList();
                        uow.DocumentsToProcessRepository.BulkDelete(docsToProcess);

                        uow.ClientRepository.MarkAllDirty();
                        uow.FarmRepository.MarkAllDirty();
                        uow.FieldRepository.MarkAllDirty();
                        uow.TruckRepository.MarkAllDirty();
                        uow.DriverRepository.MarkAllDirty();

                        //reset last sync time to ensure module ownership table is rebuilt
                        uow.SettingsRepository.UpsertSetting(GinAppSettingKeys.LAST_SYNC_TIME, DateTime.UtcNow.AddYears(-1).ToString());

                        uow.SaveChanges();

                        BusyMessage.UpdateMessage("Restarting background sync");
                        CottonDBMS.EF.Tasks.GinSyncWithCloudTask.Reset();

                        BusyMessage.Close();
                    }
                }
                catch (Exception exc)
                {
                    Logging.Logger.Log(exc);
                    BusyMessage.Close();
                    MessageBox.Show("An error occurred clearing data: " + exc.Message);
                }
            }
        }
コード例 #25
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase <see cref="FormPage"/>.
 /// </summary>
 public PreviewWindow()
 {
     InitializeComponent();
     BtnNext.Click            += BtnNext_Click;
     BtnPrev.Click            += BtnPrev_Click;
     BtnPrint.Click           += BtnPrint_Click;
     BtnWord.Click            += BtnWord_Click;
     SldTextSize.ValueChanged += SldTextSize_ValueChanged;
     SldImgWidth.ValueChanged += SldImgWidth_ValueChanged;
     BusyMessage.SetBinding(VisibilityProperty, new Binding(nameof(IsEnabled))
     {
         Source    = PnlControls,
         Converter = new System.Windows.Converters.BooleanToInvVisibilityConverter()
     });
 }
コード例 #26
0
        private void btnDeleteSelected_Click(object sender, EventArgs e)
        {
            using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
            {
                List <FarmEntity> farmsToDelete = new List <FarmEntity>();
                var idsLinkedToFields           = uow.FarmRepository.GetFarmIdsLinkedToFields();
                int undeletableCount            = 0;

                foreach (DataGridViewRow row in dataGridFarms.Rows)
                {
                    FarmEntity entity = (FarmEntity)row.DataBoundItem;
                    if (Convert.ToBoolean(row.Cells[0].Value))
                    {
                        farmsToDelete.Add(entity);
                        if (idsLinkedToFields.Contains(entity.Id))
                        {
                            undeletableCount++;
                        }
                    }
                }

                if (farmsToDelete.Count() > 0)
                {
                    if (undeletableCount > 0)
                    {
                        if (MessageBox.Show(string.Format("{0} farms(s) cannot be deleted because they are linked to one or more fields. Would you like to continue?", undeletableCount), "Info", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }

                        farmsToDelete.RemoveAll(f => idsLinkedToFields.Contains(f.Id));
                    }

                    if (farmsToDelete.Count() > 0 && MessageBox.Show("Are you sure you want to delete the " + farmsToDelete.Count.ToString() + " selected farms(s)?", "Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        BusyMessage.Show("Deleting...", this.FindForm());
                        uow.FarmRepository.BulkDelete(farmsToDelete);
                        uow.SaveChanges();
                        BusyMessage.Close();
                        refresh();
                    }
                }
                else
                {
                    MessageBox.Show("No records were selected to delete.");
                }
            }
        }
コード例 #27
0
        private void refreshFilter()
        {
            BusyMessage.Show("Loading ...", this.FindForm());
            //IEnumerable<ClientDocument> clients = await ClientCache.GetAllClientsAsync();

            using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
            {
                AutoCompleteStringCollection clientCollection = new AutoCompleteStringCollection();
                foreach (var c in uow.ClientRepository.GetAll().OrderBy(c => c.Name))
                {
                    clientCollection.Add(c.Name);
                }
                tbClientFilter.AutoCompleteCustomSource = clientCollection;
            }
            BusyMessage.Close();
        }
コード例 #28
0
        private void refresh()
        {
            refreshFilter();

            BusyMessage.Show("Loading...", this.FindForm());

            using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
            {
                IEnumerable <FarmEntity> farms = uow.FarmRepository.FindMatching(c => tbClientFilter.Text.Trim() == "" || c.Client.Name == tbClientFilter.Text.Trim(), new string[] { "Client" });
                var sorted = farms.OrderBy(t => t.Client.Name).ThenBy(t => t.Name).ToList();
                dataGridFarms.DataSource          = null;
                dataGridFarms.AutoGenerateColumns = false;
                dataGridFarms.DataSource          = sorted;
                dataGridFarms.Columns[0].ReadOnly = false;
            }
            BusyMessage.Close();
        }
コード例 #29
0
 private void loadMore()
 {
     if (lastResult.TotalPages > lastResult.LastPageNo)
     {
         loading = true;
         BusyMessage.Show("Loading...", this.FindForm());
         var filter = loadFilterBar.Filter;
         using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
         {
             lastResult = uow.GinLoadRepository.GetLoads(filter, pageSize, lastResult.LastPageNo + 1);
             foreach (var item in lastResult.ResultData)
             {
                 loadBindingSource.Add(item);
             }
             BusyMessage.Close();
         }
         loading = false;
     }
 }
コード例 #30
0
        private void refresh()
        {
            //load filters
            var filter = loadFilterBar.Filter;

            loadFilterBar.Enabled = false;
            BusyMessage.Show("Loading...", this.FindForm());
            using (var uow = UnitOfWorkFactory.CreateUnitOfWork())
            {
                lastResult = uow.GinLoadRepository.GetLoads(filter, pageSize, 1);
                loadBindingSource.DataSource      = lastResult.ResultData;
                dataGridLoads.DataSource          = loadBindingSource;
                dataGridLoads.AutoGenerateColumns = false;
                dataGridLoads.Columns[0].ReadOnly = false;
                checkbox.Checked      = false;
                loadFilterBar.Enabled = true;
                BusyMessage.Close();
            }
        }