Example #1
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Navigator.RegisterArea(typeof(SMSClient));
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <SMSConfigurationEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSConfiguration")
                    },

                    new EntitySettings <SMSMessageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSMessage")
                    },
                    new EntitySettings <SMSTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSTemplate")
                    },
                    new EmbeddedEntitySettings <SMSTemplateMessageEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSTemplateMessage")
                    },

                    new EntitySettings <SMSSendPackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSSendPackage")
                    },
                    new EntitySettings <SMSUpdatePackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("SMSUpdatePackage")
                    },

                    new ModelEntitySettings <MultipleSMSModel> {
                        PartialViewName = e => ViewPrefix.FormatWith("MultipleSMS")
                    },
                });

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <Entity>(SMSMessageOperation.CreateSMSWithTemplateFromEntity)
                    {
                        Click = ctx => Module["createSmsWithTemplateFromEntity"](ctx.Options(), JsFunction.Event,
                                                                                 ctx.Url.Action((SMSController sms) => sms.CreateSMSMessageFromTemplate()),
                                                                                 SmsTemplateFindOptions(ctx.Entity.GetType()).ToJS(ctx.Prefix, "New"))
                    },

                    new ContextualOperationSettings <Entity>(SMSMessageOperation.SendSMSMessagesFromTemplate)
                    {
                        Click = ctx => Module["sendMultipleSMSMessagesFromTemplate"](ctx.Options(), JsFunction.Event,
                                                                                     ctx.Url.Action((SMSController sms ) => sms.SendMultipleMessagesFromTemplate()),
                                                                                     SmsTemplateFindOptions(ctx.SingleType).ToJS(ctx.Prefix, "New"))
                    },

                    new ContextualOperationSettings <Entity>(SMSMessageOperation.SendSMSMessages)
                    {
                        Click = ctx => Module["sentMultipleSms"](ctx.Options(), JsFunction.Event, ctx.Prefix,
                                                                 ctx.Url.Action((SMSController sms) => sms.SendMultipleSMSMessagesModel()),
                                                                 ctx.Url.Action((SMSController sms) => sms.SendMultipleMessages()))
                    },
                });
            }
        }
Example #2
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                if (!Navigator.Manager.EntitySettings.ContainsKey(typeof(TypeEntity)))
                {
                    Navigator.AddSetting(new EntitySettings <TypeEntity>());
                }

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new ModelEntitySettings <ChartPaletteModel>
                    {
                        PartialViewName = _ => ChartClient.ViewPrefix.FormatWith("ChartPalette"),
                        MappingDefault  = new EntityMapping <ChartPaletteModel>(true)
                                          .SetProperty(a => a.Colors, new MListDictionaryMapping <ChartColorEntity, Lite <Entity> >(cc => cc.Related,
                                                                                                                                    new EntityMapping <ChartColorEntity>(false)
                                                                                                                                    .CreateProperty(m => m.Color)
                                                                                                                                    .CreateProperty(c => c.Related)))
                    }
                });

                ChartUtils.GetChartColor = ChartColorLogic.ColorFor;

                ButtonBarEntityHelper.RegisterEntityButtons <ChartPaletteModel>((ctx, entity) =>
                {
                    var typeName = Navigator.ResolveWebTypeName(entity.Type.ToType());
                    return(new[]
                    {
                        new ToolBarButton(ctx.Prefix, "savePalette")
                        {
                            Text = ChartMessage.SavePalette.NiceToString(),
                            Style = BootstrapStyle.Primary,
                            OnClick = Module["savePalette"](ctx.Url.Action <ColorChartController>(pc => pc.SavePalette(typeName)))
                        },
                        new ToolBarButton(ctx.Prefix, "newPalette")
                        {
                            Text = ChartMessage.NewPalette.NiceToString(),
                            OnClick = Module["createPalette"](
                                ctx.Url.Action <ColorChartController>(pc => pc.CreateNewPalette(typeName)),
                                ChartColorLogic.Palettes.Keys,
                                ChartMessage.ChooseABasePalette.NiceToString())
                        },
                        new ToolBarButton(ctx.Prefix, "deletePalette")
                        {
                            Text = ChartMessage.DeletePalette.NiceToString(),
                            Style = BootstrapStyle.Danger,
                            OnClick = Module["deletePalette"](
                                ctx.Url.Action <ColorChartController>(pc => pc.DeletePalette(typeName)))
                        }
                    });
                });
            }
        }
Example #3
0
        private async void Authenticate(string password)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                return;
            }

            if (await ApiService.CheckPassword(_actualBriefingId, password))
            {
                _editedBriefing = await ApiService.GetBriefingToEdit(_actualBriefingId, password);

                _editPassword = password;

                _authenticated = true;
                _authModal.Hide();
                StateHasChanged();

                LoadData(_editedBriefing);
            }
            else
            {
                CurrentPage.ShowNotification("Wrong password.");
                return;
            }

            await JsModule.InvokeVoidAsync("registerEvents");

            await JsModule.InvokeVoidAsync("createFilePond", JsonConvert.SerializeObject(_editedBriefing.AttachmentsArray.ToArray <object>()));

            await JsRuntime.InvokeVoidAsync("startTime");
        }
Example #4
0
 public bool init(JsModule someCallingModule, JsProcess someProcess)
 {
     myModule = someCallingModule;
     myModule.Engine.SetFunction("__test",new Action<bool>(this.testNullable));
     myModule.Engine.SetFunction("__testThrow",new Action(this.testFailTestInCSharp));
     return true;
 }
Example #5
0
        static MapColorProvider[] GetMapColors()
        {
            var strategies = IsolationLogic.GetIsolationStrategies().SelectDictionary(t => Navigator.ResolveWebTypeName(t), p => p);

            return(new[]
            {
                new MapColorProvider
                {
                    Name = "isolation",
                    NiceName = "Isolation",
                    GetJsProvider = ColorsModule["isolationColors"](MapClient.NodesConstant),
                    AddExtra = t =>
                    {
                        var s = strategies.TryGetS(t.webTypeName);

                        if (s == null)
                        {
                            return;
                        }

                        t.extra["isolation"] = s.ToString();
                    },
                    Order = 3,
                },
            });
        }
