示例#1
0
        private void SubCal_read_DTCposition(Dictionary <decimal, List <DTC_Position_Headers> > whr_map, Dividend dvd)
        {
            List <Dividend_DTC_Position> pos_list = dvd.Get_DTCposition_list();

            ParticipantMaster pc = new ParticipantMaster();

            pc.Init_from_dtcPosList(pos_list);

            foreach (Dividend_DTC_Position pos in pos_list)
            {
                bool        isRSH_flag = false;
                Participant pt         = pc.GetParticipant(pos.DTC_Number.Value);
                if (pt != null)
                {
                    isRSH_flag = pt.DCT_Number.StartsWith("RSH", StringComparison.OrdinalIgnoreCase);
                }

                int custodianID = pos.CustodianID.Value;
                if (!this.dvdCus_dic_custodianType.ContainsKey(custodianID))
                {
                    continue;
                }

                DividendCustodian pos_dvdCust = this.dvdCus_dic_custodianType[custodianID];//check against selected Depository
                if (!pos_dvdCust.Depositary.Value.Equals(this.dvdCust.Depositary.Value, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                foreach (KeyValuePair <decimal, List <DTC_Position_Headers> > pair in whr_map)
                {
                    decimal WH_rate = pair.Key, ADR_shares = 0;
                    foreach (DTC_Position_Headers dph in pair.Value)
                    {
                        ADR_shares += pos.GetRateValues(dph.Table_Column.Value);
                    }

                    if (isRSH_flag)
                    {
                        this.RSH_dic[WH_rate].ADRQuantity += ADR_shares;
                    }
                    else
                    {
                        this.DTC_participant_dic[WH_rate].ADRQuantity += ADR_shares;
                    }

                    this.custodianEle_dic[custodianID].cust_dic[WH_rate].ADRQuantity += ADR_shares;
                    this.summary.totalEle_dic[WH_rate].ADRQuantity += ADR_shares;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Insert DTC Position using SPR file from DTCC
        /// </summary>
        /// <param name="sf">SPR file</param>
        /// <param name="createNew_flag">append or create new</param>
        public bool Insert_DTC_position(SPR_file sf, bool createNew_flag = true)
        {
            if (sf == null || sf.FileBinary == null)
            {
                MessageBox.Show("Dividend_func4 error 0: No SPR data");
                return(false);
            }

            MemoryStream ms = new MemoryStream(sf.FileBinary);
            StreamReader sr = new StreamReader(ms);

            if (createNew_flag)
            {
                this.Delete_DTC_position();
            }

            List <Position> posList = new List <Position>();
            string          str     = null;

            while ((str = sr.ReadLine()) != null)
            {
                if (str.Length <= 37)
                {
                    continue;
                }

                char recordType_char = str[SPR_fileControl.RecordTypeChar_index];
                if (recordType_char != '2')
                {
                    continue;                         //'2' stands for detail records
                }
                if (str.StartsWith("HDR", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                if (str.StartsWith("TRL", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }

                Position dtcPos = new Position();
                dtcPos.DividendIndex = this.DividendIndex;

                dtcPos.DTC_Number   = str.Substring(19, 8).TrimStart('0');
                dtcPos.Company_Name = str.Substring(27, 10).Trim();

                string  totalPos_str = str.Substring(37).Trim();
                decimal tempDecimal  = -1;
                if (decimal.TryParse(totalPos_str, out tempDecimal))
                {
                    dtcPos.Total_RecDate_Position = tempDecimal;
                }

                posList.Add(dtcPos);
            }

            ParticipantMaster pcMaster = new ParticipantMaster();

            pcMaster.Init_from_dtcPosList(posList);

            Bulk_DBcmd buk_ins = new Bulk_DBcmd();
            List <DTC_Participants> missing_DCTpart_list = new List <DTC_Participants>();

            foreach (Position pos in posList)
            {
                Participant pt = pcMaster.GetParticipant(pos.DTC_Number);
                if (pt == null)
                {
                    DTC_Participants dtcPart = new DTC_Participants();

                    int tempInt = -1;
                    if (!int.TryParse(pos.DTC_Number, out tempInt))
                    {
                        continue;
                    }
                    dtcPart.DTC = tempInt;

                    dtcPart.DTC_Number.Value   = pos.DTC_Number;
                    dtcPart.Company_Name.Value = pos.Company_Name;

                    missing_DCTpart_list.Add(dtcPart);
                }
                else
                {
                    pos.Company_Name = pt.Company_Name; //if exist, change the name to what we have in [DTC_Participants]
                }
                buk_ins.Add_DBcmd(pos.Get_DBinsert());
            }

            int count0 = buk_ins.SaveToDB(Utility.Get_DRWIN_hDB());
            int count1 = DTC_Participants_master.Insert_DTC_Participants(missing_DCTpart_list);

            return(true);
        }