public PrintEFormSelectDialog(int typeID, int docID)
        {
            InitializeComponent();

            object obj = Environment.GetDocTypeName(typeID);

            if (obj != null)
            {
                labelText.Text += obj.ToString();
            }

            if (typeID > 0)
            {
                using (DataTable dt = Environment.PrintData.GetEFormPrintTypeData(typeID, docID))
                {
                    if (dt.Rows.Count > 0)
                    {
                        SettingsPrintForm[] settings =
                            Environment.SettingsPrintForm.GetSettings(typeID);
                        bool isOneItemSelect = false;
                        foreach (DataRow dr in dt.Rows)
                        {
                            var po = new PrinterObjectClass((int)dr[Environment.PrintData.IDField],
                                                            dr[Environment.PrintData.NameField].ToString(),
                                                            dr[Environment.PrintData.URL].ToString(),
                                                            Convert.ToInt32(
                                                                dr[Environment.PrintData.PrintIDField]),
                                                            (short)
                                                            dr[Environment.PrintData.PaperSizeField]);

                            if (settings.Any(t => t.PrintID == po.TypeID && t.TypeID == typeID))
                            {
                                typeBox.Items.Add(po, CheckState.Checked);
                                isOneItemSelect = true;
                                typeBox.Items.Add(po, CheckState.Unchecked);
                            }
                        }
                        if (!isOneItemSelect)
                        {
                            typeBox.SetItemChecked(0, true);
                        }
                    }
                    else
                    {
                        Close();
                        throw new Exception(Environment.StringResources.GetString("Dialog_DocPrintDialog_Error1"));
                    }
                    dt.Dispose();
                }
            }
            typeBox.ItemCheck            += typeBox_ItemCheck;
            typeBox.SelectedIndexChanged += typeBox_SelectedIndexChanged;
        }
Пример #2
0
        private void StartSwitchPrintEform()
        {
            int docID = values[row - 1];

            if (poindex < printerObject.Count)
            {
                poindex++;
                PrinterObjectClass po = printerObject[poindex - 1];
                GC.Collect();
                syncPrintEForm.WaitOne(30000, false);
                Console.WriteLine("{0}: printing form {1}", DateTime.Now.ToString("HH:mm:ss fff"), po.TypeID);
                if (InvokeRequired)
                {
                    Invoke(new Data.Action <int, string, int, int, short, short>(SwitchPrintEform), new object[] { po.PrintType, po.URL, docID, po.TypeID, po.PaperSize, copiescount });
                }
                else
                {
                    SwitchPrintEform(po.PrintType, po.URL, docID, po.TypeID, po.PaperSize, copiescount);
                }
            }
            else
            {
                if (timer == null)
                {
                    timer = new System.Timers.Timer(200)
                    {
                        AutoReset = false
                    }
                }
                ;
                else
                {
                    timer.Elapsed -= timer_Elapsed;
                    timer.Interval = 200;
                }
                timer.Elapsed += timer_Elapsed;
                timer.Start();
            }
        }