示例#1
0
        /// <summary>
        /// Executes the query and returns the result as a JSON array
        /// </summary>
        public JsonArray ExecuteToArray(AqlQuery query)
        {
            var array = new JsonArray();

            foreach (JsonValue item in Execute(query))
            {
                array.Add(item);
            }

            return(array);
        }
示例#2
0
 protected override void OnInit(EventArgs e)
 {
     q = WAFContext.Session.CreateQuery();
     var alias = new AqlAlias();
     alias.IncludeOnlyDeletedNodes = true;
     q.From(alias);
     q.Where(Aql.MemberOf(alias.EditGroupId, WAFContext.Session.Access));
     q.Where(Aql.MemberOf(alias.PublishGroupId, WAFContext.Session.Access));
     q.Select(alias, "Content");
     q.Select(alias.Name, "Name");
     q.Select(alias.ChangeDate, "ChangeDate");
     q.Select(alias.CreateDate, "CreateDate");
     lstBin.SortColumnIndex = 1;
     lstBin.Query = q;
     base.OnInit(e);
 }
示例#3
0
 protected void btnEmpty_Click(object sender, EventArgs e)
 {
     lstBin.DataBind();
     deleteList m = new deleteList();
     q = WAFContext.Session.CreateQuery();
     var alias = new AqlAlias();
     alias.IncludeOnlyDeletedNodes = true;
     q.From(alias);
     if (!WAFContext.Session.Access.IsAdmin()) {
         q.Where(Aql.MemberOf(alias.EditGroupId, WAFContext.Session.Access));
         q.Where(Aql.MemberOf(alias.PublishGroupId, WAFContext.Session.Access));
     }
     q.Select(alias.NodeId);
     m.NodeIds = q.Execute<int>();
     WAFContext.StartWorkflowMethod(m);
 }
示例#4
0
文件: Default.aspx.cs 项目: kyvkri/MG
 NextCall onComplete(WorkflowMethod invoker)
 {
     var f = (WMContentForm)invoker;
     int pixels = 1000000 * int.Parse(f.Result.Get<ShortStringPropertyValue>("megapixels").Value.Substring(1));
     AqlQuery q = new AqlQuery(Session);
     AqlAliasHierarchicalContent alias = new AqlAliasHierarchicalContent();
     var rC = q.Select<HierarchicalContent>(alias);
     q.From(alias);
     var rs = q.Execute();
     var cs = new List<HierarchicalContent>();
     while (rs.Read()) cs.Add(rC.Value);
     foreach (var c in cs) {
         _countContents++;
         WFContext.Caption = "Rescaling images...";
         WFContext.Description = _countContents + " contents examined. " + _countResized + " images rescaled. Before: " + Utils.GetByteSizeString(bytesBefore) + ". After: " + Utils.GetByteSizeString(bytesAfter);
         try {
             resizeImages(c, pixels);
             if (WFContext.BreakExecution) return null;
             if (c.Changed) c.UpdateChanges(false, false, false);
         } catch { }
     }
     Session.Notify("Rescale complete", _countContents + " contents examined. " + _countResized + " images rescaled. Before: " + Utils.GetByteSizeString(bytesBefore) + ". After: " + Utils.GetByteSizeString(bytesAfter));
     return null;
 }
示例#5
0
文件: Default.aspx.cs 项目: kyvkri/MG
    public override NextCall Invoke(WorkflowMethod invoker)
    {
        if (!Session.Access.IsAdmin()) throw new Exception("Only administrators can run this workflow. ");

        if (!Engine.Installation.EnableContentLinkIndex) {
            Session.Notify("Link indexing is not enabled on this installation. See menu \"Application/Settings\" to enable it. ");
            return null;
        }

        WFContext.Caption = "Updating link index...";

        AqlQuery q;
        AqlResultSet result;

        q = new AqlQuery(Session);
        var rNodeId = q.Select(AqlContent.NodeId);
        var rLCID = q.Select(AqlContent.NodeId);
        var rClassId = q.Select(AqlContent.ContentClassId);
        q.Distinct();
        q.From<UrlStatus>();
        var nodeIds = new List<int>();
        result = q.Execute();
        nodeIds = new List<int>();
        while (result.Read()) nodeIds.Add(rNodeId);
        int n = 0;
        foreach (int id in nodeIds) {
            n++;
            WFContext.Description = "Deleting old non-system url index, " + n + " of " + nodeIds.Count + "...";
            if (WFContext.BreakExecution) return null;
            Session.DeleteNode(id, true);
        }

        WFContext.Description = "Queuing link updates...";
        q = new AqlQuery(Session);
        rNodeId = q.Select(AqlContent.NodeId);
        rClassId = q.Select(AqlContent.ContentClassId);
        q.Distinct();
        result = q.Execute();
        var keys = new List<CKeyNC>();
        while (result.Read()) {
            keys.Add(new CKeyNC(rNodeId, rClassId));
        }
        WFContext.Engine.QueNodeLinksUpdate(keys);

        WFContext.Notify("Link update is cued for " + keys.Count + " nodes.");
        return null;
    }
