示例#1
0
        internal static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ImportUserAssets", () => UserAssetPermission.UserAssetsToXML.IsAuthorized(), win =>
                {
                    OpenFileDialog ofd = new OpenFileDialog
                    {
                        DefaultExt = ".xml",
                    };

                    if (ofd.ShowDialog() != true)
                    {
                        return;
                    }

                    byte[] bytes = File.ReadAllBytes(ofd.FileName);

                    ImportUserAssetsConfirmation config = new ImportUserAssetsConfirmation
                    {
                        DataContext = Server.Return((IUserAssetsServer s) => s.PreviewAssetImport(bytes))
                    };

                    if (config.ShowDialog() == true)
                    {
                        Server.Execute((IUserAssetsServer s) => s.AssetImport(bytes, (UserAssetPreviewModel)config.DataContext));
                    }
                }));
            }
        }
示例#2
0
        internal static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(UserAssetsClient));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ImportUserAssets", () => UserAssetPermission.UserAssetsToXML.IsAuthorized(), url =>
                                                                         url.Action((UserAssetController a) => a.Import())));
            }
        }
示例#3
0
 public static void Start()
 {
     if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
     {
         SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ClientProfiler",
                                                                  () => true,
                                                                  win =>
         {
             ProfilerUploader.OpenProfilerUploader();
         }));
     }
 }
示例#4
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(CacheClient));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ViewCache",
                                                                         () => CachePermission.ViewCache.IsAuthorized(),
                                                                         uh => uh.Action((CacheController cc) => cc.View())));

                MapClient.GetColorProviders += GetMapColors;
            }
        }
示例#5
0
        public static void Start(bool simpleTask)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(SchedulerClient));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <ScheduledTaskLogEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduledTaskLog")
                    },
                    new EntitySettings <ScheduledTaskEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduledTask")
                    },

                    new EntitySettings <ScheduleRuleMinutelyEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduleRuleMinutely")
                    },
                    new EntitySettings <ScheduleRuleWeekDaysEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduleRuleWeekDays")
                    },
                    new EntitySettings <ScheduleRuleMonthsEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("ScheduleRuleMonths")
                    },

                    new EntitySettings <HolidayCalendarEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("HolidayCalendar")
                    },
                    new EmbeddedEntitySettings <HolidayEmbedded> {
                        PartialViewName = _ => ViewPrefix.FormatWith("Holiday")
                    },
                });

                if (simpleTask)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SimpleTaskSymbol> {
                            PartialViewName = _ => ViewPrefix.FormatWith("SimpleTask")
                        },
                    });
                }

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("SchedulerPanel",
                                                                         () => SchedulerPermission.ViewSchedulerPanel.IsAuthorized(),
                                                                         uh => uh.Action((SchedulerController sc) => sc.View())));
            }
        }
示例#6
0
        public static void Start(bool packages, bool packageOperations)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(ProcessClient), "Processes");

                UrlsRepository.DefaultSFUrls.Add("processFromMany", url => url.Action((ProcessController pc) => pc.ProcessFromMany()));

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <ProcessEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("Process"),
                    },
                    new EntitySettings <ProcessAlgorithmSymbol> {
                        PartialViewName = e => ViewPrefix.FormatWith("ProcessAlgorithm")
                    },
                });

                if (packages || packageOperations)
                {
                    Navigator.AddSetting(new EntitySettings <PackageLineEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("PackageLine")
                    });
                }

                if (packages)
                {
                    Navigator.AddSetting(new EntitySettings <PackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("Package")
                    });
                }

                if (packageOperations)
                {
                    Navigator.AddSetting(new EntitySettings <PackageOperationEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("PackageOperation")
                    });

                    OperationClient.Manager.CustomizeMenuItem += CustomizeMenuItemForProcess;
                }

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ProcessPanel",
                                                                         () => ProcessPermission.ViewProcessPanel.IsAuthorized(),
                                                                         uh => uh.Action((ProcessController pc) => pc.View())));
            }
        }
