Ejemplo n.º 1
0
        public Service1()
        {
            InitializeComponent();
            string CommonPath = Application.CommonAppDataPath.Remove(Application.CommonAppDataPath.Length - Application.ProductVersion.Length, Application.ProductVersion.Length);

            DatabasePath = CommonPath + Properties.Settings.Default.FOLDERDB + @"\";
            PcapPath     = CommonPath + Properties.Settings.Default.FOLDERPCAP + @"\";
            string currentUserAccount = System.Environment.UserName;

            try
            {
                if (!Directory.Exists(DatabasePath))
                {
                    Directory.CreateDirectory(DatabasePath);
                    SeeSystemConfig.GrantModifyAccessToFolder
                        (currentUserAccount, DatabasePath);
                }
                if (!Directory.Exists(PcapPath))
                {
                    Directory.CreateDirectory(PcapPath);
                    SeeSystemConfig.GrantModifyAccessToFolder
                        (currentUserAccount, PcapPath);
                }
                UdpBroadcast1.SetPorts(Properties.Settings.Default.UDPSEND, Properties.Settings.Default.UDPRECV);
                UdpBroadcast1.MessageRcvd += new UdpDelegate(UdpBroadcast1_MessageRcvd);
                controlTimer.AutoReset     = true;
                controlTimer.Elapsed      += new System.Timers.ElapsedEventHandler(controlTimer_Elapsed);
            }
            catch (Exception exc)
            { WriteAppLogError(exc.ToString(), 10000); }
        }
Ejemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();
            Text = Text + " (" + AboutBox1.AssemblyVersion + ")";
#if DEBUG
            Debug.Indent();
            #region Check for logs
            //EventLog.DeleteEventSource("SeeClient1");
            //EventLog.DeleteEventSource("SeeService1");
            //EventLog.CreateEventSource("SeeService1", "SeeTCPIP");
            //EventLog.CreateEventSource("SeeClient1", "SeeTCPIP");
            EventLog[] logs = EventLog.GetEventLogs();
            Debug.WriteLine("---Event Logs---");
            foreach (EventLog log in logs)
            {
                Debug.WriteLine(log.Log);
            }
            Debug.WriteLine("---Sources registered---");
            string[] srcNames = new string[3] {
                "SeeTCPIP4VSE", "SeeService1", "SeeClient1"
            };
            foreach (string srcName in srcNames)
            {
                string logName = EventLog.LogNameFromSourceName(srcName, ".");
                if (EventLog.SourceExists(srcName))
                {
                    Debug.WriteLine(srcName + " registered to " + logName);
                }
            }
            Debug.WriteLine("---End of Event Logs---");
            #endregion
            csi.see.service1.Service1 service = new csi.see.service1.Service1();
            service.StartforDebug();
#endif
            string CommonPath = Application.CommonAppDataPath.Remove(Application.CommonAppDataPath.Length - Application.ProductVersion.Length, Application.ProductVersion.Length);
            DatabasePath = CommonPath + Properties.Settings.Default.FOLDERDB + @"\";
            PcapPath     = CommonPath + Properties.Settings.Default.FOLDERPCAP + @"\";
            try
            {
                UdpBroadcast1.SetPorts(Properties.Settings.Default.UDPSEND, Properties.Settings.Default.UDPRECV);
                UdpBroadcast1.MessageRcvd += new UdpDelegate(UdpBroadcast1_MessageRcvd);
                udp1.Text = Properties.Settings.Default.UDPSEND.ToString();
                udp2.Text = Properties.Settings.Default.UDPRECV.ToString();
            }
            catch (Exception exc)
            {
                udp1.Text = "FAIL";
                udp2.Text = "FAIL";
                MessageBox.Show("Udp communication failed!" + Environment.NewLine +
                                exc.Message, "SeeTCP/IP Error");
            }
            finally
            { status1.Text = ""; }
        }