예제 #1
0
        public static void ExecuteQuery(ref DbTask dbt, QueryFinished pEvent)
        {
            var sw = TimerStart();

            try
            {
                dbt.DbQueryType = DbQueryType.ExecQuery;
                SqlParameterSetup(ref dbt);
                if (ConnectionNotOpenHappened(ref dbt, MethodBase.GetCurrentMethod()))
                {
                    pEvent(0, new Exception("ExecuteQuery not attempted. Connection was not open."));
                }
                int count = dbt.SqlCmd.ExecuteNonQuery();
                //dbt.DebugExtendedInfo = string.Format("Rows affected={0}", count);
                pEvent(count, null);
            }
            catch (Exception exc1)
            {
                dbt.ExceptionQuery = exc1;
                pEvent(0, exc1);
            }
            finally
            {
                TimerEnd(dbt, sw);
                DebugSql(dbt);
                if (dbt.SqlCmd.Connection.State == ConnectionState.Open)
                {
                    dbt.SqlCmd.Connection.Close();
                }
                dbt.SqlCmd.Connection.Dispose();
            }
        }
예제 #2
0
        /// <summary>
        /// Starts a process that retrieves all entries with a partition key greater or equal than <paramref name="minTimestamp"/>
        /// </summary>
        /// <remarks>
        /// After 1000 elements are loaded this method will fire <see cref="EntriesReceived"/>.
        /// </remarks>
        /// <param name="table">The Azure WADLogs table to query against.</param>
        /// <param name="minTimestamp">The smallest WADLogs partition key to put into result.</param>
        /// <returns>All items from the WADLogs table inside the defined time.</returns>
        public async Task <IEnumerable <TTableItem> > GetEntriesAsync(CloudTable table, string minTimestamp)
        {
            var term  = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.GreaterThanOrEqual, minTimestamp);
            var query = new TableQuery <TTableItem>().Where(term);
            TableContinuationToken continuationToken = null;
            var result = new List <TTableItem>();

            do
            {
                var stopWatch = new Stopwatch();
                QueryStarted?.Invoke(null, EventArgs.Empty);
                stopWatch.Start();
                try
                {
                    var tableQueryResult = await table.ExecuteQuerySegmentedAsync(query, continuationToken);

                    stopWatch.Stop();
                    LastQueryTime = stopWatch.Elapsed;
                    QueryFinished?.Invoke(null, EventArgs.Empty);
                    continuationToken = tableQueryResult.ContinuationToken;
                    var entries = tableQueryResult.Results.ToList();
                    EntriesReceived?.Invoke(null, new TableEntityListEventArgs <TTableItem>(entries));
                    result.AddRange(entries);
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.Message);
                }
            }while (continuationToken != null);
            return(result);
        }
예제 #3
0
 public unsafe void Request()
 {
     try {
         _Request();
     } catch (TypeLoadException) {
         // We're definitely using the stubbed Steamworks.NET now... unless someone dropped in an outdated version? But why?
         QueryFinished?.Invoke(this);
     }
 }
