public Entity.BaseResponse <List <Entity.AttributeItem> > DeviceAttributeLookup(Guid deviceId)
        {
            Entity.BaseResponse <List <Entity.AttributeItem> > result = new Entity.BaseResponse <List <Entity.AttributeItem> >();
            try
            {
                _logger.InfoLog(Constants.ACTION_ENTRY, "Device_LatestAttributeValue_Get.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", deviceId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));

                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Device_LatestAttributeValue_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = DataUtils.DataReaderToList <Entity.AttributeItem>(dbDataReader, null);
                    if (parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault() != null)
                    {
                        result.LastSyncDate = Convert.ToString(parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault().Value);
                    }
                }
                _logger.InfoLog(Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
Пример #2
0
 public Entity.SearchResult <List <Entity.AlertResponse> > GetAlertList(Entity.AlertRequest request)
 {
     Entity.SearchResult <List <Entity.AlertResponse> > result = new Entity.SearchResult <List <Entity.AlertResponse> >();
     try
     {
         logger.InfoLog(Constants.ACTION_ENTRY, MethodBase.GetCurrentMethod().Name);
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, "v1");
             parameters.Add(sqlDataAccess.CreateParameter("companyGuid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
             if (!string.IsNullOrEmpty(request.EntityGuid))
             {
                 parameters.Add(sqlDataAccess.CreateParameter("entityGuid", Guid.Parse(request.EntityGuid), DbType.Guid, ParameterDirection.Input));
             }
             if (!string.IsNullOrEmpty(request.DeviceGuid))
             {
                 parameters.Add(sqlDataAccess.CreateParameter("deviceGuid", Guid.Parse(request.DeviceGuid), DbType.Guid, ParameterDirection.Input));
             }
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Alert_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Entity.AlertResponse>(dbDataReader, null);
             result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
         }
         logger.InfoLog(Constants.ACTION_EXIT, MethodBase.GetCurrentMethod().Name);
     }
     catch (Exception ex)
     {
         logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
        public Entity.BaseResponse <List <Entity.DashboardOverviewResponse> > GetStatistics()
        {
            Entity.BaseResponse <List <Entity.DashboardOverviewResponse> > result = new Entity.BaseResponse <List <Entity.DashboardOverviewResponse> >();
            try
            {
                _logger.InfoLog(Constants.ACTION_ENTRY, "GeneratorRepository.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(SolutionConfiguration.CurrentUserId, SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[CompanyStatistics_Get]", CommandType.StoredProcedure, null), parameters.ToArray());

                    result.Data = DataUtils.DataReaderToList <Entity.DashboardOverviewResponse>(dbDataReader, null);
                    if (parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault() != null)
                    {
                        result.LastSyncDate = Convert.ToString(parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault().Value);
                    }
                }
                _logger.InfoLog(Constants.ACTION_EXIT, "GeneratorRepository.Get");
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
 public Entity.SearchResult <List <Model.Crop> > List(Entity.SearchRequest request)
 {
     Entity.SearchResult <List <Model.Crop> > result = new Entity.SearchResult <List <Model.Crop> >();
     try
     {
         _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
             parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("greenHouseGuid", request.GreenHouseId, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Crop_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Model.Crop>(dbDataReader, null);
             result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
         }
         _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     return(result);
 }
Пример #5
0
        public List <Entity.DeviceMaintenanceResponse> GetUpComingList(Entity.DeviceMaintenanceRequest request)
        {
            List <Entity.DeviceMaintenanceResponse> result = new List <Entity.DeviceMaintenanceResponse>();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceMaintenanceRepository.GetUpComingList");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, "v1");
                    parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    if (request.EntityGuid.HasValue)
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("entityGuid", request.EntityGuid.Value, DbType.Guid, ParameterDirection.Input));
                    }
                    if (request.DeviceGuid.HasValue)
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("guid", request.DeviceGuid, DbType.Guid, ParameterDirection.Input));
                    }
                    parameters.Add(sqlDataAccess.CreateParameter("currentDate", request.currentDate, DbType.DateTime, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[DeviceMaintenance_UpComingList]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Entity.DeviceMaintenanceResponse>(dbDataReader, null);
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceMaintenanceRepository.GetUpComingList");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
 public Entity.SearchResult <List <Entity.HardwareKitResponse> > List(Entity.SearchRequest request, bool isAssigned, string companyId)
 {
     Entity.SearchResult <List <Entity.HardwareKitResponse> > result = new Entity.SearchResult <List <Entity.HardwareKitResponse> >();
     try
     {
         logger.InfoLog(Constants.ACTION_ENTRY, "HardwareKitRepository.Get");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
             if (!string.IsNullOrEmpty(companyId))
             {
                 parameters.Add(sqlDataAccess.CreateParameter("companyguid", Guid.Parse(companyId), DbType.Guid, ParameterDirection.Input));
             }
             parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("isAssigned", isAssigned ? 1 : 0, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[HardwareKit_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Entity.HardwareKitResponse>(dbDataReader, null);
             result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
         }
         logger.InfoLog(Constants.ACTION_EXIT, "HardwareKitRepository.Get");
     }
     catch (Exception ex)
     {
         logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
 public List <Entity.CompanyConfig> Get()
 {
     try
     {
         return(_companyConfigRepository.GetAll().Where(e => !e.IsDeleted).Select(p => Mapper.Configuration.Mapper.Map <Entity.CompanyConfig>(p)).ToList());
     }
     catch (Exception ex)
     {
         _logger.InfoLog(Constants.ACTION_EXCEPTION, "CompanyConfig.Get " + ex);
         return(null);
     }
 }
 public void DailyProcess()
 {
     _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     try
     {
         var status = _chartService.TelemetrySummary_DayWise();
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
 }
 public Entity.SearchResult <List <Entity.HardwareKitResponse> > List(Entity.SearchRequest request, bool isAssigned)
 {
     try
     {
         var result = _hardwareKitRepository.List(request, isAssigned, null);
         return(result);
     }
     catch (Exception ex)
     {
         _logger.InfoLog(Constants.ACTION_EXCEPTION, $"HardwareKitService.List, Error: {ex.Message}");
         return(new Entity.SearchResult <List <Entity.HardwareKitResponse> >());
     }
 }
Пример #10
0
        public List <Company> Get()
        {
            List <Entity.Company> result = new List <Entity.Company>();

            try
            {
                result = _companyRepository.GetAll().Where(e => !e.IsDeleted).Select(p => Mapper.Configuration.Mapper.Map <Entity.Company>(p)).ToList();
            }
            catch (Exception ex)
            {
                _logger.InfoLog(Constants.ACTION_EXCEPTION, "CompanyManager.GetCompany" + ex);
            }
            return(result);
        }
Пример #11
0
 public virtual void BeginTransaction()
 {
     _logger.InfoLog(Constants.ACTION_ENTRY, "UnitOfWork.BeginTransaction");
     try
     {
         InTransaction = true;
         _transaction  = DbContext.Database.BeginTransaction();
         _logger.InfoLog(Constants.ACTION_EXIT, "UnitOfWork.BeginTransaction");
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex + ":UnitofWork.BeginTransaction", ex);
         throw;
     }
 }
 public virtual void BeginTransaction()
 {
     _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     try
     {
         InTransaction = true;
         _transaction  = DbContext.Database.BeginTransaction();
         _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
         throw;
     }
 }
        public Model.User Get(string userName)
        {
            var result = new Model.User();

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                _uow.DbContext.User.Where(u => u.Email.Equals(userName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
        public Model.User Get(string userName)
        {
            var result = new Model.User();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "UserRepository.Get");
                _uow.DbContext.User.Where(u => u.Email.Equals(userName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                logger.InfoLog(Constants.ACTION_EXIT, "UserRepository.Get");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
 public Entity.ActionStatus AdminLogin(Entity.LoginRequest request)
 {
     Entity.ActionStatus result = new ActionStatus(true);
     try
     {
         Model.AdminUser adminUser = _adminUserRepository.AdminLogin(request);
         if (adminUser == null)
         {
             result.Success = false;
             result.Message = "No User Found!";
         }
         else if (adminUser == null || !adminUser.Password.Equals(request.Password))
         {
             result.Success = false;
             result.Message = "Invalid credentials.";
         }
         else if (adminUser != null && (!adminUser.IsActive || adminUser.IsDeleted))
         {
             result.Success = false;
             result.Message = "Your account has been deactivated.";
         }
         else
         {
             result.Success = true;
             result.Data    = adminUser;
         }
     }
     catch (Exception ex)
     {
         result.Success = false;
         _logger.InfoLog(Constants.ACTION_EXCEPTION, $"UserManager.Login {ex.Message}");
     }
     return(result);
 }
        public List <Entity.LookupItem> GetLookup(Guid companyId)
        {
            var result = new List <Entity.LookupItem>();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "EntityRepository.GetLookup");
                result = _uow.DbContext.Entity.Where(u => u.CompanyGuid.Equals(companyId) && !u.Guid.Equals(component.helper.SolutionConfiguration.EntityGuid) && u.ParentEntityGuid.Equals(SolutionConfiguration.EntityGuid) && u.IsActive == true && !u.IsDeleted).Select(g => new Entity.LookupItem()
                {
                    Text = g.Name, Value = g.Guid.ToString()
                }).ToList();
                logger.InfoLog(Constants.ACTION_EXIT, "EntityRepository.GetLookup");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
Пример #17
0
 public Entity.ActionStatus TelemetrySummary_DayWise()
 {
     Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
     try
     {
         _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <DbParameter> parameters = new List <DbParameter>();
             sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[TelemetrySummary_DayWise_Add]", CommandType.StoredProcedure, null), parameters.ToArray());
         }
         _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
         actionStatus.Success = false;
         actionStatus.Message = ex.Message;
     }
     return(actionStatus);
 }
Пример #18
0
        public List <Response.EnergyUsageResponse> GetEnergyUsage(Request.ChartRequest request)
        {
            List <Response.EnergyUsageResponse> result = new List <Response.EnergyUsageResponse>();

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("entityguid", request.GreenHouseGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", request.HardwareKitGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Chart_CurrentConsumption]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Response.EnergyUsageResponse>(dbDataReader, null);
                }
                _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
Пример #19
0
 public Entity.SearchResult <List <Model.Role> > List(Entity.SearchRequest request)
 {
     Entity.SearchResult <List <Model.Role> > result = new Entity.SearchResult <List <Model.Role> >();
     try
     {
         logger.InfoLog(Constants.ACTION_ENTRY, "RoleRepository.Get");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
             parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
             System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Role_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Model.Role>(dbDataReader, null);
             //  result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
             var count = parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault();
             if (count != null && !string.IsNullOrWhiteSpace(count.Value.ToString()))
             {
                 result.Count = int.Parse(count.Value.ToString());
             }
             var outPut = parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault();
             if (outPut != null)
             {
                 int outputvalue = int.Parse(outPut.Value.ToString());
                 result.Count = outputvalue < 0 ? outputvalue : result.Count;
             }
         }
         logger.InfoLog(Constants.ACTION_EXIT, "RoleRepository.Get");
     }
     catch (Exception ex)
     {
         logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
Пример #20
0
        public ActionStatus Manage(Entity.AddCompanyRequest request)
        {
            ActionStatus result = new ActionStatus(true);

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("name", request.Name, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("cpid", request.CpId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("address", request.Address, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("countryGuid", request.CountryGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("stateGuid", request.StateGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("city", request.City, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("postalCode", request.PostalCode, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("timezoneGuid", request.TimezoneGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("contactNo", request.ContactNo, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("firstName", request.FirstName, DbType.String, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("lastName", request.LastName, DbType.String, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("userId", request.UserID, DbType.Guid, ParameterDirection.Output));//Email
                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", request.CompanyGuid, DbType.Guid, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("userGuid", request.AdminUserGuid, DbType.Guid, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("greenhouseGuid", request.GreenHouseGuid, DbType.Guid, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("roleGuid", request.RoleGuid, DbType.Guid, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    int intResult = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[Company_AddUpdate]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = int.Parse(parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault().Value.ToString());
                }
                _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
Пример #21
0
        public Entity.SearchResult <List <Entity.AdminRule> > List(Entity.SearchRequest request)
        {
            var isAdmin = false;

            Entity.SearchResult <List <Entity.AdminRule> > result = new Entity.SearchResult <List <Entity.AdminRule> >();
            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "AdminRuleRepository.Get");


                var checkForAdmin = _companyRepository.FindBy(x => x.Guid.Equals(component.helper.SolutionConfiguration.CompanyId)).FirstOrDefault();

                if (checkForAdmin == null)
                {
                    isAdmin = true;
                }
                else
                {
                    isAdmin = false;
                }

                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(SolutionConfiguration.CurrentUserId, request.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("isAdmin", isAdmin, DbType.Boolean, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[AdminRule_List]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Items = DataUtils.DataReaderToList <Entity.AdminRule>(dbDataReader, null);
                    result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
                }
                logger.InfoLog(Constants.ACTION_EXIT, "AdminRuleRepository.Get");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
Пример #22
0
 public Entity.BaseResponse <List <Entity.ZoneLookup> > ZoneLookup(Guid facilityId)
 {
     Entity.BaseResponse <List <Entity.ZoneLookup> > result = new Entity.BaseResponse <List <Entity.ZoneLookup> >();
     try
     {
         _logger.InfoLog(Constants.ACTION_ENTRY, "ZoneLookup.Get");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
             parameters.Add(sqlDataAccess.CreateParameter("parentEntityGuid", facilityId, DbType.Guid, ParameterDirection.Input));
             DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Zone_Lookup]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Data      = DataUtils.DataReaderToList <Entity.ZoneLookup>(dbDataReader, null);
             result.IsSuccess = true;
             result.Message   = "Data Loaded Successfully !!";
         }
         _logger.InfoLog(Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     return(result);
 }
        public List <Entity.DashboardOverviewResponse> GetStatistics()
        {
            List <Entity.DashboardOverviewResponse> result = new List <Entity.DashboardOverviewResponse>();

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(SolutionConfiguration.CurrentUserId, SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[CompanyStatistics_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
                    // DataUtils.DataReaderToObject(dbDataReader, result);
                    result = DataUtils.DataReaderToList <Entity.DashboardOverviewResponse>(dbDataReader, null);
                }
                _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
Пример #24
0
        public Entity.BaseResponse <Entity.DashboardOverviewResponse> GetOverview()
        {
            Entity.BaseResponse <List <Entity.DashboardOverviewResponse> > listResult = new Entity.BaseResponse <List <Entity.DashboardOverviewResponse> >();
            Entity.BaseResponse <Entity.DashboardOverviewResponse>         result     = new Entity.BaseResponse <Entity.DashboardOverviewResponse>();

            try
            {
                listResult = _dashboardrepository.GetStatistics();
                if (listResult.Data.Count > 0)
                {
                    result.IsSuccess    = true;
                    result.Data         = listResult.Data[0];
                    result.LastSyncDate = listResult.LastSyncDate;
                }

                var deviceResult = _generatorService.GetDeviceCounters();

                if (deviceResult.IsSuccess && deviceResult.Data != null)
                {
                    result.Data.TotalDisconnectedGenerators = deviceResult.Data.disConnected;
                    result.Data.TotalGenerators             = deviceResult.Data.total;
                    result.Data.TotalOffGenerators          = 0;
                    result.Data.TotalOnGenerators           = deviceResult.Data.connected;
                }
                else
                {
                    result.Data.TotalDisconnectedGenerators = 0;
                    result.Data.TotalGenerators             = 0;
                    result.Data.TotalOffGenerators          = 0;
                    result.Data.TotalOnGenerators           = 0;
                }
            }
            catch (Exception ex)
            {
                _logger.InfoLog(Constants.ACTION_EXCEPTION, ex);
            }

            return(result);
        }
        public List <Entity.LookupItem> GetLookup(Guid companyId)
        {
            var result = new List <Entity.LookupItem>();

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                result = _uow.DbContext.GreenHouse.Where(u => u.CompanyGuid.Equals(companyId) && !u.Guid.Equals(component.helper.SolutionConfiguration.EntityGuid) && u.IsActive == true && !u.IsDeleted).Select(g => new Entity.LookupItem()
                {
                    Text = g.Name, Value = g.Guid.ToString()
                }).ToList();
                _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
Пример #26
0
 public List <Entity.Generator> Get()
 {
     try
     {
         return(_generatorRepository.GetAll().Where(e => !e.IsDeleted && e.CompanyGuid == SolutionConfiguration.CompanyId).Select(p => Mapper.Configuration.Mapper.Map <Entity.Generator>(p)).ToList());
     }
     catch (Exception ex)
     {
         _logger.InfoLog(Constants.ACTION_EXCEPTION, "GeneratorService.Get " + ex);
         return(null);
     }
 }
Пример #27
0
        public Entity.DeviceDetailModel Get(Guid deviceId)
        {
            Entity.SearchResult <List <Entity.DeviceDetailModel> > listResult = new Entity.SearchResult <List <Entity.DeviceDetailModel> >();
            var result = new Entity.DeviceDetailModel();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceRepository.Get");

                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", deviceId, DbType.Guid, ParameterDirection.Input));
                    System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Device_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
                    listResult.Items = DataUtils.DataReaderToList <Entity.DeviceDetailModel>(dbDataReader, null);
                    if (listResult.Items.Count > 0)
                    {
                        result = listResult.Items[0];
                        result.DeviceMediaFiles = GetMediaFiles(result.Guid.Value, "M");
                        result.DeviceImageFiles = GetMediaFiles(result.Guid.Value, "I");

                        result.DeviceAttributes = _uow.DbContext.DeviceAttribute.Where(u => u.DeviceGuid == deviceId && !u.IsDeleted).Select(g => new Entity.DeviceAttribute()
                        {
                            Guid     = g.Guid,
                            AttrGuid = g.AttrGuid,
                            AttrName = g.AttrName,
                            DispName = g.DisplayName
                        }).ToList();
                    }
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceRepository.Get");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
Пример #28
0
        public Entity.ActionStatus Manage(Entity.AddLocationRequest request)
        {
            Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
            try
            {
                if (request.Guid == null || request.Guid == Guid.Empty)
                {
                    var checkExisting = _locationRepository.FindBy(x => x.Name.Equals(request.Name) && x.IsActive == true && !x.IsDeleted && x.CompanyGuid.Equals(SolutionConfiguration.CompanyId)).FirstOrDefault();
                    if (checkExisting == null)
                    {
                        var addEntityResult = AsyncHelpers.RunSync <IOT.DataResponse <IOT.AddEntityResult> >(() =>
                                                                                                             _iotConnectClient.Entity.Add(Mapper.Configuration.Mapper.Map <IOT.AddEntityModel>(request)));

                        if (addEntityResult != null && addEntityResult.status && addEntityResult.data != null)
                        {
                            request.Guid = Guid.Parse(addEntityResult.data.EntityGuid.ToUpper());
                            var dbLocation = Mapper.Configuration.Mapper.Map <Entity.AddLocationRequest, Model.Location>(request);
                            dbLocation.Guid        = request.Guid;
                            dbLocation.CompanyGuid = component.helper.SolutionConfiguration.CompanyId;
                            dbLocation.CreatedDate = DateTime.Now;
                            dbLocation.CreatedBy   = component.helper.SolutionConfiguration.CurrentUserId;
                            actionStatus           = _locationRepository.Manage(dbLocation);
                            actionStatus.Data      = (Guid)(actionStatus.Data);
                            if (!actionStatus.Success)
                            {
                                _logger.ErrorLog(new Exception($"Location is not added in solution database, Error: {actionStatus.Message}"), this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                                var deleteEntityResult = _iotConnectClient.Entity.Delete(request.Guid.ToString()).Result;
                                if (deleteEntityResult != null && deleteEntityResult.status)
                                {
                                    _logger.ErrorLog(new Exception($"Location is not deleted from iotconnect, Error: {deleteEntityResult.message}"), this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                                    actionStatus.Success = false;
                                    actionStatus.Message = new UtilityHelper().IOTResultMessage(deleteEntityResult.errorMessages);
                                }
                            }
                        }
                        else
                        {
                            _logger.ErrorLog(new Exception($"Location is not added in iotconnect, Error: {addEntityResult.message}"), this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                            actionStatus.Success = false;
                            actionStatus.Message = new UtilityHelper().IOTResultMessage(addEntityResult.errorMessages);
                        }
                    }
                    else
                    {
                        _logger.InfoLog($"Location Already Exist !!");
                        actionStatus.Success = false;
                        actionStatus.Message = "Location Name Already Exists";
                    }
                }
                else
                {
                    var olddbLocation = _locationRepository.FindBy(x => x.Guid.Equals(request.Guid)).FirstOrDefault();
                    if (olddbLocation == null)
                    {
                        throw new NotFoundCustomException($"{CommonException.Name.NoRecordsFound} : Location");
                    }

                    var updateEntityResult = _iotConnectClient.Entity.Update(request.Guid.ToString(), Mapper.Configuration.Mapper.Map <IOT.UpdateEntityModel>(request)).Result;
                    if (updateEntityResult != null && updateEntityResult.status && updateEntityResult.data != null)
                    {
                        var dbLocation = Mapper.Configuration.Mapper.Map(request, olddbLocation);
                        dbLocation.UpdatedDate = DateTime.Now;
                        dbLocation.UpdatedBy   = component.helper.SolutionConfiguration.CurrentUserId;
                        dbLocation.CompanyGuid = component.helper.SolutionConfiguration.CompanyId;
                        actionStatus           = _locationRepository.Manage(dbLocation);
                        actionStatus.Data      = (Guid)actionStatus.Data;
                        if (!actionStatus.Success)
                        {
                            _logger.ErrorLog(new Exception($"Location is not updated in solution database, Error: {actionStatus.Message}"), this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                            actionStatus.Success = false;
                            actionStatus.Message = "Something Went Wrong!";
                        }
                    }
                    else
                    {
                        _logger.ErrorLog(new Exception($"Location is not added in iotconnect, Error: {updateEntityResult.message}"), this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                        actionStatus.Success = false;
                        actionStatus.Message = new UtilityHelper().IOTResultMessage(updateEntityResult.errorMessages);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, "LocationService.Manage " + ex);
                actionStatus.Success = false;
                actionStatus.Message = ex.Message;
            }
            return(actionStatus);
        }
        public Entity.DeviceDetail Get(Guid deviceId)
        {
            List <Entity.DeviceDetail> listResult = new List <Entity.DeviceDetail>();
            var result = new Entity.DeviceDetail();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceRepository.Get");

                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", deviceId, DbType.Guid, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Device_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
                    listResult = DataUtils.DataReaderToList <Entity.DeviceDetail>(dbDataReader, null);
                    if (listResult.Count > 0)
                    {
                        result = listResult[0];
                    }
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceRepository.Get");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
        public Entity.ActionStatus ManageUserWidget(Entity.UserDasboardWidget request)
        {
            try
            {
                if (request.DashboardName.ToLower().Trim().Equals("system default"))
                {
                    return(new Entity.ActionStatus
                    {
                        Success = false,
                        Message = "Dashboard Name Can not be System Default !",
                        Data = null
                    });
                }
                Entity.ActionStatus actionStatus = new Entity.ActionStatus(true);
                var dbUserWidget = Mapper.Configuration.Mapper.Map <Entity.UserDasboardWidget, Model.UserDasboardWidget>(request);
                if (request.Guid == null || request.Guid == Guid.Empty)
                {
                    var checkExisting = _userDashboardWidgetRepository.FindBy(x => x.DashboardName.Equals(request.DashboardName) && x.UserId == component.helper.SolutionConfiguration.CurrentUserId && x.IsActive == true && !x.IsDeleted).FirstOrDefault();
                    if (checkExisting == null)
                    {
                        if (request.IsDefault)
                        {
                            var response = _userDashboardWidgetRepository.FindBy(r => r.IsDefault == true && r.UserId == component.helper.SolutionConfiguration.CurrentUserId).Select(p => Mapper.Configuration.Mapper.Map <Model.UserDasboardWidget>(p)).FirstOrDefault();
                            if (response != null)
                            {
                                response.IsDefault = false;
                                _userDashboardWidgetRepository.Update(response);
                            }
                        }
                        string renderedValues = string.Join(",", request.WidgetsList);
                        dbUserWidget.Guid   = Guid.NewGuid();
                        dbUserWidget.UserId = component.helper.SolutionConfiguration.CurrentUserId;
                        string res = RemoveWhiteSpace(Convert.ToString(renderedValues));
                        dbUserWidget.Widgets     = "[" + res + "]";
                        dbUserWidget.IsActive    = true;
                        dbUserWidget.IsDeleted   = false;
                        dbUserWidget.CreatedDate = DateTime.Now;
                        dbUserWidget.CreatedBy   = component.helper.SolutionConfiguration.CurrentUserId;
                        actionStatus             = _userDashboardWidgetRepository.Insert(dbUserWidget);
                        actionStatus.Data        = Mapper.Configuration.Mapper.Map <Model.UserDasboardWidget, Entity.UserDasboardWidget>(actionStatus.Data);
                    }
                    else
                    {
                        _logger.InfoLog("Dashboard Name Already Exists !!", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                        actionStatus.Success = false;
                        actionStatus.Message = "Dashboard Name Already Exists !!";
                    }
                }
                else
                {
                    var uniqUserWidget = _userDashboardWidgetRepository.GetByUniqueId(x => x.Guid == dbUserWidget.Guid);
                    if (uniqUserWidget == null)
                    {
                        throw new NotFoundCustomException($"{CommonException.Name.NoRecordsFound} : User Widget");
                    }
                    if (!uniqUserWidget.DashboardName.Equals(request.DashboardName.Trim()))
                    {
                        var checkExisting = _userDashboardWidgetRepository.FindBy(x => x.DashboardName.Equals(request.DashboardName) && x.UserId == component.helper.SolutionConfiguration.CurrentUserId && x.IsActive == true && !x.IsDeleted).FirstOrDefault();
                        if (checkExisting != null)
                        {
                            return(new Entity.ActionStatus
                            {
                                Success = false,
                                Message = "Widget already exists!",
                                Data = null
                            });
                        }
                    }

                    if (request.IsDefault && !uniqUserWidget.IsDefault)
                    {
                        var response = _userDashboardWidgetRepository.FindBy(r => r.IsDefault == true && r.Guid != request.Guid && r.UserId == component.helper.SolutionConfiguration.CurrentUserId).Select(p => Mapper.Configuration.Mapper.Map <Model.UserDasboardWidget>(p)).FirstOrDefault();
                        if (response != null)
                        {
                            response.IsDefault = false;
                            _userDashboardWidgetRepository.Update(response);
                        }
                    }

                    if (uniqUserWidget != null)
                    {
                        string renderedValues = string.Join(",", request.WidgetsList);
                        string res            = RemoveWhiteSpace(Convert.ToString(renderedValues));
                        uniqUserWidget.DashboardName = request.DashboardName;
                        uniqUserWidget.Widgets       = "[" + res + "]";
                        uniqUserWidget.IsActive      = request.IsActive;
                        uniqUserWidget.IsDefault     = request.IsDefault;
                        uniqUserWidget.ModifiedDate  = DateTime.Now;
                        uniqUserWidget.ModifiedBy    = component.helper.SolutionConfiguration.CurrentUserId;
                        actionStatus      = _userDashboardWidgetRepository.Update(uniqUserWidget);
                        actionStatus.Data = Mapper.Configuration.Mapper.Map <Model.UserDasboardWidget, Entity.UserDasboardWidget>(actionStatus.Data);
                    }
                    else
                    {
                        return(new Entity.ActionStatus
                        {
                            Success = false,
                            Message = "Widget already exists!",
                            Data = null
                        });
                    }
                }
                return(actionStatus);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                return(new Entity.ActionStatus
                {
                    Success = false,
                    Message = ex.Message
                });
            }
        }