public async Task <string> CheckInOfflineSync(string apitoken, User loguser) { int totalCounts = 0; StringBuilder sbUnMoved = new StringBuilder(); DALExceptionManagment dal_Exceptionlog = new DALExceptionManagment(); try { var lstchekIns = await App.SQLiteDb.GetAllVehicleAsync(); if (lstchekIns != null) { if (lstchekIns.Count > 0) { foreach (var items in lstchekIns) { if (DeviceInternet.InternetConnected()) { var objexlog = new OfflineSyncLog(); try { var resultCustomerID = SaveVehicleNewCheckIn(apitoken, items); if (resultCustomerID != null) { try { objexlog.CustomerParkingSlotID = resultCustomerID.CustomerParkingSlotID; objexlog.RegistrationNumber = items.RegistrationNumber; objexlog.LocationParkingLotName = loguser.LocationParkingLotID.LocationParkingLotName; objexlog.LocationParkingLotID = loguser.LocationParkingLotID.LocationParkingLotID; objexlog.CreatedBy = resultCustomerID.CreatedBy; if (resultCustomerID.CustomerParkingSlotID != 0) { objexlog.ExceptionMessage = "Success"; objexlog.IsSync = true; if (!string.IsNullOrEmpty(items.ParkingStartTime) && !string.IsNullOrEmpty(items.ParkingEndTime)) { objexlog.ExpectedStartTime = Convert.ToDateTime(items.ParkingStartTime); objexlog.ExpectedEndTime = Convert.ToDateTime(items.ParkingEndTime); } } else { if (sbUnMoved.Length == 0) { sbUnMoved.AppendLine(items.RegistrationNumber); } else { sbUnMoved.AppendLine(", " + items.RegistrationNumber); } objexlog.ExceptionMessage = "Failed"; objexlog.IsSync = false; DeSyncVehicleCheckIn objdesync = new DeSyncVehicleCheckIn(); objdesync.VehicleTypeCode = items.VehicleTypeCode; objdesync.BayRange = items.BayRange; objdesync.RegistrationNumber = items.RegistrationNumber; objdesync.LocationParkingLotName = items.LocationParkingLotName; await App.SQLiteDb.SaveDeSyncCheckInAsync(objdesync); } } catch (Exception ex) { objexlog.ExceptionMessage = "Failed"; objexlog.IsSync = false; dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message + ",At:" + "Item after Online Sync" + resultCustomerID.CustomerParkingSlotID, "DALCheckIn.cs", items.RegistrationNumber + "," + items.ParkingStartTime + "," + items.ParkingEndTime + "," + "", "CheckInOfflineSync"); } finally { dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", "Finally at:" + "Item after Online Sync" + resultCustomerID.CustomerParkingSlotID, "DALCheckIn.cs", items.RegistrationNumber + "," + items.ParkingStartTime + "," + items.ParkingEndTime + "," + "", "CheckInOfflineSync"); dal_Exceptionlog.InsertOfflineSynchException(Convert.ToString(App.Current.Properties["apitoken"]), objexlog); await App.SQLiteDb.DeleteItemAsync(items); } } else { dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", "No Records found ", "DALCheckIn.cs", "", "CheckInOfflineSync"); } } catch (Exception ex) { if (sbUnMoved.Length == 0) { sbUnMoved.AppendLine(items.RegistrationNumber); } else { sbUnMoved.AppendLine(", " + items.RegistrationNumber); } await App.SQLiteDb.DeleteItemAsync(items); dal_Exceptionlog.InsertOfflineSynchException(Convert.ToString(App.Current.Properties["apitoken"]), objexlog); dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "DALCheckIn.cs", items.RegistrationNumber + "," + items.ParkingStartTime + "," + items.ParkingEndTime, "CheckInOfflineSync"); } } else { if (sbUnMoved.Length == 0) { sbUnMoved.AppendLine(items.RegistrationNumber); } else { sbUnMoved.AppendLine(", " + items.RegistrationNumber); } } } } else { dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", "No Records in VehicleCheckIn", "DALCheckIn.cs", "", "CheckInOfflineSync"); } } else { dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", "No Records in VehicleCheckIn", "DALCheckIn.cs", "", "CheckInOfflineSync"); } } catch (Exception ex) { StackTrace st = new StackTrace(ex, true); //Get the first stack frame StackFrame frame = st.GetFrame(0); //Get the file name string fileName = frame.GetFileName(); //Get the method name string methodName = frame.GetMethod().Name; //Get the line number from the stack frame int line = frame.GetFileLineNumber(); string exDetails = fileName + "," + methodName + "," + line; dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "DALCheckIn.cs", exDetails, "CheckInOfflineSync"); } return(sbUnMoved.ToString()); }