public async Task <bool> HasValidSetup(App_Settings appSettings) { bool hasValidSetup = false; //get version string version = "1.6"; //doesn't like this in mobile anymore Assembly.GetExecutingAssembly().GetName().Version.ToString(); string dbVersion = (appSettings.DbVersion != null) ? appSettings.DbVersion : "0.0.0.0"; if (version.Substring(0, 3) != dbVersion.Substring(0, 3)) { return(false); } // i think has dataconnection is redundant at this point with a validation of the rest componen if (HasDataConnection()) { hasValidSetup = true; } else { // it'll either have old data or it won't. hasValidSetup = false; } // validate device return(hasValidSetup); }
public string GetDeviceID(string DeviceName) { App_Settings appSettings = GetApplicationSettings(); RestClient restClient = new RestClient(appSettings); return(restClient.GetDeviceID(DeviceName)); }
public bool UpdateTechnicianRecordSync(JT_Technician technician) { bool returnData = false; App_Settings appSettings = App.Database.GetApplicationSettings(); // set up the proper URL string url = GetRestServiceUrl(); if (!url.EndsWith(@"/")) { url += @"/"; } url += @"u/JT_Technician"; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(url); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); JsonSerializerSettings microsoftDateFormatSettings = new JsonSerializerSettings(); microsoftDateFormatSettings.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat; if (appSettings.DeviceID != null) { SimpleAES encryptText = new SimpleAES("V&WWJ3d39brdR5yUh5(JQGHbi:FB@$^@", "W4aRWS!D$kgD8Xz@"); string authid = encryptText.EncryptToString(appSettings.DeviceID); string datetimever = encryptText.EncryptToString(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); client.DefaultRequestHeaders.Add("x-tdws-authid", authid); client.DefaultRequestHeaders.Add("x-tdws-auth", datetimever); } //client.AddHeader("x-tdws-authid", authid); //request.AddHeader("x-tdws-auth", datetimever); // Make the call and get a valid response HttpResponseMessage response = client.PutAsync(client.BaseAddress, new StringContent(JsonConvert.SerializeObject(technician, microsoftDateFormatSettings), null, "application/json")).Result; // TODO.... await response.EnsureSuccessStatusCode(); // Read out the result... it better be JSON! string JsonResult = response.Content.ReadAsStringAsync().Result; try { returnData = JsonConvert.DeserializeObject <bool>(JsonResult); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.Data.UpdatTechnicianRecordSync"); } client.Dispose(); response.Dispose(); return(returnData); }
public void SignIn(App_Technician technician) { // dch rkl 12/07/2016 catch exception try { App.Database.SaveTechnicianAsCurrent(technician); if (App.Database.HasDataConnection()) { App.Database.CreateDependentTables(technician); } App_Settings appSettings = App.Database.GetApplicationSettings(); appSettings.LoggedInTechnicianNo = technician.TechnicianNo; appSettings.LoggedInTechnicianDeptNo = technician.TechnicianDeptNo; App.Database.SaveAppSettings(appSettings); IsSignedIn = true; } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.TechnicianListPageViewModel.SignIn"); } }
public async void SignIn(App_Technician technician) { if (IsLoading) { return; } else { IsLoading = true; await Task.Run(() => App.Database.SaveTechnicianAsCurrent(technician)); //Thread.Sleep(5000); await Task.Run(() => App.Database.CreateDependentTables(technician)); //Thread.Sleep(5000); App_Settings appSettings = App.Database.GetApplicationSettings(); appSettings.LoggedInTechnicianNo = technician.TechnicianNo; appSettings.LoggedInTechnicianDeptNo = technician.TechnicianDeptNo; App.Database.SaveAppSettings(appSettings); IsLoading = false; IsSignedIn = true; } }
public RestClient(App_Settings appSettings) : base() { if (appSettings != null) { IsUsingHttps = appSettings.IsUsingHttps; RestUrl = appSettings.RestServiceUrl; } }
public AppSettingsPageViewModel() { _appSettings = App.Database.GetApplicationSettings(); if (_appSettings == null) { _appSettings = new App_Settings(); } }
public List <T> GetDataPostSync <T>(string filterType, string filterText) { App_Settings appSettings = App.Database.GetApplicationSettings(); // Set up our return data object -- a list of typed objects. List <T> returnData = new List <T>(); // set up the proper URL string url = GetRestServiceUrl(); if (!url.EndsWith(@"/")) { url += @"/"; } if ((filterType != null) && (filterType.Length > 0) && (filterText != null) && (filterText.Length > 0)) { url += @"q/" + typeof(T).Name + @"/" + filterType;// + @"?v=" + Uri.EscapeDataString(filterText); } else { url += @"all/" + typeof(T).Name; } // Create a HTTP client to call the REST service RestSharp.RestClient client = new RestSharp.RestClient(url); var request = new RestSharp.RestRequest(Method.POST); if (appSettings.DeviceID != null) { SimpleAES encryptText = new SimpleAES("V&WWJ3d39brdR5yUh5(JQGHbi:FB@$^@", "W4aRWS!D$kgD8Xz@"); string authid = encryptText.EncryptToString(appSettings.DeviceID); string datetimever = encryptText.EncryptToString(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); request.AddHeader("x-tdws-authid", authid); request.AddHeader("x-tdws-auth", datetimever); } request.RequestFormat = DataFormat.Json; request.AddBody(filterText); var response = client.Execute(request); if (response.StatusCode != System.Net.HttpStatusCode.OK) { //throw new Exception("Bad request"); ErrorReporting errorReporting = new ErrorReporting(); // dch rkl 12/07/2016 add the call/sub/proc to log //errorReporting.sendException(new Exception(response.Content)); errorReporting.sendException(new Exception(response.Content), "RestClient.cs.GetDataPostSync"); } string JsonResult = response.Content; returnData = JsonConvert.DeserializeObject <List <T> >(JsonResult); return(returnData); }
public RestClient(TechDashboardDatabase database) : base() { App_Settings appSettings = database.GetApplicationSettings(); if (appSettings != null) { IsUsingHttps = appSettings.IsUsingHttps; RestUrl = appSettings.RestServiceUrl; } }
public SDataClient(App_Settings appSettings) : base() { if (appSettings != null) { IsUsingHttps = appSettings.IsUsingHttps; SDataUrl = appSettings.SDataUrl; UserId = appSettings.SDataUserId; Password = appSettings.SDataPassword; } }
public SDataClient(TechDashboardDatabase database) : base() { App_Settings appSettings = database.GetApplicationSettings(); if (appSettings != null) { IsUsingHttps = appSettings.IsUsingHttps; SDataUrl = appSettings.SDataUrl; UserId = appSettings.SDataUserId; Password = appSettings.SDataPassword; } }
// dch rkl 10/14/2016 format the time - Note: This logic should be added to the JT_Technician model private string FormattedTime(string sTimeIn) { if (sTimeIn == null) { sTimeIn = ""; } string sTimeOut = sTimeIn; string sHour = ""; string sMin = ""; string sAMorPM = ""; int iHour = 0; if (sTimeIn.Length == 4) { sHour = sTimeIn.Substring(0, 2); sMin = sTimeIn.Substring(2, 2); } else if (sTimeIn.Length == 3) { sHour = "0" + sTimeIn.Substring(0, 1); sMin = sTimeIn.Substring(1, 2); } int.TryParse(sHour, out iHour); if (iHour > 0) { if (iHour < 12) { sAMorPM = "AM"; } else { sAMorPM = "PM"; } App_Settings appSettings = App.Database.GetApplicationSettings(); if (appSettings.TwentyFourHourTime == false && iHour > 12) { iHour = iHour - 12; sHour = iHour.ToString(); if (sHour.Length == 1) { sHour = "0" + sHour; } } sTimeOut = string.Format("{0}:{1} {2}", sHour, sMin, sAMorPM); } return(sTimeOut); }
public SDataClient(TechDashboardDatabase database) { if (database.HasValidSetup()) { App_Settings appSettings = database.GetApplicatioinSettings(); if (appSettings != null) { _isUsingHttps = appSettings.IsUsingHttps; _sDataUrl = appSettings.SDataUrl; _userId = appSettings.SDataUserId; _password = appSettings.SDataPassword; } } }
private void ButtonFilter_Clicked(object sender, EventArgs e) { App_Settings appSettings = App.Database.GetApplicationSettings(); DateTime lowerLimit = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysBefore) * (-1))).Date; DateTime upperLimit = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysAfter))).Date; if (lowerLimit > filterStartDate.Date || upperLimit < filterEndDate.Date) { DisplayAlert("Update Settings", "These dates exceed your application settings. Please modify your range in there to import more data.", "OK"); } _vm.filterScheduledAppointments(filterStartDate.Date, filterEndDate.Date); }
public SDataClient(App_Settings appSettings) { //_isUsingHttps = false; //_sDataUrl = @"jobops2015dev.rkldev.local/sdata/MasApp/MasContract/JOB/"; //_userId = @"sdata"; //_password = @"RKLsupp@rt"; if (appSettings != null) { _isUsingHttps = appSettings.IsUsingHttps; _sDataUrl = appSettings.SDataUrl; _userId = appSettings.SDataUserId; _password = appSettings.SDataPassword; } }
public void SignIn(JT_Technician technician) { App.Database.SaveTechnicianAsCurrent(technician); if (App.Database.HasDataConnection()) { App.Database.CreateDependentTables(technician); } App_Settings appSettings = App.Database.GetApplicationSettings(); appSettings.LoggedInTechnicianNo = technician.TechnicianNo; appSettings.LoggedInTechnicianDeptNo = technician.TechnicianDeptNo; App.Database.SaveAppSettings(appSettings); IsSignedIn = true; }
async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { MainMenuItem item = e.SelectedItem as MainMenuItem; if (item != null) { if (item.Title.ToLower() == "exit") { // puke... close app await DisplayAlert("Log off", "Normally, this would log the user off.", "OK", "Cancel"); return; } if (item.Title.ToLower() == "log out") { App_Settings appSettings = App.Database.GetApplicationSettings(); appSettings.LoggedInTechnicianNo = ""; appSettings.LoggedInTechnicianDeptNo = ""; App.Database.SaveAppSettings(appSettings); TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel(); viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged; //await Navigation.PushAsync(new TechnicianListPage(viewModel)); //Detail = new NavigationPage(new TechnicianListPage(viewModel)); Application.Current.MainPage = new TechnicianListPage(viewModel); //new NavigationPage(new TechnicianListPage(viewModel)); return; } _masterPage.ListView.SelectedItem = null; // so the item doesn't stay highlighted if (item.Title.ToLower() == "settings") { AppSettingsPage page = (AppSettingsPage)Activator.CreateInstance(item.TargetType); page.SettingsSaved += AppSettingsPage_SettingsSaved; await Detail.Navigation.PushAsync(page); } else { await Detail.Navigation.PushAsync((Page)Activator.CreateInstance(item.TargetType)); } IsPresented = false; } }
public void SaveAppSettings(App_Settings appSettings) { int rows = 0; lock (_locker) { if (appSettings.ID == 0) { rows = _database.Insert(appSettings); System.Diagnostics.Debug.WriteLine("Rows inserted = " + rows.ToString()); } else { rows = _database.Update(appSettings); System.Diagnostics.Debug.WriteLine("Rows updated = " + rows.ToString()); } } }
private void buttonFilter_Click(object sender, RoutedEventArgs e) { // dch rkl 10/27/2016 Validate the dates that are input BEGIN DateTime dtStart; DateTime dtEnd; if (DateTime.TryParse(filterStartDate.SelectedDate.ToString(), out dtStart) == false) { MessageBox.Show("Invalid Start Date", "Invalid Date", MessageBoxButton.OK); } else if (DateTime.TryParse(filterEndDate.SelectedDate.ToString(), out dtEnd) == false) { MessageBox.Show("Invalid End Date", "Invalid Date", MessageBoxButton.OK); } else { // dch rkl 10/27/2016 Validate the dates that are input END App_Settings appSettings = App.Database.GetApplicationSettings(); DateTime lowerLimit = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysBefore) * (-1))).Date; DateTime upperLimit = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysAfter))).Date; App.Current.Properties["filterStartDate"] = filterStartDate.SelectedDate; App.Current.Properties["filterEndDate"] = filterEndDate.SelectedDate; // dch rkl 12/01/2016 if dates are outside of acceptable range, change them. BEGIN //if (lowerLimit > filterStartDate.SelectedDate || upperLimit < filterEndDate.SelectedDate) //{ // MessageBox.Show("These dates exceed your application settings. Please modify your range in there to import more data.", "Update Settings", MessageBoxButton.OK); //} if (lowerLimit > filterStartDate.SelectedDate) { filterStartDate.Text = lowerLimit.ToShortDateString(); } if (upperLimit < filterEndDate.SelectedDate) { filterEndDate.Text = upperLimit.ToShortDateString(); } // dch rkl 12/01/2016 if dates are outside of acceptable range, change them. END _vm.filterScheduledAppointments((DateTime)filterStartDate.SelectedDate, (DateTime)filterEndDate.SelectedDate); } // dch rkl 10/27/2016 Validate the dates that are input }
private void BtnExit_Click(object sender, RoutedEventArgs e) { // dch rkl 01/20/2017 Do not allow logoff if there is no data connection bool bDoLogoff = true; bool bHasDataConnection = App.Database.HasDataConnection(); if (bHasDataConnection == false) { string sMsg = "WARNING: No data connection exists; logoff cannot be done at this time."; MessageBoxResult result = MessageBox.Show(sMsg, "Cannot Log Off", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); bDoLogoff = false; } else { // dch rkl 01/20/2017 If Transactions are Pending to Sync, force them to sync first List <JT_TransactionImportDetail> transactionImportDetails = App.Database.GetCurrentExport(); if (transactionImportDetails.Count > 0) { string sMsg = "WARNING: Pending transactions exist, and\n a sync is required before logging off.\n\nClick OK to proceed with Sync, or \nCancel to cancel logoff."; MessageBoxResult result = MessageBox.Show(sMsg, "Sync is Required", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); if (result == MessageBoxResult.OK) { TransactionSync(); } else { bDoLogoff = false; } } } //Application.Current.Shutdown(); if (bDoLogoff) { App_Settings appSettings = App.Database.GetApplicationSettings(); appSettings.LoggedInTechnicianDeptNo = ""; appSettings.LoggedInTechnicianNo = ""; App.Database.SaveAppSettings(appSettings); contentArea.Content = new TechnicianListPage(); } }
/// <summary> /// Retreives all technician schedule detail records from the ERP connection /// for a given technician and fills the local JT_TechnicianScheduleDetail table. /// </summary> /// <param name="technicianNumber">The technician's employee number</param> public void FillTechnicianScheduleDetailTable(string technicianNumber) { FillLocalTable <JT_TechnicianScheduleDetail>("where", "TechnicianNo eq '" + technicianNumber + "'"); if (technicianNumber == "0000203") { JT_TechnicianScheduleDetail skedDetail = new JT_TechnicianScheduleDetail() { TechnicianDeptNo = "13", TechnicianNo = "0000202", SalesOrderNo = "0001671", WTNumber = "001", WTStep = "001", ScheduleDate = DateTime.Now, StartTime = "1100", HoursScheduled = 5 }; _database.Insert(skedDetail); } // now that we have the schedule details, remove any that don't match our date range // First, get the number of days before and after today that will be allowed. App_Settings appSettings = GetApplicationSettings(); // Find the "bad" schedule details -- date less than allowed lower limint and // greater than allowed upper limit DateTime lowerLimit = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysBefore) * (-1))).Date; DateTime upperLimit = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysAfter))).Date; List <JT_TechnicianScheduleDetail> scheduleDetails = _database.Table <JT_TechnicianScheduleDetail>().Where( sd => (sd.ScheduleDate < lowerLimit) || (sd.ScheduleDate > upperLimit) ).ToList(); // Get rid of these records from our DB foreach (JT_TechnicianScheduleDetail detail in scheduleDetails) { System.Diagnostics.Debug.WriteLine("Removing JT_TechnicianScheduleDetail object with date " + detail.ScheduleDate.ToString("yyyy-MM-dd")); _database.Delete(detail); } }
public SchedulePageViewModel() { // dch rkl 12/07/2016 catch exception try { App_Settings appSettings = App.Database.GetApplicationSettings(); _clockedInTimeEntry = App.Database.GetClockedInTimeEntry(); _scheduleDetails = new ObservableCollection <App_ScheduledAppointment>(App.Database.GetScheduledAppointments()); // dch rkl 10/14/2016 if any tickets in the schedule list are marked COM (completed) // in the JT_TransactionImportDetail table, remove them from the schedule list List <JT_TransactionImportDetail> lsTrans = App.Database.GetCurrentExport(); if (lsTrans.Count > 0) { var copy = new ObservableCollection <App_ScheduledAppointment>(_scheduleDetails); foreach (App_ScheduledAppointment sched in copy) { foreach (JT_TransactionImportDetail tran in lsTrans) { if (tran.RecordType == "S" && tran.SalesOrderNo == sched.SalesOrderNumber && tran.WTNumber == sched.WorkTicketNumber && tran.WTStep == sched.WorkTicketStep && tran.StatusCode == "COM") { _scheduleDetails.Remove(sched); break; } } } } // dch rkl 10/14/2016 END _defaultStartDate = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysBefore) * (-1))).Date; _defaultEndDate = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysAfter))).Date; } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.SchedulePageViewModel"); } }
// dch rkl 12/09/2016 return number failed and number successful //public void syncWithServer() public void syncWithServer(ref int syncSuccess, ref int syncFailed) { // dch rkl 12/07/2016 catch exception try { // dch rkl 12/09/2016 return number failed and number successful syncSuccess = 0; syncFailed = 0; TechDashboard.Data.RestClient restClient = new Data.RestClient(App.Database.GetApplicationSettings().IsUsingHttps, App.Database.GetApplicationSettings().RestServiceUrl); foreach (JT_TransactionImportDetail transaction in _transactionImportDetails) { // dch rkl 12/05/2016 If Lot/Serial Nbr Data, sync back to JobOps with multiple rows //bool updateWorked = restClient.InsertTransactionImportDetailRecordSync(transaction); bool updateWorked = true; if (transaction.LotSerialNo == null || transaction.LotSerialNo.Trim().Length == 0) { // dch rkl 12/09/2016 This now returns a results object //updateWorked = restClient.InsertTransactionImportDetailRecordSync(transaction); updateWorked = restClient.InsertTransactionImportDetailRecordSync(transaction).Success; } else { // Split into LotSerNo/Qty strings string[] lotSerQty = transaction.LotSerialNo.Split('|'); double qty = 0; foreach (string lsq in lotSerQty) { // Split each LotSerNo/Qty string into LotSerNo and Qty string[] sqty = lsq.Split('~'); if (sqty.GetUpperBound(0) > 0) { double.TryParse(sqty[1], out qty); if (qty > 0) { transaction.QuantityUsed = qty; transaction.LotSerialNo = sqty[0]; // dch rkl 12/09/2016 This now returns a results object //bool updateWorkedLS = restClient.InsertTransactionImportDetailRecordSync(transaction); bool updateWorkedLS = restClient.InsertTransactionImportDetailRecordSync(transaction).Success; if (updateWorkedLS == false) { updateWorked = false; break; } } } } } if (updateWorked) { App.Database.DeleteExportRow(transaction); // dch rkl 12/09/2016 return number failed and number successful syncSuccess++; } // dch rkl 12/09/2016 return number failed and number successful else { syncFailed++; } } _transactionImportDetails = App.Database.GetCurrentExport(); PropertyChanged(this, new PropertyChangedEventArgs("UpdateCount")); PropertyChanged(this, new PropertyChangedEventArgs("transactionImportDetails")); JT_Technician technician = App.Database.GetCurrentTechnicianFromDb(); var techUpdateWorked = restClient.UpdateTechnicianRecordSync(technician); PropertyChanged(this, new PropertyChangedEventArgs("UpdateCount")); PropertyChanged(this, new PropertyChangedEventArgs("transactionImportDetails")); App_Settings appSettings = App.Database.GetApplicationSettings(); appSettings.LastSyncDate = DateTime.Now.ToString(); LastSyncDate = appSettings.LastSyncDate; App.Database.SaveAppSettings(appSettings); } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.SyncPageViewModel.syncWithServer"); } }
public bool HasValidSetup() //public async Task<bool> HasValidSetup() { bool hasValidSetup = false; App_Settings appSettings = null; lock (_locker) { appSettings = GetApplicationSettings(); } //get version string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); string dbVersion = (appSettings.DbVersion != null) ? appSettings.DbVersion : "0.0.0.0"; if (version.Substring(0, 3) != dbVersion.Substring(0, 3)) { return(false); } if (HasDataConnection()) { try { switch (_dataConnectionType) { case ConnectionType.Rest: hasValidSetup = IsValidRestServiceConnection(appSettings.IsUsingHttps, appSettings.RestServiceUrl); //await IsValidRestServiceConnection(appSettings.IsUsingHttps, appSettings.RestServiceUrl); break; case ConnectionType.SData: hasValidSetup = IsValidSDataConnection( appSettings.IsUsingHttps, appSettings.SDataUrl, appSettings.SDataUserId, appSettings.SDataPassword ); break; default: break; } } catch (Exception ex) { hasValidSetup = false; System.Diagnostics.Debug.WriteLine("Exception caught in HasValidSetup() method."); System.Diagnostics.Debug.WriteLine(ex.Message); // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.TechDashboardDB_AppSettings.HasValidSetup"); } } else { // it'll either have old data or it won't. hasValidSetup = true; } // validate device return(hasValidSetup); }
public SchedulePage() { // Create the view model for this page _vm = new SchedulePageViewModel(); this.BindingContext = _vm.ScheduleDetails; BackgroundColor = Color.White; // Create our screen objects // Create a label for the technician list _labelTitle = new Xamarin.Forms.Label(); _labelTitle.Text = "SCHEDULE"; _labelTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null); _labelTitle.FontSize = 22; _labelTitle.TextColor = Color.White; _labelTitle.HorizontalTextAlignment = TextAlignment.Center; _labelTitle.VerticalTextAlignment = TextAlignment.Center; Grid titleLayout = new Grid() { BackgroundColor = Color.FromHex("#2980b9"), HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 80 }; titleLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); titleLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); titleLayout.Children.Add(_labelTitle, 0, 0); StackLayout stackDateFilter = new StackLayout(); stackDateFilter.Padding = 30; stackDateFilter.Spacing = 10; filterStartDate = new DatePicker(); filterEndDate = new DatePicker(); Button buttonFilter = new Button() { FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = Color.White, Text = "FILTER TICKETS BY DATE", BackgroundColor = Color.FromHex("#2ECC71") }; buttonFilter.Clicked += ButtonFilter_Clicked; App_Settings appSettings = App.Database.GetApplicationSettings(); filterStartDate.Date = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysBefore) * (-1))).Date; filterEndDate.Date = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysAfter))).Date; stackDateFilter.Children.Add(filterStartDate); stackDateFilter.Children.Add(filterEndDate); stackDateFilter.Children.Add(buttonFilter); // Create a template to display each technician in the list var dataTemplateItem = new DataTemplate(typeof(ScheduledAppointmentDataCell)); // Create the actual list _listViewScheduledAppointments = new ListView() { HasUnevenRows = true, BindingContext = _vm.ScheduleDetails, ItemsSource = _vm.ScheduleDetails, ItemTemplate = dataTemplateItem, SeparatorVisibility = SeparatorVisibility.None }; _listViewScheduledAppointments.ItemTapped += ListViewScheduledAppointments_ItemTapped; Content = new StackLayout { BackgroundColor = Color.FromHex("#2980b9"), Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { titleLayout, stackDateFilter, _listViewScheduledAppointments } }; }
public bool SaveData(AppSettingDL objList) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); int Result = 0; string emSerialNo = (objList.EmpSerialForDocNotify == null ? 0 : objList.EmpSerialForDocNotify).ToString(); App_Settings ObjForUpdate = (from objLinq in objPharmaEntities.App_Settings where objLinq.Company_Id == objList.Company_Id && objLinq.Branch_Id == objList.Branch_Id select objLinq).FirstOrDefault(); if (ObjForUpdate != null) { //bool resultupdate = objPharmaEntities.ChangeTracker.HasChanges(); //if (resultupdate) //{ ObjForUpdate.EmpSerialForDocNotify = Convert.ToDecimal(emSerialNo); ObjForUpdate.CalcWithGrade = objList.CalcWithGrade; ObjForUpdate.UseTimeInWorkFlowRequest = objList.UseTimeInWorkFlowRequest; ObjForUpdate.PerioddayToForwordRequest = objList.PerioddayToForwordRequest; ObjForUpdate.PeriodDayToNotifyFinishContract = objList.PeriodDayToNotifyFinishContract; ObjForUpdate.PayrollDay = objList.PayrollDay; ObjForUpdate.AllowedPeriodForStopRequestEffect = objList.AllowedPeriodForStopRequestEffect; ObjForUpdate.WorkingHoursPerDay = objList.WorkingHoursPerDay; ObjForUpdate.ApplyPermissionDiscount = objList.ApplyPermissionDiscount; ObjForUpdate.VacAllownaceBOrA = "1"; ObjForUpdate.chkVacAfterMonth = objList.chkVacAfterMonth; ObjForUpdate.chkPaidByLastSal = objList.chkPaidByLastSal; ObjForUpdate.chkAbilityTransferVac = objList.chkAbilityTransferVac; ObjForUpdate.chkAbilityTrncferToNext = objList.chkAbilityTrncferToNext; ObjForUpdate.MaxTrnsferPeriod = objList.MaxTrnsferPeriod; ObjForUpdate.VacTransferAllownceSalaryItem = objList.VacTransferAllownceSalaryItem; ObjForUpdate.VacAllownceSalaryItem = objList.VacAllownceSalaryItem; ObjForUpdate.AbsenceSalaryItem = objList.AbsenceSalaryItem; ObjForUpdate.DelySalaryItem = objList.DelySalaryItem; ObjForUpdate.ExtraSalaryItem = objList.ExtraSalaryItem; ObjForUpdate.VacTicketHireItem_Id = objList.VacTicketHireItem_Id; ObjForUpdate.AbsenceCalcWayByDay = objList.AbsenceCalcWayByDay; ObjForUpdate.SalPrevDuesDHireItem_Id = objList.SalPrevDuesDHireItem_Id; ObjForUpdate.IntegratedWithGL = objList.IntegratedWithGL; ObjForUpdate.CalcSalDayRateWay = objList.CalcSalDayRateWay; ObjForUpdate.SalDayRate = objList.SalDayRate; ObjForUpdate.SalCalcWay = objList.SalCalcWay; //ObjForUpdate.CustomerCompany_Code = objList.CustomerCompany_Code; ObjForUpdate.MaxallowedTransferdays = objList.MaxallowedTransferdays; ObjForUpdate.FlightRservationManEmail = objList.FlightRservationManEmail; //ObjForUpdate.PeriodDayToNotifyFinishTesting = objList.PeriodDayToNotifyFinishTesting; Result = objPharmaEntities.SaveChanges(); Result = 1; return(Result > 0); //} //else //{ // return true; //} } else { App_Settings loclDtls = new App_Settings { Branch_Id = objList.Branch_Id, Company_Id = objList.Company_Id, EmpSerialForDocNotify = Convert.ToDecimal(emSerialNo), CalcWithGrade = objList.CalcWithGrade, UseTimeInWorkFlowRequest = objList.UseTimeInWorkFlowRequest, PerioddayToForwordRequest = objList.PerioddayToForwordRequest, WorkingHoursPerDay = objList.WorkingHoursPerDay, PeriodDayToNotifyFinishContract = objList.PeriodDayToNotifyFinishContract, PayrollDay = objList.PayrollDay, AllowedPeriodForStopRequestEffect = objList.AllowedPeriodForStopRequestEffect, ApplyPermissionDiscount = objList.ApplyPermissionDiscount, VacAllownaceBOrA = objList.VacAllownaceBOrA, chkVacAfterMonth = objList.chkVacAfterMonth, chkPaidByLastSal = objList.chkPaidByLastSal, chkAbilityTransferVac = objList.chkAbilityTransferVac, chkAbilityTrncferToNext = objList.chkAbilityTrncferToNext, MaxTrnsferPeriod = objList.MaxTrnsferPeriod, VacTransferAllownceSalaryItem = objList.VacTransferAllownceSalaryItem, VacAllownceSalaryItem = objList.VacAllownceSalaryItem, AbsenceSalaryItem = objList.AbsenceSalaryItem, DelySalaryItem = objList.DelySalaryItem, ExtraSalaryItem = objList.ExtraSalaryItem, VacTicketHireItem_Id = objList.VacTicketHireItem_Id, AbsenceCalcWayByDay = objList.AbsenceCalcWayByDay, SalPrevDuesDHireItem_Id = objList.SalPrevDuesDHireItem_Id, IntegratedWithGL = objList.IntegratedWithGL, CalcSalDayRateWay = objList.CalcSalDayRateWay, SalDayRate = objList.SalDayRate, SalCalcWay = objList.SalCalcWay, //CustomerCompany_Code = objList.CustomerCompany_Code, MaxallowedTransferdays = objList.MaxallowedTransferdays, FlightRservationManEmail = objList.FlightRservationManEmail, //PeriodDayToNotifyFinishTesting = objList.PeriodDayToNotifyFinishTesting }; objPharmaEntities.App_Settings.Add(loclDtls); //saves all above operations within one transaction Result = objPharmaEntities.SaveChanges(); return(Result > 0); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); ex.InnerException.Message.ToString(); return(false); } finally { CloseEntityConnection(); } }
private string FormatTime(string sTimeIn, ref bool bValidTime) { // Validate and Format the Time string sTimeOut = sTimeIn; bValidTime = false; try { App_Settings appSettings = App.Database.GetApplicationSettings(); // dch rkl 11/22/2016 handle all versions of time entered sTimeIn = sTimeIn.ToUpper(); // dch rkl 01/12/2017 handle additional time formats BEGIN string sAMPM = ""; int iHorM; if (sTimeIn.IndexOf("AM") > -1) { sAMPM = "AM"; sTimeIn = sTimeIn.Replace("AM", ""); } else if (sTimeIn.IndexOf("PM") > -1) { sAMPM = "PM"; sTimeIn = sTimeIn.Replace("PM", ""); } else if (sTimeIn.IndexOf("A") > -1) { sAMPM = "AM"; sTimeIn = sTimeIn.Replace("A", ""); } else if (sTimeIn.IndexOf("P") > -1) { sAMPM = "PM"; sTimeIn = sTimeIn.Replace("P", ""); } if (sTimeIn.Length == 1) { int.TryParse(sTimeIn, out iHorM); if (appSettings.TwentyFourHourTime && sAMPM == "PM") { iHorM += 12; sTimeIn = string.Format("{0}:00", iHorM); } else { sTimeIn = string.Format("0{0}:00", sTimeIn); } } else if (sTimeIn.Length == 2) { int.TryParse(sTimeIn, out iHorM); if (iHorM > 12) { if (appSettings.TwentyFourHourTime) { sTimeIn = string.Format("{0}:00", sTimeIn); sAMPM = ""; } else { sTimeIn = string.Format("{0}:00", iHorM - 12); sAMPM = "PM"; } } else { sTimeIn = string.Format("{0}:00", sTimeIn); } } else if (sTimeIn.Length == 3) { sTimeIn = string.Format("0{0}:{1}", sTimeIn.Substring(0, 1), sTimeIn.Substring(1, 2)); } else if (sTimeIn.Length == 4) { sTimeIn = string.Format("{0}:{1}", sTimeIn.Substring(0, 2), sTimeIn.Substring(2, 2)); } if (sAMPM.Length > 0) { sTimeIn = sTimeIn + " " + sAMPM; } //if (sTimeIn.IndexOf("A") > -1 && sTimeIn.IndexOf("AM") == -1) { sTimeIn = sTimeIn.Replace("A", "AM"); } //if (sTimeIn.IndexOf("P") > -1 && sTimeIn.IndexOf("PM") == -1) { sTimeIn = sTimeIn.Replace("P", "PM"); } //if (sTimeIn.Length == 1) { sTimeIn = string.Format("0{0}:00", sTimeIn); } //else if (sTimeIn.Length == 2) { sTimeIn = string.Format("{0}:00", sTimeIn); } // dch rkl 01/12/2017 handle additional time formats END string myDateString = DateTime.Now.Date.ToString("MM/dd/yyyy") + " " + sTimeIn; DateTime dtDate = DateTime.Parse(myDateString); // dch rkl 01/12/2017 handle additional time formats BEGIN if (appSettings.TwentyFourHourTime) { sTimeOut = dtDate.ToString("HH:mm tt"); } else { sTimeOut = dtDate.ToString("hh:mm tt"); } //sTimeOut = dtDate.ToString("hh:mm tt"); // dch rkl 01/12/2017 handle additional time formats END bValidTime = true; } catch (Exception ex) { bValidTime = false; } return(sTimeOut); }
protected async override void OnStart() { // Handle when your app starts bool hasValidSetup = false; App_Settings appSettings = App.Database.GetApplicationSettings(); string loggiedintechnicianno; JT_Technician technician = null; bool tableExists = false; try { hasValidSetup = await Database.HasValidSetup(appSettings); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); await MainPage.DisplayAlert("Error!", ex.Message, "OK"); throw; } tableExists = App.Database.TableExists <JT_Technician>(); // Are the settings valid? if (hasValidSetup) { // Yes, so move on to the technician login //App_Settings appSettings = App.Database.GetApplicatioinSettings(); loggiedintechnicianno = (appSettings.LoggedInTechnicianNo != null) ? appSettings.LoggedInTechnicianNo : ""; if (tableExists && loggiedintechnicianno.Length > 0) // we've already established we do && Database.HasDataConnection()) { technician = App.Database.GetTechnician(appSettings.LoggedInTechnicianDeptNo, appSettings.LoggedInTechnicianNo); if (technician != null) { App.Database.SaveTechnicianAsCurrent(technician); App.Database.CreateDependentTables(technician); MainPage = new MainDashboard(); } else { if (Database.HasDataConnection()) { Database.CreateGlobalTables(); } Thread.Sleep(5000); TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel(); viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged; MainPage = new TechnicianListPage(viewModel); } } else { if (Database.HasDataConnection()) { Database.CreateGlobalTables(); } Thread.Sleep(5000); TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel(); viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged; MainPage = new TechnicianListPage(viewModel); } } else { // Invalid settings, so show the settings page. // Otherwise, data calls will never work. AppSettingsPage settingsPage = new AppSettingsPage(); settingsPage.SettingsSaved += AppSettingsPage_SettingsSaved; MainPage = settingsPage; return; } }
public AppSettingDL GetDataByBranchandCompany(string strCompany_Id, string strBranch_Id) { StackFrame stackFrame = new StackFrame(); MethodBase methodBase = stackFrame.GetMethod(); try { OpenEntityConnection(); App_Settings ObjlistAppSetting = (from objLinq in objPharmaEntities.App_Settings where objLinq.Company_Id == strCompany_Id && objLinq.Branch_Id == strBranch_Id select objLinq).FirstOrDefault(); if (ObjlistAppSetting != null) { AppSettingDL objAppSettingDL = new AppSettingDL(); { objAppSettingDL.Branch_Id = ObjlistAppSetting.Branch_Id; objAppSettingDL.Company_Id = ObjlistAppSetting.Company_Id; objAppSettingDL.EmpSerialForDocNotify = ObjlistAppSetting.EmpSerialForDocNotify; objAppSettingDL.CalcWithGrade = ObjlistAppSetting.CalcWithGrade; objAppSettingDL.UseTimeInWorkFlowRequest = ObjlistAppSetting.UseTimeInWorkFlowRequest; objAppSettingDL.PerioddayToForwordRequest = ObjlistAppSetting.PerioddayToForwordRequest; objAppSettingDL.PeriodDayToNotifyFinishContract = ObjlistAppSetting.PeriodDayToNotifyFinishContract; objAppSettingDL.PayrollDay = ObjlistAppSetting.PayrollDay; objAppSettingDL.AllowedPeriodForStopRequestEffect = ObjlistAppSetting.AllowedPeriodForStopRequestEffect; objAppSettingDL.WorkingHoursPerDay = ObjlistAppSetting.WorkingHoursPerDay; objAppSettingDL.ApplyPermissionDiscount = ObjlistAppSetting.ApplyPermissionDiscount; objAppSettingDL.VacAllownaceBOrA = "1"; objAppSettingDL.chkVacAfterMonth = ObjlistAppSetting.chkVacAfterMonth; objAppSettingDL.chkPaidByLastSal = ObjlistAppSetting.chkPaidByLastSal; objAppSettingDL.chkAbilityTransferVac = ObjlistAppSetting.chkAbilityTransferVac; objAppSettingDL.chkAbilityTrncferToNext = ObjlistAppSetting.chkAbilityTrncferToNext; objAppSettingDL.MaxTrnsferPeriod = ObjlistAppSetting.MaxTrnsferPeriod; objAppSettingDL.VacTransferAllownceSalaryItem = ObjlistAppSetting.VacTransferAllownceSalaryItem; objAppSettingDL.VacAllownceSalaryItem = ObjlistAppSetting.VacAllownceSalaryItem; objAppSettingDL.AbsenceSalaryItem = ObjlistAppSetting.AbsenceSalaryItem; objAppSettingDL.DelySalaryItem = ObjlistAppSetting.DelySalaryItem; objAppSettingDL.ExtraSalaryItem = ObjlistAppSetting.ExtraSalaryItem; objAppSettingDL.VacTicketHireItem_Id = ObjlistAppSetting.VacTicketHireItem_Id; objAppSettingDL.AbsenceCalcWayByDay = ObjlistAppSetting.AbsenceCalcWayByDay; objAppSettingDL.SalPrevDuesDHireItem_Id = ObjlistAppSetting.SalPrevDuesDHireItem_Id; objAppSettingDL.IntegratedWithGL = ObjlistAppSetting.IntegratedWithGL; objAppSettingDL.CalcSalDayRateWay = ObjlistAppSetting.CalcSalDayRateWay; objAppSettingDL.SalDayRate = ObjlistAppSetting.SalDayRate; objAppSettingDL.SalCalcWay = ObjlistAppSetting.SalCalcWay; //objAppSettingDL.CustomerCompany_Code = ObjlistAppSetting.CustomerCompany_Code; objAppSettingDL.MaxallowedTransferdays = ObjlistAppSetting.MaxallowedTransferdays; objAppSettingDL.FlightRservationManEmail = ObjlistAppSetting.FlightRservationManEmail; //objAppSettingDL.PeriodDayToNotifyFinishTesting = ObjlistAppSetting.PeriodDayToNotifyFinishTesting; } return(objAppSettingDL); } else { return(null); } } catch (Exception ex) { catchEntityvalidation((System.Data.Entity.Validation.DbEntityValidationException)ex, System.Runtime.InteropServices.Marshal.GetExceptionCode().ToString(), this.UserNameProperty.ToString(), this.GetType().Name.ToString(), methodBase.Name.ToString()); ex.InnerException.Message.ToString(); return(null); } finally { CloseEntityConnection(); } }
public MainWindow() { InitializeComponent(); btnSettings.Click += BtnSettings_Click; btnExpenses.Click += BtnExpenses_Click; btnSchedule.Click += BtnSchedule_Click; btnHistory.Click += BtnHistory_Click; btnMiscTime.Click += BtnMiscTime_Click; btnSync.Click += BtnSync_Click; btnTechnician.Click += BtnTechnician_Click; //btnSMS.Click += BtnSMS_Click; btnExit.Click += BtnExit_Click; App_Settings appSettings = App.Database.GetApplicationSettings(); // dch rkl 12/08/2016 Get Application Version and Compare to Current DB Version // If the versions do not match, they need to do a sync and refresh of their data System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string Buildversion = fvi.FileVersion; string dbVersion = appSettings.DbVersion.Substring(0, 5); // dch rkl 02/03/2017 Need more positions for version if (Buildversion != dbVersion) { bool bHasDataConnection = App.Database.HasDataConnection(); if (bHasDataConnection == false) { string sMsg = string.Format("WARNING: Your local database version is {0}, and your \napplication version is {1}. An internet connection is required \nto refresh your database schema, and is not currently present. Please log into the application when an internet connection \nis available so the sync and upgrade can be completed.", dbVersion, Buildversion); var result = MessageBox.Show(sMsg, "Database Update Required", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); Application.Current.Shutdown(); return; } else { string sMsg = string.Format("WARNING: Your local database version is {0}, and your \napplication version is {1}. A database Sync is required at this time. \nClick OK to continue with the upgrade, or Cancel to exit.\n \nIf OK is selected, any pending transactions will be sent to JobOps prior to sync.", dbVersion, Buildversion); var result = MessageBox.Show(sMsg, "Database Update Required", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); if (result == MessageBoxResult.Cancel) { Application.Current.Shutdown(); return; } else { // Send any JT_TransactionImportDetail records back to JobOps TransactionSync(); // Update local Data App.Database.CreateGlobalTables(); appSettings.DbVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); App.Database.SaveAppSettings(appSettings); } } } if (appSettings.LoggedInTechnicianNo != null) { if (appSettings.LoggedInTechnicianNo.Length > 0 && appSettings.LoggedInTechnicianDeptNo.Length > 0) { JT_Technician technician = App.Database.GetTechnician(appSettings.LoggedInTechnicianDeptNo, appSettings.LoggedInTechnicianNo); App.Database.SaveTechnicianAsCurrent(technician); if (App.Database.HasDataConnection()) { App.Database.CreateDependentTables(technician); } contentArea.Content = new SchedulePage(); } else { contentArea.Content = new TechnicianListPage(); } } else { contentArea.Content = new TechnicianListPage(); } contentArea.IsTabStop = false; // dch rkl 01/16/2017 Make sure the main window isn't a tab stop, and doesn't get selected. AddHandler(TechnicianListPage.SignedInEvent, new RoutedEventHandler(SignedInEventHandlerMethod)); AddHandler(SchedulePage.SelectedTicketEvent, new RoutedEventHandler(SelectedTicketEventHandlerMethod)); this.Closed += MainWindow_Closed; if (App.Database.GetCurrentTechnicianFromDb() == null) { btnTechnician.Visibility = Visibility.Collapsed; btnSchedule.Visibility = Visibility.Collapsed; btnHistory.Visibility = Visibility.Collapsed; btnMiscTime.Visibility = Visibility.Collapsed; btnExpenses.Visibility = Visibility.Collapsed; //btnSMS.Visibility = Visibility.Collapsed; btnSync.Visibility = Visibility.Collapsed; } }