Beispiel #1
0
    public void cancelOneRide(int ridePatID, Volunteer user)
    {
        //get ride details and generate msg
        RidePat rp  = new RidePat();
        var     abc = rp.GetRidePat(ridePatID);

        TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC");
        TimeZoneInfo targetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");
        var          converted      = TimeZoneInfo.ConvertTime(abc.Date, sourceTimeZone, targetTimeZone);
        string       time           = converted.ToShortTimeString();

        if (time == "22:14")
        {
            time = "אחה\"צ";
        }


        var msg = " החולה " + abc.Pat.DisplayName + " ירד מההסעה מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " בתאריך " + abc.Date.ToShortDateString() + ", בשעה " + time + ". אבל הנסיעה מתקיימת כי יש עדיין חולים אחרים על הסעה זו.";
        //insert msg to db
        string sender = (string)HttpContext.Current.Session["loggedInName"];
        int    msgID  = insertMsg(0, "Cancel", "נסיעה בוטלה", msg, ridePatID, System.DateTime.Now, user.Id, "", true, false, false, sender);

        Volunteer V      = new Volunteer();
        string    device = V.getDeviceByID(user.Id);
        var       data   = new JObject();


        if (device == "iOS")
        {
            data = new JObject();
            //PUSH IOS
            var notification = new JObject();
            notification.Add("title", "עדכון לגבי הסעה");
            notification.Add("body", msg);
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushIOS = new myPushNot();
            pushIOS.RunPushNotificationOne(user, data, notification);
        }
        else
        {
            data = new JObject();
            //PUSH ANDROID
            data.Add("message", msg);
            data.Add("title", "עדכון לגבי הסעה");
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushANDROID = new myPushNot();
            pushANDROID.RunPushNotificationOne(user, data, null);
        }
    }
Beispiel #2
0
    public void pushFromAssistant(int ridePatID, string cellphone, string msg)
    {
        RidePat rp  = new RidePat();
        var     abc = rp.GetRidePat(ridePatID);


        TimeSpan ts = abc.Date - System.DateTime.Now;

        // Difference in days.
        double differenceInDays = ts.TotalDays; // This is in double

        if (differenceInDays <= 2)
        {
            Volunteer V      = new Volunteer();
            Volunteer user   = V.getVolunteerByCellphone(cellphone);
            string    device = V.getDeviceByID(user.Id);

            string sender = (string)HttpContext.Current.Session["loggedInName"];
            int    msgID  = insertMsg(0, "Change by assistant", "שינוי על ידי עוזר", msg, ridePatID, System.DateTime.Now, user.Id, "", true, false, false, sender);

            var data = new JObject();


            if (device == "iOS")
            {
                data = new JObject();
                //PUSH IOS
                var notification = new JObject();
                notification.Add("title", "שינוי ע\"י עוזר");
                notification.Add("body", msg);
                data.Add("rideID", ridePatID);
                data.Add("status", "Assistant change");
                data.Add("msgID", msgID);
                data.Add("content-available", 1);
                //send push
                myPushNot pushIOS = new myPushNot();
                pushIOS.RunPushNotificationOne(user, data, notification);
            }
            else
            {
                data = new JObject();
                //PUSH ANDROID
                data.Add("message", msg);
                data.Add("title", "שינוי ע\"י עוזר");
                data.Add("rideID", ridePatID);
                data.Add("status", "Assistant change");
                data.Add("msgID", msgID);
                data.Add("content-available", 1);
                //send push
                myPushNot pushANDROID = new myPushNot();
                pushANDROID.RunPushNotificationOne(user, data, null);
            }
        }
    }