Example #6
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(IsolationClient));

                WidgetsHelper.GetWidget += ctx => ctx.Entity is Entity && MixinDeclarations.IsDeclared(ctx.Entity.GetType(), typeof(IsolationMixin)) ?
                                           IsolationWidgetHelper.CreateWidget(ctx) : null;

                Navigator.AddSetting(new EntitySettings <IsolationEntity> {
                    PartialViewName = _ => ViewPrefix.FormatWith("Isolation")
                });

                Constructor.ClientManager.GlobalPreConstructors += ctx =>
                                                                   (!MixinDeclarations.IsDeclared(ctx.Type, typeof(IsolationMixin)) || IsolationEntity.Current != null) ? null :
                                                                   Module["getIsolation"](ClientConstructorManager.ExtraJsonParams, ctx.Prefix,
                                                                                          IsolationMessage.SelectAnIsolation.NiceToString(),
                                                                                          GetIsolationChooserOptions(ctx.Type));

                //Unnecessary with the filter
                Constructor.Manager.PreConstructors += ctx =>
                                                       !MixinDeclarations.IsDeclared(ctx.Type, typeof(IsolationMixin)) ? null :
                                                       IsolationEntity.Override(GetIsolation(ctx.Controller.ControllerContext));

                MapClient.GetColorProviders += GetMapColors;
            }
        }
Example #7
0
        public void Dispose()
        {
            JsModule.InvokeVoidAsync("destroyFilePond");
            JsModule.InvokeVoidAsync("unregisterEvents");

            JsRuntime.InvokeVoidAsync("stopTime");
        }
Example #8
0
        static MapColorProvider[] GetMapColors()
        {
            if (!BasicPermission.AdminRules.IsAuthorized())
            {
                return(new MapColorProvider[0]);
            }

            var roleRules = AuthLogic.RolesInOrder().ToDictionary(r => r,
                                                                  r => TypeAuthLogic.GetTypeRules(r).Rules.ToDictionary(a => Navigator.ResolveWebTypeName(a.Resource.ToType()), a => a.Allowed));

            return(roleRules.Keys.Select((r, i) => new MapColorProvider
            {
                Name = "role-" + r.Key(),
                NiceName = "Role - " + r.ToString(),
                GetJsProvider = ColorModule["authAdminColor"](MapClient.NodesConstant, "role-" + r.Key()),
                AddExtra = t =>
                {
                    TypeAllowedAndConditions tac = roleRules[r].TryGetC(t.webTypeName);

                    if (tac == null)
                    {
                        return;
                    }

                    t.extra["role-" + r.Key() + "-ui"] = GetName(ToStringList(tac, userInterface: true));
                    t.extra["role-" + r.Key() + "-db"] = GetName(ToStringList(tac, userInterface: false));
                    t.extra["role-" + r.Key() + "-tooltip"] = ToString(tac.Fallback) + "\n" + (tac.Conditions.IsNullOrEmpty() ? null :
                                                                                               tac.Conditions.ToString(a => a.TypeCondition.NiceToString() + ": " + ToString(a.Allowed), "\n") + "\n");
                },
                Defs = i == 0 ? GetAllGradients(roleRules) : null,
                Order = 10,
            }).ToArray());
        }
Example #9
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Navigator.RegisterArea(typeof(WordClient));
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <WordTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("WordTemplate")
                    },
                    new EntitySettings <SystemWordTemplateEntity> {
                    },
                    new EntitySettings <WordTransformerSymbol> {
                    },
                    new EntitySettings <WordConverterSymbol> {
                    },
                });
                OperationClient.AddSetting(new EntityOperationSettings <WordTemplateEntity>(WordTemplateOperation.CreateWordReport)
                {
                    Group = EntityOperationGroup.None,
                    Click = ctx => Module["createWordReportFromTemplate"](ctx.Options(), JsFunction.Event,
                                                                          new FindOptions(ctx.Entity.Query.ToQueryName()).ToJS(ctx.Prefix, "New"),
                                                                          ctx.Url.Action((WordController mc) => mc.CreateWordReport()))
                });
            }
        }
Example #10
0
        public bool init(JsModule someCallingModule, JsProcess someProcess)
        {
            var toReturn = true;

            engine = someCallingModule.Engine;
            process = someProcess;

            engine.SetFunction("__log", new Action<object>(Console.WriteLine));
            engine.SetFunction("__updateLevel", new Action<object>(someProcess.OnChangeLogLevel));

            return toReturn;
        }
Example #11
0
 public (string?fileName, AstToplevel?content) ResolveAndLoad(JsModule module)
 {
     if (module.Name.StartsWith("./", StringComparison.Ordinal) ||
         module.Name.StartsWith("../", StringComparison.Ordinal))
     {
         var fileName = PathUtils.Join(PathUtils.Parent(module.ImportedFrom), module.Name);
         _content.TryGetValue(fileName, out var res);
         var parser   = new Parser(new Options(), res ?? "");
         var toplevel = parser.Parse();
         toplevel.FigureOutScope();
         return(fileName, toplevel);
     }
     return(null, null);
 }
