Пример #1
0
        public bool Add(UDS uds)
        {
            bool locationexist = false;

            foreach (Location loc in lokocations.Locations)
            {
                if (uds.Location.Id == loc.Id)
                {
                    locationexist = true;
                }
            }

            if (uds != null && CategoriesCollection.Instance.Categories.Contains(uds.Category) && locationexist)
            {
                UDScollection.Add(uds);

                if (UDScollection.Contains(uds))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }
Пример #2
0
 public void Remove(UDS uds)
 {
     if (uds != null)
     {
         UDScollection.Remove(uds);
     }
 }
Пример #3
0
        public void TestRemove()
        {
            //Arrange
            Arrange();

            UDS item = GetTestUDS();

            collection.UDScollection.Add(item);
            int startvalue = collection.UDScollection.Count;

            //Act
            collection.UDScollection.Remove(item);

            //Assert
            Assert.AreEqual(startvalue - 1, collection.UDScollection.Count);
        }
        public async void Testadd()
        {
            //Arrange
            Arrange();
            int startvalue = UdsCollection.Instance.UDScollection.Count;
            UDS item       = GetTestUDS();

            //Act
            UdsCollection.Instance.Add(item);

            //Assert
            Assert.AreEqual(startvalue + 1, UdsCollection.Instance.UDScollection.Count);

            //Cleanup
            UdsCollection.Instance.UDScollection.Remove(item);
        }
Пример #5
0
 /// <summary>
 /// ����ļ��������ݿ����
 /// </summary>
 /// <param name="att">DocAttachFile��</param>
 /// <param name="DocID">�ļ�ID</param>
 public void AddAttach(UDS.Components.DocAttachFile att,long DocID)
 {
     UDS.Components.Database data = new UDS.Components.Database();
     SqlParameter[] prams = {
                                data.MakeInParam("@DocID",  SqlDbType.Int, 20, DocID),
                                data.MakeInParam("@FileName",  SqlDbType.VarChar, 300, att.FileName),
                                data.MakeInParam("@FileSize",  SqlDbType.Int, 20, att.FileSize),
                                data.MakeInParam("@FileAttribute",  SqlDbType.SmallInt,20, att.FileAttribute),
                                data.MakeInParam("@FileVisualPath",  SqlDbType.NVarChar, 200, att.FileVisualPath),
                                data.MakeInParam("@FileAuthor",  SqlDbType.NVarChar, 50, att.FileAuthor),
                                data.MakeInParam("@FileCatlog",  SqlDbType.NVarChar, 20, att.FileCatlog),
                                data.MakeInParam("@FileAddedDate", SqlDbType.DateTime, 30, DateTime.Parse(att.FileAddedDate))
                            };
     try
     {
         data.RunProc("sp_Flow_AddFile", prams);
     }
     catch (Exception ex)
     {
         Error.Log(ex.ToString());
         throw new Exception("�ļ��������ͳ���!",ex);
     }
 }
Пример #6
0
        public override byte[] ReceiveRequest(IEnumerable <byte> request)
        {
            SharedResponse = new List <byte>();

            byte[] requestBytes = request.ToArray();
            if (requestBytes.Length == 0)
            {
                // this shouldn't happen
                return(new byte[] { });
            }

            if (!Enum.IsDefined(typeof(UDS), requestBytes[0]))
            {
                return(CreateNegativeResponse((UDS)requestBytes[0], NR.NR_ServiceNotSupported));
            }
            UDS requestCommand = (UDS)requestBytes[0];

            WriteByte((byte)(requestBytes[0] + 0x40));

            ushort identifier = 0;

            if (requestBytes.Length > 2)
            {
                identifier = (ushort)(requestBytes[1] << 8 | requestBytes[2]);
            }

            if ((requestCommand == UDS.UDS_TesterPresent) && (requestBytes.Length >= 2))
            {
                WriteByte(requestBytes[1]);
            }
            else if ((requestCommand == UDS.UDS_DiagnosticSessionControl) && (requestBytes.Length >= 2))
            {
                ECU_SESSION = requestBytes[1];
                WriteByte(ECU_SESSION);
                WriteUint16(ECU_TIMING_RESOLUTION_1MS);
                WriteUint16(ECU_TIMING_RESOLUTION_10MS);
            }
            else if ((requestCommand == UDS.UDS_ReadDataByIdentifier) && (requestBytes.Length >= 3))
            {
                WriteUint16(identifier);
                if (identifier == (ushort)Identifier.ID_SupplierIdentifier)
                {
                    WriteByte(ECU_SUPPLIER_IDENTIFIER);
                }
                else if (identifier == (ushort)Identifier.ID_SessionVariant)
                {
                    WriteByte(ECU_GATEWAY_MODE);
                    WriteUint16(ECU_VARIANT);
                    WriteByte(ECU_SESSION);
                }
            }
            else if ((requestCommand == UDS.UDS_WriteDataByIdentifier) && (requestBytes.Length >= 3))
            {
            }
            else if ((requestCommand == UDS.UDS_ReadDTCInformation) && (requestBytes.Length >= 2))
            {
                byte infoType = requestBytes[1];
                WriteByte(infoType);

                byte mask = requestBytes[2];
                WriteByte(0xFF); // mask

                if (infoType == 0x02)
                {
                    WriteByte(0x00);
                    WriteByte(0x90);
                    WriteByte(0x00);
                    WriteByte(0x2F);
                }
                else if (infoType == 0x06)
                {
                    WriteByteArray(EnvTest);
                }
            }
            else
            {
                // unrecognized
                return(CreateNegativeResponse((UDS)requestBytes[0], NR.NR_ServiceNotSupported));
            }

            return(SharedResponse.ToArray());
        }
Пример #7
0
 public byte[] CreateNegativeResponse(UDS callingFunction, NR reason)
 {
     // throw new Exception("debugger please");
     return(new byte[] { 0x7F, (byte)callingFunction, (byte)reason });
 }