示例#1
0
        public bool InsertFairValues(EntitySelectionData entitySelectionData, string valueType, int?fvMeasure, decimal?fvbuy, decimal?fvSell, decimal?currentMeasureValue, decimal?upside, DateTime?updated)
        {
            try
            {
                ExternalResearchEntities            entity = new ExternalResearchEntities();
                GreenField.DAL.GF_SECURITY_BASEVIEW data   = DimensionEntity.GF_SECURITY_BASEVIEW.Where(a => a.ISSUE_NAME == entitySelectionData.LongName).FirstOrDefault();
                if (data == null)
                {
                    return(false);
                }
                int?securityId = int.Parse(data.SECURITY_ID);
                if (securityId == null)
                {
                    return(false);
                }
                if (valueType != null)
                {
                    valueType = valueType.ToUpper();
                }

                entity.InsertDCFFairValue(Convert.ToString(securityId), valueType, fvMeasure, fvbuy, fvSell, currentMeasureValue, upside, updated, "C", 0);
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#2
0
 public bool DeleteFairValues(EntitySelectionData entitySelectionData)
 {
     try
     {
         ExternalResearchEntities            entity = new ExternalResearchEntities();
         GreenField.DAL.GF_SECURITY_BASEVIEW data   = DimensionEntity.GF_SECURITY_BASEVIEW.Where(a => a.ISSUE_NAME == entitySelectionData.LongName).FirstOrDefault();
         if (data == null)
         {
             return(false);
         }
         int?securityId = int.Parse(data.SECURITY_ID);
         if (securityId == null)
         {
             return(false);
         }
         entity.DeleteDCFFairValueData(Convert.ToString(securityId));
         return(true);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
示例#3
0
 public Boolean UpdateDocumentsDataForUser(Int64 fileId, String fileName, String userName, String metaTags, String companyInfo
                                           , String categoryType, String comment, Byte[] overwriteStream)
 {
     try
     {
         ICPresentationEntities entity = new ICPresentationEntities();
         if (overwriteStream == null)
         {
             entity.UpdateDocumentsData(fileId, userName, metaTags, companyInfo, categoryType, comment);
         }
         else
         {
             FileMaster fileMaster = entity.FileMasters.Where(record => record.FileID == fileId).FirstOrDefault();
             if (fileMaster != null)
             {
                 String uploadUrl = UploadDocument(fileName, overwriteStream, fileMaster.Location);
                 Int32? result    = entity.SetUploadFileInfo(userName, fileName, uploadUrl, companyInfo, null, null
                                                             , categoryType, metaTags, comment).FirstOrDefault();
                 if (result == 0)
                 {
                     entity.DeleteFileMaster(fileMaster.FileID);
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
示例#4
0
 public List <PERIOD_FINANCIALS> RetrieveFairValue(EntitySelectionData entitySelectionData)
 {
     try
     {
         List <PERIOD_FINANCIALS>            result = new List <PERIOD_FINANCIALS>();
         GreenField.DAL.GF_SECURITY_BASEVIEW data   = DimensionEntity.GF_SECURITY_BASEVIEW.Where(a => a.ISSUE_NAME == entitySelectionData.LongName).FirstOrDefault();
         if (data == null)
         {
             return(new List <PERIOD_FINANCIALS>());
         }
         int?securityId = int.Parse(data.SECURITY_ID);
         if (securityId == null)
         {
             return(new List <PERIOD_FINANCIALS>());
         }
         ExternalResearchEntities entity = new ExternalResearchEntities();
         result = entity.GetDCFFairValue(Convert.ToString(securityId)).ToList();
         if (result == null)
         {
             return(new List <PERIOD_FINANCIALS>());
         }
         return(result);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
示例#5
0
        public List <DCFTerminalValueCalculationsData> RetrieveTerminalValueCalculationsData(EntitySelectionData entitySelectionData)
        {
            try
            {
                List <DCFTerminalValueCalculationsData> result        = new List <DCFTerminalValueCalculationsData>();
                Dictionary <string, decimal?>           dataROIC_SDPR = new Dictionary <string, decimal?>();
                List <DCFCashFlowData> cashFlowResult = new List <DCFCashFlowData>();
                string issuerId;
                ExternalResearchEntities entity = new ExternalResearchEntities();
                if (entitySelectionData == null)
                {
                    return(new List <DCFTerminalValueCalculationsData>());
                }

                /*#region ServiceAvailabilityChecker
                 *
                 * bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 * if (!isServiceUp)
                 * {
                 *  throw new Exception("Services are not available");
                 * }
                 #endregion*/

                GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails = DimensionEntity.GF_SECURITY_BASEVIEW
                                                                      .Where(record => record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                                             record.ISSUE_NAME == entitySelectionData.LongName &&
                                                                             record.TICKER == entitySelectionData.ShortName).FirstOrDefault();

                issuerId = securityDetails.ISSUER_ID;
                if (issuerId == null)
                {
                    return(new List <DCFTerminalValueCalculationsData>());
                }
                decimal longTermGDPGrowth             = Convert.ToDecimal(entity.GetDCFGDP(Convert.ToString(securityDetails.ISO_COUNTRY_CODE)).FirstOrDefault());
                DCFTerminalValueCalculationsData data = new DCFTerminalValueCalculationsData();
                dataROIC_SDPR = GetROIC(issuerId);
                if (dataROIC_SDPR.ContainsKey("ROIC"))
                {
                    data.SustainableROIC = dataROIC_SDPR.Where(a => a.Key == "ROIC").Select(a => a.Value).FirstOrDefault();
                }
                if (dataROIC_SDPR.ContainsKey("SDPR"))
                {
                    data.SustainableDividendPayoutRatio = Convert.ToDecimal(dataROIC_SDPR.Where(a => a.Key == "SDPR").Select(a => a.Value).FirstOrDefault());
                }
                data.LongTermNominalGDPGrowth = longTermGDPGrowth;
                result.Add(data);
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#6
0
        public List <DocumentCategoricalData> RetrieveDocumentsDataForUser(String userName)
        {
            try
            {
                List <DocumentCategoricalData> result = new List <DocumentCategoricalData>();
                ICPresentationEntities         entity = new ICPresentationEntities();
                List <FileMaster> data = entity.FileMasters.Where(record => record.CreatedBy == userName).ToList();
                if (data == null)
                {
                    return(result);
                }

                foreach (FileMaster fileMasterRecord in data)
                {
                    DocumentCatalogData documentCatalogData = new DocumentCatalogData()
                    {
                        FileId         = fileMasterRecord.FileID,
                        FileMetaTags   = fileMasterRecord.MetaTags,
                        FileName       = fileMasterRecord.Name,
                        FilePath       = fileMasterRecord.Location,
                        FileUploadedBy = fileMasterRecord.CreatedBy,
                        FileUploadedOn = Convert.ToDateTime(fileMasterRecord.CreatedOn)
                    };

                    List <CommentInfo>    commentInfo    = fileMasterRecord.CommentInfoes.ToList();
                    List <CommentDetails> commentDetails = new List <CommentDetails>();
                    foreach (CommentInfo info in commentInfo)
                    {
                        commentDetails.Add(new CommentDetails()
                        {
                            Comment   = info.Comment,
                            CommentBy = info.CommentBy,
                            CommentOn = Convert.ToDateTime(info.CommentOn)
                        });
                    }

                    result.Add(new DocumentCategoricalData()
                    {
                        CommentDetails         = commentDetails,
                        DocumentCatalogData    = documentCatalogData,
                        DocumentCategoryType   = (DocumentCategoryType)EnumUtils.ToEnum(fileMasterRecord.Type, typeof(DocumentCategoryType)),
                        DocumentCompanyName    = fileMasterRecord.IssuerName,
                        DocumentSecurityName   = fileMasterRecord.SecurityName,
                        DocumentSecurityTicker = fileMasterRecord.SecurityTicker
                    });
                }

                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#7
0
        public List <FreeCashFlowsData> RetrieveFreeCashFlowsData(EntitySelectionData entitySelectionData)
        {
            try
            {
                List <FreeCashFlowsData>       result            = new List <FreeCashFlowsData>();
                List <GetFreeCashFlows_Result> resultDB          = new List <GetFreeCashFlows_Result>();
                ExternalResearchEntities       dcf_FreeCashFlows = new ExternalResearchEntities();

                if (entitySelectionData == null)
                {
                    return(null);
                }

                DimensionEntities entity = DimensionEntity;

                /*  bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 *
                 * if (!isServiceUp)
                 *    throw new Exception("Services are not available");*/

                //Retrieving data from security view
                GreenField.DAL.GF_SECURITY_BASEVIEW data = entity.GF_SECURITY_BASEVIEW
                                                           .Where(record => record.TICKER == entitySelectionData.ShortName &&
                                                                  record.ISSUE_NAME == entitySelectionData.LongName &&
                                                                  record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                                  record.SECURITY_TYPE == entitySelectionData.SecurityType)
                                                           .FirstOrDefault();

                if (data == null)
                {
                    return(null);
                }
                ////Retrieving data from Period Financials table
                resultDB = dcf_FreeCashFlows.ExecuteStoreQuery <GetFreeCashFlows_Result>("exec GetFreeCashFlows @IssuerID={0}", data.ISSUER_ID).ToList();

                foreach (GetFreeCashFlows_Result record in resultDB)
                {
                    FreeCashFlowsData item = new FreeCashFlowsData();
                    item.FieldName  = record.FIELD_NAME;
                    item.PeriodYear = record.PERIOD_YEAR;
                    item.Amount     = record.AMOUNT;
                    result.Add(item);
                }
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#8
0
        public List <DCFSummaryData> RetrieveSummaryData(EntitySelectionData entitySelectionData)
        {
            try
            {
                List <DCFSummaryData>    result         = new List <DCFSummaryData>();
                List <DCFSummaryDBData>  dbResult       = new List <DCFSummaryDBData>();
                List <DCFSummaryDBData>  dbResultShares = new List <DCFSummaryDBData>();
                ExternalResearchEntities entity         = new ExternalResearchEntities();
                if (entitySelectionData == null)
                {
                    return(new List <DCFSummaryData>());
                }

                /*  #region ServiceAvailabilityChecker
                 *
                 * bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 *
                 * if (!isServiceUp)
                 * {
                 *    throw new Exception("Services are not available");
                 * }
                 #endregion*/

                GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails = DimensionEntity.GF_SECURITY_BASEVIEW
                                                                      .Where(record => record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                                             record.ISSUE_NAME == entitySelectionData.LongName &&
                                                                             record.TICKER == entitySelectionData.ShortName).FirstOrDefault();

                string issuerId = securityDetails.ISSUER_ID;
                if (issuerId == null)
                {
                    return(new List <DCFSummaryData>());
                }
                dbResult       = entity.GetDCFSummaryData(issuerId).ToList();
                dbResultShares = entity.GetDCF_NumberOfShares(Convert.ToString(securityDetails.SECURITY_ID)).ToList();
                DCFSummaryData data = new DCFSummaryData();
                data.Cash           = dbResult.Where(a => a.DATA_ID == 255).Select(a => a.AMOUNT).FirstOrDefault();
                data.FVInvestments  = dbResult.Where(a => a.DATA_ID == 258).Select(a => a.AMOUNT).FirstOrDefault();
                data.GrossDebt      = dbResult.Where(a => a.DATA_ID == 256).Select(a => a.AMOUNT).FirstOrDefault();
                data.FVMinorities   = dbResult.Where(a => a.DATA_ID == 257).Select(a => a.AMOUNT).FirstOrDefault();
                data.NumberOfShares = dbResultShares.Select(a => a.AMOUNT).FirstOrDefault();
                result.Add(data);
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#9
0
        public List <string> GetDocumentsMetaTags(Boolean OnlyTags)
        {
            try
            {
                ICPresentationEntities entity       = new ICPresentationEntities();
                List <string>          metaTagsInfo = new List <string>();
                List <String>          metaTags     = entity.FileMasters.Select(a => a.MetaTags).Distinct().ToList();
                for (int i = 0; i < metaTags.Count; i++)
                {
                    if (metaTags[i] != null)
                    {
                        if (metaTags[i].Contains(";"))
                        {
                            List <String> subTags = metaTags[i].Split(';').ToList();
                            metaTagsInfo.AddRange(subTags);
                        }

                        else
                        {
                            metaTagsInfo.Add(metaTags[i]);
                        }
                    }
                }

                if (!OnlyTags)
                {
                    metaTagsInfo.AddRange(entity.FileMasters.Select(a => a.IssuerName).Distinct().ToList());
                    metaTagsInfo.AddRange(entity.FileMasters.Select(a => a.SecurityName).Distinct().ToList());
                    metaTagsInfo.AddRange(entity.FileMasters.Select(a => a.SecurityTicker).Distinct().ToList());
                }
                for (int i = 0; i < metaTagsInfo.Count; i++)
                {
                    if (metaTagsInfo[i] != null)
                    {
                        metaTagsInfo[i] = metaTagsInfo[i].ToUpper();
                    }
                }

                metaTagsInfo = metaTagsInfo.Where(record => record != null && record != String.Empty).ToList();
                metaTagsInfo = metaTagsInfo.Distinct().ToList();
                return(metaTagsInfo);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#10
0
 public Boolean SetDocumentComment(String userName, Int64 fileId, String comment)
 {
     try
     {
         ICPresentationEntities entity = new ICPresentationEntities();
         Int32?result = entity.SetFileCommentInfo(userName, fileId, comment).FirstOrDefault();
         return(result == 0);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
示例#11
0
 public bool DeleteFileMasterRecord(Int64 fileId)
 {
     try
     {
         ICPresentationEntities entity = new ICPresentationEntities();
         entity.DeleteFileMaster(fileId);
         return(true);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
示例#12
0
 /// <summary>
 /// Retrieve List of DataPoints for Model-Upload worksheet
 /// </summary>
 /// <param name="issuerId">Issuer Id of the Selected Security</param>
 /// <returns>List of DataPointsModelUploadData</returns>
 private List <DataPointsModelUploadData> RetrieveModelUploadDataPoints(string issuerId)
 {
     try
     {
         ExternalResearchEntities         entity = new ExternalResearchEntities();
         List <DataPointsModelUploadData> result = new List <DataPointsModelUploadData>();
         result = entity.RetrieveDataPointsModelUpload(issuerId).ToList();
         return(result);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         return(null);
     }
 }
示例#13
0
 public Boolean SetUploadFileInfo(String userName, String Name, String Location, String CompanyName, String SecurityName
                                  , String SecurityTicker, String Type, String MetaTags, String Comments)
 {
     try
     {
         ICPresentationEntities entity = new ICPresentationEntities();
         Int32?result = entity.SetUploadFileInfo(userName, Name, Location, CompanyName, SecurityName
                                                 , SecurityTicker, Type, MetaTags, Comments).FirstOrDefault();
         return(result == 0);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
示例#14
0
        public bool MakeDocumentReadOnly(String fileName)
        {
            bool filereadonly = false;

            try
            {
                /*  string strBatch = "<Method ID='1'>" +
                 *    "<Field Name='ID'>3</Field>" +
                 *   "<Field READONLY='TRUE'/>" +
                 *
                 *    "<Field Name='FileRef'>" +
                 *
                 *    fileName +
                 *    "</Field>" +
                 *    "</Method>";
                 *
                 * XmlDocument xmlDoc = new XmlDocument();
                 * System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
                 * elBatch.SetAttribute("OnError", "Continue");
                 * elBatch.SetAttribute("PreCalc", "TRUE");
                 * elBatch.SetAttribute("ListVersion", "0");
                 * elBatch.SetAttribute("ViewName", String.Empty);
                 * elBatch.InnerXml = strBatch;
                 *
                 * XmlNode ndReturn = ListsService.UpdateListItems(DocumentLibrary, elBatch); //Remove if testing model uploading locally
                 *
                 * if (ndReturn.InnerText.ToLower() == "0x00000000".ToLower()) //Remove if testing model uploading locally
                 * {
                 *    filereadonly = true;
                 * } */
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }

            return(filereadonly);
        }
示例#15
0
 /// <summary>
 /// Retrieve Data for Model-Reference worksheet
 /// </summary>
 /// <param name="issuerId">IssuerId of the selected Security</param>
 /// <param name="securityDetails">Data of the selected security from GF_SECURITY_BASEVIEW</param>
 /// <returns>object of type ModelReferenceDatapoints</returns>
 private ModelReferenceDataPoints RetrieveExcelModelReferenceData(string issuerId, GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails)
 {
     try
     {
         ExternalResearchEntities entity = new ExternalResearchEntities();
         ModelReferenceDataPoints data   = new ModelReferenceDataPoints();
         data.IssuerId   = issuerId;
         data.IssuerName = securityDetails.ISSUER_NAME;
         INTERNAL_ISSUER issuerData = entity.RetrieveCOAType(issuerId).FirstOrDefault();
         if (issuerData != null)
         {
             data.COATypes = issuerData.COA_TYPE;
         }
         return(data);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         return(null);
     }
 }
示例#16
0
        public String UploadDocument(String fileName, Byte[] fileByteStream, String deleteFileUrl)
        {
            try
            {
                String resultUrl = String.Empty;
                try
                {
                    if (deleteFileUrl != String.Empty)
                    {
                        DeleteDocument(deleteFileUrl);
                    }

                    String[] destinationUrl = { DocumentServerUrl + "/" + "[" + DateTime.UtcNow.ToString("ddMMyyyy") + "]" + fileName };

                    DocumentCopyService.CopyResult[]       cResultArray    = { new DocumentCopyService.CopyResult() };
                    DocumentCopyService.FieldInformation[] ffieldInfoArray = { new DocumentCopyService.FieldInformation() };

                    UInt32 copyResult = CopyService.CopyIntoItems(destinationUrl[0], destinationUrl, ffieldInfoArray, fileByteStream, out cResultArray); //Remove if testing model uploading locally

                    if (cResultArray[0].ErrorCode == CopyErrorCode.Success)                                                                              //Remove if testing model uploading locally
                    {
                        resultUrl = cResultArray[0].DestinationUrl;
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                return(resultUrl);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#17
0
 public string RetrieveCountryName(EntitySelectionData entitySelectionData)
 {
     try
     {
         string countryName = string.Empty;
         GreenField.DAL.GF_SECURITY_BASEVIEW data = DimensionEntity.GF_SECURITY_BASEVIEW.Where(a => a.ISSUE_NAME == entitySelectionData.LongName).FirstOrDefault();
         if (data != null)
         {
             countryName = data.ASEC_SEC_COUNTRY_NAME;
         }
         if (countryName == null)
         {
             return(string.Empty);
         }
         return(countryName);
     }
     catch (Exception ex)
     {
         ExceptionTrace.LogException(ex);
         string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
         throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
     }
 }
示例#18
0
        /// <summary>
        /// Retrieve Consensus Data for the Selected Security
        /// </summary>
        /// <param name="issuerId">Issuer id of the selected security</param>
        /// <param name="currency">Selected currency</param>
        /// <returns>List of ModelConsensusEstimatesData</returns>
        private List <ModelConsensusEstimatesData> RetrieveModelConsensusData(string issuerId, string currency)
        {
            try
            {
                ExternalResearchEntities           entity          = new ExternalResearchEntities();
                List <ModelConsensusEstimatesData> resultConsensus = new List <ModelConsensusEstimatesData>();
                List <ModelConsensusEstimatesData> data            = new List <ModelConsensusEstimatesData>();
                List <FinancialStatementType>      statementType   = new List <FinancialStatementType>()
                {
                    FinancialStatementType.INCOME_STATEMENT, FinancialStatementType.BALANCE_SHEET, FinancialStatementType.CASH_FLOW_STATEMENT
                };
                List <FinancialStatementPeriodType> periodType = new List <FinancialStatementPeriodType>()
                {
                    FinancialStatementPeriodType.ANNUAL, FinancialStatementPeriodType.QUARTERLY
                };

                foreach (FinancialStatementPeriodType item in periodType)
                {
                    data = entity.GetModelConsensusEstimates(issuerId, "REUTERS", EnumUtils.ToString(item).Substring(0, 1), "FISCAL", currency).ToList();
                    if (data != null)
                    {
                        resultConsensus.AddRange(data);
                    }
                }
                foreach (ModelConsensusEstimatesData item in resultConsensus)
                {
                    item.SortOrder = ReturnSortOrder(item.ESTIMATE_ID);
                }
                return(resultConsensus.OrderBy(a => a.SortOrder).ThenBy(a => a.PERIOD_YEAR).ThenBy(a => a.PERIOD_TYPE).ToList());
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                return(null);
            }
        }
示例#19
0
        /// <summary>
        /// Retrieve Reuters Data
        /// </summary>
        /// <param name="issuerId">Issuer Id of Security</param>
        /// <param name="currency">Currency</param>
        /// <returns>Collection of FinancialStatementDataModels</returns>
        private List <FinancialStatementDataModels> RetrieveFinancialData(string issuerId, string currency)
        {
            try
            {
                ExternalResearchEntities            entity        = new ExternalResearchEntities();
                List <FinancialStatementDataModels> resultReuters = new List <FinancialStatementDataModels>();
                List <FinancialStatementType>       statementType = new List <FinancialStatementType>()
                {
                    FinancialStatementType.INCOME_STATEMENT, FinancialStatementType.BALANCE_SHEET, FinancialStatementType.CASH_FLOW_STATEMENT
                };
                List <FinancialStatementPeriodType> periodType = new List <FinancialStatementPeriodType>()
                {
                    FinancialStatementPeriodType.ANNUAL, FinancialStatementPeriodType.QUARTERLY
                };
                List <FinancialStatementDataModels> resultStatement = new List <FinancialStatementDataModels>();

                foreach (FinancialStatementType item in statementType)
                {
                    string statement = EnumUtils.ToString(item);
                    foreach (FinancialStatementPeriodType period in periodType)
                    {
                        resultStatement = entity.Get_Statement_Models(issuerId, "REUTERS", EnumUtils.ToString(period).Substring(0, 1), "FISCAL", statement, currency).ToList();
                        if (resultStatement != null)
                        {
                            resultReuters.AddRange(resultStatement);
                        }
                    }
                }
                return(resultReuters);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                return(null);
            }
        }
示例#20
0
        public decimal?RetrieveCurrentPriceData(EntitySelectionData entitySelectionData)
        {
            try
            {
                if (entitySelectionData == null)
                {
                    return(0);
                }

                /*   #region ServiceAvailabilityChecker
                 *
                 * bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 *
                 * if (!isServiceUp)
                 * {
                 *     throw new Exception("Services are not available");
                 * }
                 #endregion*/

                GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails = DimensionEntity.GF_SECURITY_BASEVIEW
                                                                      .Where(record => record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                                             record.ISSUE_NAME == entitySelectionData.LongName &&
                                                                             record.TICKER == entitySelectionData.ShortName).FirstOrDefault();
                if (securityDetails == null)
                {
                    return(0);
                }
                return(Convert.ToDecimal(securityDetails.CLOSING_PRICE));
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#21
0
        public List <FairValueCompositionSummaryData> RetrieveFairValueCompostionSummary(EntitySelectionData entitySelectionData)
        {
            try
            {
                List <FairValueCompositionSummaryData> result   = new List <FairValueCompositionSummaryData>();
                List <GetFairValueComposition_Result>  resultDB = new List <GetFairValueComposition_Result>();
                ExternalResearchEntities fairValueCompSummary   = new ExternalResearchEntities();

                if (entitySelectionData == null)
                {
                    return(null);
                }

                //Retrieving data from security view
                GreenField.DAL.GF_SECURITY_BASEVIEW data = GetSecurityDataForSelectedSecurity(entitySelectionData);

                if (data == null)
                {
                    return(null);
                }

                ////Retrieving data from Period Financials table
                resultDB = fairValueCompSummary.ExecuteStoreQuery <GetFairValueComposition_Result>("exec GetFairValueCompositionSummaryData @SECURITY_ID={0}", Convert.ToString(data.SECURITY_ID)).ToList();

                if (resultDB == null || resultDB.Count == 0)
                {
                    List <FairValueCompositionSummaryData> items = GetSummaryDataIfDatabaseContaisnNorecords(data);
                    result.AddRange(items);
                }

                foreach (GetFairValueComposition_Result record in resultDB)
                {
                    FairValueCompositionSummaryData item = new FairValueCompositionSummaryData();
                    if (!String.IsNullOrEmpty(record.SOURCE))
                    {
                        if (record.SOURCE.ToUpper() == "PRIMARY")
                        {
                            item.Source = "Primary Analyst";
                        }
                        else
                        {
                            if (record.SOURCE.ToUpper() == "INDUSTRY")
                            {
                                item.Source = "Industry Analyst";
                            }
                            else
                            {
                                item.Source = record.SOURCE;
                            }
                        }
                    }
                    item.Measure = record.MEASURE;
                    item.Buy     = record.BUY;
                    item.Sell    = record.SELL;
                    item.Upside  = record.UPSIDE;
                    if (record.DATE != null)
                    {
                        item.Date = record.DATE.Value;
                    }
                    item.DataId          = record.DATA_ID;
                    item.PrimaryAnalyst  = data.ASHMOREEMM_PRIMARY_ANALYST;
                    item.IndustryAnalyst = data.ASHMOREEMM_INDUSTRY_ANALYST;
                    result.Add(item);
                }
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#22
0
        public List <FairValueCompositionSummaryData> SaveUpdatedFairValueData(EntitySelectionData entitySelectionData,
                                                                               List <FairValueCompositionSummaryData> editedFairValueData)
        {
            List <FairValueCompositionSummaryData> result = null;

            try
            {
                if (entitySelectionData == null || editedFairValueData == null)
                {
                    return(null);
                }

                GreenField.DAL.GF_SECURITY_BASEVIEW data = GetSecurityDataForSelectedSecurity(entitySelectionData);

                if (data == null)
                {
                    return(null);
                }

                string securityId = Convert.ToString(data.SECURITY_ID);

                ExternalResearchEntities entity = new ExternalResearchEntities();
                UpdateSoureValues(ref editedFairValueData);
                XDocument doc = GetEntityXml <FairValueCompositionSummaryData>(editedFairValueData);

                var updatedResultSet = entity.SaveUpdatedFairValueMeasures(securityId, doc.ToString()).ToList();

                if (updatedResultSet != null)
                {
                    result = new List <FairValueCompositionSummaryData>();
                    foreach (GetFairValueComposition_Result record in updatedResultSet)
                    {
                        FairValueCompositionSummaryData item = new FairValueCompositionSummaryData();
                        if (!String.IsNullOrEmpty(record.SOURCE))
                        {
                            if (record.SOURCE.ToUpper() == "PRIMARY")
                            {
                                item.Source = "Primary Analyst";
                            }
                            else
                            {
                                if (record.SOURCE.ToUpper() == "INDUSTRY")
                                {
                                    item.Source = "Industry Analyst";
                                }
                                else
                                {
                                    item.Source = record.SOURCE;
                                }
                            }
                        }
                        item.Measure = record.MEASURE;
                        item.Buy     = record.BUY;
                        item.Sell    = record.SELL;
                        item.Upside  = record.UPSIDE;
                        if (record.DATE != null)
                        {
                            item.Date = record.DATE.Value;
                        }
                        item.DataId          = record.DATA_ID;
                        item.PrimaryAnalyst  = data.ASHMOREEMM_PRIMARY_ANALYST;
                        item.IndustryAnalyst = data.ASHMOREEMM_INDUSTRY_ANALYST;

                        result.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }

            return(result);
        }
示例#23
0
        public FairValueCompositionSummaryData RetrieveFairValueDataWithNewUpside(EntitySelectionData entitySelectionData,
                                                                                  FairValueCompositionSummaryData editedFairValueData)
        {
            FairValueCompositionSummaryData result = null;
            decimal upsideValue = 0;

            try
            {
                if (entitySelectionData == null || editedFairValueData == null)
                {
                    return(null);
                }

                if (entitySelectionData == null)
                {
                    return(null);
                }

                //retrieving data from security view
                GreenField.DAL.GF_SECURITY_BASEVIEW data = GetSecurityDataForSelectedSecurity(entitySelectionData);

                if (data == null)
                {
                    return(null);
                }

                string securityId = Convert.ToString(data.SECURITY_ID);
                int?   dataId     = editedFairValueData.DataId;
                string dataSource = editedFairValueData.Source;

                ExternalResearchEntities entity = new ExternalResearchEntities();

                decimal?amountValue = entity.GetAmountForUpsideCalculation(securityId, dataId, dataSource).FirstOrDefault();

                if (amountValue != null)
                {
                    if (amountValue == 0 || editedFairValueData.Sell == null)
                    {
                        upsideValue = 0;
                    }
                    else
                    {
                        if (dataId != null && dataId != 236)
                        {
                            upsideValue = (decimal)(editedFairValueData.Sell / amountValue) - 1;
                        }
                        else
                        {
                            if (editedFairValueData.Sell != 0)
                            {
                                upsideValue = (decimal)(amountValue / (editedFairValueData.Sell / 100)) - 1;
                            }
                        }
                    }
                }

                result = GetFairValueSummary(editedFairValueData, upsideValue);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }

            return(result);
        }
示例#24
0
        public List <FairValueCompositionSummaryData> RetrieveFairValueCompostionSummaryData(EntitySelectionData entitySelectionData)
        {
            try
            {
                List <FairValueCompositionSummaryData> result   = new List <FairValueCompositionSummaryData>();
                List <GetFairValueComposition_Result>  resultDB = new List <GetFairValueComposition_Result>();
                ExternalResearchEntities fairValueCompSummary   = new ExternalResearchEntities();

                if (entitySelectionData == null)
                {
                    return(null);
                }

                //retrieving data from security view
                GreenField.DAL.GF_SECURITY_BASEVIEW data = GetSecurityDataForSelectedSecurity(entitySelectionData);

                if (data == null)
                {
                    return(null);
                }

                //retrieving data from period financials table
                resultDB = fairValueCompSummary.ExecuteStoreQuery <GetFairValueComposition_Result>
                               ("exec GetFairValueCompositionSummaryData @SECURITY_ID={0}", Convert.ToString(data.SECURITY_ID)).ToList();

                string sourceNames = string.Empty;
                foreach (GetFairValueComposition_Result record in resultDB)
                {
                    FairValueCompositionSummaryData item = new FairValueCompositionSummaryData();
                    if (!String.IsNullOrEmpty(record.SOURCE))
                    {
                        if (record.SOURCE.ToUpper() == "PRIMARY")
                        {
                            item.Source = "Primary Analyst";
                        }
                        else if (record.SOURCE.ToUpper() == "INDUSTRY")
                        {
                            item.Source = "Industry Analyst";
                        }
                        else if (record.SOURCE.ToUpper() == "DCF_PE")
                        {
                            item.Source = "DCF-PE";
                        }
                        else if (record.SOURCE.ToUpper() == "DCF_PBV")
                        {
                            item.Source = "DCF-PBV";
                        }
                        else
                        {
                            item.Source = record.SOURCE;
                        }
                    }
                    sourceNames += item.Source + ",";
                    item.Measure = record.MEASURE;
                    item.Buy     = record.BUY;
                    item.Sell    = record.SELL;
                    item.Upside  = record.UPSIDE;
                    if (record.DATE != null)
                    {
                        item.Date = record.DATE.Value;
                    }
                    item.DataId = record.DATA_ID;
                    result.Add(item);
                }
                if (!sourceNames.Contains("Primary Analyst"))
                {
                    result.Add(new FairValueCompositionSummaryData {
                        Source = "Primary Analyst"
                    });
                }
                if (!sourceNames.Contains("Industry Analyst"))
                {
                    result.Add(new FairValueCompositionSummaryData {
                        Source = "Industry Analyst"
                    });
                }
                if (!sourceNames.Contains("DCF-PE"))
                {
                    result.Add(new FairValueCompositionSummaryData {
                        Source = "DCF-PE"
                    });
                }
                if (!sourceNames.Contains("DCF-PBV"))
                {
                    result.Add(new FairValueCompositionSummaryData {
                        Source = "DCF-PBV"
                    });
                }

                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#25
0
        public ExcelModelData RetrieveStatementData(string issuerId, String currency)
        {
            List <ModelConsensusEstimatesData>  resultConsensus = new List <ModelConsensusEstimatesData>();
            List <FinancialStatementDataModels> resultReuters   = new List <FinancialStatementDataModels>();
            List <FinancialStatementData>       resultStatement = new List <FinancialStatementData>();
            List <string>  commodities = new List <string>();
            ExcelModelData modelData   = new ExcelModelData();
            List <DataPointsModelUploadData> dataPointsExcelUpload    = new List <DataPointsModelUploadData>();
            ModelReferenceDataPoints         dataPointsModelReference = new ModelReferenceDataPoints();
            string currencyReuters   = "";
            string currencyConsensus = string.Empty;

            try
            {
                ExternalResearchEntities entity = new ExternalResearchEntities();
                if (issuerId == null)
                {
                    throw new Exception("Issuer Id is not Valid");
                }
                GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails = DimensionEntity.GF_SECURITY_BASEVIEW
                                                                      .Where(record => record.ISSUER_ID == issuerId).FirstOrDefault();
                if (securityDetails == null)
                {
                    throw new Exception("Issuer Id is not Valid");
                }
                //External_Country_Master countryDetails = entity.External_Country_Master
                //.Where(record => record.COUNTRY_CODE == securityDetails.ISO_COUNTRY_CODE &&
                // record.COUNTRY_NAME == securityDetails.ASEC_SEC_COUNTRY_NAME)
                //.FirstOrDefault();
                string issuerID = issuerId;
                //string currency = countryDetails.CURRENCY_CODE;
                if (currency != null)
                {
                    resultReuters     = RetrieveFinancialData(issuerID, currency);
                    resultConsensus   = RetrieveModelConsensusData(issuerID, currency);
                    currencyReuters   = currency;
                    currencyConsensus = currency;
                }
                if (resultReuters != null)
                {
                    resultReuters = resultReuters.Where(a => a.PeriodYear != 2300).ToList();
                }
                if (resultReuters == null || resultReuters.Count == 0)
                {
                    //if (currency != "USD")
                    //{
                    //    resultReuters = RetrieveFinancialData(issuerID, "USD");
                    //    currencyReuters = "USD";
                    //}
                    //else
                    //{
                    //    resultReuters = new List<FinancialStatementDataModels>();
                    //}

                    throw new Exception("Data does not exist for the selected currency '"
                                        + currency + "' and issuer id '" + issuerId + "'.");
                }
                resultReuters = resultReuters.Where(a => a.PeriodYear != 2300).ToList();

                if (resultConsensus == null || resultConsensus.Count == 0)
                {
                    //if (currency != "USD")
                    //{
                    //    resultConsensus = RetrieveModelConsensusData(issuerID, "USD");
                    //    currencyConsensus = "USD";
                    //}
                    //else
                    //{
                    //    resultConsensus = new List<ModelConsensusEstimatesData>();
                    //}
                    throw new Exception("Data does not exist for the selected currency '"
                                        + currency + "' and issuer id '" + issuerId + "'.");
                }

                if (resultReuters == null || resultReuters.Count == 0)
                {
                    throw new Exception("No Data Returned from server");
                }
                dataPointsExcelUpload = RetrieveModelUploadDataPoints(issuerID);
                commodities           = entity.RetrieveCommodityForecasts().ToList();
                ExcelModelData excelModelData = new ExcelModelData();
                excelModelData.ConsensusEstimateData = new List <ModelConsensusEstimatesData>();
                excelModelData.ModelReferenceData    = dataPointsModelReference;
                excelModelData.ModelUploadDataPoints = dataPointsExcelUpload;
                excelModelData.Currencies            = entity.RetrieveDistinctFXRates().ToList();
                excelModelData.Commodities           = commodities;
                excelModelData.ReutersData           = resultReuters;
                excelModelData.CurrencyReuters       = currencyReuters;
                excelModelData.ConsensusEstimateData = resultConsensus;
                return(excelModelData);
            }
            catch (Exception ex)
            {
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#26
0
        public List <DocumentCategoricalData> RetrieveDocumentsData(String searchString)
        {
            try
            {
                List <DocumentCategoricalData> result = new List <DocumentCategoricalData>();

                ICPresentationEntities entity            = new ICPresentationEntities();
                List <DocumentsData>   documentsDataInfo = entity.GetDocumentsData(searchString).ToList();

                if (documentsDataInfo == null)
                {
                    return(result);
                }

                List <DocumentsData> distinctDocumentsData = documentsDataInfo
                                                             .GroupBy(record => record.FileID, (key, group) => group.First()).ToList();

                foreach (DocumentsData distinctInfo in distinctDocumentsData)
                {
                    List <DocumentsData> distinctDocumentsDataInfo = documentsDataInfo
                                                                     .Where(record => record.FileID == distinctInfo.FileID).ToList();

                    List <CommentDetails> commentsDetails = new List <CommentDetails>();

                    foreach (DocumentsData documentData in distinctDocumentsDataInfo)
                    {
                        commentsDetails.Add(new CommentDetails()
                        {
                            Comment   = documentData.Comment,
                            CommentBy = documentData.CommentBy,
                            CommentOn = Convert.ToDateTime(documentData.CommentOn)
                        });
                    }

                    result.Add(new DocumentCategoricalData()
                    {
                        DocumentCategoryType   = (DocumentCategoryType)EnumUtils.ToEnum(distinctInfo.Type, typeof(DocumentCategoryType)),
                        DocumentCompanyName    = distinctInfo.IssuerName,
                        DocumentSecurityName   = distinctInfo.SecurityName,
                        DocumentSecurityTicker = distinctInfo.SecurityTicker,
                        DocumentCatalogData    = new DocumentCatalogData()
                        {
                            FileId         = distinctInfo.FileID,
                            FileMetaTags   = distinctInfo.MetaTags,
                            FileName       = distinctInfo.Name,
                            FilePath       = distinctInfo.Location,
                            FileUploadedBy = distinctInfo.CreatedBy,
                            FileUploadedOn = Convert.ToDateTime(distinctInfo.CreatedOn)
                        },
                        CommentDetails = commentsDetails
                    });
                }
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#27
0
        public List <DCFAnalysisSummaryData> RetrieveDCFAnalysisData(EntitySelectionData entitySelectionData)
        {
            try
            {
                string issuerId;
                List <DCFAnalysisSummaryData>        result = new List <DCFAnalysisSummaryData>();
                List <DCFAnalysisSummaryData_Result> dbResult;
                MODEL_INPUTS_CTY         modelData = new MODEL_INPUTS_CTY();
                decimal                  marketCap;
                ExternalResearchEntities entity = new ExternalResearchEntities();
                if (entitySelectionData == null)
                {
                    return(new List <DCFAnalysisSummaryData>());
                }

                /*  #region ServiceAvailabilityChecker
                 *
                 * bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 *
                 * if (!isServiceUp)
                 * {
                 *    throw new Exception("Services are not available");
                 * }
                 #endregion*/

                GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails = DimensionEntity.GF_SECURITY_BASEVIEW
                                                                      .Where(record => record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                                             record.ISSUE_NAME == entitySelectionData.LongName &&
                                                                             record.TICKER == entitySelectionData.ShortName).FirstOrDefault();

                if (securityDetails == null)
                {
                    return(new List <DCFAnalysisSummaryData>());
                }
                issuerId = securityDetails.ISSUER_ID;
                if (issuerId == null)
                {
                    return(new List <DCFAnalysisSummaryData>());
                }
                dbResult  = entity.RetrieveDCFAnalysisSummaryData(issuerId, "PRIMARY", "C", "FISCAL", "USD").ToList();
                modelData = entity.GetDCFRiskFreeRate(Convert.ToString(securityDetails.ISO_COUNTRY_CODE)).FirstOrDefault();
                marketCap = Convert.ToDecimal(entity.GetDCFMarketCap(Convert.ToString(securityDetails.SECURITY_ID)).FirstOrDefault());
                DCFAnalysisSummaryData data = new DCFAnalysisSummaryData();
                data.SecurityId = securityDetails.ASEC_SEC_SHORT_NAME;
                data.IssuerId   = securityDetails.ISSUER_ID;
                data.Beta       = (securityDetails.BARRA_BETA == null) ?
                                  (Convert.ToDecimal(securityDetails.BETA)) : (Convert.ToDecimal(securityDetails.BARRA_BETA));
                data.CostOfDebt      = Convert.ToDecimal(securityDetails.WACC_COST_DEBT);
                data.MarginalTaxRate = dbResult.Where(a => a.DATA_ID == 289 && a.PERIOD_TYPE.Trim() == "C").Select(a => a.AMOUNT).FirstOrDefault();
                data.GrossDebt       = dbResult.Where(a => a.DATA_ID == 256 && a.PERIOD_TYPE.Trim() == "C").Select(a => a.AMOUNT).FirstOrDefault();
                data.MarketCap       = Convert.ToDecimal(marketCap);
                if (modelData != null)
                {
                    data.RiskFreeRate      = (modelData.RISK_FREE_RATE != null ? modelData.RISK_FREE_RATE : 0);
                    data.MarketRiskPremium = (modelData.RISK_PREM != null ? modelData.RISK_PREM : 0);
                }
                result.Add(data);
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#28
0
        public byte[] RetrieveStatementData(EntitySelectionData selectedSecurity)
        {
            List <ModelConsensusEstimatesData>  resultConsensus = new List <ModelConsensusEstimatesData>();
            List <FinancialStatementDataModels> resultReuters   = new List <FinancialStatementDataModels>();
            List <FinancialStatementData>       resultStatement = new List <FinancialStatementData>();
            List <string>  commodities = new List <string>();
            ExcelModelData modelData   = new ExcelModelData();
            List <DataPointsModelUploadData> dataPointsExcelUpload    = new List <DataPointsModelUploadData>();
            ModelReferenceDataPoints         dataPointsModelReference = new ModelReferenceDataPoints();
            string currencyReuters   = "";
            string currencyConsensus = "";

            try
            {
                ExternalResearchEntities entity = new ExternalResearchEntities();
                if (selectedSecurity == null)
                {
                    return(new byte[1]);
                }
                GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails = DimensionEntity.GF_SECURITY_BASEVIEW
                                                                      .Where(record => record.ASEC_SEC_SHORT_NAME == selectedSecurity.InstrumentID &&
                                                                             record.ISSUE_NAME == selectedSecurity.LongName &&
                                                                             record.TICKER == selectedSecurity.ShortName).FirstOrDefault();
                if (securityDetails == null)
                {
                    return(new byte[1]);
                }
                External_Country_Master countryDetails = entity.External_Country_Master
                                                         .Where(record => record.COUNTRY_CODE == securityDetails.ISO_COUNTRY_CODE &&
                                                                record.COUNTRY_NAME == securityDetails.ASEC_SEC_COUNTRY_NAME)
                                                         .FirstOrDefault();
                string issuerID = securityDetails.ISSUER_ID;
                string currency = countryDetails.CURRENCY_CODE;
                if (issuerID == null)
                {
                    return(new byte[1]);
                }
                if (currency != null)
                {
                    resultReuters     = RetrieveFinancialData(issuerID, currency);
                    resultConsensus   = RetrieveModelConsensusData(issuerID, currency);
                    currencyReuters   = currency;
                    currencyConsensus = currency;
                }
                if (resultReuters != null)
                {
                    resultReuters = resultReuters.Where(a => a.PeriodYear != 2300).ToList();
                }
                if (resultReuters == null || resultReuters.Count == 0)
                {
                    if (currency != "USD")
                    {
                        resultReuters   = RetrieveFinancialData(issuerID, "USD");
                        currencyReuters = "USD";
                    }
                    else
                    {
                        resultReuters = new List <FinancialStatementDataModels>();
                    }
                }
                resultReuters = resultReuters.Where(a => a.PeriodYear != 2300).ToList();

                if (resultConsensus == null || resultConsensus.Count == 0)
                {
                    if (currency != "USD")
                    {
                        resultConsensus   = RetrieveModelConsensusData(issuerID, "USD");
                        currencyConsensus = "USD";
                    }
                    else
                    {
                        resultConsensus = new List <ModelConsensusEstimatesData>();
                    }
                }
                dataPointsExcelUpload    = RetrieveModelUploadDataPoints(issuerID);
                dataPointsModelReference = RetrieveExcelModelReferenceData(issuerID, securityDetails);
                commodities = entity.RetrieveCommodityForecasts().ToList();
                ExcelModelData excelModelData = new ExcelModelData();
                excelModelData.ModelReferenceData    = dataPointsModelReference;
                excelModelData.ModelUploadDataPoints = dataPointsExcelUpload;
                excelModelData.Currencies            = entity.RetrieveDistinctFXRates().ToList();
                excelModelData.Commodities           = commodities;
                return(GenerateOpenXMLExcelModel.GenerateExcel(resultReuters, resultConsensus, currencyReuters, currencyConsensus, excelModelData));
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }
示例#29
0
        public List <DCFCashFlowData> RetrieveCashFlows(EntitySelectionData entitySelectionData)
        {
            try
            {
                List <DCFCashFlowData> result   = new List <DCFCashFlowData>();
                List <DCFCashFlowData> dbResult = new List <DCFCashFlowData>();

                ExternalResearchEntities entity = new ExternalResearchEntities();

                if (entitySelectionData == null)
                {
                    return(new List <DCFCashFlowData>());
                }

                /*  #region ServiceAvailabilityChecker
                 *
                 * bool isServiceUp;
                 * isServiceUp = CheckServiceAvailability.ServiceAvailability();
                 *
                 * if (!isServiceUp)
                 * {
                 *   throw new Exception("Services are not available");
                 * }
                 #endregion */

                GreenField.DAL.GF_SECURITY_BASEVIEW securityDetails = DimensionEntity.GF_SECURITY_BASEVIEW
                                                                      .Where(record => record.ASEC_SEC_SHORT_NAME == entitySelectionData.InstrumentID &&
                                                                             record.ISSUE_NAME == entitySelectionData.LongName &&
                                                                             record.TICKER == entitySelectionData.ShortName).FirstOrDefault();

                string issuerId = securityDetails.ISSUER_ID;
                if (issuerId == null)
                {
                    return(new List <DCFCashFlowData>());
                }
                dbResult = entity.GetDCFCashFlow(issuerId).OrderBy(a => a.PERIOD_YEAR).ToList();
                if (dbResult == null || dbResult.Count == 0)
                {
                    return(new List <DCFCashFlowData>());
                }
                int currentYear = DateTime.Today.Year;
                for (int i = 0; i < 10; i++)
                {
                    if (dbResult.Where(a => a.PERIOD_YEAR == currentYear + i).FirstOrDefault() != null)
                    {
                        result.Add(dbResult.Where(a => a.PERIOD_YEAR == currentYear + i).FirstOrDefault());
                    }
                    else
                    {
                        result.Add(new DCFCashFlowData()
                        {
                            AMOUNT = 0, DISCOUNTING_FACTOR = 0, PERIOD_YEAR = currentYear + i
                        });
                    }
                }
                decimal average = result.Where(a => a.PERIOD_YEAR < currentYear + 5).Select(a => Convert.ToDecimal(a.AMOUNT)).Sum() / 5;
                foreach (DCFCashFlowData item in result)
                {
                    if (item.PERIOD_YEAR > currentYear + 4)
                    {
                        item.AMOUNT = average * Convert.ToDecimal(Math.Pow((0.99), Convert.ToDouble(item.PERIOD_YEAR - (currentYear + 4))));
                    }
                    item.FREE_CASH_FLOW = item.AMOUNT;
                }
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionTrace.LogException(ex);
                string networkFaultMessage = ServiceFaultResourceManager.GetString("NetworkFault").ToString();
                throw new FaultException <ServiceFault>(new ServiceFault(networkFaultMessage), new FaultReason(ex.Message));
            }
        }