Beispiel #3
0
    public void rideIsTomorrow(int ridePatID, Volunteer user)
    {
        //get ride details and generate msg
        RidePat rp  = new RidePat();
        var     abc = rp.GetRidePat(ridePatID);
        var     msg = "מחר מתקיימת הסעה מ" + abc.Origin.Name + " ל" + abc.Destination.Name + ", בשעה " + abc.Date.ToShortTimeString();

        if (abc.Date.ToShortTimeString() == "22:14")
        {
            msg = "מחר מתקיימת הסעה מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " אחה\"צ";
        }
        //insert msg to db
        string sender = (string)HttpContext.Current.Session["loggedInName"];
        int    msgID  = insertMsg(0, "Reminder", "תזכורת", msg, ridePatID, System.DateTime.Now, user.Id, "", true, false, false, sender);


        //PUSH ANDROID
        var data = new JObject();

        data.Add("message", msg);
        data.Add("title", "נסיעה קרובה");
        data.Add("rideID", ridePatID);
        data.Add("status", "Reminder");
        data.Add("msgID", msgID);
        data.Add("content-available", 1);
        //send push
        myPushNot pushANDROID = new myPushNot();

        pushANDROID.RunPushNotificationOne(user, data, null);

        //PUSH IOS
        var notification = new JObject();

        notification.Add("title", "נסיעה קרובה");
        notification.Add("body", msg);
        data = new JObject();
        data.Add("rideID", ridePatID);
        data.Add("status", "Reminder");
        data.Add("msgID", msgID);
        data.Add("content-available", 1);
        //send push
        myPushNot pushIOS = new myPushNot();

        pushIOS.RunPushNotificationOne(user, data, notification);
    }
Beispiel #4
0
    public void globalMessage(string message, string title)
    {
        //insert msg to db
        string sender = (string)HttpContext.Current.Session["loggedInName"];
        int    msgID  = insertMsg(0, "Global", title, message, 0, System.DateTime.Now, 0, "", true, false, false, sender);

        //get volunteers
        Volunteer        v = new Volunteer();
        List <Volunteer> volunteersList = v.getVolunteersList(true);
        var data = new JObject();

        foreach (Volunteer V in volunteersList)
        {
            if (v.Device == "iOS")
            {
                //PUSH IOS
                data = new JObject();
                var notification = new JObject();
                notification.Add("title", title);
                notification.Add("body", message);
                data = new JObject();
                data.Add("msgID", msgID);
                data.Add("content-available", 1);
                //send push
                myPushNot pushIOS = new myPushNot();
                pushIOS.RunPushNotificationOne(V, data, notification);
            }
            else
            {
                data = new JObject();
                data.Add("message", message);
                data.Add("title", title);
                data.Add("msgID", msgID);
                data.Add("content-available", 1);
                //send push
                myPushNot pushANDROID = new myPushNot();
                pushANDROID.RunPushNotificationOne(V, data, null);
            }
        }
    }
Beispiel #5
0
    public void driverAddedToRide(int ridePatID, Volunteer user)
    {
        //get ride details and generate message
        RidePat rp  = new RidePat();
        var     abc = rp.GetRidePat(ridePatID);
        //Volunteer coor = new Volunteer();
        //coor = abc.Coordinator.getVolunteerByDisplayName(abc.Coordinator.DisplayName);

        TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC");
        TimeZoneInfo targetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");
        var          converted      = TimeZoneInfo.ConvertTime(abc.Date, sourceTimeZone, targetTimeZone);
        string       time           = converted.ToShortTimeString();

        if (time == "22:14")
        {
            time = "אחה\"צ";
        }
        //abc.Date.ToShortDateString()

        string escortsStr = "";

        if (abc.Escorts.Count > 0)
        {
            if (abc.Escorts.Count == 1)
            {
                escortsStr = " עם מלווה";
            }
            else
            {
                escortsStr = " עם " + abc.Escorts.Count + " מלווים";
            }
        }

        string displayName = abc.Pat.DisplayName;

        if (abc.Pat.IsAnonymous == "True")
        {
            displayName = "חולה";
        }



        var message = "שובצת לנסיעה: " + displayName + escortsStr + ", מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " ב-" + abc.Date.Day + "/" + abc.Date.Month + ", בשעה " + time;

        int       userId = 0;
        Volunteer V      = new Volunteer();

        //if (user != null)
        //{
        //    V = V.getVolunteerByID(user.Id);
        //    userId = user.Id;
        //    message = "נסיעה בוטלה על ידי הרכז/ת " + abc.Coordinator.DisplayName + "." + " הנסיעה בתאריך " + abc.Date.ToShortDateString() + " בשעה " + time + " עם החולה " + abc.Pat.DisplayName + " על ידי הנהג/ת " + V.DisplayName;
        //}

        //insert msg to db

        string sender1;

        try { sender1 = (string)HttpContext.Current.Session["loggedInName"]; }
        catch
        {
            sender1 = "הנהג";
        }



        int msgID;

        try
        {
            msgID = insertMsg(0, "You have been listed for a ride", "שובצת לנסיעה", message, ridePatID, System.DateTime.Now, user.Id, "", true, false, false, sender1);
        }
        catch (Exception ex)
        {
            throw new Exception("insertMsg Failed: sender2: " + sender1);
        }

        var data = new JObject();

        if (user.Device == "iOS")
        {
            //PUSH IOS
            data = new JObject();
            var notification = new JObject();
            notification.Add("title", "שובצת לנסיעה");
            notification.Add("body", message);
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushIOS = new myPushNot();
            pushIOS.RunPushNotificationOne(user, data, notification);
        }
        else
        {
            //PUSH ANDROID
            data = new JObject();
            data.Add("message", message);
            data.Add("title", "שובצת לנסיעה");
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushANDROID = new myPushNot();
            pushANDROID.RunPushNotificationOne(user, data, null);
        }
    }