Example #12
0
        private async void Submit()
        {
            if (!ValidateInputData())
            {
                return;
            }

            var filepondStatus = await JsModule.InvokeAsync <bool>("checkIfFilepondBusy");

            if (filepondStatus)
            {
                CurrentPage.ShowNotification("Files are still uploading.");
                return;
            }

            _showLoadingIndicator = true;
            await InvokeAsync(StateHasChanged);

            var newBriefing = new Briefing
            {
                Server            = Server,
                Origin            = DepartureAirport.ToUpper(),
                Destination       = ArrivalAirport.ToUpper(),
                OriginRunway      = DepartureRunway.ToUpper(),
                DestinationRunway = ArrivalRunway.ToUpper(),
                FlightLevel       = FlightLevel,
                CruiseSpeed       = GetActualCruiseSpeed(CruiseSpeed),
                DepartureTime     = DepartureTimeSelect.GetDateTime(),
                TimeEnroute       = TimeEnrouteSelect.GetTimeSpan().Ticks,
                FlightPlan        = FlightPlan.ToUpper(),
                Author            = Author,
                Remarks           = Remarks,
                EditPassword      = EditPassword,
                ViewPassword      = ViewPassword,
                CreatedOn         = DateTime.UtcNow
            };

            var attachments = await JsModule.InvokeAsync <string[]>("getFilepondFileIds");

            newBriefing.AttachmentsArray = attachments;

            _newBriefingId = int.Parse(await ApiService.MakeBriefing(newBriefing));

            _showLoadingIndicator = false;
            _showCompleted        = true;

            await JsModule.InvokeVoidAsync("unregisterEvents");

            await InvokeAsync(StateHasChanged);
        }
Example #13
0
    public (string fileName, AstToplevel content) ResolveAndLoad(JsModule module)
    {
        if (module.Name.StartsWith("./", StringComparison.Ordinal))
        {
            var fileName = PathUtils.Join(PathUtils.ParentSafe(module.ImportedFrom), module.Name);
            var input    = File.ReadAllText(fileName + ".js");
            var parser   = new Parser(new Options(), input);
            var toplevel = parser.Parse();
            toplevel.FigureOutScope();
            return(fileName, toplevel);
        }

        throw new NotSupportedException("TestImportResolver supports only relative paths " +
                                        module.ImportedFrom + " " + module.Name);
    }
Example #14
0
        private static void RegisterSaveButton <T>(string partialViewName, bool embedded)
            where T : ModifiableEntity
        {
            ButtonBarEntityHelper.RegisterEntityButtons <T>((ctx, entity) =>
            {
                if (TypeAuthLogic.GetAllowed(PackToRule.GetOrThrow(typeof(T))).MaxUI() >= TypeAllowedBasic.Modify)
                {
                    return new[]
                    {
                        new ToolBarButton(ctx.Prefix, partialViewName)
                        {
                            Text    = AuthMessage.Save.NiceToString(),
                            Style   = BootstrapStyle.Primary,
                            OnClick = embedded?
                                      Module["postDialog"](ctx.Url.Action("save" + partialViewName, "AuthAdmin"), ctx.Prefix):
                                      Module["submitPage"](ctx.Url.Action(partialViewName, "AuthAdmin"), ctx.Prefix),
                        }
                    }
                }
                ;

                return(new ToolBarButton[] { });
            });
        }
Example #15
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                _fplModal.FplReceived += FlightPlanReceived;

                JsModule = await JsRuntime.InvokeAsync <IJSObjectReference>("import", "./js/newBriefing.js");

                await JsModule.InvokeVoidAsync("createFilePond");

                await JsModule.InvokeVoidAsync("registerEvents");

                await JsRuntime.InvokeVoidAsync("startTime");
            }
        }
 public object ConstValue(IConstEvalCtx ctx, JsModule module, object export)
 {
     if (JustModuleExports)
     {
         return(null);
     }
     if (!(export is string))
     {
         return(null);
     }
     var(fileName, content) = _resolver.ResolveAndLoad(module);
     if (fileName == null || content == null)
     {
         return(null);
     }
     try
     {
         var ctx2       = ctx.CreateForSourceName(fileName);
         var treeWalker = new ExportFinder((string)export, ctx2);
         treeWalker.Walk(content);
         if (treeWalker.Result == null)
         {
             return(null);
         }
         var result = treeWalker.Result.ConstValue(ctx2);
         if (result == null)
         {
             return(null);
         }
         if (treeWalker.CompleteResult)
         {
             if (result is IReadOnlyDictionary <object, object> dict)
             {
                 if (dict.TryGetValue((string)export, out result))
                 {
                     return(result);
                 }
                 return(AstUndefined.Instance);
             }
             return(null);
         }
         return(result);
     }
     catch
     {
         return(null);
     }
 }
Example #17
0
        private async void Submit()
        {
            if (!_authenticated)
            {
                return;
            }
            if (!ValidateInputData())
            {
                return;
            }

            var filepondStatus = await JsModule.InvokeAsync <bool>("checkIfFilepondBusy");

            if (filepondStatus)
            {
                CurrentPage.ShowNotification("Files are still uploading.");
                return;
            }

            _showLoadingIndicator = true;
            await InvokeAsync(StateHasChanged);

            var attachments = await JsModule.InvokeAsync <string[]>("getFilepondFileIds");

            // Edit the original briefing entity
            _editedBriefing.Server            = Server;
            _editedBriefing.Origin            = DepartureAirport.ToUpper();
            _editedBriefing.OriginRunway      = DepartureRunway.ToUpper();
            _editedBriefing.Destination       = ArrivalAirport.ToUpper();
            _editedBriefing.DestinationRunway = ArrivalRunway.ToUpper();
            _editedBriefing.FlightLevel       = FlightLevel;
            _editedBriefing.CruiseSpeed       = GetActualCruiseSpeed(CruiseSpeed);
            _editedBriefing.DepartureTime     = DepartureTimeSelect.GetDateTime();
            _editedBriefing.TimeEnroute       = TimeEnrouteSelect.GetTimeSpan().Ticks;
            _editedBriefing.FlightPlan        = FlightPlan.ToUpper();
            _editedBriefing.Author            = Author;
            _editedBriefing.Remarks           = Remarks;
            _editedBriefing.LastEdited        = DateTime.UtcNow;

            _editedBriefing.AttachmentsArray = attachments;

            _editedBriefing.ViewPassword = _briefingType == "Public" ? "none" : ViewPassword;

            await ApiService.EditBriefing(_actualBriefingId, _editedBriefing, _editPassword);

            // Done editing, return to the briefing page.
            NavManager.NavigateTo($"/b/{BriefingId}");
        }
