Ejemplo n.º 1
0
        public static object ExtractValueFromSophisCell(this SSMCellValue cv, SSMCellStyle cs)
        {
            switch (cs.kind)
            {
            case NSREnums.eMDataType.M_dDate:
            case NSREnums.eMDataType.M_dDateTime:

                if (cv.integerValue == 0)
                {
                    return(0);
                }

                return(GetDateTime(cv.integerValue));


            case NSREnums.eMDataType.M_dInt:

                return(ConvertLong((long)cv.integerValue, cs.@null));

#if !V72
            case NSREnums.eMDataType.M_dPascalString:
#endif
            case NSREnums.eMDataType.M_dUnicodeString:
            case NSREnums.eMDataType.M_dNullTerminatedString:

                var stringValue = ConvertString(cv.GetString());
                return(stringValue);

            case NSREnums.eMDataType.M_dLong:
            case NSREnums.eMDataType.M_dLongLong:
                return(cv.longlongValue);

            case NSREnums.eMDataType.M_dArray:
                return(cv.GetString());

            case NSREnums.eMDataType.M_dSlidingDate:
                return(cv.GetString());

            case NSREnums.eMDataType.M_dBool:
                return(Convert.ToBoolean(cv.shortInteger));

            case NSREnums.eMDataType.M_dPointer:
                return(cv.shortInteger);

            case NSREnums.eMDataType.M_dDouble:
                return(ConvertDouble(cv.doubleValue, cs.@null));

            case NSREnums.eMDataType.M_dFloat:
                return(ConvertDouble((double)cv.floatValue, cs.@null));

            case NSREnums.eMDataType.M_dShort:
                return(ConvertLong((long)cv.shortInteger, cs.@null));

            case NSREnums.eMDataType.M_dSmallIcon:
                return((long)cv.iconIdentifier);
            }

            throw new ApplicationException("Unknown eMDataType");
        }
Ejemplo n.º 2
0
    public override void GetCell(CSMAccpostingData data, ref SSMCellValue value, SSMCellStyle style)
    {
        var    postingData = data.GetAccPosting();
        int    tradeId = 0, accountNameId = 0;
        int    REVALUATION = 11, IDB_NOSTRO = 33528;
        String strValue = "Could Not Get Value", tempString;

        style.kind = eMDataType.M_dNullTerminatedString;

        if (postingData != null)
        {
            if (postingData.fPostingType == REVALUATION)
            {
                CSMPosition pos = CSMPosition.GetCSRPosition(postingData.fPositionID);
                if (pos != null)
                {
                    CSMPortfolio port = pos.GetPortfolio();
                    if (port != null)
                    {
                        CSMAmFund fund = CSMAmFund.GetFundFromFolio(port);                          //GetHedgeFund()
                        if (fund != null)
                        {
                            strValue = GetAccountBookNameForFund(fund);
                        }
                    }
                }
            }
            else
            {
                accountNameId = postingData.fAccountNameID;
                tradeId       = postingData.fTradeID;

                if (tradeId != 0 && accountNameId != 0)
                {
                    if (accountNameId == IDB_NOSTRO)
                    {
                        strValue = GetNostroIDBAccountBook(postingData.fNostroAccountID, postingData.fAccountNumber);
                    }
                    else
                    {
                        tempString = CSxDataFacade.GetAccountBookName(postingData.fAccountingBookID);
                        if (tempString != null)
                        {
                            strValue = tempString.Substring(0, Math.Min(4, tempString.Length));
                        }
                    }
                }
            }
        }
        value.SetString(strValue);
    }
