Example #1
0
        /// <summary>
        /// Builds a BasePathFinder
        /// </summary>
        /// <param name="parms">BasePathFinderParams object containing the data requried to build the pathfinder</param>
        public BasePathFinder(BasePathFinderParams parms)
        {
            this.tieBreakerRandom         = new Random();
            this.directionRestrictionType = parms.DirectionRestrictionType;
            this.costs  = parms.Costs;
            this.HEIGHT = parms.Height;
            this.WIDTH  = parms.Width;
            this.allowedToCutCorners = parms.AllowCornerCutting;
            this.board = null;

            if (this.directionRestrictionType == RestrictionType.Restricted)
            {
                this.DIRECTIONS_LENGTH = 4;
                this.directions        = new int[4, 2] {
                    { 0, 1 },                           // right
                    { 0, -1 },                          // left
                    { 1, 0 },                           // bottom
                    { -1, 0 }                           // top
                };
            }
            else
            {
                this.DIRECTIONS_LENGTH = 8;
                this.directions        = new int[8, 2] {
                    { 0, 1 },                           // right
                    { 0, -1 },                          // left
                    { 1, 0 },                           // bottom
                    { -1, 0 },                          // top
                    { -1, -1 },                         // top left corner
                    { -1, 1 },                          // top right corner
                    { 1, -1 },                          // bottom left corner
                    { 1, 1 }                            // bottom right corner
                };
            }
        }
        public async Task <IActionResult> PutRestrictionType([FromRoute] short id, [FromBody] RestrictionType restrictionType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != restrictionType.RestrictionTypeId)
            {
                return(BadRequest());
            }

            _context.Entry(restrictionType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RestrictionTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
        private List <Restriction> GetRestrictions(INode classUri, RestrictionType restrictionType)
        {
            var query = GetQueryForClassRestrictionsByType(classUri, restrictionType);
            var restrictionsSparqlSet = ExecuteQuery(query);
            var listOfRestrictions    = new List <Restriction>();

            foreach (var restrictionSparql in restrictionsSparqlSet)
            {
                var restriction = new Restriction
                {
                    RestrictionType  = restrictionType,
                    OwlOnPropertyUri = restrictionSparql["onPropertyUri"],
                    OwlOnClass       = restrictionSparql["onClass"],
                    ParentClassUri   = classUri,
                    LabelsOfProperty = GetLabelsOfProperty(restrictionSparql["onPropertyUri"].ToString()),
                };

                if (restrictionType == RestrictionType.MaxQualifiedCardinality ||
                    restrictionType == RestrictionType.QualifiedCardinality ||
                    restrictionType == RestrictionType.MinQualifiedCardinality)
                {
                    restriction.Cardinality = restrictionSparql["cardinality"];
                }

                listOfRestrictions.Add(restriction);
            }

            return(listOfRestrictions);
        }
Example #4
0
                public RestrictionSpecification(int titleID, string property, RestrictionType type)
                {
                    this.titleID  = titleID;
                    this.type     = type;
                    this.property = property;

                    StartTime = EndTime = DateTime.Today;
                }
Example #5
0
 public FlightRestriction(RestrictionType type, DateTime startDate, DateTime endDate, BaseUnit from, BaseUnit to)
 {
     this.Type = type;
     this.StartDate = startDate;
     this.EndDate = endDate;
     this.From = from;
     this.To = to;
 }
Example #6
0
		public static RestrictionDefinition Create(RestrictionType type, ActorDefinition actor)
		{
			return new RestrictionDefinition()
			{
				Actor = actor,
				Type = type
			};
		}
 public FlightRestriction(RestrictionType type, DateTime startDate, DateTime endDate, BaseUnit from, BaseUnit to)
 {
     Type = type;
     StartDate = startDate;
     EndDate = endDate;
     From = from;
     To = to;
 }
Example #8
0
        private Dialog_Restrictions(RestrictionType type, Rules rules)
        {
            _rules = rules;
            _type  = type;

            _presetList = new Listing_Preset <Restriction>(_type, _rules.GetRestriction(_type), new[] { Registry.GetVoidPreset <Restriction>(_type) }, RefreshTemplate, SaveTemplate, null);
            RefreshTemplate();
        }
 public DateTimeRestriction(List <DayOfWeek> daysOfWeek, DateTime timeStart, DateTime timeEnd, List <DateTime> dates, RestrictionType restrictionType)
 {
     DaysOfWeek = daysOfWeek;
     TimeStart  = timeStart;
     TimeEnd    = timeEnd;
     Dates      = dates;
     Type       = restrictionType;
 }
Example #10
0
 public FlightRestriction(RestrictionType type, DateTime startDate, DateTime endDate, BaseUnit from, BaseUnit to)
 {
     this.Type      = type;
     this.StartDate = startDate;
     this.EndDate   = endDate;
     this.From      = from;
     this.To        = to;
 }
Example #11
0
 public Split(string id, Group group, Vector3 axis, Vector3 pivot, float value, RestrictionType restriction)
 {
     Axis = axis;
     Pivot = pivot;
     Value = value;
     Id = id;
     Group = group;
     Restriction = restriction;
 }
Example #12
0
        /// <summary>
        /// The operation construct a request for FindItem operation.
        /// </summary>
        /// <param name="folderName">A string that specifies the folder to search.</param>
        /// <param name="value">A string that specifies the value for a search restriction.</param>
        /// <param name="field">A string that specifies the type of referenced field URI.</param>
        /// <returns>The request of FindItem operation which constructed with special folder name, search restriction and referenced field URI</returns>
        protected FindItemType ConstructFindItemRequest(string folderName, string value, string field)
        {
            FindItemType findRequest = new FindItemType();

            findRequest.ItemShape           = new ItemResponseShapeType();
            findRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

            DistinguishedFolderIdType     folderId = new DistinguishedFolderIdType();
            DistinguishedFolderIdNameType folderIdName;

            if (Enum.TryParse <DistinguishedFolderIdNameType>(folderName, out folderIdName))
            {
                folderId.Id = folderIdName;
            }
            else
            {
                Site.Assert.Fail("The value of the first argument (foldIdNameType) of FindItem operation is invalid.");
            }

            findRequest.ParentFolderIds    = new BaseFolderIdType[1];
            findRequest.ParentFolderIds[0] = folderId;

            PathToUnindexedFieldType itemClass = new PathToUnindexedFieldType();
            UnindexedFieldURIType    fieldURI;

            if (Enum.TryParse <UnindexedFieldURIType>(field, out fieldURI))
            {
                // set search field.
                itemClass.FieldURI = fieldURI;
            }
            else
            {
                Site.Assert.Fail("The value of the second argument (fieldURIType) of FindItem operation is invalid.");
            }

            ContainsExpressionType expressionType = new ContainsExpressionType();

            expressionType.Item                           = itemClass;
            expressionType.ContainmentMode                = ContainmentModeType.Substring;
            expressionType.ContainmentModeSpecified       = true;
            expressionType.ContainmentComparison          = ContainmentComparisonType.IgnoreCaseAndNonSpacingCharacters;
            expressionType.ContainmentComparisonSpecified = true;
            expressionType.Constant                       = new ConstantValueType();
            expressionType.Constant.Value                 = value;

            RestrictionType restriction = new RestrictionType();

            restriction.Item = expressionType;

            if (!string.IsNullOrEmpty(value))
            {
                findRequest.Restriction = restriction;
            }

            return(findRequest);
        }
Example #13
0
        public override int GetHashCode()
        {
            int hashCode = 1516578759;

            hashCode = (hashCode * -1521134295) + IsSponsorSpot.GetHashCode();
            hashCode = (hashCode * -1521134295) + Applicability.GetHashCode();
            hashCode = (hashCode * -1521134295) + CompetitorType.GetHashCode();
            hashCode = (hashCode * -1521134295) + RestrictionType.GetHashCode();
            return(hashCode);
        }
        public async Task <IActionResult> PostRestrictionType([FromBody] RestrictionType restrictionType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.RestrictionType.Add(restrictionType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRestrictionType", new { id = restrictionType.RestrictionTypeId }, restrictionType));
        }
Example #15
0
 public Restriction(RestrictionType type, string parameter)
     : this()
 {
     if (!String.IsNullOrWhiteSpace(parameter))
     {
         this.Parameter = parameter;
         this.Type = type;
     }
     else
     {
         throw new NullReferenceException("Restriction parameter cannot be null or empty.");
     }
 }
Example #16
0
 private IEnumerable<string> ApplyRestriction(RestrictionType restriction, string value, Common.SimpleDatatypeEnumeration datatypeEnumeration, string restrictionHint)
 {
     List<string> messages = new List<string>();
     IOvalComparator comparator = new OvalComparatorFactory().GetComparator(datatypeEnumeration);
     if (!comparator.Compare(value, restriction.Value, restriction.operation))
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine(restrictionHint);
         sb.AppendLine(restriction.GetRestrictionMessage());
         messages.Add(sb.ToString());
     }
     return messages;
 }
Example #17
0
        public Restriction(Entities.Restriction restriction)
        {
            Code = restriction.Code;
            Type = restriction.Type;

            RoleCode = restriction.Role?.Code ?? restriction.RoleCode;

            Role = new Role
            {
                Name = restriction.Role?.Name,
                Code = restriction.Role?.Code ?? restriction.RoleCode
            };
        }
Example #18
0
        static List <SignRestriction> GenerateSignRestrictions(string line)
        {
            List <SignRestriction> restrictions = new List <SignRestriction>();

            string[] data = line.Split(' ');
            for (int i = 0; i < data.Length; i++)
            {
                RestrictionType restrictionType = DetermineRestrictionType(data[i]);
                string          decVar          = "x" + (i + 1);
                SignRestriction sr = new SignRestriction(decVar, restrictionType);
                restrictions.Add(sr);
            }
            return(restrictions);
        }
        private IEnumerable <string> ApplyRestriction(RestrictionType restriction, string value, Common.SimpleDatatypeEnumeration datatypeEnumeration, string restrictionHint)
        {
            List <string>   messages   = new List <string>();
            IOvalComparator comparator = new OvalComparatorFactory().GetComparator(datatypeEnumeration);

            if (!comparator.Compare(value, restriction.Value, restriction.operation))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(restrictionHint);
                sb.AppendLine(restriction.GetRestrictionMessage());
                messages.Add(sb.ToString());
            }
            return(messages);
        }
