示例#1
0
        public Grammar()
        {
            Options     = RuntimeOptions.Default;

            Productions = new ProductionCollection(this);
            Symbols     = new SymbolCollection(this);
            Conditions  = new ConditionCollection(this);
            Matchers    = new MatcherCollection(this);
            Mergers     = new MergerCollection(this);
            Contexts    = new ForeignContextCollection(this);
            Reports     = new ReportCollection();
            GlobalContextProvider = new ForeignContextProvider { Owner = this.Contexts };
            Joint       = new Joint();

            for (int i = PredefinedTokens.Count; i != 0; --i)
            {
                Symbols.Add(null); // stub
            }

            Symbols[PredefinedTokens.Propagated]      = new Symbol("#");
            Symbols[PredefinedTokens.Epsilon]         = new Symbol("$eps");
            Symbols[PredefinedTokens.AugmentedStart]  = new Symbol("$start");
            Symbols[PredefinedTokens.Eoi]             = new Symbol("$")
                                          {
                                              Categories = SymbolCategory.DoNotInsert
                                                         | SymbolCategory.DoNotDelete
                                          };
            Symbols[PredefinedTokens.Error]           = new Symbol("$error");

            AugmentedProduction = Productions.Define((Symbol)Symbols[PredefinedTokens.AugmentedStart], new Symbol[] { null });
        }
示例#2
0
		/// <summary>
		/// This constructor is used when we have just the name
		/// </summary>
		public TracePolicy(string name)
		{
			if (name == null)
			{
				System.Diagnostics.Trace.WriteLine( Properties.Resources.TRACE_NULL, "TracePolicy Constructor 1" );
				throw ( new ArgumentNullException( "name", Properties.Resources.TRACE_NULL ) );
			}
			m_name = name;
			m_conditons = new ConditionCollection();
		}
示例#3
0
		/// <summary>
		/// This constructor is used when we have just the name
		/// </summary>
		public TracePolicy(Guid messageId, string name, bool isViolated)
		{
			if (name == null)
			{
				System.Diagnostics.Trace.WriteLine( Properties.Resources.TRACE_NULL, "TracePolicy Constructor 2" );
				throw ( new ArgumentNullException( "name", Properties.Resources.TRACE_NULL ) );
			}
            m_msgId = messageId;
			m_name = name;
			m_isViolated = isViolated;
			m_conditons = new ConditionCollection();
		}
        public FieldValidate(XmlElement fieldDescription, FieldValidatorCollection validators, ConditionCollection conditions)
        {
            Validators = validators;
            Conditions = conditions;
            Fields = new Dictionary<string, FieldDescription>();

            foreach (XmlElement n in fieldDescription.SelectNodes("Field"))
            {
                FieldDescription fd = new FieldDescription(n);
                Fields.Add(fd.Name, fd);
            }
        }
示例#5
0
 public MatcherCode(
     EmitSyntax           emit, 
     IContextCode         contextCode,
     Pipe<EmitSyntax>     ldCursor,
     Ref<Types>           declaringType,
     ConditionCollection  conditions,
     Ref<Labels>          RETURN)
 {
     this.emit            = emit;
     this.ldCursor        = ldCursor;
     this.contextCode     = contextCode;
     this.declaringType   = declaringType;
     this.conditions      = conditions;
     this.RETURN          = RETURN;
 }
 public RowValidate(XmlElement rowDescription, RowValidatorCollection RVList, ConditionCollection CondList)
 {
     Validators = RVList;
     Conditions = CondList;
     Statements = new ValidateStatements(rowDescription);
 }
		public virtual ConditionCollection ToConditions()
		{
			ConditionCollection conditions = null;
			var descriptor = _cache.GetOrAdd(this.GetType(), type => new ConditionalDescriptor(type));

			foreach(var property in descriptor.Properties)
			{
				var condition = this.GenerateCondition(property);

				if(condition != null)
				{
					if(conditions == null)
						conditions = new ConditionCollection(this.ConditionCombination);

					conditions.Add(condition);
				}
			}

			return conditions;
		}
示例#8
0
 public void SetCurrent(ConditionCollection conditions)
 {
     _conditions = conditions;
 }
示例#9
0
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            SdMenuCommand       newItem             = null;
            StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));

            object o = null;

            if (Class != null)
            {
                o = AddIn.CreateObject(Class);                //说明当前菜单项是没有子菜单项�?即它有自己的功能,其功能由Class类具体实�?这种菜单项也是最常见�?
            }
            if (o != null)
            {
                if (o is ISubmenuBuilder)
                {
                    return(((ISubmenuBuilder)o).BuildSubmenu(owner));
                }

                if (o is IMenuCommand)
                {
                    newItem = new SdMenuCommand(stringParserService.Parse(Label), new EventHandler(new MenuEventHandler(owner, (IMenuCommand)o).Execute));
                    if (beginGroup == "true")
                    {
                        newItem.BeginGroup = true;
                    }
                }
            }

            if (newItem == null)
            {            //说明当前菜单项既不是Link类型�?也没有指出其Class属�?所以有可能是一个包含子菜单的菜单项.
                newItem = new SdMenuCommand(stringParserService.Parse(Label));
                if (subItems != null && subItems.Count > 0)
                {                //判断是否有子菜单�?
                    foreach (object item in subItems)
                    {
                        if (item is ButtonItem)
                        {                        //添加一个子菜单�?
                            newItem.SubItems.Add((ButtonItem)item);
                        }
                        else
                        {                        //添加一组子菜单�?
                            newItem.SubItems.AddRange((ButtonItem[])item);
                        }
                    }
                }
            }

            Debug.Assert(newItem != null);            //到这里为�?newItem即当前菜单项不应该为空了.

            if (Icon != null)
            {            //为菜单设置Icon.
                ResourceService ResourceService = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService));
                newItem.Image = ResourceService.GetBitmap(Icon);
            }
            newItem.Description = description;

            newItem.MouseEnter += new EventHandler(newItem_MouseEnter);
            newItem.MouseLeave += new EventHandler(newItem_MouseLeave);

            if (Shortcut != null)
            {            //为菜单设置Shortcut.
                try
                {
                    newItem.Shortcuts.Add((eShortcut)Enum.Parse(eShortcut.F1.GetType(), Shortcut));
                }
                catch (Exception)
                {
                }
            }

            return(newItem);           //最后返回当前菜单项.
        }
