コード例 #1
0
    /// <summary>
    ///     Callback for when a client attempts to upload a resource.
    /// </summary>
    /// <param name="msg"></param>
    /// <exception cref="NotImplementedException"></exception>
    protected override async void ResourceUploadMsg(NetworkResourceUploadMessage msg)
    {
        // Do not allow uploading any new resources if it has been disabled.
        // Note: Any resources uploaded before being disabled will still be kept and sent.
        if (!Enabled)
            return;

        if (!_playerManager.TryGetSessionByChannel(msg.MsgChannel, out var session))
            return;

        // +QUERY only for now.
        if (!_adminManager.HasAdminFlag(session, AdminFlags.Query))
            return;

        // Ensure the data is under the current size limit, if it's currently enabled.
        if (SizeLimit > 0f && msg.Data.Length * BytesToMegabytes > SizeLimit)
            return;

        ContentRoot.AddOrUpdateFile(msg.RelativePath, msg.Data);

        // Now we broadcast the message!
        foreach (var channel in _serverNetManager.Channels)
        {
            channel.SendMessage(msg);
        }

        if (!StoreUploaded)
            return;

        await _serverDb.AddUploadedResourceLogAsync(session.UserId, DateTime.Now, msg.RelativePath.ToString(), msg.Data);
    }
コード例 #2
0
    internal XamlIslandRoot(WinUICoreServices coreServices)
    {
        _contentRoot = coreServices.ContentRootCoordinator.CreateContentRoot(ContentRootType.XamlIsland, Colors.Transparent, this);

        //Uno specific - flag as VisualTreeRoot for interop with existing logic
        IsVisualTreeRoot = true;
    }
コード例 #3
0
        public void MoveRoot(int ContentID, int ContentNewParentID)
        {
            List <int> _Childs = new List <int>();

            _Childs.Add(ContentID);
            GetChildsID(ref _Childs, ContentID);

            List <int> _NewParents = new List <int>();

            _NewParents.Add(ContentNewParentID);
            // _NewParents.Add(ContentID);
            GetParentsID(ref _NewParents, ContentNewParentID);

            List <int> _OldParents = new List <int>();

            //_OldParents.Add(ContentID);
            GetParentsID(ref _OldParents, ContentID);

            using (var _c = db)
            {
                foreach (var item in _Childs)
                {
                    var _ToDelete = _c.ContentRoots.Where(m => _OldParents.Contains(m.ContentParentID) && m.ContentID == item);
                    _c.ContentRoots.RemoveRange(_ToDelete);
                    _c.SaveChanges();

                    foreach (var item2 in _NewParents)
                    {
                        var _Model = new ContentRoot(item, item2);
                        _c.ContentRoots.Add(_Model);
                        _c.SaveChanges();
                    }
                }
            }
        }
コード例 #4
0
        private void ConfigureFileSystem(IHostEnvironment hostEnvironment)
        {
            hostEnvironment.ContentRootFileProvider = new LocalFileSystem(hostEnvironment.ContentRootPath);

            if (hostEnvironment is IWebHostEnvironment we)
            {
                we.WebRootFileProvider = new LocalFileSystem(we.WebRootPath);
                WebRoot = (IFileSystem)we.WebRootFileProvider;
            }
            else
            {
                WebRoot = (IFileSystem)hostEnvironment.ContentRootFileProvider;
            }

            // TODO: (core) Read stuff from config and resolve tenant. Check folders and create them also.
            ThemesRoot  = new LocalFileSystem(ContentRoot.MapPath("Themes"));
            ModulesRoot = new LocalFileSystem(ContentRoot.MapPath("Modules"));
            AppDataRoot = new LocalFileSystem(ContentRoot.MapPath("App_Data"));

            if (!AppDataRoot.DirectoryExists("Tenants"))
            {
                AppDataRoot.TryCreateDirectory("Tenants");
            }

            CommonHelper.ContentRoot = ContentRoot;
            WebHelper.WebRoot        = WebRoot;
        }
コード例 #5
0
        public void default_index_can_be_changed()
        {
            var root = new ContentRoot {
                DefaultFileName = "default.html"
            };

            root.DefaultFileName.ShouldBe("default.html");
        }
コード例 #6
0
 private void ServerNetManagerOnConnected(object?sender, NetChannelArgs e)
 {
     foreach (var(path, data) in ContentRoot.GetAllFiles())
     {
         var msg = _serverNetManager.CreateNetMessage <NetworkResourceUploadMessage>();
         msg.RelativePath = path;
         msg.Data         = data;
         e.Channel.SendMessage(msg);
     }
 }
コード例 #7
0
        public void default_folder_can_be_changed()
        {
            var newdir = "newdir";

            if (Directory.Exists(newdir))
            {
                Directory.Delete(newdir);
            }

            var root = new ContentRoot {
                Folder = newdir
            };

            root.Folder.EndsWith(newdir).ShouldBe(true);
        }
