Пример #1
0
        /// <summary>
        /// 自动保存编辑内容
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void SaveEditer(object source, ElapsedEventArgs e)
        {
            if (InvokeRequired)
            {
                EventHandler <ElapsedEventArgs> handler = SaveEditer;
                Invoke(handler, source, e);
            }
            var value = ApplicationContext.GetParameterValue("autoSaveStyle", "关闭自动保存");

            if (value.Equals("直接保存"))
            {
                SaveEditCommand cmd = new SaveEditCommand {
                    HasPopForm = false
                };
                cmd.Execute(null);
                SaveTimer.Stop();
                SaveTimer.Start();
            }
            else if (value.Equals("弹框提示"))
            {
                SaveEditCommand cmd = new SaveEditCommand {
                    HasPopForm = true
                };
                cmd.Execute(null);
                SaveTimer.Stop();
                SaveTimer.Start();
            }
        }
Пример #2
0
        private void InitializeAttachments()
        {
            Outlook.Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
            Outlook.MailItem  mail      = inspector.CurrentItem;
            try
            {
                if (mail.Attachments == null || mail.Attachments.Count <= 0)
                {
                    return;
                }

                foreach (Outlook.Attachment attachment in mail.Attachments)
                {
                    AttachmentsTextBox.Text = $"{AttachmentsTextBox.Text}{attachment.FileName}\r\n";
                }

                SaveTimer.Stop();
                ClearTimer();
                SaveTimer.Start();
            }
            finally
            {
                if (inspector != null)
                {
                    Marshal.ReleaseComObject(mail);
                    mail = null;
                }
                if (inspector != null)
                {
                    Marshal.ReleaseComObject(inspector);
                    inspector = null;
                }
            }
        }
 private void biStart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     for (int i = 0; i < ArbitrageHelper.Items.Count; i++)
     {
         ArbitrageHelper.Items[i].History.Clear();
     }
     ArbitrageHelper.StartWorking();
     SaveTimer.Start();
     UpdateTimer.Start();
 }
Пример #4
0
 private void biStart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     foreach (var item in ArbitrageHelper.Items)
     {
         item.History.Clear();
     }
     ArbitrageHelper.StartWorking();
     SaveTimer.Start();
     UpdateTimer.Start();
 }
Пример #5
0
 private void start_ping_Click(object sender, EventArgs e)
 {
     if (node_id.Text != "")
     {
         pingtimer.Start();
         SaveTimer.Start();
         tracert_interval_timer.Start();
         running = true;
         tracert_interval_timer.Interval = 5000;
     }
     else
     {
         ping_logg.Items.Add("Please input node IP or hostname");
     }
 }
Пример #6
0
        private void Log(ConsoleColor Color, LogType Type, string Severity, string Message, DateTime Time)
        {
            if (!Message.Contains("DELETE") &&
                !Message.Contains("POST") &&
                !Message.Contains("GET") &&
                !Message.Contains("PUT") &&
                !Message.Contains("PATCH"))
            {
                string TimeBlock = "[" + GetTime(Time) + "] ";
                var    TypeBlock = "";
                if (Type != LogType.NoDisplay)
                {
                    TypeBlock = "[" + Type.ToString() + "] ";
                }

                string SeverityBlock = Severity;

                string LogLine = TimeBlock + TypeBlock;

                if (!string.IsNullOrWhiteSpace(SeverityBlock))
                {
                    SeverityBlock = "[" + SeverityBlock + "] ";
                    LogLine      += SeverityBlock;
                }
                LogLine += Message;

                Logs.Add(LogLine);

                SaveTimer.Start();

                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write(TimeBlock);

                Console.ForegroundColor = Color;
                Console.Write(TypeBlock);

                if (!string.IsNullOrWhiteSpace(SeverityBlock))
                {
                    Console.Write(SeverityBlock);
                }

                Console.ResetColor();

                Console.Write(Message + Environment.NewLine);
            }
        }
Пример #7
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                SaveTimer.Stop();
                ClearTimer();

                Outlook.Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
                Outlook.MailItem  mail      = inspector.CurrentItem;

                try
                {
                    if (mail != null)
                    {
                        var syncObject = Globals.ThisAddIn.Application.Session.SyncObjects[1];
                        syncObject.SyncEnd         += SyncObject_SyncEnd;
                        syncObject.OnError         += SyncObject_OnError;
                        SaveButton.Enabled          = false;
                        AddAttachmentButton.Enabled = false;
                        mail.Save();
                        syncObject.Start();
                    }
                }
                finally
                {
                    if (inspector != null)
                    {
                        Marshal.ReleaseComObject(mail);
                        mail = null;
                    }
                    if (inspector != null)
                    {
                        Marshal.ReleaseComObject(inspector);
                        inspector = null;
                    }
                }
                SaveTimer.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Пример #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Scintilla.SavePointReached += Scintilla_SavePointReached;
            Scintilla.SavePointLeft    += Scintilla_SavePointLeft;
            Scintilla.TextChanged      += Scintilla_TextChanged;

            if (!File.Exists(@"c:\tmp\tmp.txt"))
#pragma warning disable CS0642 // Possible mistaken empty statement
            {
                using (File.Create(@"c:\tmp\tmp.txt"));
            }
#pragma warning restore CS0642 // Possible mistaken empty statement

            using (StreamReader sr = new StreamReader(@"c:\tmp\tmp.txt", Encoding.UTF8))
            {
                var fileContent = sr.ReadToEnd();
                Scintilla.Text = fileContent;
                Scintilla.SetSavePoint();
            }

            SaveTimer.Start();
        }
