Exemple #1
0
        /// <summary>
        /// Deletes the user views.
        /// </summary>
        /// <param name="uvList">The uv list.</param>
        /// <returns></returns>
        public int DeleteUserViews(string uvList)
        {
            int result;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                List <string> tagIds    = uvList.Split(',').ToList();
                var           userViews = new List <UserView>();
                foreach (var uv in tagIds)
                {
                    int uvId;
                    Int32.TryParse(uv, out uvId);
                    var userView = sdaCloudEntities.UserViews.Where(q => q.UserViewID == uvId).SingleOrDefault();
                    if (userView != null)
                    {
                        userViews.Add(userView);
                    }
                }
                foreach (var userview in userViews)
                {
                    //sdaCloudEntities.DeleteObject(userview);
                }
                result = sdaCloudEntities.SaveChanges();
            }
            return(result);
        }
Exemple #2
0
        public bool AddErrorLogMessage(int userId, int clientId, string errorMessage)
        {
            bool result = false;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    using (var transactionScope = new TransactionScope())
                    {
                        var errorLog = new ErrorLog
                        {
                            ClientID     = clientId,
                            UserID       = userId,
                            ErrorMessage = errorMessage,
                            ProcessDT    = DateTime.UtcNow
                        };
                        sdaCloudEntities.ErrorLogs.AddObject(errorLog);
                        sdaCloudEntities.SaveChanges();
                        transactionScope.Complete();
                    }
                }
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Updates the user.
        /// </summary>
        /// <param name="userDto">The user dto.</param>
        /// <returns></returns>
        public int UpdateUser(UserDto userDto)
        {
            int result;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (var transactionScope = new TransactionScope())
                {
                    var existingUser = sdaCloudEntities.Users.FirstOrDefault(i => i.UserID == userDto.UserId);

                    if (existingUser != null)
                    {
                        existingUser.Administrator  = (userDto.Administrator ? "Y" : "N");
                        existingUser.FirstName      = userDto.FirstName;
                        existingUser.LastName       = userDto.LastName;
                        existingUser.LoginID        = userDto.LoginID;
                        existingUser.ManagerUserID  = userDto.ManagerUserID;
                        existingUser.CloudLastUpdBy = userDto.CloudLastUpdBy;
                        existingUser.CloudLastUpdDT = DateTime.UtcNow;
                    }
                    result = sdaCloudEntities.SaveChanges();
                    transactionScope.Complete();
                }
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Updates the user email sent field.
        /// </summary>
        /// <param name="uList">The u list.</param>
        /// <returns></returns>
        public string UpdateUserEmailSent(string uList)
        {
            string result = string.Empty;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                List <string> tagIds = uList.Split(',').ToList();
                var           users  = new List <User>();
                foreach (var uv in tagIds)
                {
                    int uvId;
                    Int32.TryParse(uv, out uvId);
                    var userView = sdaCloudEntities.Users.Where(q => q.UserID == uvId).SingleOrDefault();
                    if (userView != null)
                    {
                        userView.EmailSent = "Requested";
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(result))
                        {
                            result += ",";
                        }
                        result += uv;
                    }
                }

                sdaCloudEntities.SaveChanges();
            }
            return(result);
        }
