/*__________________________________________________________________________________________*/ public override void Setup(Form deskForm) { procMsgFormPwd = new ProcessingMessage("* INITIALIZING SUPPORT APPLICATION *"); // Set up the History Session Object HistorySession = new HistoryTrack(deskForm); // Set CashlinxPawnSupportSession's desktop form this.desktopForm = deskForm; // Load barcode formats during startup until Admin section created try { procMsgFormPwd.Message = "* LOADING SUPPORT APPLICATION DATA *"; } catch (Exception ex) { BasicExceptionHandler.Instance.AddException("Error retrieving start up data from the database", new ApplicationException(ex.Message)); } PopulateCategoryXML(); procMsgFormPwd.Hide(); CashlinxPawnSupportSession.instance.PerformAuthorization(); GetPickListValues(); }
private void loginButton_Click(object sender, RoutedEventArgs e) { //Ensure the user name / password are valid strings if (string.IsNullOrEmpty(this.curUserName)) { MessageBox.Show("Please enter a valid employee number (cannot be empty)."); return; } //Ensure the user name contains only digits var isDigits = true; foreach (var c in this.curUserName) { if (!Char.IsDigit(c)) { isDigits = false; break; } } if (!isDigits) { MessageBox.Show("Please enter a valid user name (must contain only digits [0-9])"); return; } var procMsg = new ProcessingMessage("*** VALIDATING LOGIN ***"); procMsg.Show(); //Load pawn security data and authenticate string errTxt; if (!setupInternalData(out errTxt)) { procMsg.Hide(); MessageBox.Show(string.Format("Could not log in to the environment chosen. Error: {0}", errTxt)); if (Application.Current != null) { Application.Current.Shutdown(3); } this.Close(); return; } //Set some more key fields //Log audit message var auditLogData = new Dictionary <string, object>(); auditLogData.Add(DesktopSession.AUDIT_OVERRIDE_COMMENT, string.Format("Employee #{0} logging in to Cashlinx {1} with DSTRViewer", this.curUserName, curEnvString)); AuditLogger.Instance.LogAuditMessage(AuditLogType.OVERRIDE, auditLogData); //Set and show the viewer window procMsg.Hide(); var viewer = new DSTRViewerWindow(this.curEnvString, this.curUserName); viewer.PawnSecData = this.pawnSecData; viewer.EncryptedConfig = this.encConfig; viewer.CouchServer = this.couchServer; viewer.DatabaseServer = this.databaseServer; viewer.CshLnxCred = this.cshLnxCred; viewer.CshLnxDataTools = this.cshLnxDataTools; viewer.PwnSecCred = this.pwnSecCred; viewer.PwnSecDataTools = this.pwnSecDataTools; var res = viewer.ShowDialog(); if (res == false) { this.cleanup(); if (Application.Current != null) { Application.Current.Shutdown(4); } this.Close(); } }
private void DownloadFiles() { ProcessingMessage = new ProcessingMessage("Retrieving upload files", 0); ProcessingMessage.Show(); try { string tmpPath = Path.Combine(Application.StartupPath, "tmp"); string trakkerPath = Path.Combine(tmpPath, "uptrak"); string trakkerIdPath = Path.Combine(tmpPath, "trakker.id"); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } FtpHelper ftpHelper = new FtpHelper(FtpHost, FtpUser, FtpPassword); ftpHelper.DownloadFile("tmp_" + ADS.ActiveAudit.StoreNumber + "/uptrak", trakkerPath, false); ftpHelper.DownloadFile("tmp_" + ADS.ActiveAudit.StoreNumber + "/trakker.id", trakkerIdPath, false); string[] fileContents = File.ReadAllLines(trakkerIdPath); if (fileContents.Length == 0 || string.IsNullOrWhiteSpace(fileContents[0])) { ProcessingMessage.Close(); throw new ApplicationException("trakker.id file is empty"); } int trakkerId = Utilities.GetIntegerValue(fileContents[0].Substring(fileContents[0].IndexOf('|') + 1), 0); ProcessingMessage.Hide(); ConfirmTrakker confirmTrakker = new ConfirmTrakker(trakkerId); if (confirmTrakker.ShowDialog() == DialogResult.Cancel) { ProcessingMessage.Close(); return; } ProcessingMessage.Show(); TrakkerFileReader trakkerFileReader = new TrakkerFileReader(trakkerPath); List <TrakkerItem> uploadedItems = trakkerFileReader.ReadFile(); int count = 0; if (uploadedItems.Count > 0) { ADS.beginTransactionBlock(); foreach (TrakkerItem item in uploadedItems) { count++; ProcessingMessage.Message = string.Format("Uploading record {0} of {1}", count, uploadedItems.Count); CommonDatabaseContext dataContext = new CommonDatabaseContext(); InventoryAuditProcedures.UploadTrakkerItem(item, ADS.ActiveAudit.AuditId, trakkerId, ADS.ActiveAudit.StoreNumber, dataContext); if (!dataContext.Result) { ADS.endTransactionBlock(EndTransactionType.ROLLBACK); MessageBox.Show(dataContext.ErrorText); return; } } ADS.endTransactionBlock(EndTransactionType.COMMIT); } ProcessingMessage.Close(); ChangeStatusMessage2("Records Uploaded from Trakker " + trakkerId); ChangeStatusValue2(uploadedItems.Count.ToString()); Uploaded = true; } catch (Exception exc) { ProcessingMessage.Close(); BasicExceptionHandler.Instance.AddException("Failed to upload trakker files", exc); MessageBox.Show(exc.Message); } }
/* * select storenumber, storage_id, storage_date, storage_time from ccsowner.pawndocumentregistry pdr * where PDR.STORENUMBER = '02030' * and PDR.DOC_TYPE = 'PDF' * and PDR.RECEIPTDETAIL_NUMBER = 0 * and PDR.TICKET_NUMBER = 0 * and PDR.CUSTOMERNUMBER is null * and PDR.STORAGE_DATE > (sysdate-90); * */ private void submitStoreButton_Click(object sender, RoutedEventArgs e) { if (this.storeCalendar != null) { this.storeCalendar.IsEnabled = false; } //Check file time - we do not want to hit production if the time limit is still in effect TupleType <long, long, string> timeData; if (TimeFileExists() && WithinTimeLimit(out timeData)) { var diffTime = timeData.Right; MessageBox.Show("You are still within the time restriction limit. " + Environment.NewLine + " The application will now close.", "*** TIME LIMIT WARNING ***"); Application.Current.Shutdown(); this.Close(); return; } if (!string.IsNullOrEmpty(this.selectedStore)) { //Check to see if the store is in the list if (this.storeList.BinarySearch(this.selectedStore) < 0) { MessageBox.Show("That store has not yet been converted to Cashlinx. Please enter a different store number."); return; } string errTxt; var dTools = this.CshLnxDataTools; this.submitStoreButton.IsEnabled = false; var ninetyDaysAgo = DateTime.Now.Date.Subtract(new TimeSpan(90, 0, 0, 0)); var toDateConstruct = string.Format( "to_date('{0}/{1}/{2}', 'MM/DD/YYYY')", ninetyDaysAgo.Date.Month.ToString().PadLeft(2, '0'), ninetyDaysAgo.Date.Day.ToString().PadLeft(2, '0'), ninetyDaysAgo.Date.Year.ToString().PadLeft(4, '0')); if (!InitCouchDB()) { MessageBox.Show("Cannot connect to couch server! Exiting...", "Exit Warning"); Application.Current.Shutdown(); this.DialogResult = false; this.Close(); } var procMsg = new ProcessingMessage("*** PLEASE WAIT - FINDING DOCUMENTS ***"); procMsg.Show(); if (!DataAccessService.ExecuteQuery( false, string.Format( "select storage_id, storage_time from ccsowner.pawndocumentregistry where storenumber = '{0}' " + "and receiptdetail_number = 0 and ticket_number = 0 and doc_type = 'PDF' " + "and customernumber is null and storage_date > {1} order by storage_time desc", this.selectedStore, toDateConstruct), "ccsowner.pawndocumentregistry", PawnStoreProcedures.CCSOWNER, out dstrStorageData, ref dTools)) { procMsg.Hide(); errTxt = string.Format( "Could not find any DSTR documents for that store"); showError(errTxt); this.submitStoreButton.IsEnabled = true; return; } if (dstrStorageData == null || dstrStorageData.NumberRows <= 0) { procMsg.Hide(); errTxt = string.Format( "Could not find any DSTR documents to view"); showError(errTxt); this.submitStoreButton.IsEnabled = true; return; } //Collect dates into a temporary map this.dateStorageMap.Clear(); bool foundValidDoc = false; for (var j = 0; j < dstrStorageData.NumberRows; ++j) { DataReturnSetRow dRow; if (!dstrStorageData.GetRow(j, out dRow)) { continue; } var dRowDate = Utilities.GetDateTimeValue(dRow.GetData("STORAGE_TIME"), DateTime.Now.Date); List <PairType <string, Document> > storageIds; var ticksKey = dRowDate.Date.Ticks; if (CollectionUtilities.isNotEmptyContainsKey(this.dateStorageMap, ticksKey)) { storageIds = this.dateStorageMap[ticksKey]; } else { storageIds = new List <PairType <string, Document> >(); this.dateStorageMap.Add(ticksKey, storageIds); } //Get the storage id first var storageId = Utilities.GetStringValue(dRow.GetData("STORAGE_ID"), string.Empty); Document doc; if (IsDocumentDSTR(storageId, out doc)) { storageIds.Add(new PairType <string, Document>(storageId, doc)); foundValidDoc = true; } } procMsg.Hide(); if (!foundValidDoc) { procMsg.Hide(); errTxt = string.Format( "Could not find any DSTR documents to view for this store"); showError(errTxt); this.submitStoreButton.IsEnabled = true; return; } //Update calendar var today = DateTime.Now.Date; var tomorrowDate = DateTime.Now.Date.Add(new TimeSpan(1, 0, 0, 0)); //Clear calendar black out dates this.storeCalendar.BlackoutDates.Clear(); //Black out calendar from start of time to 90 days ago this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(DateTime.MinValue.Date, ninetyDaysAgo.Date)); //Black out calendar from tomorrow to the end of time this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(tomorrowDate.Date, DateTime.MaxValue.Date)); //Ensure store calendar is set to single date mode this.storeCalendar.SelectionMode = CalendarSelectionMode.SingleDate; //Ensure calendar is on today's date this.storeCalendar.SelectedDate = null; //Go through the ninety day range to today and black out dates we do not have storage ids for... var curDay = ninetyDaysAgo.Date; while (curDay.Date.CompareTo(today.Date) < 0) { if (!CollectionUtilities.isNotEmptyContainsKey(this.dateStorageMap, curDay.Date.Ticks)) { this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(curDay.Date)); if (FileLogger.Instance.IsLogDebug) { FileLogger.Instance.logMessage(LogLevel.DEBUG, this, "Blackout date found = " + curDay.Date.ToLongDateString() + ", Ticks = " + curDay.Date.Ticks); } } else { var idList = this.dateStorageMap[curDay.Date.Ticks]; if (CollectionUtilities.isEmpty(idList)) { this.storeCalendar.BlackoutDates.Add(new CalendarDateRange(curDay.Date)); if (FileLogger.Instance.IsLogWarn) { FileLogger.Instance.logMessage(LogLevel.WARN, this, "Date with no DSTR found = " + curDay.Date.ToLongDateString() + ", Ticks = " + curDay.Date.Ticks); } } else { if (FileLogger.Instance.IsLogDebug) { FileLogger.Instance.logMessage(LogLevel.DEBUG, this, "Valid date found = " + curDay.Date.ToLongDateString() + ", Ticks = " + curDay.Date.Ticks); } } } //Increment date curDay = curDay.Date.Add(new TimeSpan(1, 0, 0, 0)); } //Enable calendar this.storeCalendar.IsEnabled = true; } }