Example #20
0
        private string GetQueryForClassRestrictionsByType(INode classUri, RestrictionType restrictionType)
        {
            var queryAllValuesFrom  = "SELECT * WHERE { { GRAPH ?g { ?restriction owl:onProperty ?onPropertyUri. ?restriction owl:allValuesFrom ?onClass. <" + classUri + "> rdfs:subClassOf ?restriction.} } }";
            var querySomeValuesFrom = "SELECT * WHERE { { GRAPH ?g { ?restriction owl:onProperty ?onPropertyUri. ?restriction owl:someValuesFrom ?onClass. <" + classUri + "> rdfs:subClassOf ?restriction.} } }";
            var queryMinCardinality = "SELECT * WHERE { { GRAPH ?g { ?restriction owl:onProperty ?onPropertyUri. ?restriction owl:minQualifiedCardinality ?cardinality. ?restriction owl:onClass ?onClass. <" + classUri + "> rdfs:subClassOf ?restriction.} } }";
            var queryCardinality    = "SELECT * WHERE { { GRAPH ?g { ?restriction owl:onProperty ?onPropertyUri. ?restriction owl:qualifiedCardinality ?cardinality. ?restriction owl:onClass ?onClass. <" + classUri + "> rdfs:subClassOf ?restriction.} } }";
            var queryMaxCardinality = "SELECT * WHERE { { GRAPH ?g { ?restriction owl:onProperty ?onPropertyUri. ?restriction owl:maxQualifiedCardinality ?cardinality. ?restriction owl:onClass ?onClass. <" + classUri + "> rdfs:subClassOf ?restriction.} } }";

            switch (restrictionType)
            {
            case RestrictionType.AllValuesFrom:
            {
                return(queryAllValuesFrom);
            }

            case RestrictionType.SomeValuesFrom:
            {
                return(querySomeValuesFrom);
            }

            case RestrictionType.MaxQualifiedCardinality:
            {
                return(queryMaxCardinality);
            }

            case RestrictionType.QualifiedCardinality:
            {
                return(queryCardinality);
            }

            case RestrictionType.MinQualifiedCardinality:
            {
                return(queryMinCardinality);
            }

            default:
            {
                throw new ArgumentOutOfRangeException("Can`t find appropriate restrictionType");
            }
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Interval.GetHashCode();
         hashCode = (hashCode * 397) ^ RestrictionType.GetHashCode();
         hashCode = (hashCode * 397) ^ EvaluationMode.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Frequency;
         hashCode = (hashCode * 397) ^ Until.GetHashCode();
         hashCode = (hashCode * 397) ^ Count;
         hashCode = (hashCode * 397) ^ (int)FirstDayOfWeek;
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(BySecond);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(ByMinute);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(ByHour);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(ByDay);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(ByMonthDay);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(ByYearDay);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(ByWeekNo);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(ByMonth);
         hashCode = (hashCode * 397) ^ CollectionHelpers.GetHashCode(BySetPosition);
         return(hashCode);
     }
 }