Exemple #5
0
        /// <summary>
        /// Gets the user tree by manager.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <returns></returns>
        public List <UserDto> GetUserTreeByManager(UserDto clientId)
        {
            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var existingUsers =
                        sdaCloudEntities.Users.Where(u => u.ClientID == clientId.ClientId && u.DeleteInd == "N").ToList();

                    Mapper.CreateMap <User, UserDto>()
                    .ForMember(dest => dest.CloudLastUpdDT, opt => opt.Ignore())
                    .ForMember(dest => dest.CloudLastUpdBy, opt => opt.Ignore())
                    .ForMember(dest => dest.ManagerUserName, opt => opt.Ignore())
                    .ForMember(dest => dest.Administrator, opt => opt.MapFrom(src => src.Administrator.ToUpper() == "Y"))
                    .ForMember(dest => dest.DeleteInd, opt => opt.MapFrom(src => src.DeleteInd.ToUpper() == "Y"));
                    var peopleVm = Mapper.Map <List <User>, List <UserDto> >(existingUsers);
                    ////Mapper.AssertConfigurationIsValid();

                    var liUsers = new List <UserDto>();
                    GetUserList(clientId.UserId, peopleVm, liUsers);
                    var tUser = peopleVm.FirstOrDefault(u => u.UserId == clientId.UserId);
                    liUsers.Add(tUser);

                    foreach (var u in liUsers)
                    {
                        u.ManagerUserName = peopleVm.Where(v => u.ManagerUserID != null && v.UserId == u.ManagerUserID.Value).Select(v => v.FirstName + " " + v.LastName).FirstOrDefault() ?? "-------";
                    }

                    return(liUsers);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Validates the user.
        /// </summary>
        /// <param name="clientLogin">The client login.</param>
        /// <returns></returns>
        public UserDto ValidateUser(UserDto clientLogin)
        {
            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var myPassword = clientLogin.Password;

                    var existingUser =
                        sdaCloudEntities.Users.FirstOrDefault(
                            i =>
                            i.LoginID == clientLogin.LoginID &&
                            i.Password == myPassword && i.DeleteInd != "Y");

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

                    Mapper.CreateMap <User, UserDto>()
                    .ForMember(dest => dest.CloudLastUpdDT, opt => opt.Ignore())
                    .ForMember(dest => dest.CloudLastUpdBy, opt => opt.Ignore())
                    .ForMember(dest => dest.ManagerUserName, opt => opt.Ignore())
                    .ForMember(dest => dest.Administrator, opt => opt.MapFrom(src => src.Administrator.ToUpper() == "Y"))
                    .ForMember(dest => dest.DeleteInd, opt => opt.MapFrom(src => src.DeleteInd.ToUpper() == "Y"));
                    var person = Mapper.Map <User, UserDto>(existingUser);
                    //////Mapper.AssertConfigurationIsValid();
                    return(person);
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// </summary>
        /// <param name="clientId"></param>
        /// <returns></returns>
        public List <ClientUpdateDB> GetClientUpdateDBByClientContentId(int clientId)
        {
            List <ClientUpdateDB> clientBase = new List <ClientUpdateDB>();

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                List <int> clientContentId = new List <int>();
                //get all ids in contentClientTable
                clientContentId = sdaCloudEntities.ClientContents
                                  .Where(i => i.ClientID == clientId)
                                  .Select(i => i.ContentClientID)
                                  .ToList();

                if (clientContentId.Count > 0)
                {
                    clientBase = sdaCloudEntities
                                 .ClientUpdateDBs
                                 .Where(i => clientContentId.Contains(i.ClientID.Value))
                                 .ToList();
                }
            }

            foreach (var clientContent in clientBase)
            {
                if (!String.IsNullOrEmpty(clientContent.DBFileName))
                {
                    clientContent.DBFileName = (clientContent.DBDescription + Path.GetExtension(clientContent.DBFileName));
                }
            }
            return(clientBase);
        }
Exemple #8
0
        /// <summary>
        /// Updates the user manager.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="newValue">The new value.</param>
        /// <returns></returns>
        public int UpdateUserManager(int userId, int newValue)
        {
            int result;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    using (var transactionScope = new TransactionScope())
                    {
                        var existingQuote = sdaCloudEntities.Users.FirstOrDefault(i => i.UserID == userId);

                        if (existingQuote != null)
                        {
                            if (newValue > 0)
                            {
                                existingQuote.ManagerUserID = newValue;
                            }
                            else
                            {
                                existingQuote.ManagerUserID = null;
                            }
                        }

                        result = sdaCloudEntities.SaveChanges();

                        transactionScope.Complete();
                    }
                }
            }
            return(result);
        }