예제 #4
0
    private unsafe void OnSteamUGCQueryCompleted(SteamUGCQueryCompleted_t queryCompleted, bool ioFailure)
    {
        UGCQueryHandle_t handle = queryCompleted.m_handle;

        if (_handle.m_UGCQueryHandle == 0 || ioFailure)
        {
            goto Finish;
        }

        numResultsTotal = queryCompleted.m_unTotalMatchingResults;
        uint results = queryCompleted.m_unNumResultsReturned;

        if (results == 0 || fetchedData == WorkshopQueryData.TotalOnly)
        {
            goto Finish;
        }

        numResultsFetched += results;
        for (uint resulti = 0; resulti < results; resulti++)
        {
            WorkshopQueryResult result = new WorkshopQueryResult();
            SteamUGC.GetQueryUGCPreviewURL(handle, resulti, out result.previewURL, 260);

            SteamUGCDetails_t ugcDetails;
            SteamUGC.GetQueryUGCResult(queryCompleted.m_handle, resulti, out ugcDetails);
            WorkshopQueryResultDetails resultDetails = result.details = new WorkshopQueryResultDetails();

            resultDetails.acceptedForUse = ugcDetails.m_bAcceptedForUse;
            resultDetails.banned         = ugcDetails.m_bBanned;

            resultDetails.title        = ugcDetails.m_rgchTitle;
            resultDetails.description  = ugcDetails.m_rgchDescription;
            resultDetails.steamIDOwner = ugcDetails.m_ulSteamIDOwner;
            resultDetails.score        = ugcDetails.m_flScore;
            resultDetails.visibility   = ugcDetails.m_eVisibility;
            resultDetails.votesDown    = ugcDetails.m_unVotesDown;
            resultDetails.votesUp      = ugcDetails.m_unVotesUp;

            resultDetails.tags          = ugcDetails.m_rgchTags.Split(',');
            resultDetails.tagsTruncated = ugcDetails.m_bTagsTruncated;

            resultDetails.timeAddedToUserList = ugcDetails.m_rtimeAddedToUserList;
            resultDetails.timeCreated         = ugcDetails.m_rtimeCreated;
            resultDetails.timeUpdated         = ugcDetails.m_rtimeUpdated;

            resultDetails.file     = ugcDetails.m_hFile.m_UGCHandle;
            resultDetails.fileName = ugcDetails.m_pchFileName;
            resultDetails.fileSize = ugcDetails.m_nFileSize;
            resultDetails.fileType = ugcDetails.m_eFileType;

            resultDetails.numChildren = ugcDetails.m_unNumChildren;

            resultDetails.previewFile     = ugcDetails.m_hPreviewFile.m_UGCHandle;
            resultDetails.previewFileSize = ugcDetails.m_nPreviewFileSize;

            resultDetails.URL = ugcDetails.m_rgchURL;

            resultDetails.publishedFile = WorkshopItem.GetItem(ugcDetails.m_nPublishedFileId);

            resultDetails.result = ugcDetails.m_eResult;

            if ((fetchedData & WorkshopQueryData.Children) != 0)
            {
                PublishedFileId_t[] children = new PublishedFileId_t[resultDetails.numChildren];
                if (SteamUGC.GetQueryUGCChildren(handle, resulti, children, (uint)children.Length))
                {
                    result.fileList = _.GetArray(children, id => WorkshopItem.GetItem(id));
                }
            }

            if ((fetchedData & WorkshopQueryData.Metadata) != 0)
            {
                SteamUGC.GetQueryUGCMetadata(handle, resulti, out result.metadata, 260);
            }

            if ((fetchedData & WorkshopQueryData.AdditionalPreviews) != 0)
            {
                WorkshopQueryResultAdditionalPreview[] previews = result.additionalPreviews = new WorkshopQueryResultAdditionalPreview[SteamUGC.GetQueryUGCNumAdditionalPreviews(handle, resulti)];
                for (uint previewi = 0; previewi < previews.Length; previewi++)
                {
                    string           url;
                    string           name;
                    EItemPreviewType type;
                    if (SteamUGC.GetQueryUGCAdditionalPreview(handle, resulti, previewi, out url, 260, out name, 260, out type))
                    {
                        previews[previewi] = new WorkshopQueryResultAdditionalPreview(type == EItemPreviewType.k_EItemPreviewType_Image, url);
                    }
                }
            }

            if ((fetchedData & WorkshopQueryData.Statistics) != 0)
            {
                uint[] stats = result.statistics = new uint[8];
                for (WorkshopResultStatistic stat = WorkshopResultStatistic.NumSubscriptions; (int)stat < stats.Length; stat++)
                {
                    ulong val;
                    if (SteamUGC.GetQueryUGCStatistic(handle, resulti, (EItemStatistic)stat, out val))
                    {
                        stats[(int)stat] = (uint)val;
                    }
                }
            }

            ResultFetched?.Invoke(this, result);
        }

        if (numResultsFetched != numResultsTotal && !justOnePage)
        {
            Destroy();
            page++;
            Create();
            Request();
            return;
        }

Finish:
        QueryFinished?.Invoke(this);
    }