Пример #1
0
        /// <summary>
        /// Phương thức khởi tạo
        /// </summary>
        static UtilitiesProcess()
        {
            EndpointAddress  endpointAddressTruyVan  = Common.Utilities.getEndpointAddress(ApplicationConstant.SystemService.TruyVanService.layGiaTri());
            BasicHttpBinding basicHttpBindingTruyVan = Common.Utilities.getBasicHttpBinding(ApplicationConstant.SystemService.TruyVanService.layGiaTri());

            ClientTruyVan = new TruyVanServiceClient(basicHttpBindingTruyVan, endpointAddressTruyVan);

            foreach (var operationDescription in ClientTruyVan.Endpoint.Contract.Operations)
            {
                DataContractSerializerOperationBehavior dcsob =
                    operationDescription.Behaviors.Find <DataContractSerializerOperationBehavior>();
                if (dcsob != null)
                {
                    dcsob.MaxItemsInObjectGraph = 2147483646;
                }
            }

            //Client = new UtilitiesServiceClient();
            EndpointAddress  endpointAddress  = Common.Utilities.getEndpointAddress(ApplicationConstant.SystemService.UtilitiesService.layGiaTri());
            BasicHttpBinding basicHttpBinding = Common.Utilities.getBasicHttpBinding(ApplicationConstant.SystemService.UtilitiesService.layGiaTri());

            Client = new UtilitiesServiceClient(basicHttpBinding, endpointAddress);

            foreach (var operationDescription in Client.Endpoint.Contract.Operations)
            {
                DataContractSerializerOperationBehavior dcsob =
                    operationDescription.Behaviors.Find <DataContractSerializerOperationBehavior>();
                if (dcsob != null)
                {
                    dcsob.MaxItemsInObjectGraph = 2147483646;
                }
            }
        }
Пример #2
0
        public string GetDBVersion()
        {
            const string DBVERSION_SESSIONVALUE = "DBVERSION";
            string       dbVersion = string.Empty;

            if (Session[DBVERSION_SESSIONVALUE] == null)
            {
                dbVersion = new UtilitiesServiceClient().GetDBVersion(_logonSettings.LogonId).DBVersion;
                Session[DBVERSION_SESSIONVALUE] = dbVersion;
            }
            else
            {
                dbVersion = Session[DBVERSION_SESSIONVALUE].ToString();
            }

            return(dbVersion);
        }
Пример #3
0
        /// <summary>
        /// Searches for users that match the search criteria.
        /// </summary>
        public UserSearchItem[] SearchUser(int startRow, int pageSize, string sortBy, string name, bool forceRefresh)
        {
            UtilitiesServiceClient userService = null;

            UserSearchItem[] users = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    if (name == null || name.Trim() == string.Empty)
                    {
                        throw new Exception("Please enter search criteria");
                    }


                    if (!IsReset)
                    {
                        // LSC - Insert Wildcards - 28/08/2010
                        if (!name.Contains('%'))
                        {
                            name = "%" + name.Trim() + "%";
                        }

                        Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                        CollectionRequest collectionRequest = new CollectionRequest();
                        collectionRequest.ForceRefresh = forceRefresh;
                        collectionRequest.StartRow     = startRow;
                        collectionRequest.RowCount     = pageSize;


                        UserSearchCriteria criteria = new UserSearchCriteria();
                        criteria.UserType = 1;
                        criteria.Name     = name;

                        userService = new UtilitiesServiceClient();
                        UserSearchReturnValue returnValue = userService.UserSearch(_logonId, collectionRequest, criteria);

                        //int idx =0;
                        //while (idx < returnValue.Users.Rows.Count())
                        //{

                        //    idx++;
                        //}

                        if (returnValue.Success)
                        {
                            _userRowCount = returnValue.Users.TotalRowCount;
                            users         = returnValue.Users.Rows;

                            //users[0].UserId;
                        }
                        else
                        {
                            if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.")
                            {
                                throw new Exception("Date is invalid");
                            }
                            else
                            {
                                throw new Exception(returnValue.Message);
                            }
                        }
                    }
                }
                return(users);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (userService != null)
                {
                    if (userService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        userService.Close();
                    }
                }
            }
        }
        public string GetDBVersion()
        {
            const string DBVERSION_SESSIONVALUE = "DBVERSION";
            string dbVersion = string.Empty;

            if (Session[DBVERSION_SESSIONVALUE] == null)
            {
                dbVersion = new UtilitiesServiceClient().GetDBVersion(_logonSettings.LogonId).DBVersion;
                Session[DBVERSION_SESSIONVALUE] = dbVersion;
            }
            else
            {
                dbVersion = Session[DBVERSION_SESSIONVALUE].ToString();
            }

            return dbVersion;
        }
        /// <summary>
        /// Searches for users that match the search criteria.
        /// </summary>
        public UserSearchItem[] SearchUser(int startRow, int pageSize, string sortBy, string name,  bool forceRefresh)
        {
            UtilitiesServiceClient userService = null;
            UserSearchItem[] users = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    if (name == null || name.Trim() == string.Empty)
                        throw new Exception("Please enter search criteria");

                    if (!IsReset)
                    {
                        // LSC - Insert Wildcards - 28/08/2010
                        if (!name.Contains('%')) { name = "%" + name.Trim() + "%"; }

                        Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                        CollectionRequest collectionRequest = new CollectionRequest();
                        collectionRequest.ForceRefresh = forceRefresh;
                        collectionRequest.StartRow = startRow;
                        collectionRequest.RowCount = pageSize;

                        UserSearchCriteria criteria = new UserSearchCriteria();
                        criteria.UserType = 1;
                        criteria.Name = name;

                        userService = new UtilitiesServiceClient();
                        UserSearchReturnValue returnValue = userService.UserSearch(_logonId, collectionRequest, criteria);

                        //int idx =0;
                        //while (idx < returnValue.Users.Rows.Count())
                        //{

                        //    idx++;
                        //}

                        if (returnValue.Success)
                        {
                            _userRowCount = returnValue.Users.TotalRowCount;
                            users = returnValue.Users.Rows;

                            //users[0].UserId;
                        }
                        else
                        {
                            if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.")
                                throw new Exception("Date is invalid");
                            else
                                throw new Exception(returnValue.Message);

                        }
                    }
                }
                return users;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (userService != null)
                {
                    if (userService.State != System.ServiceModel.CommunicationState.Faulted)
                        userService.Close();
                }
            }
        }