public TimeInfo(string timeString) { hour = minute = 0; if (timeString.Length == 5) { if (DTC.IsNumeric(timeString.Substring(0, 2)) && DTC.IsNumeric(timeString.Substring(3, 2))) { hour = Convert.ToInt32(timeString.Substring(0, 2)); minute = Convert.ToInt32(timeString.Substring(3, 2)); } } if (hour > 23) { hour = 23; } if (hour < 0) { hour = 0; } if (minute > 59) { minute = 59; } if (minute < 0) { minute = 0; } }
private void MostrarClientesF() { CN_Clientefacturacion objeccl = new CN_Clientefacturacion(); DTC.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = objeccl.MostrarClienteF() }); }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { CN_Clientes objetoCN = new CN_Clientes(); DTC.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = objetoCN.BuscarC(txt_BuscaCliente.Text) }); }
public override void Enlist(object distributedTransaction) { ITransaction transaction = (ITransaction)distributedTransaction; if (transaction == null) { Future future = new Future(Service.TransactionEnlist, (int)DtpFlags.SQL_TP_UNENLIST, null); object result = null; try { futures.Add(future); future.SendRequest(Session); result = future.GetNextResult(Session, futures); } finally { futures.Remove(future); } if (result != null && result is object[]) { object[] results = (object[])result; errors.AddServerError((string)results[1], null, (string)results[2]); Diagnostics.HandleErrors(CLI.ReturnCode.SQL_ERROR, this); } } else { byte[] whereabouts = GetServerDtcWhereabouts(); DTC.ITransactionExport export = DTC.GetTransactionExport(transaction, whereabouts); byte[] cookie = DTC.GetTransactionCookie(transaction, export); string cookie_encoded = Encode(cookie); ManagedCommand cmd = new ManagedCommand(this); cmd.SetParameters(null); try { cmd.Execute("select mts_enlist_transaction('" + cookie_encoded + "')"); if (cmd.Fetch()) { autocommit = false; } } finally { cmd.CloseCursor(true); cmd.Dispose(); } } }
public IEnumerable <RealHoursPerWeekInfo> Get(int projectID, int nTop) { List <RealHoursPerWeekInfo> data = new List <RealHoursPerWeekInfo>(); Dictionary <string, int> realMinutes = DB.GetRealMinutesPerWeek(projectID, nTop); ProjectInfo project = DB.Projects.GetProject(projectID); bool isOK = false; WeekInfo w = new WeekInfo(DateTime.Today); int count = 0; while (!isOK) { string keyCandidate = w.StartDate.Year.ToString() + DTC.GetFullDigits(w.WeekNO, 2); if (realMinutes.ContainsKey(keyCandidate)) { decimal realHours = Convert.ToDecimal(DTC.Format2(Convert.ToDecimal(realMinutes[keyCandidate]) / 60)); data.Add(new RealHoursPerWeekInfo(w.StartDate.Year, w.WeekNO, realHours)); } else { data.Add(new RealHoursPerWeekInfo(w.StartDate.Year, w.WeekNO, 0)); } w = DTC.GetPreviousWeek(w); count++; if (count > 20 || w.StartDate < project.StartDate) { isOK = true; } } data.Reverse(); /* * foreach(string key in realMinutes.Keys) * { * int year = Convert.ToInt16(key.Substring(0, 4)); * int week = Convert.ToInt16(key.Substring(4, key.Length - 4)); * decimal realHours = Convert.ToDecimal(DTC.Format2(Convert.ToDecimal(realMinutes[key]) / 60)); * * data.Add(new RealHoursPerWeekInfo(year, week, realHours)); * } */ return(data); }
public DTC getDTC(string strDTC) { int idx = 0; if (m_arrayListDTC.Count > 0) { do { DTC dtc = m_arrayListDTC[idx] as DTC; if (dtc.Name.Equals(strDTC)) { return(dtc); } idx++; }while (idx < m_arrayListDTC.Count); } return(new DTC(strDTC, "", "")); }
public override bool GetDtcSnapshot(DTC dtc, ECUConnection connection, out byte[] snapshotBytes) { byte[] identifier = BitUtility.BytesFromHex(dtc.Qualifier.Substring(1)); // apparently the existing dtc's mask should be ignored, use FF instead byte[] request = new byte[] { 0x19, 0x06, identifier[0], identifier[1], identifier[2], 0xFF }; byte[] expectedResponse = new byte[] { 0x59, 0x06 }; byte[] response = connection.SendMessage(request); if (response.Take(expectedResponse.Length).SequenceEqual(expectedResponse)) { snapshotBytes = response; return(true); } else { snapshotBytes = new byte[] { }; return(false); } }
public override List <DTCContext> ReportDtcsByStatusMask(ECUConnection connection, ECUVariant variant, byte inMask = 0) { List <DTCContext> dtcCtx = new List <DTCContext>(); byte mask = (byte)(DTCStatusByte.TestFailedAtRequestTime | DTCStatusByte.TestFailedAtCurrentCycle | DTCStatusByte.PendingDTC | DTCStatusByte.ConfirmedDTC | DTCStatusByte.TestFailedSinceLastClear); byte[] request = new byte[] { 0x19, 0x02, inMask == 0 ? mask : inMask }; byte[] expectedResponse = new byte[] { 0x59, 0x02 }; byte[] response = connection.SendMessage(request); if (!response.Take(expectedResponse.Length).SequenceEqual(expectedResponse)) { return(new List <DTCContext>()); } for (int i = 3; i < response.Length; i += 4) { byte[] dtcRow = new byte[4]; Array.ConstrainedCopy(response, i, dtcRow, 0, 4); string dtcIdentifier = BitUtility.BytesToHex(dtcRow.Take(3).ToArray(), false); DTC foundDtc = DTC.FindDTCById(dtcIdentifier, variant); if (foundDtc is null) { Console.WriteLine($"DTC: No matching DTC available for {dtcIdentifier}"); } dtcCtx.Add(new DTCContext() { DTC = foundDtc, StatusByte = dtcRow[3], EnvironmentContext = new List <string[]>() }); } return(dtcCtx); }
private void RefreshDisplay() { richTextDTC.Text = ""; richTextPending.Text = ""; richTextPermanent.Text = ""; int idx; string text; if (m_ListDTC.Count > 0) { for (idx = 1; idx <= m_ListDTC.Count; idx++) { DTC dtc = m_ListDTC[idx - 1]; richTextDTC.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); richTextDTC.SelectionColor = Color.Red; richTextDTC.AppendText(string.Format("{0}. {1}\r\n", idx, dtc.Name)); if (string.IsNullOrEmpty(dtc.Description)) { richTextDTC.SelectionFont = new Font("Courier New", 10f, FontStyle.Italic | FontStyle.Bold); richTextDTC.SelectionColor = Color.Black; text = " No definition found.\r\n\r\n"; } else { richTextDTC.SelectionFont = new Font("Courier New", 10f, FontStyle.Bold); richTextDTC.SelectionColor = Color.Black; text = string.Format(" {0}: {1}\r\n\r\n", dtc.Category, dtc.Description); } richTextDTC.AppendText(text); } } else { richTextDTC.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); richTextDTC.SelectionColor = Color.Green; richTextDTC.AppendText("No stored trouble codes found."); } if (m_ListPending.Count > 0) { for (idx = 1; idx <= m_ListPending.Count; idx++) { DTC dtc = m_ListPending[idx - 1]; richTextPending.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); richTextPending.SelectionColor = Color.Red; richTextPending.AppendText(string.Format("{0}. {1}\r\n", idx, dtc.Name)); if (string.IsNullOrEmpty(dtc.Description)) { richTextPending.SelectionFont = new Font("Courier New", 10f, FontStyle.Italic | FontStyle.Bold); richTextPending.SelectionColor = Color.Black; text = " No definition found.\r\n\r\n"; } else { richTextPending.SelectionFont = new Font("Courier New", 10f, FontStyle.Bold); richTextPending.SelectionColor = Color.Black; text = string.Format(" {0}: {1}\r\n\r\n", dtc.Category, dtc.Description); } richTextPending.AppendText(text); } } else { richTextPending.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); richTextPending.SelectionColor = Color.Green; richTextPending.AppendText("No pending trouble codes found."); } if (m_ListPermanent.Count > 0) { for (idx = 1; idx <= m_ListPermanent.Count; idx++) { DTC dtc = (DTC)m_ListPermanent[idx - 1]; richTextPermanent.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); richTextPermanent.SelectionColor = Color.Red; richTextPermanent.AppendText(string.Format("{0}. {1}\r\n", idx, dtc.Name)); if (string.IsNullOrEmpty(dtc.Description)) { richTextPermanent.SelectionFont = new Font("Courier New", 10f, FontStyle.Italic | FontStyle.Bold); richTextPermanent.SelectionColor = Color.Black; text = " No definition found.\r\n\r\n"; } else { richTextPermanent.SelectionFont = new Font("Courier New", 10f, FontStyle.Bold); richTextPermanent.SelectionColor = Color.Black; text = string.Format(" {0}: {1}\r\n\r\n", dtc.Category, dtc.Description); } richTextPermanent.AppendText(text); } } else { richTextPermanent.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); richTextPermanent.SelectionColor = Color.Green; richTextPermanent.AppendText("No permanent trouble codes found."); } }
public virtual bool GetDtcSnapshot(DTC dtc, ECUConnection connection, out byte[] snapshotBytes) { snapshotBytes = new byte[] { }; return(false); }
private void RefreshDisplay() { richTextDTC.Text = ""; richTextPending.Text = ""; richTextPermanent.Text = ""; if (arrayListDTC.Count > 0) { int num3 = 1; if (1 <= arrayListDTC.Count) { do { DTC dtc3 = (DTC)arrayListDTC[num3 - 1]; string text = string.Format("{0}. {1}\r\n", num3, dtc3.Name); richTextDTC.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); Color red = Color.Red; richTextDTC.SelectionColor = red; richTextDTC.AppendText(text); if (string.Compare(dtc3.Description, "") == 0) { richTextDTC.SelectionFont = new Font("Courier New", 10f, FontStyle.Italic | FontStyle.Bold); Color black = Color.Black; richTextDTC.SelectionColor = black; richTextDTC.AppendText(" No definition found.\r\n\r\n"); } else { string str5 = string.Format(" {0}: {1}\r\n\r\n", dtc3.Category, dtc3.Description); richTextDTC.SelectionFont = new Font("Courier New", 10f, FontStyle.Bold); Color color19 = Color.Black; richTextDTC.SelectionColor = color19; richTextDTC.AppendText(str5); } num3++; }while (num3 <= arrayListDTC.Count); } } else { richTextDTC.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); Color green = Color.Green; richTextDTC.SelectionColor = green; richTextDTC.AppendText("No stored trouble codes found."); } if (arrayListPending.Count > 0) { int num2 = 1; if (1 <= arrayListPending.Count) { do { DTC dtc2 = (DTC)arrayListPending[num2 - 1]; string str4 = string.Format("{0}. {1}\r\n", num2, dtc2.Name); richTextPending.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); Color color15 = Color.Red; richTextPending.SelectionColor = color15; richTextPending.AppendText(str4); if (string.Compare(dtc2.Description, "") == 0) { richTextPending.SelectionFont = new Font("Courier New", 10f, FontStyle.Italic | FontStyle.Bold); Color color13 = Color.Black; richTextPending.SelectionColor = color13; richTextPending.AppendText(" No definition found.\r\n\r\n"); } else { string str3 = string.Format(" {0}: {1}\r\n\r\n", dtc2.Category, dtc2.Description); richTextPending.SelectionFont = new Font("Courier New", 10f, FontStyle.Bold); Color color11 = Color.Black; richTextPending.SelectionColor = color11; richTextPending.AppendText(str3); } num2++; }while (num2 <= arrayListPending.Count); } } else { richTextPending.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); Color color9 = Color.Green; richTextPending.SelectionColor = color9; richTextPending.AppendText("No pending trouble codes found."); } if (arrayListPermanent.Count > 0) { int num = 1; if (1 <= arrayListPermanent.Count) { do { DTC dtc = (DTC)arrayListPermanent[num - 1]; string str2 = string.Format("{0}. {1}\r\n", num, dtc.Name); richTextPermanent.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); Color color7 = Color.Red; richTextPermanent.SelectionColor = color7; richTextPermanent.AppendText(str2); if (string.Compare(dtc.Description, "") == 0) { richTextPermanent.SelectionFont = new Font("Courier New", 10f, FontStyle.Italic | FontStyle.Bold); Color color5 = Color.Black; richTextPermanent.SelectionColor = color5; richTextPermanent.AppendText(" No definition found.\r\n\r\n"); } else { string str = string.Format(" {0}: {1}\r\n\r\n", dtc.Category, dtc.Description); richTextPermanent.SelectionFont = new Font("Courier New", 10f, FontStyle.Bold); Color color3 = Color.Black; richTextPermanent.SelectionColor = color3; richTextPermanent.AppendText(str); } num++; }while (num <= arrayListPermanent.Count); } } else { richTextPermanent.SelectionFont = new Font("Courier New", 12f, FontStyle.Bold); Color color = Color.Green; richTextPermanent.SelectionColor = color; richTextPermanent.AppendText("No permanent trouble codes found."); } }
public void ReadCodes() { arrayListDTC.Clear(); arrayListPending.Clear(); arrayListPermanent.Clear(); OBDParameterValue value6 = m_obdInterface.getValue("SAE.MIL", true); if (!value6.ErrorDetected) { SetMilStatus(value6.BoolValue); } OBDParameterValue value5 = m_obdInterface.getValue("SAE.DTC_COUNT", true); if (!value5.ErrorDetected) { SetDTCTotal((int)value5.DoubleValue); } OBDParameterValue value4 = m_obdInterface.getValue("SAE.STORED_DTCS", true); if (!value4.ErrorDetected) { StringEnumerator enumerator3 = value4.StringCollectionValue.GetEnumerator(); if (enumerator3.MoveNext()) { do { string current = enumerator3.Current; DTC dtc3 = m_obdInterface.getDTC(current); arrayListDTC.Add(dtc3); }while (enumerator3.MoveNext()); } } OBDParameterValue value3 = m_obdInterface.getValue("SAE.PENDING_DTCS", true); if (!value3.ErrorDetected) { StringEnumerator enumerator2 = value3.StringCollectionValue.GetEnumerator(); if (enumerator2.MoveNext()) { do { string strDTC = enumerator2.Current; DTC dtc2 = m_obdInterface.getDTC(strDTC); arrayListPending.Add(dtc2); }while (enumerator2.MoveNext()); } } OBDParameterValue value2 = m_obdInterface.getValue("SAE.PERMANENT_DTCS", true); if (!value2.ErrorDetected) { StringEnumerator enumerator = value2.StringCollectionValue.GetEnumerator(); if (enumerator.MoveNext()) { do { string str = enumerator.Current; DTC dtc = m_obdInterface.getDTC(str); arrayListPermanent.Add(dtc); }while (enumerator.MoveNext()); } } }
public override bool GetDtcSnapshot(DTC dtc, ECUConnection connection, out byte[] snapshotBytes) { // FIXME return(base.GetDtcSnapshot(dtc, connection, out snapshotBytes)); }