/// <summary>
        /// 
        /// </summary>
        private void LoopGetCandlesManagerAPI()
        {
            string symbols = string.Empty;
            if (Business.Market.Symbols != null)
            {
                foreach (KeyValuePair<string, Business.Symbol> sm in Business.Market.Symbols)
                {
                    symbols += sm.Key + "{";
                }
            }

            if (symbols.EndsWith("{"))
                symbols = symbols.Remove(symbols.Length - 1, 1);

            DateTime timeCandles = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 00, 00, 00);
            DateTime timeCandlesOne = timeCandles.AddDays(-1);

            DateTime timeCandlesFive = timeCandles.AddDays(-5);
            if (timeCandlesFive.DayOfWeek == DayOfWeek.Saturday)
                timeCandlesFive = timeCandlesFive.AddDays(-1);

            if (timeCandlesFive.DayOfWeek == DayOfWeek.Sunday)
                timeCandlesFive = timeCandlesFive.AddDays(-2);

            string cmd = "GetCandlesByDate$" + symbols + "|" + timeCandles;
            string resultAPI = Business.Market.InstanceSocket.SendSocket(cmd);
            Business.Market.CandlesByDate = Model.BuildCommand.Instance.MapStringToDicCandle(resultAPI);

            string cmdOneDay = "GetCandlesByDate$" + symbols + "|" + timeCandlesOne;
            string OneDay = Business.Market.InstanceSocket.SendSocket(cmdOneDay);
            Business.Market.CandlesByDateOneDay = Model.BuildCommand.Instance.MapStringToDicCandle(OneDay);

            string cmdFiveDay = "GetCandlesByDate$" + symbols + "|" + timeCandlesFive;
            string FiveDay = Business.Market.InstanceSocket.SendSocket(cmdFiveDay);
            Business.Market.CandlesByDateFiveDay = Model.BuildCommand.Instance.MapStringToDicCandle(FiveDay);

            //==============================================================================================

            Business.Market.EventGetCandles = new TimeEvent();
            EventGetCandles.EventType = TimeEventType.BeginSwap;
            EventGetCandles.TimeEventID = 0;

            Business.TargetFunction newTargetFunction = new TargetFunction();
            newTargetFunction.EventPosition = "All";
            newTargetFunction.Function = this.EventGetCandlesByDate;

            EventGetCandles.TargetFunction = new List<TargetFunction>();
            EventGetCandles.TargetFunction.Add(newTargetFunction);

            Business.DateTimeEvent newDateTimeEvent = new DateTimeEvent();
            newDateTimeEvent.Day = -1;
            newDateTimeEvent.Month = -1;
            newDateTimeEvent.DayInWeek = DateTime.Now.DayOfWeek;
            newDateTimeEvent.Hour = 0;
            newDateTimeEvent.Minute = 5;

            EventGetCandles.Time = newDateTimeEvent;
            EventGetCandles.IsEnable = true;
            DateTime _tempTime = DateTime.Now.AddDays(1);
            DateTime newDateTime = new DateTime(_tempTime.Year, _tempTime.Month, _tempTime.Day, newDateTimeEvent.Hour, newDateTimeEvent.Minute, 00);

            EventGetCandles.TimeExecution = newDateTime;

            TimeSpan _timeSpand = EventGetCandles.TimeExecution - DateTime.Now;
            this.TimeEventExecuteCandles(_timeSpand.TotalMilliseconds);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Cmd"></param>
        /// <returns></returns>
        internal List<Business.TimeEvent> ExtractTimeEvent(string Cmd,string TargetPosition,string Code,int ID)
        {
            List<Business.TimeEvent> Result = new List<TimeEvent>();
            if (!string.IsNullOrEmpty(Cmd))
            {
                int HourFrist = -1;
                int MinuteFirst = -1;
                int HourSecond = -1;
                int MinuteSecond = -1;
                string[] subParameter = Cmd.Split('~');
                if (subParameter.Length > 0)
                {
                    int count = subParameter.Length;
                    for (int i = 0; i < count; i++)
                    {
                        string[] subEvent = subParameter[i].Split('#');
                        if (subEvent.Length > 1)
                        {
                            string[] subSession = subEvent[1].Split('+');
                            if (subSession.Length > 0)
                            {
                                int countSession = subSession.Length;
                                for (int j = 0; j < countSession; j++)
                                {
                                    string[] subTimeSession = subSession[j].Split('-');
                                    if (subTimeSession.Length > 1)
                                    {
                                        string[] subTimeStart = subTimeSession[0].Split(':');
                                        string[] subTimeEnd = subTimeSession[1].Split(':');

                                        switch (Code)
                                        {
                                            case "S042":
                                                {
                                                    #region Add Event Quote Config
                                                    int.TryParse(subTimeStart[0], out HourFrist);
                                                    int.TryParse(subTimeStart[1], out MinuteFirst);

                                                    Business.TimeEvent TimeEventStart = new TimeEvent();
                                                    Business.DateTimeEvent TimeEvent = new DateTimeEvent();
                                                    TimeEventStart.EventType = TimeEventType.EndCloseTradeSymbol;
                                                    TimeEvent.Day = -1;
                                                    TimeEvent.DayInWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), subEvent[0], true);
                                                    TimeEvent.Hour = HourFrist;
                                                    TimeEvent.Minute = MinuteFirst;
                                                    TimeEvent.Month = -1;
                                                    TimeEventStart.Time = TimeEvent;
                                                    TimeEventStart.TimeEventID = ID;
                                                    TimeEventStart.NumSession = j;

                                                    Business.TargetFunction newTargetFunctionStart = new TargetFunction();
                                                    newTargetFunctionStart.EventPosition = TargetPosition;
                                                    newTargetFunctionStart.Function = this.OpenTradeSymbol;
                                                    newTargetFunctionStart.NumSession = j;

                                                    if (TimeEventStart.TargetFunction == null)
                                                        TimeEventStart.TargetFunction = new List<TargetFunction>();

                                                    TimeEventStart.TargetFunction.Add(newTargetFunctionStart);

                                                    Result.Add(TimeEventStart);

                                                    //Add Event
                                                    Business.TimeEvent TimeEventEnd = new TimeEvent();
                                                    Business.DateTimeEvent DateTimeEnd = new DateTimeEvent();
                                                    TimeEventEnd.EventType = TimeEventType.BeginCloseQuoteSymbol;
                                                    int.TryParse(subTimeEnd[0], out HourSecond);
                                                    int.TryParse(subTimeEnd[1], out MinuteSecond);
                                                    DateTimeEnd.Day = -1;
                                                    DateTimeEnd.DayInWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), subEvent[0], true);
                                                    DateTimeEnd.Hour = HourSecond;
                                                    DateTimeEnd.Minute = MinuteSecond;
                                                    TimeEventEnd.Time = DateTimeEnd;
                                                    TimeEventEnd.TimeEventID = ID;
                                                    TimeEventEnd.NumSession = j;

                                                    Business.TargetFunction newTargetFunctionEnd = new TargetFunction();
                                                    newTargetFunctionEnd.EventPosition = TargetPosition;
                                                    newTargetFunctionEnd.Function = this.CloseTradeSymbol;
                                                    newTargetFunctionEnd.NumSession = j;

                                                    if (TimeEventEnd.TargetFunction == null)
                                                        TimeEventEnd.TargetFunction = new List<TargetFunction>();

                                                    TimeEventEnd.TargetFunction.Add(newTargetFunctionEnd);

                                                    Result.Add(TimeEventEnd);
                                                    #endregion
                                                }
                                                break;

                                            case "S043":
                                                {
                                                    #region Add Trade Symbol Config
                                                    int.TryParse(subTimeStart[0], out HourFrist);
                                                    int.TryParse(subTimeStart[1], out MinuteFirst);
                                                    Business.TimeEvent TimeEventStart = new TimeEvent();
                                                    Business.DateTimeEvent TimeEvent = new DateTimeEvent();
                                                    TimeEventStart.EventType = TimeEventType.EndCloseQuoteSymbol;
                                                    TimeEvent.Day = -1;
                                                    TimeEvent.DayInWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), subEvent[0], true);
                                                    TimeEvent.Hour = HourFrist;
                                                    TimeEvent.Minute = MinuteFirst;
                                                    TimeEvent.Month = -1;
                                                    TimeEventStart.Time = TimeEvent;
                                                    TimeEventStart.TimeEventID = ID;
                                                    TimeEventStart.NumSession = j;

                                                    Business.TargetFunction newTargetFunctionStart = new TargetFunction();
                                                    newTargetFunctionStart.EventPosition = TargetPosition;
                                                    newTargetFunctionStart.Function = this.OpenQuoteSymbol;
                                                    newTargetFunctionStart.NumSession = j;

                                                    if (TimeEventStart.TargetFunction == null)
                                                        TimeEventStart.TargetFunction = new List<TargetFunction>();

                                                    TimeEventStart.TargetFunction.Add(newTargetFunctionStart);

                                                    Result.Add(TimeEventStart);

                                                    Business.TimeEvent TimeEventEnd = new TimeEvent();
                                                    Business.DateTimeEvent DateTimeEnd = new DateTimeEvent();
                                                    TimeEventEnd.EventType = TimeEventType.BeginCloseTradeSymbol;
                                                    int.TryParse(subTimeEnd[0], out HourSecond);
                                                    int.TryParse(subTimeEnd[1], out MinuteSecond);
                                                    DateTimeEnd.Day = -1;
                                                    DateTimeEnd.DayInWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), subEvent[0], true);
                                                    DateTimeEnd.Hour = HourSecond;
                                                    DateTimeEnd.Minute = MinuteSecond;
                                                    TimeEventEnd.Time = DateTimeEnd;
                                                    TimeEventEnd.TimeEventID = ID;
                                                    TimeEventEnd.NumSession = j;

                                                    Business.TargetFunction newTargetFunctionEnd = new TargetFunction();
                                                    newTargetFunctionEnd.EventPosition = TargetPosition;
                                                    newTargetFunctionEnd.Function = this.CloseQuoteSymbol;
                                                    newTargetFunctionEnd.NumSession = j;

                                                    if (TimeEventEnd.TargetFunction == null)
                                                        TimeEventEnd.TargetFunction = new List<TargetFunction>();

                                                    TimeEventEnd.TargetFunction.Add(newTargetFunctionEnd);

                                                    Result.Add(TimeEventEnd);
                                                    #endregion
                                                }
                                                break;

                                            case "C28":
                                                {
                                                    #region Add Trade Symbol Config
                                                    int.TryParse(subTimeStart[0], out HourFrist);
                                                    int.TryParse(subTimeStart[1], out MinuteFirst);
                                                    Business.TimeEvent TimeEventStart = new TimeEvent();
                                                    Business.DateTimeEvent TimeEvent = new DateTimeEvent();
                                                    TimeEventStart.EventType = TimeEventType.EndCloseMarket;
                                                    TimeEvent.Day = -1;
                                                    TimeEvent.DayInWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), subEvent[0], true);
                                                    TimeEvent.Hour = HourFrist;
                                                    TimeEvent.Minute = MinuteFirst;
                                                    TimeEvent.Month = -1;
                                                    TimeEventStart.Time = TimeEvent;
                                                    TimeEventStart.TimeEventID = ID;
                                                    TimeEventStart.NumSession = j;

                                                    Business.TargetFunction newTargetFunctionStart = new TargetFunction();
                                                    newTargetFunctionStart.EventPosition = TargetPosition;
                                                    newTargetFunctionStart.Function = this.OpenMarket;
                                                    newTargetFunctionStart.NumSession = j;

                                                    if (TimeEventStart.TargetFunction == null)
                                                        TimeEventStart.TargetFunction = new List<TargetFunction>();

                                                    TimeEventStart.TargetFunction.Add(newTargetFunctionStart);

                                                    Result.Add(TimeEventStart);

                                                    Business.TimeEvent TimeEventEnd = new TimeEvent();
                                                    Business.DateTimeEvent DateTimeEnd = new DateTimeEvent();
                                                    TimeEventEnd.EventType = TimeEventType.BeginCloseMarket;
                                                    int.TryParse(subTimeEnd[0], out HourSecond);
                                                    int.TryParse(subTimeEnd[1], out MinuteSecond);
                                                    DateTimeEnd.Day = -1;
                                                    DateTimeEnd.DayInWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), subEvent[0], true);
                                                    DateTimeEnd.Hour = HourSecond;
                                                    DateTimeEnd.Minute = MinuteSecond;
                                                    TimeEventEnd.Time = DateTimeEnd;
                                                    TimeEventEnd.TimeEventID = ID;
                                                    TimeEventEnd.NumSession = j;

                                                    Business.TargetFunction newTargetFunctionEnd = new TargetFunction();
                                                    newTargetFunctionEnd.EventPosition = TargetPosition;
                                                    newTargetFunctionEnd.Function = this.CloseMarket;
                                                    newTargetFunctionEnd.NumSession = j;

                                                    if (TimeEventEnd.TargetFunction == null)
                                                        TimeEventEnd.TargetFunction = new List<TargetFunction>();

                                                    TimeEventEnd.TargetFunction.Add(newTargetFunctionEnd);

                                                    Result.Add(TimeEventEnd);
                                                    #endregion
                                                }
                                                break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return Result;
            }

            return Result;
        }
        /// <summary>
        /// INIT TIME EVENT SERVER, HOLIDAY, EVENT END DAY
        /// </summary>
        internal void InitTimeEventServer()
        {
            string[] subEndofDay = new string[] { };
            Business.Market.YearEvent = new List<TimeEvent>();
            Business.Market.DayEvent = new List<TimeEvent>();
            if (Market.MarketConfig != null)
            {
                int count = Market.MarketConfig.Count;
                for (int i = 0; i < count; i++)
                {
                    #region GET CONFIG END OF DAY OF MARKET CONFIG
                    if (Market.MarketConfig[i].Code == "C09")
                    {
                        subEndofDay = Market.MarketConfig[i].StringValue.Split(':');

                        if (subEndofDay.Length > 1)
                        {
                            //Set End Of Day To Class Market
                            this.EndOfDay.Hour = int.Parse(subEndofDay[0]);
                            this.EndOfDay.Minute = int.Parse(subEndofDay[1]);

                            #region BUILD TIME EVENT CALCULATOR SWAP
                            Business.TimeEvent newTimeEvent = new Business.TimeEvent();
                            newTimeEvent.EventType = Business.TimeEventType.BeginSwap;
                            newTimeEvent.TimeEventID = Market.MarketConfig[i].ParameterItemID;

                            Business.TargetFunction newTargetFunction = new Business.TargetFunction();
                            newTargetFunction.EventPosition = "All";
                            newTargetFunction.Function = this.BeginCalculationSwap;

                            newTimeEvent.TargetFunction = new List<Business.TargetFunction>();
                            newTimeEvent.TargetFunction.Add(newTargetFunction);

                            Business.DateTimeEvent newDataTimeEvent = new Business.DateTimeEvent();
                            newDataTimeEvent.Day = -1;
                            newDataTimeEvent.Month = -1;
                            newDataTimeEvent.DayInWeek = DateTime.Now.DayOfWeek;
                            newDataTimeEvent.Hour = int.Parse(subEndofDay[0]);
                            newDataTimeEvent.Minute = int.Parse(subEndofDay[1]);

                            newTimeEvent.Time = newDataTimeEvent;
                            DateTime newDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, newDataTimeEvent.Hour, newDataTimeEvent.Minute, 00);

                            newTimeEvent.IsEnable = true;

                            newTimeEvent.TimeExecution = newDateTime;

                            Business.Market.DayEvent.Add(newTimeEvent);

                            #endregion

                            #region BUILD TIME EVENT MAINTAIN
                            Business.TimeEvent newTimeEventMaintain = new Business.TimeEvent();
                            newTimeEventMaintain.EventType = Business.TimeEventType.BeginMaintain;
                            newTimeEventMaintain.TimeEventID = Market.MarketConfig[i].ParameterItemID;

                            Business.TargetFunction newTargetFunctionMaintain = new Business.TargetFunction();
                            newTargetFunctionMaintain.EventPosition = "All";
                            newTargetFunctionMaintain.Function = this.BeginMaintain;

                            newTimeEventMaintain.TargetFunction = new List<Business.TargetFunction>();
                            newTimeEventMaintain.TargetFunction.Add(newTargetFunctionMaintain);

                            Business.DateTimeEvent newDataTimeEventMaintain = new Business.DateTimeEvent();
                            newDataTimeEventMaintain.Day = -1;
                            newDataTimeEventMaintain.Month = -1;
                            newDataTimeEventMaintain.DayInWeek = DateTime.Now.DayOfWeek;
                            newDataTimeEventMaintain.Hour = int.Parse(subEndofDay[0]);
                            newDataTimeEventMaintain.Minute = int.Parse(subEndofDay[1]);

                            newTimeEventMaintain.Time = newDataTimeEventMaintain;
                            DateTime newDateTimeExe = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, newDataTimeEventMaintain.Hour, newDataTimeEventMaintain.Minute, 00);
                            newTimeEventMaintain.TimeExecution = newDateTimeExe;

                            newTimeEventMaintain.IsEnable = true;

                            Business.Market.DayEvent.Add(newTimeEventMaintain);
                            #endregion

                            #region BUILD TIME EVENT EXECUTOR SETTING ORDER IN ADMIN
                            Business.TimeEvent newTimeEventOrder = new Business.TimeEvent();
                            newTimeEventOrder.EventType = Business.TimeEventType.SettingOrder;
                            newTimeEventOrder.TimeEventID = Market.MarketConfig[i].ParameterItemID;

                            Business.TargetFunction newTargetFunctionOrder = new Business.TargetFunction();
                            newTargetFunctionOrder.EventPosition = "All";
                            newTargetFunctionOrder.Function = this.ProcessSettingOrder;

                            newTimeEventOrder.TargetFunction = new List<Business.TargetFunction>();
                            newTimeEventOrder.TargetFunction.Add(newTargetFunctionOrder);

                            Business.DateTimeEvent newDataTimeEventOrder = new Business.DateTimeEvent();
                            newDataTimeEventOrder.Day = -1;
                            newDataTimeEventOrder.Month = -1;
                            newDataTimeEventOrder.DayInWeek = DateTime.Now.DayOfWeek;
                            newDataTimeEventOrder.Hour = int.Parse(subEndofDay[0]);
                            newDataTimeEventOrder.Minute = int.Parse(subEndofDay[1]);

                            newTimeEventOrder.Time = newDataTimeEventMaintain;
                            DateTime newDateTimeExeOrder = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, newDataTimeEventMaintain.Hour, newDataTimeEventMaintain.Minute, 00);
                            newTimeEventOrder.TimeExecution = newDateTimeExeOrder;

                            newTimeEventOrder.IsEnable = true;

                            Business.Market.DayEvent.Add(newTimeEventOrder);
                            #endregion
                        }

                        break;
                    }
                    #endregion
                }

                for (int j = 0; j < count; j++)
                {
                    #region GET CONFIG STATEMENTS MODE OF MARKET CONFIG
                    if (Market.MarketConfig[j].Code == "C11")
                    {
                        switch (Market.MarketConfig[j].StringValue)
                        {
                            #region BUILD EVENT STATEMENTS WITH END OF DAY
                            case "End of day":
                                {
                                    Business.TimeEvent newTimeEvent = new Business.TimeEvent();
                                    newTimeEvent.EventType = Business.TimeEventType.Statements;
                                    newTimeEvent.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                    Business.TargetFunction newTargetFunction = new Business.TargetFunction();
                                    newTargetFunction.EventPosition = "All";
                                    newTargetFunction.Function = this.SendReportDay;

                                    newTimeEvent.TargetFunction = new List<Business.TargetFunction>();
                                    newTimeEvent.TargetFunction.Add(newTargetFunction);

                                    Business.DateTimeEvent newDataTimeEvent = new Business.DateTimeEvent();
                                    newDataTimeEvent.Day = -1;
                                    newDataTimeEvent.Month = -1;
                                    newDataTimeEvent.DayInWeek = DateTime.Now.DayOfWeek;
                                    newDataTimeEvent.Hour = int.Parse(subEndofDay[0]);
                                    newDataTimeEvent.Minute = int.Parse(subEndofDay[1]);

                                    newTimeEvent.Time = newDataTimeEvent;
                                    DateTime newDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, newDataTimeEvent.Hour, newDataTimeEvent.Minute, 00);
                                    newTimeEvent.TimeExecution = newDateTime;

                                    newTimeEvent.IsEnable = true;

                                    Business.Market.DayEvent.Add(newTimeEvent);

                                    Market.EndDayTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 00);
                                }
                                break;
                            #endregion

                            #region BUILD EVENT STATEMENTS WITH START OF DAY
                            case "Start of day":
                                {
                                    Business.TimeEvent newTimeEvent = new Business.TimeEvent();
                                    newTimeEvent.EventType = Business.TimeEventType.Statements;
                                    newTimeEvent.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                    Business.TargetFunction newTargetFunction = new Business.TargetFunction();
                                    newTargetFunction.EventPosition = "All";
                                    newTargetFunction.Function = this.SendReportDay;

                                    newTimeEvent.TargetFunction = new List<Business.TargetFunction>();
                                    newTimeEvent.TargetFunction.Add(newTargetFunction);

                                    Business.DateTimeEvent newDataTimeEvent = new Business.DateTimeEvent();
                                    newDataTimeEvent.Day = -1;
                                    newDataTimeEvent.Month = -1;
                                    newDataTimeEvent.DayInWeek = DateTime.Now.AddDays(1).DayOfWeek;
                                    newDataTimeEvent.Hour = 00;
                                    newDataTimeEvent.Minute = 00;

                                    newTimeEvent.Time = newDataTimeEvent;

                                    DateTime newDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, newDataTimeEvent.Hour, newDataTimeEvent.Minute, 00);
                                    newTimeEvent.TimeExecution = newDateTime.AddDays(1);

                                    newTimeEvent.IsEnable = true;

                                    Business.Market.DayEvent.Add(newTimeEvent);

                                    Market.EndDayTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                                }
                                break;
                            #endregion
                        }
                    }
                    #endregion

                    #region GET CONFIG MONTHLY STATEMENTS MODE
                    if (Market.MarketConfig[j].Code == "C12")
                    {
                        switch (Market.MarketConfig[j].StringValue)
                        {
                            #region LAST DAY OF MONTH
                            case "Last day of month":
                                {
                                    Business.TimeEvent newTimeEvent = new Business.TimeEvent();
                                    newTimeEvent.EventType = Business.TimeEventType.StatementsMonth;
                                    newTimeEvent.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                    Business.TargetFunction newTargetFunction = new Business.TargetFunction();
                                    newTargetFunction.EventPosition = "All";
                                    newTargetFunction.Function = this.SendReportMonth;

                                    newTimeEvent.TargetFunction = new List<Business.TargetFunction>();
                                    newTimeEvent.TargetFunction.Add(newTargetFunction);

                                    //GET LAST DAY OF MONTH
                                    DateTime LastofMonth = Model.CommandFramework.CommandFrameworkInstance.GetLastDayOfMonth(DateTime.Now);

                                    Business.DateTimeEvent newDataTimeEvent = new Business.DateTimeEvent();
                                    newDataTimeEvent.Day = LastofMonth.Day;
                                    newDataTimeEvent.Month = LastofMonth.Month;
                                    newDataTimeEvent.DayInWeek = LastofMonth.DayOfWeek;
                                    newDataTimeEvent.Hour = int.Parse(subEndofDay[0]);
                                    newDataTimeEvent.Minute = int.Parse(subEndofDay[1]);

                                    newTimeEvent.Time = newDataTimeEvent;

                                    DateTime newDateTime = new DateTime(DateTime.Now.Year, newDataTimeEvent.Month, newDataTimeEvent.Day, newDataTimeEvent.Hour, newDataTimeEvent.Minute, 00);
                                    newTimeEvent.TimeExecution = newDateTime;

                                    TimeSpan temp = newTimeEvent.TimeExecution - DateTime.Now;
                                    if (temp.TotalSeconds < 0)
                                    {
                                        newTimeEvent.TimeExecution = newTimeEvent.TimeExecution.AddMonths(1);
                                    }

                                    newTimeEvent.IsEnable = true;

                                    Business.Market.YearEvent.Add(newTimeEvent);
                                }
                                break;
                            #endregion

                            #region FIRST DAY OF MONTH
                            case "First day of month":
                                {
                                    Business.TimeEvent newTimeEvent = new Business.TimeEvent();
                                    newTimeEvent.EventType = Business.TimeEventType.StatementsMonth;
                                    newTimeEvent.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                    Business.TargetFunction newTargetFunction = new Business.TargetFunction();
                                    newTargetFunction.EventPosition = "All";
                                    newTargetFunction.Function = this.SendReportMonth;

                                    newTimeEvent.TargetFunction = new List<Business.TargetFunction>();
                                    newTimeEvent.TargetFunction.Add(newTargetFunction);

                                    //GET LAST DAY OF MONTH
                                    DateTime FirstofMonth = Model.CommandFramework.CommandFrameworkInstance.GetFirstDayOfMonth(DateTime.Now);

                                    Business.DateTimeEvent newDataTimeEvent = new Business.DateTimeEvent();
                                    newDataTimeEvent.Day = FirstofMonth.Day;
                                    newDataTimeEvent.Month = FirstofMonth.Month;
                                    newDataTimeEvent.DayInWeek = FirstofMonth.DayOfWeek;
                                    newDataTimeEvent.Hour = 00;
                                    newDataTimeEvent.Minute = 00;

                                    newTimeEvent.Time = newDataTimeEvent;

                                    DateTime newDateTime = new DateTime(DateTime.Now.Year, newDataTimeEvent.Month, newDataTimeEvent.Day, newDataTimeEvent.Hour, newDataTimeEvent.Minute, 00);
                                    newTimeEvent.TimeExecution = newDateTime;

                                    TimeSpan temp = newTimeEvent.TimeExecution - DateTime.Now;
                                    if (temp.TotalSeconds < 0)
                                    {
                                        newTimeEvent.TimeExecution = newTimeEvent.TimeExecution.AddMonths(1);
                                    }

                                    newTimeEvent.IsEnable = true;

                                    Business.Market.YearEvent.Add(newTimeEvent);
                                }
                                break;
                            #endregion
                        }
                    }
                    #endregion

                    #region GET CONFIG HOLIDAY OF MARKET CONFIG
                    if (Market.MarketConfig[j].Code == "C27")
                    {
                        string[] subValue = Market.MarketConfig[j].StringValue.Split('~');
                        if (subValue.Length == 5)
                        {
                            bool IsEnable = false;
                            bool Every = false;
                            int Year = -1;
                            int Month = -1;
                            int Day = -1;
                            int HourStart = -1;
                            int MinuteStart = -1;
                            int HourEnd = -1;
                            int MinuteEnd = -1;

                            bool.TryParse(subValue[0], out IsEnable);
                            bool.TryParse(subValue[4], out Every);

                            #region SUB PARAMETER DAY AND TIME
                            string[] subTime = subValue[1].Split('#');
                            if (subTime.Length == 2)
                            {
                                string[] subDay = subTime[0].Split(':');
                                if (subDay.Length == 3)
                                {
                                    bool IsParse = int.TryParse(subDay[0], out Year);
                                    if (!IsParse)
                                        Year = -1;

                                    int.TryParse(subDay[1], out Month);
                                    int.TryParse(subDay[2], out Day);

                                    #region SUB PARAMETER START WORK AND END WORK
                                    string[] subTimeWork = subTime[1].Split('-');
                                    if (subTimeWork.Length == 2)
                                    {
                                        string[] subTimeWorkStart = subTimeWork[0].Split(':');
                                        string[] subTimeWorkEnd = subTimeWork[1].Split(':');
                                        if (subTimeWorkStart.Length == 2 && subTimeWorkEnd.Length == 2)
                                        {
                                            int.TryParse(subTimeWorkStart[0], out HourStart);
                                            int.TryParse(subTimeWorkStart[1], out MinuteStart);
                                            int.TryParse(subTimeWorkEnd[0], out HourEnd);
                                            int.TryParse(subTimeWorkEnd[1], out MinuteEnd);

                                            #region BUILD EVENT HOLIDAY
                                            //NO START WORLK AND END WORLK
                                            if (HourStart == 0 && MinuteStart == 0 && HourEnd == 0 && MinuteEnd == 0)
                                            {
                                                #region BUILD EVENT BEGIN HOLIDAY
                                                Business.TimeEvent newTimeEvent = new TimeEvent();
                                                newTimeEvent.EventType = TimeEventType.BeginHoliday;

                                                newTimeEvent.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                newTimeEvent.TargetFunction = new List<TargetFunction>();
                                                Business.TargetFunction newTargetFunction = new TargetFunction();
                                                newTargetFunction.EventPosition = subValue[2];
                                                newTargetFunction.Function = this.BeginHoliday;

                                                newTimeEvent.TargetFunction.Add(newTargetFunction);

                                                Business.DateTimeEvent newDateTimeEvent = new DateTimeEvent();
                                                newDateTimeEvent.Year = Year;
                                                newDateTimeEvent.Month = Month;
                                                newDateTimeEvent.Day = Day;
                                                newDateTimeEvent.Hour = 00;
                                                newDateTimeEvent.Minute = 00;

                                                newTimeEvent.Time = newDateTimeEvent;
                                                newTimeEvent.Every = Every;

                                                newTimeEvent.IsEnable = IsEnable;

                                                Business.Market.YearEvent.Add(newTimeEvent);
                                                #endregion

                                                #region EXECUTOR EVENT LATER
                                                if (newTimeEvent.IsEnable)
                                                {
                                                    if (newTimeEvent.Time.Day == DateTime.Now.Day && newTimeEvent.Time.Month == DateTime.Now.Month)
                                                    {
                                                        int tempHour = DateTime.Now.Hour - newTimeEvent.Time.Hour;
                                                        int tempMinute = DateTime.Now.Minute - newTimeEvent.Time.Minute;
                                                        int tempTotal = (tempHour * 60) + tempMinute;

                                                        if (tempTotal > 0)
                                                        {
                                                            if (newTimeEvent.TargetFunction != null)
                                                            {
                                                                int countTarget = newTimeEvent.TargetFunction.Count;
                                                                for (int m = 0; m < countTarget; m++)
                                                                {
                                                                    newTimeEvent.TargetFunction[m].Function(newTimeEvent.TargetFunction[m].EventPosition, newTimeEvent);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                #endregion

                                                #region BUILD EVENT END HOLIDAY
                                                Business.TimeEvent newTimeEventEnd = new TimeEvent();
                                                newTimeEventEnd.EventType = TimeEventType.EndHoliday;

                                                newTimeEventEnd.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                newTimeEventEnd.TargetFunction = new List<TargetFunction>();
                                                Business.TargetFunction newTargetFunctionEnd = new TargetFunction();
                                                newTargetFunctionEnd.EventPosition = subValue[2];
                                                newTargetFunctionEnd.Function = this.EndHoliday;

                                                newTimeEventEnd.TargetFunction.Add(newTargetFunctionEnd);

                                                Business.DateTimeEvent newDateTimeEventEnd = new DateTimeEvent();
                                                newDateTimeEventEnd.Year = Year;
                                                newDateTimeEventEnd.Month = Month;
                                                newDateTimeEventEnd.Day = Day;
                                                newDateTimeEventEnd.Hour = int.Parse(subEndofDay[0]);
                                                newDateTimeEventEnd.Minute = int.Parse(subEndofDay[1]);

                                                newTimeEventEnd.Time = newDateTimeEventEnd;
                                                newTimeEventEnd.Every = Every;

                                                newTimeEventEnd.IsEnable = IsEnable;

                                                Business.Market.YearEvent.Add(newTimeEventEnd);
                                                #endregion
                                            }
                                            else
                                            {
                                                //IF START WORLK = BEGIN HOLIDAY
                                                if (HourStart == 0 && MinuteStart == 0)
                                                {
                                                    #region BUILD EVENT TIME WORK START
                                                    Business.TimeEvent newTimeEventWorkStart = new TimeEvent();
                                                    newTimeEventWorkStart.EventType = TimeEventType.BeginWork;

                                                    newTimeEventWorkStart.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                    newTimeEventWorkStart.TargetFunction = new List<TargetFunction>();
                                                    Business.TargetFunction newTargetFunctionWorkStart = new TargetFunction();
                                                    newTargetFunctionWorkStart.EventPosition = subValue[2];
                                                    newTargetFunctionWorkStart.Function = this.BeginWork;

                                                    newTimeEventWorkStart.TargetFunction.Add(newTargetFunctionWorkStart);

                                                    Business.DateTimeEvent newDateTimeEventWorkStart = new DateTimeEvent();
                                                    newDateTimeEventWorkStart.Year = Year;
                                                    newDateTimeEventWorkStart.Month = Month;
                                                    newDateTimeEventWorkStart.Day = Day;
                                                    newDateTimeEventWorkStart.Hour = HourStart;
                                                    newDateTimeEventWorkStart.Minute = MinuteStart;

                                                    newTimeEventWorkStart.Time = newDateTimeEventWorkStart;
                                                    newTimeEventWorkStart.Every = Every;

                                                    newTimeEventWorkStart.IsEnable = IsEnable;

                                                    Business.Market.YearEvent.Add(newTimeEventWorkStart);
                                                    #endregion

                                                    #region EXECUTOR EVENT LATER WORK START
                                                    if (newTimeEventWorkStart.IsEnable)
                                                    {
                                                        if (newTimeEventWorkStart.Time.Day == DateTime.Now.Day && newTimeEventWorkStart.Time.Month == DateTime.Now.Month)
                                                        {
                                                            int tempHour = DateTime.Now.Hour - newTimeEventWorkStart.Time.Hour;
                                                            int tempMinute = DateTime.Now.Minute - newTimeEventWorkStart.Time.Minute;
                                                            int tempTotal = (tempHour * 60) + tempMinute;

                                                            if (tempTotal > 0)
                                                            {
                                                                if (newTimeEventWorkStart.TargetFunction != null)
                                                                {
                                                                    int countTarget = newTimeEventWorkStart.TargetFunction.Count;
                                                                    for (int m = 0; m < countTarget; m++)
                                                                    {
                                                                        newTimeEventWorkStart.TargetFunction[m].Function(newTimeEventWorkStart.TargetFunction[m].EventPosition, newTimeEventWorkStart);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    #endregion

                                                    #region BUILD EVENT TIME WORK END
                                                    Business.TimeEvent newTimeEventWorkEnd = new TimeEvent();
                                                    newTimeEventWorkEnd.EventType = TimeEventType.EndWork;

                                                    newTimeEventWorkEnd.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                    newTimeEventWorkEnd.TargetFunction = new List<TargetFunction>();
                                                    Business.TargetFunction newTargetFunctionWorkEnd = new TargetFunction();
                                                    newTargetFunctionWorkEnd.EventPosition = subValue[2];
                                                    newTargetFunctionWorkEnd.Function = this.EndWork;

                                                    newTimeEventWorkEnd.TargetFunction.Add(newTargetFunctionWorkEnd);

                                                    Business.DateTimeEvent newDateTimeEventWorkEnd = new DateTimeEvent();
                                                    newDateTimeEventWorkEnd.Year = Year;
                                                    newDateTimeEventWorkEnd.Month = Month;
                                                    newDateTimeEventWorkEnd.Day = Day;
                                                    newDateTimeEventWorkEnd.Hour = HourEnd;
                                                    newDateTimeEventWorkEnd.Minute = MinuteEnd;

                                                    newTimeEventWorkEnd.Time = newDateTimeEventWorkEnd;
                                                    newTimeEventWorkEnd.Every = Every;

                                                    newTimeEventWorkEnd.IsEnable = IsEnable;

                                                    Business.Market.YearEvent.Add(newTimeEventWorkEnd);
                                                    #endregion

                                                    #region EXECUTOR EVENT LATER WORK END
                                                    if (newTimeEventWorkEnd.IsEnable)
                                                    {
                                                        if (newTimeEventWorkEnd.Time.Day == DateTime.Now.Day && newTimeEventWorkEnd.Time.Month == DateTime.Now.Month)
                                                        {
                                                            int tempHour = DateTime.Now.Hour - newTimeEventWorkEnd.Time.Hour;
                                                            int tempMinute = DateTime.Now.Minute - newTimeEventWorkEnd.Time.Minute;
                                                            int tempTotal = (tempHour * 60) + tempMinute;

                                                            if (tempTotal > 0)
                                                            {
                                                                if (newTimeEventWorkEnd.TargetFunction != null)
                                                                {
                                                                    int countTarget = newTimeEventWorkEnd.TargetFunction.Count;
                                                                    for (int m = 0; m < countTarget; m++)
                                                                    {
                                                                        newTimeEventWorkEnd.TargetFunction[m].Function(newTimeEventWorkEnd.TargetFunction[m].EventPosition, newTimeEventWorkEnd);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    #endregion

                                                    #region BUILD EVENT END HOLIDAY
                                                    Business.TimeEvent newTimeEventEnd = new TimeEvent();
                                                    newTimeEventEnd.EventType = TimeEventType.EndHoliday;

                                                    newTimeEventEnd.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                    newTimeEventEnd.TargetFunction = new List<TargetFunction>();
                                                    Business.TargetFunction newTargetFunctionEnd = new TargetFunction();
                                                    newTargetFunctionEnd.EventPosition = subValue[2];
                                                    newTargetFunctionEnd.Function = this.EndHoliday;

                                                    newTimeEventEnd.TargetFunction.Add(newTargetFunctionEnd);

                                                    Business.DateTimeEvent newDateTimeEventEnd = new DateTimeEvent();
                                                    newDateTimeEventEnd.Year = Year;
                                                    newDateTimeEventEnd.Month = Month;
                                                    newDateTimeEventEnd.Day = Day;
                                                    newDateTimeEventEnd.Hour = int.Parse(subEndofDay[0]);
                                                    newDateTimeEventEnd.Minute = int.Parse(subEndofDay[1]);

                                                    newTimeEventEnd.Time = newDateTimeEventEnd;
                                                    newTimeEventEnd.Every = Every;

                                                    newTimeEventEnd.IsEnable = IsEnable;

                                                    Business.Market.YearEvent.Add(newTimeEventEnd);
                                                    #endregion
                                                }
                                                else
                                                {
                                                    //IF END WORLK = END HOLIDAY
                                                    if (HourEnd == 24)
                                                    {
                                                        #region BUILD EVENT BEGIN HOLIDAY
                                                        Business.TimeEvent newTimeEvent = new TimeEvent();
                                                        newTimeEvent.EventType = TimeEventType.BeginHoliday;

                                                        newTimeEvent.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                        newTimeEvent.TargetFunction = new List<TargetFunction>();
                                                        Business.TargetFunction newTargetFunction = new TargetFunction();
                                                        newTargetFunction.EventPosition = subValue[2];
                                                        newTargetFunction.Function = this.BeginHoliday;

                                                        newTimeEvent.TargetFunction.Add(newTargetFunction);

                                                        Business.DateTimeEvent newDateTimeEvent = new DateTimeEvent();
                                                        newDateTimeEvent.Year = Year;
                                                        newDateTimeEvent.Month = Month;
                                                        newDateTimeEvent.Day = Day;
                                                        newDateTimeEvent.Hour = 00;
                                                        newDateTimeEvent.Minute = 00;

                                                        newTimeEvent.Time = newDateTimeEvent;
                                                        newTimeEvent.Every = Every;

                                                        newTimeEvent.IsEnable = IsEnable;

                                                        Business.Market.YearEvent.Add(newTimeEvent);
                                                        #endregion

                                                        #region EXECUTOR EVENT LATER BEGIN HOLIDAY
                                                        if (newTimeEvent.IsEnable)
                                                        {
                                                            if (newTimeEvent.Time.Day == DateTime.Now.Day && newTimeEvent.Time.Month == DateTime.Now.Month)
                                                            {
                                                                int tempHour = DateTime.Now.Hour - newTimeEvent.Time.Hour;
                                                                int tempMinute = DateTime.Now.Minute - newTimeEvent.Time.Minute;
                                                                int tempTotal = (tempHour * 60) + tempMinute;

                                                                if (tempTotal > 0)
                                                                {
                                                                    if (newTimeEvent.TargetFunction != null)
                                                                    {
                                                                        int countTarget = newTimeEvent.TargetFunction.Count;
                                                                        for (int m = 0; m < countTarget; m++)
                                                                        {
                                                                            newTimeEvent.TargetFunction[m].Function(newTimeEvent.TargetFunction[m].EventPosition, newTimeEvent);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        #endregion

                                                        #region BUILD EVENT TIME WORK START
                                                        Business.TimeEvent newTimeEventWorkStart = new TimeEvent();
                                                        newTimeEventWorkStart.EventType = TimeEventType.BeginWork;

                                                        newTimeEventWorkStart.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                        newTimeEventWorkStart.TargetFunction = new List<TargetFunction>();
                                                        Business.TargetFunction newTargetFunctionWorkStart = new TargetFunction();
                                                        newTargetFunctionWorkStart.EventPosition = subValue[2];
                                                        newTargetFunctionWorkStart.Function = this.BeginWork;

                                                        newTimeEventWorkStart.TargetFunction.Add(newTargetFunctionWorkStart);

                                                        Business.DateTimeEvent newDateTimeEventWorkStart = new DateTimeEvent();
                                                        newDateTimeEventWorkStart.Year = Year;
                                                        newDateTimeEventWorkStart.Month = Month;
                                                        newDateTimeEventWorkStart.Day = Day;
                                                        newDateTimeEventWorkStart.Hour = HourStart;
                                                        newDateTimeEventWorkStart.Minute = MinuteStart;

                                                        newTimeEventWorkStart.Time = newDateTimeEventWorkStart;
                                                        newTimeEventWorkStart.Every = Every;

                                                        newTimeEventWorkStart.IsEnable = IsEnable;

                                                        Business.Market.YearEvent.Add(newTimeEventWorkStart);
                                                        #endregion

                                                        #region EXECUTOR EVENT LATER WORK START
                                                        if (newTimeEventWorkStart.IsEnable)
                                                        {
                                                            if (newTimeEventWorkStart.Time.Day == DateTime.Now.Day && newTimeEventWorkStart.Time.Month == DateTime.Now.Month)
                                                            {
                                                                int tempHour = DateTime.Now.Hour - newTimeEventWorkStart.Time.Hour;
                                                                int tempMinute = DateTime.Now.Minute - newTimeEventWorkStart.Time.Minute;
                                                                int tempTotal = (tempHour * 60) + tempMinute;

                                                                if (tempTotal > 0)
                                                                {
                                                                    if (newTimeEventWorkStart.TargetFunction != null)
                                                                    {
                                                                        int countTarget = newTimeEventWorkStart.TargetFunction.Count;
                                                                        for (int m = 0; m < countTarget; m++)
                                                                        {
                                                                            newTimeEventWorkStart.TargetFunction[m].Function(newTimeEventWorkStart.TargetFunction[m].EventPosition, newTimeEventWorkStart);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        #endregion

                                                        #region BUILD EVENT END HOLIDAY
                                                        Business.TimeEvent newTimeEventEnd = new TimeEvent();
                                                        newTimeEventEnd.EventType = TimeEventType.EndHoliday;

                                                        newTimeEventEnd.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                        newTimeEventEnd.TargetFunction = new List<TargetFunction>();
                                                        Business.TargetFunction newTargetFunctionEnd = new TargetFunction();
                                                        newTargetFunctionEnd.EventPosition = subValue[2];
                                                        newTargetFunctionEnd.Function = this.EndHoliday;

                                                        newTimeEventEnd.TargetFunction.Add(newTargetFunctionEnd);

                                                        Business.DateTimeEvent newDateTimeEventEnd = new DateTimeEvent();
                                                        newDateTimeEventEnd.Year = Year;
                                                        newDateTimeEventEnd.Month = Month;
                                                        newDateTimeEventEnd.Day = Day;
                                                        newDateTimeEventEnd.Hour = int.Parse(subEndofDay[0]);
                                                        newDateTimeEventEnd.Minute = int.Parse(subEndofDay[1]);

                                                        newTimeEventEnd.Time = newDateTimeEventEnd;
                                                        newTimeEventEnd.Every = Every;

                                                        newTimeEventEnd.IsEnable = IsEnable;

                                                        Business.Market.YearEvent.Add(newTimeEventEnd);
                                                        #endregion
                                                    }
                                                    else
                                                    {
                                                        //FULL HOLIDAY
                                                        #region BUILD EVENT BEGIN HOLIDAY
                                                        Business.TimeEvent newTimeEvent = new TimeEvent();
                                                        newTimeEvent.EventType = TimeEventType.BeginHoliday;

                                                        newTimeEvent.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                        newTimeEvent.TargetFunction = new List<TargetFunction>();
                                                        Business.TargetFunction newTargetFunction = new TargetFunction();
                                                        newTargetFunction.EventPosition = subValue[2];
                                                        newTargetFunction.Function = this.BeginHoliday;

                                                        newTimeEvent.TargetFunction.Add(newTargetFunction);

                                                        Business.DateTimeEvent newDateTimeEvent = new DateTimeEvent();
                                                        newDateTimeEvent.Year = Year;
                                                        newDateTimeEvent.Month = Month;
                                                        newDateTimeEvent.Day = Day;
                                                        newDateTimeEvent.Hour = 00;
                                                        newDateTimeEvent.Minute = 00;

                                                        newTimeEvent.Time = newDateTimeEvent;
                                                        newTimeEvent.Every = Every;

                                                        newTimeEvent.IsEnable = IsEnable;

                                                        Business.Market.YearEvent.Add(newTimeEvent);
                                                        #endregion

                                                        #region EXECUTOR EVENT LATER BEGIN HOLIDAY
                                                        if (newTimeEvent.IsEnable)
                                                        {
                                                            if (newTimeEvent.Time.Day == DateTime.Now.Day && newTimeEvent.Time.Month == DateTime.Now.Month)
                                                            {
                                                                int tempHour = DateTime.Now.Hour - newTimeEvent.Time.Hour;
                                                                int tempMinute = DateTime.Now.Minute - newTimeEvent.Time.Minute;
                                                                int tempTotal = (tempHour * 60) + tempMinute;

                                                                if (tempTotal > 0)
                                                                {
                                                                    if (newTimeEvent.TargetFunction != null)
                                                                    {
                                                                        int countTarget = newTimeEvent.TargetFunction.Count;
                                                                        for (int m = 0; m < countTarget; m++)
                                                                        {
                                                                            newTimeEvent.TargetFunction[m].Function(newTimeEvent.TargetFunction[m].EventPosition, newTimeEvent);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        #endregion

                                                        if (HourStart != HourEnd || MinuteStart != MinuteEnd)
                                                        {
                                                            #region BUILD EVENT TIME WORK START
                                                            Business.TimeEvent newTimeEventWorkStart = new TimeEvent();
                                                            newTimeEventWorkStart.EventType = TimeEventType.BeginWork;

                                                            newTimeEventWorkStart.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                            newTimeEventWorkStart.TargetFunction = new List<TargetFunction>();
                                                            Business.TargetFunction newTargetFunctionWorkStart = new TargetFunction();
                                                            newTargetFunctionWorkStart.EventPosition = subValue[2];
                                                            newTargetFunctionWorkStart.Function = this.BeginWork;

                                                            newTimeEventWorkStart.TargetFunction.Add(newTargetFunctionWorkStart);

                                                            Business.DateTimeEvent newDateTimeEventWorkStart = new DateTimeEvent();
                                                            newDateTimeEventWorkStart.Year = Year;
                                                            newDateTimeEventWorkStart.Month = Month;
                                                            newDateTimeEventWorkStart.Day = Day;
                                                            newDateTimeEventWorkStart.Hour = HourStart;
                                                            newDateTimeEventWorkStart.Minute = MinuteStart;

                                                            newTimeEventWorkStart.Time = newDateTimeEventWorkStart;
                                                            newTimeEventWorkStart.Every = Every;

                                                            newTimeEventWorkStart.IsEnable = IsEnable;

                                                            Business.Market.YearEvent.Add(newTimeEventWorkStart);
                                                            #endregion

                                                            #region EXECUTOR EVENT LATER WORK START
                                                            if (newTimeEventWorkStart.IsEnable)
                                                            {
                                                                if (newTimeEventWorkStart.Time.Day == DateTime.Now.Day && newTimeEventWorkStart.Time.Month == DateTime.Now.Month)
                                                                {
                                                                    int tempHour = DateTime.Now.Hour - newTimeEventWorkStart.Time.Hour;
                                                                    int tempMinute = DateTime.Now.Minute - newTimeEventWorkStart.Time.Minute;
                                                                    int tempTotal = (tempHour * 60) + tempMinute;

                                                                    if (tempTotal > 0)
                                                                    {
                                                                        if (newTimeEventWorkStart.TargetFunction != null)
                                                                        {
                                                                            int countTarget = newTimeEventWorkStart.TargetFunction.Count;
                                                                            for (int m = 0; m < countTarget; m++)
                                                                            {
                                                                                newTimeEventWorkStart.TargetFunction[m].Function(newTimeEventWorkStart.TargetFunction[m].EventPosition, newTimeEventWorkStart);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            #endregion

                                                            #region BUILD EVENT TIME WORK END
                                                            Business.TimeEvent newTimeEventWorkEnd = new TimeEvent();
                                                            newTimeEventWorkEnd.EventType = TimeEventType.EndWork;

                                                            newTimeEventWorkEnd.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                            newTimeEventWorkEnd.TargetFunction = new List<TargetFunction>();
                                                            Business.TargetFunction newTargetFunctionWorkEnd = new TargetFunction();
                                                            newTargetFunctionWorkEnd.EventPosition = subValue[2];
                                                            newTargetFunctionWorkEnd.Function = this.EndWork;

                                                            newTimeEventWorkEnd.TargetFunction.Add(newTargetFunctionWorkEnd);

                                                            Business.DateTimeEvent newDateTimeEventWorkEnd = new DateTimeEvent();
                                                            newDateTimeEventWorkEnd.Year = Year;
                                                            newDateTimeEventWorkEnd.Month = Month;
                                                            newDateTimeEventWorkEnd.Day = Day;
                                                            newDateTimeEventWorkEnd.Hour = HourEnd;
                                                            newDateTimeEventWorkEnd.Minute = MinuteEnd;

                                                            newTimeEventWorkEnd.Time = newDateTimeEventWorkEnd;
                                                            newTimeEventWorkEnd.Every = Every;

                                                            newTimeEventWorkEnd.IsEnable = IsEnable;

                                                            Business.Market.YearEvent.Add(newTimeEventWorkEnd);
                                                            #endregion

                                                            #region EXECUTOR EVENT LATER WORK START
                                                            if (newTimeEventWorkEnd.IsEnable)
                                                            {
                                                                if (newTimeEventWorkEnd.Time.Day == DateTime.Now.Day && newTimeEventWorkEnd.Time.Month == DateTime.Now.Month)
                                                                {
                                                                    int tempHour = DateTime.Now.Hour - newTimeEventWorkEnd.Time.Hour;
                                                                    int tempMinute = DateTime.Now.Minute - newTimeEventWorkEnd.Time.Minute;
                                                                    int tempTotal = (tempHour * 60) + tempMinute;

                                                                    if (tempTotal > 0)
                                                                    {
                                                                        if (newTimeEventWorkEnd.TargetFunction != null)
                                                                        {
                                                                            int countTarget = newTimeEventWorkEnd.TargetFunction.Count;
                                                                            for (int m = 0; m < countTarget; m++)
                                                                            {
                                                                                newTimeEventWorkEnd.TargetFunction[m].Function(newTimeEventWorkEnd.TargetFunction[m].EventPosition, newTimeEventWorkEnd);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            #endregion
                                                        }

                                                        #region BUILD EVENT END HOLIDAY
                                                        Business.TimeEvent newTimeEventEnd = new TimeEvent();
                                                        newTimeEventEnd.EventType = TimeEventType.EndHoliday;

                                                        newTimeEventEnd.TimeEventID = Market.MarketConfig[j].ParameterItemID;

                                                        newTimeEventEnd.TargetFunction = new List<TargetFunction>();
                                                        Business.TargetFunction newTargetFunctionEnd = new TargetFunction();
                                                        newTargetFunctionEnd.EventPosition = subValue[2];
                                                        newTargetFunctionEnd.Function = this.EndHoliday;

                                                        newTimeEventEnd.TargetFunction.Add(newTargetFunctionEnd);

                                                        Business.DateTimeEvent newDateTimeEventEnd = new DateTimeEvent();
                                                        newDateTimeEventEnd.Year = Year;
                                                        newDateTimeEventEnd.Month = Month;
                                                        newDateTimeEventEnd.Day = Day;
                                                        newDateTimeEventEnd.Hour = int.Parse(subEndofDay[0]);
                                                        newDateTimeEventEnd.Minute = int.Parse(subEndofDay[1]);

                                                        newTimeEventEnd.Time = newDateTimeEventEnd;
                                                        newTimeEventEnd.Every = Every;

                                                        newTimeEventEnd.IsEnable = IsEnable;

                                                        Business.Market.YearEvent.Add(newTimeEventEnd);
                                                        #endregion
                                                    }
                                                }
                                            }
                                            #endregion
                                        }
                                    }
                                    #endregion
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region GET DEFAULT GROUP BROKER
                    if (Business.Market.MarketConfig[j].Code == "C34")
                    {
                        string[] subValue = Business.Market.MarketConfig[j].StringValue.Split('`');
                        if (subValue.Length == 2)
                        {
                            Business.GroupDefault newGroupDefault = new GroupDefault();
                            newGroupDefault.GroupDefaultID = Business.Market.MarketConfig[j].ParameterItemID;
                            newGroupDefault.DomainName = subValue[0];
                            newGroupDefault.GroupDefaultName = subValue[1];

                            Business.Market.ListGroupDefault.Add(newGroupDefault);
                        }
                    }
                    #endregion

                    #region GET CONFIG TIME MARKET OF MARKET CONFIG
                    if (Market.MarketConfig[j].Code == "C28")
                    {
                        List<Business.TimeEvent> ResultTimeEvent = new List<TimeEvent>();
                        ResultTimeEvent = this.ExtractTimeEvent(Market.MarketConfig[j].StringValue, "Market", Market.MarketConfig[j].Code, Market.MarketConfig[j].ParameterItemID);
                        if (ResultTimeEvent != null && ResultTimeEvent.Count > 0)
                        {
                            int countTimeEvent = ResultTimeEvent.Count;
                            for (int n = 0; n < countTimeEvent; n++)
                            {
                                #region Execute Events Later In Week
                                if (ResultTimeEvent[n].Time.DayInWeek == DateTime.Now.DayOfWeek)
                                {
                                    int Hour = ResultTimeEvent[n].Time.Hour - DateTime.Now.Hour;
                                    int Minute = ResultTimeEvent[n].Time.Minute - DateTime.Now.Minute;

                                    int temp = (Hour * 60) + Minute;
                                    if (temp < 0)
                                    {
                                        if (ResultTimeEvent[n].TargetFunction != null)
                                        {
                                            int countTargetFunction = ResultTimeEvent[n].TargetFunction.Count;
                                            for (int k = 0; k < countTargetFunction; k++)
                                            {
                                                ResultTimeEvent[n].TargetFunction[k].Function(ResultTimeEvent[n].TargetFunction[k].EventPosition, ResultTimeEvent[n]);
                                            }
                                        }
                                    }
                                }
                                #endregion

                                Business.Market.WeekEvent.Add(ResultTimeEvent[n]);
                            }
                        }
                    }
                    #endregion

                    #region GET CONFIG MULTIPLE QUOTES
                    if (Business.Market.MarketConfig[j].Code == "C30")
                        Business.PriceServer.Instance.ConfigMultipleQuotes(Business.Market.MarketConfig[j].StringValue);
                    #endregion

                    #region GET CONFIG TIME MULTIPLE QUOTES
                    if (Business.Market.MarketConfig[j].Code == "C31")
                        Business.PriceServer.Instance.UpdateTimeCheckMultipleQuotes(Business.Market.MarketConfig[j].NumValue);
                    #endregion
                }
            }

            if (Business.Market.DayEvent != null && Business.Market.DayEvent.Count > 0)
                this.ProcessSortTimeEventDay();

            if (Business.Market.YearEvent != null && Business.Market.YearEvent.Count > 0)
                this.ProcessSortTimeEventYear();

            if (Business.Market.WeekEvent != null && Business.Market.WeekEvent.Count > 0)
                this.ProcessSortTimeEventWeek();
        }