Ejemplo n.º 1
0
 public ItemRange(ItemRange copy) : this(NDalicPINVOKE.new_ItemRange__SWIG_1(ItemRange.getCPtr(copy)), true)
 {
     if (NDalicPINVOKE.SWIGPendingException.Pending)
     {
         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 2
0
        private void OnLongPressGestureDetected(object source, LongPressGestureDetector.DetectedEventArgs e)
        {
            switch (e.LongPressGesture.State)
            {
            case Gesture.StateType.Started:
            {
                Size      windowSize = NUIApplication.GetDefaultWindow().Size;
                ItemRange range      = new ItemRange(0, 0);
                mItemView.GetItemsRange(range);

                uint item = (e.LongPressGesture.ScreenPoint.Y < 0.5f * (float)windowSize.Height) ? range.begin : range.end;

                mItemView.ScrollToItem(item, SCROLL_TO_ITEM_ANIMATION_TIME);

                break;
            }

            case Gesture.StateType.Finished:
            {
                PropertyMap attributes = new PropertyMap();
                mItemView.DoAction("stopScrolling", attributes);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Ejemplo n.º 3
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var request = controllerContext.HttpContext.Request;
            var queryPropertiesDictionary = request.QueryString;

            try
            {
                return(new Query
                {
                    OldPattern = queryPropertiesDictionary["oldPattern"],
                    NewPattern = queryPropertiesDictionary["newPattern"],
                    ContentId = Parser.ParseContentIdNullable(queryPropertiesDictionary["contentId"]),
                    RedirectType = Parser.ParseRedirectTypeNullable(queryPropertiesDictionary["redirectType"]),
                    RedirectRuleType = Parser.ParseRedirectRuleTypeNullable(queryPropertiesDictionary["redirectRuleType"]),
                    RedirectOrigin = Parser.ParseRedirectOriginNullable(queryPropertiesDictionary["redirectOrigin"]),
                    IsActive = Parser.ParseNullableBoolean(queryPropertiesDictionary["isActive"]),
                    CreatedOnFrom = Parser.ParseCreatedOnFrom(queryPropertiesDictionary["createdOnFrom"]),
                    CreatedOnTo = Parser.ParseCreatedOnTo(queryPropertiesDictionary["createdOnTo"]),
                    CreatedBy = queryPropertiesDictionary["createdBy"],
                    Notes = queryPropertiesDictionary["notes"],
                    Priority = Parser.ParsePriorityNullable(queryPropertiesDictionary["priority"]),
                    SortColumns = Parser.ParseSortColumns(queryPropertiesDictionary.ToString()),
                    Range = ItemRange.ReadHeaderFrom(request)
                });
            }
            catch
            {
                throw new Exception("Failed to parse query string from http request");
            }
        }
Ejemplo n.º 4
0
        public void ItemViewGetItemsRange()
        {
            tlog.Debug(tag, $"ItemViewGetItemsRange START");

            using (ItemFactory factory = new ItemFactory())
            {
                var testingTarget = new ItemView(factory);
                Assert.IsNotNull(testingTarget, "Should be not null!");
                Assert.IsInstanceOf <ItemView>(testingTarget, "Should be an Instance of ItemView!");

                try
                {
                    using (ItemRange range = new ItemRange(0, 300))
                    {
                        testingTarget.GetItemsRange(range);
                    }
                }
                catch (Exception e)
                {
                    tlog.Debug(tag, e.Message.ToString());
                    Assert.Fail("Caught Exception: Failed!");
                }

                testingTarget.Dispose();
            }

            tlog.Debug(tag, $"ItemViewGetItemsRange END (OK)");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Logs out current user
        /// </summary>
        /// <exception cref="AlertMedia.CodeGen.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="itemRange">item-range pagination</param>
        /// <returns>ApiResponse of Object(void)</returns>
        public ApiResponse <Object> LogoutWithHttpInfo(ItemRange itemRange = null)
        {
            var    localVarPath         = "/logout";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
            };
            String localVarHttpContentType    = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }
            if (itemRange != null)
            {
                localVarHeaderParams.Add("Range", itemRange.ToHeader());
            }


            // authentication (basicAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
            {
                localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("Logout", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            null));
        }
Ejemplo n.º 6
0
        public ItemRange Assign(ItemRange range)
        {
            ItemRange ret = new ItemRange(NDalicPINVOKE.ItemRange_Assign(swigCPtr, ItemRange.getCPtr(range)), false);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 7
0
        public ItemRange Intersection(ItemRange second)
        {
            ItemRange ret = new ItemRange(NDalicPINVOKE.ItemRange_Intersection(swigCPtr, ItemRange.getCPtr(second)), true);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 8
0
        public override QueryRange <IContent> ExecuteQuery(IQueryParameters parameters)
        {
            var contentQueryParam = parameters as ContentQueryParameters;

            var searchRequest = SearchClient.Search <TContent>();

            var searchPhrase     = parameters.AllParameters["q"];
            var hasFreeTextQuery = !string.IsNullOrWhiteSpace(searchPhrase) && searchPhrase != "*";

            if (hasFreeTextQuery)
            {
                searchRequest = ApplyTextSearch(searchRequest, searchPhrase);
            }

            searchRequest = searchRequest.Filter(x => !x.MatchTypeHierarchy(typeof(ILocalizable)) | ((ILocalizable)x).Language.Name.Match(contentQueryParam.PreferredCulture.Name));

            searchRequest = Filter(searchRequest, contentQueryParam);

            searchRequest = ApplyVisibilityFilter(searchRequest);

            if (contentQueryParam.SortColumns != null && contentQueryParam.SortColumns.Any())
            {
                var sortColumn = contentQueryParam.SortColumns.FirstOrDefault();
                searchRequest = ApplySorting(searchRequest, sortColumn);
            }

            if (parameters.Range.Start.HasValue && parameters.Range.End.HasValue)
            {
                searchRequest = searchRequest
                                .Skip(parameters.Range.Start.Value)
                                .Take(parameters.Range.End.Value);
            }

            try
            {
                var result = searchRequest.GetContentResult();

                var itemRange = new ItemRange
                {
                    Total = result.TotalMatching,
                    Start = parameters.Range.Start,
                    End   = parameters.Range.End
                };
                var contentRange = new ContentRange(result.OfType <IContent>(), itemRange);
                return(contentRange);
            }
            catch
            {
                return(new ContentRange(Enumerable.Empty <IContent>(), new ItemRange {
                    Total = 0, Start = 0, End = 0
                }));
            }
        }
Ejemplo n.º 9
0
        public void ItemRangeConstructor()
        {
            tlog.Debug(tag, $"ItemRangeConstructor START");

            var testingTarget = new ItemRange(0, 300);

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <ItemRange>(testingTarget, "Should be an Instance of ItemRange!");

            testingTarget.Dispose();

            tlog.Debug(tag, $"ItemRangeConstructor END (OK)");
        }
Ejemplo n.º 10
0
        public override QueryRange <IContent> ExecuteQuery(IQueryParameters parameters)
        {
            var originalContentRange = base.ExecuteQuery(parameters);
            var filteredResults      = originalContentRange.Items.Where(IsNotReferenced).ToList();

            var itemRange = new ItemRange
            {
                Total = filteredResults.Count,
                Start = parameters.Range.Start,
                End   = parameters.Range.End
            };

            return(new ContentRange(filteredResults, itemRange));
        }
Ejemplo n.º 11
0
        public virtual ActionResult Get(int?id, ItemRange range, IEnumerable <SortColumn> sortColumns)
        {
            // If there is no id then return all the projects within the given range.
            if (!id.HasValue)
            {
                // Load all the items in order to apply sorting.
                var result   = _projectRepository.List(0, int.MaxValue, out var totalCount);
                var projects = result.Select(_viewModelConverter.ToViewModel).ToList();
                AddExtendedFields(projects);

                if (sortColumns != null)
                {
                    projects = projects.AsQueryable().OrderBy(sortColumns).ToList();
                }

                if (_projectOptions.ShowVisibleTo)
                {
                    var currentUser      = PrincipalInfo.CurrentPrincipal.Identity.Name;
                    var currentUserRoles = _roleProvider.GetRolesForUser(currentUser).ToList();
                    projects = projects.Where(x => IsProjectAvailable(x, currentUser, currentUserRoles)).ToList();
                }

                return(Rest(projects, range));
            }

            // Otherwise get the project by id.
            var project = _projectRepository.Get(id.Value);

            if (project == null)
            {
                // Return a 404 if no project exists for the given id.
                return(new RestStatusCodeResult(HttpStatusCode.NotFound));
            }

            var extendedProjectViewModel = _viewModelConverter.ToViewModel(project);

            AddExtendedFields(extendedProjectViewModel);
            if (_projectOptions.ShowVisibleTo)
            {
                var currentUser      = PrincipalInfo.CurrentPrincipal.Identity.Name;
                var currentUserRoles = _roleProvider.GetRolesForUser(currentUser).ToList();
                if (!IsProjectAvailable(extendedProjectViewModel, currentUser, currentUserRoles))
                {
                    return(new RestStatusCodeResult(HttpStatusCode.Forbidden));
                }
            }

            return(Rest(extendedProjectViewModel));
        }
Ejemplo n.º 12
0
        public void ItemRangeConstructorWithItemRange()
        {
            tlog.Debug(tag, $"ItemRangeConstructorWithItemRange START");

            using (ItemRange copy = new ItemRange(0, 300))
            {
                var testingTarget = new ItemRange(copy);
                Assert.IsNotNull(testingTarget, "Should be not null!");
                Assert.IsInstanceOf <ItemRange>(testingTarget, "Should be an Instance of ItemRange!");

                testingTarget.Dispose();
            }

            tlog.Debug(tag, $"ItemRangeConstructorWithItemRange END (OK)");
        }
Ejemplo n.º 13
0
        public void ItemRangeWithin()
        {
            tlog.Debug(tag, $"ItemRangeWithin START");

            var testingTarget = new ItemRange(0, 300);

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <ItemRange>(testingTarget, "Should be an Instance of ItemRange!");

            var result = testingTarget.Within(50);

            Assert.IsTrue(result);

            testingTarget.Dispose();
            tlog.Debug(tag, $"ItemRangeWithin END (OK)");
        }
Ejemplo n.º 14
0
        public void ItemRangeBegin()
        {
            tlog.Debug(tag, $"ItemRangeBegin START");

            var testingTarget = new ItemRange(0, 300);

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <ItemRange>(testingTarget, "Should be an Instance of ItemRange!");

            Assert.AreEqual(0, testingTarget.begin, "Should be equal!");
            testingTarget.begin = 100;
            Assert.AreEqual(100, testingTarget.begin, "Should be equal!");

            testingTarget.Dispose();

            tlog.Debug(tag, $"ItemRangeBegin END (OK)");
        }
Ejemplo n.º 15
0
        public void ItemRangeEnd()
        {
            tlog.Debug(tag, $"ItemRangeEnd START");

            var testingTarget = new ItemRange(0, 300);

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <ItemRange>(testingTarget, "Should be an Instance of ItemRange!");

            Assert.AreEqual(300, testingTarget.end, "Should be equal!");
            testingTarget.end = 500;
            Assert.AreEqual(500, testingTarget.end, "Should be equal!");

            testingTarget.Dispose();

            tlog.Debug(tag, $"ItemRangeEnd END (OK)");
        }
Ejemplo n.º 16
0
        public void ItemRangeAssign()
        {
            tlog.Debug(tag, $"ItemRangeAssign START");

            using (ItemRange range = new ItemRange(0, 300))
            {
                using (ItemRange copy = new ItemRange(range))
                {
                    var testingTarget = range.Assign(copy);
                    Assert.IsNotNull(testingTarget, "Should be not null!");
                    Assert.IsInstanceOf <ItemRange>(testingTarget, "Should be an Instance of ItemRange!");

                    testingTarget.Dispose();
                }
            }

            tlog.Debug(tag, $"ItemRangeAssign END (OK)");
        }
Ejemplo n.º 17
0
        public RestResult Get(int?id, ItemRange range)
        {
            if (id.HasValue)
            {
                string   result      = "";
                PageData currentPage = EPiServer.DataFactory.Instance.GetPage(new PageReference(id.Value));
                var      pageId      = currentPage.ContentLink.ID;
                var      _rules      = new List <Rule>();
                int      cnt         = 0;

                List <Rule> _rulesLeft  = RuleEngine.Instance.GetRulesLeft(pageId) as List <Rule>;
                List <Rule> _rulesRight = RuleEngine.Instance.GetRulesRight(pageId) as List <Rule>;

                foreach (Rule rule in _rulesLeft)
                {
                    if (rule.RuleTextLeft != rule.RuleTextRight)
                    {
                        result += "<b>" + rule.RuleTextLeft + "</b><br/>";
                        List <int> relations = RelationEngine.Instance.GetRelationPagesForPage(pageId, rule);
                        foreach (int pgid in relations)
                        {
                            result += "- " + EPiServer.DataFactory.Instance.GetPage(new PageReference(pgid)).Name +
                                      "<br/>";
                            cnt++;
                        }
                    }
                }

                foreach (Rule rule in _rulesRight)
                {
                    result += "<b>" + rule.RuleTextRight + "</b><br/>";
                    List <int> relations = RelationEngine.Instance.GetRelationPagesForPage(pageId, rule);
                    foreach (int pgid in relations)
                    {
                        result += "- " + EPiServer.DataFactory.Instance.GetPage(new PageReference(pgid)).Name + "<br/>";
                        cnt++;
                    }
                }
                result = "Number of relations: " + cnt + "<br/><br/>" + result;

                return(Rest(result));
            }
            return(null);
        }
Ejemplo n.º 18
0
        public void ItemRangeIntersection()
        {
            tlog.Debug(tag, $"ItemRangeIntersection START");

            var testingTarget = new ItemRange(0, 300);

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <ItemRange>(testingTarget, "Should be an Instance of ItemRange!");

            using (ItemRange second = new ItemRange(300, 500))
            {
                var result = testingTarget.Intersection(second);
                Assert.IsNotNull(result, "Should be not null!");
                Assert.IsInstanceOf <ItemRange>(result, "Should be an Instance of ItemRange!");
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"ItemRangeIntersection END (OK)");
        }
Ejemplo n.º 19
0
        public RestResult Get(
            ContentReference id,
            string query,
            ContentReference referenceId,
            IEnumerable <SortColumn> sortColumns,
            ItemRange range)
        {
            var queryParameters = new ContentQueryParameters
            {
                ReferenceId      = referenceId,
                SortColumns      = sortColumns,
                Range            = range,
                AllParameters    = ControllerContext.HttpContext.Request.QueryString,
                CurrentPrincipal = PrincipalInfo.CurrentPrincipal,
            };

            var filterOptions = _facetService.GetItems(queryParameters).ToList();

            return(Rest(filterOptions));
        }
        public static Dictionary <string, List <ItemRange> > MergeRange(List <CnMOPsItem> data)
        {
            GenomeUtils.SortChromosome(data, m => m.Seqname, m => m.Start);

            Dictionary <string, List <ItemRange> > result = new Dictionary <string, List <ItemRange> >();

            foreach (var d in data)
            {
                if (!result.ContainsKey(d.Seqname))
                {
                    result[d.Seqname] = new List <ItemRange>();
                }

                var ranges = result[d.Seqname];

                bool bFound = false;
                foreach (var range in ranges)
                {
                    if (range.Overlap(d, 0))
                    {
                        range.Items.Add(d);
                        range.Start = Math.Min(range.Start, d.Start);
                        range.End   = Math.Max(range.End, d.End);
                        bFound      = true;
                        break;
                    }
                }

                if (!bFound)
                {
                    var range = new ItemRange();
                    range.Items.Add(d);
                    range.Seqname = d.Seqname;
                    range.Start   = d.Start;
                    range.End     = d.End;
                    ranges.Add(range);
                }
            }

            return(result);
        }
        public static int[] CountSubarrays(int[] arr)
        {
            var subarrayRanges = new ItemRange[arr.Length]; //time: O(N*f(N)); memory: O(N)

            for (int i = 0; i < arr.Length; i++)            //actual f(N) is on average....?
            {
                subarrayRanges[i] = new ItemRange()
                {
                    Index = i,
                    Item  = arr[i],
                    Start = GetSubarrayStart(arr, i, subarrayRanges)
                };
            }

            for (int i = arr.Length - 1; i >= 0; i--)
            {
                subarrayRanges[i].End = GetSubarrayEnd(arr, i, subarrayRanges);
            }

            return(subarrayRanges.Select(range => range.SubArrayCount).ToArray());
        }
Ejemplo n.º 22
0
        private void CommitBatch(ItemRange range)
        {
            var  newHeadIndex = range.HeadIndex + range.ItemCount;
            long oldHeadIndex;

            lock (_lockObject)
            {
                // Update meta data
                oldHeadIndex = _metaData.HeadIndex;
                if (newHeadIndex > oldHeadIndex)
                {
                    _metaData.HeadIndex = newHeadIndex;
                }

                PersistMetaData();
            }

            if (newHeadIndex > oldHeadIndex)
            {
                var lastHeadIndex        = GetPreviousIndex(oldHeadIndex);
                var lastWrittenIndex     = GetPreviousIndex(newHeadIndex);
                var oldHeadIndexItem     = GetIndexItem(lastHeadIndex);
                var lastWrittenIndexItem = GetIndexItem(lastWrittenIndex);

                for (var dataPageIndex = oldHeadIndexItem.DataPageIndex;
                     dataPageIndex < lastWrittenIndexItem.DataPageIndex;
                     dataPageIndex++)
                {
                    _dataPageFactory.DeletePage(dataPageIndex);
                }

                for (var indexPageIndex = GetIndexPageIndex(lastHeadIndex);
                     indexPageIndex < GetIndexPageIndex(lastWrittenIndex);
                     indexPageIndex++)
                {
                    _indexPageFactory.DeletePage(indexPageIndex);
                }
            }
        }
Ejemplo n.º 23
0
        public virtual ContentRange ExecuteQuery(ContentQueryParameters parameters)
        {
            var searchRequest = SearchClient.Search <TContent>()
                                .FilterOnLanguages(new [] { parameters.PreferredCulture.Name });

            var searchPhrase     = parameters.AllParameters["q"];
            var hasFreeTextQuery = !string.IsNullOrWhiteSpace(searchPhrase) && searchPhrase != "*";

            if (hasFreeTextQuery)
            {
                searchRequest = ApplyTextSearch(searchRequest, searchPhrase);
            }

            searchRequest = Filter(searchRequest, parameters);

            searchRequest = ApplyVisibilityFilter(searchRequest);

            if (parameters.SortColumns != null && parameters.SortColumns.Any())
            {
                var sortColumn = parameters.SortColumns.FirstOrDefault();
                searchRequest = ApplySorting(searchRequest, sortColumn);
            }

            var result = searchRequest
                         .Skip(parameters.Range.Start)
                         .Take(parameters.Range.End)
                         .GetContentResult(CacheForSeconds, true);

            var itemRange = new ItemRange
            {
                Total = result.TotalMatching,
                Start = parameters.Range.Start,
                End   = parameters.Range.End
            };
            var contentRange = new ContentRange(result.OfType <IContent>(), itemRange);

            return(contentRange);
        }
Ejemplo n.º 24
0
    public static Dictionary<string, List<ItemRange>> MergeRange(List<CnMOPsItem> data)
    {
      GenomeUtils.SortChromosome(data, m => m.Seqname, m => m.Start);

      Dictionary<string, List<ItemRange>> result = new Dictionary<string, List<ItemRange>>();
      foreach (var d in data)
      {
        if (!result.ContainsKey(d.Seqname))
        {
          result[d.Seqname] = new List<ItemRange>();
        }

        var ranges = result[d.Seqname];

        bool bFound = false;
        foreach (var range in ranges)
        {
          if (range.Overlap(d, 0))
          {
            range.Items.Add(d);
            range.Start = Math.Min(range.Start, d.Start);
            range.End = Math.Max(range.End, d.End);
            bFound = true;
            break;
          }
        }

        if (!bFound)
        {
          var range = new ItemRange();
          range.Items.Add(d);
          range.Seqname = d.Seqname;
          range.Start = d.Start;
          range.End = d.End;
          ranges.Add(range);
        }
      }

      return result;
    }
Ejemplo n.º 25
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ItemRange obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Ejemplo n.º 26
0
        public RestResult Get(int?id, ItemRange range)
        {
            // When requesting a specific item we return that item; otherwise return all items.

            return(Rest("Hello world!"));
        }
Ejemplo n.º 27
0
        public RestResult Get(int?id, ItemRange range)
        {
            if (id.HasValue)
            {
                ContentReference currentContentRef = new PageReference(id.Value);
                if (new ContentReference(id.Value) != null && EPiServer.DataFactory.Instance.Get <IContent>(new ContentReference(id.Value)) as PageData != null)
                {
                    PageData currentPage = EPiServer.DataFactory.Instance.GetPage(new PageReference(id.Value));
                    var      pageId      = currentPage.ContentLink.ID;
                    var      _rules      = new List <RuleDescription>();

                    List <Rule> _rulesLeft  = RuleEngine.Instance.GetRulesLeft(pageId) as List <Rule>;
                    List <Rule> _rulesRight = RuleEngine.Instance.GetRulesRight(pageId) as List <Rule>;

                    AccessControlList list = currentPage.ACL;

                    foreach (Rule leftRule in _rulesLeft)
                    {
                        RuleDescription rd = new RuleDescription()
                        {
                            RuleName = leftRule.RuleTextLeft, RuleDesc = leftRule.RuleDescriptionLeft, RuleDirection = "left", RuleGuid = leftRule.Id.ExternalId.ToString(), RuleId = leftRule.RuleName
                        };
                        if (HasAccess(list, leftRule.EditModeAccessLevel) && leftRule.RuleVisibleLeft)
                        {
                            _rules.Add(rd);
                        }
                    }



                    foreach (Rule rightRule in _rulesRight)
                    {
                        RuleDescription rd = new RuleDescription()
                        {
                            RuleName = rightRule.RuleTextRight, RuleDesc = rightRule.RuleDescriptionRight, RuleDirection = "right", RuleGuid = rightRule.Id.ExternalId.ToString(), RuleId = rightRule.RuleName
                        };
                        if (HasAccess(list, rightRule.EditModeAccessLevel) && rightRule.RuleVisibleRight && rightRule.RuleTextLeft != rightRule.RuleTextRight)
                        {
                            _rules.Add(rd);
                        }
                    }

                    /*
                     *
                     * List<RuleDescription> result = new List<RuleDescription>();
                     * int cnt = 0;
                     *
                     * foreach (Rule rule in _rules)
                     * {
                     *  bool isLeftRule = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName)));
                     *  if ((from p in result where p.RuleName == rule.RuleName select p).Any())
                     *      result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "left", RuleName = rule.RuleTextLeft + "2", RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                     *  else
                     *      result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "left", RuleName = rule.RuleTextLeft, RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                     *  cnt++;
                     * }
                     *
                     * foreach (Rule rule in _rulesRight)
                     * {
                     *  bool isLeftRule = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName)));
                     *  if ((from p in result where p.RuleName == rule.RuleName select p).Any())
                     *      result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "right", RuleName = rule.RuleTextRight + "2", RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                     *  else
                     *      result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "right", RuleName = rule.RuleTextRight, RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                     *  cnt++;
                     * }
                     */
                    return(Rest(_rules.Select(m => new { Guid = m.RuleGuid, Name = TryTranslate(m.RuleName), Id = m.RuleId, Description = TryTranslate(m.RuleDesc), Direction = m.RuleDirection })));
                }
            }
            return(null);
        }
Ejemplo n.º 28
0
 private void RejectBatch(ItemRange range)
 {
 }
Ejemplo n.º 29
0
        public RestResult Get(int? id, ItemRange range)
        {
            if (id.HasValue)
            {
                ContentReference currentContentRef = new PageReference(id.Value);
                if (new ContentReference(id.Value) != null && EPiServer.DataFactory.Instance.Get<IContent>(new ContentReference(id.Value)) as PageData != null)
                {
                    PageData currentPage = EPiServer.DataFactory.Instance.GetPage(new PageReference(id.Value));
                    var pageId = currentPage.ContentLink.ID;
                    var _rules = new List<RuleDescription>();

                    List<Rule> _rulesLeft = RuleEngine.Instance.GetRulesLeft(pageId) as List<Rule>;
                    List<Rule> _rulesRight = RuleEngine.Instance.GetRulesRight(pageId) as List<Rule>;

                    AccessControlList list = currentPage.ACL;

                    foreach (Rule leftRule in _rulesLeft)
                    {
                        RuleDescription rd = new RuleDescription() { RuleName = leftRule.RuleTextLeft, RuleDesc = leftRule.RuleDescriptionLeft, RuleDirection = "left", RuleGuid = leftRule.Id.ExternalId.ToString(), RuleId = leftRule.RuleName };
                        if (HasAccess(list, leftRule.EditModeAccessLevel) && leftRule.RuleVisibleLeft)
                            _rules.Add(rd);
                    }

                    foreach (Rule rightRule in _rulesRight)
                    {
                        RuleDescription rd = new RuleDescription() { RuleName = rightRule.RuleTextRight, RuleDesc = rightRule.RuleDescriptionRight, RuleDirection = "right", RuleGuid = rightRule.Id.ExternalId.ToString(), RuleId = rightRule.RuleName };
                        if (HasAccess(list, rightRule.EditModeAccessLevel) && rightRule.RuleVisibleRight && rightRule.RuleTextLeft != rightRule.RuleTextRight)
                            _rules.Add(rd);
                    }

                    /*

                    List<RuleDescription> result = new List<RuleDescription>();
                    int cnt = 0;

                    foreach (Rule rule in _rules)
                    {
                        bool isLeftRule = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName)));
                        if ((from p in result where p.RuleName == rule.RuleName select p).Any())
                            result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "left", RuleName = rule.RuleTextLeft + "2", RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                        else
                            result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "left", RuleName = rule.RuleTextLeft, RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                        cnt++;
                    }

                    foreach (Rule rule in _rulesRight)
                    {
                        bool isLeftRule = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName)));
                        if ((from p in result where p.RuleName == rule.RuleName select p).Any())
                            result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "right", RuleName = rule.RuleTextRight + "2", RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                        else
                            result.Add(new RuleDescription() { RuleGuid = rule.Id.ExternalId.ToString(), RuleId = rule.RuleName, RuleDirection = "right", RuleName = rule.RuleTextRight, RuleDesc = (RuleEngine.Instance.IsLeftRule(pageId, RuleEngine.Instance.GetRule(rule.RuleName))) ? rule.RuleDescriptionLeft : rule.RuleDescriptionRight });
                        cnt++;
                    }
                    */
                    return Rest(_rules.Select(m => new { Guid = m.RuleGuid, Name = TryTranslate( m.RuleName), Id = m.RuleId, Description = TryTranslate(m.RuleDesc), Direction = m.RuleDirection }));
                }
            }
            return null;
        }
Ejemplo n.º 30
0
        public RestResult Get(int? id, ItemRange range)
        {
            // When requesting a specific item we return that item; otherwise return all items.

                return Rest("Hello world!");
        }
Ejemplo n.º 31
0
        public RestResult Get(int? id, ItemRange range)
        {
            if (id.HasValue)
            {
                string result = "";
                PageData currentPage = EPiServer.DataFactory.Instance.GetPage(new PageReference(id.Value));
                var pageId = currentPage.ContentLink.ID;
                var _rules = new List<Rule>();
                int cnt = 0;

                List<Rule> _rulesLeft = RuleEngine.Instance.GetRulesLeft(pageId) as List<Rule>;
                List<Rule> _rulesRight = RuleEngine.Instance.GetRulesRight(pageId) as List<Rule>;

                foreach (Rule rule in _rulesLeft)
                {
                    if (rule.RuleTextLeft != rule.RuleTextRight)
                    {
                        result += "<b>" + rule.RuleTextLeft + "</b><br/>";
                        List<int> relations = RelationEngine.Instance.GetRelationPagesForPage(pageId, rule);
                        foreach (int pgid in relations)
                        {
                            result += "- " + EPiServer.DataFactory.Instance.GetPage(new PageReference(pgid)).Name +
                                      "<br/>";
                            cnt++;
                        }

                    }
                }

                foreach (Rule rule in _rulesRight)
                {
                    result += "<b>" + rule.RuleTextRight + "</b><br/>";
                    List<int> relations = RelationEngine.Instance.GetRelationPagesForPage(pageId, rule);
                    foreach (int pgid in relations)
                    {
                        result += "- " + EPiServer.DataFactory.Instance.GetPage(new PageReference(pgid)).Name + "<br/>";
                        cnt++;
                    }
                }
                result = "Number of relations: " + cnt + "<br/><br/>" + result;

                return Rest(result);

            }
            return null;
        }
Ejemplo n.º 32
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="AlertMedia.CodeGen.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="customer">customer id</param>
        /// <param name="itemRange">item-range pagination</param>
        /// <returns>ApiResponse of ICollection&lt;User&gt;</returns>
        public ApiResponse <ICollection <User> > ListWithHttpInfo(long?customer, ItemRange itemRange = null)
        {
            // verify the required parameter 'customer' is set
            if (customer == null)
            {
                throw new ApiException(400, "Missing required parameter 'customer' when calling UserApi->List");
            }

            var    localVarPath         = "/users";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
            };
            String localVarHttpContentType    = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }
            if (itemRange != null)
            {
                localVarHeaderParams.Add("Range", itemRange.ToHeader());
            }

            if (customer != null)
            {
                localVarQueryParams.Add("customer", Configuration.ApiClient.ParameterToString(customer));                   // query parameter
            }
            // authentication (basicAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
            {
                localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("List", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <ICollection <User> >(localVarStatusCode,
                                                         localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                         (ICollection <User>)Configuration.ApiClient.Deserialize(localVarResponse, typeof(Collection <User>))));
        }