Пример #1
0
        public string AddNotification(int jobServiceId)
        {
            Models.JobServicePickup svcpu;
            Models.JobServices      svc = db.JobServices.Find(jobServiceId);

            svcpu = svc.JobServicePickups.FirstOrDefault();

            //add notification
            JobNotificationRequest jnr = new JobNotificationRequest();

            db.JobNotificationRequests.Add(new JobNotificationRequest
            {
                RefId     = "0", //job id
                ReqDt     = DateTime.Parse(DateTime.Now.ToString("MMM dd yyyy HH:mm:ss")),
                ServiceId = jobServiceId
            });

            db.SaveChanges();
            return("Notification added to the list");
        }
Пример #2
0
        public getItemSchedReturn ItemSchedules()
        {
            #region get itemJobs
            string SqlStr = @"
select  a.Id ItemId, c.JobMainId, c.Id ServiceId, c.Particulars, c.DtStart, c.DtEnd from 
InvItems a
left outer join JobServiceItems b on b.InvItemId = a.Id 
left outer join JobServices c on b.JobServicesId = c.Id
left outer join JobMains d on c.JobMainId = d.Id
where d.JobStatusId < 4
;";
            List <cItemSchedule> itemJobs = db.Database.SqlQuery <cItemSchedule>(SqlStr).ToList();

            //cItemSchedule
            #endregion

            int                 NoOfDays  = 20;
            DateTime            dtStart   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
            List <ItemSchedule> ItemSched = new List <ItemSchedule>();

            var InvItems = db.InvItems.ToList().OrderBy(s => s.OrderNo);
            var ItemId   = db.InvItems.Select(s => s.Id).ToList();


            foreach (var tmpItem in InvItems)
            {
                ItemSchedule ItemTmp = new ItemSchedule();

                ItemTmp.ItemId    = tmpItem.Id;
                ItemTmp.Item      = tmpItem;
                ItemTmp.dayStatus = new List <DayStatus>();

                Console.WriteLine(ItemTmp.Item.Description);

                var JobServiceList = itemJobs.Where(d => d.ItemId == tmpItem.Id);
                for (int i = 0; i <= NoOfDays; i++)
                {
                    DayStatus dsTmp = new DayStatus();
                    dsTmp.Date   = dtStart.AddDays(i);
                    dsTmp.Day    = i + 1;
                    dsTmp.status = 0;

                    //Check if your Messages collection exists
                    if (dsTmp.svc == null)
                    {
                        //It's null - create it
                        dsTmp.svc = new List <JobServices>();
                    }


                    foreach (var jsTmp in JobServiceList)
                    {
                        int istart = dsTmp.Date.CompareTo(jsTmp.DtStart);
                        int iend   = dsTmp.Date.CompareTo(jsTmp.DtEnd);

                        if (istart >= 0 && iend <= 0)
                        {
                            dsTmp.status += 1;
                            JobServices js = db.JobServices.Where(j => j.Id == jsTmp.ServiceId).FirstOrDefault();
                            dsTmp.svc.Add(js);
                        }
                    }

                    ItemTmp.dayStatus.Add(dsTmp);
                }


                ItemSched.Add(ItemTmp);
            }

            //Day Label
            List <DayLabel> dLabel = new List <DayLabel>();
            for (int i = 0; i <= NoOfDays; i++)
            {
                DateTime dtDay = dtStart.AddDays(i);

                DayLabel dsTmp = new DayLabel();
                dsTmp.iDay     = i + 1;
                dsTmp.sDayName = dtDay.ToString("ddd");
                dsTmp.sDayNo   = dtDay.ToString("dd");

                dLabel.Add(dsTmp);
            }

            getItemSchedReturn dReturn = new getItemSchedReturn();
            dReturn.dLabel    = dLabel;
            dReturn.ItemSched = ItemSched;

            return(dReturn);
        }