Example #18
0
        public static ToolBarButton ChartQueryButton(QueryButtonContext ctx)
        {
            if (!ChartPermission.ViewCharting.IsAuthorized())
            {
                return(null);
            }

            string chartNewText = ChartMessage.Chart.NiceToString();

            return(new ToolBarButton(ctx.Prefix, "qbChartNew")
            {
                Title = chartNewText,
                Text = chartNewText,
                OnClick = Module["openChart"](ctx.Prefix, ctx.Url.Action("Index", "Chart"))
            });
        }
Example #19
0
            public object ConstValue(IConstEvalCtx ctx, JsModule module, object export)
            {
                if (module.Name == "bobril" && export is string expName)
                {
                    if (expName == "asset" || expName == "styleDef" || expName == "styleDefEx" || expName == "sprite")
                    {
                        return(new JsModuleExport(module.Name, expName));
                    }
                }

                if (module.Name == "bobril-g11n" && export is string expName2)
                {
                    if (expName2 == "t" || expName2 == "f" || expName2 == "dt")
                    {
                        return(new JsModuleExport(module.Name, expName2));
                    }
                }
                return(_ctx.ConstValue(ctx, module, export));
            }
Example #20
0
        public (string?fileName, AstToplevel?content) ResolveAndLoad(JsModule module)
        {
            var fileName = ResolveImport(module.ImportedFrom, module.Name);

            if (fileName == null || fileName == "?")
            {
                return(null, null);
            }
            if (_currentlyTranspiling.Owner.FullPath == fileName)
            {
                return(null, null);
            }

            Result.Path2FileInfo.TryGetValue(module.ImportedFrom, out var sourceInfo);
            var info = CrawlFile(fileName);

            _currentlyTranspiling.ReportTranspilationDependency(sourceInfo.Owner.HashOfContent, module.Name,
                                                                info.Owner.HashOfContent);
            if (_parsedCache.TryGetValue(fileName, out var toplevel))
            {
                return(fileName, toplevel);
            }

            if (info.Type == FileCompilationType.Json)
            {
                _parsedCache.Add(fileName, null);
                return(fileName, null);
            }

            try
            {
                var parser = new Parser(new Options(), info.Output);
                toplevel = parser.Parse();
                toplevel.FigureOutScope();
                _parsedCache.Add(fileName, toplevel);
                return(fileName, toplevel);
            }
            catch
            {
                return(fileName, null);
            }
        }
Example #21
0
        static MapColorProvider[] GetMapColors()
        {
            var strategies = DisconnectedLogic.GetStrategyPairs().SelectDictionary(t => Navigator.ResolveWebTypeName(t), p => p);

            return(new[]
            {
                new MapColorProvider
                {
                    Name = "disconnected",
                    NiceName = "Disconnected",
                    GetJsProvider = ColorModule["disconnectedColors"](MapClient.NodesConstant),
                    AddExtra = t =>
                    {
                        var s = strategies.TryGetC(t.webTypeName);

                        if (s == null)
                        {
                            return;
                        }

                        t.extra["disc-upload"] = s.Upload.ToString();
                        foreach (var mt in t.mlistTables)
                        {
                            mt.extra["disc-upload"] = s.Upload.ToString();
                        }

                        t.extra["disc-download"] = s.Download.ToString();
                        foreach (var mt in t.mlistTables)
                        {
                            mt.extra["disc-download"] = s.Download.ToString();
                        }
                    },
                    Defs = new HtmlStringBuilder(
                        from u in EnumExtensions.GetValues <Upload>()
                        from d in EnumExtensions.GetValues <Download>()
                        select GradientDef(u, d)).ToHtml(),
                    Order = 4,
                },
            });
        }
Example #22
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(MapClient));


                GetColorProviders += () => new[]
                {
                    new MapColorProvider
                    {
                        Name          = "namespace",
                        NiceName      = MapMessage.Namespace.NiceToString(),
                        GetJsProvider = ColorModule["namespace"](NodesConstant)
                    },
                };

                GetColorProviders += () => new[]
                {
                    new MapColorProvider
                    {
                        Name          = "entityKind",
                        NiceName      = typeof(EntityKind).Name,
                        GetJsProvider = ColorModule["entityKind"](NodesConstant)
                    }
                };

                GetColorProviders += () => new[]
                {
                    new MapColorProvider
                    {
                        Name          = "columns",
                        NiceName      = MapMessage.Columns.NiceToString(),
                        GetJsProvider = ColorModule["columns"](NodesConstant, MapMessage.Columns.NiceToString())
                    }
                };

                GetColorProviders += () => new[]
                {
                    new MapColorProvider
                    {
                        Name          = "entityData",
                        NiceName      = typeof(EntityData).Name,
                        GetJsProvider = ColorModule["entityData"](NodesConstant)
                    }
                };

                GetColorProviders += () => new[]
                {
                    new MapColorProvider
                    {
                        Name          = "rows",
                        NiceName      = MapMessage.Rows.NiceToString(),
                        GetJsProvider = ColorModule["rows"](NodesConstant, MapMessage.Rows.NiceToString())
                    }
                };

                GetColorProviders += () => new[]
                {
                    new MapColorProvider
                    {
                        Name          = "tableSize",
                        NiceName      = MapMessage.TableSize.NiceToString(),
                        GetJsProvider = ColorModule["tableSize"](NodesConstant)
                    },
                };
            }
        }