示例#7
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(ProfilerClient));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ProfilerHeavy",
                                                                         () => ProfilerPermission.ViewHeavyProfiler.IsAuthorized(),
                                                                         uh => uh.Action((ProfilerController pc) => pc.Heavy(false))));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ProfilerTimeTable",
                                                                         () => ProfilerPermission.ViewTimeTracker.IsAuthorized(),
                                                                         uh => uh.Action((ProfilerController pc) => pc.TimeTable())));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("ProfilerTimes",
                                                                         () => ProfilerPermission.ViewTimeTracker.IsAuthorized(),
                                                                         uh => uh.Action((ProfilerController pc) => pc.Times())));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("OverrideSessionTimeout",
                                                                         () => ProfilerPermission.OverrideSessionTimeout.IsAuthorized(),
                                                                         uh => uh.Action((ProfilerController pc) => pc.OverrideSessionTimeout(60))));
            }
        }
示例#8
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())));
            }
        }
示例#9
0
        public static void Start(bool types, bool property, bool queries, bool permissions, bool operations, bool defaultPasswordExpiresLogic)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Server.Connecting += UpdateCache;

                if (types)
                {
                    TypeAuthClient.Start();
                }
                if (property)
                {
                    PropertyAuthClient.Start();
                }
                if (queries)
                {
                    QueryAuthClient.Start();
                }
                if (permissions)
                {
                    PermissionAuthClient.Start();
                }
                if (operations)
                {
                    OperationAuthClient.Start();
                }

                UpdateCache();

                Navigator.AddSetting(new EntitySettings <UserEntity> {
                    View = e => new User(), Icon = ImageLoader.GetImageSortName("user.png")
                });
                Navigator.AddSetting(new EntitySettings <RoleEntity> {
                    View = e => new Role(), Icon = ImageLoader.GetImageSortName("role.png")
                });

                if (defaultPasswordExpiresLogic)
                {
                    Navigator.AddSetting(new EntitySettings <PasswordExpiresIntervalEntity> {
                        View = e => new PasswordExpiresInterval()
                    });
                }

                OperationClient.AddSettings(new List <OperationSettings>()
                {
                    new EntityOperationSettings <UserEntity>(UserOperation.SetPassword)
                    {
                        IsVisible = e => false
                    },
                    new EntityOperationSettings <UserEntity>(UserOperation.SaveNew)
                    {
                        IsVisible = e => e.Entity.IsNew
                    },
                    new EntityOperationSettings <UserEntity>(UserOperation.Save)
                    {
                        IsVisible = e => !e.Entity.IsNew
                    }
                });

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("UpdateAuthCache",
                                                                         () => true,
                                                                         win =>
                {
                    UpdateCache();

                    MessageBox.Show(AuthMessage.AuthorizationCacheSuccessfullyUpdated.NiceToString());
                }));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("DownloadAuthRules",
                                                                         () => BasicPermission.AdminRules.IsAuthorized(),
                                                                         win =>
                {
                    SaveFileDialog sfc = new SaveFileDialog()
                    {
                        FileName = "AuthRules.xml"
                    };
                    if (sfc.ShowDialog() == true)
                    {
                        var bytes = Server.Return((ILoginServer ls) => ls.DownloadAuthRules());

                        File.WriteAllBytes(sfc.FileName, bytes);
                    }
                }));
            }
        }
