private ActionBase GetMethodBasedAction(string name, Content content, object state) { var(httpContext, config) = ((HttpContext, IConfiguration))state; //var odataRequest = (ODataRequest) httpContext.Items[ODataMiddleware.ODataRequestHttpContextKey]; OperationCallingContext method; try { method = OperationCenter.GetMethodByRequest(content, name, ODataMiddleware.ReadToJsonAsync(httpContext) .GetAwaiter().GetResult(), httpContext.Request.Query); } catch (OperationNotFoundException e) { SnTrace.System.WriteError($"Operation {name} not found. " + $"Content: {content.Path}, User: {User.Current.Username}"); throw new InvalidContentActionException(e, InvalidContentActionReason.UnknownAction, content.Path, e.Message, name); } catch (AmbiguousMatchException e) { SnTrace.System.WriteError($"Operation {name} is ambiguous. " + $"Content: {content.Path}, User: {User.Current.Username}"); throw new InvalidContentActionException(e, InvalidContentActionReason.UnknownAction, content.Path, e.Message, name); } catch (Exception ex) { SnTrace.System.WriteError($"Error during discovery of method {name}. {ex.Message} " + $"Content: {content.Path}, User: {User.Current.Username}"); throw; } method.HttpContext = httpContext; method.ApplicationConfiguration = config; return(new ODataOperationMethodExecutor(method)); }
private async Task ODataTestAsync(IUser user, Action <RepositoryBuilder> initialize, Func <Task> callback) { Providers.Instance.ResetBlobProviders(); OnTestInitialize(); var builder = base.CreateRepositoryBuilderForTestInstance(); //CreateRepositoryBuilder(); //UNDONE:<?: do not call discovery and providers setting in the static ctor of ODataMiddleware var _ = new ODataMiddleware(null, null, null); // Ensure running the first-touch discover in the static ctor OperationCenter.Operations.Clear(); OperationCenter.Discover(); Providers.Instance.SetProvider(typeof(IOperationMethodStorage), new OperationMethodStorage()); initialize?.Invoke(builder); Indexing.IsOuterSearchEngineEnabled = true; Cache.Reset(); ResetContentTypeManager(); using (var repo = Repository.Start(builder)) { User.Current = user ?? User.Administrator; if (user == null) { User.Current = User.Administrator; using (new SystemAccount()) await callback().ConfigureAwait(false); } else { User.Current = user; await callback().ConfigureAwait(false); } } }
/// <summary> /// プレイリスト中の未変換 ogg, ogv を一気に変換する。 /// mainTimerTick の中から呼ばれること! /// </summary> private void convBypass(int needConvOcxIndex) { List <ConvBypassEntry> entries = new List <ConvBypassEntry>(); if (Gnd.i.convBypassまとめて実行) { for (int rowidx = 0; rowidx < plSheet.RowCount; rowidx++) { MediaInfo mi = plSheetGetRow(rowidx); if (mi.status == Consts.MediaStatus_e.NEED_CONVERSION && Utils.isOgxPath(mi.file)) { entries.Add(new ConvBypassEntry() { rowidx = rowidx, mi = mi, }); } } } else { entries.Add(new ConvBypassEntry() { rowidx = needConvOcxIndex, mi = plSheetGetRow(needConvOcxIndex), }); } { OperationCenter convOcBk = Gnd.i.convOc; Gnd.i.convOc = new OperationCenter(); BusyDlg.perform(delegate { foreach (ConvBypassEntry cbe in entries) { using (Conv conv = new Conv(cbe.mi.file, Path.Combine(Gnd.i.mediaDir, StringTools.zPad(cbe.mi.serial, 10)))) { while (conv.completed == false) { Gnd.i.convOc.eachTimerTick(); } cbe.mi.status = Consts.MediaStatus_e.READY; completedConvToMediaInfo(conv, cbe.mi); cbe.proced = true; } } }, this, entries.Count == 1 ); Gnd.i.convOc = convOcBk; } foreach (ConvBypassEntry cbe in entries) { if (cbe.proced) { plSheetSetRow(cbe.rowidx, cbe.mi); if (cbe.rowidx == 0 && Gnd.i.autoPlayTop) // 自動再生 { int playingIndex = getPlayingIndex(); if (playingIndex == -1) // ? 未再生 { Gnd.i.lastPlayedSerial = cbe.mi.serial; Gnd.i.client.sendLine("ES!"); } } } } }