using System; 
 | 
using System.Collections.Generic; 
 | 
using System.ComponentModel; 
 | 
using System.Data; 
 | 
using System.Drawing; 
 | 
using System.Linq; 
 | 
using System.Text; 
 | 
using System.Threading.Tasks; 
 | 
using System.Windows.Forms; 
 | 
using WebAPI.Controllers; 
 | 
  
 | 
namespace LMES 
 | 
{ 
 | 
    public partial class DingDing_autoGetData : Form 
 | 
    { 
 | 
        public DingDing_autoGetData() 
 | 
        { 
 | 
            InitializeComponent(); 
 | 
  
 | 
            //页面初始化 
 | 
            set_initPage(); 
 | 
        } 
 | 
  
 | 
        #region 页面初始化 
 | 
        public void set_initPage() 
 | 
        { 
 | 
            timer1.Enabled = true; 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
  
 | 
        #region 钉钉数据同步 
 | 
        public bool DingDing_getData(ref string msg) 
 | 
        { 
 | 
            //钉钉数据同步操作类 
 | 
            DD_DataSynchronizationController obj = new DD_DataSynchronizationController(); 
 | 
  
 | 
            try 
 | 
            { 
 | 
                int num = 0; 
 | 
                obj.getAccessToken(); 
 | 
                if (obj.getData_FenCengShenHeQianDaoBiao(ref msg) == false) 
 | 
                { 
 | 
                    //return false; 
 | 
                    num = num + 1; 
 | 
                } 
 | 
  
 | 
                if (obj.getData_XianChangBianHuaDianPingShenDan(ref msg) == false) 
 | 
                { 
 | 
                    //return false; 
 | 
                    num = num + 1; 
 | 
                } 
 | 
  
 | 
                if (obj.getData_FenCengShenHeGuanLi(ref msg) == false) 
 | 
                { 
 | 
                    //return false; 
 | 
                    num = num + 1; 
 | 
                } 
 | 
  
 | 
                if (obj.getData_QRQCWenTiTiJiaoBiao(ref msg) == false) 
 | 
                { 
 | 
                    //return false; 
 | 
                    num = num + 1; 
 | 
                } 
 | 
  
 | 
                //设备维修记录单 
 | 
                if (obj.getData_EquipRepairWeiXiu(ref msg) == false) 
 | 
                { 
 | 
                    //return false; 
 | 
                    num = num + 1; 
 | 
                } 
 | 
                //模具维修记录单 保养记录单 
 | 
                if (obj.getData_MouldFileWeiXiuBaoYang(ref msg) == false) 
 | 
                { 
 | 
                    //return false; 
 | 
                    num = num + 1; 
 | 
                } 
 | 
  
 | 
                if (obj.getData_HuaMingCe(ref msg) == false) 
 | 
                { 
 | 
                    //return false; 
 | 
                    num = num + 1; 
 | 
                } 
 | 
                if (num > 0) 
 | 
                { 
 | 
                    return false; 
 | 
                } 
 | 
  
 | 
                return true; 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                msg = e.Message; 
 | 
                return false; 
 | 
            } 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
        #region 定时器一 
 | 
        private void timer1_Tick(object sender, EventArgs e) 
 | 
        { 
 | 
            //系统托盘显示软件图标 
 | 
            this.notifyIcon_Icon.Visible = true; 
 | 
            // 隐藏主窗体 
 | 
            this.Hide();  
 | 
            // 隐藏任务栏软件图标 
 | 
            this.ShowInTaskbar = false; 
 | 
  
 | 
            timer1.Enabled = false; 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
        #region 定时器二:同步钉钉数据 
 | 
        private void timer2_Tick(object sender, EventArgs e) 
 | 
        { 
 | 
            //this.timer2.Enabled = false; 
 | 
            int connectTimes = 0; 
 | 
            int maxConnectTimes = 10; 
 | 
  
 | 
            string msg = ""; 
 | 
  
 | 
            while (true) 
 | 
            { 
 | 
                if(DingDing_getData(ref msg) == true) 
 | 
                { 
 | 
                    break; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    connectTimes++; 
 | 
                    if (connectTimes >= maxConnectTimes) 
 | 
                    { 
 | 
                        break; 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
        #endregion 
 | 
    } 
 | 
} 
 |