Exemplo n.º 1
0
        //定时轮询
        private void detect_msg()
        {
            while(true)
            {
                try
                {
                    var dc = new BathDBDataContext(connectionString);
                    var job = dc.Job.FirstOrDefault(x => x.ip == m_ip);
                    if (job == null)
                        m_msg = dc.TechMsg.FirstOrDefault(x => !x.read);
                    else
                    {
                        m_msg = dc.TechMsg.FirstOrDefault(x => !x.read &&
                            (x.techType == job.name || (x.techId!=null && x.techId!="" &&
                            dc.Employee.FirstOrDefault(y=>y.id==x.techId).jobId==job.id)));
                    }

                    if (m_msg == null)
                    {
                        this.Invoke(new delegate_no_param(unable_msg_btn), null);
                        continue;
                    }

                    var tech = dc.Employee.FirstOrDefault(x => x.msgId == m_msg.id);
                    if (tech == null && job != null)
                    {
                        tech = dc.Employee.FirstOrDefault(x => x.id == m_msg.techId);
                        if (tech == null)
                        {
                            if (m_msg.gender == null || m_msg.gender.Trim() == "" || m_msg.gender == "无"|| m_msg.gender == "女")
                            {
                                var tLst = dc.TechIndex.FirstOrDefault(x => x.dutyid == job.id && x.gender == "女").ids.Split('%').ToList();

                                foreach (var techIds in tLst)
                                {
                                    var tech_id = techIds.Split('=');
                                    if (tech_id[1] == "F") continue;

                                    var tmp_tech = dc.Employee.FirstOrDefault(x => x.id == tech_id[0]);
                                    if (tmp_tech.techStatus == "空闲" || tmp_tech.techStatus == null)
                                    {
                                        tech = tmp_tech;
                                        tech.techStatus = "待钟";
                                        tech.techMenu = m_msg.menu;
                                        tech.room = m_msg.room;
                                        tech.seat = m_msg.seat;
                                        tech.msgId = m_msg.id;

                                        m_msg.techId = tech.id;
                                        dc.SubmitChanges();

                                        this.Invoke(new delegate_create_tech_panel_gender(create_tech_panel_gender),
                                            new object[]{dc, "女", SplitGender.Panel1});
                                        //this.Invoke(new delegate_no_param(create_tech_panel));
                                        break;
                                    }
                                }
                            }
                            else if (m_msg.gender == "男")
                            {
                                var tLst = dc.TechIndex.FirstOrDefault(x => x.dutyid == job.id && x.gender == "男").ids.Split('%').ToList();

                                foreach (var techIds in tLst)
                                {
                                    var tech_id = techIds.Split('=');
                                    if (tech_id[1] == "F") continue;
                                    var tmp_tech = dc.Employee.FirstOrDefault(x => x.id == tech_id[0]);
                                    if (tmp_tech.techStatus == "空闲" || tmp_tech.techStatus == null)
                                    {
                                        tech = tmp_tech;
                                        tech.techStatus = "待钟";
                                        tech.techMenu = m_msg.menu;
                                        tech.room = m_msg.room;
                                        tech.seat = m_msg.seat;
                                        tech.msgId = m_msg.id;

                                        m_msg.techId = tech.id;
                                        dc.SubmitChanges();

                                        this.Invoke(new delegate_create_tech_panel_gender(create_tech_panel_gender),
                                            new object[]{dc, "男", SplitGender.Panel2});
                                        //this.Invoke(new delegate_no_param(create_tech_panel));
                                        break;
                                    }
                                }
                            }

                        }
                        else
                        {
                            tech.techStatus = "待钟";
                            tech.techMenu = m_msg.menu;
                            tech.room = m_msg.room;
                            tech.seat = m_msg.seat;
                            tech.msgId = m_msg.id;

                            m_msg.techId = tech.id;
                            dc.SubmitChanges();

                            Control sp = SplitGender.Panel1;
                            if (tech.gender == "男")
                                sp = SplitGender.Panel2;

                            this.Invoke(new delegate_create_tech_panel_gender(create_tech_panel_gender),
                                            new object[] { dc, tech.gender, sp });
                            //this.Invoke(new delegate_no_param(create_tech_panel));

                        }

                    }
                    this.Invoke(new delegate_no_param(showMessage));
                    play();
                    if (print_tech_msg)
                        print_msg(dc);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        public static void Print_Msg(TechMsg techMsg, string coName)
        {
            PrintPreviewDialog ppvw;
            try
            {
                printer = IOUtil.get_config_by_key(ConfigKeys.KEY_PRINTER);
                if (printer == "")
                {
                    PrinterChooseForm printerChooseForm = new PrinterChooseForm();
                    if (printerChooseForm.ShowDialog() != DialogResult.OK)
                        return;
                    printer = printerChooseForm.printer;
                }

                // Getting DataGridView object to print
                m_techMsg = techMsg;
                DashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                companyName = coName;

                printDoc.PrinterSettings.PrinterName = printer;
                printDoc.OriginAtMargins = true;
                printDoc.DefaultPageSettings.Margins.Left = 10;
                printDoc.DefaultPageSettings.Margins.Right = 10;
                printDoc.DefaultPageSettings.Margins.Top = 0;
                printDoc.DefaultPageSettings.Margins.Bottom = 100;

                ppvw = new PrintPreviewDialog();
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);

                // Printing the Documnet
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
 partial void UpdateTechMsg(TechMsg instance);
Exemplo n.º 4
0
 partial void DeleteTechMsg(TechMsg instance);
Exemplo n.º 5
0
 partial void InsertTechMsg(TechMsg instance);