old_flsystem/FLSystem/Forms/home_control.cs

147 lines
4.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraTab;
using Api.Framework;
using Api.Framework.Enums;
using Api.Framework.Model;
using System.Threading;
namespace FLSystem.Forms
{
public partial class home_control : UserControl
{
//private const string url = "www.baidu.com";
//private readonly static string url = "https://cps.api.52cmg.cn/view/note.html?rd=";
//private const string url = "https://mo.m.taobao.com/union/hr-team-invite?bizTypeName=raceHorse&timeStamp=1633923247662&id=64315895-70e8-463d-b57e-0dc87564434227247953";
//private void GetNoticeUrl()
//{
//return url + new Random(Guid.NewGuid().GetHashCode()).Next(10000, 50000);
//}
public home_control()
{
InitializeComponent();
webBrowser1.Dock = DockStyle.Fill;
webBrowser1.ScriptErrorsSuppressed = true; //禁用错误脚本提示
webBrowser1.IsWebBrowserContextMenuEnabled = false; //禁用右键菜单
webBrowser1.WebBrowserShortcutsEnabled = true; //禁用快捷键
webBrowser1.AllowWebBrowserDrop = false;//禁止拖拽
Task.Run(() =>
{
this.Invoke(new Action(() =>
{
var dtEnd = DateTime.Now.AddSeconds(3);
do
{
Thread.Sleep(200);
if (this.Parent != null)
break;
} while (DateTime.Now < dtEnd);
GetNotice();
}));
});
}
private void home_control_Load(object sender, EventArgs e)
{
}
private void GetNotice()
{
var flag = true;
try
{
//return url + new Random(Guid.NewGuid().GetHashCode()).Next(10000, 50000);
var ali = CpsClient.Members.FirstOrDefault(f => f.cpstype == CpsType.);
if (ali == null)
ali = new fl_cps_member() { cpstype = CpsType., username = "28592081" };
var cps = CpsClient.CreateAlimamaRequest(ali);
var data = cps.SendServer("find_notice", "webTool.asmx").message.ToString();
webBrowser1.Navigate("about:blank");
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
webBrowser1.Document.Write(data);
webBrowser1.Refresh();//不刷新一下Iframe显示不出来。
}
catch (Exception)
{
flag = false;
}
try
{
var tab = this.Parent as XtraTabPage;
if (tab != null)
{
if (!flag)
tab.PageVisible = false;
else
tab.PageVisible = true;
}
else
tab.PageVisible = false;
}
catch (Exception)
{ }
}
private void timer1_Tick(object sender, EventArgs e)
{
try
{
GetNotice();
//webBrowser1.Navigate(GetNoticeUrl());
}
catch (Exception ex)
{ }
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//try
//{
// var tab = this.Parent as XtraTabPage;
// if (tab != null)
// {
// string content = webBrowser1.DocumentText;
// if (content.Contains("<title>404"))
// {
// //(ss.Parent as XtraTabControl).TabPages.Remove(ss);
// tab.PageVisible = false;
// }
// else
// {
// tab.PageVisible = true;
// }
// }
//}
//catch (Exception)
//{ }
}
}
}