partial void DeleteNonComplaintUser(NonComplaintUser instance);
 partial void InsertNonComplaintUser(NonComplaintUser instance);
 partial void UpdateNonComplaintUser(NonComplaintUser instance);
Example #4
0
        /// <summary>
        /// ProcessNonComplaintUsers
        /// </summary>
        public void ProcessNonComplaintUsers()
        {
            try
            {
                IList<NonComplaintUser> ncuList = new List<NonComplaintUser>();
                var recyclerScanInfos = context.RecyclerScanInfos.Where(@w => @w.Processed == null);

                if (recyclerScanInfos != null && recyclerScanInfos.Count() > 0)
                {
                    foreach (var recyclerScan in recyclerScanInfos)
                    {
                        var garbage = context.Garbages.Where(@w => @w.Tag == recyclerScan.Tag).First();
                        var bin = context.Bins.Where(@w => @w.Id == garbage.BinId).First();
                        var recycler = context.Recyclers.Where(@w => @w.Id == recyclerScan.RecyclerId).First();
                        var ward = context.Wards.Where(@w => @w.Id == recycler.WardId).First();

                        NonComplaintUser ncu = new NonComplaintUser
                        {
                            Id = Guid.NewGuid(),
                            UserId = bin.UserId,
                            WardId = ward.Id,
                            CreatedDateTime = DateTime.Now
                        };

                        ncuList.Add(ncu);
                        recyclerScan.Processed = true;
                    }

                    context.NonComplaintUsers.InsertAllOnSubmit(ncuList.AsEnumerable());

                    var ncus = context.NonComplaintUsers.Where(@w => @w.Processed == null &&
                        DateTime.Compare(@w.CreatedDateTime, DateTime.Today.AddDays(-7)) > 1 &&
                        @w.Accepted == true);

                    if (ncus != null && ncus.Count() > 0)
                    {
                        foreach (var ncu in ncus)
                        {
                            ncu.Processed = true;
                        }
                    }

                    SubmitData();
                }
            }
            catch (Exception ex)
            {
                using (StreamWriter sw = File.AppendText(@"C:\IWMSLog.txt"))
                {
                    Log(ex.Message, sw);
                }
            }
        }