示例#10
0
 public static Product[] Search(ConditionCollection conditions, SortingCollection sorting)
 {
     return(Search(conditions, sorting, false));
 }
示例#11
0
 public ColumnBackgroundCondition()
 {
     Conditions = new ConditionCollection();
 }
示例#12
0
 private void InitializeCollections()
 {
     Conditions = new ConditionCollection();
 }
示例#13
0
 public TriggerAction(string name)
 {
     Conditions = new ConditionCollection();
     this.Name  = name;
     InitializeCollections();
 }
示例#14
0
        /// <summary>
        /// 检查版本信息
        /// </summary>
        /// <param name="verModel">版本信息参数</param>
        /// <returns>版本信息结果</returns>
        public object CheckVersion(VerViewModel verModel)
        {
            //校验设备表示
            bool isExist = SingleInstance <PrinterService> .Instance.CheckEquipmentIsExists(verModel.Mac);

            if (!isExist)
            {
                LogUtil.Info($"设备不存在-{JsonUtil.Serialize(verModel)}");
                throw new MessageException("设备不存在!");
            }

            //更改设备对应版本号
            bool result = SingleInstance <PrinterService> .Instance.UpdatePrintVersion(verModel);

            if (!result)
            {
                throw new MessageException($"更新打印机{verModel.Mac}版本号失败,请重试");
            }

            //获取版本
            Dictionary <string, object> verDic = new Dictionary <string, object>();
            ConditionCollection         cc     = new ConditionCollection();

            cc.Add(new Condition("objec_type", TryConvertUtil.ToString(verModel.Type)));
            cc.Add(new Condition("status_code", StatusCodeType.Valid.GetHashCode()));

            int isNeed = 0;

            string newVer   = string.Empty;
            string filePath = string.Empty;
            var    lastVer  = this.GetRepository <McpSysVersionInfo>().GetModel(cc);

            if (lastVer != null)
            {
                var isUpdate  = false;
                var serVer    = 0;
                var curVer    = 0;
                var serVers   = lastVer.ObjectVersion.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                var curVers   = verModel.Ver.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                var maxLength = Math.Max(serVers.Length, curVers.Length);

                for (var i = 0; i < maxLength; i++)
                {
                    serVer = i < serVers.Length ? TryConvertUtil.ToInt(serVers[i]) : 0;
                    curVer = i < curVers.Length ? TryConvertUtil.ToInt(curVers[i]) : 0;
                    if (serVer != curVer)
                    {
                        isUpdate = serVer > curVer;
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }

                if (isUpdate)
                {
                    isNeed   = lastVer.IsForce > 0 ? 2 : 1;
                    newVer   = lastVer.ObjectVersion;
                    filePath = lastVer.VersionFile;
                }
            }

            verDic.Add("IsNeedUpdate", isNeed);
            verDic.Add("NewVer", newVer);
            verDic.Add("UpdateFilePath", filePath);

            LogUtil.Info(string.Format("设备:{0},当前版本:{1},获取新版本...", verModel.Mac, verModel.Ver));

            return(verDic);
        }
        /// <summary>
        /// 新增应用
        /// </summary>
        /// <param name="model">视图数据模型</param>
        public ProcessResult AddApplyInfo(DevApplyViewModel model)
        {
            var result = new ProcessResult();
            var url    = "";

            // 数据校验
            result = CheckApplyData(model);
            if (model.LogoFile != null)
            {
                result = LogFileUpload(model.LogoFile);
                if (result.Result)
                {
                    url = result.Data;
                }
                else
                {
                    return(result);
                }
            }

            if (result.Result)
            {
                // 判断应用Id是否为空
                if (!string.IsNullOrEmpty(model.AppId))
                {
                    var cc = new ConditionCollection()
                    {
                        new Condition("app_id", model.AppId)
                    };

                    var dataMode = GetRepository <McpApplicationInfo>().GetModel(cc);

                    dataMode.AppName           = model.AppName;
                    dataMode.SignKey           = model.SignKey;
                    dataMode.UpdateCallbackUrl = model.UpdateCallbackUrl;
                    dataMode.ModifiedBy        = model.ModifiedBy;
                    dataMode.ModifiedOn        = CommonUtil.GetDBDateTime();
                    dataMode.DeveloperId       = model.DeveloperId;
                    dataMode.Memo = model.Memo;
                    if (string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(model.LogoPath))
                    {
                        dataMode.LogoPath = model.LogoPath;
                    }
                    else
                    {
                        dataMode.LogoPath = url;
                    }


                    var count = this.GetRepository <McpApplicationInfo>().Update(dataMode);

                    if (count <= 0)
                    {
                        result.Result = false;
                        result.Msg    = "修改应用失败,请与管理员联系";
                        return(result);
                    }
                    result.Msg = "修改应用成功";
                }
                else
                {
                    var cc = new ConditionCollection()
                    {
                        new Condition("app_name", model.AppName)
                    };

                    if (GetRepository <McpApplicationInfo>().IsExists(cc))
                    {
                        result.Result = false;
                        result.Msg    = "应用名称已经在系统中存在,请更换应用名称";
                        return(result);
                    }

                    var dataMode = new McpApplicationInfo()
                    {
                        AppId             = CommonUtil.GetGuidNoSeparator(),
                        AppKey            = VerifyCodeUtil.Intance.GenCode(16).ToLower(),
                        AppName           = model.AppName,
                        SignKey           = model.SignKey,
                        UpdateCallbackUrl = model.UpdateCallbackUrl,
                        LogoPath          = url,
                        CreatedBy         = model.ModifiedBy,
                        CreatedOn         = CommonUtil.GetDBDateTime(),
                        DeveloperId       = model.DeveloperId,
                        Memo       = model.Memo,
                        StatusCode = Convert.ToInt32(ApplyStatuCode.Operative)
                    };

                    var appId = this.GetRepository <McpApplicationInfo>().Create(dataMode);
                    if (string.IsNullOrEmpty(appId.ToString()))
                    {
                        result.Result = false;
                        result.Msg    = "新增应用失败,请与管理员联系";
                        return(result);
                    }
                    result.Msg = "新增应用成功";
                }
                result.Result = true;
                return(result);
            }
            return(result);
        }
示例#16
0
 public static Category[] Search(ConditionCollection conditions, SortingCollection sorting, bool distinct)
 {
     return(Search(conditions, sorting, distinct, 0));
 }
示例#17
0
		private void EnsureConflict(User user, string scope, bool isUpdate)
		{
			var ns = MembershipHelper.GetNamespaceCondition(user.Namespace);
			var conditions = new ConditionCollection(ConditionCombination.Or);

			if(!string.IsNullOrWhiteSpace(user.Name) && MembershipHelper.InScope<User>(scope, "Name"))
				conditions.Add(ns & Condition.Equal("Name", user.Name));
			if(!string.IsNullOrWhiteSpace(user.Email) && MembershipHelper.InScope<User>(scope, "Email"))
				conditions.Add(ns & Condition.Equal("Email", user.Email));
			if(!string.IsNullOrWhiteSpace(user.PhoneNumber) && MembershipHelper.InScope<User>(scope, "PhoneNumber"))
				conditions.Add(ns & Condition.Equal("PhoneNumber", user.PhoneNumber));

			if(isUpdate && conditions.Count > 0)
				conditions = Condition.NotEqual("UserId", user.UserId) & conditions;

			if(conditions.Count > 0 && this.DataAccess.Exists(MembershipHelper.DATA_ENTITY_USER, conditions))
				throw new DataConflictException(Zongsoft.Resources.ResourceUtility.GetString("Text.UserConflict"));
		}
示例#18
0
 public static Department[] Search(ConditionCollection conditions, SortingCollection sorting, bool distinct)
 {
     return(Search(conditions, sorting, distinct, 0));
 }
示例#19
0
 public static Category[] Search(ConditionCollection conditions, SortingCollection sorting)
 {
     return(Search(conditions, sorting, false));
 }
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            Debug.Assert(Class != null && Class.Length > 0);

            return((IViewType)AddIn.CreateObject(Class));
        }