Example #22
0
        private void ChangeRestriction(RestrictionType type)
        {
            var list = new List <FloatMenuOption>();

            var presets = Registry.GetPresets <Restriction>(type).Where(preset => preset != _template.GetRestriction(type)).ToArray();

            if (!presets.Any() && _template.GetRestriction(type).IsVoid)
            {
                Dialog_Restrictions.Open(type, _template);
                return;
            }

            list.Add(new FloatMenuOption(Lang.Get("Dialog_Rules.EditRestriction"), () => Dialog_Restrictions.Open(type, _template)));

            var voidPreset = Registry.GetVoidPreset <Restriction>(type);

            if (!_template.GetRestriction(type).IsVoid)
            {
                list.Add(new FloatMenuOption(Lang.Get("Dialog_Rules.ClearRestriction", voidPreset.Type.Categorization.ToLower()), () => _template.SetRestriction(type, voidPreset)));
            }
            list.AddRange(presets.Select(restriction => new FloatMenuOption(Lang.Get("Dialog_Rules.ChangeRestriction", restriction.Name.Bold()), () => _template.SetRestriction(type, restriction))));

            Find.WindowStack.Add(new FloatMenu(list));
        }
 public ItemFilter(RestrictionType restrictionType, FilterType filterType)
 {
     this.restrictionType = restrictionType;
     this.filterType      = filterType;
 }
