Exemplo n.º 1
0
        public async static Task <bool> SendGetAllShiftsRequest(string employeeid)
        {
            GetAllShiftsRequest getAllShiftsRequest = new GetAllShiftsRequest(employeeid);
            var response = await ServiceRequestHandler.MakeServiceCall <ShiftList>(getAllShiftsRequest);

            if (response != null)
            {
                RealmManager.RemoveAll <ShiftList>();

                ShiftList parsedList = new ShiftList();

                for (int i = 0; i < response.shifts.Count; i++)
                {
                    Shift interShift = response.shifts.ElementAt(i);
                    interShift.clock_in = interShift.clock_in.Substring(11, 8) + " " + interShift.clock_in.Substring(5, 2) + "/" + interShift.clock_in.Substring(8, 2) + "/" + interShift.clock_in.Substring(0, 4);
                    if (!String.IsNullOrEmpty(interShift.clock_out))
                    {
                        interShift.clock_out = interShift.clock_out.Substring(11, 8) + " " + interShift.clock_out.Substring(5, 2) + "/" + interShift.clock_out.Substring(8, 2) + "/" + interShift.clock_out.Substring(0, 4);;
                    }
                    parsedList.shifts.Add(interShift);
                }

                RealmManager.AddOrUpdate <ShiftList>(parsedList);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// GetCurrentShift
        /// </summary>
        /// <param name="correctedDate"></param>
        /// <returns></returns>
        public List <ShiftList> ShiftList(string correctedDate)
        {
            List <ShiftList> shiftLists = new List <ShiftList>();

            try
            {
                var shiftDetails = db.UnitworkccsTblshiftMstr.ToList();
                int i            = 1;
                foreach (var item in shiftDetails)
                {
                    ShiftList shiftList = new ShiftList();
                    shiftList.shfitId   = item.ShiftId;
                    shiftList.shiftName = item.ShiftName;

                    switch (i)
                    {
                    case 1:
                        string datee  = DateTime.Now.Date.ToShortDateString();
                        string date1  = correctedDate + " " + item.StartTime;
                        string dateee = Convert.ToDateTime(correctedDate).ToShortDateString();
                        string date2  = dateee + " " + item.EndTime;
                        shiftList.shiftStartDateTime = Convert.ToDateTime(date1);
                        shiftList.shiftEndDateTime   = Convert.ToDateTime(date2);
                        break;

                    case 2:
                        string datee1  = DateTime.Now.Date.ToShortDateString();
                        string date11  = correctedDate + " " + item.StartTime;
                        string dateee1 = Convert.ToDateTime(correctedDate).ToShortDateString();
                        string date21  = dateee1 + " " + item.EndTime;
                        shiftList.shiftStartDateTime = Convert.ToDateTime(date11);
                        shiftList.shiftEndDateTime   = Convert.ToDateTime(date21);
                        break;

                    case 3:
                        string datee2  = DateTime.Now.Date.ToShortDateString();
                        string date12  = correctedDate + " " + item.StartTime;
                        string dateee2 = Convert.ToDateTime(correctedDate).Date.AddDays(1).ToShortDateString();
                        string date22  = dateee2 + " " + item.EndTime;
                        shiftList.shiftStartDateTime = Convert.ToDateTime(date12);
                        shiftList.shiftEndDateTime   = Convert.ToDateTime(date22);
                        break;

                    default: break;
                    }

                    shiftLists.Add(shiftList);
                    i++;
                }
            }
            catch (Exception ex)
            {
            }

            return(shiftLists);
        }
Exemplo n.º 3
0
        private void SaveShift()
        {
            SqlTransaction Tran;

            if (MessageBox.Show(string.Format(SaveConfirmText, "Shift"), MessageBoxCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }
            try
            {
                using (SqlConnection Conn = new SqlConnection(GlobalClass.TConnectionString))
                {
                    Conn.Open();
                    Tran = Conn.BeginTransaction();

                    try
                    {
                        shift.SHIFT_ID = Conn.ExecuteScalar <byte>("SELECT CAST(ISNULL(MAX(SHIFT_ID), 0) + 1 AS SMALLINT) FROM tblShift", transaction: Tran);
                        if (shift.Save(Tran))
                        {
                            GlobalClass.SetUserActivityLog(Tran, "Attendant Shift", "New", WorkDetail: "SHIFT_ID : " + shift.SHIFT_ID, Remarks: shift.SHIFT_NAME);
                            Tran.Commit();
                            MessageBox.Show("Shift Saved Successfully.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                            ShiftList.Add(new Shift {
                                SHIFT_ID = shift.SHIFT_ID, SHIFT_NAME = shift.SHIFT_NAME, SHIFT_START = shift.SHIFT_START, UID = GlobalClass.User.UID, SHIFT_STATUS = shift.SHIFT_STATUS, SHIFT_END = shift.SHIFT_END
                            });
                            ExecuteUndo(null);
                        }
                        else
                        {
                            MessageBox.Show("shift Type could not be Saved.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                            Tran.Rollback();
                        }
                    }
                    catch (SqlException ex)
                    {
                        if (Tran.Connection != null)
                        {
                            Tran.Rollback();
                        }
                        if (ex.Number == 2601)
                        {
                            MessageBox.Show("Entered shift name already exist in the database. Enter unique name and try again", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Hand);
                        }
                        MessageBox.Show(ex.Number + " : " + ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 4
0
        private void CreateEntities()
        {
            if (_filePaths != null && _filePaths.Count > 0)
            {
                List <string> traceNames         = new List <string>();
                List <string> testProcedureNames = new List <string>();
                List <string> shiftTableNames    = new List <string>();
                List <string> shiftListNames     = new List <string>();

                foreach (string filePath in _filePaths)
                {
                    Trace         newTrace         = new Trace();
                    TestProcedure newTestProcedure = new TestProcedure();
                    ShiftTable    newShiftTable    = new ShiftTable();;
                    ShiftList     newShiftList     = new ShiftList();

                    string             baseName     = GetNameFromPath(filePath);
                    FileContents       fileContents = GetFileContents(filePath);
                    List <TraceColumn> columnData   = new List <TraceColumn>();

                    string predictedTraceName         = ExtendedEntityManager.PredictEntityName <Trace>(baseName + " Trace", traceNames);
                    string predictedTestProcedureName = ExtendedEntityManager.PredictEntityName <TestProcedure>(baseName + " Test Procedure", testProcedureNames);
                    string predictedShiftTableName    = ExtendedEntityManager.PredictEntityName <ShiftTable>(baseName + " Shift Table", shiftTableNames);
                    string predictedShiftListName     = ExtendedEntityManager.PredictEntityName <ShiftList>(baseName + " Shift List", shiftListNames);

                    traceNames.Add(predictedTraceName);
                    testProcedureNames.Add(predictedTestProcedureName);
                    shiftTableNames.Add(predictedShiftTableName);
                    shiftListNames.Add(predictedShiftListName);

                    SetTraceData(ref newTrace, ref columnData, fileContents, predictedTraceName);
                    SetTestProcedureData(ref newTestProcedure, predictedTestProcedureName, predictedTraceName);
                    SetShiftTableData(ref newShiftTable, columnData, fileContents, predictedShiftTableName, predictedTraceName);
                    SetShiftListData(ref newShiftList, predictedShiftListName, predictedTestProcedureName, predictedShiftTableName);

                    MEF.EntityManagerView.Traces.Value.Create(ExtendedEntityManager.GetEntityURI <Trace>(), newTrace.Properties);
                    MEF.EntityManagerView.TestProcedures.Value.Create(ExtendedEntityManager.GetEntityURI <TestProcedure>(), newTestProcedure.Properties);
                    MEF.EntityManagerView.ShiftTables.Value.Create(ExtendedEntityManager.GetEntityURI <ShiftTable>(), newShiftTable.Properties);
                    MEF.EntityManagerView.ShiftLists.Value.Create(ExtendedEntityManager.GetEntityURI <ShiftList>(), newShiftList.Properties);

                    ShowDialog(predictedTraceName, predictedTestProcedureName, predictedShiftTableName, predictedShiftListName);

                    //if (filePath == _filePaths.Last())
                    //{
                    //    Thread newThread = new Thread(x => ShowImportedTrace(predictedTraceName)) { IsBackground = true };
                    //    newThread.Start();
                    //}
                }
            }
        }
Exemplo n.º 5
0
        // add new shift work
        public JsonResult adshift(DateTime shiftdate, string cbyn)
        {
            ShiftList shft     = new ShiftList();
            var       isactive = db.ShiftLists.Where(x => x.IsActive == true).ToList();

            isactive.ForEach(x => x.IsActive = false);
            db.SaveChanges();

            shft.ShftDate = shiftdate;
            shft.IsActive = true;

            db.ShiftLists.Add(shft);
            db.SaveChanges();
            return(Json(new { Success = true, Message = "تمت الإضافة  شفت بنجاح" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
 private void UpdateShift()
 {
     if (MessageBox.Show(string.Format(UpdateConfirmText, "Shift"), MessageBoxCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
     {
         return;
     }
     try
     {
         using (SqlConnection Conn = new SqlConnection(GlobalClass.TConnectionString))
         {
             Conn.Open();
             using (SqlTransaction tran = Conn.BeginTransaction())
             {
                 string Remarks = Newtonsoft.Json.JsonConvert.SerializeObject(Conn.Query <Shift>("SELECT * FROM tblShift WHERE SHIFT_ID = @SHIFT_ID", shift, tran).First());
                 if (shift.Update(tran))
                 {
                     GlobalClass.SetUserActivityLog(tran, "Attendant Shift", "Edit", WorkDetail: "SHIFT_ID : " + shift.SHIFT_ID, Remarks: Remarks);
                     tran.Commit();
                     MessageBox.Show("Shift Updated Successfully.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                     var vehicle = ShiftList.First(x => x.SHIFT_ID == shift.SHIFT_ID);
                     vehicle.SHIFT_NAME   = shift.SHIFT_NAME;
                     vehicle.SHIFT_START  = shift.SHIFT_START;
                     vehicle.SHIFT_END    = shift.SHIFT_END;
                     vehicle.SHIFT_STATUS = shift.SHIFT_STATUS;
                     vehicle.UID          = GlobalClass.User.UID;
                     ExecuteUndo(null);
                 }
                 else
                 {
                     MessageBox.Show("shift Type could not be updated.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                     tran.Rollback();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         if (ex is SqlException && (ex as SqlException).Number == 2601)
         {
             MessageBox.Show("Entered shift name already exist in the database. Enter unique name and try again", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Hand);
         }
         MessageBox.Show(GlobalClass.GetRootException(ex).Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 7
0
 private void ExecuteDelete(object obj)
 {
     if (MessageBox.Show(string.Format(DeleteConfirmText, "Shift"), MessageBoxCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
     {
         return;
     }
     try
     {
         using (SqlConnection Conn = new SqlConnection(GlobalClass.TConnectionString))
         {
             Conn.Open();
             using (SqlTransaction tran = Conn.BeginTransaction())
             {
                 string Remarks = Newtonsoft.Json.JsonConvert.SerializeObject(Conn.Query <Shift>("SELECT * FROM tblShift WHERE SHIFT_ID = @SHIFT_ID", shift, tran).First());
                 if (shift.Delete(tran))
                 {
                     GlobalClass.SetUserActivityLog(tran, "Attendant Shift", "Delete", WorkDetail: "SHIFT_ID : " + shift.SHIFT_ID, Remarks: Remarks);
                     tran.Commit();
                     MessageBox.Show("Shift deleted successfully.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                     ShiftList.Remove(ShiftList.First(x => x.SHIFT_ID == shift.SHIFT_ID));
                     ExecuteUndo(null);
                 }
                 else
                 {
                     MessageBox.Show("Shift Type could not be Deleted.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                     tran.Rollback();
                 }
             }
         }
     }
     catch (SqlException ex)
     {
         if (ex.Number == 547)
         {
             MessageBox.Show("Selected shift cannot be deleted because it has already been linked to another transaction.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Hand);
         }
         MessageBox.Show(ex.Number + " : " + ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 8
0
        public async Task <bool> RefreshShifts()
        {
            List <Shift> backup = ShiftList;

            for (int i = 0; i < 3; i++)
            {
                ShiftList = await Utility.LoadShifts(Utility.APIURL + "shifts", MainAuth);

                ShiftList = ShiftList.OrderBy(x => x.Start).ToList();
                if (ShiftList != null)
                {
                    return(true);
                }
            }
            ShiftList = backup;
            await Utility.ShowDialog("API Connection Error", "There was an error retrieving shifts. Information displayed might be outdated!");

            return(false);
        }
Exemplo n.º 9
0
 private void ExecuteLoad(object obj)
 {
     if (obj != null)
     {
         byte id = Convert.ToByte(obj);
         if (!ShiftList.Any(x => x.SHIFT_ID == id))
         {
             MessageBox.Show("Invalid Id.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
             return;
         }
         SelectedShift = ShiftList.FirstOrDefault(x => x.SHIFT_ID == id);
     }
     shift = new Shift
     {
         SHIFT_ID     = SelectedShift.SHIFT_ID,
         SHIFT_NAME   = SelectedShift.SHIFT_NAME,
         SHIFT_START  = SelectedShift.SHIFT_START,
         UID          = SelectedShift.UID,
         SHIFT_END    = SelectedShift.SHIFT_END,
         SHIFT_STATUS = SelectedShift.SHIFT_STATUS
     };
     SetAction(ButtonAction.Selected);
 }
Exemplo n.º 10
0
 private void SetShiftListData(ref ShiftList newShiftList, string name, string testProcedureName, string shiftTableName)
 {
     newShiftList.TestProcedureName = testProcedureName;
     newShiftList.ShiftTableNames   = new string[] { shiftTableName };
     newShiftList.Name = name;
 }
Exemplo n.º 11
0
        public void LoadShiftDetails(ShiftTable shift)
        {
            Pages = new ObservableCollection <CarouselViewModel>();

            Drives = new List <DriveTable>();
            Notes  = new List <NoteTable>();
            Breaks = new List <BreakTable>();

            Drives = db.GetDriveShifts(shift.Key);
            Notes  = db.GetNotes(shift.Key);
            Breaks = db.GetBreaks(shift);

            if (Drives.Count != 0 || Breaks.Count != 0 || Notes.Count != 0)
            {
                ExtraDetails = true;
            }
            else
            {
                ExtraDetails = false;
            }

            if (Drives.Count != 0)
            {
                Pages.Add(new CarouselViewModel {
                    Title = "Drives", Page = "DriveView", ImageSource = "icon.png", Drives = Drives
                });
            }

            if (Notes.Count != 0)
            {
                Pages.Add(new CarouselViewModel {
                    Title = "Notes", Page = "NoteView", ImageSource = "icon.png", Notes = Notes
                });
            }

            if (Breaks.Count != 0)
            {
                Pages.Add(new CarouselViewModel {
                    Title = "Breaks", Page = "BreakView", ImageSource = "icon.png", Breaks = Breaks
                });
            }

            CurrentPage = Pages.FirstOrDefault();

            if (shift.EndDate != string.Empty)
            {
                ShiftDate = DateTime.Parse(shift.StartDate).ToString("g") + " - " + DateTime.Parse(shift.EndDate).ToString("g");
            }
            else
            {
                ShiftDate = DateTime.Parse(shift.StartDate).ToString("g") + " - Current";
            }

            if (shift.StartLocation != null)
            {
                string startLocation = shift.StartLocation.Split(',')[1];

                if (shift.EndLocation != null)
                {
                    string endLocation = shift.EndLocation.Split(',')[1];

                    ShiftLocation = startLocation.Trim() + " - " + endLocation.Trim();
                }
                else
                {
                    ShiftLocation = startLocation.Trim() + " -";
                }
            }
            else
            {
                ShiftLocation = "Unknown - Unknown";
            }

            ShiftSelected = true;

            CurrentShiftIndex = ShiftList.IndexOf(shift);

            if (CurrentShiftIndex == 0)
            {
                CanExecuteChangeShift(false, true);
            }
            else if (CurrentShiftIndex == (ShiftList.Count - 1))
            {
                CanExecuteChangeShift(true, false);
            }
            else
            {
                CanExecuteChangeShift(true, true);
            }

            OnPropertyChanged("Drives");
            OnPropertyChanged("Notes");
            OnPropertyChanged("Breaks");
            OnPropertyChanged("ShiftDate");
            OnPropertyChanged("ShiftLocation");
            OnPropertyChanged("ShiftSelected");
            OnPropertyChanged("DrivesAvailable");
            OnPropertyChanged("BreaksAvailable");
            OnPropertyChanged("NotesAvailable");
        }