Exemple #9
0
        public int UpdateOppStatusDefault(int clientId, int cdfId)
        {
            int result = 0;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    using (var transactionScope = new TransactionScope())
                    {
                        var collection = sdaCloudEntities.OppStatus.Where(i => i.ClientID == clientId);
                        collection.ToList().ForEach(c => c.Default = "N");
                        sdaCloudEntities.SaveChanges();

                        var existingOppStatus = sdaCloudEntities.OppStatus.FirstOrDefault(i => i.ID == cdfId);

                        if (existingOppStatus != null)
                        {
                            existingOppStatus.Default = "Y";
                            result = sdaCloudEntities.SaveChanges();
                        }

                        transactionScope.Complete();
                    }
                }
            }
            return(result);
        }
Exemple #10
0
        public bool ValidateFieldToUpdate(int clientID, int cdfId, string field, string newValue)
        {
            bool result = true;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var existingCDF = sdaCloudEntities.ClientDefinedFields.FirstOrDefault(i => i.ClientDefinedFieldID == cdfId);

                    if (existingCDF != null)
                    {
                        var existingOpp = sdaCloudEntities.ClientDefinedFields.Where(i => i.ClientID == clientID).ToList();

                        if (field.Equals("Table"))
                        {
                            existingOpp = existingOpp.Where(opp => opp.Table.Equals(newValue) && opp.Field.Equals(existingCDF.Field)).ToList();
                        }

                        if (field.Equals("Field"))
                        {
                            existingOpp = existingOpp.Where(opp => opp.Table.Equals(existingCDF.Table) && opp.Field.Equals(newValue)).ToList();
                        }

                        if (existingOpp.Count > 0)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(result);
        }
Exemple #11
0
        /// <summary>
        /// Manages the opportunities in CRM.
        /// </summary>
        /// <param name="clientID">The client identifier.</param>
        /// <returns></returns>
        public ClientLoginDto ManageOpportunitiesInCRM(int clientID)
        {
            var client = new ClientLoginDto();

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var existingClient =
                        sdaCloudEntities.Clients.FirstOrDefault(
                            i => i.ClientID == clientID);

                    if (existingClient == null)
                    {
                        return(client);
                    }
                    else
                    {
                        client.CRMData          = existingClient.CRMData;
                        client.ManageOppysInCRM = (existingClient.ManageOppysInCRM == "Y");
                    }
                }
            }
            return(client);
        }
Exemple #12
0
        public ClientLoginDto GetClientSyncValues(int clientID)
        {
            ClientLoginDto client = new ClientLoginDto();

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var crmXrefUpdDT =
                        sdaCloudEntities.Clients.FirstOrDefault(
                            i => i.ClientID == clientID);

                    //verify this

                    /*client.CorsProSyncInd     = crmXrefUpdDT.CorsProSyncInd;
                     * client.SyncServerLocation = crmXrefUpdDT.SyncServerLocation;
                     * client.SyncServerLogin    = crmXrefUpdDT.SyncServerLogin;
                     * client.SyncServerPwd      = crmXrefUpdDT.SyncServerPwd;
                     * client.OpportunityMgmt    = (crmXrefUpdDT.OpportunityMgmt);
                     * client.LastSDAVer         = crmXrefUpdDT.LastSDAVer;
                     * client.LastSDAVerWithDBUpdates = crmXrefUpdDT.LastSDAVerWithDBUpdates;*/
                    return(client);
                }
            }
        }
Exemple #13
0
 /// <summary>
 /// </summary>
 /// <param name="ClientId"></param>
 /// <param name="UserId"></param>
 /// <param name="WindowsUserName"></param>
 /// <param name="MACAddress"></param>
 /// <returns></returns>
 public UserMachineDataDto GetUserMachineData(int ClientId, int UserId, string WindowsUserName, string MACAddress)
 {
     try
     {
         using (var sdaCloudEntities = new SDACloudEntities())
         {
             using (sdaCloudEntities)
             {
                 var existingEntity = sdaCloudEntities
                                      .UserMachineDatas
                                      .Where(i => i.ClientID == ClientId && i.UserID == UserId && i.WindowsUserName.Equals(WindowsUserName) && i.MACAddress.Equals(MACAddress))
                                      .FirstOrDefault();
                 if (existingEntity != null)
                 {
                     Mapper.CreateMap <UserMachineData, UserMachineDataDto>()
                     .ForMember(x => x.LastUpdDT, opt => opt.Ignore())
                     .ForMember(x => x.CreateDT, opt => opt.Ignore());
                     var dto = Mapper.Map <UserMachineData, UserMachineDataDto>(existingEntity);
                     return(dto);
                 }
             }
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
     return(null);
 }
Exemple #14
0
        /// <summary>
        /// Deletes the opp statuses.
        /// </summary>
        /// <param name="uList">The u list.</param>
        /// <returns></returns>
        public string DeleteOppStatuses(string uList)
        {
            string result = string.Empty;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                List <string> tagIds = uList.Split(',').ToList();

                foreach (var uv in tagIds)
                {
                    int uvId;
                    Int32.TryParse(uv, out uvId);
                    var oppStatus = sdaCloudEntities.OppStatus.Where(q => q.ID == uvId).SingleOrDefault();
                    if (oppStatus != null) //&& oppStatus.Opportunities.Count == 0
                    {
                        oppStatus.DeleteInd = "Y";
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(result))
                        {
                            result += ",";
                        }
                        result += uv;
                    }
                }

                sdaCloudEntities.SaveChanges();
            }
            return(result);
        }
