public static string GenerateJoinKey(string imei) { AVL.RegisterDevice.JRegisterDevice d = new AVL.RegisterDevice.JRegisterDevice(imei); //AVL.Purchase.JPurchasePlan plan = new AVL.Purchase.JPurchasePlan(d.PurchasePlanCode.ToString()); //DataTable childs = AVL.JoinDevice.JJoinDevices.GetData(0,d.Code); //if (childs.Rows.Count >= plan.personCount) // return "-1," + childs.Rows.Count; Accounting.Cash.JCash cash = new Accounting.Cash.JCash(0, d.personCode); if (cash.paid <= 0) { return("-1,"); } AVL.AndroidKeys.JAndroidKey k = new AVL.AndroidKeys.JAndroidKey(); k.ExpireDate = DateTime.Now.AddMinutes(15); k.IMEI = imei; k.RegKey = rnd.Next(100000, 999999).ToString(); if (k.Insert() > 0) { //add device itself to its own group //AVL.JoinDevice.JJoinDevice jd = new AVL.JoinDevice.JJoinDevice(); //AVL.RegisterDevice.JRegisterDevice d = new AVL.RegisterDevice.JRegisterDevice(imei); //if (!jd.GetData(" parentDeviceCode= " + d.Code))//check if group made before //{ // jd.registerDate = DateTime.Now; // jd.parentDeviceCode = jd.childDeviceCode = d.Code; // jd.Insert(); //} return(k.RegKey); } return("0"); }
/// <summary> /// وقتی یک فاکتور صادر می شود یک کد کالا هم دارد که بعد پرداخت فاکتور در ///webavl/callback.aspx /// این متد صدا زده می شود تا عملیاتی برای بعد پرداخت انجام شود. /// </summary> /// <param name="parameter"></param> public void DoOperation(string parameter) { AVL.RegisterDevice.JRegisterDevice ol = new AVL.RegisterDevice.JRegisterDevice(int.Parse(parameter)); ol.isPaid = true; ol.active = true; if (ol.Update(true, false)) { WebClassLibrary.JWebManager.RunClientScript("alert('عملیات با موفقیت انجام شد.');", "ConfirmDialog"); } }
/// <summary> ///اگر ///true ///شی سرعت غیر مجاز دارد و از سرعت یتعیین شده برای دستگاه بیشتر است. /// </summary> /// <param name="ol"></param> /// <param name="device"></param> /// <param name="coordinate"></param> /// <returns></returns> public static bool CheckSpeedFault(AVL.ObjectList.JObjectList ol, AVL.RegisterDevice.JRegisterDevice device, AVL.Coordinate.JCoordinate coordinate) { if (device.speed != 0 && coordinate.Speed > device.speed) { AVL.SpeedFault.JSpeedFaultData speed = new AVL.SpeedFault.JSpeedFaultData(); speed.Datetime = coordinate.DeviceSendDateTime; speed.LimitedSpeed = device.speed; speed.speed = coordinate.Speed; speed.Insert(false, false); return(true); } return(false); }
/// <summary> /// FM1100, FM2100, FM2200, FM4100 , FM4200 /// </summary> /// <returns></returns> public static AVL.Coordinate.JCoordinate TeltonikaFMv1(byte[] Data) { DataProtocol.JTeltonikaProtocolV1 protocol = new DataProtocol.JTeltonikaProtocolV1(); byte pStart = 0; byte ByteLength = 0; byte[] tempData; //IMEI -15 ByteLength = 15; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.IMEI = System.Text.Encoding.ASCII.GetString(tempData); //GetDecimal(tempData).ToString(); pStart += ByteLength; //Codec ID -1 ByteLength = 1; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.CodecID = (int)GetDecimal(tempData); pStart += ByteLength; //Number Of Data -1 ByteLength = 1; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.NumberOfData = (int)GetDecimal(tempData); pStart += ByteLength; //TimeStamp -8 ByteLength = 8; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.TimeStamp = GetDateTime(tempData, new DateTime(1970, 1, 1)); pStart += ByteLength; //Priority Data -1 ByteLength = 1; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Priority = (byte)GetDecimal(tempData); pStart += ByteLength; //Longitude -4 ByteLength = 4; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Longitude = GetDecimal(tempData); pStart += ByteLength; //Latitude -4 ByteLength = 4; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Latitude = GetDecimal(tempData); pStart += ByteLength; //Altitude -2 ByteLength = 2; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Altitude = (float)GetDecimal(tempData); pStart += ByteLength; //Angle -2 ByteLength = 2; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Angle = (int)GetDecimal(tempData); pStart += ByteLength; //Satellite -1 ByteLength = 1; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Satellite = (int)GetDecimal(tempData); pStart += ByteLength; //Speed -2 ByteLength = 2; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Speed = (float)GetDecimal(tempData); pStart += ByteLength; AVL.Coordinate.JCoordinate coordinate = new Coordinate.JCoordinate(); coordinate.Altitude = protocol.Altitude; coordinate.Angle = protocol.Angle; coordinate.lat = (float)protocol.Latitude; coordinate.lng = (float)protocol.Longitude; coordinate.DeviceSendDateTime = protocol.TimeStamp; coordinate.RegisterDateTime = DateTime.Now; coordinate.Speed = protocol.Speed; coordinate.IMEI = protocol.IMEI; AVL.RegisterDevice.JRegisterDevice regdevice = new AVL.RegisterDevice.JRegisterDevice(protocol.IMEI); coordinate.DeviceCode = regdevice.Code; coordinate.ObjectCode = regdevice.ObjectCode; return(coordinate); }
//Tarahan Samane Android Aplication public static void TSIPAndroidApplication() { byte[] Data; int discarded; foreach (System.Data.DataRow dr in AVL.GPSData.TSIPAndroid.JTSIPAndroids.GetDataTable().Rows) { Data = AVL.Device.DataProtocol.HexEncoding.GetBytes(dr["Data"].ToString(), out discarded); DataProtocol.JTSIPAndroidProtocol protocol = new DataProtocol.JTSIPAndroidProtocol(); byte pStart = 0; byte ByteLength = 0; byte[] tempData; //IMEI -8 ByteLength = 8; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.IMEI = System.Text.Encoding.ASCII.GetString(tempData); //GetDecimal(tempData).ToString(); pStart += ByteLength; //Longitude -8 ByteLength = 8; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Longitude = GetDecimal(tempData); pStart += ByteLength; //Latitude -8 ByteLength = 8; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Latitude = GetDecimal(tempData); pStart += ByteLength; //datetime -8 ByteLength = 8; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.datetime = GetDateTime(tempData, new DateTime(1970, 1, 1)); pStart += ByteLength; //Speed -1 ByteLength = 1; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Speed = (float)GetDecimal(tempData); pStart += ByteLength; //curse -1 ByteLength = 1; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.curse = (int)GetDecimal(tempData); pStart += ByteLength; //Altitude -8 ByteLength = 8; tempData = new byte[ByteLength]; Buffer.BlockCopy(Data, pStart, tempData, 0, ByteLength); protocol.Altitude = (float)GetDecimal(tempData); pStart += ByteLength; AVL.Coordinate.JCoordinate coordinate = new Coordinate.JCoordinate(); coordinate.Altitude = protocol.Altitude; coordinate.Angle = protocol.curse; coordinate.lat = (float)protocol.Latitude; coordinate.lng = (float)protocol.Longitude; coordinate.DeviceSendDateTime = protocol.datetime; coordinate.RegisterDateTime = DateTime.Now; coordinate.Speed = protocol.Speed; coordinate.IMEI = protocol.IMEI; AVL.RegisterDevice.JRegisterDevice regdevice = new AVL.RegisterDevice.JRegisterDevice(protocol.IMEI); coordinate.DeviceCode = regdevice.Code; coordinate.ObjectCode = regdevice.ObjectCode; coordinate.Insert(); AVL.GPSData.TSIPAndroid.JTSIPAndroid t = new GPSData.TSIPAndroid.JTSIPAndroid(); t.Proceced(int.Parse(dr["Code"].ToString())); } }