Ejemplo n.º 3
0
        public override void GetCell(CSMAccPostingData data, ref SSMCellValue value, SSMCellStyle style)
        {
            using (var log = LogHelper.GetLogger(GetType().Name, MethodBase.GetCurrentMethod().Name))
            {
                style.kind = eMDataType.M_dNullTerminatedString;

                var accountData = data.GetAccPosting();
                var tradeId     = accountData.fTradeID;
                var accountId   = 0;



                SSMFinalPosting _fPosting = data.GetAccPosting();
                if (_fPosting != null)
                {
                    accountId = _fPosting.fAccountNameID;
                    if (_fPosting.fPostingType == 11)
                    {
                        CSMPosition pos = CSMPosition.GetCSRPosition(_fPosting.fPositionID);
                        if (pos != null)
                        {
                            CSMPortfolio port = pos.GetPortfolio();
                            if (port != null)
                            {
                                CSMAmFund fund = CSMAmFund.GetFundFromFolio(port);
                                if (fund != null)
                                {
                                    string accountBookName = GetAccountBookNameForFund(fund);
                                    value.SetString(accountBookName);
                                    return;
                                }
                            }
                        }
                        return;
                    }
                }

                if (tradeId == 0 || accountId == 0)
                {
                    return;
                }

                CSMTransaction trade = CSMTransaction.newCSRTransaction(tradeId);
                if (trade == null)
                {
                    return;
                }

                //Business Event
                int type = (int)trade.GetTransactionType();

                //Any Posting linked to the IDB Group should have account book 1000
                if (_fPosting.fAccountNameID == 33528)
                {
                    value.SetString(GetNostroIDBAccountBook(_fPosting.fID));
                    return;
                }
                int PostingId = _fPosting.fID;
                int NostroId  = _fPosting.fNostroAccountID;
                if (NostroId > 0)
                {
                    int EntityId = 0;
                    if (fDataLoaded == false)
                    {
                        LoadAccountEntities();
                    }
                    fNostroAndEntity.TryGetValue(NostroId, out EntityId);
                    if (IsIDBGroupEntity(EntityId))
                    {
                        value.SetString("1000");
                        return;
                    }
                }

                var cacheKey = string.Format("AccountBook_{0}", accountData.fID);
                var strValue = CacheManager.GetItem <string>(cacheKey);

                try
                {
                    if (!string.IsNullOrEmpty(strValue))
                    {
                        value.SetString(strValue);
                        return;
                    }

                    //if value is not cached already we loaded it
                    strValue = CSxDataFacade.GetAccountBookName(accountData.fAccountingBookID);



                    //Filter on the account defined in the config file
                    if (CSxIslamicInstrumentsHelperCLI.IsForbiddenAccountId(accountId))
                    {
                        var parentId = 0;
                        try
                        {
                            //parentId = CSxIslamicInstrumentsHelperCLI.GetParentTrade(tradeId);

                            //couponS and redemption sukuk are not taken in account in this function
                            parentId = CSxIdbTradeId.GetParentIDBMergingAllocatedTrade(type, tradeId);
                        }
                        catch (Exception)
                        {
                            log.WriteSystemError("Failed to check if tarde is merged");
                        }
                        // AccountExceptions.Contains(accountData.fAccountingBookID)
                        //FILTER on merged trades
                        if (parentId != 0)
                        {
                            try
                            {
                                var t = CSMTransaction.newCSRTransaction(tradeId);
                                if (t == null)
                                {
                                    throw new Exception("Failed to open trade");
                                }

                                var fid = 0;
                                //if(CSxIslamicInstrumentsHelperCLI.IsInterFundCashTransferBusinessEvent(type))
                                //{
                                //    var tr = CSMTransaction.newCSRTransaction(parentId);
                                //    if (tr == null)
                                //        throw new Exception("Failed to open trade");

                                //    fid = CSxIslamicInstrumentsHelperCLI.GetFundForEntity(tr.GetEntity());
                                //}
                                //else
                                //{
                                fid = CSxIslamicInstrumentsHelperCLI.GetFundForEntity(t.GetEntity());
                                //}


                                CSMAmFund f = CSMInstrument.GetInstance(fid);
                                if (f == null)
                                {
                                    throw new Exception("Failed to find fund for settlement entity");
                                }
                                strValue = CSxDataFacade.GetAccountBookIdForFolio(f.GetTradingPortfolio());
                            }
                            catch (Exception e)
                            {
                                log.WriteSystemError("Failed to get Account Book Id from Settlement Entity for merged trade {0} : {1}", tradeId, e.Message);
                            }
                        }
                        //if (strValue != null)
                        //{
                        //    //strValue = strValue.Substring(0, Math.Min(4, strValue.Length));
                        //    //we cache the value for next time
                        //    CacheManager.SetItem(cacheKey, strValue);

                        //}
                    }

                    if (strValue != null)
                    {
                        strValue = strValue.Substring(0, Math.Min(4, strValue.Length));
                        value.SetString(strValue);
                    }
                }
                catch (Exception e)
                {
                    log.WriteSystemError("Failed to get Account Book Name for trade {0} : {1}", tradeId, e.Message);

                    if (IDB.IslamicInstruments.CSxIslamicInstrumentsHelperCLI.IsInGUIMode())
                    {
                        MessageBox.Show("Failed to get Account Book Name for trade " + tradeId + " Error:" + e.Message);
                    }
                }
            }
        }