Exemple #15
0
 public void Update(DocumentDto documentDto)
 {
     try
     {
         using (SDACloudEntities sDACloudEntities = new SDACloudEntities())
         {
             using (sDACloudEntities)
             {
                 using (TransactionScope transactionScope = new TransactionScope())
                 {
                     Document document = sDACloudEntities.Documents.FirstOrDefault((Document i) => i.ClientID == (int?)documentDto.ClientID && i.LastFileSaveLocation.Equals(documentDto.LastFileSaveLocation));
                     document.DocumentType         = documentDto.DocumentType;
                     document.FilePlatformID       = documentDto.FilePlatformID;
                     document.LastFileSaveLocation = documentDto.LastFileSaveLocation;
                     document.LastUpdatedBy        = new int?(documentDto.CreatedBy);
                     document.LastUpdatedDT        = new DateTime?(DateTime.Now);
                     sDACloudEntities.SaveChanges();
                     transactionScope.Complete();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #16
0
        public int DeleteInterfaceXRef(ClientDefinedFieldDto clientDefinedField)
        {
            int result = 0;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (var transactionScope = new TransactionScope())
                {
                    var existingCDF = sdaCloudEntities.InterfaceXRefs.FirstOrDefault(i => i.InterfaceXRefID == clientDefinedField.InterfaceXRefID);

                    if (existingCDF != null)
                    {
                        //sdaCloudEntities.DeleteObject(existingCDF);
                    }

                    result = sdaCloudEntities.SaveChanges();

                    if (result >= 0)
                    {
                        var client = sdaCloudEntities.Clients.FirstOrDefault(o => o.ClientID == clientDefinedField.ClientID);
                        if (client != null)
                        {
                            client.CRMXrefUpdDT = DateTime.Now;
                            sdaCloudEntities.SaveChanges();
                        }
                    }

                    transactionScope.Complete();
                }
            }
            return(result);
        }
Exemple #17
0
        /// <summary>
        /// Gets the user by user identifier and client identifier.
        /// </summary>
        /// <param name="clientLogin">The client login.</param>
        /// <returns></returns>
        public UserDto GetUserByUserIDAndClientID(UserDto clientLogin)
        {
            using (var SdaCloudEntities = new SDACloudEntities())
            {
                using (SdaCloudEntities)
                {
                    var existingUser =
                        SdaCloudEntities
                        .Users
                        .Where(i =>
                               i.UserID == clientLogin.UserId &&
                               i.ClientID == clientLogin.ClientId &&
                               i.DeleteInd != "Y")
                        .FirstOrDefault();

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

                    Mapper.CreateMap <User, UserDto>()
                    .ForMember(dest => dest.CloudLastUpdDT, opt => opt.Ignore())
                    .ForMember(dest => dest.CloudLastUpdBy, opt => opt.Ignore())
                    .ForMember(dest => dest.ManagerUserName, opt => opt.Ignore())
                    .ForMember(dest => dest.Administrator, opt => opt.MapFrom(src => src.Administrator.ToUpper() == "Y"))
                    .ForMember(dest => dest.DeleteInd, opt => opt.MapFrom(src => src.DeleteInd.ToUpper() == "Y"));
                    var person = Mapper.Map <User, UserDto>(existingUser);
                    ////Mapper.AssertConfigurationIsValid();
                    return(person);
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// Gets the user views by user and client.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <returns></returns>
        public UserDto GetByUserIdAndClientId(int clientId, int userId)
        {
            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var User =
                        sdaCloudEntities.Users.Where(
                            i =>
                            i.ClientID == clientId &&
                            i.UserID == userId)
                        .FirstOrDefault();

                    Mapper.CreateMap <User, UserDto>()
                    .ForMember(dest => dest.CloudLastUpdDT, opt => opt.Ignore())
                    .ForMember(dest => dest.CloudLastUpdBy, opt => opt.Ignore())
                    .ForMember(dest => dest.ManagerUserName, opt => opt.Ignore())
                    .ForMember(dest => dest.Administrator, opt => opt.MapFrom(src => src.Administrator.ToUpper() == "Y"))
                    .ForMember(dest => dest.DeleteInd, opt => opt.MapFrom(src => src.DeleteInd.ToUpper() == "Y"));

                    var UserDto = Mapper.Map <User, UserDto>(User);
                    return(UserDto);
                }
            }
        }
Exemple #19
0
        /// <summary>
        /// Adds the user.
        /// </summary>
        /// <param name="userDto">The user dto.</param>
        /// <returns></returns>
        public int AddUser(UserDto userDto)
        {
            int result = 0;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (var transactionScope = new TransactionScope())
                {
                    var existingUser = sdaCloudEntities.Users.FirstOrDefault(i => i.LoginID == userDto.LoginID);

                    if (existingUser == null)
                    {
                        existingUser = new User
                        {
                            ClientID       = userDto.ClientId,
                            LoginID        = userDto.LoginID,
                            Password       = userDto.Password,
                            FirstName      = userDto.FirstName,
                            LastName       = userDto.LastName,
                            ManagerUserID  = userDto.ManagerUserID,
                            Administrator  = (userDto.Administrator ? "Y" : "N"),
                            DeleteInd      = "N",
                            CloudLastUpdBy = userDto.CloudLastUpdBy,
                            CloudLastUpdDT = DateTime.UtcNow
                        };

                        sdaCloudEntities.Users.AddObject(existingUser);
                    }
                    else
                    {
                        if (existingUser.DeleteInd.Equals("Y") && existingUser.ClientID == userDto.ClientId)
                        {
                            existingUser.Password       = userDto.Password;
                            existingUser.FirstName      = userDto.FirstName;
                            existingUser.LastName       = userDto.LastName;
                            existingUser.ManagerUserID  = userDto.ManagerUserID;
                            existingUser.Administrator  = (userDto.Administrator ? "Y" : "N");
                            existingUser.DeleteInd      = "N";
                            existingUser.CloudLastUpdBy = userDto.CloudLastUpdBy;
                            existingUser.CloudLastUpdDT = DateTime.UtcNow;
                        }
                        else
                        {
                            result = -2;
                        }
                    }

                    sdaCloudEntities.SaveChanges();

                    if (result != -2)
                    {
                        result = existingUser.UserID;
                    }

                    transactionScope.Complete();
                }
            }
            return(result);
        }
Exemple #20
0
        /// <summary>
        /// Saves the new user view.
        /// </summary>
        /// <param name="userView">The user view.</param>
        /// <returns></returns>
        public int SaveNewUserView(UserViewDto userView)
        {
            int result;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (var transactionScope = new TransactionScope())
                {
                    var nList = GetUserViewsByUserAndClient(userView.ClientID, userView.UserID);

                    if (nList.Count < 30)
                    {
                        var existName = nList.Where(u => u.ViewName.ToUpper().Equals(userView.ViewName.ToUpper())).FirstOrDefault();
                        if ((existName == null) && (!userView.ViewName.ToUpper().Equals("DEFAULT")))
                        {
                            var existingUser = new UserView
                            {
                                UserID   = userView.UserID,
                                ClientID = userView.ClientID,
                                View     = userView.View,
                                ViewName = userView.ViewName
                            };

                            sdaCloudEntities.UserViews.AddObject(existingUser);

                            sdaCloudEntities.SaveChanges();

                            var existingUv = sdaCloudEntities.UserViews.Where(u => u.ClientID == userView.ClientID && u.UserID == userView.UserID && u.ViewName.ToUpper().Equals(userView.ViewName.ToUpper())).FirstOrDefault();

                            result = existingUv.UserViewID;

                            transactionScope.Complete();
                        }
                        else if ((existName != null) && (!userView.ViewName.ToUpper().Equals("DEFAULT")))
                        {
                            var existingUv = sdaCloudEntities.UserViews.Where(u => u.ClientID == userView.ClientID && u.UserID == userView.UserID && u.ViewName.ToUpper().Equals(userView.ViewName.ToUpper())).FirstOrDefault();
                            existingUv.View = userView.View;

                            sdaCloudEntities.SaveChanges();

                            result = existingUv.UserViewID;

                            transactionScope.Complete();
                        }
                        else
                        {
                            result = -2;
                        }
                    }
                    else
                    {
                        result = 0;
                    }
                }
            }
            return(result);
        }
Exemple #21
0
        /// <summary>
        /// </summary>
        /// <param name="UserMachineDataDto"></param>
        /// <returns></returns>
        public int AddUserMachineData(UserMachineDataDto UserMachineDataDto)
        {
            int result = 0;

            try
            {
                using (var sdaCloudEntities = new SDACloudEntities())
                {
                    using (var transactionScope = new TransactionScope())
                    {
                        var existingEntity = sdaCloudEntities
                                             .UserMachineDatas
                                             .Where(i => i.ClientID == UserMachineDataDto.ClientID && i.UserID == UserMachineDataDto.UserID && i.WindowsUserName.Equals(UserMachineDataDto.WindowsUserName) && i.MACAddress.Equals(UserMachineDataDto.MACAddress))
                                             .FirstOrDefault();
                        if (existingEntity == null)
                        {
                            existingEntity = new UserMachineData()
                            {
                                ClientID            = UserMachineDataDto.ClientID,
                                UserID              = UserMachineDataDto.UserID,
                                WindowsUserName     = UserMachineDataDto.WindowsUserName,
                                MACAddress          = UserMachineDataDto.MACAddress,
                                VersionDotNet       = UserMachineDataDto.VersionDotNet,
                                VersionExcel        = UserMachineDataDto.VersionExcel,
                                VersionWord         = UserMachineDataDto.VersionWord,
                                VersionSDA          = UserMachineDataDto.VersionSDA,
                                VersionSalesManager = UserMachineDataDto.VersionSalesManager,
                                VersionWindows      = UserMachineDataDto.VersionWindows,
                                InstallType         = UserMachineDataDto.InstallType,
                                UserName            = UserMachineDataDto.UserName,
                                Email        = UserMachineDataDto.Email,
                                Company      = UserMachineDataDto.Company,
                                Title        = UserMachineDataDto.Title,
                                Phone        = UserMachineDataDto.Phone,
                                UserTimeZone = UserMachineDataDto.UserTimeZone,
                                CreateDT     = DateTime.UtcNow,
                                LastUpdDT    = DateTime.UtcNow
                            };
                            sdaCloudEntities.UserMachineDatas.AddObject(existingEntity);
                            result = sdaCloudEntities.SaveChanges();
                            transactionScope.Complete();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(result);
        }
Exemple #22
0
        public string GetCRMXrefCRMSystem(int clientID)
        {
            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var crmXrefUpdDT =
                        sdaCloudEntities.Clients.FirstOrDefault(
                            i => i.ClientID == clientID);

                    return(crmXrefUpdDT.CRMSystem);
                }
            }
        }
Exemple #23
0
        /// <summary>
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="fileName"></param>
        /// <param name="AWSFilePath"></param>
        /// <param name="AWSFileName"></param>
        /// <param name="DBFileUpdDT"></param>
        /// <param name="DBUploadedDt"></param>
        /// <returns></returns>
        public ClientUpdateDBDto UpdateClientUpdateDB(int ClientId, string FileName, string AWSID, string AWSFilePath,
                                                      string AWSFileName, string DBFileUpdDT, string DBUploadedDt, bool BetaVersion,
                                                      int UploaderClientID, int UploaderUserID, string UploaderUserName)
        {
            ClientUpdateDBDto clientBase = null;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    ClientUpdateDB client = sdaCloudEntities.ClientUpdateDBs
                                            .Where(i => i.ClientID == ClientId && i.DBFileName == FileName)
                                            .FirstOrDefault();
                    if (client != null)
                    {
                        if (!BetaVersion)
                        {
                            client.AWSFlePath   = AWSFilePath;
                            client.AWSFileName  = AWSFileName;
                            client.AWSFileID    = AWSID;
                            client.DBFileUpdDT  = DateTime.Parse(DBFileUpdDT);
                            client.DBUploadedDT = DateTime.Parse(DBUploadedDt);
                        }
                        else
                        {
                            client.BetaAwsFilePath      = AWSFilePath;
                            client.BetaAWSFileName      = AWSFileName;
                            client.BetaAWSFileID        = AWSID;
                            client.BetaDBFileUpdDT      = DateTime.Parse(DBFileUpdDT);
                            client.BetaUploaderClientID = UploaderClientID;
                            client.BetaUploaderUserID   = UploaderUserID;
                            client.BetaUploaderUserName = UploaderUserName;
                        }
                        client.UploaderClientID = UploaderClientID;
                        client.UploaderUserID   = UploaderUserID;
                        client.UploaderUserName = UploaderUserName;

                        Mapper.CreateMap <ClientUpdateDB, ClientUpdateDBDto>();
                        if (client != null)
                        {
                            clientBase = Mapper.Map <ClientUpdateDB, ClientUpdateDBDto>(client);
                            Mapper.AssertConfigurationIsValid();
                        }
                        sdaCloudEntities.SaveChanges();
                    }
                }
            }
            return(clientBase);
        }
Exemple #24
0
        public InterfaceDto GetInterfaceByClientId(int clientId, string InterfaceSystem)
        {
            InterfaceDto result;

            using (SDACloudEntities sDACloudEntities = new SDACloudEntities())
            {
                Interface source = (from i in sDACloudEntities.Interfaces
                                    where i.ClientID == clientId && i.InterfaceSystem.Equals(InterfaceSystem)
                                    select i).SingleOrDefault <Interface>();
                Mapper.CreateMap <Interface, InterfaceDto>();
                InterfaceDto interfaceDto = Mapper.Map <Interface, InterfaceDto>(source);
                result = interfaceDto;
            }
            return(result);
        }
Exemple #25
0
        /// <summary>
        /// Deletes the user.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns></returns>
        public int DeleteUser(int userId)
        {
            int result;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                var existinguser = sdaCloudEntities.Users.FirstOrDefault(i => i.UserID == userId);
                if (existinguser != null)
                {
                    existinguser.DeleteInd = "Y";
                }
                result = sdaCloudEntities.SaveChanges();
            }
            return(result);
        }
Exemple #26
0
        /// <summary>
        /// Validates the client login.
        /// </summary>
        /// <param name="clientLogin">The client login.</param>
        /// <returns></returns>
        public bool ValidateClientLogin(ClientLoginDto clientLogin)
        {
            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var existingClient =
                        sdaCloudEntities.Clients.FirstOrDefault(
                            i =>
                            i.ClientLoginID == clientLogin.ClientLoginId &&
                            i.ClientLoginPwd == clientLogin.ClientLoginPwd);

                    return(existingClient != null);
                }
            }
        }