Beispiel #6
0
    public void changeInRide(int ridePatID, Volunteer user)
    {
        //get ride details and generate msg
        RidePat rp  = new RidePat();
        var     abc = rp.GetRidePat(ridePatID);

        TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC");
        TimeZoneInfo targetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");
        var          converted      = TimeZoneInfo.ConvertTime(abc.Date, sourceTimeZone, targetTimeZone);
        string       time           = converted.ToShortTimeString();

        if (time == "22:14")
        {
            time = "אחה\"צ";
        }

        string escortsStr = "";

        if (abc.Escorts.Count > 0)
        {
            if (abc.Escorts.Count == 1)
            {
                escortsStr = " עם מלווה";
            }
            else
            {
                escortsStr = " עם " + abc.Escorts.Count + " מלווים";
            }
        }

        string displayName = abc.Pat.DisplayName;

        if (abc.Pat.IsAnonymous == "True")
        {
            displayName = "חולה";
        }

        var msg = "בוצע שינוי בהסעה שנרשמת אליה. לאחר השינוי, " + displayName + escortsStr + ", מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " ב-" + abc.Date.Day + "/" + abc.Date.Month + ", בשעה " + time;


        string sender;


        if (HttpContext.Current.Session["loggedInName"] == null)
        {
            sender = "משתמש שהמערכת לא הצליחה לזהות";
        }
        else
        {
            sender = (string)HttpContext.Current.Session["loggedInName"];
        }

        int msgID = insertMsg(0, "Changes in ride", "שינויים בהסעה", msg, ridePatID, System.DateTime.Now, user.Id, "", true, false, false, sender);


        Volunteer V      = new Volunteer();
        string    device = V.getDeviceByID(user.Id);
        var       data   = new JObject();

        if (device == "iOS")
        {
            data = new JObject();
            //PUSH IOS
            var notification = new JObject();
            notification.Add("title", "שינויים בהסעה");
            notification.Add("body", msg);
            data.Add("rideID", ridePatID);
            data.Add("status", "Changes in ride");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushIOS = new myPushNot();
            pushIOS.RunPushNotificationOne(user, data, notification);
        }
        else
        {
            data = new JObject();
            //PUSH ANDROID
            data.Add("message", msg);
            data.Add("title", "שינויים בהסעה");
            data.Add("rideID", ridePatID);
            data.Add("status", "Changes in ride");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushANDROID = new myPushNot();
            pushANDROID.RunPushNotificationOne(user, data, null);
        }
    }