示例#10
0
        public static void Start(bool types, bool properties, bool queries, bool operations, bool permissions)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Navigator.RegisterArea(typeof(AuthAdminClient));
                if (Navigator.Manager.EntitySettings.ContainsKey(typeof(UserEntity)))
                {
                    Navigator.EntitySettings <UserEntity>().PartialViewName = _ => ViewPrefix.FormatWith("User");
                }
                else
                {
                    Navigator.AddSetting(new EntitySettings <UserEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("User")
                    });
                }

                Navigator.EntitySettings <UserEntity>().MappingMain.AsEntityMapping().RemoveProperty(a => a.PasswordHash);

                if (Navigator.Manager.EntitySettings.ContainsKey(typeof(RoleEntity)))
                {
                    Navigator.EntitySettings <RoleEntity>().PartialViewName = _ => ViewPrefix.FormatWith("Role");
                }
                else
                {
                    Navigator.AddSetting(new EntitySettings <RoleEntity> {
                        PartialViewName = _ => ViewPrefix.FormatWith("Role")
                    });
                }

                if (types)
                {
                    RegisterTypes();
                }

                if (properties)
                {
                    Register <PropertyRulePack, PropertyAllowedRule, PropertyRouteEntity, PropertyAllowed, string>("properties", a => a.Resource.Path,
                                                                                                                   Mapping.New <PropertyAllowed>(), true);
                }

                if (queries)
                {
                    QueryClient.Start();

                    Register <QueryRulePack, QueryAllowedRule, QueryEntity, QueryAllowed, string>("queries", a => a.Resource.Key,
                                                                                                  Mapping.New <QueryAllowed>(), true);
                }

                if (operations)
                {
                    Register <OperationRulePack, OperationAllowedRule, OperationSymbol, OperationAllowed, OperationSymbol>("operations", a => a.Resource,
                                                                                                                           Mapping.New <OperationAllowed>(), true);
                }

                if (permissions)
                {
                    Register <PermissionRulePack, PermissionAllowedRule, PermissionSymbol, bool, PermissionSymbol>("permissions", a => a.Resource,
                                                                                                                   Mapping.New <bool>(), false);
                }

                LinksClient.RegisterEntityLinks <RoleEntity>((role, ctx) =>
                                                             !BasicPermission.AdminRules.IsAuthorized() ? null :
                                                             new[]
                {
                    types ? new QuickLinkAction(AuthAdminMessage.TypeRules, RouteHelper.New().Action((AuthAdminController c) => c.Types(role))): null,
                    permissions ? new QuickLinkAction(AuthAdminMessage.PermissionRules, RouteHelper.New().Action((AuthAdminController c) => c.Permissions(role))): null,
                });

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("DownloadAuthRules",
                                                                         () => BasicPermission.AdminRules.IsAuthorized(),
                                                                         uh => uh.Action((AuthAdminController aac) => aac.Export())));

                MapClient.GetColorProviders += GetMapColors;
            }
        }
示例#11
0
        /// <param name="copyTranslationsToRootFolder">avoids Web Application restart when translations change</param>
        public static void Start(ITranslator translator, bool translatorUser, bool translationReplacement, bool instanceTranslator, bool copyNewTranslationsToRootFolder = true)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Translator = translator;

                Navigator.RegisterArea(typeof(TranslationClient));

                if (translatorUser)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <TranslatorUserEntity> {
                            PartialViewName = t => ViewPrefix.FormatWith("TranslatorUser")
                        },
                        new EmbeddedEntitySettings <TranslatorUserCultureEmbedded> {
                            PartialViewName = t => ViewPrefix.FormatWith("TranslatorUserCulture")
                        },
                    });
                }

                if (translationReplacement)
                {
                    FileRepositoryManager.Register(new LocalizedJavaScriptRepository(typeof(TranslationJavascriptMessage), "translation"));

                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <TranslationReplacementEntity> {
                            PartialViewName = t => ViewPrefix.FormatWith("TranslationReplacement")
                        },
                    });
                }

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("TranslateCode",
                                                                         () => TranslationPermission.TranslateCode.IsAuthorized(),
                                                                         uh => uh.Action((TranslationController tc) => tc.Index(null))));

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("LocalizableTypeUsedNotLocalized",
                                                                         () => TranslationPermission.TranslateCode.IsAuthorized(),
                                                                         uh => uh.Action((TranslationController tc) => tc.LocalizableTypeUsedNotLocalized(null))));

                if (instanceTranslator)
                {
                    SpecialOmniboxProvider.Register(new SpecialOmniboxAction("TranslateInstances",
                                                                             () => TranslationPermission.TranslateInstances.IsAuthorized(),
                                                                             uh => uh.Action((TranslatedInstanceController tic) => tic.Index())));
                }


                if (copyNewTranslationsToRootFolder)
                {
                    string path = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(new Uri(typeof(DescriptionManager).Assembly.CodeBase).LocalPath)), "Translations");

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    var existingFiles = Directory.GetFiles(path).ToHashSet();

                    foreach (string fromFile in Directory.GetFiles(DescriptionManager.TranslationDirectory))
                    {
                        string toFile = Path.Combine(path, Path.GetFileName(fromFile));

                        if (!existingFiles.Contains(toFile) || File.GetLastWriteTime(toFile) < File.GetLastWriteTime(fromFile))
                        {
                            File.Copy(fromFile, toFile, overwrite: true);
                        }
                    }

                    DescriptionManager.TranslationDirectory = path;
                }
            }
        }