Ejemplo n.º 1
0
 public int UpdateUserMachineData(UserMachineDataDto UserMachineDataDto)
 {
     try
     {
         return(new UserMachineDataDL().UpdateUserMachineData(UserMachineDataDto));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ClientID"></param>
        /// <param name="UserID"></param>
        /// <param name="WindowsUserName"></param>
        /// <param name="MACAddress"></param>
        /// <param name="VersionDotNet"></param>
        /// <param name="VersionExcel"></param>
        /// <param name="VersionWord"></param>
        /// <param name="VersionSDA"></param>
        /// <param name="VersionSalesManager"></param>
        /// <param name="VersionWindows"></param>
        /// <param name="InstallType"></param>
        /// <param name="UserFullName"></param>
        /// <param name="Email"></param>
        /// <param name="CompanyLong"></param>
        /// <param name="Title"></param>
        /// <param name="Phone"></param>
        /// <param name="UserTimeZone"></param>
        /// <returns></returns>
        public string UploadUserMachineData(int ClientID, int UserID, string WindowsUserName, string MACAddress, string VersionDotNet, string VersionExcel, string VersionWord, string VersionSDA, string VersionSalesManager,
                                            string VersionWindows, string InstallType, string UserFullName, string Email, string CompanyLong, string Title, string Phone, string UserTimeZone)
        {
            string ReturnMessage = "";

            try
            {
                UserMachineDataDto UserMachineDataDto = new UserMachineDataDto()
                {
                    ClientID            = ClientID,
                    UserID              = UserID,
                    WindowsUserName     = WindowsUserName,
                    MACAddress          = MACAddress,
                    VersionDotNet       = VersionDotNet,
                    VersionExcel        = VersionExcel,
                    VersionWord         = VersionWord,
                    VersionSDA          = VersionSDA,
                    VersionSalesManager = VersionSalesManager,
                    VersionWindows      = VersionWindows,
                    InstallType         = InstallType,
                    UserName            = UserFullName,
                    Email        = Email,
                    Company      = CompanyLong,
                    Title        = Title,
                    Phone        = Phone,
                    UserTimeZone = UserTimeZone
                };

                var UMDDL           = new UserMachineDataBL();
                var UserMachineData = UMDDL.GetUserMachineData(ClientID, UserID, WindowsUserName, MACAddress);
                if (UserMachineData == null)
                {
                    UMDDL.AddUserMachineData(UserMachineDataDto);
                    ReturnMessage = "Inserted";
                }
                else if (!Utilitary.AreObjectsEquals(UserMachineData, UserMachineDataDto))
                {
                    UMDDL.UpdateUserMachineData(UserMachineDataDto);
                    ReturnMessage = "Updated";
                }
                else
                {
                    ReturnMessage = "Nothing to update";
                }
            }
            catch (Exception e)
            {
                ReturnMessage = "Error: shit " + e.Message + " " + e.InnerException;
            }
            return(ReturnMessage);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name="UserMachineDataDto"></param>
        /// <returns></returns>
        public int UpdateUserMachineData(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.VersionDotNet       = UserMachineDataDto.VersionDotNet;
                            existingEntity.VersionExcel        = UserMachineDataDto.VersionExcel;
                            existingEntity.VersionWord         = UserMachineDataDto.VersionWord;
                            existingEntity.VersionSDA          = UserMachineDataDto.VersionSDA;
                            existingEntity.VersionSalesManager = UserMachineDataDto.VersionSalesManager;
                            existingEntity.VersionWindows      = UserMachineDataDto.VersionWindows;
                            existingEntity.InstallType         = UserMachineDataDto.InstallType;
                            existingEntity.UserName            = UserMachineDataDto.UserName;
                            existingEntity.Email        = UserMachineDataDto.Email;
                            existingEntity.Company      = UserMachineDataDto.Company;
                            existingEntity.Title        = UserMachineDataDto.Title;
                            existingEntity.Phone        = UserMachineDataDto.Phone;
                            existingEntity.UserTimeZone = UserMachineDataDto.UserTimeZone;
                            existingEntity.LastUpdDT    = DateTime.UtcNow;
                            result = sdaCloudEntities.SaveChanges();
                            transactionScope.Complete();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(result);
        }