示例#6
0
 /// <summary>
 /// Executes an AQL query against the database
 /// </summary>
 public List <JsonValue> ExecuteAqlQuery(AqlQuery query)
 {
     return(Executor.Execute(query));
 }
示例#7
0
 List <JsonValue> IArango.ExecuteAqlQuery(AqlQuery query)
 => ExecuteAqlQuery(query);
示例#8
0
 void setQueryMessageList()
 {
     AqlQuery q = new AqlQuery(WAFContext.Session);
     var classIds = from item in chkTypeFilter.Items.Cast<ListItem>() where item.Selected select int.Parse(item.Value);
     q.Where(Aql.In(AqlMessageBase.ContentClassId, classIds));
     q.Where(Aql.InIndexQuery(AqlMessageBase.NodeId, txtSearch.Text));
     foreach (string v in lstTree.GetSelectedValues()) {
         q.Where(AqlMessageBase.Status == int.Parse(v));
     }
     lstMessages.Query = q;
     q.OrderBy(AqlMessageBase.MessageDate, true);
     q.Select<MessageBase>();
     q.Select(AqlMessageBase.MessageDate);
     q.Select(AqlMessageBase.Name);
     q.Select(AqlMessageBase.From);
     q.Select(AqlMessageBase.ToSort);
     q.Select(AqlMessageBase.NodeId);
 }
示例#9
0
        /// <summary>
        /// Executes an AQL query
        /// </summary>
        public List <JsonValue> Execute(AqlQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            query.ValidateQuery();

            var initialFrame = new ExecutionFrame();

            var frameStream = Enumerable.Repeat(initialFrame, 1);

            foreach (AqlOperation operation in query)
            {
                switch (operation)
                {
                case AqlReturnOperation op:
                    return(op
                           .ApplyToFrameStream(this, frameStream)
                           .ToList()); // make sure the query is executed

                // even if nobody looks at the results

                case AqlForOperation op:
                    frameStream = op.ApplyToFrameStream(this, frameStream);
                    break;

                case AqlInsertOperation op:
                    frameStream = op.ApplyToFrameStream(this, frameStream);
                    break;

                case AqlFilterOperation op:
                    frameStream = op.ApplyToFrameStream(this, frameStream);
                    break;

                case AqlReplaceOperation op:
                    frameStream = op.ApplyToFrameStream(this, frameStream);
                    break;

                case AqlRemoveOperation op:
                    frameStream = op.ApplyToFrameStream(this, frameStream);
                    break;

                default:
                    throw new ArgumentException(
                              "Unknown operation type " + operation
                              );
                }
            }

            // there was no return statement, so we return an empty collection
            // BUT !!! we still need to enumerate over it, otherwise nothing
            // happens (inserts, updates, deletes, ...)

            foreach (var _ in frameStream)
            { /* do nothing (let the pipeline work) */
            }

            return(new List <JsonValue>());
        }
 public List <JsonValue> ExecuteAqlQuery(AqlQuery query)
 {
     return(ExecuteRawAqlQuery(query.ToAql(), new JsonObject()));
 }
示例#11
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     _countContents = 0;
     AqlQuery q = new AqlQuery(Session);
     AqlAliasHierarchicalContent alias = new AqlAliasHierarchicalContent();
     var rC = q.Select<HierarchicalContent>(alias);
     q.From(alias);
     var rs = q.Execute();
     var cs = new List<HierarchicalContent>();
     while (rs.Read()) cs.Add(rC.Value);
     foreach (var c in cs) {
         _countContents++;
         WFContext.Caption = "Resetting encoded video files...";
         WFContext.Description = _countContents + " contents examined. " + _countReset + " video files reset. ";
         try {
             resetVideoEncoding(c);
             if (WFContext.BreakExecution) return null;
             if (c.Changed) c.UpdateChanges(false, false, false);
         } catch { }
     }
     Session.Notify("Encoding reset complete", _countContents + " contents examined. " + _countReset + " video reset. ");
     return null;
 }
示例#12
0
 protected EntityQuery(IArango arango)
 {
     Query  = new AqlQuery();
     Arango = arango;
 }
示例#13
0
 /// <summary>
 /// Extension method to execute AQL queries directly
 /// </summary>
 public static IEnumerable <JsonValue> Execute(this AqlQuery query)
 {
     return(GetArango().ExecuteAqlQuery(query));
 }