Beispiel #7
0
    public void coordinatorCanceledRide(int ridePatID, Volunteer user)
    {//this method is to inform a coordinator about ride cancellation
        //get ride details and generate message
        RidePat   rp   = new RidePat();
        var       abc  = rp.GetRidePat(ridePatID);
        Volunteer coor = new Volunteer();

        coor = abc.Coordinator.getVolunteerByDisplayName(abc.Coordinator.DisplayName);


        TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC");
        TimeZoneInfo targetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");
        var          converted      = TimeZoneInfo.ConvertTime(abc.Date, sourceTimeZone, targetTimeZone);
        string       time           = converted.ToShortTimeString();

        if (time == "22:14")
        {
            time = "אחה\"צ";
        }
        //abc.Date.ToShortDateString()
        var       message = "נסיעה בוטלה על ידי הרכז/ת " + abc.Coordinator.DisplayName + "." + " הנסיעה בתאריך " + abc.Date.ToShortDateString() + " בשעה " + time + " עם החולה " + abc.Pat.DisplayName;
        int       userId  = 0;
        Volunteer V       = new Volunteer();

        if (user != null)
        {
            V       = V.getVolunteerByID(user.Id);
            userId  = user.Id;
            message = "נסיעה בוטלה על ידי הרכז/ת " + abc.Coordinator.DisplayName + "." + " הנסיעה בתאריך " + abc.Date.ToShortDateString() + " בשעה " + time + " עם החולה " + abc.Pat.DisplayName + " על ידי הנהג/ת " + V.DisplayName;
        }

        //insert msg to db
        string   sender = (string)HttpContext.Current.Session["loggedInName"];
        LogEntry log    = new LogEntry(System.DateTime.Now, "hardware", message, 1234);



        var data = new JObject();

        if (coor.Device == "iOS")
        {
            //PUSH IOS
            data = new JObject();
            var notification = new JObject();
            notification.Add("title", "נסיעה בוטלה על ידי רכז/ת");
            notification.Add("body", message);
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushIOS = new myPushNot();
            pushIOS.RunPushNotificationOne(coor, data, notification);
        }
        else
        {
            //PUSH ANDROID
            data = new JObject();
            data.Add("message", message);
            data.Add("title", "נסיעה בוטלה על ידי רכז/ת");
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushANDROID = new myPushNot();
            pushANDROID.RunPushNotificationOne(coor, data, null);
        }
    }
