public void syncDropboxCsvFiles(Context ctx, bool IsNeedToDelete) { if (!IsConnected()) { return; } Dictionary<string, DateTime> _AndroidlFilesModifiedDate = new Dictionary<string, DateTime>(); Dictionary<string, byte[]> _AndroidlFilesContent = new Dictionary<string, byte[]>(); var _localFiles = ctx.FileList(); foreach (var _item in _localFiles) { if (_item.IndexOf(".csv") <= 0 && _item.IndexOf(".CSV") <= 0) { continue; } var AndroidfilemodifiedDate = System.IO.File.GetLastWriteTimeUtc(_item); _AndroidlFilesModifiedDate.Add(_item, AndroidfilemodifiedDate); } var _list = new List<MetaData>(); //getMetaData("/", false); // Employee var _DeletedFileslist = new List<MetaData>(); string number = settings.GetString("pref_phoneNumber", string.Empty); if (!string.IsNullOrEmpty(number)) { var _subList = getMetaData("/TimePilot_aPhone/aP" + number, false); if(_subList.ContainsKey(1)) _list.AddRange(_subList[1].ToList()); if(_subList.ContainsKey(0)) _DeletedFileslist.AddRange(_subList[0].ToList()); } foreach (var item in _list) { if (item.Extension==".csv" || item.Extension==".CSV") { if (_AndroidlFilesModifiedDate.ContainsKey(item.Name)) { var AndroidFileDate = _AndroidlFilesModifiedDate[item.Name]; if (AndroidFileDate < item.UTCDateModified) { try { byte[] dropboxFileContent = _client.GetFile(item.Path); SaveAsPrivateFile(ctx, dropboxFileContent, item.Name); } catch (DropNet.Exceptions.DropboxException ex) { //throw new System.Exception(ex.Message); } catch (System.Exception ex) { //throw new System.Exception(ex.Message); } } } else { byte[] dropboxFileContent = _client.GetFile(item.Path); SaveAsPrivateFile(ctx, dropboxFileContent, item.Name); } } } foreach (var item in _DeletedFileslist) { if (EmployeeManagement.DeletedFilesName == null) { EmployeeManagement.DeletedFilesName = new List<string>(); } EmployeeManagement.DeletedFilesName.Add(item.Name.Substring(0, item.Name.LastIndexOf(".")-1)); } if (IsNeedToDelete) { var _listTransFile = _list.Where(L => L.Name.Contains("Trans")); foreach (var item in _DeletedFileslist) { var _theFile = _listTransFile.Where(L => item.Name.Equals(L.Name)).FirstOrDefault(); if (_theFile == null) { ctx.DeleteFile(item.Name); } } } }
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 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); } } }