Ejemplo n.º 1
0
        }//initParams

        public string paramByName(String strName)
        { // Finds and returns parameter value by specified name
          // In case it is not found "" is returned (not null)
            try
            {
                if (m_dtParameters == null)
                {
                    initParams();
                }

                DataRow dr = m_dtParameters.Rows.Find(strName);

                if (dr == null)
                {
                    return("");
                }
                else
                {
                    return(dr["Value"].ToString());
                }
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
                throw;
            }
        }//paramByName
Ejemplo n.º 2
0
        }//setIniFileName

        #endregion Constructors, Initialization & Destructor

        #region Methods

        #region Initialization

        public void loadApplicationSettings()
        { // Loads application settings from file and sets cProperties accordingly
            try
            {
                verifyFileExists();
                //setSettingsCollection();
                setPropertiesFromFile();
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
        }//loadApplicationSettings
Ejemplo n.º 3
0
        }//getDataTableEditable

        #endregion DataTable handler

        #region Import related methods

        public List <DataRow> setLocalDbSecuritiesCollection(ref List <DataRow> colSelectedSecs)
        { // Sets & reads the securities found on local DB
            // Remove securities from collection of SecsForImport (if exists in LocalDB)
            List <DataRow> lstRowsToDelete = new List <DataRow>();
            List <DataRow> lstLocalSecs    = new List <DataRow>();

            try
            {
                DataTable dtLocalDbSecs = cDbOleConnection.FillDataTable(cSqlStatements.getSecuritiesList(colSelectedSecs), m_SqlCeConnection);

                lstLocalSecs.Clear();
                foreach (DataRow dr in colSelectedSecs)
                { // Goes through list of selected securities
                    DataRow[] arrFound = dtLocalDbSecs.Select("idSecurity = '" + dr["idSecurity"].ToString() + "'");
                    if (arrFound.Length > 0)
                    { // Found on Local DB
                        lstRowsToDelete.Add(dr);
                        lstLocalSecs.Add(arrFound[0]);
                    }
                }//main for

                for (int iSecs = 0; iSecs < lstRowsToDelete.Count; iSecs++)
                {
                    colSelectedSecs.Remove(lstRowsToDelete[iSecs]); // Remove securities from server import
                }
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
            return(lstLocalSecs);
        }//setLocalDbSecuritiesCollection
Ejemplo n.º 4
0
        }//constructor

        #endregion Constructors, Initialization & Destructor

        #region Methods

        #region Matrix conversions

        public double[,] get1dTo2dArr(double[] origMatrix, Size matSize)
        { // Transforms a 1-dimensional array to a 2-dimensional matrix
            double[,] finalArr = null;
            finalArr           = new double[matSize.Height, matSize.Width];
            int iPosVar    = 0;
            int iPosVarCnt = 0;
            int iLen       = 0;

            try
            {
                for (iLen = 0; iLen <= origMatrix.Length - 1; iLen++)
                {
                    if (iPosVarCnt == matSize.Height)
                    {
                        iPosVar   += 1;
                        iPosVarCnt = 0;
                    }
                    finalArr[iPosVarCnt, iPosVar] = origMatrix[iLen];
                    iPosVarCnt += 1;
                }
                return(finalArr);
            } catch (IndexOutOfRangeException exInd) {
                m_objErrorHandler.LogInfo(exInd.Message);
                return(finalArr);
            }
        } // get1dTo2dArr
