Esempio n. 1
0
        /// <summary>
        /// Delete All Blocker Records
        /// </summary>
        public Boolean DeleteBookmarks(string licenseId, int?deviceid = null, string date = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var maxDate = DateTime.MinValue;
                if (date != null)
                {
                    maxDate = DateTime.ParseExact(date, "ddMMyyyy", CultureInfo.InvariantCulture).AddDays(1);
                }
                var removing = context.CustomerBookMarks.Where(x => x.LicenseId == licenseId &&
                                                               (deviceid == null || x.DeviceId == deviceid) &&
                                                               (date == null || x.Created < maxDate));
                foreach (var customerBookmark in removing)
                {
                    context.CustomerBookMarks.Remove(customerBookmark);
                }

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create New Record
        /// </summary>
        public bool InsertBlocker(string licenseId, int childid, int deviceid, string blocker)
        {
            var customerBlocker = new CustomerBlocker
            {
                LicenseId = licenseId,
                ChildId   = childid,
                DeviceId  = deviceid,
                Obs       = "",
                Blocker   = blocker,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerBlockers.Add(customerBlocker);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create New Blocker Record
        /// </summary>
        public bool InsertBookmarks(string licenseId, int childid, int deviceid, string bookmarks)
        {
            var customerBookmark = new CustomerBookmark
            {
                LicenseId = licenseId,
                ChildId   = childid,
                DeviceId  = deviceid,
                Obs       = string.Empty,
                BookMarks = bookmarks,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerBookMarks.Add(customerBookmark);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Update IsEmailVerified flag to True
        /// </summary>
        public Customer ActivateEmail(CustomerData customerData)
        {
            using (var context = new CustomerInfoRepository())
            {
                var user = context.Customers.FirstOrDefault(x => x.LicenseId == customerData.LicenseId);
                if (user != null)
                {
                    user.Updated         = DateTime.UtcNow;
                    user.IsEmailVerified = true;

                    try
                    {
                        context.SaveChanges();
                        return(user);
                    }
                    catch (Exception)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Create New RDC Record
        /// </summary>
        public bool InsertRemoteView(string licenseId, int childid, int deviceid, string snapshotlocation,
                                     byte[] imgtostore, byte[] thumbnail)
        {
            var remoteView = new Rdc
            {
                LicenseId         = licenseId,
                ChildId           = childid,
                DeviceId          = deviceid,
                SnapshotLocaltion = snapshotlocation,
                Snapshot          = imgtostore,
                Thumbnail         = thumbnail,
                Created           = DateTime.UtcNow,
                Updated           = DateTime.UtcNow,
                Version           = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.RemoteViews.Add(remoteView);

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean customerslogs_Emails(string from, string to, string body, Boolean result)
        {
            var customerLogsEmail = new CustomerLogsEmails
            {
                From    = from,
                To      = to,
                Body    = body,
                Result  = result,
                Created = DateTime.UtcNow,
                Updated = DateTime.UtcNow,
                Version = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerLogsEmails.Add(customerLogsEmail);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
        /// <summary>
        /// Create New RDC Record
        /// </summary>
        public bool InsertRemoteView(string licenseId, int childid, int deviceid, string snapshotlocation,
            byte[] imgtostore, byte[] thumbnail)
        {
            var remoteView = new Rdc
                             {
                                 LicenseId = licenseId,
                                 ChildId = childid,
                                 DeviceId = deviceid,
                                 SnapshotLocaltion = snapshotlocation,
                                 Snapshot = imgtostore,
                                 Thumbnail = thumbnail,
                                 Created = DateTime.UtcNow,
                                 Updated = DateTime.UtcNow,
                                 Version = "1.0"
                             };

            using (var context = new CustomerInfoRepository())
            {
                context.RemoteViews.Add(remoteView);

                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean InsertInstallerLog(string result, string license, string type, string remoteIp, string step, string message, out int?objId)
        {
            objId = null;
            var installerLog = new InstallerLog
            {
                Result    = result,
                LicenseId = license,
                Type      = type,
                RemoteIp  = remoteIp,
                Step      = step,
                Message   = message,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.InstallerLogs.Add(installerLog);
                try
                {
                    context.SaveChanges();
                    objId = installerLog.Id;
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Update OnlineTime Record
        /// </summary>
        public OnlineTime UpdateOnlineTime(string licenseid, int childid, int deviceid, string onlineTime, string onlinewebTime)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.OnlineTimes
                               .SingleOrDefault(x => x.LicenseId == licenseid && x.DeviceId == deviceid);

                if (updating != null)
                {
                    updating.Updated       = DateTime.UtcNow;
                    updating.Time          = onlineTime ?? "";
                    updating.OnlineWebTime = onlinewebTime ?? "";

                    try
                    {
                        context.SaveChanges();
                        return(updating);
                    }
                    catch (Exception)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Delete All CustomersAlerts Records
        /// </summary>
        public Boolean DeleteCustomersAlerts(string licenseId, int?alertId = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var deletingItem = context.CustomerAlerts
                                   .SingleOrDefault(x => x.LicenseId == licenseId && (alertId == null || x.Id == alertId));

                if (deletingItem != null)
                {
                    try
                    {
                        context.CustomerAlerts.Remove(deletingItem);
                        context.SaveChanges();
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Create New GPSLocation Record
        /// </summary>
        public bool InsertGPSLocation(string licenseId, int childid, int deviceid, string gpsLocation)
        {
            var location = new GpsLocation
            {
                LicenseId = licenseId,
                ChildId   = childid,
                DeviceId  = deviceid,
                Obs       = "",
                Location  = gpsLocation,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerGpsLocations.Add(location);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Create New OnlineTime Record
        /// </summary>
        public bool InsertOnlineTime(string licenseid, int childid, int deviceid, string onlineTime, string onlinewebTime)
        {
            var entity = new OnlineTime
            {
                LicenseId     = licenseid,
                ChildId       = childid,
                DeviceId      = deviceid,
                Obs           = "",
                Time          = onlineTime,
                OnlineWebTime = onlinewebTime,
                Created       = DateTime.UtcNow,
                Updated       = DateTime.UtcNow,
                Version       = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.OnlineTimes.Add(entity);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Create New CallHistory Record
        /// </summary>
        public bool InsertCallHistory(string customerid, int childid, int deviceid, string number, string type, string duration, string name, string date)
        {
            var callHistory = new CallHistory
            {
                LicenseId = customerid,
                ChildId   = childid,
                DeviceId  = deviceid,
                Obs       = "",
                Number    = AESHelper.Encrypt(number),
                Duration  = duration,
                Name      = name,
                Date      = date,
                Type      = type,                 //InBound or OutBound
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerCallHistory.Add(callHistory);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Delete All RDC Records
        /// </summary>
        public bool DeleteRemoteView(string licenseId, int?deviceid = null, string date = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var endDate  = DateTime.ParseExact(date, "ddMMyyyy", CultureInfo.InvariantCulture).AddDays(1);
                var removing = context.RemoteViews.Where(x => x.LicenseId == licenseId &&
                                                         (deviceid == null || x.DeviceId == deviceid) &&
                                                         (date == null || x.Created < endDate)
                                                         );
                foreach (var rdc in removing)
                {
                    context.RemoteViews.Remove(rdc);
                }

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Create New SMSMMS Record
        /// </summary>
        public bool InsertSMSMMS(string licenseId, int childid, int deviceid, string type, string number, string msgtolog, string date)
        {
            var customerSmsmms = new CustomerSmsmms
            {
                LicenseId = licenseId,
                ChildId   = childid,
                DeviceId  = deviceid,
                Obs       = "",
                Smsmms    = AESHelper.Encrypt(msgtolog),
                Number    = AESHelper.Encrypt(number),
                MsgDate   = date,
                Type      = type,                         //InBound or OutBound
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerSmsmmss.Add(customerSmsmms);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean InsertLog(string licenseId, string actionId, string description)
        {
            var log = new Log
            {
                LicenseId    = licenseId,
                Action       = actionId,
                Descrtiption = description,
                Created      = DateTime.UtcNow,
                Updated      = DateTime.UtcNow,
                Version      = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.Logs.Add(log);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Insert Customer Alerts Logs
        /// </summary>
        public Boolean InsertCustomerAlert(string licenseId, int deviceId, string msg, string severity, out int?objId)
        {
            objId = null;
            var customalerts = new CustomerAlert
            {
                LicenseId = licenseId,
                DeviceId  = deviceId,
                Obs       = "",
                Msg       = msg,
                Severity  = severity,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerAlerts.Add(customalerts);
                try
                {
                    context.SaveChanges();
                    objId = customalerts.Id;
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
        /// <summary>
        /// Delete All RDC Records 
        /// </summary>
        public bool DeleteRemoteView(string licenseId, int? deviceid = null, string date = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var endDate = DateTime.ParseExact(date, "ddMMyyyy", CultureInfo.InvariantCulture).AddDays(1);
                var removing = context.RemoteViews.Where(x => x.LicenseId == licenseId
                                                                         && (deviceid == null || x.DeviceId == deviceid)
                                                                         && (date == null || x.Created < endDate)
                                                         );
                foreach (var rdc in removing)
                {
                    context.RemoteViews.Remove(rdc);
                }

                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Create New Child
        /// </summary>
        public Boolean InsertChild(ChildData childData)
        {
            var child = new Child
            {
                LicenseId = childData.LicenseId,
                Name      = childData.Name,
                Avatar    = childData.Avatar,
                Obs       = childData.Obs,
                Category  = childData.Category,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.Childrens.Add(child);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Create New History Record
        /// </summary>
        public bool InsertHistory(string licenseId, int childid, int deviceid, string history)
        {
            var customerHistory = new CustomerHistory
            {
                LicenseId = licenseId,
                ChildId   = childid,
                DeviceId  = deviceid,
                Obs       = string.Empty,
                History   = history,
                Created   = DateTime.UtcNow,
                Updated   = DateTime.UtcNow,
                Version   = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerHistories.Add(customerHistory);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Delete All AnalyticsExceptions Records
        /// </summary>
        public Boolean DeleteAnalyticsExceptions(string licenseId)
        {
            using (var context = new CustomerInfoRepository())
            {
                var deletingItem = context.ExceptionLogs
                                   .SingleOrDefault(x => x.LicenseId == licenseId);

                if (deletingItem != null)
                {
                    try
                    {
                        context.ExceptionLogs.Remove(deletingItem);
                        context.SaveChanges();
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 22
0
        public Boolean InsertDevice(ChildDevices childDevices)
        {
            // define defaults blocked classes
            if (childDevices.BlockedURLs == null)
            {
                childDevices.BlockedURLs = ConfigurationManager.AppSettings["DefaultBlockedURLs"];
            }

            var device = new Device
            {
                LicenseId           = childDevices.LicenseId,
                TbpId               = childDevices.Tbpid,
                Name                = childDevices.Name,
                Avatar              = childDevices.Avatar,
                OnlineTimeFrames    = childDevices.OnlineTimeFrames,
                OnlineWebTimeFrames = childDevices.OnlineWebTimeFrames,
                BlockedUrls         = childDevices.BlockedURLs,
                Obs          = "",
                Created      = DateTime.UtcNow,
                Updated      = DateTime.UtcNow,
                Version      = "1.0",
                Type         = childDevices.Type,
                ChildDevices = new Collection <ChildDevice>
                {
                    new ChildDevice
                    {
                        ChildId = childDevices.ChildId
                    }
                }
            };

            using (var context = new CustomerInfoRepository())
            {
                context.Devices.Add(device);
                try
                {
                    context.SaveChanges();
                }
                catch (Exception)
                {
                    return(false);
                }
            }

            var repository = new CustomerRepository();

            repository.InsertBlocker(childDevices.LicenseId, childDevices.ChildId, device.Id, childDevices.BlockedURLs);
            repository.InsertOnlineTime(childDevices.LicenseId, childDevices.ChildId, device.Id, childDevices.OnlineTimeFrames, childDevices.OnlineWebTimeFrames);

            return(true);
        }
Esempio n. 23
0
        /// <summary>
        /// Update Blocker Record
        /// </summary>
        public CustomerBlocker UpdateBlocker(string licenseId, int childid, int deviceid, string blocker)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updateing =
                    context.CustomerBlockers.FirstOrDefault(x => x.LicenseId == licenseId && x.DeviceId == deviceid);

                if (updateing == null)
                {
                    return(null);
                }

                updateing.Updated = DateTime.UtcNow;
                updateing.Blocker = blocker;

                context.SaveChanges();
                return(updateing);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Update New Child
        /// </summary>
        public object UpdateChild(ChildData childData)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.Childrens.FirstOrDefault(x => x.Id == childData.Id);
                if (updating != null)
                {
                    updating.Updated = DateTime.UtcNow;
                    if (childData.Name != null)
                    {
                        updating.Name = childData.Name;
                    }
                    if (childData.Avatar != null)
                    {
                        updating.Avatar = childData.Avatar;
                    }
                    if (childData.Obs != null)
                    {
                        updating.Obs = childData.Obs;
                    }
                    if (childData.Category != null)
                    {
                        updating.Category = childData.Category;
                    }

                    try
                    {
                        context.SaveChanges();
                        return(updating);
                    }
                    catch (Exception)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Delete Blocker Records
        /// </summary>
        public Boolean DeleteBlocker(string licenseId, int?deviceid = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var deleting = context.CustomerBlockers.Where(x => x.LicenseId == licenseId && (deviceid == null || x.DeviceId == deviceid));

                foreach (var customerBlocker in deleting)
                {
                    context.CustomerBlockers.Remove(customerBlocker);
                }

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
        /// <summary>
        /// Create New Customer
        /// </summary>
        public Boolean InsertCustomer(CustomerData customerData, out string licenseId)
        {
            var customer = new Customer
                           {
                               LicenseId = customerData.LicenseId,
                               FirstName = customerData.FirstName,
                               LastName = customerData.LastName,
                               DateOfBirth = customerData.DateOfBirth,
                               Email = AESHelper.Encrypt(customerData.Email),
                               IsEmailVerified = false,
                               Timezone = customerData.Timezone,
                               Hashpass = AESHelper.Encrypt(customerData.HashPass),
                               PaymentProfile = customerData.PaymentProfile,
                               Expires = customerData.Expires,
                               Obs = customerData.Obs,
                               Status = customerData.Status,
                               Type = customerData.Type,
                               Created = DateTime.UtcNow,
                               Updated = DateTime.UtcNow,
                               Version = "1.0"
                           };

            using (var context = new CustomerInfoRepository())
            {
                context.Customers.Add(customer);
                try
                {
                    context.SaveChanges();
                    licenseId = customerData.LicenseId;
                    return true;
                }
                catch (Exception)
                {
                    licenseId = "";
                    return false;
                }
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Create New Customer
        /// </summary>
        public Boolean InsertCustomer(CustomerData customerData, out string licenseId)
        {
            var customer = new Customer
            {
                LicenseId       = customerData.LicenseId,
                FirstName       = customerData.FirstName,
                LastName        = customerData.LastName,
                DateOfBirth     = customerData.DateOfBirth,
                Email           = AESHelper.Encrypt(customerData.Email),
                IsEmailVerified = false,
                Timezone        = customerData.Timezone,
                Hashpass        = AESHelper.Encrypt(customerData.HashPass),
                PaymentProfile  = customerData.PaymentProfile,
                Expires         = customerData.Expires,
                Obs             = customerData.Obs,
                Status          = customerData.Status,
                Type            = customerData.Type,
                Created         = DateTime.UtcNow,
                Updated         = DateTime.UtcNow,
                Version         = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.Customers.Add(customer);
                try
                {
                    context.SaveChanges();
                    licenseId = customerData.LicenseId;
                    return(true);
                }
                catch (Exception)
                {
                    licenseId = "";
                    return(false);
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Delete OnlineTime Records
        /// </summary>
        public Boolean DeleteOnlineTime(string licenseId, int?deviceid = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var removing = context.OnlineTimes
                               .Where(x => x.LicenseId == licenseId && (deviceid == null || x.DeviceId == deviceid)).ToArray();

                foreach (var onlineTime in removing)
                {
                    context.OnlineTimes.Remove(onlineTime);
                }

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 29
0
 /// <summary>
 /// Delete New Device
 /// </summary>
 public Boolean DeleteDevice(string licenseId, int?id = null)
 {
     using (var context = new CustomerInfoRepository())
     {
         var deleting = context.Devices.FirstOrDefault(x => x.LicenseId == licenseId && (id == null || x.Id == id));
         if (deleting != null)
         {
             context.Devices.Remove(deleting);
             try
             {
                 context.SaveChanges();
                 return(true);
             }
             catch (Exception)
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 30
0
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean InsertExceptionLog(SPCServices.ExceptionHandling.ExceptionObj onewEx)
        {
            var exceptionLog = new ExceptionLog
            {
                LicenseId      = onewEx.LicenseId,
                Environment    = onewEx.Environment,
                Type           = onewEx.Type,
                RemoteIp       = onewEx.remoteIP,
                Exception      = onewEx.Exception,
                OsName         = onewEx.OsName,
                OsEdition      = onewEx.OsEdition,
                Sp             = onewEx.SP,
                Processor      = onewEx.Processor,
                Osbits         = onewEx.OSBits,
                SpcAppVersion  = onewEx.SPCAppVersion,
                Browser        = onewEx.Browser,
                BrowserVersion = onewEx.BrowserVersion,
                Created        = DateTime.UtcNow,
                Updated        = DateTime.UtcNow,
                Version        = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.ExceptionLogs.Add(exceptionLog);
                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Esempio n. 31
0
 /// <summary>
 /// Delete New Customer
 /// </summary>
 public Boolean DeleteCustomer(string licenseId)
 {
     using (var context = new CustomerInfoRepository())
     {
         var deleting = context.Customers.FirstOrDefault(x => x.LicenseId == licenseId);
         if (deleting != null)
         {
             try
             {
                 context.Customers.Remove(deleting);
                 context.SaveChanges();
                 return(true);
             }
             catch (Exception)
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
 }
        public Customer UpdateCustomer(CustomerData customerData)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.Customers.FirstOrDefault(x => x.LicenseId == customerData.LicenseId);
                if (updating != null)
                {
                    if (customerData.FirstName != null) updating.FirstName = customerData.FirstName;
                    if (customerData.LastName != null) updating.LastName = customerData.LastName;
                    if (customerData.Email != null) updating.Email = AESHelper.Encrypt(customerData.Email);
                    if (customerData.Timezone != null) updating.Timezone = customerData.Timezone;
                    if (customerData.HashPass != null) updating.Hashpass = AESHelper.Encrypt(customerData.HashPass);
                    if (customerData.PaymentProfile != null) updating.PaymentProfile = customerData.PaymentProfile;
                    if (customerData.Expires != DateTime.MinValue) updating.Expires = customerData.Expires;
                    if (customerData.DateOfBirth != null) updating.DateOfBirth = customerData.DateOfBirth;
                    if (customerData.Obs != null) updating.Obs = customerData.Obs;
                    if (customerData.Status != null) updating.Status = customerData.Status;
                    if (customerData.Type != null) updating.Type = customerData.Type;

                    try
                    {
                        context.SaveChanges();
                        return updating;
                    }
                    catch (Exception)
                    {
                        return null;
                    }
                }
                else
                {
                    return null;
                }
            }
        }
        /// <summary>
        /// Delete All AnalyticsExceptions Records 
        /// </summary>
        public Boolean DeleteAnalyticsExceptions(string licenseId)
        {
            using (var context = new CustomerInfoRepository())
            {
                var deletingItem = context.ExceptionLogs
                    .SingleOrDefault(x => x.LicenseId == licenseId);

                if (deletingItem != null)
                {
                    try
                    {
                        context.ExceptionLogs.Remove(deletingItem);
                        context.SaveChanges();
                        return true;
                    }
                    catch (Exception)
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Delete All CustomersAlerts Records 
        /// </summary>
        public Boolean DeleteCustomersAlerts(string licenseId, int? alertId = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var deletingItem = context.CustomerAlerts
                    .SingleOrDefault(x => x.LicenseId == licenseId && (alertId == null || x.Id == alertId));

                if (deletingItem != null)
                {
                    try
                    {
                        context.CustomerAlerts.Remove(deletingItem);
                        context.SaveChanges();
                        return true;
                    }
                    catch (Exception)
                    {
                        return false;
                    }
                }
                else
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Delete OnlineTime Records 
        /// </summary>
        public Boolean DeleteOnlineTime(string licenseId, int? deviceid = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var removing = context.OnlineTimes
                    .Where(x => x.LicenseId == licenseId && (deviceid == null || x.DeviceId == deviceid)).ToArray();

                foreach (var onlineTime in removing)
                {
                    context.OnlineTimes.Remove(onlineTime);
                }

                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Create New OnlineTime Record
        /// </summary>
        public bool InsertOnlineTime(string licenseid, int childid, int deviceid, string onlineTime, string onlinewebTime)
        {
            var entity = new OnlineTime
                             {
                                 LicenseId = licenseid,
                                 ChildId = childid,
                                 DeviceId = deviceid,
                                 Obs = "",
                                 Time = onlineTime,
                                 OnlineWebTime = onlinewebTime,
                                 Created = DateTime.UtcNow,
                                 Updated = DateTime.UtcNow,
                                 Version = "1.0"
                             };

            using (var context = new CustomerInfoRepository())
            {
                context.OnlineTimes.Add(entity);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
 /// <summary>
 /// Delete New Customer
 /// </summary>
 public Boolean DeleteCustomer(string licenseId)
 {
     using (var context = new CustomerInfoRepository())
     {
         var deleting = context.Customers.FirstOrDefault(x => x.LicenseId == licenseId);
         if (deleting != null)
         {
             try
             {
                 context.Customers.Remove(deleting);
                 context.SaveChanges();
                 return true;
             }
             catch (Exception)
             {
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
 }
        /// <summary>
        /// Update New Device
        /// </summary>
        public Device UpdateDevice(ChildDevices childDevices)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.Devices.SingleOrDefault(x => x.Id == childDevices.Id);
                if (updating != null)
                {
                    updating.Updated = DateTime.UtcNow;

                    foreach (var childDevice in updating.ChildDevices.ToArray())
                    {
                        context.ChildDevices.Remove(childDevice);
                    }

                    var newChildDevice = new ChildDevice
                                 {
                                     DeviceId = updating.Id,
                                     ChildId = childDevices.ChildId
                                 };
                    context.ChildDevices.Add(newChildDevice);
                    updating.ChildDevices.Add(newChildDevice);
                    if (childDevices.Name != null) updating.Name = childDevices.Name;
                    if (childDevices.Avatar != null) updating.Avatar = childDevices.Avatar;
                    if (childDevices.OnlineTimeFrames != null) updating.OnlineTimeFrames = childDevices.OnlineTimeFrames;
                    if (childDevices.OnlineWebTimeFrames != null) updating.OnlineWebTimeFrames = childDevices.OnlineWebTimeFrames;
                    if (childDevices.BlockedURLs != null) updating.BlockedUrls = childDevices.BlockedURLs;
                    if (childDevices.Obs != null) updating.Obs = childDevices.Obs;
                    if (childDevices.Type != null) updating.Type = childDevices.Type;

                    try
                    {
                        context.SaveChanges();
                    }
                    catch (Exception)
                    {
                        return null;
                    }

                    var repository = new CustomerRepository();
                    repository.UpdateBlocker(childDevices.LicenseId, childDevices.ChildId, childDevices.Id, childDevices.BlockedURLs);
                    repository.UpdateOnlineTime(childDevices.LicenseId, childDevices.ChildId, childDevices.Id, childDevices.OnlineTimeFrames, childDevices.OnlineWebTimeFrames);
                    return updating;
                }
                else
                {
                    return null;
                }
            }
        }
        /// <summary>
        /// Create New Customer
        /// </summary>
        public Boolean InsertIPN(NameValueCollection ipn, string call)
        {
            var licenseid = "";

            try
            {
                licenseid = ipn["custom"].Split('|')[0];
            }
            catch
            { }

            var insertingIpn = new Ipn
                               {
                                   LicenseId = licenseid,
                                   Product = ipn["custom"].Split('|').Length > 2 ? ipn["custom"].Split('|')[1] : null,
                                   ReceiverEmail = ipn["receiver_email"],
                                   ReceiverId = ipn["receiver_id"],
                                   ResidenceCountry = ipn["residence_country"],
                                   TestIpn = ipn["test_ipn"],
                                   TransactionSubject = ipn["transaction_subject"],
                                   TxnId = ipn["txn_id"],
                                   TxnType = ipn["txn_type"],
                                   PayerEmail = ipn["payer_email"],
                                   PayerId = ipn["payer_id"],
                                   PayerStatus = ipn["payer_status"],
                                   FirstName = ipn["first_name"],
                                   LastName = ipn["last_name"],
                                   AddressCity = ipn["address_city"],
                                   AddressCountry = ipn["address_country"],
                                   AddressCountryCode = ipn["address_country_code"],
                                   AddressName = ipn["address_name"],
                                   AddressState = ipn["address_state"],
                                   AddressStatus = ipn["address_status"],
                                   AddressStreet = ipn["address_street"],
                                   AddressZip = ipn["address_zip"],
                                   Custom = ipn["custom"],
                                   HandlingAmount = ipn["handling_amount"],
                                   ItemName = ipn["item_name"],
                                   ItemNumber = ipn["item_number"],
                                   McCurrency = ipn["mc_currency"],
                                   McFee = ipn["mc_fee"],
                                   McGross = ipn["mc_gross"],
                                   PaymentDate = ipn["payment_date"],
                                   PaymentFee = ipn["payment_fee"],
                                   PaymentGross = ipn["payment_gross"],
                                   PaymentStatus = ipn["payment_status"],
                                   PaymentType = ipn["payment_type"],
                                   ProtectionEligibility = ipn["protection_eligibility"],
                                   Quantity = ipn["quantity"],
                                   Shipping = ipn["shipping"],
                                   Tax = ipn["tax"],
                                   Call = call,
                                   Created = DateTime.UtcNow,
                                   Updated = DateTime.UtcNow,
                                   Version = "1.0"
                               };

            using (var context = new CustomerInfoRepository())
            {
                context.Ipns.Add(insertingIpn);

                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception exception)
                {
                    SPCServices.ExceptionHandling.SPCExceptionLog.LogSPCException(exception, licenseid);
                    return false;
                }
            }
        }
Esempio n. 40
0
        /// <summary>
        /// Update New Device
        /// </summary>
        public Device UpdateDevice(ChildDevices childDevices)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.Devices.SingleOrDefault(x => x.Id == childDevices.Id);
                if (updating != null)
                {
                    updating.Updated = DateTime.UtcNow;

                    foreach (var childDevice in updating.ChildDevices.ToArray())
                    {
                        context.ChildDevices.Remove(childDevice);
                    }

                    var newChildDevice = new ChildDevice
                    {
                        DeviceId = updating.Id,
                        ChildId  = childDevices.ChildId
                    };
                    context.ChildDevices.Add(newChildDevice);
                    updating.ChildDevices.Add(newChildDevice);
                    if (childDevices.Name != null)
                    {
                        updating.Name = childDevices.Name;
                    }
                    if (childDevices.Avatar != null)
                    {
                        updating.Avatar = childDevices.Avatar;
                    }
                    if (childDevices.OnlineTimeFrames != null)
                    {
                        updating.OnlineTimeFrames = childDevices.OnlineTimeFrames;
                    }
                    if (childDevices.OnlineWebTimeFrames != null)
                    {
                        updating.OnlineWebTimeFrames = childDevices.OnlineWebTimeFrames;
                    }
                    if (childDevices.BlockedURLs != null)
                    {
                        updating.BlockedUrls = childDevices.BlockedURLs;
                    }
                    if (childDevices.Obs != null)
                    {
                        updating.Obs = childDevices.Obs;
                    }
                    if (childDevices.Type != null)
                    {
                        updating.Type = childDevices.Type;
                    }

                    try
                    {
                        context.SaveChanges();
                    }
                    catch (Exception)
                    {
                        return(null);
                    }

                    var repository = new CustomerRepository();
                    repository.UpdateBlocker(childDevices.LicenseId, childDevices.ChildId, childDevices.Id, childDevices.BlockedURLs);
                    repository.UpdateOnlineTime(childDevices.LicenseId, childDevices.ChildId, childDevices.Id, childDevices.OnlineTimeFrames, childDevices.OnlineWebTimeFrames);
                    return(updating);
                }
                else
                {
                    return(null);
                }
            }
        }
        /// <summary>
        /// Update New Child
        /// </summary>
        public object UpdateChild(ChildData childData)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.Childrens.FirstOrDefault(x => x.Id == childData.Id);
                if (updating != null)
                {
                    updating.Updated = DateTime.UtcNow;
                    if (childData.Name != null) updating.Name = childData.Name;
                    if (childData.Avatar != null) updating.Avatar = childData.Avatar;
                    if (childData.Obs != null) updating.Obs = childData.Obs;
                    if (childData.Category != null) updating.Category = childData.Category;

                    try
                    {
                        context.SaveChanges();
                        return updating;
                    }
                    catch (Exception)
                    {
                        return null;
                    }
                }
                else
                {
                    return null;
                }
            }
        }
        /// <summary>
        /// Update Blocker Record 
        /// </summary>
        public CustomerBlocker UpdateBlocker(string licenseId, int childid, int deviceid, string blocker)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updateing =
                    context.CustomerBlockers.FirstOrDefault(x => x.LicenseId == licenseId && x.DeviceId == deviceid);
                    
                if (updateing == null)
                    return null;

                updateing.Updated = DateTime.UtcNow;
                updateing.Blocker = blocker;

                context.SaveChanges();
                return updateing;
            }
        }
        /// <summary>
        /// Create New CallHistory Record
        /// </summary>
        public bool InsertCallHistory(string customerid, int childid, int deviceid, string number, string type, string duration, string name, string date)
        {
            var callHistory = new CallHistory
                                 {
                                     LicenseId = customerid,
                                     ChildId = childid,
                                     DeviceId = deviceid,
                                     Obs = "",
                                     Number = AESHelper.Encrypt(number),
                                     Duration = duration,
                                     Name = name,
                                     Date = date,
                                     Type = type, //InBound or OutBound
                                     Created = DateTime.UtcNow,
                                     Updated = DateTime.UtcNow,
                                     Version = "1.0"
                                 };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerCallHistory.Add(callHistory);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Create New SMSMMS Record
        /// </summary>
        public bool InsertSMSMMS(string licenseId, int childid, int deviceid, string type, string number, string msgtolog, string date)
        {
            var customerSmsmms = new CustomerSmsmms
                                 {
                                     LicenseId = licenseId,
                                     ChildId = childid,
                                     DeviceId = deviceid,
                                     Obs = "",
                                     Smsmms = AESHelper.Encrypt(msgtolog),
                                     Number = AESHelper.Encrypt(number),
                                     MsgDate = date,
                                     Type = type,         //InBound or OutBound
                                     Created = DateTime.UtcNow,
                                     Updated = DateTime.UtcNow,
                                     Version = "1.0"
                                 };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerSmsmmss.Add(customerSmsmms);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Update IsEmailVerified flag to True
        /// </summary>
        public Customer ActivateEmail(CustomerData customerData)
        {
            using (var context = new CustomerInfoRepository())
            {
                var user = context.Customers.FirstOrDefault(x => x.LicenseId == customerData.LicenseId);
                if (user != null)
                {
                    user.Updated = DateTime.UtcNow;
                    user.IsEmailVerified = true;

                    try
                    {
                        context.SaveChanges();
                        return user;
                    }
                    catch (Exception)
                    {
                        return null;
                    }
                }
                else
                {
                    return null;
                }
            }
        }
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean customerslogs_Emails(string from, string to, string body, Boolean result)
        {
            var customerLogsEmail = new CustomerLogsEmails
                                    {
                                        From = from,
                                        To = to,
                                        Body = body,
                                        Result = result,
                                        Created = DateTime.UtcNow,
                                        Updated = DateTime.UtcNow,
                                        Version = "1.0"
                                    };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerLogsEmails.Add(customerLogsEmail);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Update OnlineTime Record 
        /// </summary>
        public OnlineTime UpdateOnlineTime(string licenseid, int childid, int deviceid, string onlineTime, string onlinewebTime)
        {
            using (var context = new CustomerInfoRepository())
            {
                var updating = context.OnlineTimes
                    .SingleOrDefault(x => x.LicenseId == licenseid && x.DeviceId == deviceid);
                
                if (updating != null)
                {
                    updating.Updated = DateTime.UtcNow;
                    updating.Time = onlineTime ?? "";
                    updating.OnlineWebTime = onlinewebTime ?? "";

                    try
                    {
                        context.SaveChanges();
                        return updating;
                    }
                    catch (Exception)
                    {
                        return null;
                    }
                }
                else
                {
                    return null;
                }
            }
        }
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean InsertInstallerLog(string result, string license, string type, string remoteIp, string step, string message, out int? objId)
        {
            objId = null;
            var installerLog = new InstallerLog
                               {
                                   Result = result,
                                   LicenseId = license,
                                   Type = type,
                                   RemoteIp = remoteIp,
                                   Step = step,
                                   Message = message,
                                   Created = DateTime.UtcNow,
                                   Updated = DateTime.UtcNow,
                                   Version = "1.0"
                               };

            using (var context = new CustomerInfoRepository())
            {
                context.InstallerLogs.Add(installerLog);
                try
                {
                    context.SaveChanges();
                    objId = installerLog.Id;
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Create New Child
        /// </summary>
        public Boolean InsertChild(ChildData childData)
        {
            var child = new Child
                        {
                            LicenseId = childData.LicenseId,
                            Name = childData.Name,
                            Avatar = childData.Avatar,
                            Obs = childData.Obs,
                            Category = childData.Category,
                            Created = DateTime.UtcNow,
                            Updated = DateTime.UtcNow,
                            Version = "1.0"
                        };

            using (var context = new CustomerInfoRepository())
            {
                context.Childrens.Add(child);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Delete Blocker Records 
        /// </summary>
        public Boolean DeleteBlocker(string licenseId, int? deviceid = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var deleting = context.CustomerBlockers.Where(x => x.LicenseId == licenseId && (deviceid == null || x.DeviceId == deviceid));

                foreach (var customerBlocker in deleting)
                {
                    context.CustomerBlockers.Remove(customerBlocker);
                }
                
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        public Boolean InsertDevice(ChildDevices childDevices)
        {
            // define defaults blocked classes
            if (childDevices.BlockedURLs == null)
                childDevices.BlockedURLs = ConfigurationManager.AppSettings["DefaultBlockedURLs"];

            var device = new Device
                         {
                             LicenseId = childDevices.LicenseId,
                             TbpId = childDevices.Tbpid,
                             Name = childDevices.Name,
                             Avatar = childDevices.Avatar,
                             OnlineTimeFrames = childDevices.OnlineTimeFrames,
                             OnlineWebTimeFrames = childDevices.OnlineWebTimeFrames,
                             BlockedUrls = childDevices.BlockedURLs,
                             Obs = "",
                             Created = DateTime.UtcNow,
                             Updated = DateTime.UtcNow,
                             Version = "1.0",
                             Type = childDevices.Type,
                             ChildDevices = new Collection<ChildDevice>
                                            {
                                                new ChildDevice
                                                {
                                                    ChildId = childDevices.ChildId
                                                }
                                            }
                         };

            using (var context = new CustomerInfoRepository())
            {
                context.Devices.Add(device);
                try
                {
                    context.SaveChanges();
                }
                catch (Exception)
                {
                    return false;
                }
            }

            var repository = new CustomerRepository();
            repository.InsertBlocker(childDevices.LicenseId, childDevices.ChildId, device.Id, childDevices.BlockedURLs);
            repository.InsertOnlineTime(childDevices.LicenseId, childDevices.ChildId, device.Id, childDevices.OnlineTimeFrames, childDevices.OnlineWebTimeFrames);

            return true;
        }
Esempio n. 52
0
        /// <summary>
        /// Create New Customer
        /// </summary>
        public Boolean InsertIPN(NameValueCollection ipn, string call)
        {
            var licenseid = "";

            try
            {
                licenseid = ipn["custom"].Split('|')[0];
            }
            catch
            { }

            var insertingIpn = new Ipn
            {
                LicenseId          = licenseid,
                Product            = ipn["custom"].Split('|').Length > 2 ? ipn["custom"].Split('|')[1] : null,
                ReceiverEmail      = ipn["receiver_email"],
                ReceiverId         = ipn["receiver_id"],
                ResidenceCountry   = ipn["residence_country"],
                TestIpn            = ipn["test_ipn"],
                TransactionSubject = ipn["transaction_subject"],
                TxnId                 = ipn["txn_id"],
                TxnType               = ipn["txn_type"],
                PayerEmail            = ipn["payer_email"],
                PayerId               = ipn["payer_id"],
                PayerStatus           = ipn["payer_status"],
                FirstName             = ipn["first_name"],
                LastName              = ipn["last_name"],
                AddressCity           = ipn["address_city"],
                AddressCountry        = ipn["address_country"],
                AddressCountryCode    = ipn["address_country_code"],
                AddressName           = ipn["address_name"],
                AddressState          = ipn["address_state"],
                AddressStatus         = ipn["address_status"],
                AddressStreet         = ipn["address_street"],
                AddressZip            = ipn["address_zip"],
                Custom                = ipn["custom"],
                HandlingAmount        = ipn["handling_amount"],
                ItemName              = ipn["item_name"],
                ItemNumber            = ipn["item_number"],
                McCurrency            = ipn["mc_currency"],
                McFee                 = ipn["mc_fee"],
                McGross               = ipn["mc_gross"],
                PaymentDate           = ipn["payment_date"],
                PaymentFee            = ipn["payment_fee"],
                PaymentGross          = ipn["payment_gross"],
                PaymentStatus         = ipn["payment_status"],
                PaymentType           = ipn["payment_type"],
                ProtectionEligibility = ipn["protection_eligibility"],
                Quantity              = ipn["quantity"],
                Shipping              = ipn["shipping"],
                Tax     = ipn["tax"],
                Call    = call,
                Created = DateTime.UtcNow,
                Updated = DateTime.UtcNow,
                Version = "1.0"
            };

            using (var context = new CustomerInfoRepository())
            {
                context.Ipns.Add(insertingIpn);

                try
                {
                    context.SaveChanges();
                    return(true);
                }
                catch (Exception exception)
                {
                    SPCServices.ExceptionHandling.SPCExceptionLog.LogSPCException(exception, licenseid);
                    return(false);
                }
            }
        }
 /// <summary>
 /// Delete New Device
 /// </summary>
 public Boolean DeleteDevice(string licenseId, int? id = null)
 {
     using (var context = new CustomerInfoRepository())
     {
         var deleting = context.Devices.FirstOrDefault(x => x.LicenseId == licenseId && (id == null || x.Id == id));
         if (deleting != null)
         {
             context.Devices.Remove(deleting);
             try
             {
                 context.SaveChanges();
                 return true;
             }
             catch (Exception)
             {
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
 }
        /// <summary>
        /// Create New Record
        /// </summary>
        public bool InsertBlocker(string licenseId, int childid, int deviceid, string blocker)
        {
            var customerBlocker = new CustomerBlocker
                          {
                              LicenseId = licenseId,
                              ChildId = childid,
                              DeviceId = deviceid,
                              Obs = "",
                              Blocker = blocker,
                              Created = DateTime.UtcNow,
                              Updated = DateTime.UtcNow,
                              Version = "1.0"
                          };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerBlockers.Add(customerBlocker);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean InsertLog(string licenseId, string actionId, string description)
        {
            var log = new Log
                      {
                          LicenseId = licenseId,
                          Action = actionId,
                          Descrtiption = description,
                          Created = DateTime.UtcNow,
                          Updated = DateTime.UtcNow,
                          Version = "1.0"
                      };

            using (var context = new CustomerInfoRepository())
            {
                context.Logs.Add(log);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Delete All Blocker Records 
        /// </summary>
        public Boolean DeleteBookmarks(string licenseId, int? deviceid = null, string date = null)
        {
            using (var context = new CustomerInfoRepository())
            {
                var maxDate = DateTime.MinValue;
                if (date != null)
                {
                    maxDate = DateTime.ParseExact(date, "ddMMyyyy", CultureInfo.InvariantCulture).AddDays(1);
                }
                var removing = context.CustomerBookMarks.Where(x => x.LicenseId == licenseId
                                                              && (deviceid == null || x.DeviceId == deviceid)
                                                              && (date == null || x.Created < maxDate));
                foreach (var customerBookmark in removing)
                {
                    context.CustomerBookMarks.Remove(customerBookmark);
                }

                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Create New Logs
        /// </summary>
        public Boolean InsertExceptionLog(SPCServices.ExceptionHandling.ExceptionObj onewEx)
        {
            var exceptionLog = new ExceptionLog
                               {    
                                   LicenseId = onewEx.LicenseId,
                                   Environment = onewEx.Environment,
                                   Type = onewEx.Type,
                                   RemoteIp = onewEx.remoteIP,
                                   Exception = onewEx.Exception,
                                   OsName = onewEx.OsName,
                                   OsEdition = onewEx.OsEdition,
                                   Sp = onewEx.SP,
                                   Processor = onewEx.Processor,
                                   Osbits = onewEx.OSBits,
                                   SpcAppVersion = onewEx.SPCAppVersion,
                                   Browser = onewEx.Browser,
                                   BrowserVersion = onewEx.BrowserVersion,
                                   Created = DateTime.UtcNow,
                                   Updated = DateTime.UtcNow,
                                   Version = "1.0"
                               };

            using (var context = new CustomerInfoRepository())
            {
                context.ExceptionLogs.Add(exceptionLog);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Create New Blocker Record
        /// </summary>
        public bool InsertBookmarks(string licenseId, int childid, int deviceid, string bookmarks)
        {
            var customerBookmark = new CustomerBookmark
                                  {
                                      LicenseId = licenseId,
                                      ChildId = childid,
                                      DeviceId = deviceid,
                                      Obs = string.Empty,
                                      BookMarks = bookmarks,
                                      Created = DateTime.UtcNow,
                                      Updated = DateTime.UtcNow,
                                      Version = "1.0"
                                  };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerBookMarks.Add(customerBookmark);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Insert Customer Alerts Logs
        /// </summary>
        public Boolean InsertCustomerAlert(string licenseId, int deviceId, string msg, string severity, out int? objId)
        {
            objId = null;
            var customalerts = new CustomerAlert
                               {
                                   LicenseId = licenseId,
                                   DeviceId = deviceId,
                                   Obs = "",
                                   Msg = msg,
                                   Severity = severity,
                                   Created = DateTime.UtcNow,
                                   Updated = DateTime.UtcNow,
                                   Version = "1.0"
                               };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerAlerts.Add(customalerts);
                try
                {
                    context.SaveChanges();
                    objId = customalerts.Id;
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
        /// <summary>
        /// Create New GPSLocation Record
        /// </summary>
        public bool InsertGPSLocation(string licenseId, int childid, int deviceid, string gpsLocation)
        {
            var location = new GpsLocation
                           {
                               LicenseId = licenseId,
                               ChildId = childid,
                               DeviceId = deviceid,
                               Obs = "",
                               Location = gpsLocation,
                               Created = DateTime.UtcNow,
                               Updated = DateTime.UtcNow,
                               Version = "1.0"
                           };

            using (var context = new CustomerInfoRepository())
            {
                context.CustomerGpsLocations.Add(location);
                try
                {
                    context.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }