public void AddEmployee(string Name, string Number, bool Active)
        {
            Employee item = new Employee();

            item.Name = Name;
            item.Number = Number;
            item.Active = Active;

            if (_employees == null)
            {
                _employees = new List<Employee>();
            }
            _employees.Add(item);
            DropboxHelper.GetInstance().CreateEmployeeCsvFileToDropbox(_context, item);
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DatePicker);

            // Assign UI Variables
            //cancelButton = FindViewById<Button>(Resource.Id.cancelButton);
            saveButton = FindViewById<Button>(Resource.Id.saveButton);
            inOutButton = FindViewById<ToggleButton>(Resource.Id.inOutButton);
            inOutButton.Checked = true;
            title = FindViewById<TextView>(Resource.Id.title);
            dateButton = FindViewById<Button>(Resource.Id.dateButton);
            timeButton = FindViewById<Button>(Resource.Id.timeButton);

            // Get current date
            date = DateTime.Today;
            hour = DateTime.Now.Hour;
            minute = DateTime.Now.Minute;

            // Display current date (this method is below)
            UpdateDisplay();

            EmployeeNumber = Intent.GetStringExtra("EmployeeNumber");
            employee = EmployeeManagement.GetInstance().Employees.Where(L => L.Number == EmployeeNumber).FirstOrDefault();

            // Add a click event handler to the buttons
            dateButton.Click += delegate {
                ShowDialog(DATE_DIALOG_ID);
            };

            timeButton.Click += delegate {
                ShowDialog(TIME_DIALOG_ID);
            };

            inOutButton.Click += delegate
            {
                UpdateDisplay();
            };
            /*
            cancelButton.Click += delegate
            {
                Finish();
            };
             */

            saveButton.Click += SaveTime_Click;
        }
Пример #3
0
 public CheckLogs(Employee employee, CheckType CheckType, DateTime temptime)
 {
     if (employee == null) throw new CheckLogsException();
     if (employee.Logs==null)
     {
         employee.Logs = new List<CheckLogs>();
     }
     //Remove Seconds
     //DateTime CheckTime = temptime.AddSeconds(-temptime.Second);
     DateTime CheckTime = temptime;
     this.CheckTime = CheckTime;
     this.CheckType = CheckType;
     _employee = employee;
     var _localtion = GPSHelper.GetInstance().GetLocation();
     x = Convert.ToDouble(_localtion.Latitude.ToString());
     y = Convert.ToDouble(_localtion.Longitude.ToString());
     employee.Logs.Add(this);
 }