Exemple #27
0
        /// <summary>
        /// Gets the records with mapped fields.
        /// </summary>
        /// <param name="interfaceId">The interface identifier.</param>
        /// <param name="txn">The TXN.</param>
        /// <returns></returns>
        public List <InterfaceXRefDto> GetRecordsWithMappedFields(int clientId, string txn)
        {
            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var existingClient = sdaCloudEntities.InterfaceXRefs.Where(o => o.ClientID == clientId && o.Txn == txn).ToList();

                    Mapper.CreateMap <InterfaceXRef, InterfaceXRefDto>()
                    .ForMember(dest => dest.CRMXrefUpdDT, opt => opt.Ignore());

                    var peopleVm = Mapper.Map <List <InterfaceXRef>, List <InterfaceXRefDto> >(existingClient);

                    return(peopleVm);
                }
            }
        }
Exemple #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientId"></param>
        /// <returns></returns>
        public bool HasPermissionToUpload(int clientId, string fileName)
        {
            bool HasPermissionToUpload = false;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var clientBase = sdaCloudEntities.ClientUpdateDBs
                                     .Where(i => i.ClientID == clientId && i.DBFileName == fileName)
                                     .ToList();

                    HasPermissionToUpload = (clientBase.Count > 0);
                }
            }
            return(HasPermissionToUpload);
        }
