Example #1
0
 /// <summary>
 /// 判断对象是不是存在
 /// </summary>
 public static bool IsExits(string key, Depositary where)
 {
     if (SystemConfig.IsBSsystem)
     {
         if (where == Depositary.Application)
         {
             if (System.Web.HttpContext.Current.Cache[key] == null)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             if (System.Web.HttpContext.Current.Session[key] == null)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     else
     {
         return(CS_Cash.ContainsKey(key));
     }
 }
Example #2
0
        /// <summary>
        /// 从 Cash 里面取出对象.
        /// </summary>
        public static object GetObj(string key, Depositary where)
        {
#if DEBUG
            if (where == Depositary.None)
            {
                throw new Exception("您没有把[" + key + "]放到session or application 里面不能找出他们.");
            }
#endif

            if (SystemConfig.IsBSsystem)
            {
                if (where == Depositary.Application)
                {
                    // return  System.Web.HttpContext.Current.Cache[key];
                    return(BS_Cash[key]); //  System.Web.HttpContext.Current.Cache[key];
                }
                else
                {
                    return(System.Web.HttpContext.Current.Session[key]);
                }
            }
            else
            {
                return(CS_Cash[key]);
            }
        }
Example #3
0
        private static Dividend ApproveXBRL4_InsertDvdXBRL(XBRL_event_info xei, Dividend dvd)
        {
            if (dvd == null || xei == null)
            {
                return(null);
            }

            DividendXBRL dvdXBRL = DividendXBRL_master.Get_dvdXBRL(xei.XBRL_ReferenceNumber, dvd.DividendIndex);

            if (dvdXBRL == null)
            {
                dvdXBRL = new DividendXBRL();
            }

            Depositary depo = DepositaryMaster.GetDepositary_by_name(xei.depoName);

            if (depo == null)
            {
                depo = DepositaryMaster.GetDepositary_by_name(xei.Sender);
            }
            if (depo != null)
            {
                dvdXBRL.Depositary.Value = depo.DepositaryName.Value;
            }

            dvdXBRL.DividendIndex.Value        = dvd.DividendIndex;
            dvdXBRL.XBRL_ReferenceNumber.Value = xei.XBRL_ReferenceNumber;

            dvdXBRL.Announcement_Identifier.Value = xei.AnnouncementIdentifier;
            if (!dvdXBRL.IsCompleteEvent_flag)
            {
                dvdXBRL.Event_Completeness.Value = xei.EventCompleteness;
            }

            if (dvdXBRL.XBRL_ID > 0)
            {
                if (dvdXBRL.CheckValueChanges())
                {
                    dvdXBRL.LastModifiedBy.Value   = Utility.CurrentUser;
                    dvdXBRL.LastModifiedDate.Value = DateTime.Now;
                    bool flag = dvdXBRL.Update_to_DB();
                }
            }
            else
            {
                dvdXBRL.LastModifiedBy.Value   = Utility.CurrentUser;
                dvdXBRL.LastModifiedDate.Value = DateTime.Now;
                bool flag = dvdXBRL.Insert_to_DB();
            }

            return(dvd);
        }
        /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

        public void Init_from_DRWIN_depo(Depositary depo)
        {
            if (depo == null)
            {
                return;
            }

            this.idemnification.Value        = depo.ESP_Idemnification.Value;
            this.idemnification2.Value       = depo.ESP_Idemnification2.Value;
            this.idemnification_di.Value     = depo.ESP_Idemnification_DI.Value;
            this.idemnification2_di.Value    = depo.ESP_Idemnification2_DI.Value;
            this.idemnification_russia.Value = depo.ESP_Idemnification_RUSSIA.Value;
        }
Example #5
0
        public static void AddObj(string key, Depositary where, object obj)
        {
            if (key == null)
            {
                throw new Exception("您需要为obj=" + obj.ToString() + ",设置为主键值。key");
            }

            if (obj == null)
            {
                throw new Exception("您需要为obj=null  设置为主键值。key=" + key);
            }

#if DEBUG
            if (where == Depositary.None)
            {
                throw new Exception("您没有把[" + key + "]放到 session or application 里面设置他们.");
            }
#endif
            //if (Cash.IsExits(key, where))
            //    return;

            if (SystemConfig.IsBSsystem)
            {
                if (where == Depositary.Application)
                {
                    BS_Cash[key] = obj;
                }
                else
                {
                    System.Web.HttpContext.Current.Session[key] = obj;
                }
            }
            else
            {
                if (CS_Cash.ContainsKey(key))
                {
                    CS_Cash[key] = obj;
                }
                else
                {
                    CS_Cash.Add(key, obj);
                }
            }
        }
Example #6
0
        private static bool DifferentRef_from_sameDepo(XBRL_event_info xei, Dividend existing_dvd)
        {
            if (xei == null || existing_dvd == null)
            {
                return(false);
            }

            List <DividendXBRL> dx_list = existing_dvd.Get_dividendXBRL_list();

            foreach (DividendXBRL dx in dx_list)
            {
                if (dx.XBRL_ReferenceNumber.IsValueEmpty || dx.Depositary.IsValueEmpty)
                {
                    continue;
                }
                if (dx.XBRL_ReferenceNumber.Value.Equals(xei.XBRL_ReferenceNumber, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                Depositary existingDepo = DepositaryMaster.GetDepositary_by_name(dx.Depositary.Value);
                if (existingDepo == null)
                {
                    continue;
                }

                Depositary XBRLdepo = DepositaryMaster.GetDepositary_by_name(xei.depoName);
                if (XBRLdepo == null)
                {
                    XBRLdepo = DepositaryMaster.GetDepositary_by_name(xei.Sender);
                }
                if (XBRLdepo == null)
                {
                    continue;
                }

                if (XBRLdepo.DepositaryName.Value.Equals(existingDepo.DepositaryName.Value, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #7
0
        /// <summary>
        /// RemoveObj
        /// </summary>
        /// <param name="key"></param>
        /// <param name="where"></param>
        public static void RemoveObj(string key, Depositary where)
        {
            if (Cash.IsExits(key, where) == false)
            {
                return;
            }

            if (SystemConfig.IsBSsystem)
            {
                if (where == Depositary.Application)
                {
                    System.Web.HttpContext.Current.Cache.Remove(key);
                }
                else
                {
                    System.Web.HttpContext.Current.Session.Remove(key);
                }
            }
            else
            {
                CS_Cash.Remove(key);
            }
        }
Example #8
0
        public string Create_dividendID(int dvdID_offset = 0)
        {
            if (dvdID_offset > 49 || dvdID_offset < 0)
            {
                dvdID_offset = 0;                                       //only support offset range 0 ~ 49 for now
            }
            Depositary depo = null;

            int    sponserID = 99;
            string depoID    = "00";

            if (this.Sponsored.Value)
            {
                sponserID = 0 + dvdID_offset;
                depo      = DepositaryMaster.GetDepositary_by_name(this.Depositary.Value);
            }
            else
            {
                sponserID -= dvdID_offset;
                depo       = DepositaryMaster.GetDepositary_by_name(Depositaries.Depositary.Unsponsored);
            }

            if (depo != null)
            {
                depoID = depo.DepositaryID.Value;
            }

            StringBuilder dvdID_sb = new StringBuilder();

            dvdID_sb.Append(HssStr.Trim_to_size(sponserID, 2));//sponsered or not
            dvdID_sb.Append(HssStr.Trim_to_size(depoID, 2));
            dvdID_sb.Append(HssStr.Trim_to_size(this.CUSIP.Value, 9));
            dvdID_sb.Append(this.RecordDate_ADR.Value.ToString("MMddyyyy"));
            dvdID_sb.Append(HssStr.Trim_to_size(this.IncomeEventID.Value, 2, '0'));

            return(dvdID_sb.ToString());
        }
Example #9
0
        private static void ApproveXBRL3_AddFees(Dividend dvd)
        {
            if (dvd == null)
            {
                return;
            }

            string     depo_str = dvd.Sponsored.Value ? dvd.Depositary.Value : dvd.FirstFiler.Value;
            Depositary depo     = DepositaryMaster.GetDepositary_by_name(depo_str);

            if (depo == null)
            {
                return;
            }

            Schedule_Of_Fees_DSC sfd = DSC_master.GetDSC_from_CDS(dvd.Country.Value, depo.DepositaryName.Value, dvd.RecordDate_ADR.Value, dvd.SecurityTypeID.Value);

            if (sfd == null)
            {
                return;
            }
            Dictionary <decimal, Schedule_Of_Fees_Per_Rate> Japan_atSourceFee_dic = DSC_master.Get_SFPR_dic(dvd.Country.Value, depo.DepositaryName.Value, dvd.RecordDate_ADR.Value);

            Bulk_DBcmd bk_cmd = new Bulk_DBcmd();
            List <DTC_Position_Headers> header_list = DTCpositionHeader_master.Get_headerList_modNum(dvd.DTCPosition_ModelNumber.Value);

            HashSet <decimal> unique_WHrate_hs = new HashSet <decimal>();

            foreach (DTC_Position_Headers dph in header_list)
            {
                unique_WHrate_hs.Add(dph.WHRate.Value);
            }

            foreach (decimal WHrate in unique_WHrate_hs)
            {
                Dividend_Schedule_Of_Fees_DSC dsfd = new Dividend_Schedule_Of_Fees_DSC();
                dsfd.DividendIndex.Value = dvd.DividendIndex;
                dsfd.WHRate.Value        = WHrate / 100;

                dsfd.LongFormFees.Value   = sfd.LongFormFees.Value;
                dsfd.MinLongFormFee.Value = sfd.MinLongFormFee.Value;

                dsfd.Fee_Consularization.Value = dvd.ConsularizationFee.Value;
                dsfd.Fee_QuickRefund.Value     = sfd.ShortFormFees.Value;

                /*  //useless for now
                 *  dsfd.Fee_AtSource.Value = dvd.AtSourceFee.Value;
                 *  dsfd.Fee_Max.Value = dvd.MAX_Fees.Value;
                 *  dsfd.ExemptAtSourceFee.Value = sfd.ExemptAtSourceFee.Value;//combined into FavAtSourceFee
                 *  dsfd.ShortFormFees.Value = sfd.ShortFormFees.Value;
                 *  dsfd.MinShortFormFee.Value = sfd.MinShortFormFee.Value;
                 */

                dsfd.MinAtSourceFee.Value          = sfd.MinAtSourceFee.Value;
                dsfd.MinQuickRefundFee.Value       = sfd.MinQuickRefundFee.Value;
                dsfd.FavTransparentEntityFee.Value = sfd.FavTransparentEntityFee.Value;

                if (Japan_atSourceFee_dic.ContainsKey(WHrate))
                {
                    Schedule_Of_Fees_Per_Rate sfpr = Japan_atSourceFee_dic[WHrate];
                    dsfd.FavAtSourceFee.Value = sfpr.RateWithADSC.Value;

                    dsfd.AdditionalDSCFee.Value  = sfpr.ADSC.Value;
                    dsfd.AdditionalDSCFee1.Value = sfpr.ADSC.Value;
                }
                else
                {
                    if (WHrate == 0)
                    {
                        dsfd.FavAtSourceFee.Value = sfd.ExemptAtSourceFee.Value;
                    }
                    else
                    {
                        dsfd.FavAtSourceFee.Value = sfd.FavAtSourceFee.Value;
                    }

                    dsfd.AdditionalDSCFee.Value  = sfd.AdditionalDSCFee.Value;
                    dsfd.AdditionalDSCFee1.Value = sfd.AdditionalDSCFee.Value;
                }

                dsfd.Source_FeeID.Value     = sfd.FeesID;
                dsfd.LastModifiedBy.Value   = "StevenXBRL-" + Utility.CurrentUser;
                dsfd.ModifiedDateTime.Value = DateTime.Now;

                bk_cmd.Add_DBcmd(dsfd.Get_DBinsert());
            }

            int count = bk_cmd.SaveToDB(Utility.Get_DRWIN_hDB());
        }
Example #10
0
        private static Security CreateSecurity_fromXBRL(XBRL_event_info xei)
        {
            if (xei == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(xei.CUSIP))
            {
                Console.WriteLine("SecurityMaster error 0: no CUSIP in XBRL");
                return(null);
            }
            if (xei.ADR_Ratio_ADR == 0 || xei.ADR_Ratio_ORD == 0)
            {
                Console.WriteLine("SecurityMaster error 1: ratio incorrect in XBRL");
                return(null);
            }

            Country cty = CountryMaster.GetCountry_name(xei.ISO2CntryCode);

            Depositary depo = DepositaryMaster.GetDepositary_by_name(xei.depoName);

            if (depo == null)
            {
                depo = DepositaryMaster.GetDepositary_by_name(xei.Sender);
            }
            if (depo == null)
            {
                Console.WriteLine("SecurityMaster error 2: no depository info in XBRL");
                return(null);
            }

            Security xbrl_sec = new Security();

            xbrl_sec.Name.Value           = xei.Issue.ToUpper();
            xbrl_sec.CUSIP.Value          = xei.CUSIP;
            xbrl_sec.ClearingSystem.Value = "DTCC";
            xbrl_sec.SecurityType.Value   = "ADR";
            xbrl_sec.ADR_RATIO_ADR.Value  = xei.ADR_Ratio_ADR;
            xbrl_sec.ADR_RATIO_ORD.Value  = xei.ADR_Ratio_ORD;
            if (cty != null)
            {
                xbrl_sec.Country.Value = cty.name;
            }

            if (xei.Sponsored)
            {
                xbrl_sec.Depositary.Value = depo.DepositaryName.Value;
            }
            else //Un-sponsored event
            {
                if (xei.IsFirstFiler)
                {
                    xbrl_sec.Depositary.Value = Depositary.Unsponsored;
                    xbrl_sec.FirstFiler.Value = depo.DepositaryShortName.Value;
                }
                else
                {
                    Console.WriteLine("SecurityMaster info 0: Unsponsored event and this depo is not first filer, return null");
                    return(null);
                }
            }

            xbrl_sec.LastModifiedBy.Value   = Utility.CurrentUser;
            xbrl_sec.ModifiedDateTime.Value = DateTime.Now;

            return(xbrl_sec);
        }