Ejemplo n.º 1
0
        public String ConvertImageURLToBase64(string latlng, int Zoom)
        {
            string[] newlatlongs = latlng.Split('|');
            string   MapKey      = wc.AppSettings("ApiMapKey").ToString();
            var      APIKey      = MapKey;
            var      mapZoom     = Zoom;

            if (mapZoom <= 0)
            {
                mapZoom = 1;
            }
            StringBuilder sb = new StringBuilder();

            foreach (var ll in newlatlongs)
            {
                sb.Append("&markers=color:red%7C" + ll);
            }
            string url = "https://maps.googleapis.com/maps/api/staticmap?zoom=" + mapZoom + "&size=400x350&maptype=roadmap" + sb + "&key=" + APIKey;

            StringBuilder _sb = new StringBuilder();

            Byte[] _byte = this.GetImg(url);
            _sb.Append(Convert.ToBase64String(_byte, 0, _byte.Length));
            return(string.Format(@"data:image/jpg;base64, {0}", _sb.ToString()));
        }
Ejemplo n.º 2
0
        private void SendEmail(string Subject, string ToEmail, string Body)
        {
            WebConfig wc                = new WebConfig();
            string    SmtpServer        = wc.AppSettings("SmtpServer");
            string    SmtpServerPort    = wc.AppSettings("SmtpServerPort");
            string    FromEmail         = wc.AppSettings("FromEmail");
            string    FromEmailPassword = wc.AppSettings("FromEmailPassword");

            //string ToEmail = wc.AppSettings("ToEmail");

            FromEmailPassword = Encryption.Decrypt(FromEmailPassword, true);
            Email em = new Email(SmtpServer, Convert.ToInt32(SmtpServerPort), FromEmail, FromEmailPassword);

            try
            {
                if (SmtpServer != null && SmtpServerPort != null && FromEmail != null && FromEmailPassword != null && ToEmail != null)
                {
                    em.SendEmail(Subject, Body, ToEmail);
                }
            }
            catch (Exception)
            {
                //throw;
            }
        }
Ejemplo n.º 3
0
        private void SendMessage(string DevieToken, string Number, int Ducation, string TestType)
        {
            try
            {
                WebConfig wc          = new WebConfig();
                var       FirebaseKey = wc.AppSettings("FirebaseKey");
                var       result      = "-1";
                var       webAddr     = "https://fcm.googleapis.com/fcm/send";

                var httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr);
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Headers.Add("Authorization:key=" + FirebaseKey);
                httpWebRequest.Method = "POST";
                // VMT,MT,SMSMT
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    //  string json = "{\"to\": \"dfk90rb_znE:APA91bHLegH5Ru1zVNj-aDnV6zrm7ewOFmjl9QvM7N9wL-wnInpqBlHWfWyICpcH6lJgRSux2M-EkVXhtRlGdb2REnwftdE-4xgXAOxm54U-c35PIB7k7Q-o-wepxhC0_30QQp3D2jhe\",\"data\": {\"message\": \"This is a Firebase Cloud Messaging Topic Message!\",}}";
                    string json = "{ \"data\": {\"TestType\": \"" + TestType + "\",\"Number\":\"" + Number + "\",\"duration\":\"" + Ducation + "\",\"AnotherActivity\": \"True\"},\"to\" : \"" + DevieToken + "\"}";
                    streamWriter.Write(json);
                    streamWriter.Flush();
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    result = streamReader.ReadToEnd();
                }

                // return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        private string ApiMapKey()
        {
            WebConfig wc     = new WebConfig();
            string    MapKey = wc.AppSettings("ApiMapKey").ToString();

            return(MapKey);
        }