Exemple #29
0
        /// <summary>
        /// Adds the error message.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <param name="record">The record.</param>
        public bool AddErrorMessage(int clientId, string errorMessage, string record)
        {
            bool result = false;

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    using (var transactionScope = new TransactionScope())
                    {
                        var existingError = sdaCloudEntities.ErrorLogs.FirstOrDefault(
                            i =>
                            i.ClientID == clientId &&
                            i.ErrorMessage.Trim().ToUpper().Equals(errorMessage.Trim().ToUpper()) &&
                            i.Record.Trim().ToUpper().Equals(record.Trim().ToUpper()));

                        if (existingError != null)
                        {
                            existingError.ProcessDT = DateTime.UtcNow;
                            if (!string.IsNullOrEmpty(existingError.NoLongerSend) && existingError.NoLongerSend.Equals("Y"))
                            {
                                result = true;
                            }
                        }
                        else
                        {
                            var errorLog = new ErrorLog
                            {
                                ClientID     = clientId,
                                ErrorMessage = errorMessage,
                                Record       = record,
                                ProcessDT    = DateTime.UtcNow
                            };

                            sdaCloudEntities.ErrorLogs.AddObject(errorLog);
                        }

                        sdaCloudEntities.SaveChanges();

                        transactionScope.Complete();
                    }
                }
            }
            return(result);
        }