Example #24
0
        /// <summary>
        /// Deserialized byte array to a Restriction instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public override uint Deserialize(byte[] buffer)
        {
            BufferReader bufferReader = new BufferReader(buffer);

            this.RestrictType  = (RestrictionType)bufferReader.ReadByte();
            this.restrictCount = (this.CountType == CountByte.TwoBytesCount) ? bufferReader.ReadUInt16() : bufferReader.ReadUInt32();
            int count = (this.CountType == CountByte.TwoBytesCount) ? (int)(ushort)this.RestrictCount : (int)(uint)this.RestrictCount;

            this.Restricts = new IRestriction[count];

            uint size = bufferReader.Position;

            byte[] tmpArray = bufferReader.ReadToEnd();
            for (int i = 0; i < count; i++)
            {
                RestrictionType restrictionType = (RestrictionType)tmpArray[0];
                switch (restrictionType)
                {
                case RestrictionType.AndRestriction:
                    this.Restricts[i] = new AndRestriction(this.CountType);
                    break;

                case RestrictionType.BitMaskRestriction:
                    this.Restricts[i] = new BitMaskRestriction();
                    break;

                case RestrictionType.CommentRestriction:
                    this.Restricts[i] = new CommentRestriction(this.CountType);
                    break;

                case RestrictionType.ComparePropertiesRestriction:
                    this.Restricts[i] = new ComparePropertiesRestriction();
                    break;

                case RestrictionType.ContentRestriction:
                    this.Restricts[i] = new ContentRestriction();
                    break;

                case RestrictionType.CountRestriction:
                    this.Restricts[i] = new CountRestriction(this.CountType);
                    break;

                case RestrictionType.ExistRestriction:
                    this.Restricts[i] = new ExistRestriction();
                    break;

                case RestrictionType.NotRestriction:
                    this.Restricts[i] = new NotRestriction(this.CountType);
                    break;

                case RestrictionType.OrRestriction:
                    this.Restricts[i] = new OrRestriction(this.CountType);
                    break;

                case RestrictionType.PropertyRestriction:
                    this.Restricts[i] = new PropertyRestriction();
                    break;

                case RestrictionType.SizeRestriction:
                    this.Restricts[i] = new SizeRestriction();
                    break;

                case RestrictionType.SubObjectRestriction:
                    this.Restricts[i] = new SubObjectRestriction(this.CountType);
                    break;
                }

                uint tmpLength = this.Restricts[i].Deserialize(tmpArray);
                size        += tmpLength;
                bufferReader = new BufferReader(tmpArray);
                tmpArray     = bufferReader.ReadBytes(tmpLength, (uint)(tmpArray.Length - tmpLength));
            }

            return(size);
        }
        /// <summary>
        /// The method searches the mailbox and returns the items that meet a specified search restriction.
        /// </summary>
        /// <param name="folder">A string that specifies the folder to search.</param>
        /// <param name="value">A string that specifies the value for a search restriction.</param>
        /// <returns>If the method succeeds, return an array of item; otherwise, return null.</returns>
        private ItemIdType[] GetItemIds(string folder, string value)
        {
            #region Construct FindItem request
            FindItemType findRequest = new FindItemType();

            if (string.IsNullOrEmpty(folder) || string.IsNullOrEmpty(value))
            {
                Site.Assert.Fail("Invalid argument: one or more invalid arguments passed to GetItemIds method.");
            }

            findRequest.ItemShape           = new ItemResponseShapeType();
            findRequest.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;

            DistinguishedFolderIdType     folderId = new DistinguishedFolderIdType();
            DistinguishedFolderIdNameType folderIdName;
            if (Enum.TryParse <DistinguishedFolderIdNameType>(folder, out folderIdName))
            {
                folderId.Id = folderIdName;
            }
            else
            {
                Site.Assert.Fail("The value of the first argument (foldIdNameType) of FindItem operation is invalid.");
            }

            findRequest.ParentFolderIds    = new BaseFolderIdType[1];
            findRequest.ParentFolderIds[0] = folderId;

            PathToUnindexedFieldType itemClass = new PathToUnindexedFieldType();
            itemClass.FieldURI = UnindexedFieldURIType.itemSubject;
            ContainsExpressionType expressionType = new ContainsExpressionType();
            expressionType.Item                           = itemClass;
            expressionType.ContainmentMode                = ContainmentModeType.Substring;
            expressionType.ContainmentModeSpecified       = true;
            expressionType.ContainmentComparison          = ContainmentComparisonType.IgnoreCaseAndNonSpacingCharacters;
            expressionType.ContainmentComparisonSpecified = true;
            expressionType.Constant                       = new ConstantValueType();
            expressionType.Constant.Value                 = value;

            RestrictionType restriction = new RestrictionType();
            restriction.Item = expressionType;

            findRequest.Restriction = restriction;
            #endregion

            #region Get the ids of all ItemId instances
            int counter    = 0;
            int upperBound = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));
            int waitTime   = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            FindItemResponseType findResponse = new FindItemResponseType();

            while (counter < upperBound)
            {
                Thread.Sleep(waitTime);

                findResponse = this.exchangeServiceBinding.FindItem(findRequest);
                if (findResponse != null &&
                    findResponse.ResponseMessages != null &&
                    findResponse.ResponseMessages.Items != null &&
                    findResponse.ResponseMessages.Items.Length > 0)
                {
                    ArrayOfRealItemsType items = ((FindItemResponseMessageType)findResponse.ResponseMessages.Items[0]).RootFolder.Item as ArrayOfRealItemsType;

                    if (items.Items != null && items.Items.Length > 0)
                    {
                        List <ItemIdType> itemIds = new List <ItemIdType>();
                        foreach (ItemType item in items.Items)
                        {
                            if (item.ItemId != null)
                            {
                                itemIds.Add(item.ItemId);
                            }
                        }

                        if (itemIds.Count > 0)
                        {
                            return(itemIds.ToArray());
                        }
                    }
                }

                counter++;
            }

            Site.Log.Add(LogEntryKind.Debug, "When there is not any message found by FindItem operation, the retry count is {0}", counter);
            return(null);

            #endregion
        }
 public SubscriptionRestrictionException(string p, RestrictionType type)
     : base(p)
 {
     this.TypeOfRestriction = type;
 }
Example #27
0
 public SignRestriction(string decisionVariable, RestrictionType restrictionType)
 {
     this.DecisionVariable = decisionVariable;
     this.RestrictionType  = restrictionType;
 }
    static FolderIdType FindFolder(ExchangeServiceBinding esb, DistinguishedFolderIdType fiFolderID, String fnFldName)
    {
        FolderIdType rvFolderID = new FolderIdType();

        // Create the request and specify the travesal type
        FindFolderType findFolderRequest = new FindFolderType();
        findFolderRequest.Traversal = FolderQueryTraversalType.Deep;

        // Define the properties returned in the response
        FolderResponseShapeType responseShape = new FolderResponseShapeType();
        responseShape.BaseShape = DefaultShapeNamesType.Default;
        findFolderRequest.FolderShape = responseShape;

        // Identify which folders to search
        DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
        folderIDArray[0] = new DistinguishedFolderIdType();
        folderIDArray[0].Id = fiFolderID.Id;

        //Add Restriction for DisplayName
        RestrictionType ffRestriction = new RestrictionType();
        IsEqualToType ieToType = new IsEqualToType();
        PathToUnindexedFieldType diDisplayName = new PathToUnindexedFieldType();
        diDisplayName.FieldURI = UnindexedFieldURIType.folderDisplayName;
        FieldURIOrConstantType ciConstantType = new FieldURIOrConstantType();
        ConstantValueType cvConstantValueType = new ConstantValueType();
        cvConstantValueType.Value = fnFldName;
        ciConstantType.Item = cvConstantValueType;
        ieToType.Item = diDisplayName;
        ieToType.FieldURIOrConstant = ciConstantType;
        ffRestriction.Item = ieToType;
        findFolderRequest.Restriction = ffRestriction;

        // Add the folders to search to the request
        findFolderRequest.ParentFolderIds = folderIDArray;

        try
        {
            // Send the request and get the response
            FindFolderResponseType findFolderResponse = esb.FindFolder(findFolderRequest);

            // Get the response messages
            ResponseMessageType[] rmta = findFolderResponse.ResponseMessages.Items;

            foreach (ResponseMessageType rmt in rmta)
            {
                // Cast to the correct response message type
                FindFolderResponseMessageType ffResponse = (FindFolderResponseMessageType)rmt;

                foreach (FolderType fFoundFolder in ffResponse.RootFolder.Folders)
                {
                    rvFolderID = fFoundFolder.FolderId;
                }
            }
        }
        catch (Exception e)
        {
            string problem = e.Message;
        }

        return rvFolderID;
    }
 public RestrictionSpecial(string productName, int purchaseQty,
                           bool isActive, int discountQty, float discountAmount, RestrictionType restrictionType)
 {
     this.ProductName     = productName;
     this.PurchaseQty     = purchaseQty;
     this.Type            = SpecialType.Restriction;
     this.IsActive        = isActive;
     this.DiscountQty     = discountQty;
     this.DiscountAmount  = discountAmount;
     this.RestrictionType = restrictionType;
 }
        /// <summary>
        /// Log on to a mailbox with a specified user account and create a search folder.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">Password of the user.</param>
        /// <param name="userDomain">Domain of the user.</param>
        /// <param name="searchFolderName">Name of the search folder.</param>
        /// <param name="searchText">Search text of the search folder.</param>
        /// <returns>If the search folder is created successfully, return true; otherwise, return false.</returns>
        public bool CreateSearchFolder(string userName, string userPassword, string userDomain, string searchFolderName, string searchText)
        {
            // Log on mailbox with specified user account(userName, userPassword, userDomain).
            bool isLoged = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site);

            Site.Assert.IsTrue(
                isLoged,
                string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain));

            // Create the request.
            CreateFolderType createFolder = new CreateFolderType();

            SearchFolderType[] folderArray  = new SearchFolderType[1];
            SearchFolderType   searchFolder = new SearchFolderType();

            // Use the following search filter to get all mail in the Inbox with the word searchText in the subject line.
            searchFolder.SearchParameters                    = new SearchParametersType();
            searchFolder.SearchParameters.Traversal          = SearchFolderTraversalType.Deep;
            searchFolder.SearchParameters.TraversalSpecified = true;
            searchFolder.SearchParameters.BaseFolderIds      = new DistinguishedFolderIdType[4];

            // Create a distinguished folder Identified of the inbox folder.
            DistinguishedFolderIdType inboxFolder = new DistinguishedFolderIdType();

            inboxFolder.Id = new DistinguishedFolderIdNameType();
            inboxFolder.Id = DistinguishedFolderIdNameType.inbox;
            searchFolder.SearchParameters.BaseFolderIds[0] = inboxFolder;
            DistinguishedFolderIdType contactType = new DistinguishedFolderIdType();

            contactType.Id = new DistinguishedFolderIdNameType();
            contactType.Id = DistinguishedFolderIdNameType.contacts;
            searchFolder.SearchParameters.BaseFolderIds[1] = contactType;
            DistinguishedFolderIdType calendarType = new DistinguishedFolderIdType();

            calendarType.Id = new DistinguishedFolderIdNameType();
            calendarType.Id = DistinguishedFolderIdNameType.calendar;
            searchFolder.SearchParameters.BaseFolderIds[2] = calendarType;
            DistinguishedFolderIdType taskType = new DistinguishedFolderIdType();

            taskType.Id = new DistinguishedFolderIdNameType();
            taskType.Id = DistinguishedFolderIdNameType.calendar;
            searchFolder.SearchParameters.BaseFolderIds[3] = taskType;

            // Use the following search filter.
            searchFolder.SearchParameters.Restriction = new RestrictionType();
            PathToUnindexedFieldType path = new PathToUnindexedFieldType();

            path.FieldURI = UnindexedFieldURIType.itemSubject;
            RestrictionType        restriction        = new RestrictionType();
            FieldURIOrConstantType fieldURIORConstant = new FieldURIOrConstantType();

            fieldURIORConstant.Item = new ConstantValueType();
            (fieldURIORConstant.Item as ConstantValueType).Value = searchText;
            ExistsType isEqual = new ExistsType();

            isEqual.Item     = path;
            restriction.Item = isEqual;
            searchFolder.SearchParameters.Restriction = restriction;

            // Give the search folder a unique name.
            searchFolder.DisplayName = searchFolderName;
            folderArray[0]           = searchFolder;

            // Create the search folder under the default Search Folder.
            TargetFolderIdType        targetFolder  = new TargetFolderIdType();
            DistinguishedFolderIdType searchFolders = new DistinguishedFolderIdType();

            searchFolders.Id            = DistinguishedFolderIdNameType.searchfolders;
            targetFolder.Item           = searchFolders;
            createFolder.ParentFolderId = targetFolder;
            createFolder.Folders        = folderArray;
            bool isSearchFolderCreated = false;

            // Invoke CreateFolder operation and get the response.
            CreateFolderResponseType response = this.exchangeServiceBinding.CreateFolder(createFolder);

            if (response != null && ResponseClassType.Success == response.ResponseMessages.Items[0].ResponseClass)
            {
                // If the search folder is created successfully, return true; otherwise, return false.
                isSearchFolderCreated = true;

                searchFolder.FolderId = ((FolderInfoResponseMessageType)response.ResponseMessages.Items[0]).Folders[0].FolderId;
                AdapterHelper.CreatedFolders.Add(searchFolder);
            }

            return(isSearchFolderCreated);
        }
 public InventoryItemFilter(RestrictionType restrictionType, FilterType filterType)
 {
     this.restrictionType = restrictionType;
     this.filterType = filterType;
 }
