Ejemplo n.º 1
0
        //filter, checking the validity of the information



        #endregion
        //---------------------------------------------------------------------------------------------

        //-------------------------------File and Meeting Process ---------------------------------
        //Previous Condition: List of File information from recent file viewer, list of file information from google attachments, and meeting list from google calendar
        //Post Condition: List of New Files with sorted ID, List of Old Files with previous IDs, List of meetings. All filelist and meetinglist in nodes updated

        public void ProcessFileWithMeetingNode(MeetingNode mNode)
        {
            //check if the meeting node is valid or not first
            if (!Tools.IsValidMeeting(mNode, minDuration))
            {
                return;
            }

            String meetingID = mNode.GetMeetingID();

            if (meetingID == "")
            {
                Console.WriteLine("Meeting ID for Meeting " + mNode.GetMeetingTitle() + "is missing.");
                return;
            }
            LinkedList <FileNode> filteredFileList = new LinkedList <FileNode>();
            DateTime startTime = mNode.GetStartTime();
            DateTime endTime   = mNode.GetEndTime();

            foreach (FileNode item in fileList)
            {
                if (Tools.IsValidTimeRange(item.GetCreatedTime(), item.GetExecuteTime(), item.GetModifiedTime(), startTime, endTime) != -1)
                {
                    item.AddMeetings(meetingID);
                    filteredFileList.AddLast(item);
                }
            }
            foreach (FileNode Aitem in AttachmentList)
            {
                if (Aitem.GetMeetingListS() == mNode.GetMeetingID())
                {
                    filteredFileList.AddLast(Aitem);
                }
            }
            filteredFileList = AssignFileIDs(filteredFileList);
            foreach (FileNode node in filteredFileList)
            {
                fileFinalList.AddLast(node);
                mNode.AddFiles(node.GetFileID());
            }
            meetingList.AddLast(mNode);
        }
Ejemplo n.º 2
0
        public bool Execute(params object[] Stuff)
        {
            RoomUser      roomUser = (RoomUser)Stuff[0];
            WiredItemType item     = (WiredItemType)Stuff[1];

            foreach (RoomItem Aitem in this.Items)
            {
                switch (Aitem.GetBaseItem().InteractionType)
                {
                case InteractionType.triggerrepeater:
                case InteractionType.triggertimer:
                    WiredItem Trigger = Room.GetWiredHandler().GetWired(Aitem);

                    Trigger.Delay = 5000;
                    Room.GetWiredHandler().ReloadWired(Trigger);
                    break;
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        static UpdateInfo GetUpdateInfo(HtmlAgilityPack.HtmlNode doc, string NewVersion = null)
        {
            UpdateInfo updateInfo = new UpdateInfo
            {
                verson = NewVersion,
                files  = new List <UpdateFileInfo>(),
                desc   = new List <string>()
            };

            //label-latest
            HtmlAgilityPack.HtmlNode releaseMain = GetReleaseMain(doc);

            HtmlAgilityPack.HtmlNode Pre    = releaseMain.SelectSingleNode("//div[contains(@class,'flex-self-start')]");
            HtmlAgilityPack.HtmlNode header = releaseMain.SelectSingleNode("//div[contains(@class,'release-header')]");
            HtmlAgilityPack.HtmlNode body   = releaseMain.SelectSingleNode("//div[contains(@class,'markdown-body')]");
            if (Pre != null)
            {
                if (Pre.InnerText.Contains("Pre"))
                {
                    updateInfo.pre = true;
                }
            }
            if (header != null)
            {
                if (NewVersion != null)
                {
                    HtmlAgilityPack.HtmlNode headers = header.SelectSingleNode("div[1]/div[1]");
                    if (headers != null)
                    {
                        updateInfo.title = headers.InnerText.Replace("\n", "").Trim();
                    }
                }
                else
                {
                    HtmlAgilityPack.HtmlNode headers = header.SelectSingleNode("div[1]/div[1]/a[1]");
                    if (headers != null)
                    {
                        string _Newversion = headers.GetAttributeValue("href", null);
                        if (_Newversion != null)
                        {
                            updateInfo.verson = _Newversion.Substring(_Newversion.LastIndexOf("/") + 1).TrimStart('v');
                        }
                        updateInfo.title = headers.InnerText.Replace("\n", "").Trim();
                    }
                }
                HtmlAgilityPack.HtmlNode headersTime = header.SelectSingleNode("p[1]/relative-time[1]");
                if (headersTime != null)
                {
                    string time = headersTime.GetAttributeValue("datetime", null);//2020-07-07T07:58:07Z
                    updateInfo.time = time.ToDateTime(DateTime.Now);
                }
            }
            if (body != null)
            {
                HtmlAgilityPack.HtmlNodeCollection nodes = body.SelectNodes("p");
                if (nodes != null && nodes.Count > 0)
                {
                    foreach (HtmlAgilityPack.HtmlNode item in nodes)
                    {
                        HtmlAgilityPack.HtmlNodeCollection Anodes = item.ChildNodes;
                        if (Anodes != null && Anodes.Count > 0)
                        {
                            foreach (HtmlAgilityPack.HtmlNode Aitem in Anodes)
                            {
                                switch (Aitem.Name)
                                {
                                case "a":
                                    string url = Aitem.GetAttributeValue("href", null);
                                    if (url != null)
                                    {
                                        updateInfo.files.Add(new UpdateFileInfo
                                        {
                                            name = Aitem.InnerText.Trim(),
                                            url  = url
                                        });
                                    }
                                    break;

                                case "#text":
                                    updateInfo.desc.Add(Aitem.InnerText.Replace("\n", "").Trim());
                                    break;

                                default:
                                    Debug.WriteLine(Aitem.Name);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            updateInfo.desc.Add(item.InnerText.Trim());
                        }
                    }
                }
                else
                {
                    var reg = new System.Text.RegularExpressions.Regex(@"(?is)<a(?:(?!href=).)*href=(['""]?)(?<url>[^""\s>]*)\1[^>]*>(?<text>(?:(?!</?a\b).)*)</a>");
                    var mc  = reg.Matches(body.InnerHtml);
                    foreach (System.Text.RegularExpressions.Match m in mc)
                    {
                        string url = m.Groups["url"].Value;
                        if (url.StartsWith("/files/"))
                        {
                            updateInfo.files.Add(new UpdateFileInfo
                            {
                                name = m.Groups["text"].Value,
                                url  = url
                            });
                        }
                    }
                }
                //string title = header.InnerText.Trim();
            }

            if (updateInfo.files.Count == 0)
            {
                HtmlAgilityPack.HtmlNode filebody = releaseMain.SelectSingleNode("//div[contains(@class,'Box--condensed')]");
                if (filebody != null)
                {
                    HtmlAgilityPack.HtmlNodeCollection files = filebody.SelectNodes("div[1]/div");
                    if (files != null)
                    {
                        foreach (HtmlAgilityPack.HtmlNode file in files)
                        {
                            HtmlAgilityPack.HtmlNode Afiles = file.SelectSingleNode("a[1]");
                            if (Afiles != null)
                            {
                                string url = Afiles.GetAttributeValue("href", null);
                                if (url != null)
                                {
                                    if (url.StartsWith("/"))
                                    {
                                        url = "https://github.com" + url;
                                    }
                                    //https://github.com/giant-app/LiveWallpaper/archive/v1.4.67.zip
                                    updateInfo.files.Add(new UpdateFileInfo
                                    {
                                        name = Afiles.InnerText.Trim(),
                                        url  = url
                                    });
                                }
                            }
                        }
                    }
                }
            }

            return(updateInfo);
        }