Пример #9
0
        private void SaveButton_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                SaveTimer.Stop();
                ClearTimer();

                Outlook.Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
                Outlook.MailItem  mail      = inspector.CurrentItem;

                try
                {
                    if (mail != null)
                    {
                        mail.Save();
                    }
                }
                finally
                {
                    if (inspector != null)
                    {
                        Marshal.ReleaseComObject(mail);
                        mail = null;
                    }
                    if (inspector != null)
                    {
                        Marshal.ReleaseComObject(inspector);
                        inspector = null;
                    }
                }
                SaveTimer.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Пример #10
0
        public bool Traceroute(string ipAddress)

        {
            tracert_interval_timer.Stop();
            bool trace_ok = false;

            trace_listBox.Items.Add("Tracing.... in tracerout  try");



            using (Ping pingSender_T = new Ping())
            {
                PingOptions pingOptions = new PingOptions();
                System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
                byte[] bytes = new byte[32];
                pingOptions.DontFragment = true;
                pingOptions.Ttl          = 1;
                int    maxHops     = 30;
                string addressname = "";

                traceResults_.Add(string.Format("Traced route to {0} over a maximum of {1} hops:", ipAddress, maxHops));
                trace_ips.Clear();


                for (int i = 1; i < maxHops + 1; i++)
                {
                    stopWatch.Reset();
                    stopWatch.Start();
                    PingReply pingReply_ = pingSender_T.Send(ipAddress, 3000, new byte[32], pingOptions);
                    try
                    {
                        addressname = pingReply_.Address.ToString();
                    }
                    catch
                    {
                        addressname = "Unresolved address";
                    }

                    stopWatch.Stop();
                    try
                    {
                        if (stopWatch.ElapsedMilliseconds > 30000)
                        {
                            trace_ok = false;



                            traceResults_.Add(string.Format("trace failed {0} ms\t{1}", i, addressname));
                            events.Add(string.Format("trace failed {0} ms\t{1}", i, addressname));
                            break;
                        }
                        traceResults_.Add(string.Format("{0}\t{1} ms\t{2}", i, stopWatch.ElapsedMilliseconds, addressname));
                        events.Add(string.Format("{0}\t{1} ms\t{2}", i, stopWatch.ElapsedMilliseconds, addressname));
                        trace_ips.Add(pingReply_.Address.ToString());
                    }
                    catch
                    {
                        trace_listBox.Items.Add("Tracing.... in tracerout  inner catch");
                    }

                    if (pingReply_.Status == IPStatus.Success)

                    {
                        trace_ok = true;
                        break;
                    }


                    pingOptions.Ttl++;
                }

                pingSender_T.Dispose();
            }

            tracert_interval_timer.Start();
            SaveTimer.Start();
            event_timer.Start();
            return(trace_ok);
        }
Пример #11
0
 private void Scintilla_TextChanged(object sender, EventArgs e)
 {
     SaveTimer.Stop();
     SaveTimer.Start();
 }
Пример #12
0
        void RunInSim()
        {
            // Bind packet events.
            insim.Bind <IS_NCN>(NewConnection);
            insim.Bind <IS_NPL>(NewPlayer);
            insim.Bind <IS_MSO>(MessageReceived);
            insim.Bind <IS_MCI>(MultiCarInfo);
            insim.Bind <IS_CNL>(ConnectionLeave);
            insim.Bind <IS_CPR>(ClientRenames);
            // insim.Bind<IS_PLL>(PlayerLeave);
            insim.Bind <IS_STA>(OnStateChange);
            // insim.Bind<IS_BTC>(ButtonClicked);
            insim.Bind <IS_BFN>(ClearButtons);
            // insim.Bind<IS_VTN>(VoteNotify);
            insim.Bind <IS_AXI>(OnAutocrossInformation);
            // insim.Bind<IS_TINY>(OnTinyReceived);
            // insim.Bind<IS_CON>(CarCOntact);
            insim.Bind <IS_BTT>(ButtonType);
            insim.Bind <IS_LAP>(Laps);
            insim.Bind <IS_RES>(Res);
            insim.Bind <IS_PIT>(Pitstop);
            insim.Bind <IS_HLV>(HotLapValidity);
            insim.Bind <IS_RES>(Result);

            // Initialize InSim
            insim.Initialize(new InSimSettings
            {
                Host   = "51.254.134.112", // 51.254.134.112         192.168.3.10
                Port   = 29999,
                Admin  = "2910693997",
                Prefix = '!',
                Flags  = InSimFlags.ISF_MCI | InSimFlags.ISF_MSO_COLS | InSimFlags.ISF_CON | InSimFlags.ISF_RES_0 | InSimFlags.ISF_RES_1 | InSimFlags.ISF_NLP | InSimFlags.ISF_HLV,

                Interval = 500
            });

            insim.Send(new[]
            {
                new IS_TINY {
                    SubT = TinyType.TINY_NCN, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_NPL, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_ISM, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_SST, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_MCI, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_NCI, ReqI = 255
                },
                new IS_TINY {
                    SubT = TinyType.TINY_AXI, ReqI = 255
                },
            });

            // insim.Send("/cars " + AVAILABLE_CARS);
            insim.Send(255, "^8InSim connected with version ^2" + InSim_Version);

            ConnectedToSQL = SqlInfo.StartUp(SQLIPAddress, SQLDatabase, SQLUsername, SQLPassword);
            if (!ConnectedToSQL)
            {
                insim.Send(255, "SQL connect attempt failed! Attempting to reconnect in ^310 ^8seconds!");
                SQLReconnectTimer.Start();
                SaveTimer.Start();
            }
            else
            {
                insim.Send(255, "^2Loaded userdata from database");
            }
        }