예제 #1
0
        async Task ExecuteLoadEventsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                DetailItems.Clear();
                var events = await Repository.EventDataStore.GetItemsAsync(true);

                events = events.Where(d => d.ClubId == Item.Id);

                foreach (var item in events)
                {
                    DetailItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #2
0
 public int SaveDetailsAsync(DetailItems item)
 {
     if (item.tableID != 0)
     {
         return(database.Update(item));
     }
     else
     {
         return(database.Insert(item));
     }
 }
        public void OnPost()
        {
            //WebApi呼び出し
            var            url = "http://localhost:50367/api/Details";
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

            req.Method      = "POST";
            req.ContentType = "application/json";

            var dic = new Dictionary <string, object>
            {
                { "user_id", 1764565 },
                { "keyword", SearchItem.Keyword },
                { "from_date", SearchItem.FromDate.ToString("yyyy-MM-dd") },
                { "to_date", SearchItem.ToDate.ToString("yyyy-MM-dd") }
            };
            var source = JToken.FromObject(dic);

            var inputJson = JsonConvert.SerializeObject(source);

            byte[] byteArray = Encoding.UTF8.GetBytes(inputJson);
            req.ContentLength = byteArray.Length;
            using (Stream dataStream = req.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
            }
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();

            var responseJson = "";

            using (var sr = new StreamReader(res.GetResponseStream()))
            {
                responseJson = sr.ReadToEnd();
            }
            var result = JsonConvert.DeserializeObject <JToken>(responseJson);


            foreach (var t in result["items"])
            {
                var item = new DetailItem()
                {
                    Id               = t["Id"].Value <int>(),
                    SettlementDay    = t["SettlementDay"].Value <DateTime>(),
                    ItemNumber       = t["ItemNumber"].Value <int>(),
                    AccountTypeId    = t["AccountTypeId"].Value <int>(),
                    AccountTypeName  = t["AccountTypeName"].Value <string>(),
                    ExpenseOrRevenue = t["ExpenseOrRevenue"].Value <string>(),
                    Amount           = t["Amount"].Value <int>(),
                    Remarks          = t["Remarks"].Value <string>()
                };
                DetailItems.Add(item);
            }
        }
        async void GetListData()
        {
            loading.IsVisible = true;
            try
            {
                overloadRecord.Clear();
                var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, uri, this);

                clsResponse response = JsonConvert.DeserializeObject <clsResponse>(content);

                if (response.IsGood == true)
                {
                    App.Database.deleteRecords(menuItems.Id);
                    App.Database.deleteRecordSummary(menuItems.Id);
                    App.Database.deleteRecordDetails();

                    //clsHaulageModel inherit clsDataRow
                    records = JObject.Parse(content)["Result"].ToObject <List <clsHaulageModel> >();

                    foreach (clsHaulageModel data in records)
                    {
                        Guid      objectID = Guid.NewGuid();
                        ListItems record   = new ListItems
                        {
                            Id         = (menuItems.Id == "PendingCollection") ? objectID.ToString() : data.Id,
                            Background = (!(String.IsNullOrEmpty(data.BackColor))) ? data.BackColor : "#ffffff",
                            Category   = menuItems.Id,
                            Name       = menuItems.Name,
                            Action     = data.Action
                        };

                        if (menuItems.Id == "JobList")
                        {
                            record.TruckId        = data.TruckId;
                            record.ReqSign        = data.ReqSign;
                            record.Latitude       = data.Latitude;
                            record.Longitude      = data.Longitude;
                            record.TelNo          = data.TelNo;
                            record.EventRecordId  = data.EventRecordId;
                            record.TrailerId      = data.TrailerId;
                            record.ContainerNo    = data.ContainerNo;
                            record.MaxGrossWeight = data.MaxGrossWeight;
                            record.TareWeight     = data.TareWeight;
                            record.CollectSeal    = data.CollectSeal;
                            record.SealNo         = data.SealNo;
                            record.ActionId       = data.ActionId.ToString();
                            record.ActionMessage  = data.ActionMessage;
                            record.Title          = data.Title;
                            record.SealMode       = data.SealMode;
                        }

                        //store summary of the record for search
                        string summary = "", closingTime = "";
                        int    count = 0;
                        foreach (clsCaptionValue summaryItem in data.Summary)
                        {
                            count++;

                            if (summaryItem.Caption == "Closing Date")
                            {
                                closingTime = summaryItem.Value.Replace('-', '/');
                            }
                            else if (!(String.IsNullOrEmpty(summaryItem.Caption)))
                            {
                                if (count == data.Summary.Count)
                                {
                                    summary += summaryItem.Caption + " :  " + summaryItem.Value;
                                }
                                else
                                {
                                    summary += summaryItem.Caption + " :  " + summaryItem.Value + "\r\n" + "\r\n";
                                }
                            }
                            else if (summaryItem.Caption == "")
                            {
                                if (!(String.IsNullOrEmpty(summaryItem.Value)))
                                {
                                    summary += summaryItem.Value + "\r\n" + "\r\n";
                                }
                            }
                        }

                        record.Summary     = summary;
                        record.ClosingDate = (String.IsNullOrEmpty(closingTime)) ? DateTime.Now : DateTime.Parse(closingTime);

                        if (records.Count < 50)
                        {
                            App.Database.SaveMenuAsync(record);

                            foreach (clsCaptionValue summaryList in data.Summary)
                            {
                                SummaryItems summaryItem = new SummaryItems();

                                summaryItem.Id        = (menuItems.Id == "PendingCollection") ? objectID.ToString() : data.Id;
                                summaryItem.Caption   = summaryList.Caption;
                                summaryItem.Value     = summaryList.Value;
                                summaryItem.Display   = summaryList.Display;
                                summaryItem.Type      = menuItems.Id;
                                summaryItem.BackColor = data.BackColor;
                                App.Database.SaveSummarysAsync(summaryItem);
                            }

                            foreach (clsCaptionValue detailList in data.Details)
                            {
                                DetailItems detailItem = new DetailItems();
                                detailItem.Id      = data.Id;
                                detailItem.Caption = detailList.Caption;
                                detailItem.Value   = detailList.Value;
                                detailItem.Display = detailList.Display;
                                App.Database.SaveDetailsAsync(detailItem);
                            }
                        }
                        else
                        {
                            overloadRecord.Add(record);
                        }
                    }

                    if (records.Count < 50)
                    {
                        LoadListData();
                    }
                    else
                    {
                        listView.ItemsSource = overloadRecord;
                    }

                    listView.IsRefreshing = false;
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
            }

            loading.IsVisible = false;
        }
예제 #5
0
        async void RefreshJobContent()
        {
            App.Database.deleteRecords("JobList");
            App.Database.deleteRecordSummary("JobList");
            App.Database.deleteRecordDetails();

            var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getHaulageJobListURL(), this);

            clsResponse response = JsonConvert.DeserializeObject <clsResponse>(content);

            if (response.IsGood)
            {
                var HaulageJobList = JObject.Parse(content)["Result"].ToObject <List <clsHaulageModel> >();

                foreach (clsHaulageModel job in HaulageJobList)
                {
                    ListItems record = new ListItems
                    {
                        Id             = job.Id,
                        Background     = job.BackColor,
                        Category       = "JobList",
                        TruckId        = job.TruckId,
                        ReqSign        = job.ReqSign,
                        Latitude       = job.Latitude,
                        Longitude      = job.Longitude,
                        TelNo          = job.TelNo,
                        EventRecordId  = job.EventRecordId,
                        TrailerId      = job.TrailerId,
                        ContainerNo    = job.ContainerNo,
                        MaxGrossWeight = job.MaxGrossWeight,
                        TareWeight     = job.TareWeight,
                        CollectSeal    = job.CollectSeal,
                        SealNo         = job.SealNo,
                        ActionId       = job.ActionId.ToString(),
                        ActionMessage  = job.ActionMessage,
                        Title          = job.Title,
                        SealMode       = job.SealMode
                    };
                    App.Database.SaveMenuAsync(record);

                    foreach (clsCaptionValue summaryList in job.Summary)
                    {
                        SummaryItems summaryItem = new SummaryItems();

                        summaryItem.Id        = job.Id;
                        summaryItem.Caption   = summaryList.Caption;
                        summaryItem.Value     = summaryList.Value;
                        summaryItem.Display   = summaryList.Display;
                        summaryItem.Type      = "JobList";
                        summaryItem.BackColor = job.BackColor;
                        App.Database.SaveSummarysAsync(summaryItem);
                    }

                    foreach (clsCaptionValue detailList in job.Details)
                    {
                        DetailItems detailItem = new DetailItems();

                        detailItem.Id      = job.Id;
                        detailItem.Caption = detailList.Caption;
                        detailItem.Value   = detailList.Value;
                        detailItem.Display = detailList.Display;
                        App.Database.SaveDetailsAsync(detailItem);
                    }

                    if (job.Id.Equals(Ultis.Settings.SessionCurrentJobId))
                    {
                        Ultis.Settings.Action = job.ActionId.ToString();
                        Ultis.Settings.SessionCurrentJobId = job.Id;
                        jobItem = null;
                        JobContent();
                    }
                }
            }
        }
