/// <summary>
        ///
        /// </summary>
        /// <param name="environmentStr"></param>
        /// <param name="errTxt"></param>
        /// <returns></returns>
        private bool loadEnvironmentData(string environmentStr, out string errTxt)
        {
            errTxt = string.Empty;
            var rt = true;

            if (string.IsNullOrEmpty(environmentStr))
            {
                errTxt = "Invalid environment string.";
                return(false);
            }

            //Setup file logger
            FileLogger.Instance.initializeLogger(
                string.Format("logs/dstr_viewer_{0}.log", DateTime.Now.Ticks),
                DefaultLoggerHandlers.defaultLogLevelCheckHandler,
                DefaultLoggerHandlers.defaultLogLevelGenerator,
                DefaultLoggerHandlers.defaultDateStampGenerator,
                DefaultLoggerHandlers.defaultLogMessageHandler,
                DefaultLoggerHandlers.defaultLogMessageFormatHandler);
            FileLogger.Instance.setEnabled(true);
            FileLogger.Instance.setLogLevel(LogLevel.DEBUG);

            //Setup audit logger
            this.auditLogger = AuditLogger.Instance;
            this.auditLogger.SetAuditLogEnabledChangeHandler(auditLogEnabledChangeHandler);
            this.auditLogger.SetAuditLogHandler(logAuditMessageHandler);
            this.auditLogger.SetEnabled(true);

            //Pwn sec tuples (user name, password, host, port, schema, service)
            var internalStorage = new Dictionary <string, Tuple <string, string, string, string, string, string> >(8)
            {
                {
                    "CLXD3", new Tuple <string, string, string, string, string, string>
                        (@"Ny2VIxVYqnA=", @"jZekk5GlbvfnRVTll7RpCw==",
                        @"5HYH35IsmBLxuFKgDA0deV4cSI9w/aeE", @"c5oa+iWxTPs=", @"Ny2VIxVYqnA=",
                        @"tN2vG1Y6pleVpj7+YIrMdxtI3uI0kDL1")
                },
                {
                    "CLXI", new Tuple <string, string, string, string, string, string>
                        (@"Ny2VIxVYqnA=", @"jZekk5GlbvfnRVTll7RpCw==",
                        @"1xaOn6Ot6HRjXbIPl7E2WJ3Bs9SmWpEy", @"c5oa+iWxTPs=", @"Ny2VIxVYqnA=",
                        @"7GS8RS4GC4MRrLvSkAHG8w==")
                },
                {
                    "CLXT", new Tuple <string, string, string, string, string, string>
                        (@"Ny2VIxVYqnA=", @"jZekk5GlbvfnRVTll7RpCw==",
                        @"bYtNZ/PbgPkj30psRLKPF+5CvrNdg5WA", @"07s4aRvDFLs=", @"Ny2VIxVYqnA=",
                        @"BBBxdZodCA0RrLvSkAHG8w==")
                },
                {
                    "CLXT2", new Tuple <string, string, string, string, string, string>
                        (@"Ny2VIxVYqnA=", @"jZekk5GlbvfnRVTll7RpCw==",
                        @"bYtNZ/PbgPkj30psRLKPF+5CvrNdg5WA", @"07s4aRvDFLs=", @"Ny2VIxVYqnA=",
                        @"Ny/sG2mylyCVpj7+YIrMdxtI3uI0kDL1")
                },
                {
                    PROD, new Tuple <string, string, string, string, string, string>
                        (@"Ny2VIxVYqnA=", @"jZekk5GlbvfnRVTll7RpCw==",
                        @"bIyV3M7QftbxuFKgDA0deV4cSI9w/aeE", @"07s4aRvDFLs=", @"Ny2VIxVYqnA=",
                        @"ZisF3qmLAEMRrLvSkAHG8w==")
                }
            };



            //Construct data storage at runtime and select based on environment string
            //Grab the tuple and make the proper connections
            if (CollectionUtilities.isNotEmptyContainsKey(internalStorage, environmentStr))
            {
                var cxnInfo = internalStorage[environmentStr];
                var privKey = Common.Properties.Resources.PrivateKey;
                if (cxnInfo != null)
                {
                    //Create pawn security connection credentials
                    this.pwnSecCred = new Credentials
                    {
                        UserName  = StringUtilities.Decrypt(cxnInfo.Item1, privKey, true),
                        PassWord  = StringUtilities.Decrypt(cxnInfo.Item2, privKey, true),
                        DBHost    = StringUtilities.Decrypt(cxnInfo.Item3, privKey, true),
                        DBPort    = StringUtilities.Decrypt(cxnInfo.Item4, privKey, true),
                        DBService = StringUtilities.Decrypt(cxnInfo.Item6, privKey, true),
                        DBSchema  = StringUtilities.Decrypt(cxnInfo.Item5, privKey, true)
                    };

                    //Create pawn security data access tools
                    this.pwnSecDataTools = DataAccessService.CreateDataAccessTools();
                    if (!DataAccessService.Connect(PawnStoreProcedures.PAWNSEC, this.pwnSecCred, DataAccessTools.ConnectMode.MULTIPLE, DataAccessTools.LogMode.DEBUG, ref this.pwnSecDataTools))
                    {
                        errTxt = "Could not connect to pawn security database.";
                        if (FileLogger.Instance.IsLogError)
                        {
                            FileLogger.Instance.logMessage(LogLevel.ERROR, this, errTxt);
                        }
                        rt = false;
                    }
                    else
                    {
                        //Create pawn sec vo
                        this.pawnSecData = new PawnSecVO();
                        string decryptKey;

                        //Get primary oracle connection credentials
                        if (!PawnStoreProcedures.GetAllPawnSecData(ref this.pwnSecDataTools, ref this.pawnSecData, out decryptKey))
                        {
                            errTxt = "Could not load pawn security data for selected environment";
                            if (FileLogger.Instance.IsLogError)
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, this, errTxt);
                            }
                            rt = false;
                        }
                        else
                        {
                            //Get the oracle server info
                            this.databaseServer = this.pawnSecData.DatabaseServiceList.Find(
                                vo => (string.Equals(vo.ServiceType, EncryptedConfigContainer.ORACLEKEY, StringComparison.Ordinal)));

                            //Connect to the primary Oracle server
                            this.cshLnxCred = new Credentials
                            {
                                UserName  = StringUtilities.Decrypt(this.databaseServer.DbUser, decryptKey, true),
                                PassWord  = StringUtilities.Decrypt(this.databaseServer.DbUserPwd, decryptKey, true),
                                DBHost    = StringUtilities.Decrypt(this.databaseServer.Server, decryptKey, true),
                                DBPort    = StringUtilities.Decrypt(this.databaseServer.Port, decryptKey, true),
                                DBService = StringUtilities.Decrypt(this.databaseServer.AuxInfo, decryptKey, true),
                                DBSchema  = StringUtilities.Decrypt(this.databaseServer.Schema, decryptKey, true)
                            };

                            this.cshLnxDataTools = DataAccessService.CreateDataAccessTools();
                            if (!DataAccessService.Connect(PawnStoreProcedures.CCSOWNER, this.cshLnxCred, DataAccessTools.ConnectMode.MULTIPLE,
                                                           DataAccessTools.LogMode.DEBUG, ref this.cshLnxDataTools))
                            {
                                errTxt = "Could not connect to primary Cashlinx database";
                                if (FileLogger.Instance.IsLogError)
                                {
                                    FileLogger.Instance.logMessage(LogLevel.ERROR, this, errTxt);
                                }
                                rt = false;
                            }
                            else
                            {
                                //Get the couch server info
                                this.couchServer = this.pawnSecData.DatabaseServiceList.Find(
                                    vo => (string.Equals(vo.ServiceType, EncryptedConfigContainer.COUCHDBKEY, StringComparison.Ordinal)));
                                //Get the LDAP server info

                                //Change #00042 - Removing LDAP authentication from DSTR viewer

                                /*this.ldapServer = this.pawnSecData.DatabaseServiceList.Find(
                                 *  vo => (string.Equals(vo.ServiceType, EncryptedConfigContainer.LDAPKEY, StringComparison.Ordinal)));*/

                                //Setup the LDAP connection
                                this.encConfig = new EncryptedConfigContainer(
                                    Common.Properties.Resources.PrivateKey,
                                    this.pawnSecData.GlobalConfiguration.DataPublicKey,
                                    "00152",   //Hard coded to 00152 for pawn security retrieval - GJL 05/08/2012
                                    this.pawnSecData,
                                    PawnSecApplication.None,
                                    true);

                                //Change #00042 - Removing LDAP authentication from DSTR viewer

                                /*
                                 * var ldapService =
                                 *  conf.GetLDAPService(
                                 *      out loginDN,
                                 *      out searchDN,
                                 *      out userIdKey,
                                 *      out userPwd,
                                 *      out pwdPolicyCN);
                                 * if (ldapService != null && FileLogger.Instance.IsLogDebug)
                                 * {
                                 *  FileLogger.Instance.logMessage(
                                 *      LogLevel.DEBUG, this, "- Connecting to LDAP server:{0}{1}",
                                 *      System.Environment.NewLine, conf.DecryptValue(ldapService.Server));
                                 * }
                                 *
                                 * //Connect to the LDAP server
                                 * PawnLDAPAccessor.Instance.InitializeConnection(
                                 *  conf.DecryptValue(ldapService.Server),
                                 *  conf.DecryptValue(ldapService.Port),
                                 *  loginDN,
                                 *  userPwd,
                                 *  pwdPolicyCN,
                                 *  searchDN,
                                 *  userIdKey);
                                 *
                                 * if (PawnLDAPAccessor.Instance.State != PawnLDAPAccessor.LDAPState.CONNECTED)
                                 * {
                                 *  errTxt = "Could not connect to the LDAP Server";
                                 *  if (FileLogger.Instance.IsLogError)
                                 *  {
                                 *      FileLogger.Instance.logMessage(LogLevel.ERROR, this, errTxt);
                                 *  }
                                 *  rt = false;
                                 * }
                                 * else
                                 * {
                                 *  //Authenticate the user
                                 *  var attemptCount = 1;
                                 *  DateTime pwdLastMod;
                                 *  bool lockedOut;
                                 *  string[] pwdHistory;
                                 *  string displayName;
                                 *  if (!PawnLDAPAccessor.Instance.AuthorizeUser(
                                 *      this.curUserName, this.curPassword, ref attemptCount,
                                 *      out pwdLastMod, out pwdHistory, out displayName, out lockedOut))
                                 *  {
                                 *      errTxt = "Could not verify user name and password";
                                 *      if (FileLogger.Instance.IsLogError)
                                 *      {
                                 *          FileLogger.Instance.logMessage(LogLevel.ERROR, this, errTxt);
                                 *      }
                                 *      rt = false;
                                 *  }
                                 * }
                                 */
                            }
                        }
                    }
                }
                else
                {
                    errTxt = "Could not find valid connection info in internal environment data.";
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this, errTxt);
                    }
                    rt = false;
                }
            }
            else
            {
                errTxt = "Environment string not found in internal environment data.";
                if (FileLogger.Instance.IsLogError)
                {
                    FileLogger.Instance.logMessage(LogLevel.ERROR, this, errTxt);
                }
                rt = false;
            }

            return(rt);
        }