Example #23
0
        public static void Start(bool types, bool property, bool queries, bool resetPassword, bool passwordExpiration, bool singleSignOnMessage)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                ResetPasswordStarted = resetPassword;
                SingleSignOnMessage  = singleSignOnMessage;

                Navigator.RegisterArea(typeof(AuthClient));

                if (!Navigator.Manager.EntitySettings.ContainsKey(typeof(UserEntity)))
                {
                    Navigator.AddSetting(new EntitySettings <UserEntity>());
                }

                if (!Navigator.Manager.EntitySettings.ContainsKey(typeof(RoleEntity)))
                {
                    Navigator.AddSetting(new EntitySettings <RoleEntity>());
                }

                if (resetPassword)
                {
                    Navigator.AddSetting(new EntitySettings <ResetPasswordRequestEntity>());
                }

                if (passwordExpiration)
                {
                    Navigator.AddSetting(new EntitySettings <PasswordExpiresIntervalEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("PasswordValidInterval")
                    });
                }

                Navigator.AddSetting(new ModelEntitySettings <SetPasswordModel>
                {
                    PartialViewName = _ => ViewPrefix.FormatWith("SetPassword"),
                    MappingDefault  = new EntityMapping <SetPasswordModel>(false)
                                      .SetProperty(a => a.PasswordHash, ctx => UserMapping.GetNewPassword(ctx, UserMapping.NewPasswordKey, UserMapping.NewPasswordBisKey))
                });

                if (property)
                {
                    Common.CommonTask += TaskAuthorizeProperties;
                    Mapping.CanChange += Mapping_CanChange;
                }


                var manager = Navigator.Manager;
                if (types)
                {
                    manager.IsCreable  += manager_IsCreable;
                    manager.IsReadOnly += manager_IsReadOnly;
                    manager.IsViewable += manager_IsViewable;
                }

                if (queries)
                {
                    Finder.Manager.IsFindable += q => QueryAuthLogic.GetQueryAllowed(q) != QueryAllowed.None;
                }

                AuthenticationRequiredAttribute.Authenticate = context =>
                {
                    if (UserEntity.Current == null)
                    {
                        string returnUrl = context.HttpContext.Request.SuggestedReturnUrl().PathAndQuery;

                        //send them off to the login page
                        string loginUrl = PublicLoginUrl(returnUrl);
                        context.Result = context.Controller.RedirectHttpOrAjax(loginUrl);
                    }
                };

                Schema.Current.EntityEvents <UserEntity>().Saving += AuthClient_Saving;

                var defaultException = SignumExceptionHandlerAttribute.OnControllerException;
                SignumExceptionHandlerAttribute.OnControllerException = ctx =>
                {
                    if (ctx.Exception is UnauthorizedAccessException && (UserEntity.Current == null || UserEntity.Current.Is(AuthLogic.AnonymousUser)))
                    {
                        string returnUrl = ctx.HttpContext.Request.SuggestedReturnUrl().PathAndQuery;
                        string loginUrl  = PublicLoginUrl(returnUrl);

                        DefaultOnControllerUnauthorizedAccessException(ctx, loginUrl);
                    }
                    else
                    {
                        defaultException(ctx);
                    }
                };

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <UserEntity>(UserOperation.SetPassword)
                    {
                        Click = ctx => Module["setPassword"](ctx.Options(),
                                                             ctx.Url.Action((AuthController c) => c.SetPasswordModel()),
                                                             ctx.Url.Action((AuthController c) => c.SetPasswordOnOk()))
                    },

                    new EntityOperationSettings <UserEntity>(UserOperation.SaveNew)
                    {
                        Click = ctx => Module["saveNew"](ctx.Options(),
                                                         ctx.Url.Action((AuthController c) => c.SaveNewUser()))
                    }
                });
            }
        }
Example #24
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                QueryClient.Start();

                Navigator.RegisterArea(typeof(UserQueriesClient));

                UserAssetsClient.Start();
                UserAssetsClient.RegisterExportAssertLink <UserQueryEntity>();

                LinksClient.RegisterEntityLinks <UserQueryEntity>((lite, ctx) => new[]
                {
                    new QuickLinkAction(UserQueryMessage.Preview, RouteHelper.New().Action <UserQueriesController>(cc => cc.View(lite, null, null)))
                    {
                        IsVisible = UserQueryPermission.ViewUserQuery.IsAuthorized()
                    }
                });

                RouteTable.Routes.MapRoute(null, "UQ/{webQueryName}/{lite}",
                                           new { controller = "UserQueries", action = "View" });

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <UserQueryEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("UserQuery"), IsCreable = EntityWhen.Never
                    },

                    new EmbeddedEntitySettings <QueryFilterEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("QueryFilter"),
                        MappingDefault  = new EntityMapping <QueryFilterEmbedded>(false)
                                          .SetProperty(a => a.Token, QueryTokenMapping(SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement))
                                          .CreateProperty(a => a.Operation)
                                          .CreateProperty(a => a.ValueString)
                    },

                    new EmbeddedEntitySettings <QueryColumnEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("QueryColumn"),
                        MappingDefault  = new EntityMapping <QueryColumnEmbedded>(false)
                                          .SetProperty(a => a.Token, QueryTokenMapping(SubTokensOptions.CanElement))
                                          .CreateProperty(a => a.DisplayName)
                    },

                    new EmbeddedEntitySettings <QueryOrderEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("QueryOrder"),
                        MappingDefault  = new EntityMapping <QueryOrderEmbedded>(false)
                                          .SetProperty(a => a.Token, QueryTokenMapping(SubTokensOptions.CanElement))
                                          .CreateProperty(a => a.OrderType)
                    },
                });

                ButtonBarQueryHelper.RegisterGlobalButtons(ButtonBarQueryHelper_GetButtonBarForQueryName);

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <UserQueryEntity>(UserQueryOperation.Delete)
                    {
                        Click = ctx => Module["deleteUserQuery"](ctx.Options(), Finder.FindRoute(((UserQueryEntity)ctx.Entity).Query.ToQueryName())),
                    }
                });

                LinksClient.RegisterEntityLinks <Entity>((entity, ctrl) =>
                {
                    if (!UserQueryPermission.ViewUserQuery.IsAuthorized())
                    {
                        return(null);
                    }

                    return(UserQueryLogic.GetUserQueriesEntity(entity.EntityType)
                           .Select(cp => new UserQueryQuickLink(cp, entity)).ToArray());
                });
            }
        }
