Ejemplo n.º 1
0
        private void fillTimesheetLines(int position)
        {
            if (temp != null)
            {
                temp = null;
            }

            if (mPeriodz.numHome > 1)
            {
                mPeriodz.removeItems(mPeriozAdapter);
                mPeriodz.addPeriod(periodTemp, position);
                currentDayPosition = position;
            }

            temp = JsonConvert.DeserializeObject <TimesheetLines.RootObject>(main.offline.ElementAt(currentDayPosition).offlineTimesheetLines);
            for (int i = 0; i < temp.D.Results.Count; i++)
            {
                mPeriodz.addPeriod(temp.D.Results[i].ProjectName,
                                   temp.D.Results[i].TaskName,
                                   temp.D.Results[i].Comment,
                                   temp.D.Results[i].ValidationType.ToString(),
                                   temp.D.Results[i].Status.ToString(),
                                   temp.D.Results[i].TotalWork);
            }
            mPeriozAdapter.NotifyItemRangeInserted(mPeriodz.numHome - 1, temp.D.Results.Count - 1);
        }
Ejemplo n.º 2
0
        public void fillTimesheetLines(int position)
        {
            if (temp != null)
            {
                temp = null;
            }

            if (mPeriodz.numHome > 1)
            {
                mPeriodz.removeItems(mPeriozAdapter);
                mPeriodz.addPeriod(periodTemp, position);
                currentDayPosition = position;
            }

            ThreadPool.QueueUserWorkItem(async state =>
            {
                try {
                    bool success = await core.CreateTimesheet("", periodList.D.Results[position].Id);
                    if (success)
                    {
                        string data = await core.GetTimesheetLines(periodList.D.Results[position].Id);
                        temp        = JsonConvert.DeserializeObject <TimesheetLines.RootObject>(data);

                        for (int i = 0; i < temp.D.Results.Count; i++)
                        {
                            mPeriodz.addPeriod(temp.D.Results[i].ProjectName,
                                               temp.D.Results[i].TaskName,
                                               temp.D.Results[i].Comment,
                                               temp.D.Results[i].LineClass.ToString(),
                                               temp.D.Results[i].Status.ToString(),
                                               temp.D.Results[i].TotalWork);
                        }
                        main.RunOnUiThread(() => { mPeriozAdapter.NotifyItemRangeInserted(mPeriodz.numHome - 1, temp.D.Results.Count - 1); });
                    }
                }
                catch (Exception e) {
                    Log.Info("kfsama", e.Message);
                }
            });
        }