示例#21
0
        protected virtual IEnumerable <AuthorizationToken> GetAuthorizedTokens(string @namespace, uint memberId, MemberType memberType)
        {
            var conditions = Condition.Equal("MemberId", memberId) & Condition.Equal("MemberType", memberType);

            //获取指定成员的所有上级角色集和上级角色的层级列表
            if (MembershipHelper.GetAncestors(this.DataAccess, @namespace, memberId, memberType, out var flats, out var hierarchies) > 0)
            {
                //如果指定成员有上级角色,则进行权限定义的查询条件还需要加上所有上级角色
                conditions = ConditionCollection.Or(
                    conditions,
                    Condition.In("MemberId", flats.Select(p => p.RoleId)) & Condition.Equal("MemberType", MemberType.Role)
                    );
            }

            //获取指定条件的所有权限定义(注:禁止分页查询,并即时加载到数组中)
            var permissions = this.DataAccess.Select <Permission>(conditions, Paging.Disabled).ToArray();

            //获取指定条件的所有权限过滤定义(注:禁止分页查询,并即时加载到数组中)
            var permissionFilters = this.DataAccess.Select <PermissionFilter>(conditions, Paging.Disabled).ToArray();

            var states = new HashSet <AuthorizationState>();
            IEnumerable <Permission>         prepares;
            IEnumerable <AuthorizationState> grants, denies;

            //如果上级角色层级列表不为空则进行分层过滤
            if (hierarchies != null && hierarchies.Count > 0)
            {
                //从最顶层(即距离指定成员最远的层)开始到最底层(集距离指定成员最近的层)
                for (int i = hierarchies.Count - 1; i >= 0; i--)
                {
                    //定义权限集过滤条件:当前层级的角色集的所有权限定义
                    prepares = permissions.Where(p => hierarchies[i].Any(role => role.RoleId == p.MemberId) && p.MemberType == MemberType.Role);

                    grants = prepares.Where(p => p.Granted).Select(p => new AuthorizationState(p.SchemaId, p.ActionId)).ToArray();
                    denies = prepares.Where(p => !p.Granted).Select(p => new AuthorizationState(p.SchemaId, p.ActionId)).ToArray();

                    states.UnionWith(grants);                      //合并授予的权限定义
                    states.ExceptWith(denies);                     //排除拒绝的权限定义

                    //更新授权集中的相关目标的过滤文本
                    this.SetPermissionFilters(states, permissionFilters.Where(p => hierarchies[i].Any(role => role.RoleId == p.MemberId) && p.MemberType == MemberType.Role));
                }
            }

            //查找权限定义中当前成员的设置项
            prepares = permissions.Where(p => p.MemberId == memberId && p.MemberType == memberType);

            grants = prepares.Where(p => p.Granted).Select(p => new AuthorizationState(p.SchemaId, p.ActionId)).ToArray();
            denies = prepares.Where(p => !p.Granted).Select(p => new AuthorizationState(p.SchemaId, p.ActionId)).ToArray();

            states.UnionWith(grants);              //合并授予的权限定义
            states.ExceptWith(denies);             //排除拒绝的权限定义

            //更新授权集中的相关目标的过滤文本
            this.SetPermissionFilters(states, permissionFilters.Where(p => p.MemberId == memberId && p.MemberType == memberType));

            foreach (var group in states.GroupBy(p => p.SchemaId))
            {
                yield return(new AuthorizationToken(group.Key, group.Select(p => new AuthorizationToken.ActionToken(p.ActionId, p.Filter))));
            }
        }