Example #25
0
        static MapColorProvider[] GetMapColors()
        {
            if (!CachePermission.ViewCache.IsAuthorized())
            {
                return(new MapColorProvider[0]);
            }

            var groups = CacheLogic.Statistics().SelectMany(a => a.Explore()).GroupToDictionary(a => a.Table.Name.ToString());
            var semi   = CacheLogic.SemiControllers.ToHashSet();

            var s = Schema.Current;

            var semiNames = semi.Select(t => s.Table(t).Name.ToString()).ToArray();

            return(new[]
            {
                new MapColorProvider
                {
                    Name = "cache-rows",
                    NiceName = "Cache - Rows",
                    GetJsProvider = ColorModule["cacheColors"](MapClient.NodesConstant, "Rows", "cache-rows"),
                    AddExtra = t =>
                    {
                        if (groups.ContainsKey(t.tableName))
                        {
                            var isSemi = semiNames.Contains(t.tableName);
                            t.extra["cache-semi"] = isSemi;
                            foreach (var mt in t.mlistTables)
                            {
                                if (groups.ContainsKey(mt.tableName))
                                {
                                    mt.extra["cache-semi"] = isSemi;
                                }
                            }

                            t.extra["cache-rows"] = groups[t.tableName].Sum(a => a.Count);
                            foreach (var mt in t.mlistTables)
                            {
                                if (groups.ContainsKey(mt.tableName))
                                {
                                    mt.extra["cache-rows"] = groups[mt.tableName].Sum(a => a.Count);
                                }
                            }
                        }
                    },
                    Order = 5,
                    Defs = MvcHtmlString.Create(@"
<pattern id=""pattern-stripe"" width=""4"" height=""4"" patternUnits=""userSpaceOnUse"" patternTransform=""rotate(45)"">
   <rect width=""2"" height=""4"" transform=""translate(0,0)"" fill=""white""></rect>
</pattern>
<mask id=""mask-stripe"">
   <rect x=""0"" y=""0"" width=""100%"" height=""100%"" fill=""url(#pattern-stripe)""></rect>
</mask>")
                },

                new MapColorProvider
                {
                    Name = "cache-invalidations",
                    NiceName = "Cache - Invalidations",
                    GetJsProvider = ColorModule["cacheColors"](MapClient.NodesConstant, "Invalidations", "cache-invalidations"),
                    AddExtra = t =>
                    {
                        if (groups.ContainsKey(t.tableName))
                        {
                            t.extra["cache-invalidations"] = groups[t.tableName].Sum(a => a.Invalidations);
                            foreach (var mt in t.mlistTables)
                            {
                                if (groups.ContainsKey(mt.tableName))
                                {
                                    mt.extra["cache-invalidations"] = groups[mt.tableName].Sum(a => a.Invalidations);
                                }
                            }
                        }
                    },
                    Order = 5,
                },

                new MapColorProvider
                {
                    Name = "cache-loads",
                    NiceName = "Cache - Loads",
                    GetJsProvider = ColorModule["cacheColors"](MapClient.NodesConstant, "Loads", "cache-loads"),
                    AddExtra = t =>
                    {
                        if (groups.ContainsKey(t.tableName))
                        {
                            t.extra["cache-loads"] = groups[t.tableName].Sum(a => a.Loads);
                            foreach (var mt in t.mlistTables)
                            {
                                if (groups.ContainsKey(mt.tableName))
                                {
                                    mt.extra["cache-loads"] = groups[mt.tableName].Sum(a => a.Loads);
                                }
                            }
                        }
                    },
                    Order = 5,
                },

                new MapColorProvider
                {
                    Name = "cache-load-time",
                    NiceName = "Cache - Load Time",
                    GetJsProvider = ColorModule["cacheColors"](MapClient.NodesConstant, "ms Load Time", "cache-load-time"),
                    AddExtra = t =>
                    {
                        if (groups.ContainsKey(t.tableName))
                        {
                            t.extra["cache-load-time"] = groups[t.tableName].Sum(a => a.SumLoadTime.Milliseconds);
                            foreach (var mt in t.mlistTables)
                            {
                                if (groups.ContainsKey(mt.tableName))
                                {
                                    mt.extra["cache-load-time"] = groups[mt.tableName].Sum(a => a.SumLoadTime.Milliseconds);
                                }
                            }
                        }
                    },
                    Order = 5,
                },
            });
        }
Example #26
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <AddressEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Address")
                    },

                    new EntitySettings <TerritoryEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Territory")
                    },
                    new EntitySettings <RegionEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Region")
                    },
                    new EntitySettings <EmployeeEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Employee")
                    },

                    new EntitySettings <SupplierEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Supplier")
                    },
                    new EntitySettings <ProductEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Product")
                    },
                    new EntitySettings <CategoryEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Category")
                    },

                    new EntitySettings <PersonEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Person")
                    },
                    new EntitySettings <CompanyEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Company")
                    },

                    new EntitySettings <OrderEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Order")
                    },
                    new EmbeddedEntitySettings <OrderDetailsEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("OrderDetails")
                    },
                    new EntitySettings <ShipperEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("Shipper")
                    },

                    new EmbeddedEntitySettings <OrderFilterModel>(),

                    new EntitySettings <ApplicationConfigurationEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("ApplicationConfiguration")
                    },
                });

                Constructor.Register(ctx => new ApplicationConfigurationEntity
                {
                    Sms   = new SMSConfigurationEntity(),
                    Email = new EmailConfigurationEntity()
                });

                QuerySettings.RegisterPropertyFormat((CategoryEntity e) => e.Picture,
                                                     new CellFormatter((html, obj) => obj == null ? null :
                                                                       new HtmlTag("img")
                                                                       .Attr("src", Base64Data((EmbeddedFileEntity)obj))
                                                                       .Attr("alt", obj.ToString())
                                                                       .Attr("style", "width:48px").ToHtmlSelf())
                {
                    TextAlign = "center"
                });                                                                         // Category

                QuerySettings.RegisterPropertyFormat((EmployeeEntity e) => e.Photo,
                                                     new CellFormatter((html, obj) => obj == null ? null :
                                                                       new HtmlTag("img")
                                                                       .Attr("src", RouteHelper.New().Action((FileController c) => c.Download(new RuntimeInfo((Lite <FileEntity>)obj).ToString())))
                                                                       .Attr("alt", obj.ToString())
                                                                       .Attr("style", "width:48px").ToHtmlSelf())
                {
                    TextAlign = "center"
                });                                                                         //Emmployee


                Finder.AddQuerySetting(new QuerySettings(OrderQuery.OrderSimple)
                {
                    SimpleFilterBuilder = (html, ctx, querySettings, findOptions) => new SimpleFilterBuilder(
                        html.Partial(SouthwindClient.ViewPrefix.FormatWith("OrderFilter"), new TypeContext <OrderFilterModel>(new OrderFilterModel(), ctx.Prefix)),
                        html.UrlHelper().Action((HomeController s) => s.OrderFilterFilters()))
                });

                Constructor.Register(ctx => new EmployeeEntity {
                    Address = new AddressEntity()
                });
                Constructor.Register(ctx => new PersonEntity {
                    Address = new AddressEntity()
                });
                Constructor.Register(ctx => new CompanyEntity {
                    Address = new AddressEntity()
                });
                Constructor.Register(ctx => new SupplierEntity {
                    Address = new AddressEntity()
                });

                OperationClient.AddSettings(new List <OperationSettings>()
                {
                    new ConstructorOperationSettings <OrderEntity>(OrderOperation.Create)
                    {
                        ClientConstructor = ctx => OrderModule["createOrder"](ClientConstructorManager.ExtraJsonParams,
                                                                              new FindOptions(typeof(CustomerEntity))
                        {
                            SearchOnLoad = true
                        }.ToJS(ctx.ClientConstructorContext.Prefix, "cust")),

                        Constructor = ctx =>
                        {
                            var cust = ctx.ConstructorContext.Controller.TryParseLite <CustomerEntity>("customer");

                            return(OperationLogic.Construct(OrderOperation.Create, cust));
                        }
                    },

                    new ContextualOperationSettings <ProductEntity>(OrderOperation.CreateOrderFromProducts)
                    {
                        Click = ctx => OrderModule["createOrderFromProducts"](ctx.Options(),
                                                                              new FindOptions(typeof(CustomerEntity))
                        {
                            SearchOnLoad = true
                        }.ToJS(ctx.Prefix, "cust"),
                                                                              ctx.Url.Action((HomeController c) => c.CreateOrderFromProducts()),
                                                                              JsFunction.Event)
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.SaveNew)
                    {
                        IsVisible = ctx => ctx.Entity.IsNew
                    },
                    new EntityOperationSettings <OrderEntity>(OrderOperation.Save)
                    {
                        IsVisible = ctx => !ctx.Entity.IsNew
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Cancel)
                    {
                        ConfirmMessage = ctx => ((OrderEntity)ctx.Entity).State == OrderState.Shipped ? OrderMessage.CancelShippedOrder0.NiceToString(ctx.Entity) : null
                    },

                    new EntityOperationSettings <OrderEntity>(OrderOperation.Ship)
                    {
                        Click = ctx => OrderModule["shipOrder"](ctx.Options(),
                                                                ctx.Url.Action((HomeController c) => c.ShipOrder()),
                                                                GetValueLineOptions(ctx.Prefix),
                                                                false),

                        Contextual =
                        {
                            Click = ctx => OrderModule["shipOrder"](ctx.Options(),
                                                                    ctx.Url.Action((HomeController c) => c.ShipOrder()),
                                                                    GetValueLineOptions(ctx.Prefix),
                                                                    true),
                        }
                    },
                });

                RegisterQuickLinks();
            }
        }