예제 #6
0
        protected async void GetJobList()
        {
            var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getTruckListURL(webServiceAction), this);

            clsResponse job_response = JsonConvert.DeserializeObject <clsResponse>(content);

            if (job_response.IsGood)
            {
                records.Clear();

                App.Database.DeleteTruckModel();
                App.Database.DeleteTruckModeDetail();

                List <clsTruckingModel> trucks = JObject.Parse(content)["Result"].ToObject <List <clsTruckingModel> >();

                foreach (clsTruckingModel truck in trucks)
                {
                    string     summary = "";
                    TruckModel record  = new TruckModel
                    {
                        TruckId       = truck.TruckId,
                        RecordId      = truck.Id,
                        Action        = truck.Action,
                        EventRecordId = truck.EventRecordId,
                        Latitude      = truck.Latitude,
                        Longitude     = truck.Longitude,
                        TelNo         = truck.TelNo,
                        ReqSign       = truck.ReqSign
                    };

                    if (!(String.IsNullOrEmpty(truck.BackColor)))
                    {
                        record.BackColor = truck.BackColor;
                    }
                    else
                    {
                        record.BackColor = "#ffffff";
                    }

                    foreach (clsCaptionValue truckSummary in truck.Summary)
                    {
                        if (!(String.IsNullOrEmpty(truckSummary.Caption)))
                        {
                            summary += truckSummary.Caption + "  :  " + truckSummary.Value + "\r\n" + "\r\n";
                        }
                    }

                    foreach (clsCaptionValue truckDetail in truck.Details)
                    {
                        DetailItems detail = new DetailItems();

                        detail.Id      = truck.Id;
                        detail.Caption = truckDetail.Caption;
                        detail.Value   = truckDetail.Value;
                        detail.Display = truckDetail.Display;
                        App.Database.SaveDetailsAsync(detail);
                    }

                    record.Summary = summary;

                    App.Database.SaveTruckModelAsync(record);
                }
                loadJobList();
            }
            else
            {
                await DisplayAlert("JsonError", job_response.Message, "OK");
            }
        }
예제 #7
0
 public int DeleteDetailItem(DetailItems item)
 {
     return(database.Delete(item));
 }