示例#22
0
 /// <summary>
 /// Creates an item with the specified sub items. And the current
 /// Condition status for this item.
 /// </summary>
 public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
 {
     return(this);
 }
示例#23
0
 public static PersonItem[] Search(ConditionCollection conditions, SortingCollection sorting, bool distinct)
 {
     return(Search(conditions, sorting, distinct, 0));
 }
        /// <summary>
        /// 載入驗證規則
        /// </summary>
        /// <param name="XmlNode"></param>
        public void LoadRule(XmlElement XmlNode)
        {
            FieldValidators = new FieldValidatorCollection(XmlNode.SelectSingleNode("ValidatorList") as XmlElement);
            RowValidators = new RowValidatorCollection(XmlNode.SelectSingleNode("ValidatorList") as XmlElement);
            Conditions = new ConditionCollection(XmlNode.SelectSingleNode("ConditionList") as XmlElement);
            FieldValidate = new FieldValidate(XmlNode.SelectSingleNode("FieldList") as XmlElement, FieldValidators, Conditions);
            RowValidate = new RowValidate(XmlNode.SelectSingleNode("RowValidate") as XmlElement, RowValidators, Conditions);
            Duplication = new DuplicateDetection(XmlNode.SelectSingleNode("DuplicateDetection") as XmlElement);
            //MappingTables = LoadMappingTable(XmlNode.SelectSingleNode("MappingTable") as XmlElement);
            //DataSources = LoadDataSource(XmlNode.SelectSingleNode("DataSource") as XmlElement);

            FieldValidate.AutoCorrect += new EventHandler<AutoCorrectEventArgs>(mFieldValidate_AutoCorrect);
            FieldValidate.ErrorCaptured += new EventHandler<ErrorCapturedEventArgs>(mFieldValidate_ErrorCaptured);

            RowValidate.AutoCorrect += new EventHandler<AutoCorrectEventArgs>(mRowValidate_AutoCorrect);
            RowValidate.ErrorCaptured += new EventHandler<ErrorCapturedEventArgs>(mRowValidate_ErrorCaptured);
        }
示例#25
0
 public static Product[] Search(ConditionCollection conditions, SortingCollection sorting, bool distinct, int limit)
 {
     return(Search(conditions, sorting, distinct, limit, null));
 }
示例#26
0
        void AddCodonsToExtension(Extension e, XmlElement el, ConditionCollection conditions)
        {
            foreach (object o in el.ChildNodes)
            {
                if (!(o is XmlElement))
                {
                    continue;
                }
                XmlElement curEl = (XmlElement)o;

                switch (curEl.Name)
                {
                case "And":                         // these nodes are silently ignored.
                case "Or":
                case "Not":
                case "Condition":
                    break;

                case "Conditional":
                    ICondition condition = null;

                    // 若当前条件结点的属性个数为零或者(个数为1并且包含action属性),
                    //则说明当前条件结点为一个复合逻辑条件(即该条件由一些and,or等条件组成)
                    if (curEl.Attributes.Count == 0 || (curEl.Attributes.Count == 1 && curEl.Attributes["FailedAction"] != null))
                    {
                        condition = BuildComplexCondition(curEl);

                        // set condition action manually
                        if (curEl.Attributes["FailedAction"] != null)
                        {
                            condition.FailedAction = (ConditionFailedAction)Enum.Parse(typeof(ConditionFailedAction), curEl.Attributes["FailedAction"].InnerText);
                        }

                        if (condition == null)
                        {
                            throw new AddInTreeFormatException("empty conditional, but no condition definition found.");
                        }
                    }
                    else
                    {                               //当前条件结点为一个简单条件结点,该条件结点不会包含<Or>,<And>等子结点
                        condition = AddInTreeSingleton.AddInTree.ConditionFactory.CreateCondition(this, curEl);
                        AutoInitializeAttributes(condition, curEl);
                    }

                    // put the condition at the end of the condition 'stack'
                    conditions.Add(condition);

                    // traverse the subtree
                    AddCodonsToExtension(e, curEl, conditions);

                    // now we are back to the old level, remove the condition
                    // that was applied to the subtree.
                    conditions.RemoveAt(conditions.Count - 1);
                    break;

                default:
                    ICodon codon = AddInTreeSingleton.AddInTree.CodonFactory.CreateCodon(this, curEl);

                    AutoInitializeAttributes(codon, curEl);

                    // Ensure that the codon is inserted after the codon which is defined
                    // before in the add-in definition.
                    // The codons get topologically sorted and if I don't set the InsertAfter they may
                    // change it's sorting order.
                    e.Conditions[codon.ID] = new ConditionCollection(conditions);
                    if (codon.InsertAfter == null && codon.InsertBefore == null && e.CodonCollection.Count > 0)
                    {
                        codon.InsertAfter = new string[] { ((ICodon)e.CodonCollection[e.CodonCollection.Count - 1]).ID };
                    }

                    e.CodonCollection.Add(codon);
                    if (curEl.ChildNodes.Count > 0)
                    {
                        Extension newExtension = new Extension(e.Path + '/' + codon.ID);
                        AddCodonsToExtension(newExtension, curEl, conditions);
                        extensions.Add(newExtension);
                    }
                    break;
                }
            }
        }