Example #32
0
        /// <summary>
        /// Deserialized byte array to an ExtendedRuleCondition instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            this.NamedPropertyInformation = new NamedPropertyInfo();
            uint         namedPropInfoLength = this.NamedPropertyInformation.Deserialize(buffer);
            BufferReader bufferReader        = new BufferReader(buffer);

            byte[]          tmpArray        = bufferReader.ReadBytes(namedPropInfoLength, (uint)(buffer.Length - namedPropInfoLength));
            RestrictionType restrictionType = (RestrictionType)tmpArray[0];

            switch (restrictionType)
            {
            case RestrictionType.AndRestriction:
                this.RuleRestriction = new AndRestriction(this.CountType);
                break;

            case RestrictionType.BitMaskRestriction:
                this.RuleRestriction = new BitMaskRestriction();
                break;

            case RestrictionType.CommentRestriction:
                this.RuleRestriction = new CommentRestriction(this.CountType);
                break;

            case RestrictionType.ComparePropertiesRestriction:
                this.RuleRestriction = new ComparePropertiesRestriction();
                break;

            case RestrictionType.ContentRestriction:
                this.RuleRestriction = new ContentRestriction();
                break;

            case RestrictionType.CountRestriction:
                this.RuleRestriction = new CountRestriction(this.CountType);
                break;

            case RestrictionType.ExistRestriction:
                this.RuleRestriction = new ExistRestriction();
                break;

            case RestrictionType.NotRestriction:
                this.RuleRestriction = new NotRestriction(this.CountType);
                break;

            case RestrictionType.OrRestriction:
                this.RuleRestriction = new OrRestriction(this.CountType);
                break;

            case RestrictionType.PropertyRestriction:
                this.RuleRestriction = new PropertyRestriction();
                break;

            case RestrictionType.SizeRestriction:
                this.RuleRestriction = new SizeRestriction();
                break;

            case RestrictionType.SubObjectRestriction:
                this.RuleRestriction = new SubObjectRestriction(this.CountType);
                break;
            }

            uint totalLength = this.RuleRestriction.Deserialize(tmpArray);

            totalLength += namedPropInfoLength;
            return(totalLength);
        }
Example #33
0
 public ControllerFilter(RestrictionType type, IEnumerable <Type> controllers)
 {
     _type        = type;
     _controllers = controllers.Select(c => c.GetTypeInfo());
 }
Example #34
0
 public static void Open(RestrictionType type, Rules rules) => Find.WindowStack.Add(new Dialog_Restrictions(type, rules));
 public GossipRestrictAttribute(RestrictionType type, Item item, bool forceClear = false)
 {
     Type       = type;
     Item       = item;
     ForceClear = forceClear;
 }
        /// <summary>
        /// Deserialized byte array to a Restriction instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public override uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);

            this.RestrictType = (RestrictionType)reader.ReadByte();
            this.Count        = reader.ReadUInt32();

            uint size = reader.Position;

            byte[] tmpArray = reader.ReadToEnd();

            RestrictionType restrictionType = (RestrictionType)tmpArray[0];

            switch (restrictionType)
            {
            case RestrictionType.AndRestriction:
                this.SubRestriction = new AndRestriction(this.CountType);
                break;

            case RestrictionType.BitMaskRestriction:
                this.SubRestriction = new BitMaskRestriction();
                break;

            case RestrictionType.CommentRestriction:
                this.SubRestriction = new CommentRestriction(this.CountType);
                break;

            case RestrictionType.ComparePropertiesRestriction:
                this.SubRestriction = new ComparePropertiesRestriction();
                break;

            case RestrictionType.ContentRestriction:
                this.SubRestriction = new ContentRestriction();
                break;

            case RestrictionType.CountRestriction:
                this.SubRestriction = new CountRestriction(this.CountType);
                break;

            case RestrictionType.ExistRestriction:
                this.SubRestriction = new ExistRestriction();
                break;

            case RestrictionType.NotRestriction:
                this.SubRestriction = new NotRestriction(this.CountType);
                break;

            case RestrictionType.OrRestriction:
                this.SubRestriction = new OrRestriction(this.CountType);
                break;

            case RestrictionType.PropertyRestriction:
                this.SubRestriction = new PropertyRestriction();
                break;

            case RestrictionType.SizeRestriction:
                this.SubRestriction = new SizeRestriction();
                break;

            case RestrictionType.SubObjectRestriction:
                this.SubRestriction = new SubObjectRestriction(this.CountType);
                break;
            }

            size += this.SubRestriction.Deserialize(tmpArray);

            return(size);
        }