예제 #2
0
        //*********************************************************************
        //** Date created: Tuesday, Jan 19, 2010
        //** Created by  : PAWN\rmcbai1
        //*********************************************************************
        /// <summary>
        ///    build the datasets needed to generate the report
        /// </summary>
        ///
        /// <returns> the data needed to build the report ( DataSet)</returns>
        //*********************************************************************
        public DataSetOutput BuildDataset()
        {
            _reportData = null;

            try
            {
                DataAccessTools dataAccessTools = DataAccessService.CreateDataAccessTools();

                DataAccessService.Connect(_Credentials,
                                          DataAccessTools.ConnectMode.SINGLE,
                                          DataAccessTools.LogMode.DEBUG,
                                          ref dataAccessTools);


                List <OracleProcParam> inParams = new List <OracleProcParam>();

                inParams.Add(new OracleProcParam("store_num", _storeNum));
                string date_in = _runDate.ToString("d");
                inParams.Add(new OracleProcParam("date_in", date_in));

                string date_out = _runEndDate.ToString("d");
                inParams.Add(new OracleProcParam("date_out", date_out));

                List <PairType <string, string> > refCursors = new List <PairType <string, string> >();
                refCursors.Add(new PairType <string, string>("o_disp_data", "DISP_DATA"));

                inParams.Add(new OracleProcParam("o_store_name", OracleDbType.Varchar2, _storeName, ParameterDirection.Output, 100));

                bool retval = DataAccessService.ExecuteStoredProc(_Credentials.DBSchema
                                                                  , "PAWN_REPORTS"
                                                                  , "getData"
                                                                  , inParams
                                                                  , null
                                                                  , refCursors
                                                                  , "o_error_code"
                                                                  , "o_error_text"
                                                                  , null
                                                                  , out _errCode
                                                                  , out _errTxt
                                                                  , out _reportData
                                                                  , ref dataAccessTools);

                if (!retval)
                {
                    retval = DataAccessService.ExecuteStoredProc(_Credentials.DBSchema
                                                                 , "PAWN_REPORTS"
                                                                 , "getData"
                                                                 , inParams
                                                                 , null
                                                                 , refCursors
                                                                 , "o_error_code"
                                                                 , "o_error_text"
                                                                 , null
                                                                 , out _errCode
                                                                 , out _errTxt
                                                                 , out _reportData
                                                                 , ref dataAccessTools);
                }


                if (!retval)
                {
                    _errCode = "1";
                    _errTxt  = "An error occurred retrieving the report data.  Please try again, if this error persists then contact support.";
                }
            }
            catch (Exception ex)
            {
                _reportData = null;
                _errCode    = "1";
                _errTxt     = ex.Message;
            }


            return(_reportData);
        }
