zrg
2024-12-11 cf46a6e4beb7e83af331a28065c96077fa2f1e15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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
            {
                obj.getAccessToken();
                if (obj.getData_FenCengShenHeQianDaoBiao(ref msg) == false)
                {
                    return false;
                }
 
                if (obj.getData_XianChangBianHuaDianPingShenDan(ref msg) == false)
                {
                    return false;
                }
 
                if (obj.getData_FenCengShenHeGuanLi(ref msg) == false)
                {
                    return false;
                }
 
                if (obj.getData_QRQCWenTiTiJiaoBiao(ref msg) == false)
                {
                    return false;
                }
 
                //设备维修记录单
                if (obj.getData_EquipRepairWeiXiu(ref msg) == false)
                {
                    return false;
                }
                //模具维修记录单 保养记录单
                if (obj.getData_MouldFileWeiXiuBaoYang(ref msg) == false)
                {
                    return false;
                }
 
                if (obj.getData_HuaMingCe(ref msg) == false)
                {
                    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
    }
}