Example #27
0
        public static void Start(bool smtpConfig, bool newsletter, bool pop3Config, bool emailReport, Type[] quickLinkFrom)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Navigator.RegisterArea(typeof(MailingClient));
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <EmailAttachmentEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailAttachment")
                    },
                    new EntitySettings <EmailPackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailPackage")
                    },

                    new EntitySettings <EmailMessageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMessage"), AvoidValidateRequest = true
                    },

                    new EmbeddedEntitySettings <EmailAddressEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailAddress")
                    },
                    new EmbeddedEntitySettings <EmailRecipientEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailRecipient")
                    },

                    new EmbeddedEntitySettings <EmailConfigurationEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailConfiguration")
                    },
                    new EntitySettings <SystemEmailEntity> {
                    },

                    new EntitySettings <EmailMasterTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMasterTemplate"), AvoidValidateRequest = true
                    },
                    new EmbeddedEntitySettings <EmailMasterTemplateMessageEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMasterTemplateMessage"),
                        MappingDefault  = new EntityMapping <EmailMasterTemplateMessageEmbedded>(true)
                                          .SetProperty(emtm => emtm.MasterTemplate, ctx =>
                        {
                            return((EmailMasterTemplateEntity)ctx.Parent.Parent.Parent.Parent.UntypedValue);
                        })
                    },

                    new EntitySettings <EmailTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplate"), AvoidValidateRequest = true
                    },
                    new EmbeddedEntitySettings <EmailTemplateMessageEmbedded>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateMessage")
                    },

                    new EmbeddedEntitySettings <EmailTemplateContactEmbedded>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateContact"),
                        MappingDefault  = new EntityMapping <EmailTemplateContactEmbedded>(true)
                                          .SetProperty(ec => ec.Token, ctx =>
                        {
                            string tokenStr = UserAssetsHelper.GetTokenString(ctx);
                            return(ParseQueryToken(tokenStr, ctx.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", EntityBaseKeys.RuntimeInfo)]));
                        }),
                    },

                    new EmbeddedEntitySettings <EmailTemplateRecipientEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateRecipient"),
                        MappingDefault  = new EntityMapping <EmailTemplateRecipientEntity>(true)
                                          .SetProperty(ec => ec.Token, ctx =>
                        {
                            string tokenStr = UserAssetsHelper.GetTokenString(ctx);

                            return(ParseQueryToken(tokenStr, ctx.Parent.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", EntityBaseKeys.RuntimeInfo)]));
                        })
                    },
                });

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <EmailTemplateEntity>(EmailMessageOperation.CreateEmailFromTemplate)
                    {
                        Group = EntityOperationGroup.None,
                        Click = ctx => Module["createMailFromTemplate"](ctx.Options(), JsFunction.Event,
                                                                        new FindOptions(((EmailTemplateEntity)ctx.Entity).Query.ToQueryName()).ToJS(ctx.Prefix, "New"),
                                                                        ctx.Url.Action((MailingController mc) => mc.CreateMailFromTemplateAndEntity()))
                    }
                });

                if (smtpConfig)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SmtpConfigurationEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("SmtpConfiguration")
                        },
                        new EmbeddedEntitySettings <SmtpNetworkDeliveryEmbedded> {
                            PartialViewName = e => ViewPrefix.FormatWith("SmtpNetworkDelivery")
                        },
                        new EmbeddedEntitySettings <ClientCertificationFileEmbedded> {
                            PartialViewName = e => ViewPrefix.FormatWith("ClientCertificationFile")
                        },
                    });
                }

                if (newsletter)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <NewsletterEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Newsletter"), AvoidValidateRequest = true
                        },
                        new EntitySettings <NewsletterDeliveryEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("NewsletterDelivery")
                        },
                    });

                    OperationClient.AddSettings(new List <OperationSettings>
                    {
                        new EntityOperationSettings <NewsletterEntity>(NewsletterOperation.RemoveRecipients)
                        {
                            Click = ctx => Module["removeRecipients"](ctx.Options(),
                                                                      new FindOptions(typeof(NewsletterDeliveryEntity), "Newsletter", ctx.Entity).ToJS(ctx.Prefix, "New"),
                                                                      ctx.Url.Action((MailingController mc) => mc.RemoveRecipientsExecute()))
                        },

                        new EntityOperationSettings <NewsletterEntity>(NewsletterOperation.Send)
                        {
                            Group = EntityOperationGroup.None,
                        }
                    });
                }

                if (emailReport)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SendEmailTaskEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("SendEmailTask")
                        }
                    });
                }

                if (pop3Config)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <Pop3ConfigurationEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Pop3Configuration")
                        },
                        new EntitySettings <Pop3ReceptionEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Pop3Reception")
                        },
                    });
                }

                if (quickLinkFrom != null)
                {
                    LinksClient.RegisterEntityLinks <Entity>((lite, ctx) =>
                    {
                        if (!quickLinkFrom.Contains(lite.EntityType))
                        {
                            return(null);
                        }

                        return(new[] { new QuickLinkExplore(typeof(EmailMessageEntity), "Target", lite) });
                    });
                }


                TasksGetWebMailBody += WebMailProcessor.ReplaceUntrusted;
                TasksGetWebMailBody += WebMailProcessor.CidToFilePath;

                TasksSetWebMailBody += WebMailProcessor.AssertNoUntrusted;
                TasksSetWebMailBody += WebMailProcessor.FilePathToCid;

                Navigator.EntitySettings <EmailMessageEntity>().MappingMain.AsEntityMapping()
                .RemoveProperty(a => a.Body)
                .SetProperty(a => a.Body, ctx =>
                {
                    if (!ctx.HasInput)
                    {
                        return(ctx.None());
                    }

                    var email = ((EmailMessageEntity)ctx.Parent.UntypedValue);

                    return(SetWebMailBody(ctx.Input, new WebMailOptions
                    {
                        Attachments = email.Attachments,
                        UntrustedImage = null,
                        Url = RouteHelper.New(),
                    }));
                });

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("AsyncEmailPanel",
                                                                         () => AsyncEmailSenderPermission.ViewAsyncEmailSenderPanel.IsAuthorized(),
                                                                         uh => uh.Action((AsyncEmailSenderController pc) => pc.View())));
            }
        }