Beispiel #8
0
    public int backupToPrimary(int ridePatID)
    {
        string time = "";
        //get ride details and generate msg
        RidePat rp = new RidePat();

        rp = rp.GetRidePat(ridePatID);
        Volunteer v = new Volunteer();

        if (rp.Drivers[0].DriverType == "Secondary")
        {
            v = rp.Drivers[0];
        }
        else
        {
            throw new Exception("The assigned driver is the primary driver for this ride");
        }

        string device = v.getDeviceByID(v.Id);

        TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC");
        TimeZoneInfo targetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");
        var          converted      = TimeZoneInfo.ConvertTime(rp.Date, sourceTimeZone, targetTimeZone);

        time = converted.ToShortTimeString();
        if (time == "22:14")
        {
            time = "אחה\"צ";
        }

        string msg = "האם ברצונך להחליף את הנהג הראשי בנסיעה מ" + rp.Origin.Name + " ל" + rp.Destination.Name + " בתאריך " + rp.Date.ToShortDateString() + ", בשעה " + time + "?";

        //insert msg to db
        string sender = (string)HttpContext.Current.Session["loggedInName"];
        int    msgID  = insertMsg(0, "BackupToPrimary", "החלפת נהג ראשי", msg, ridePatID, System.DateTime.Now, v.Id, "", true, false, false, sender);

        var data = new JObject();

        if (device == "iOS")
        {
            data = new JObject();
            //PUSH IOS
            var notification = new JObject();
            notification.Add("title", "החלפת נהג ראשי");
            notification.Add("body", msg);
            data.Add("rideID", ridePatID);
            data.Add("status", "PrimaryCanceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushIOS = new myPushNot();
            pushIOS.RunPushNotificationOne(v, data, notification);
        }
        else
        {
            data = new JObject();
            //PUSH ANDROID
            data.Add("message", msg);
            data.Add("title", "החלפת נהג ראשי");
            data.Add("rideID", ridePatID);
            data.Add("status", "PrimaryCanceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushANDROID = new myPushNot();
            pushANDROID.RunPushNotificationOne(v, data, null);
        }

        return(1);
    }
Beispiel #9
0
    public void driverSignUpToCloseRide(int ridePatID, Volunteer user, bool isPrimary)
    {
        //get ride details and generate message
        RidePat   rp   = new RidePat();
        var       abc  = rp.GetRidePat(ridePatID);
        Volunteer coor = new Volunteer();

        coor = abc.Coordinator.getVolunteerByDisplayName(abc.Coordinator.DisplayName);
        string       driverType     = isPrimary ? "נהג ראשי" : "גיבוי";
        TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("UTC");
        TimeZoneInfo targetTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");
        var          converted      = TimeZoneInfo.ConvertTime(abc.Date, sourceTimeZone, targetTimeZone);
        string       time           = converted.ToShortTimeString();

        if (time == "22:14")
        {
            time = "אחה\"צ";
        }

        var message = "";

        if (user.Gender == "מתנדב")
        {
            message = "הנהג " + user.FirstNameH + " " + user.LastNameH + " נרשם להסעה מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " עם החולה " + abc.Pat.DisplayName + " כ" + driverType + " בתאריך " + abc.Date.ToShortDateString() + " ושעה " + time + ".";
        }
        else
        {
            message = "הנהגת " + user.FirstNameH + " " + user.LastNameH + " נרשמה להסעה מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " עם החולה " + abc.Pat.DisplayName + " כ" + driverType + " בתאריך " + abc.Date.ToShortDateString() + " ושעה " + time + ".";
        }

        //insert msg to db
        //string sender = (string)HttpContext.Current.Session["loggedInName"];
        string sender1;

        try
        {
            sender1 = (string)HttpContext.Current.Session["loggedInName"];
        }
        catch
        {
            sender1 = "הנהג";
        }



        int msgID;

        try
        {
            msgID = insertMsg(0, "sign by driver", "הרשמה להסעה קרובה", message, ridePatID, System.DateTime.Now, user.Id, "", true, false, false, sender1); //XXX
        }
        catch (Exception ex)
        {
            throw new Exception("I1: " + ex.Message);
        }


        var data = new JObject();

        if (coor.Device == "iOS")
        {
            //PUSH IOS
            data = new JObject();
            var notification = new JObject();
            notification.Add("title", "הרשמה להסעה קרובה");
            notification.Add("body", message);
            data.Add("rideID", ridePatID);
            data.Add("status", "SignUp");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushIOS = new myPushNot();
            pushIOS.RunPushNotificationOne(coor, data, notification);
        }
        else
        {
            //PUSH ANDROID
            data = new JObject();
            data.Add("message", message);
            data.Add("title", "הרשמה להסעה קרובה");
            data.Add("rideID", ridePatID);
            data.Add("status", "SignUp");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushANDROID = new myPushNot();
            pushANDROID.RunPushNotificationOne(coor, data, null);
        }
    }
Beispiel #10
0
    public void driverCanceledRide(int ridePatID, Volunteer user)
    {
        //get ride details and generate message
        RidePat   rp   = new RidePat();
        var       abc  = rp.GetRidePat(ridePatID);
        Volunteer coor = new Volunteer();

        coor = abc.Coordinator.getVolunteerByDisplayName(abc.Coordinator.DisplayName);

        var message = "";

        if (user.Gender == "מתנדב")
        {
            message = "הנהג " + user.FirstNameH + " " + user.LastNameH + " ביטל את הנסיעה מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " עם החולה " + abc.Pat.DisplayName + " שמתקיימת בזמן הקרוב";
        }
        else
        {
            message = "הנהגת " + user.FirstNameH + " " + user.LastNameH + " ביטלה את הנסיעה מ" + abc.Origin.Name + " ל" + abc.Destination.Name + " עם החולה " + abc.Pat.DisplayName + " שמתקיימת בזמן הקרוב";
        }
        //insert msg to db


        string sender;

        if (HttpContext.Current.Session["loggedInName"] == null)
        {
            sender = "הנהג";
        }
        else
        {
            sender = (string)HttpContext.Current.Session["loggedInName"];
        }

        int msgID = insertMsg(0, "Canceled by driver", "נסיעה בוטלה על ידי נהג\\ת", message, ridePatID, System.DateTime.Now, user.Id, "", true, false, false, sender);


        var data = new JObject();

        if (coor.Device == "iOS")
        {
            //PUSH IOS
            data = new JObject();
            var notification = new JObject();
            notification.Add("title", "נסיעה בוטלה על ידי נהג\\ת");
            notification.Add("body", message);
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushIOS = new myPushNot();
            pushIOS.RunPushNotificationOne(coor, data, notification);
        }
        else
        {
            //PUSH ANDROID
            data = new JObject();
            data.Add("message", message);
            data.Add("title", "נסיעה בוטלה על ידי נהג\\ת");
            data.Add("rideID", ridePatID);
            data.Add("status", "Canceled");
            data.Add("msgID", msgID);
            data.Add("content-available", 1);
            //send push
            myPushNot pushANDROID = new myPushNot();
            pushANDROID.RunPushNotificationOne(coor, data, null);
        }
    }