コード例 #8
0
        public void DuplicateRoot(int NewContentID, int ContentPropertyParentID)
        {
            List <int> _NewParents = new List <int>();

            GetParentsID(ref _NewParents, NewContentID);
            using (var _c = db)
            {
                foreach (var item in _NewParents)
                {
                    var _Model = new ContentRoot(NewContentID, item);
                    _c.ContentRoots.Add(_Model);
                    _c.SaveChanges();
                }
            }
        }
コード例 #9
0
 private void MigratorUpdate(ICollection <ContentBindingList> Model, int ParentID)
 {
     foreach (var item in Model)
     {
         var _CR = new ContentRoot(item.ContentPropertyID, ParentID);
         using (var _c = db)
         {
             _c.ContentRoots.Add(_CR);
             _c.SaveChanges();
         }
         if (item.Items.Count > 0)
         {
             MigratorUpdate(item.Items, ParentID);
         }
     }
 }
コード例 #10
0
 public void AddRoot(int ContentID, int ContentParentID)
 {
     using (var _c = db)
     {
         if (!_c.ContentRoots.Where(m => m.ContentID == ContentID && m.ContentParentID == ContentParentID).Any())
         {
             List <int> _NewParents = new List <int>();
             GetParentsID(ref _NewParents, ContentID);
             foreach (var item in _NewParents)
             {
                 var _Model = new ContentRoot(ContentID, item);
                 _c.ContentRoots.Add(_Model);
                 _c.SaveChanges();
             }
         }
     }
 }
コード例 #11
0
        private void MigratorUpdate(ICollection <ContentBindingList> Model)
        {
            foreach (var item in Model)
            {
                var _CR = new ContentRoot(item.ContentPropertyID, item.ContentPropertyParentID);
                using (var _c = db)
                {
                    if (!_c.ContentRoots.Where(m => m.ContentID == item.ContentPropertyID && m.ContentParentID == item.ContentPropertyParentID).Any())
                    {
                        _c.ContentRoots.Add(_CR);
                        _c.SaveChanges();
                    }
                }

                if (item.Items.Count > 0)
                {
                    MigratorUpdate(item.Items, item.ContentPropertyID);
                    MigratorUpdate(item.Items);
                }
            }
        }
コード例 #12
0
        public ActionResult SlackHandler(ContentRoot content)
        {
            //TODO: change Challenge Class to payload
            if (content.Type.Contains("event_callback"))
            {
                if ([email protected] == "app_mention")
                {
                    string user         = "******" + [email protected] + ">";
                    string orig_channel = [email protected];
                    string bearerToken  = ""; //you must provide a bearerToken for this to work!!

                    var wc = new HttpClient();
                    wc.DefaultRequestHeaders.Add("Authorization", "Bearer " + bearerToken);

                    if (content.Event.Text.ToUpper().Contains("INSULT"))
                    {
                        var ranObj = new
                        {
                            channel = orig_channel,
                            text    = user + " " + InsultMe.Quote,
                            //   attachments = new[]
                            //    {
                            //new {
                            //          title = "ok",
                            //          image_url = "http://ronntorossian.com/wp-content/uploads/2014/02/power-of-the-meme-ronn-torossian-1024x640.jpg"
                            //    }
                            //}
                        };


                        var t        = wc.PostAsync("https://slack.com/api/chat.postMessage", new StringContent(JsonConvert.SerializeObject(ranObj), System.Text.Encoding.UTF8, "application/json"));
                        var response = t.Result;
                    }
                }
            }
            return(Json(content.Challenge, JsonRequestBehavior.AllowGet));
        }
コード例 #13
0
        public void default_index_is_index_dot_html()
        {
            var root = new ContentRoot();

            root.DefaultFileName.ShouldBe("index.html");
        }
コード例 #14
0
 /// <summary>
 ///     Callback for when the server sends a new resource.
 /// </summary>
 /// <param name="msg">The network message containing the data.</param>
 protected override void ResourceUploadMsg(NetworkResourceUploadMessage msg)
 {
     ContentRoot.AddOrUpdateFile(msg.RelativePath, msg.Data);
 }
コード例 #15
0
        private static DependencyObject?GetAppVisibleXamlRootContent(ContentRoot contentRoot)
        {
            var xamlRoot = contentRoot.GetOrCreateXamlRoot();

            return(xamlRoot.Content);
        }
コード例 #16
0
 internal FocusObserver(ContentRoot contentRoot)
 {
     _contentRoot = contentRoot ?? throw new ArgumentNullException(nameof(contentRoot));
 }
コード例 #17
0
        public void default_folder_is_webroot()
        {
            var root = new ContentRoot();

            root.Folder.EndsWith("webroot").ShouldBe(true);
        }