コード例 #1
0
ファイル: DTC_Solicitation.cs プロジェクト: huangss0/GTS0
        private HashSet <int> Create_dvdIndex_hs()
        {
            this.statusInfo.status = "Create dvdIndex_hs from DTC_Position";

            HashSet <int> dvdIndex_hs = new HashSet <int>();
            DB_select     selt        = new DB_select(BD_DTC_Position.Get_cmdTP());
            DB_reader     reader      = new DB_reader(selt, Utility.Get_DRWIN_hDB());

            while (reader.Read())
            {
                BD_DTC_Position bdp = new BD_DTC_Position();
                bdp.Init_from_reader(reader);

                dvdIndex_hs.Add(bdp.DividendIndex);

                DTC_Participants dp = DTC_Participants_master.Get_DTC_Participants_DTCnum(bdp.DTC_Number);
                bdp.dtcParti = dp;

                this.dtcPos_list.Add(bdp);
                ++this.statusInfo.recordNum;
            }
            reader.Close();

            return(dvdIndex_hs);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: Dividend_func_AP.cs プロジェクト: huangss0/GTS0
        public void Calculate(List <Dividend_Detail_simpleAP> selected_dd_list)
        {
            if (selected_dd_list == null || this.APcount_dic.Count == 0)
            {
                return;
            }

            //Assign CustodianID for RSH first
            foreach (Dividend_Detail_simpleAP detail in selected_dd_list)
            {
                string           DTCnum  = detail.DTC_Number.Value;
                DTC_Participants dtcPart = DTC_Participants_master.Get_DTC_Participants_DTCnum(DTCnum);
                if (dtcPart == null || dtcPart.Type.IsValueEmpty)
                {
                    continue;
                }
                if (!dtcPart.Type.Value.Equals("RSH", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                DvdCustodian_AP_count dcAP = this.GetClosest_dc(detail.RecordDatePosition.Value, dtcPart.Depositary.Value);
                if (dcAP == null)
                {
                    continue;
                }

                DividendCustodian dvdCust = dcAP.dvdCust;
                detail.CustodianID.Value = dvdCust.CustodianID;
                dcAP.expectedCount      -= detail.RecordDatePosition.Value;
                dcAP.dd_list.Add(detail);

                //foreach (int custID in this.APcount_dic.Keys)
                //{
                //    DividendCustodian dvdCust = this.dvdCust_dic[custID];
                //    if (dvdCust.Depositary.Value.Equals(dtcPart.Depositary.Value, StringComparison.OrdinalIgnoreCase))//Try to match Depositary with [Dividend_Custodian]
                //    {
                //        DvdCustodian_AP_count dcAP = this.APcount_dic[custID];
                //        if (dcAP.expectedCount >= detail.RecordDatePosition.Value)
                //        {
                //            detail.CustodianID.Value = dvdCust.CustodianID;
                //            dcAP.expectedCount -= detail.RecordDatePosition.Value;
                //            dcAP.dd_list.Add(detail);
                //        }
                //        break;
                //    }
                //}
            }

            //Assign CustodianID for non-RSH
            foreach (Dividend_Detail_simpleAP detail in selected_dd_list)
            {
                string DTCnum = detail.DTC_Number.Value;
                if (DTCnum != null && DTCnum.StartsWith("RSH", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                DvdCustodian_AP_count dcAP = this.GetHighest_dc();
                if (dcAP.expectedCount < detail.RecordDatePosition.Value)
                {
                    continue;
                }

                DividendCustodian dvdCust = dcAP.dvdCust;
                detail.CustodianID.Value = dvdCust.CustodianID;
                dcAP.expectedCount      -= detail.RecordDatePosition.Value;
                dcAP.dd_list.Add(detail);
            }
        }