Example #37
0
        public AdminAuditLogEvent[] Search()
        {
            TaskLogger.LogEnter();
            TaskLogger.Trace("Search criteria:\\r\\n{0}", new object[]
            {
                this.searchCriteria.ToString()
            });
            if (DatacenterRegistry.IsForefrontForOffice())
            {
                return(this.SearchInFFO());
            }
            ADUser tenantArbitrationMailbox;

            try
            {
                tenantArbitrationMailbox = AdminAuditLogHelper.GetTenantArbitrationMailbox(this.searchCriteria.OrganizationId);
            }
            catch (ObjectNotFoundException innerException)
            {
                TaskLogger.Trace("ObjectNotFoundException occurred when getting Exchange principal from the discovery mailbox user.", new object[0]);
                throw new AdminAuditLogSearchException(Strings.AdminAuditLogsLocationNotFound(this.searchCriteria.OrganizationId.ToString()), innerException);
            }
            catch (NonUniqueRecipientException innerException2)
            {
                TaskLogger.Trace("More than one tenant arbitration mailbox found for the current organization.", new object[0]);
                throw new AdminAuditLogSearchException(Strings.AdminAuditLogsLocationNotFound(this.searchCriteria.OrganizationId.ToString()), innerException2);
            }
            Exception         ex        = null;
            ExchangePrincipal principal = ExchangePrincipal.FromADUser(this.searchCriteria.OrganizationId.ToADSessionSettings(), tenantArbitrationMailbox, RemotingOptions.AllowCrossSite);

            AdminAuditLogEvent[] result;
            try
            {
                TaskLogger.Trace("Opening EWS connection for the tenant arbitration mailbox", new object[0]);
                EwsAuditClient ewsAuditClient = new EwsAuditClient(new EwsConnectionManager(principal, OpenAsAdminOrSystemServiceBudgetTypeType.Default, AdminAuditLogSearchWorker.Tracer), TimeSpan.FromSeconds((double)this.searchTimeoutSeconds), AdminAuditLogSearchWorker.Tracer);
                FolderIdType   folderIdType   = null;
                ewsAuditClient.CheckAndCreateWellKnownFolder(DistinguishedFolderIdNameType.root, DistinguishedFolderIdNameType.recoverableitemsroot, out folderIdType);
                ewsAuditClient.CheckAndCreateWellKnownFolder(DistinguishedFolderIdNameType.recoverableitemsroot, DistinguishedFolderIdNameType.adminauditlogs, out folderIdType);
                if (folderIdType == null)
                {
                    result = Array <AdminAuditLogEvent> .Empty;
                }
                else
                {
                    EwsAuditLogCollection            logCollection    = new EwsAuditLogCollection(ewsAuditClient, folderIdType);
                    AuditLogSearchId                 auditLogSearchId = this.searchCriteria.Identity as AuditLogSearchId;
                    IEnumerable <AdminAuditLogEvent> source;
                    if (this.UseFASTQuery())
                    {
                        QueryStringType queryFilter = this.GenerateFASTSearchQueryString();
                        source = AuditLogSearchQuery.SearchAuditLogs <AdminAuditLogEvent, QueryStringType>(logCollection, queryFilter, this.searchCriteria.ResultSize + this.searchCriteria.StartIndex, TimeSpan.FromSeconds((double)this.searchTimeoutSeconds), new AdminAuditLogSearchWorker.QueryStrategy(this.searchCriteria), AdminAuditLogSearchWorker.Tracer);
                    }
                    else
                    {
                        RestrictionType queryFilter2 = this.GenerateSearchQueryFilterForEWS();
                        source = AuditLogSearchQuery.SearchAuditLogs <AdminAuditLogEvent, RestrictionType>(logCollection, queryFilter2, this.searchCriteria.ResultSize + this.searchCriteria.StartIndex, TimeSpan.FromSeconds((double)this.searchTimeoutSeconds), new AdminAuditLogSearchWorker.QueryStrategy(this.searchCriteria), AdminAuditLogSearchWorker.Tracer);
                    }
                    if (this.searchStatistics != null)
                    {
                        this.searchStatistics.QueryComplexity = this.searchCriteria.QueryComplexity;
                        this.searchStatistics.CorrelationID   = ((auditLogSearchId != null) ? auditLogSearchId.Guid.ToString() : string.Empty);
                    }
                    AdminAuditLogEvent[] array = source.Take(this.searchCriteria.ResultSize).ToArray <AdminAuditLogEvent>();
                    this.RedactCallerField(array);
                    if (this.searchStatistics != null)
                    {
                        this.searchStatistics.ResultsReturned += array.LongLength;
                        this.searchStatistics.CallResult       = true;
                    }
                    result = array;
                }
            }
            catch (StorageTransientException ex2)
            {
                ex = ex2;
                TaskLogger.Trace("Search admin audit log failed with transient storage exception. {0}", new object[]
                {
                    ex2
                });
                throw new AdminAuditLogSearchException(Strings.AdminAuditLogSearchFailed, ex2, this.searchCriteria);
            }
            catch (StoragePermanentException ex3)
            {
                ex = ex3;
                TaskLogger.Trace("Search admin audit log failed with permanent storage exception. {0}", new object[]
                {
                    ex3
                });
                throw new AdminAuditLogSearchException(Strings.AdminAuditLogSearchFailed, ex3, this.searchCriteria);
            }
            catch (AuditLogException ex4)
            {
                ex = ex4;
                TaskLogger.Trace("Search admin audit log failed with storage exception. {0}", new object[]
                {
                    ex4
                });
                throw new AdminAuditLogSearchException(Strings.AdminAuditLogSearchFailed, ex4, this.searchCriteria);
            }
            finally
            {
                if (this.searchStatistics != null && ex != null)
                {
                    this.searchStatistics.ErrorType = ex;
                    this.searchStatistics.ErrorCount++;
                }
                TaskLogger.LogExit();
            }
            return(result);
        }
                public RestrictionSpecification(int titleID,string property, RestrictionType type)
                {
                    this.titleID = titleID;
                    this.type = type;
                    this.property = property;

                    StartTime = EndTime = DateTime.Today;
                }
