/// <summary>
        /// Method to write log entry into database
        /// </summary>
        /// <param name="logEntry">Log entry</param>
        public static void LogWriteCallback(object logEntry)
        {
            ArrayList paramList = ((Log)logEntry).DbParamList(0);

            dbLib.ExecuteProcedure("sp_insert_pdr_logs", paramList);

            //cleanup
            paramList.Clear();
            paramList = null;
            logEntry  = null;
        }
        /// <summary>
        /// Persists the TradeRecord record in database
        /// </summary>
        private void InsertIntoDatabase()
        {
            // Must be a new tradeRecord to insert, Throw an exception if existing tradeRecord is tried to insert
            if (!_isNewTradeRecord)
            {
                throw new InvalidOperationException("TradeRecord Id: " + OrderRefenceNumber + "already exists in the System");
            }

            DBLibrary dbLib = new DBLibrary();

            dbLib.ExecuteProcedure("sp_insert_st_derivatives_tradebook", DbParamList(0));

            // Now it is no more a new tradeRecord as it is entered into the system
            _isNewTradeRecord = false;
        }
Beispiel #3
0
 public void Persist()
 {
     _dbLib.ExecuteProcedure("sp_upsert_st_trading_eod_statsbook", DbParamList(1));
 }
        public static void RunOnRentPages()
        {
            int runType    = int.Parse(Config.ConfigMap["runtype"]);
            int minutesold = int.Parse(Config.ConfigMap["minutesold"]);

            ROOT_DIR          = Config.ConfigMap["rootdir"];
            CONNECTION_STRING = Config.ConfigMap["connectionstring"];

            DateTime etlStartTime = DateTime.UtcNow;

            ROOT_PROPERTIES_DIR = ROOT_DIR + @"Properties\";
            REF_FILES_DIR       = ROOT_DIR + @"1_REF_FILES\";

            //var citiesFile = ROOT_DIR + CITIES_REF_FILE;
            //var cities = File.ReadAllLines(citiesFile);

            var cities = Config.ConfigMap["cities"].Split(',');

            //Data
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            DBLibrary            db = new DBLibrary(CONNECTION_STRING);

            foreach (var city in cities)
            {
                Log.Info("Starting to do city: " + city);

                var cityNewPropertyFilePathsFile = REF_FILES_DIR + string.Format(CITYWISE_PROPERTY_FILEPATHS_REF_FILE, city);

                IEnumerable <string> filePaths;

                var cityDir = Path.Combine(ROOT_PROPERTIES_DIR, city);

                var listingsDir = Path.Combine(cityDir, "Listings");

                if (runType == 0)
                {
                    filePaths = File.ReadAllLines(cityNewPropertyFilePathsFile);
                }
                else
                {
                    filePaths = Directory.EnumerateFiles(listingsDir, "*", SearchOption.AllDirectories);
                }


                foreach (var propertyFile in filePaths)
                {
                    //Log.InfoFormat("#{0} - {1}", totalPropertiesCntr, propertyFile);

                    Interlocked.Increment(ref totalPropertiesCntr);
                    if (runType == 2)
                    {
                        if ((new FileInfo(propertyFile).LastWriteTimeUtc.Date < etlStartTime.Date))
                        {
                            continue;
                        }
                    }
                    if (runType == 3)
                    {
                        if ((new FileInfo(propertyFile).LastWriteTimeUtc < etlStartTime.AddMinutes(-minutesold)))
                        {
                            continue;
                        }
                    }
                    Log.InfoFormat("#{0} Inserting - {1}", newPropertiesInsertedCntr, propertyFile);
                    Interlocked.Increment(ref newPropertiesInsertedCntr);

                    var propertyData = File.ReadAllText(propertyFile);
                    var tmpIdx       = 0;

                    var propDescJsonBody = StringParser.GetStringBetween(propertyData,
                                                                         tmpIdx,
                                                                         PropDescStart,
                                                                         PropDescEnd, null, out tmpIdx);

                    if (tmpIdx > 0 && !string.IsNullOrEmpty(propDescJsonBody))
                    {
                        propDescJsonBody += "}";

                        var jsonDto = json_serializer.Deserialize <PropertyRentCFJsonDto>(propDescJsonBody);

                        var storageDto = ConvertCFJsonDtoToStorageDto(jsonDto);

                        db.ExecuteProcedure("dbo.RentDataDelsertCommand", storageDto.DbParamListForInsert());
                        // save the json
                    }
                }
            }

            Log.InfoFormat("Properties ETL stats - new loaded: {0}, total files available: {1}", newPropertiesInsertedCntr, totalPropertiesCntr);
        }
        /// <summary>
        /// Update the tradeRecord into database
        /// </summary>
        private void UpdateIntoDatabase()
        {
            DBLibrary dbLib = new DBLibrary();

            dbLib.ExecuteProcedure("sp_upsert_st_derivatives_tradebook", DbParamList(1));
        }