Ejemplo n.º 5
0
        private const String m_cnstFileName = "AppSettings.dat"; // Ini file name (excluding folder)

        #endregion Data memebers

        #region Constructors, Initialization & Destructor

        public cSettingsHandler(cErrorHandler cErrors)
        {
            m_objErrorHandler = cErrors;

            try
            {
                setSettingsFileName();
                loadApplicationSettings();
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
        }//constructor
Ejemplo n.º 6
0
        private Size m_sizeDimensions; // String representations of matrix columns

        #endregion Data Members

        #region Constructors, Initialization & Destructor

        public cEngineWrapper(cErrorHandler cErrHandler)
        {
            try
            {
                m_objErrorHandler = cErrHandler;

                //cEngineAssemblies cEng = new cEngineAssemblies(m_objErrorHandler);
                m_objEngine = new cScilab();
            } catch (Exception ex) {
                cErrHandler.LogInfo(ex);
            }
        }//constructor
Ejemplo n.º 7
0
 public cDbOleConnection(cErrorHandler cErrHandler)
 {
     m_objErrorHandler = cErrHandler;
     try
     {
         //m_strDbFileName = getCroppedPath(cProperties.DataFolder + "\\Database\\" + m_strDbName);
         m_strDbFileName = cProperties.DataFolder + "\\Database\\" + m_strDbName;
         setDbConnection();
         _DBWorker = new cDBWorker(m_objSqlConn);
     } catch (Exception ex) {
         m_objErrorHandler.LogInfo(ex);
     }
 }// of constructor
Ejemplo n.º 8
0
        }//constructor

        #endregion Constructors, Initialization & Destructor

        #region Methods

        public void setSecurityPrices(cDateRange cDrPort)
        { // Sets the prices of the securities relevant for the portfolio date range
            if (m_objCurrSec == null)
            {
                return;
            }
            try
            {
                m_dStartPrice = getSecurityPrice(cDrPort.StartDate);
                m_dEndDate    = getSecurityPrice(cDrPort.EndDate);
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
        }//setSecurityPrices
Ejemplo n.º 9
0
        private String m_strValueFldName;    // Name of value field (for preparation of work matrix)

        #endregion Data members

        #region Constructors, Initialization & Destructor

        public cDataTable(DataTable myDataTable, cSecurities mySecurities, cErrorHandler cErrHandler, String strSecFld, String strValueFld)
        { // This constructor is for the new table format
            // Init variables
            m_dtMain             = myDataTable;
            m_objErrorHandler    = cErrHandler;
            m_objSecCollection   = mySecurities;
            m_strSecurityFldName = strSecFld;
            m_strValueFldName    = strValueFld;

            try
            {
                setMinMaxVals();
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
            //if (m_dtMain.Rows.Count != 0) m_dWorkMatrix = getWorkMatrixCrossTbl(); // set working matrix
        }// constructor
Ejemplo n.º 10
0
        }//constructor

        #endregion Constructors, Initialization & Destructor

        #region Methods

        #region Main methods

        public void bringUpToDateAllSecurities()
        { // Brings up to date all of the securities in the database
            string lastUSD = "";

            DataTable dtAllSecs;

            //if(!cLicenseParams.isPrivate)
            dtAllSecs = cDbOleConnection.FillDataTable(cSqlStatements.getAllSecuritiesSortedSQL(), m_objDbConnection.dbConnection);
            //else dtAllSecs = cDbOleConnection.FillDataTable(cSqlStatements.getSecuritiesByPortIdSQL(idPortfolio), m_objDbConnection.dbConnection);


            if (dtAllSecs.Rows.Count == 0)
            {
                lastUSD = GetLastUSDprice();

                return;
            }

            String strSecIds = getIDListForSP(dtAllSecs);

            //string lastBringUpToDate = m_frmMain.ParameterHandler.paramByName("LastBringUpToDate");
            //if (lastBringUpToDate != "")
            //    cProperties.LastUpdate = DateTime.ParseExact(lastBringUpToDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);

            try
            {
                if (cProperties.LastUpdate < DateTime.Today)
                { // Need to bring up to date
                    DataSet dsServerData = bringUpToDateData(strSecIds, cProperties.LastUpdate, DateTime.Today.AddDays(-1));
                    setUpdatedSecurityValues(dsServerData);

                    lastUSD = dsServerData.ExtendedProperties["LastUSDprice"].ToString();
                    if (lastUSD == "")
                    {
                        cProperties.LastDollarVal = Convert.ToDouble(cGeneralFunctions.insteadValue(param.paramByName("LastUSDprice"), "390.5"));
                    }
                    else
                    {
                        cProperties.LastDollarVal = Convert.ToDouble(lastUSD);
                    }

                    DataTable dtHistoricalData = dsServerData.Tables["tbl_Securities"]; // Don't be mistaken by the name - it's tbl_Prices

                    // Delete previous prices
                    cDbOleConnection.executeSqlSatatement(cSqlStatements.deleteDbOldPrices(DateTime.Today.AddYears(-cProperties.DatesInterval).AddDays(-1)), m_objDbConnection.dbConnection);
                    // Writes all prices after removing the concatinating previous data
                    cDbOleConnection.writePricesWithBulk(dtHistoricalData, m_objDbConnection.dbConnection, cDbOleConnection.TblPrices);
                    // Updates portfolios end dates
                    cDbOleConnection.executeSqlSatatement(cSqlStatements.updtPortfolioEndDates(cProperties.LastUpdate), m_objDbConnection.dbConnection);
                    //add code update parameter "lastBrinngUpToDate"  DateTime.Today
                    param.updateParamByValue("LastBringUpToDate", DateTime.Today.ToString("yyyy-MM-dd"));
                    if (lastUSD != "")
                    {
                        param.updateParamByValue("LastUSDprice", lastUSD);     //cProperties.LastDollarVal.ToString());
                    }
                }
                else
                {
                    cProperties.LastDollarVal = Convert.ToDouble(cGeneralFunctions.insteadValue(param.paramByName("LastUSDprice"), "390.5"));
                }
            } catch (Exception ex) {
                m_objErrorHandler.LogInfo(ex);
            }
        }//bringUpToDateAllSecurities