Exemple #30
0
        /// <summary>
        ///  0 = Normal user
        ///  1 = Administrator
        ///  2 = EndUser
        /// </summary>
        /// <param name="clientId"></param>
        /// <returns></returns>
        public List <ClientUpdateDBDto> GetClientUpdateDB(int clientId, int userType)
        {
            List <ClientUpdateDBDto> clientBase = new List <ClientUpdateDBDto>();

            using (var sdaCloudEntities = new SDACloudEntities())
            {
                using (sdaCloudEntities)
                {
                    var clientUpdates = new List <ClientUpdateDB>();
                    if (userType == 0)
                    {
                        clientUpdates = sdaCloudEntities
                                        .ClientUpdateDBs
                                        .Where(i => i.ClientID == clientId)
                                        .ToList();
                    }
                    else if (userType == 1)
                    {
                        clientUpdates = sdaCloudEntities
                                        .ClientUpdateDBs
                                        .Where(i => (i.ClientID == 999999 &&
                                                     (i.DBFileType == null || i.DBFileType == "" || i.DBFileType == "Admin")))
                                        .ToList();

                        List <ClientUpdateDB> clientBaseContent = GetClientUpdateDBByClientContentId(clientId);
                        clientUpdates.AddRange(clientBaseContent);
                    }
                    else if (userType == 2)
                    {
                        clientUpdates = sdaCloudEntities
                                        .ClientUpdateDBs
                                        .Where(i => (i.ClientID == 999999 &&
                                                     (i.DBFileType == null || i.DBFileType == "")))
                                        .ToList();
                    }
                    Mapper.CreateMap <ClientUpdateDB, ClientUpdateDBDto>();
                    if (clientUpdates != null)
                    {
                        clientBase = Mapper.Map <List <ClientUpdateDB>, List <ClientUpdateDBDto> >(clientUpdates);
                        Mapper.AssertConfigurationIsValid();
                    }
                }
            }
            return(clientBase);
        }