Example #39
0
        private RestrictionType GenerateSearchQueryFilterForEWS()
        {
            TaskLogger.LogEnter();
            RestrictionType result;

            try
            {
                List <SearchExpressionType> list = new List <SearchExpressionType>();
                int num = 0;
                if (this.searchCriteria.StartDateUtc != null)
                {
                    ExDateTime exDateTime = new ExDateTime(ExTimeZone.UtcTimeZone, this.searchCriteria.StartDateUtc.Value);
                    list.Add(new IsGreaterThanOrEqualToType
                    {
                        Item = new PathToUnindexedFieldType
                        {
                            FieldURI = UnindexedFieldURIType.itemDateTimeReceived
                        },
                        FieldURIOrConstant = new FieldURIOrConstantType
                        {
                            Item = new ConstantValueType
                            {
                                Value = exDateTime.ToISOString()
                            }
                        }
                    });
                    num++;
                }
                if (this.searchCriteria.EndDateUtc != null)
                {
                    ExDateTime exDateTime2 = new ExDateTime(ExTimeZone.UtcTimeZone, this.searchCriteria.EndDateUtc.Value);
                    list.Add(new IsLessThanType
                    {
                        Item = new PathToUnindexedFieldType
                        {
                            FieldURI = UnindexedFieldURIType.itemDateTimeReceived
                        },
                        FieldURIOrConstant = new FieldURIOrConstantType
                        {
                            Item = new ConstantValueType
                            {
                                Value = exDateTime2.ToISOString()
                            }
                        }
                    });
                    num++;
                }
                this.searchCriteria.QueryComplexity = num;
                if (list.Count > 0)
                {
                    result = new RestrictionType
                    {
                        Item = new AndType
                        {
                            Items = list.ToArray()
                        }
                    };
                }
                else
                {
                    result = null;
                }
            }
            finally
            {
                TaskLogger.LogExit();
            }
            return(result);
        }
 internal void AddArray(WsdlGenerator.SchemaAttribute attribute)
 {
     this._rtype = RestrictionType.Array;
     this._attribute = attribute;
 }
Example #41
0
        /// <summary>
        /// Deserialized byte array to a Restriction instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public override uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);

            this.RestrictType      = (RestrictionType)reader.ReadByte();
            this.TaggedValuesCount = reader.ReadByte();
            this.TaggedValues      = new TaggedPropertyValue[this.TaggedValuesCount];
            uint size = reader.Position;

            byte[] tmpArray = reader.ReadToEnd();
            for (int i = 0; i < this.TaggedValuesCount; i++)
            {
                this.TaggedValues[i] = AdapterHelper.ReadTaggedProperty(tmpArray);
                uint tagLength = (uint)this.TaggedValues[i].Size();
                size    += tagLength;
                reader   = new BufferReader(tmpArray);
                tmpArray = reader.ReadBytes(tagLength, (uint)(tmpArray.Length - tagLength));
            }

            reader = new BufferReader(buffer);
            reader.ReadBytes(size);
            this.RestrictionPresent = reader.ReadByte();
            size    += reader.Position;
            tmpArray = reader.ReadToEnd();
            if (this.RestrictionPresent == 0x01)
            {
                RestrictionType restrictionType = (RestrictionType)tmpArray[0];
                switch (restrictionType)
                {
                case RestrictionType.AndRestriction:
                    this.Restriction = new AndRestriction(CountType);
                    break;

                case RestrictionType.BitMaskRestriction:
                    this.Restriction = new BitMaskRestriction();
                    break;

                case RestrictionType.CommentRestriction:
                    this.Restriction = new CommentRestriction(CountType);
                    break;

                case RestrictionType.ComparePropertiesRestriction:
                    this.Restriction = new ComparePropertiesRestriction();
                    break;

                case RestrictionType.ContentRestriction:
                    this.Restriction = new ContentRestriction();
                    break;

                case RestrictionType.CountRestriction:
                    this.Restriction = new CountRestriction(CountType);
                    break;

                case RestrictionType.ExistRestriction:
                    this.Restriction = new ExistRestriction();
                    break;

                case RestrictionType.NotRestriction:
                    this.Restriction = new NotRestriction(CountType);
                    break;

                case RestrictionType.OrRestriction:
                    this.Restriction = new OrRestriction(CountType);
                    break;

                case RestrictionType.PropertyRestriction:
                    this.Restriction = new PropertyRestriction();
                    break;

                case RestrictionType.SizeRestriction:
                    this.Restriction = new SizeRestriction();
                    break;

                case RestrictionType.SubObjectRestriction:
                    this.Restriction = new SubObjectRestriction(CountType);
                    break;
                }

                size += this.Restriction.Deserialize(tmpArray);
            }

            return(size);
        }