/// <summary>
        /// ADD NEW MARKET CONFIG
        /// </summary>
        /// <param name="CollectionValue"></param>
        /// <param name="Name"></param>
        /// <param name="Code"></param>
        /// <param name="BoolValue"></param>
        /// <param name="StringValue"></param>
        /// <param name="NumValue"></param>
        /// <param name="DateValue"></param>
        /// <returns></returns>
        internal int AddNewMarketConfig(int CollectionValue, string Name, string Code, int BoolValue,
                                            string StringValue, string NumValue, DateTime DateValue)
        {
            int Result = -1;

            Business.ParameterItem newParameter = new ParameterItem();
            newParameter.BoolValue = BoolValue;
            newParameter.Code = Code;
            newParameter.CollectionValue = new List<ParameterItem>();
            newParameter.DateValue = DateValue;
            newParameter.Name = Name;
            newParameter.NumValue = NumValue;
            newParameter.StringValue = StringValue;

            Result = ParameterItem.DBWMarketConfig.AddNewMarketConfig(CollectionValue, Name, Code, BoolValue, StringValue, NumValue, DateValue);

            newParameter.ParameterItemID = Result;

            if (Result > 0)
            {
                if (Business.Market.MarketConfig != null)
                {
                    Business.Market.MarketConfig.Add(newParameter);
                }
                else
                {
                    Business.Market.MarketConfig = new List<ParameterItem>();
                    Business.Market.MarketConfig.Add(newParameter);
                }

                if (Code == "C34")
                {
                    string[] subValue = StringValue.Split('`');
                    if (subValue.Length == 2)
                    {
                        Business.GroupDefault newGroupDefault = new GroupDefault();
                        newGroupDefault.DomainName = subValue[0];
                        newGroupDefault.GroupDefaultName = subValue[1];
                        newGroupDefault.GroupDefaultID = Result;

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

                    return Result;
                }
            }

            Business.Market.marketInstance.InitTimeEventInSymbol();

            Business.Market.marketInstance.InitTimeEventServer();

            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();
        }