示例#1
0
        public void SetStateValue(string stateName, string state, string stateValue, int quantity = 0)
        {
            var sv = TicketStateValues.SingleOrDefault(x => x.StateName == stateName);

            if (sv == null)
            {
                sv = new TicketStateValue {
                    StateName = stateName, State = state, StateValue = stateValue, Quantity = quantity
                };
                TicketStateValues.Add(sv);
            }
            else
            {
                sv.State      = state;
                sv.StateValue = stateValue;
                sv.Quantity   = quantity;
            }
            sv.LastUpdateTime = DateTime.Now;

            if (string.IsNullOrEmpty(sv.State))
            {
                TicketStateValues.Remove(sv);
            }

            TicketStates       = JsonHelper.Serialize(TicketStateValues);
            _ticketStateValues = null;
        }
示例#2
0
 public bool IsInState(string stateName, string state)
 {
     if (stateName == "*")
     {
         return(TicketStateValues.Any(x => x.State == state));
     }
     if (string.IsNullOrEmpty(state))
     {
         return(TicketStateValues.All(x => x.StateName != stateName));
     }
     return(TicketStateValues.Any(x => x.StateName == stateName && x.State == state));
 }
示例#3
0
 public string GetStateData()
 {
     return(string.Join("\r", TicketStateValues.Where(x => !string.IsNullOrEmpty(x.State)).Select(x => string.Format("{0}{1}: {2} {3}", x.Quantity > 0 ? string.Format("{0} ", x.Quantity.ToString(CultureInfo.CurrentCulture)) : "", x.StateName, x.State, !string.IsNullOrEmpty(x.StateValue) ? string.Format("[{0}]", x.StateValue) : ""))));
 }
示例#4
0
 public TicketStateValue GetStateValue(string groupName)
 {
     return(TicketStateValues.SingleOrDefault(x => x.StateName == groupName) ?? TicketStateValue.Default);
 }