Example #28
0
        static ToolBarButton[] ButtonBarQueryHelper_GetButtonBarForQueryName(QueryButtonContext ctx)
        {
            if (ctx.Prefix.HasText())
            {
                return(null);
            }

            if (ExcelReport && DynamicQueryManager.Current.QueryAllowed(typeof(ExcelReportEntity), false))

            {
                var items = new List <IMenuItem>();

                if (ToExcelPlain)
                {
                    items.Add(PlainExcel(ctx).ToMenuItem());
                }

                List <Lite <ExcelReportEntity> > reports = ExcelLogic.GetExcelReports(ctx.QueryName);

                if (reports.Count > 0)
                {
                    if (items.Count > 0)
                    {
                        items.Add(new MenuItemSeparator());
                    }

                    foreach (Lite <ExcelReportEntity> report in reports)
                    {
                        items.Add(new MenuItem(ctx.Prefix, "sfExcelReport" + report.Id)
                        {
                            Title   = report.ToString(),
                            Text    = report.ToString(),
                            OnClick = Module["toExcelReport"](ctx.Prefix, ctx.Url.Action("ExcelReport", "Excel"), report.Key()),
                        });
                    }
                }

                items.Add(new MenuItemSeparator());

                var current = QueryLogic.GetQueryEntity(ctx.QueryName).ToLite().Key();

                items.Add(new MenuItem(ctx.Prefix, "qbReportAdminister")
                {
                    Title   = ExcelMessage.Administer.NiceToString(),
                    Text    = ExcelMessage.Administer.NiceToString(),
                    OnClick = Module["administerExcelReports"](ctx.Prefix, Finder.ResolveWebQueryName(typeof(ExcelReportEntity)), current),
                });

                items.Add(new MenuItem(ctx.Prefix, "qbReportCreate")
                {
                    Title   = ExcelMessage.CreateNew.NiceToString(),
                    Text    = ExcelMessage.CreateNew.NiceToString(),
                    OnClick = Module["createExcelReports"](ctx.Prefix, ctx.Url.Action("Create", "Excel"), current),
                });

                return(new ToolBarButton[]
                {
                    new ToolBarDropDown(ctx.Prefix, "tmExcel")
                    {
                        Title = "Excel",
                        Text = "Excel",
                        Items = items
                    }
                });
            }
            else
            {
                if (ToExcelPlain)
                {
                    return new ToolBarButton[] { PlainExcel(ctx) }
                }
                ;
            }

            return(null);
        }