Пример #4
0
        public CheckLogs(Employee employee, CheckType CheckType, DateTime temptime, double x, double y)
        {
            if (employee == null) throw new CheckLogsException();
            if (employee.Logs == null)
            {
                employee.Logs = new List<CheckLogs>();
            }

            //Remove Seconds
            //DateTime CheckTime = temptime.AddSeconds(-temptime.Second);
            DateTime CheckTime = temptime;

            this.CheckTime = CheckTime;
            this.CheckType = CheckType;
            employee.Logs.Add(this);
                //.Add(this);

            _employee = employee;
            this.x = x;
            this.y = y;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Get employee
            EmployeeNumber= Intent.GetStringExtra("EmployeeNumber");
            selectedEmployee = EmployeeManagement.GetInstance().Employees.Where(L => L.Number == EmployeeNumber).FirstOrDefault();
            if (selectedEmployee == null) return;

            // Set up Listview
            SetContentView(Resource.Layout.CheckLogMaster);
            LogAdapter = new LogAdapter(this, selectedEmployee);
            listView = FindViewById<ListView>(Resource.Id.checklogs);
            listView.Adapter = LogAdapter;

            var LogName = this.FindViewById<TextView>(Resource.Id.NameForLog);
            LogName.Text = selectedEmployee.Name.ToString();

            var TotalHours = this.FindViewById<TextView>(Resource.Id.TotalHour);
            TotalHours.Text = "Total Hours: " + selectedEmployee.TotalHours;

            //editButton = this.FindViewById<Button>(Resource.Id.EditButton);
            addTimeButton = this.FindViewById<Button>(Resource.Id.AddTimeButton);

            //editButton.Click += EditButton_Click;
            addTimeButton.Click += AddTimeButton_Click;
            listView.SetOnTouchListener(this);

            // Gestures
            gestureDetector = new GestureDetector(this);
            listView.SetOnTouchListener(this);

            var _message = this.FindViewById<TextView>(Resource.Id.message);
            _message.Text = (selectedEmployee.Logs.Count == 0)?"There are no Transactions":"";
        }
 public void ClearChecklogOfEmpolyee(Context ctx, Employee employee)
 {
     var files = ctx.FileList();
     ctx.DeleteFile("Trans-aP" + employee.Number + ".csv");
     string number = settings.GetString("pref_phoneNumber", string.Empty);
     if (!string.IsNullOrEmpty(number))
     {
         try
         {
             _client.Delete("/TimePilot_aPhone/aP" + number + "/Trans-aP" + employee.Number + ".csv");
         }
         catch (DropNet.Exceptions.DropboxException ex)
         {
             throw new System.Exception(ex.Message);
         }
     }
 }
        public List<Employee> importEmployeeToAndroid(Context ctx)
        {
            string marker = "@!#:#@!";

            List<Employee> EmployeeList=new List<Employee>();
            //Dictionary<string, byte[]> _AndroidlFilesContent = new Dictionary<string, byte[]>();
            foreach (var _item in ctx.FileList())
            {
                string item=(string)_item;
                string csv = ".csv";
                string CSV = ".CSV";
                if (item.IndexOf(csv) >= 0 || item.IndexOf(CSV) >= 0)
                {
                    if (item.IndexOf("Trans") == 0)
                    {
                        continue;
                    }

                    var file = ctx.GetFileStreamPath(item);
                    var line = readFile(file.AbsolutePath);
                    if (line.Length == 0)
                    {
                        continue;
                    }

                    string firstLine = line[0];
                    int startIndex = firstLine.IndexOf("\"", 0);
                    int endIndex = 0;
                    if (startIndex > 0)
                    {
                        endIndex = firstLine.IndexOf("\"", startIndex+ 1);
                    }
                    if (startIndex > 0 && endIndex > startIndex)
                    {
                        string oldString = firstLine.Substring(startIndex, endIndex-1);
                        string newString = oldString.Replace(",", marker);
                        firstLine = firstLine.Replace(oldString, newString);
                    }

                    var cells =  firstLine.Split(',');

                    string employeeName;
                    if (cells[1].IndexOf("\"") >= 0)
                    {
                        employeeName = cells[1].Substring(1, cells[1].Length - 2).Replace(marker,",");
                    }
                    else
                        employeeName = cells[1].Replace(marker, ",");
                    if (cells.Length < 26)
                        continue;

                    Employee e = new Employee();
                    e.Name = employeeName;
                    e.Number = cells[2].Replace(marker, ",");
                    EmployeeList.Add(e);
              }
            }
            return EmployeeList;
        }
 public void DeleteEmployeeFromDropBoxandLocalFile(Context ctx, Employee employee)
 {
     var files = ctx.FileList();
     ctx.DeleteFile(employee.Number + ".CSV");
     string number = settings.GetString("pref_phoneNumber", string.Empty);
     if (!string.IsNullOrEmpty(number) && this.IsLogined())
     {
         try
         {
             _client.Delete("/TimePilot_aPhone/aP" + number + "/" + employee.Number + ".CSV");
         }
         catch(DropNet.Exceptions.DropboxException ex)
         {
             throw new System.Exception(ex.Message);
         }
     }
 }
        public void CreateEmployeeCsvFileToDropbox(Context ctx, Employee employee)
        {
            string filename = employee.Number.ToString() + ".CSV";
               List<string> data = new List<string>();
               var _localtion = GPSHelper.GetInstance().GetLocation();
               string GPSx = "";
               string GPSy = "";
               if (_localtion != null)
               {
               GPSx = _localtion.Latitude.ToString();
               GPSy = _localtion.Longitude.ToString();
               }
               var val_0=0;
               if(employee.CurrentType.Equals(CheckType.IN))
               val_0 = 1;

               var val_1 = employee.Name.ToString();
               var val_2 = employee.Number.ToString();
               var val_3 = DateTime.Today.ToString();
               var val_4 = employee.TotalHours.ToString();
               string content = string.Format("{0},\"{1}\",{2},,{3},{4},,,,,,,,,,,,,,,,,,,,{5},{6}", val_0, val_1, val_2, val_3, val_4, GPSx, GPSy);
               data.Add(content);
               SaveAsPrivateFileToDropboxTransFile(ctx, data, filename);
        }