예제 #1
0
        protected string ReplaceMatch(string inputString, Match match, IDictionary <string, string> lookups = null)
        {
            var lookupsCopy = (lookups == null)
                ? new Dictionary <string, string>()
                : new Dictionary <string, string>(lookups);

            var state = new ReplacementState
            {
                InputString = inputString,
                Regex       = Regex,
                Match       = match,
                Lookups     = lookupsCopy
            };

            IEnumerable <string> replacedBits = Placeholders.Select(p => p.Replace(state));

            return(string.Concat(replacedBits));
        }
예제 #2
0
 public string Replace(ReplacementState state)
 {
     return(state.InputString.Substring(0, state.Match.Index));
 }
예제 #3
0
 public string Replace(ReplacementState state)
 {
     return(state.Lookups[LookupKey]);
 }
 public string Replace(ReplacementState state)
 {
     return(ConstantString);
 }
예제 #5
0
 public string Replace(ReplacementState state)
 {
     return(state.InputString.Substring(state.Match.Index + state.Match.Length));
 }
예제 #6
0
 public string Replace(ReplacementState state)
 {
     return(state.Match.Value);
 }
예제 #7
0
        public string[] UpdateExceptionShift_ExceptionShiftsPage(string operationState, string ShiftID, string FirstPersonnelID, string SecondPersonnelID, string FirstWorkGroupID, string SecondWorkGroupID, string FirstDate, string SecondDate, string replacementState, string shiftViewState)
        {
            this.InitializeCulture();

            string[] retMessage = new string[4];

            try
            {
                OperationState OS                = (OperationState)Enum.Parse(typeof(OperationState), this.StringBuilder.CreateString(operationState));
                decimal        shiftID           = decimal.Parse(this.StringBuilder.CreateString(ShiftID));
                decimal        firstPersonnelID  = decimal.Parse(this.StringBuilder.CreateString(FirstPersonnelID));
                decimal        secondPersonnelID = decimal.Parse(this.StringBuilder.CreateString(SecondPersonnelID));
                decimal        firstWorkGroupID  = decimal.Parse(this.StringBuilder.CreateString(FirstWorkGroupID));
                decimal        secondWorkGroupID = decimal.Parse(this.StringBuilder.CreateString(SecondWorkGroupID));
                FirstDate  = this.StringBuilder.CreateString(FirstDate);
                SecondDate = this.StringBuilder.CreateString(SecondDate);
                ReplacementState RS    = (ReplacementState)Enum.Parse(typeof(ReplacementState), this.StringBuilder.CreateString(replacementState));
                ShiftViewState   SVS   = (ShiftViewState)Enum.Parse(typeof(ShiftViewState), this.StringBuilder.CreateString(shiftViewState));
                string           shift = string.Empty;
                string           SuccessMessageBody = string.Empty;

                switch (OS)
                {
                case OperationState.Add:
                    this.ExceptionShiftsBusiness.InsertExceptionShift(firstPersonnelID, shiftID, FirstDate, SecondDate);
                    SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString();
                    break;

                case OperationState.Edit:
                    this.ExceptionShiftsBusiness.UpdateExceptionShift(firstPersonnelID, shiftID, FirstDate, SecondDate);
                    SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString();
                    break;

                case OperationState.TwoDayReplacement:
                    switch (SVS)
                    {
                    case ShiftViewState.NotView:
                        switch (RS)
                        {
                        case ReplacementState.NotReplacement:
                            break;

                        case ReplacementState.Personnel:
                            this.ExceptionShiftsBusiness.ExchangeDayByPerson(firstPersonnelID, FirstDate, SecondDate);
                            break;

                        case ReplacementState.WorkGroup:
                            this.ExceptionShiftsBusiness.ExchangeDayByWorkGroup(firstWorkGroupID, FirstDate, SecondDate);
                            break;
                        }
                        SuccessMessageBody = GetLocalResourceObject("TwoDayReplacementComplete").ToString();
                        break;

                    case ShiftViewState.First:
                        switch (RS)
                        {
                        case ReplacementState.NotReplacement:
                            break;

                        case ReplacementState.Personnel:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByPersonId(firstPersonnelID, FirstDate);
                            break;

                        case ReplacementState.WorkGroup:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByWorkGroup(firstWorkGroupID, FirstDate);
                            break;
                        }
                        break;

                    case ShiftViewState.Second:
                        switch (RS)
                        {
                        case ReplacementState.NotReplacement:
                            break;

                        case ReplacementState.Personnel:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByPersonId(firstPersonnelID, SecondDate);
                            break;

                        case ReplacementState.WorkGroup:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByWorkGroup(firstWorkGroupID, SecondDate);
                            break;
                        }
                        break;
                    }
                    break;

                case OperationState.TwoPersonnelReplacement:
                    switch (SVS)
                    {
                    case ShiftViewState.NotView:
                        switch (RS)
                        {
                        case ReplacementState.NotReplacement:
                            break;

                        case ReplacementState.Personnel:
                            this.ExceptionShiftsBusiness.ExchangePerson(firstPersonnelID, secondPersonnelID, FirstDate, SecondDate);
                            break;

                        case ReplacementState.WorkGroup:
                            this.ExceptionShiftsBusiness.ExchangeWorkGroup(firstWorkGroupID, secondWorkGroupID, FirstDate, SecondDate);
                            break;
                        }
                        SuccessMessageBody = GetLocalResourceObject("TwoPersonnelReplacementComplete").ToString();
                        break;

                    case ShiftViewState.First:
                        switch (RS)
                        {
                        case ReplacementState.NotReplacement:
                            break;

                        case ReplacementState.Personnel:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByPersonId(firstPersonnelID, FirstDate);
                            break;

                        case ReplacementState.WorkGroup:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByWorkGroup(firstWorkGroupID, FirstDate);
                            break;
                        }
                        break;

                    case ShiftViewState.Second:
                        switch (RS)
                        {
                        case ReplacementState.NotReplacement:
                            break;

                        case ReplacementState.Personnel:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByPersonId(secondPersonnelID, SecondDate);
                            break;

                        case ReplacementState.WorkGroup:
                            shift = this.ExceptionShiftsBusiness.GetDayShiftByWorkGroup(secondWorkGroupID, SecondDate);
                            break;
                        }
                        break;
                    }
                    break;
                }
                retMessage[1] = SuccessMessageBody;
                retMessage[2] = "success";
                if (SVS != ShiftViewState.NotView)
                {
                    retMessage[3] = shift != string.Empty ? shift : GetLocalResourceObject("NoShift").ToString();
                }
                return(retMessage);
            }
            catch (UIValidationExceptions ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
                return(retMessage);
            }
            catch (UIBaseException ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
                return(retMessage);
            }
            catch (Exception ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
                return(retMessage);
            }
        }
예제 #8
0
 public string Replace(ReplacementState state)
 {
     return(state.InputString);
 }
예제 #9
0
 public string Replace(ReplacementState state)
 {
     return(state.Match.Groups[state.Match.Groups.Count - 1].Value);
 }