当前位置: 首页>>代码示例>>C#>>正文


C# Context.GetFileStreamPath方法代码示例

本文整理汇总了C#中Android.Content.Context.GetFileStreamPath方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetFileStreamPath方法的具体用法?C# Context.GetFileStreamPath怎么用?C# Context.GetFileStreamPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Content.Context的用法示例。


在下文中一共展示了Context.GetFileStreamPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadLocalExistingChecklogToDropbox

        public void UploadLocalExistingChecklogToDropbox(Context ctx)
        {
            var files = ctx.FileList();
            foreach (var _item in files.Where(L => L.Contains("Trans-a") || L.Contains("name")))
            {
                var file = ctx.GetFileStreamPath(_item);
                var lines = readFile(file.AbsolutePath);
                if (lines.Length == 0)
                {
                    continue;
                }

                SaveFileToDropbox(lines.ToList(), _item, true);
            }
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:15,代码来源:DropboxHelper.cs

示例2: UploadLocalExistingEmployeeToDropbox

        public void UploadLocalExistingEmployeeToDropbox(Context ctx)
        {
            var files = ctx.FileList();
            foreach (var _item in files.Where(L => !L.Contains("Trans-a")))
            {
                if (!_item.Contains(".CSV"))
                {
                    continue;
                }

                var file = ctx.GetFileStreamPath(_item);
                var lines = readFile(file.AbsolutePath);
                if (lines.Length == 0)
                {
                    continue;
                }
                ISharedPreferences settings = PreferenceManager.GetDefaultSharedPreferences(EmployeeManagement._context);
                string number = settings.GetString("pref_phoneNumber", string.Empty);
                var _list = new List<MetaData>();
                if (!string.IsNullOrEmpty(number))
                {

                    var _subList = getMetaData("/TimePilot_aPhone/aP" + number, false);
                    if (_subList.ContainsKey(1))
                        _list.AddRange(_subList[1].ToList());
                }
                var _dropboxFile = _list.Where(L => !L.Is_Deleted && !L.Is_Dir && L.Name.Equals(_item)).FirstOrDefault();

                if (_dropboxFile == null)
                {
                    SaveFileToDropbox(lines.ToList(), _item, true);

                }
            }
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:35,代码来源:DropboxHelper.cs

示例3: UploadCheckLogToDropbox

        public void UploadCheckLogToDropbox(Context ctx, CheckLogs checklogs)
        {
            var files = ctx.FileList();
            var _CheckType = 0;
            if(checklogs.CheckType.Equals(CheckType.IN))
            _CheckType = 1;
            string Name = checklogs.employee.Name;
            string Number = checklogs.employee.Number;
            string CheckTime = checklogs.CheckTime.ToString(@"yyyy-MM-dd HH:mm:ss");
            var _localtion = GPSHelper.GetInstance().GetLocation();

            ISharedPreferences settings = PreferenceManager.GetDefaultSharedPreferences(EmployeeManagement._context);
            string phoneName = "";
            phoneName = settings.GetString("pref_phoneName", "");
            string content = string.Format("{0},\"{1}\",{2},{3},{4},{5},{6}", _CheckType, Name, Number, CheckTime, phoneName, checklogs.x, checklogs.y);
            var fileName = files.Where(L => L.ToLower().Equals("trans-ap" + checklogs.employee.Number + ".csv")).FirstOrDefault();
            List<string> list = new List<string>();
               if (fileName == null)
               {
                   fileName = "Trans-aP" + checklogs.employee.Number + ".csv";

                   list.Add(content);
                   SaveAsPrivateFileToDropboxTransFile(ctx, list, fileName);
               }
               else
               {
                   var file = ctx.GetFileStreamPath(fileName);
                   var lines = readFile(file.AbsolutePath);
                   int count = lines.Length;

                   foreach (var line in lines)
                   {
                       list.Add(line);
                   }

                   list.Add(content);

                   SaveAsPrivateFileToDropboxTransFile(ctx, list, fileName);
               }
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:40,代码来源:DropboxHelper.cs

示例4: ModifyEmployeeName

        public void ModifyEmployeeName(Context ctx, string EmployeeNumber, string EmployeeName)
        {
            var fileName = ctx.FileList().Where(L => L.Equals(EmployeeNumber + ".CSV")).FirstOrDefault();
               if (string.IsNullOrEmpty(fileName)) return;

               var file=ctx.GetFileStreamPath(fileName);
               var line = readFile(file.AbsolutePath);
               string firstLine = line[0];
               var cells = firstLine.Split(',');
               cells[1] = "\""+EmployeeName+"\"";
               string content= string.Join(",", cells);
               SaveAsPrivateFileToDropboxTransFile(ctx, (new List<string>() { content }), fileName);
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:13,代码来源:DropboxHelper.cs

示例5: importEmployeeToAndroid

        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;
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:59,代码来源:DropboxHelper.cs

示例6: importChecklogsToAndroid

        public void importChecklogsToAndroid(Context ctx, List<Employee> Employees)
        {
            IsConnected();

            var files = ctx.FileList();
            foreach (var _item in Employees)
            {
                var fileName = files.Where(L => L.ToLower().Equals("trans-ap"+_item.Number + ".csv")).FirstOrDefault();
                if (fileName == null) continue;
                var file = ctx.GetFileStreamPath(fileName);
                var lines = readFile(file.AbsolutePath);
                if (lines.Length == 0)
                {
                    continue;
                }

                foreach (var line in lines) {
                    var cells = line.Split(',');
                    var cells_new = new List<string>();
                    foreach (var cell in cells)
                    {
                        if (cell.Length > 1 && cell.Substring(0, 1) == "\"" && cell.Substring(cell.Length - 2, 1) == "\"")
                        {
                            cells_new.Add(cell.Substring(1, cell.Length - 2));
                        }
                        else
                        {
                            cells_new.Add(cell);
                        }
                    }

                    if (cells.Length < 6 || cells_new.Count < 6) continue;

                    DateTime _time = DateTime.MinValue;
                    DateTime.TryParse(cells_new[3], out _time);

                    //TODO: ���ļ���x and y
                    if (cells_new[0] == "0")
                    {
                        if (cells_new.Count > 6)
                        {
                            _item.AddLogWithoutSync(CheckType.OUT, _time, Convert.ToDouble(cells_new[5]), Convert.ToDouble(cells_new[6]));
                        }
                    }
                    else if (cells_new[0] == "1")
                    {
                        if (cells_new.Count > 6)
                        {
                            _item.AddLogWithoutSync(CheckType.IN, _time, Convert.ToDouble(cells_new[5]), Convert.ToDouble(cells_new[6]));
                        }
                    }
                }
            }
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:54,代码来源:DropboxHelper.cs

示例7: DeleteCheckLogFromDropBox

        public void DeleteCheckLogFromDropBox(Context ctx, CheckLogs log)
        {
            var files = ctx.FileList();
            var fileName = files.Where(L => L.ToLower().Equals("trans-ap" + log.employee.Number + ".csv")).FirstOrDefault();
            List<string> list = new List<string>();

            var file = ctx.GetFileStreamPath(fileName);
            var lines = readFile(file.AbsolutePath);
            int count = lines.Length;

            // Needed so only first instance is deleted in case of duplicate transactions
            bool firstDeleted = false;

            foreach (var line in lines)
            {
                var comma = ',';
                var cells = line.Split(comma);
                var _CheckType = 0;
                if (log.CheckType.Equals(CheckType.IN))
                    _CheckType = 1;

                var match = cells[0].Equals(_CheckType.ToString()) && cells[1].Equals("\""+log.employee.Name+"\"") && cells[2].Equals(log.employee.Number) && cells[3].Equals(log.CheckTime.ToString(@"yyyy-MM-dd HH:mm:ss")) ;
                // If not a match, or if a match exists but a log was already deleted, then add it to the list.
                if (!match || (match && firstDeleted))
                    list.Add(line);
                else
                    firstDeleted = true; // If test fails, that means a match was found, make sure not to delete future duplicates
            }

            SaveAsPrivateFileToDropboxTransFile(ctx, list, fileName);
        }
开发者ID:CarolineCao,项目名称:example_timePilot,代码行数:31,代码来源:DropboxHelper.cs


注:本文中的Android.Content.Context.GetFileStreamPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。