Пример #3
0
        public void GetNotification(int jobId)
        {
            string sData = "Pickup Details";

            Models.JobServicePickup svcpu;
            Models.JobServices      svc = db.JobServices.Find(jobId);

            if (svc.JobServicePickups.FirstOrDefault() == null)
            {
                sData += "\nPickup: undefined ";
            }
            else
            {
                Decimal quote = (svc.QuotedAmt == null ? 0 : (decimal)svc.QuotedAmt);

                svcpu  = svc.JobServicePickups.FirstOrDefault();
                sData += "\nDate:" + ((DateTime)svc.DtStart).ToString("dd MMM yyyy (ddd)");
                sData += "\nTime&Location:" + svcpu.JsTime + " " + svcpu.JsLocation;
                sData += "\nGuest:" + svcpu.ClientName + " #" + svcpu.ClientContact;
                sData += "\nDriver:" + svcpu.ProviderName + " #" + svcpu.ProviderContact;
                sData += "\nUnit:" + svc.SupplierItem.Description + " " + svc.SupplierItem.Remarks;
                sData += "\nRate:P" + quote.ToString("##,###.00");
                sData += "\nParticulars:" + svc.Particulars;
                sData += "\n  " + svc.Remarks;
                sData += "\n\nHave a safe trip,\nAJ88 Car Rental";

                //create table for the message
                DataTable Dt = new DataTable("Table");
                //columns for the table
                Dt.Columns.Add("Id", typeof(int));
                Dt.Columns.Add("DtSchedule", typeof(string));
                Dt.Columns.Add("Message", typeof(string));
                Dt.Columns.Add("Recipient", typeof(string));
                Dt.Columns.Add("RecType", typeof(string));

                //add for the client, driver, admin
                int    Id         = 0;
                string dtSchedule = ((DateTime)svc.DtStart).ToString("dd MMM yyyy (ddd)");
                string msg        = sData;
                string recipients = svcpu.ProviderContact;
                Dt.Rows.Add(Id, dtSchedule, msg, recipients);

                //driver
                Id = 1;
                //the same schedule
                //the same msg
                recipients = svcpu.ClientContact;
                Dt.Rows.Add(Id, dtSchedule, msg, recipients);

                //admin
                Id = 2;
                //the same schedule
                //the same msg
                recipients = "09279016517"; //admin contact
                Dt.Rows.Add(Id, dtSchedule, msg, recipients);


                DataSet ds = new DataSet();
                ds.Tables.Add(Dt);
                ds.DataSetName = "Table";

                Context.Response.Clear();
                Context.Response.ContentType = "application/json";
                Context.Response.Write(JsonConvert.SerializeObject(ds, Newtonsoft.Json.Formatting.Indented));
            }


            /*
             * var recentControls = rpidb.RpiControls.Where(m => m.RpiDeviceId == deviceId).OrderByDescending(m => m.DtSchedule).ToList();
             *
             * DataTable Dt = new DataTable("Table");
             *
             * Dt.Columns.Add("Id", typeof(int));
             * Dt.Columns.Add("DtSchedule", typeof(DateTime));
             * Dt.Columns.Add("Data", typeof(string));
             * Dt.Columns.Add("RpiDeviceId", typeof(int));
             *
             * //get details of each failed items from recipientId
             * foreach (var control in recentControls)
             * {
             *
             *  int Id = control.Id; //component id
             *  DateTime dtSchedule = DateTime.Parse(control.DtSchedule);
             *  string Data = control.Data;
             *  int rpiDeviceId = control.RpiDeviceId;
             *
             *  if (DateTime.Parse(dtSchedule.ToString()).CompareTo(DateTime.Now) <= 0)
             *  {
             *      Dt.Rows.Add(Id, dtSchedule, Data, rpiDeviceId);
             *      break;
             *  }
             *
             * }
             *
             * DataSet ds = new DataSet();
             * ds.Tables.Add(Dt);
             * ds.DataSetName = "Table";
             *
             * Context.Response.Clear();
             * Context.Response.ContentType = "application/json";
             * Context.Response.Write(JsonConvert.SerializeObject(ds, Newtonsoft.Json.Formatting.Indented));
             */
        }
Пример #4
0
        public void GetNotification(int jobId)
        {
            string sData = "Pickup Details";

            Models.JobServicePickup svcpu;
            Models.JobServices      svc = db.JobServices.Find(jobId);

            if (svc.JobServicePickups.FirstOrDefault() == null)
            {
                sData += "\nPickup: undefined ";
            }
            else
            {
                Decimal quote = (svc.QuotedAmt == null ? 0 : (decimal)svc.QuotedAmt);

                svcpu  = svc.JobServicePickups.FirstOrDefault();
                sData += "\nDate:" + ((DateTime)svc.DtStart).ToString("dd MMM yyyy (ddd)");
                sData += "\nTime&Location:" + svcpu.JsTime + " " + svcpu.JsLocation;
                sData += "\nGuest:" + svcpu.ClientName + " #" + svcpu.ClientContact;
                sData += "\nDriver:" + svcpu.ProviderName + " #" + svcpu.ProviderContact;
                sData += "\nUnit:" + svc.SupplierItem.Description + " " + svc.SupplierItem.Remarks;
                sData += "\nRate:P" + quote.ToString("##,###.00");
                sData += "\nParticulars:" + svc.Particulars;
                sData += "\n  " + svc.Remarks;
                sData += "\n\nHave a safe trip,\nAJ88 Car Rental";

                //create table for the message
                DataTable Dt = new DataTable("Table");
                //columns for the table
                Dt.Columns.Add("Id", typeof(int));
                Dt.Columns.Add("DtSchedule", typeof(string));
                Dt.Columns.Add("Message", typeof(string));
                Dt.Columns.Add("Recipient", typeof(string));
                Dt.Columns.Add("RecType", typeof(string));

                //add for the client, driver, admin
                int    Id         = 0;
                string dtSchedule = ((DateTime)svc.DtStart).ToString("dd MMM yyyy");
                string msg        = sData;
                string recipients = svcpu.ProviderContact;
                Dt.Rows.Add(Id, dtSchedule, msg, recipients);

                //driver
                Id = 1;
                //the same schedule
                //the same msg
                recipients = svcpu.ClientContact;
                Dt.Rows.Add(Id, dtSchedule, msg, recipients);

                //admin
                Id = 2;
                //the same schedule
                //the same msg
                recipients = "09279016517"; //admin contact
                Dt.Rows.Add(Id, dtSchedule, msg, recipients);

                DataSet ds = new DataSet();
                ds.Tables.Add(Dt);
                ds.DataSetName = "Table";

                Context.Response.Clear();
                Context.Response.ContentType = "application/json";
                Context.Response.Write(JsonConvert.SerializeObject(ds, Newtonsoft.Json.Formatting.Indented));
            }
        }