Beispiel #6
0
        /// <summary>
        /// Gets the equity order detail from database
        /// </summary>
        /// <param name="orderExchangeRef">order reference to get details for</param>
        /// <returns>true if record found, false otherwise</returns>
        //private bool GetOrderRecordFromDatabase(string orderExchangeRef)
        //{
        //    bool doesOrderRecordExist = false;

        //    DBLibrary dbLib = new DBLibrary();
        //    DBUtilities dbUtilities = new DBUtilities();

        //    try
        //    {
        //        ArrayList paramList = new ArrayList();
        //        paramList.Add(dbUtilities.CreateSqlParamater("@orderRecordId", SqlDbType.VarChar, 50, ParameterDirection.Input, orderExchangeRef));

        //        // Query the database for an orderRecord with given orderRecordId
        //        DataSet ds = dbLib.ExecuteProcedureDS("sp_select_pdr_orderRecord", paramList);

        //        if (ds != null &&
        //            ds.Tables != null &&
        //            ds.Tables.Count > 0)
        //        {
        //            DataTable dt = ds.Tables[0];

        //            if (dt.Rows.Count > 0)
        //            {
        //                DataRow dr = dt.Rows[0];

        //                // Get StockOrderBookRecord data
        //                Date = DateTime.Parse(dr["date"].ToString());
        //                ContractName = dr["contract"].ToString();
        //                Direction = (OrderDirection)Enum.Parse(typeof(OrderDirection), dr["direction"].ToString());
        //                Quantity = int.Parse(dr["qty"].ToString());
        //                Price = double.Parse(dr["price"].ToString());
        //                OrderRefenceNumber = dr["order_ref"].ToString();
        //                Exchange = (Exchange)Enum.Parse(typeof(Exchange), dr["exchange"].ToString());
        //                OrderStatus = (OrderStatus)Enum.Parse(typeof(OrderStatus), dr["status"].ToString());
        //                OpenQty = int.Parse(dr["qty_open"].ToString());
        //                ExecutedQty = int.Parse(dr["qty_executed"].ToString());
        //                ExpiredQty = int.Parse(dr["qty_expired"].ToString());
        //                CancelledQty = int.Parse(dr["qty_cancelled"].ToString());
        //                StopLossPrice = double.Parse(dr["stoploss_price"].ToString());
        //                UpdatedAt = DateTime.Parse(dr["status_update_time"].ToString());
        //                AlgoId = int.Parse(dr["algo_id"].ToString());

        //                doesOrderRecordExist = true;
        //            }
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        // If we failed, trace the error for log analysis
        //        Logger.LogException(ex);
        //        throw;
        //    }

        //    return doesOrderRecordExist;
        //}

        /// <summary>
        /// Persists the OrderRecord record in database
        /// </summary>
        private void InsertIntoDatabase()
        {
            DBLibrary dbLib = new DBLibrary();

            dbLib.ExecuteProcedure("sp_insert_st_derivatives_quote", DbParamList(0));
        }