示例#27
0
 /// <summary>
 /// Creates an item with the specified sub items and the current
 /// Conditions for this item.
 /// </summary>
 public abstract object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions);
		public virtual ICondition Convert(ConditionalConverterContext context)
		{
			//如果当前属性值为默认值,则忽略它
			if(this.IsDefaultValue(context))
				return null;

			var opt = context.Operator;
			var isRange = Zongsoft.Common.TypeExtension.IsAssignableFrom(typeof(ConditionalRange), context.Type);

			//只有当属性没有指定运算符并且不是区间属性,才需要生成运算符
			if(opt == null && (!isRange))
			{
				opt = ConditionOperator.Equal;

				if(context.Type == typeof(string) && context.Value != null)
					opt = ConditionOperator.Like;
				else if(typeof(IEnumerable).IsAssignableFrom(context.Type) || Zongsoft.Common.TypeExtension.IsAssignableFrom(typeof(IEnumerable<>), context.Type))
					opt = ConditionOperator.In;
			}

			//如果当前属性只对应一个条件
			if(context.Names.Length == 1)
			{
				if(isRange)
					return ((ConditionalRange)context.Value).ToCondition(context.Names[0]);
				else
					return new Condition(context.Names[0], (opt == ConditionOperator.Like && _wildcard != '\0' ? _wildcard + context.Value.ToString().Trim(_wildcard) + _wildcard : context.Value), opt.Value);
			}

			//当一个属性对应多个条件,则这些条件之间以“或”关系进行组合
			var conditions = new ConditionCollection(ConditionCombination.Or);

			foreach(var name in context.Names)
			{
				if(isRange)
					conditions.Add(((ConditionalRange)context.Value).ToCondition(name));
				else
					conditions.Add(new Condition(name, (opt == ConditionOperator.Like && _wildcard != '\0' ? _wildcard + context.Value.ToString().Trim(_wildcard) + _wildcard : context.Value), opt.Value));
			}

			return conditions;
		}
示例#29
0
		/// <summary>
		/// This constructor will create an empty class, normally
		/// used when the Node property is assigned
		/// </summary>
		public Rule()
		{
			m_conditons = new ConditionCollection();
		}