Ejemplo n.º 5
0
 private bool CreateTCPClient()
 {
     try
     {
         WebConfig wc        = new WebConfig();
         string    TcpServer = wc.AppSettings("TcpServerIP");
         int       TcpPort   = Convert.ToInt32(wc.AppSettings("TcpPortNumber"));
         tcpclnt = new TcpClient();
         tcpclnt.ConnectAsync(TcpServer, TcpPort).Wait();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
        public Response ApproveAppRequest(Int64 AppId, Int64 UserId)
        {
            Response r = new Response();

            try
            {
                FireBase           fb          = new FireBase();
                WebConfig          wc          = new WebConfig();
                string             FirebaseKey = wc.AppSettings("AirViewStore");
                Sec_UserSettingsDL usd         = new Sec_UserSettingsDL();
                bool Result = usd.Manage("Set_IsRequestApproved", UserId, AppId, AppId.ToString(), null);

                if (Result)
                {
                    var dt = usd.GetDataTable("Get_UserAppToken", UserId.ToString(), AppId.ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        dynamic result = fb.SendNotification(FirebaseKey, dt.Rows[0]["Token"].ToString(), "{ \"EmailPIN\": \"" + dt.Rows[0]["EmailPIN"].ToString() + "\", \"MobilePIN\": \"" + dt.Rows[0]["MobilePIN"].ToString() + "\"}");

                        r.Status  = "success";
                        r.Message = "success";
                        r.Value   = result;
                    }
                    else
                    {
                        r.Status  = "error";
                        r.Message = "Device not found.";
                    }
                }
                else
                {
                    r.Status  = "error";
                    r.Message = "Request not fund.";
                }
            }
            catch (Exception ex)
            {
                r.Status  = "error";
                r.Message = ex.Message;
            }

            return(r);
        }
Ejemplo n.º 7
0
        public void SendNotification(FM_Tracker_Alarms modelBind, string Vreg, int VID, int AssignTo)
        {
            /* == Insert Notification When Create New Vehicle Start == */
            AL_SetNotification DumyObject = new AL_SetNotification();
            AL_GetNotification UserNotify = new AL_GetNotification();
            AL_AlertBL         AlertModel = new AL_AlertBL();

            string AlarmDescriptions = GetDescription(modelBind.AlrmCodes);

            WebConfig wc = new WebConfig();
            string    UserIDForNotication = wc.AppSettings("NotificationUserID");

            DumyObject.AlertConfigId    = 1005;
            DumyObject.EntityId         = VID;
            DumyObject.Notification     = "Car:" + Vreg + " generates " + AlarmDescriptions + " Alarm, current value: " + modelBind.CurrentVal;
            DumyObject.AlertRecieverId  = 29;                                   //11; //AssignTo;
            DumyObject.UserId           = Convert.ToInt32(UserIDForNotication); //12;//(int)ViewBag.UserId;
            DumyObject.IsPushAlertSent  = 1;
            DumyObject.IsPushAlertRead  = 0;
            DumyObject.IsEmailAlertSent = 0;
            //sendEmail();

            NotificationHub SRNotificationHub = new NotificationHub();
            AL_Notification ReadNotification  = new AL_Notification();

            ReadNotification.SentTo = "11";

            /* == Send Alerts based on Users == */
            List <AL_GetNotification> ModelResultReceiver = AlertModel.SendNotification("InsertNotification", DumyObject);

            for (var x = 0; x < ModelResultReceiver.Count; x++)
            {
                UserNotify.AlertRecieverId = ModelResultReceiver[x].AlertRecieverId;
                List <AL_GetNotification> ModelResult = AlertModel.GetNotification("NotificationBell", UserNotify);
                var json = JsonConvert.SerializeObject(ModelResult);
                SRNotificationHub.SendNotification(ModelResultReceiver[x].AlertRecieverId.ToString(), json);
            }
            /* == Insert Notification When Create New Vehicle End == */
        }
Ejemplo n.º 8
0
        public ActionResult Index(int id = 0)
        {
            if (id == 0)
            {
                return(RedirectToAction("Index", "Dashboard"));
            }

            string ModuleKeyCode = "MD_SITE";
            var    ProjectId     = TemplatesBL.ToList("GetProjectIdBySiteId", id.ToString()).FirstOrDefault();

            if (ProjectId != null)
            {
                var templateData = TemplatesBL.ToList("IsTemplateExist", ModuleKeyCode).Where(x => x.ProjectId == ProjectId?.ProjectId).FirstOrDefault();
                if (templateData != null && ProjectId != null)
                {
                    return(Redirect($"/Project/Template/Dashboard?Id={templateData.TemplateId}&ProjectId={templateData.ProjectId}"));
                }
            }

            ViewBag.SiteId = id;
            AD_DefinationBL db = new AD_DefinationBL();

            ViewBag.WoStatus = db.ToList("WO Status");
            WebConfig wc = new WebConfig();

            ViewBag.domain = wc.AppSettings("Domain");
            AV_GetSiteDashboardInfoBL sdb = new AV_GetSiteDashboardInfoBL();
            var rec = sdb.GetDataSet(id, 0, 0, 0, 0, "Dashboard_Site_All");

            ViewBag.PingThroughtputChart = rec.PingThroughtput;
            ViewBag.DLThroughtputChart   = rec.DLThroughtput;
            ViewBag.ULThroughtputChart   = rec.ULThroughtput;

            ViewBag.GmapsKey = WebConfigurationManager.AppSettings["ApiMapKey"];
            return(View(rec));
        }
Ejemplo n.º 9
0
        public JsonResult Movement(List <AD_UEMovement> mov, string UEStatus)
        {
            Response res = new Response();

            try
            {
                AD_UEMovementBL ueb = new AD_UEMovementBL();

                foreach (var item in mov)
                {
                    ueb.Manage(UEStatus, item);
                }

                //------------------------------
                if (UEStatus == "Issue")
                {
                    long UEId   = mov.Select(x => x.UEId).Single();
                    long UserId = mov.Select(x => x.UserId).Single();

                    AD_UserEquipmentsBL uebl = new AD_UserEquipmentsBL();
                    AD_UserEquipment    uEqu = uebl.ToSingle("ById", UEId.ToString());

                    Sec_UserBL u            = new Sec_UserBL();
                    Sec_User   usr          = u.Single("ById", UserId.ToString());
                    WebConfig  wc           = new WebConfig();
                    string     UeModel      = uEqu.Model;
                    string     Manufacturer = uEqu.Manufacturer;
                    string     SerialNo     = uEqu.SerialNo;

                    string AVStoreURL = wc.AppSettings("AVStoreURL");

                    string Url = "<a href=" + AVStoreURL + ">AirView Store</a>";

                    string UserName = usr.UserName;
                    string ToEmail  = usr.Email;

                    string Subject = "UE Device Issued";
                    string Body    = "<h1>Hi, " + UserName + "</h1>" +
                                     "<p>A new device is issued to your account.</p>" +
                                     "<table border=" + 1 + " cellpadding=" + 2 + " cellspacing=" + 0 + " width = " + 400 + ">" +
                                     "<tr bgcolor='#F5F5F5'><td><strong>Model</strong></td><td>" + UeModel + "</td></tr>" +
                                     "<tr bgcolor='#F5F5F5'><td><strong>Manufacturer</strong></td><td>" + Manufacturer + "</td></tr>" +
                                     "<tr bgcolor='#F5F5F5'><td><strong>SerialNo</strong></td><td>" + SerialNo + "</td></tr>" +
                                     "</table>" +
                                     "<p>Please download and install AirView Store by clicking here: " + Url + "</p>";


                    Thread thread = new Thread(() => SendEmail(Subject, ToEmail, Body));
                    thread.Start();

                    //-----------------------------
                }


                res.Status  = "success";
                res.Message = "save successfully";
            }
            catch (Exception ex)
            {
                res.Status  = "danger";
                res.Message = ex.Message;
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }