예제 #1
0
        public string LoadMCData()
        {
            string message = string.Empty;

            try
            {
                string        masterMCpath = ConfigurationManager.AppSettings["MasterMCpath"];
                MC            objData      = new MC();
                OBJtoXML      xmltoObj     = new OBJtoXML();
                List <MCData> data         = objData.LoadData();
                xmltoObj.CreateXML(data, masterMCpath, "MCData", false);
                message = "Loaded MC Data";
            }

            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(message);
        }
예제 #2
0
        public void ProcessData()
        {
            try
            {
                string[] _logfilePath          = ConfigurationManager.AppSettings["timeToLoadData"].Split(',');
                string[] _updateDMADataNow     = ConfigurationManager.AppSettings["UpdateDMADataNow"].Split(',');
                string[] _loadDataNow          = ConfigurationManager.AppSettings["LoadDataNow"].Split(',');
                string   _masterDatapathBasic  = ConfigurationManager.AppSettings["MasterDatapathBasic"];
                string   _masterDMAExcelSource = ConfigurationManager.AppSettings["MasterDMAExcelSource"];
                string   _masterDatapathDMA    = ConfigurationManager.AppSettings["MasterDatapathDMA"];

                string _defaultDate = "0";


                TimeSpan now = DateTime.Now.TimeOfDay;
                foreach (string item in _logfilePath)
                {
                    int h = Convert.ToInt32(item.Split('.')[0]);
                    int s = Convert.ToInt32(item.Split('.')[1]);

                    TimeSpan start = new TimeSpan(h, s, 0);
                    TimeSpan end   = new TimeSpan(h, s + 3, 0);

                    if ((now > start) && (now < end))
                    {
                        //Service processing the request in Market time
                        IntermediateClass obj = new IntermediateClass();
                        MessageContext.MessageLog(obj.ProcessRequest("BasicData,OI"));
                        MessageContext.MessageLog(obj.LoadMCData());
                    }



                    if (_loadDataNow.ToString().ToUpper() == "TRUE")
                    {
                        //Service processing the request in Market time
                        IntermediateClass obj = new IntermediateClass();
                        MessageContext.MessageLog(obj.ProcessRequest("BasicData,OI-Using Loaded now option."));
                        MessageContext.MessageLog(obj.LoadMCData());
                    }
                }

                //post market time service updating the Master data excel files
                TimeSpan startPost = new TimeSpan(17, 0, 0);
                TimeSpan endPost   = new TimeSpan(20, 0, 0);
                if ((now > startPost) && (now < endPost))
                {
                    IntermediateClass obj     = new IntermediateClass();
                    string            message = obj.RefreshData(_defaultDate);
                    if (message.Contains("Updated sucussfully"))
                    {
                        try
                        {
                            BasicDataLogic objList  = new BasicDataLogic();
                            Dma            objDma   = new Dma();
                            OBJtoXML       xmltoObj = new OBJtoXML();

                            List <CompanyDetails> basicData    = objList.UpdateDMAMasterSource(_masterDatapathBasic, _defaultDate);
                            List <KeyValue>       objLtpPrices = GeneratePrices(basicData);
                            List <Rank>           dMADataRank  = objDma.GetDmaData(_masterDMAExcelSource, objLtpPrices, "");
                            message = message + " DMA,";
                            xmltoObj.CreateXML(dMADataRank, _masterDatapathDMA, "DMAData", false);
                        }
                        catch (Exception ex)
                        {
                            ErrorContext.ErrorLog("Error in PostRefresh DMA Data" + ex.Message);
                        }
                    }
                    MessageContext.MessageLog(message);
                }
                if (_updateDMADataNow.ToString().ToUpper() == "TRUE")
                {
                    IntermediateClass obj = new IntermediateClass();
                    MessageContext.MessageLog(obj.RefreshData(_defaultDate));
                    MessageContext.MessageLog("DMA data updated using updateDMADataNow option.");
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry(ex.Message, EventLogEntryType.Error);
                ErrorContext.ErrorLog("Problem when Gettign the files   " + ex.Message.ToString());
            }
        }
예제 #3
0
        public string ProcessRequest(string id)
        {
            string message               = "Sucussfully loaded data for ";
            string _nseUrlIo             = ConfigurationManager.AppSettings["NseUrlIO"].Replace("&amp;", "&");
            string _nseUrlBasic          = ConfigurationManager.AppSettings["NseUrlBasic"].Replace("&amp;", "&");
            string _nifty50              = ConfigurationManager.AppSettings["nifty50"].Replace("&amp;", "&");
            string _allFO                = ConfigurationManager.AppSettings["AllFO"].Replace("&amp;", "&");
            string _indexOnly            = ConfigurationManager.AppSettings["IndexOnly"].Replace("&amp;", "&");
            string _banknifty            = ConfigurationManager.AppSettings["Banknifty"].Replace("&amp;", "&");
            string _expiryDate           = ConfigurationManager.AppSettings["ExpiryDate"];
            string _masterDMAExcelSource = ConfigurationManager.AppSettings["MasterDMAExcelSource"];
            string _TodayCSVFile         = ConfigurationManager.AppSettings["TodayCSVFile"];
            string _masterDatapathOI     = ConfigurationManager.AppSettings["MasterDatapathOI"];
            string _masterDatapathBasic  = ConfigurationManager.AppSettings["MasterDatapathBasic"];
            string _masterDatapathDMA    = ConfigurationManager.AppSettings["MasterDatapathDMA"];



            BulkEntity objData  = new BulkEntity();
            Dma        objDma   = new Dma();
            OBJtoXML   xmltoObj = new OBJtoXML();

            try
            {
                string _list = "";

                if (id.Contains("IndexOnly"))
                {
                    _list   = _indexOnly;
                    message = message + " IndexOnly,";
                }
                else if (id.Contains("Banknifty"))
                {
                    _list   = _banknifty;
                    message = message + " Banknifty,";
                }
                else if (id.Contains("nifty50"))
                {
                    _list   = _nifty50;
                    message = message + " nifty50,";
                }
                else
                {
                    _list   = _allFO;
                    message = message + " All listed items.,";
                }

                foreach (string item in id.Split(','))
                {
                    if (item == "BasicData")
                    {
                        objData.BasicData = BasicData.ColletData(_nseUrlBasic, _list);
                        message           = message + " BasicData,";
                        xmltoObj.CreateXML(objData.BasicData, _masterDatapathBasic, "BasicData", false);


                        List <KeyValue> objLtpPrices = GenerateLastPrices(objData.BasicData);
                        objData.DMAData = objDma.GetDmaData(_masterDMAExcelSource, objLtpPrices, "");
                        message         = message + " DMA,";
                        xmltoObj.CreateXML(objData.DMAData, _masterDatapathDMA, "DMAData", false);
                    }
                    if (item == "DMA")
                    {
                        //DMA moved to Basic data refresh, when you click referesh request for the
                        //basic data then system refresh DMA data also
                        //So, no need to saparate request for the DMA.
                        //Presently signing off the DMA refresh option based on the data.csv file

                        objData.DMAData = objDma.GetDmaData(_masterDMAExcelSource, _TodayCSVFile, "");
                        message         = message + " DMA,";
                        xmltoObj.CreateXML(objData.DMAData, _masterDatapathDMA, "DMAData", false);
                    }
                    if (item == "OI")
                    {
                        IOData objOI = new IOData();
                        objData.OIData = objOI.LoadOIData(_nseUrlIo, _expiryDate, _list);
                        message        = message + " OI,";
                        xmltoObj.CreateXML(objData.OIData, _masterDatapathOI, "OIData", false);
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return(message);
        }
예제 #4
0
        public static string LoadBasicData(string id)
        {
            string message               = "Sucussfully loaded data for ";
            string _nseUrlIo             = ConfigurationManager.AppSettings["NseUrlIO"].Replace("&amp;", "&");
            string _nseUrlBasic          = ConfigurationManager.AppSettings["NseUrlBasic"].Replace("&amp;", "&");
            string _nifty50              = ConfigurationManager.AppSettings["nifty50"].Replace("&amp;", "&");
            string _allFO                = ConfigurationManager.AppSettings["AllFO"].Replace("&amp;", "&");
            string _indexOnly            = ConfigurationManager.AppSettings["IndexOnly"].Replace("&amp;", "&");
            string _banknifty            = ConfigurationManager.AppSettings["Banknifty"].Replace("&amp;", "&");
            string _expiryDate           = ConfigurationManager.AppSettings["ExpiryDate"];
            string _masterDMAExcelSource = ConfigurationManager.AppSettings["MasterDMAExcelSource"];
            string _TodayCSVFile         = ConfigurationManager.AppSettings["TodayCSVFile"];
            string _masterDatapathOI     = ConfigurationManager.AppSettings["MasterDatapathOI"];
            string _masterDatapathBasic  = ConfigurationManager.AppSettings["MasterDatapathBasic"];
            string _masterDatapathDMA    = ConfigurationManager.AppSettings["MasterDatapathDMA"];



            BulkEntity objData  = new BulkEntity();
            Dma        objDma   = new Dma();
            OBJtoXML   xmltoObj = new OBJtoXML();

            try
            {
                string _list = "";

                if (id.Contains("IndexOnly"))
                {
                    _list   = _indexOnly;
                    message = message + " IndexOnly,";
                }
                else if (id.Contains("Banknifty"))
                {
                    _list   = _banknifty;
                    message = message + " Banknifty,";
                }
                else if (id.Contains("nifty50"))
                {
                    _list   = _nifty50;
                    message = message + " nifty50,";
                }
                else
                {
                    _list   = _allFO;
                    message = message + " All listed items.,";
                }

                foreach (string item in id.Split(','))
                {
                    if (item == "BasicData")
                    {
                        objData.BasicData = BasicData.ColletData(_nseUrlBasic, _list);
                        message           = message + " BasicData,";
                        xmltoObj.CreateXML(objData.BasicData, _masterDatapathBasic, "basicdata", true);

                        //Need to implement this one when master data been ready
                        //List<KeyValue> objLtpPrices = GenerateLastPrices(objData.BasicData);
                        //objData.DMAData = objDma.GetDmaData(_masterDMAExcelSource, objLtpPrices, "");
                        //message = message + " DMA,";
                        //xmltoObj.CreateXML(objData.DMAData, _masterDatapathDMA, "dmadata", true);
                    }
                    if (item == "OI")
                    {
                        IOData objOI = new IOData();
                        objData.OIData = objOI.LoadOIData(_nseUrlIo, _expiryDate, _list);
                        message        = message + " OI,";
                        xmltoObj.CreateXML(objData.OIData, _masterDatapathOI, "openinterest", true);
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            return(message);
        }