示例#30
0
    public static Dictionary <string, ConditionCollection> nodeB()
    {
        GameObject  nodeBgo = nodes.GetNode("B");
        SceneSounds ss      = FindObjectOfType <SceneSounds> ();

        AudioReaction whoosh_sound = new AudioReaction();

        whoosh_sound.audioSource = nodeBgo.GetComponent <AudioSource>() as AudioSource;
        whoosh_sound.audioClip   = ss.getSceneSoundByName("movewhoosh").clip;
        whoosh_sound.delay       = 0.0f;

        //float left
        ConditionCollection ccfloatleft = new ConditionCollection();
        ReactionCollection  floatleft_react_collection = new ReactionCollection();
        MoveReaction        floatleft_react            = new MoveReaction();

        floatleft_react.destination          = "A";
        floatleft_react_collection.reactions = new Reaction[] {
            floatleft_react,
            whoosh_sound
        };
        ccfloatleft.reactionCollection = floatleft_react_collection;
        Condition always_true_cond = new Condition();

        always_true_cond.toEval = () => {
            return(true);
        };
        ccfloatleft.requiredConditions = new Condition[] {
            always_true_cond
        };
        //float right
        ConditionCollection ccfloatright = new ConditionCollection();
        ReactionCollection  floatright_react_collection = new ReactionCollection();

        MoveReaction floatright_react = new MoveReaction();

        floatright_react.destination          = "C";
        floatright_react_collection.reactions = new Reaction[] {
            floatright_react,
            whoosh_sound
        };

        ccfloatright.reactionCollection = floatright_react_collection;
        ccfloatright.requiredConditions = new Condition[] {
            always_true_cond
        };

        //kombucha conditions
        Condition kombucha_not_appeared = new Condition();

        kombucha_not_appeared.toEval = () => {
            return(!((bool)GameData.GlobalBools["kombucha_appeared"]));
        };

        Condition kombucha_appeared = new Condition();

        kombucha_appeared.toEval = () => {
            return((bool)GameData.GlobalBools["kombucha_appeared"]);
        };

        //grab
        ConditionCollection ccgrab = new ConditionCollection();
        ReactionCollection  grab_react_collection = new ReactionCollection();

        InstantiateReaction grab_react = new InstantiateReaction();

        grab_react.prefab = Resources.Load <GameObject> ("Prefabs/Kombucha");
        grab_react.pos    = new Vector3(5200, 350, 0);

        GlobalBoolReaction kombucha_appeared_reaction = new GlobalBoolReaction();

        kombucha_appeared_reaction.toSet = "kombucha_appeared";
        kombucha_appeared_reaction.setTo = true;


        AudioReaction kombucha_appeared_react_sound = new AudioReaction();

        kombucha_appeared_react_sound.audioSource = nodeBgo.GetComponent <AudioSource>() as AudioSource;
        kombucha_appeared_react_sound.audioClip   = ss.getSceneSoundByName("oww").clip;
        kombucha_appeared_react_sound.delay       = 0.0f;

        grab_react_collection.reactions = new Reaction[] {
            grab_react,
            kombucha_appeared_reaction,
            kombucha_appeared_react_sound
        };

        ccgrab.reactionCollection = grab_react_collection;
        ccgrab.requiredConditions = new Condition[] {
            kombucha_not_appeared
        };

        ccgrab.reactionCollection.DoInit();

        //look kombucha
        ConditionCollection cclookk = new ConditionCollection();
        ReactionCollection  lookk_react_collection = new ReactionCollection();
        PlayerTextReaction  lookk_react            = new PlayerTextReaction();

        lookk_react.message = "My human drinks a lot of kombucha.";
        lookk_react.delay   = 0f;

        lookk_react_collection.reactions = new Reaction[] {
            lookk_react
        };

        cclookk.reactionCollection = lookk_react_collection;
        cclookk.requiredConditions = new Condition[] {
            kombucha_appeared
        };
        cclookk.reactionCollection.DoInit();

        //look
        ConditionCollection cclook = new ConditionCollection();
        ReactionCollection  look_react_collection     = new ReactionCollection();
        ReactionCollection  look_neg_react_collection = new ReactionCollection();

        PlayerTextReaction look_react = new PlayerTextReaction();

        look_react.message = "kombucha, gross.";
        look_react.delay   = 0f;

        PlayerTextReaction look_neg_react = new PlayerTextReaction();

        look_neg_react.message = "meeeow...if only there was a way to distract her!";
        look_neg_react.delay   = 0f;

        look_react_collection.reactions = new Reaction[] {
            look_react
        };
        look_neg_react_collection.reactions = new Reaction[] {
            look_neg_react
        };

        cclook.reactionCollection    = look_react_collection;
        cclook.negReactionCollection = look_neg_react_collection;
        cclook.requiredConditions    = new Condition[] {
            kombucha_appeared             //TODO: bey is gone?
        };
        cclook.reactionCollection.DoInit();
        cclook.negReactionCollection.DoInit();

        //interact kombucha
        ConditionCollection ccinteractk = new ConditionCollection();
        ReactionCollection  interactk_react_collection = new ReactionCollection();
        GameObjectReaction  interactk_go_reaction      = new GameObjectReaction();

        GameObject[] gos = FindObjectsOfType <GameObject> ();
        foreach (var g in gos)
        {
            if (g.name == "Bey")
            {
                interactk_go_reaction.gameObject = g;
                break;
            }
        }
        interactk_go_reaction.activeState = false;

        GlobalBoolReaction can_exit_tent_reaction = new GlobalBoolReaction();

        can_exit_tent_reaction.toSet = "can_exit_tent";
        can_exit_tent_reaction.setTo = true;

        UninstantiateReaction uninstantiate_kombucha_reaction = new UninstantiateReaction();

        uninstantiate_kombucha_reaction.objectName = "kombucha";

        AudioReaction kombucha_drugged_react_sound = new AudioReaction();

        kombucha_drugged_react_sound.audioSource = nodeBgo.GetComponent <AudioSource>() as AudioSource;
        kombucha_drugged_react_sound.audioClip   = ss.getSceneSoundByName("drugged_the_human").clip;
        kombucha_drugged_react_sound.delay       = 0.0f;

        Condition pills_acquired = new Condition();

        pills_acquired.toEval = () => {
            return(inv.Contains("pills"));
        };

        LostItemReaction pill_loss_react = new LostItemReaction();
        SceneItems       si = FindObjectOfType <SceneItems> ();

        pill_loss_react.item = si.getSceneItemByName("pills");

        interactk_react_collection.reactions = new Reaction[] {
            interactk_go_reaction,
            pill_loss_react,
            can_exit_tent_reaction,
            uninstantiate_kombucha_reaction,
            kombucha_drugged_react_sound
        };

        ccinteractk.reactionCollection = interactk_react_collection;
        ccinteractk.requiredConditions = new Condition[] {
            pills_acquired,
            kombucha_appeared
        };

        ccinteractk.reactionCollection.DoInit();


        Dictionary <string, ConditionCollection> htm = new Dictionary <string, ConditionCollection>();

        htm.Add("float left", ccfloatleft);
        htm.Add("float right", ccfloatright);
        htm.Add("grab", ccgrab);
        htm.Add("look kombucha", cclookk);
        htm.Add("look", cclook);
        htm.Add("interact kombucha", ccinteractk);
        return(htm);
    }
        /// <summary>
        /// 打印任务状态回调
        /// </summary>
        /// <param name="resultCode">状态码</param>
        /// <param name="orderId">订单编号</param>
        /// <param name="printerCodes">打印设备编码</param>
        public void AppCallBack(int resultCode, string orderId, string printerCodes = "")
        {
            //判断,有些状态不用回调,例如断网
            int[] printStatueCode = { 1, 3, 4, 6, 7 };
            if (!printStatueCode.Contains(resultCode))
            {
                LogUtil.Info($"跳过回调:该状态不回调-{resultCode},订单-{orderId}");
                return;
            }
            LogUtil.Info(string.Format("开始执行打印任务回调,设备号:{0},订单号:{1},状态: {2}", printerCodes, orderId, resultCode));
            //获取打印订单信息
            var cc = new ConditionCollection();

            cc.Add(new Condition("order_id", orderId));
            var order = this.GetRepository <McpOrderInfo>().GetModel(cc);

            if (order != null)
            {
                //获取订单所属应用信息
                var c1 = new ConditionCollection();
                c1.Add(new Condition("app_id", order.AppId));
                var app = this.GetRepository <McpApplicationInfo>().GetModel(c1);
                if (app != null)
                {
                    //执行回调更新第三方应用数据状态
                    if (!string.IsNullOrWhiteSpace(app.UpdateCallbackUrl))
                    {
                        if (string.IsNullOrWhiteSpace(printerCodes))
                        {
                            var c2 = new ConditionCollection();
                            c2.Add(new Condition("order_id", order.OrderId));
                            var           printers  = this.GetRepository <McpOrderPrinterInfo>().ListModel(c2);
                            StringBuilder sbPrinter = new StringBuilder();
                            if (printers != null)
                            {
                                printers.ForEach(d => sbPrinter.AppendFormat("{0},", d.PrinterCode));
                                printerCodes = sbPrinter.ToString().TrimEnd(',');
                            }
                        }
                        var callbackModel = new CallBackViewModel()
                        {
                            bill_no      = order.BillNo,
                            printer_code = printerCodes,
                            result_code  = resultCode.ToString(),
                            key          = app.SignKey,
                            order_id     = orderId
                        };
                        int status = 0, tryNum = 1;
                        try
                        {
                            status = ExceCallBack(callbackModel, app.UpdateCallbackUrl, tryNum);
                            if (status != 1)
                            {
                                System.Threading.Thread.Sleep(delayTryInterval);
                                if (tryNum <= tryMax)
                                {
                                    status = ExceCallBack(callbackModel, app.UpdateCallbackUrl, ++tryNum);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogUtil.Error(ex.Message);
                            System.Threading.Thread.Sleep(delayTryInterval);
                            if (tryNum <= tryMax)
                            {
                                status = ExceCallBack(callbackModel, app.UpdateCallbackUrl, ++tryNum);
                            }
                            else
                            {
                                throw new MessageException(ex.Message);
                            }
                        }

                        //更新回调标识
                        if (status > 0)
                        {
                            order.CallbackStatus = status;
                            order.ModifiedOn     = CommonUtil.GetDBDateTime();
                            this.GetRepository <McpOrderInfo>().Update(order, "callback_status,modified_on");
                        }
                    }
                }
            }
        }
 public static PersonDepartment[] Search(ConditionCollection conditions, SortingCollection sorting)
 {
     return(Search(conditions, sorting, false));
 }
示例#33
0
		/// <summary>
		/// This constructor will create an empty class, normally
		/// used when the Node property is assigned
		/// </summary>
		public TracePolicy(Guid id)
		{
			m_conditons = new ConditionCollection();
            m_msgId = id;
		}
示例#34
0
    public static Dictionary <string, ConditionCollection> nodeA()
    {
        GameObject  nodeAgo = nodes.GetNode("A");
        SceneSounds ss      = FindObjectOfType <SceneSounds> ();

        AudioReaction whoosh_sound = new AudioReaction();

        whoosh_sound.audioSource = nodeAgo.GetComponent <AudioSource>() as AudioSource;
        whoosh_sound.audioClip   = ss.getSceneSoundByName("movewhoosh").clip;
        whoosh_sound.delay       = 0.0f;

        //float right
        ConditionCollection cc = new ConditionCollection();
        ReactionCollection  temp_react_collection = new ReactionCollection();
        MoveReaction        temp_react            = new MoveReaction();

        temp_react.destination          = "B";
        temp_react_collection.reactions = new Reaction[] {
            temp_react,
            whoosh_sound
        };
        cc.reactionCollection = temp_react_collection;
        Condition temp_cond = new Condition();

        temp_cond.toEval = () => {
            return(true);
        };
        cc.requiredConditions = new Condition[] {
            temp_cond
        };

        //float left
        ConditionCollection floatleftcc = new ConditionCollection();
        ReactionCollection  floatleft_react_collection    = new ReactionCollection();
        ReactionCollection  floatleft_negreact_collection = new ReactionCollection();

        PlayerTextReaction floatleft_react = new PlayerTextReaction();

        floatleft_react.message = "I'm outta here.";
        floatleft_react.delay   = 0f;

        SceneReaction win_reaction = new SceneReaction();

        win_reaction.delay  = 0;
        win_reaction.toLoad = 3;

        floatleft_react_collection.reactions = new Reaction[] {
            floatleft_react,
            win_reaction
        };

        PlayerTextReaction floatleft_neg_react = new PlayerTextReaction();

        floatleft_neg_react.message = "I can't get out ... London La Croix will see.";
        floatleft_neg_react.delay   = 0f;


        AudioReaction nooutside_react_sound = new AudioReaction();

        nooutside_react_sound.audioSource = nodeAgo.GetComponent <AudioSource>() as AudioSource;
        nooutside_react_sound.audioClip   = ss.getSceneSoundByName("nooutside").clip;
        nooutside_react_sound.delay       = 0.0f;

        floatleft_negreact_collection.reactions = new Reaction[] {
            floatleft_neg_react,
            nooutside_react_sound
        };

        floatleftcc.reactionCollection    = floatleft_react_collection;
        floatleftcc.negReactionCollection = floatleft_negreact_collection;
        Condition floatleft_cond = new Condition();

        floatleft_cond.toEval = () => {
            return((bool)GameData.GlobalBools["can_exit_tent"]);
        };
        floatleftcc.requiredConditions = new Condition[] {
            floatleft_cond
        };
        floatleftcc.reactionCollection.DoInit();
        floatleftcc.negReactionCollection.DoInit();

        //look
        ConditionCollection cclook = new ConditionCollection();
        ReactionCollection  look_react_collection = new ReactionCollection();

        PlayerTextReaction look_react = new PlayerTextReaction();

        look_react.message = "UGH! this music... gotta break out of here.";
        look_react.delay   = 0.0f;

        AudioReaction concert_react_sound = new AudioReaction();

        concert_react_sound.audioSource = nodeAgo.GetComponent <AudioSource>() as AudioSource;
        concert_react_sound.audioClip   = ss.getSceneSoundByName("concert").clip;
        concert_react_sound.delay       = 0.0f;

        look_react_collection.reactions = new Reaction[] {
            look_react,
            concert_react_sound
        };

        Condition always_true_cond = new Condition();

        always_true_cond.toEval = () => {
            return(true);
        };

        cclook.reactionCollection = look_react_collection;
        cclook.requiredConditions = new Condition[] {
            always_true_cond
        };
        cclook.reactionCollection.DoInit();

        Dictionary <string, ConditionCollection> htm = new Dictionary <string, ConditionCollection>();

        htm.Add("float right", cc);
        htm.Add("float left", floatleftcc);
        htm.Add("look", cclook);
        return(htm);
    }
示例#35
0
    public static Dictionary <string, ConditionCollection> nodeC()
    {
        GameObject  nodeCgo = nodes.GetNode("C");
        SceneSounds ss      = FindObjectOfType <SceneSounds> ();

        AudioReaction whoosh_sound = new AudioReaction();

        whoosh_sound.audioSource = nodeCgo.GetComponent <AudioSource>() as AudioSource;
        whoosh_sound.audioClip   = ss.getSceneSoundByName("movewhoosh").clip;
        whoosh_sound.delay       = 0.0f;

        //float left
        ConditionCollection ccfloatleft = new ConditionCollection();
        ReactionCollection  floatleft_react_collection = new ReactionCollection();
        MoveReaction        floatleft_react            = new MoveReaction();

        floatleft_react.destination          = "B";
        floatleft_react_collection.reactions = new Reaction[] {
            floatleft_react,
            whoosh_sound
        };
        ccfloatleft.reactionCollection = floatleft_react_collection;
        Condition always_true_cond = new Condition();

        always_true_cond.toEval = () => {
            return(true);
        };
        ccfloatleft.requiredConditions = new Condition[] {
            always_true_cond
        };

        //float right
        ConditionCollection ccfloatright = new ConditionCollection();
        ReactionCollection  floatright_react_collection = new ReactionCollection();
        PlayerTextReaction  floatright_react            = new PlayerTextReaction();

        floatright_react.message = "There is nothing to the right.";
        //		floatright_react.textColor = Color.white;
        floatright_react.delay = 0.01f;
        AudioReaction floatright_react_sound = new AudioReaction();

        floatright_react_sound.audioSource    = nodeCgo.GetComponent <AudioSource>() as AudioSource;
        floatright_react_sound.audioClip      = ss.getSceneSoundByName("meow1").clip;
        floatright_react_sound.delay          = 0.0f;
        floatright_react_collection.reactions = new Reaction[] {
            floatright_react,
            floatright_react_sound
        };
        Condition always_true_init_cond = new Condition();

        always_true_init_cond.toEval = () => {
            ccfloatright.reactionCollection.DoInit();
            return(true);
        };
        ccfloatright.reactionCollection = floatright_react_collection;
        ccfloatright.requiredConditions = new Condition[] {
            always_true_init_cond
        };

        //grab
        ConditionCollection  ccgrab = new ConditionCollection();
        ReactionCollection   grab_react_collection = new ReactionCollection();
        PickedUpItemReaction grab_react            = new PickedUpItemReaction();
        SceneItems           si = FindObjectOfType <SceneItems> ();

        grab_react.item = si.getSceneItemByName("pills");

        GameObjectReaction grab_pills_react = new GameObjectReaction();

        GameObject[] gos = FindObjectsOfType <GameObject> ();
        foreach (var g in gos)
        {
            if (g.name == "pills")
            {
                grab_pills_react.gameObject = g;
                break;
            }
        }
        grab_pills_react.activeState = false;

        AudioReaction grab_pills_react_sound = new AudioReaction();

        grab_pills_react_sound.audioSource = nodeCgo.GetComponent <AudioSource>() as AudioSource;
        grab_pills_react_sound.audioClip   = ss.getSceneSoundByName("pills").clip;
        grab_pills_react_sound.delay       = 0.0f;

        grab_react_collection.reactions = new Reaction[] {
            grab_react,
            grab_pills_react,
            grab_pills_react_sound
        };

        Condition pills_not_yet_acquired = new Condition();

        pills_not_yet_acquired.toEval = () => {
            return(!inv.Contains("pills"));
        };

        ccgrab.reactionCollection = grab_react_collection;
        ccgrab.requiredConditions = new Condition[] {
            pills_not_yet_acquired
        };
        ccgrab.reactionCollection.DoInit();

        //look
        ConditionCollection cclook = new ConditionCollection();
        ReactionCollection  look_react_collection = new ReactionCollection();
        PlayerTextReaction  look_react            = new PlayerTextReaction();

        look_react.message = "My human’s happy pills, fun to bat under the couch.";
        //		floatright_react.textColor = Color.white;
        look_react.delay = 0.01f;

        look_react_collection.reactions = new Reaction[] {
            look_react
        };

        cclook.reactionCollection = look_react_collection;
        cclook.requiredConditions = new Condition[] {
            pills_not_yet_acquired
        };
        cclook.reactionCollection.DoInit();

        //interact
        ConditionCollection ccinteract = new ConditionCollection();
        ReactionCollection  interact_react_collection = new ReactionCollection();

        PlayerTextReaction interact_ptext_react = new PlayerTextReaction();

        interact_ptext_react.message = "meow...pills are for humans, not magic cats!";
        interact_ptext_react.delay   = 0f;

        interact_react_collection.reactions = new Reaction[] {
            interact_ptext_react
        };
        Condition cannot_exit_cond = new Condition();

        cannot_exit_cond.toEval = () => {
            return(!(bool)GameData.GlobalBools["can_exit_tent"]);
        };
        ccinteract.reactionCollection = interact_react_collection;
        cclook.requiredConditions     = new Condition[] {
            pills_not_yet_acquired,
            cannot_exit_cond
        };
        ccinteract.reactionCollection.DoInit();

        Dictionary <string, ConditionCollection> htm = new Dictionary <string, ConditionCollection>();

        htm.Add("float left", ccfloatleft);
        htm.Add("float right", ccfloatright);
        htm.Add("grab", ccgrab);
        htm.Add("look", cclook);
        htm.Add("interact", ccinteract);

        return(htm);
    }
    public static ConditionCollection CreateConditionCollection()
    {
        ConditionCollection newConditionCollection = CreateInstance <ConditionCollection>();

        return(newConditionCollection);
    }