예제 #3
0
        //*********************************************************************
        //** Date created: Tuesday, Jan 19, 2010
        //** Created by  : PAWN\rmcbai1
        //*********************************************************************
        /// <summary>
        ///    build the datasets needed to generate the report
        /// </summary>
        ///
        /// <returns> the data needed to build the report ( DataSet)</returns>
        //*********************************************************************
        public DataSetOutput BuildDataset()
        {
            _reportData = null;

            try
            {
                DataAccessTools dataAccessTools = DataAccessService.CreateDataAccessTools();

                DataAccessService.Connect(_Credentials,
                                          DataAccessTools.ConnectMode.SINGLE,
                                          DataAccessTools.LogMode.DEBUG,
                                          ref dataAccessTools);


                List <OracleProcParam> inParams = new List <OracleProcParam>();

                inParams.Add(new OracleProcParam("store_num", _storeNum));
                string date_in = _runDate.ToString("d");
                inParams.Add(new OracleProcParam("date_in", date_in));

                List <PairType <string, string> > refCursors = new List <PairType <string, string> >();
                refCursors.Add(new PairType <string, string>("o_cash_adv_1", "CASH_ADV_1"));
                refCursors.Add(new PairType <string, string>("o_xpp_2", "XPP_2"));
                refCursors.Add(new PairType <string, string>("o_payment_3", "PAYMENT_3"));
                refCursors.Add(new PairType <string, string>("o_recissions_4", "RECISSIONS_4"));
                refCursors.Add(new PairType <string, string>("o_debit_card_5", "DEBIT_CARDS_5"));
                refCursors.Add(new PairType <string, string>("o_phone_card_6", "PHONE_CARDS_6"));
                refCursors.Add(new PairType <string, string>("o_safe_transfer_7", "SAFE_TRANSFER_7"));
                refCursors.Add(new PairType <string, string>("o_drawer_transfer_7", "DRAWER_TRANSFER_7"));
                refCursors.Add(new PairType <string, string>("o_check_cashing_8", "CHECK_CASHING_8"));
                refCursors.Add(new PairType <string, string>("o_insurance_9", "INSURANCE_9"));
                refCursors.Add(new PairType <string, string>("o_convenience_11", "CONVENIENCE_11"));
                refCursors.Add(new PairType <string, string>("o_tax_prep_12", "TAX_PREP_12"));
                refCursors.Add(new PairType <string, string>("o_other_13", "OTHER_13"));
                refCursors.Add(new PairType <string, string>("o_money_order_14", "MONEY_ORDER_14"));
                refCursors.Add(new PairType <string, string>("o_wire_transfer_15", "WIRE_TRANSFER_15"));
                refCursors.Add(new PairType <string, string>("o_coupons_16", "COUPONS_16"));
                refCursors.Add(new PairType <string, string>("o_petty_cash_17", "PETTY_CASH_17"));
                refCursors.Add(new PairType <string, string>("o_paid_inout_18", "PAID_INOUT18"));
                refCursors.Add(new PairType <string, string>("o_extensions_19", "EXTENSIONS_19"));
                refCursors.Add(new PairType <string, string>("o_cancel_cso_20", "CANCEL_CSO_20"));
                refCursors.Add(new PairType <string, string>("o_ach_rvk_21", "ACH_RVK_21"));
                refCursors.Add(new PairType <string, string>("o_waive_off_22", "WAIVE_OFF_22"));
                refCursors.Add(new PairType <string, string>("o_reimbsmts_23", "REIMBURSEMENTS_23"));
                refCursors.Add(new PairType <string, string>("o_new_loans_24", "NEW_LOANS_24"));
                refCursors.Add(new PairType <string, string>("o_ext_25", "EXT_25"));
                refCursors.Add(new PairType <string, string>("o_renew_26", "RENEW_26"));
                refCursors.Add(new PairType <string, string>("o_paydown_27", "PAYDOWN_27"));
                refCursors.Add(new PairType <string, string>("o_pickup_28", "PICKUP_28"));
                refCursors.Add(new PairType <string, string>("o_seizure_29", "SEIZURE_29"));
                refCursors.Add(new PairType <string, string>("o_police_ret_30", "POLICE_RET_30"));
                refCursors.Add(new PairType <string, string>("o_claim_rel_31", "CLAIM_REL_31"));
                refCursors.Add(new PairType <string, string>("o_pfi_32", "PFI_32"));
                refCursors.Add(new PairType <string, string>("o_transfer_out_33", "TRANSFER_OUT_33"));
                refCursors.Add(new PairType <string, string>("o_purchase_37", "PURCHASE_37"));
                refCursors.Add(new PairType <string, string>("o_return_38", "RETURN_38"));

                refCursors.Add(new PairType <string, string>("O_RETAIL_40", "RETAIL_40"));
                refCursors.Add(new PairType <string, string>("O_RETAIL_40_DETL", "RETAIL_40_DETL"));
                refCursors.Add(new PairType <string, string>("O_LAYAWAY_41", "LAYAWAY_41"));
                refCursors.Add(new PairType <string, string>("O_LAYAWAY_41_DETL", "LAYAWAY_41_DETL"));
                refCursors.Add(new PairType <string, string>("O_SALE_REFUND", "SALE_REFUND"));
                refCursors.Add(new PairType <string, string>("O_SALE_REFUND_DETL", "SALE_REFUND_DETL"));
                refCursors.Add(new PairType <string, string>("O_LAYAWAY_REFUND", "LAYAWAY_REFUND"));
                refCursors.Add(new PairType <string, string>("o_forfeited", "LAYAWAY_TERMATION"));
                refCursors.Add(new PairType <string, string>("o_charge_off", "CHARGE_OFF"));
                refCursors.Add(new PairType <string, string>("O_PARPYMT_45", "O_PARPYMT_45"));

                /* var outParamList = new List<TupleType<string, DataTypeConstants.PawnDataType, int>>(1)
                 *                       {
                 *                           new TupleType<string, DataTypeConstants.PawnDataType, int>
                 *                                   (
                 *                                       "o_store_name",
                 *                                       DataTypeConstants.PawnDataType.STRING, 40
                 *                                   )
                 *                       };*/
                inParams.Add(new OracleProcParam("o_store_name", OracleDbType.Varchar2, _storeName, ParameterDirection.Output, 100));
                bool retval = DataAccessService.ExecuteStoredProc(_Credentials.DBSchema
                                                                  , "PAWN_DSTR"
                                                                  , "get_dstr_data"
                                                                  , inParams
                                                                  , null
                                                                  , refCursors
                                                                  , "o_error_code"
                                                                  , "o_error_text"
                                                                  , null
                                                                  , out _errCode
                                                                  , out _errTxt
                                                                  , out _reportData
                                                                  , ref dataAccessTools);

                if (!retval)
                {
                    retval = DataAccessService.ExecuteStoredProc(_Credentials.DBSchema
                                                                 , "PAWN_DSTR"
                                                                 , "get_dstr_data"
                                                                 , inParams
                                                                 , null
                                                                 , refCursors
                                                                 , "o_error_code"
                                                                 , "o_error_text"
                                                                 , null
                                                                 , out _errCode
                                                                 , out _errTxt
                                                                 , out _reportData
                                                                 , ref dataAccessTools);
                }


                if (!retval)
                {
                    _errCode = "1";
                    _errTxt  = "An error occurred retrieving the report data.  Please try again, if this error persists then contact support.";
                }
            }
            catch (Exception ex)
            {
                _reportData = null;
                _errCode    = "1";
                _errTxt     = ex.Message;
            }


            return(_reportData);
        }