Exemplo n.º 1
0
 public void RegisterProcessUnit(string Context, IPipedProcessUnit unit)
 {
     OperatorAuthentication.AuthedAction(Context, () =>
     {
         FileInfo fi = new FileInfo(Assembly.GetAssembly(unit.GetType()).FullName);
         processUnits.Add(MappedType.CreateFrom(unit));
         Trace.WriteLine(Language.Query("LWMS.Pipeline.Register.R", "Registered R Unit: {0}", unit.GetType().ToString()));
     }, false, true, PermissionID.RTRegisterRProcessUnit, PermissionID.RuntimeAll);
 }
Exemplo n.º 2
0
 public void Init(params MappedType[] units)
 {
     if (units.Length == 0)
     {
         FileInfo fi = new FileInfo(Assembly.GetAssembly(typeof(DefaultProcessUnit)).FullName);
         _processUnits.Add(MappedType.CreateFrom(new DefaultProcessUnit()));
     }
     else
     {
         _processUnits = new List <MappedType>(units);
     }
 }
Exemplo n.º 3
0
 public PipelineData Process(PipelineData Input)
 {
     {
         HttpListenerRoutedContext context = Input.PrimaryData as HttpListenerRoutedContext;
         if (requests is null)
         {
             requests = ApplicationConfiguration.Current.GetValueArray("RoutedRequests");
         }
         if (RouteTargets == null)
         {
             var targets = ApplicationConfiguration.Current.GetValueArray("RouteTargets");
             RouteTargets = new List <MappedType>();
             //Initialize the targets.
             foreach (var item in targets)
             {
                 var        parted     = item.Split(',');
                 FileInfo   fi         = new(parted[0]);
                 var        asm        = DomainManager.LoadFromFile(context.PipelineAuth, fi.FullName);
                 var        t          = asm.GetType(parted[1]);
                 MappedType mappedType = MappedType.CreateFrom(t);
                 RouteTargets.Add(mappedType);
             }
         }
         else if (RouteTargets.Count is 0)
         {
             var targets = ApplicationConfiguration.Current.GetValueArray("RouteTargets");
             foreach (var item in targets)
             {
                 var        parted     = item.Split(',');
                 FileInfo   fi         = new(parted[0]);
                 var        asm        = DomainManager.LoadFromFile(context.PipelineAuth, fi.FullName);
                 var        t          = asm.GetType(parted[1]);
                 MappedType mappedType = MappedType.CreateFrom(t);
                 RouteTargets.Add(mappedType);
             }
         }
         var path0 = context.Request.Url.LocalPath.Substring(1); //Dispose the first '/'
         if (path0 is not "")                                    //Ignore when the path is empty to prevent potential problems when performing matching.
         {
             for (int i = 0; i < requests.Length; i++)
             {
                 if (path0.ToUpper().StartsWith(requests[i].ToUpper()))//Ignore case
                 {
                     (Input.SecondaryData as HttpPipelineArguments).isHandled = (RouteTargets[i].TargetObject as IHttpEventHandler).Handle(context, requests[i]);
                     return(Input);
                 }
             }
         }
     }
     return(Input);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Register and initialize a specified module.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static bool Register(string AuthContext, string item)
        {
            bool __ = false;

            try
            {
                OperatorAuthentication.AuthedAction(AuthContext, () =>
                {
                    try
                    {
                        var asm     = Assembly.LoadFrom(item);
                        FileInfo fi = new(item);
                        var TPS     = asm.GetTypes();
                        foreach (var TP in TPS)
                        {
                            if (typeof(IManageCommand).IsAssignableFrom(TP))
                            {
                                var MC = (IManageCommand)Activator.CreateInstance(TP);
                                Trace.WriteLine(Language.Query("LWMS.Commands.Found", "Found Manage Command:{0},{1}", MC.CommandName, TP.ToString()));
                                ManageCommands.Add(MC.CommandName, MappedType.CreateFrom(MC));
                                var alias = MC.Alias;
                                foreach (var MCA in alias)
                                {
                                    ManageCommandAliases.Add(MCA, MappedType.CreateFrom(MC));
                                }
                            }
                        }
                        __ = true;
                    }
                    catch (Exception)
                    {
                        Trace.Write(Language.Query("LWMS.Commands.Error.LoadModule", "Cannot load management module: {0}", item));
                    }
                }, false, true, PermissionID.RegisterCmdModule, PermissionID.CmdModuleAll);
            }
            catch (Exception)
            {
                Trace.Write(Language.Query("LWMS.Commands.Error.LoadModule", "Cannot load management module: {0}", item));
            }
            return(__);
        }