Пример #1
0
        public ActionResult List(int? page, string search, int? size)
        {
            if (size == null)
                size = 40;

            if (size > 100)
                size = 100;

            if (page == null)
                page = 0;

            int total;

            var userSearch = new UserSearch();
            if (!string.IsNullOrEmpty(search))
            {
                search = search + "%";
                userSearch.Name = search;
                userSearch.Email = search;
                userSearch.Login = search;
                userSearch.Phone = search;
                userSearch.Junction = JunctionType.Or;
            }
            userSearch.Org = OrnamentContext.MemberShip.CurrentUser().Org;

            IList<User> userResult = _userDao.Search(userSearch, page.Value, size.Value, out total);

            var result = new
            {
                data = new ArrayList(),
                TotalRecords = total
            };
            foreach (User user in userResult)
            {
                result.data.Add(new
                {
                    user.Id,
                    user.Name,
                    user.LoginId,
                    user.Contact.Email,
                    user.Security.IsLocked,
                    user.Contact.EmailVerified,
                    Deny = user.IsDeny,
                    LastActivityDate =
                        user.Other.LastActivityDate != null
                            ? user.Other.LastActivityDate.Value.ToString("yyyy-MM-dd HH:mm:ss")
                            : "",
                });
            }

            return Json(result, JsonRequestBehavior.AllowGet);
        }
Пример #2
0
 public Int32 AddOrdinaryPacketReceive(UserSearch ordinaryPacketReceive)
 {
     return(_dal.AddOrdinaryPacketReceive(ordinaryPacketReceive));
 }
Пример #3
0
        public static List<UserSearch> getListUserByUserName(string userName, string connString)
        {
            #region code
            List<UserSearch> lists = new List<UserSearch>();
            using (SqlConnection conn = new SqlConnection(connString))
            {
                try
                {
                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "sony_sp_get_all_user_by_username";
                        cmd.Parameters.AddWithValue("@username", userName);

                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                UserSearch user = new UserSearch();
                                user.Id = (int)reader["id"];
                                user.FullName = reader["fullname"].ToString();
                                user.UserName = reader["username"].ToString();
                                user.Created = (DateTime)reader["registered"];
                                user.Updated = (DateTime)reader["updated"];
                                lists.Add(user);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog("", "Get User Error: " + ex.Message, connString);
                    return new List<UserSearch>();
                }
            }
            return lists;
            #endregion
        }
Пример #4
0
        public PagedResponse <GetUserDto> Execute(UserSearch request)
        {
            var query = Context.Users.AsQueryable();

            if (request.FirstName != null)
            {
                query = query.Where(r => r.FirstName.ToLower().Contains(request.FirstName.ToLower()));
            }
            if (request.LastName != null)
            {
                query = query.Where(r => r.LastName.ToLower().Contains(request.LastName.ToLower()));
            }
            if (request.Username != null)
            {
                query = query.Where(r => r.Username.ToLower().Contains(request.Username.ToLower()));
            }

            if (request.Active.HasValue)
            {
                query = query.Where(c => c.IsDeleted != request.Active);
            }
            else
            {
                query = query.Where(c => c.IsDeleted == false);
            }


            if (request.RoleId.HasValue)
            {
                if (!Context.Roles.Any(r => r.Id == request.RoleId))
                {
                    throw new EntityNotFoundException("Role");
                }
                query = query.Where(u => u.RoleId == request.RoleId);
            }

            var totalCount = query.Count();

            query = query.Skip((request.PageNumber - 1) * request.PerPage).Take(request.PerPage);


            var pagesCount = (int)Math.Ceiling((double)totalCount / request.PerPage);


            var response = new PagedResponse <GetUserDto>
            {
                CurrentPage = request.PageNumber,
                TotalCount  = totalCount,
                PagesCount  = pagesCount,
                Data        = query.Select(u => new GetUserDto
                {
                    Id        = u.Id,
                    FirstName = u.FirstName,
                    LastName  = u.LastName,
                    Email     = u.Email,
                    Username  = u.Username,
                    Role      = u.Role.Name
                })
            };

            return(response);
        }
Пример #5
0
        /// <summary>
        /// This is a Geotab API console example of sending text messages. It illustrates how to send a basic message, canned response message and location message.
        ///
        /// Steps:
        /// 1) Process command line arguments: Server, Database, Username and Password.
        /// 2) Create Geotab API object and Authenticate.
        /// 3) Send a basic text message.
        /// 4) Send a canned response Text Message.
        /// 5) Get a Text Message reply.
        /// 6) Send an GPS location Text Message.
        ///
        /// A complete Geotab API object and method reference is available at the Geotab SDK page.
        /// </summary>
        /// <param name="args">The command line arguments for the application. Note: When debugging these can be added by: Right click the project > Properties > Debug Tab > Start Options: Command line arguments.</param>
        static async Task Main(string[] args)
        {
            if (args.Length != 4)
            {
                Console.WriteLine();
                Console.WriteLine("Command line parameters:");
                Console.WriteLine("dotnet run <server> <database> <username> <password>");
                Console.WriteLine();
                Console.WriteLine("Command line:   dotnet run server database username password");
                Console.WriteLine("server        - The server name (Example: my.geotab.com)");
                Console.WriteLine("database      - The database name (Example: G560)");
                Console.WriteLine("username      - Geotab user name (Example: [email protected])");
                Console.WriteLine("password      - Geotab password");
                return;
            }

            // Process command line augments
            string server   = args[0];
            string database = args[1];
            string username = args[2];
            string password = args[3];

            try
            {
                // Create Geotab API object
                API api = new API(username, password, null, database, server);

                // Authenticate
                Console.WriteLine("Authenticating...");
                await api.AuthenticateAsync();

                // Get a device to send text messages to.
                IList <Device> devices = await api.CallAsync <IList <Device> >("Get", typeof(Device), new { resultsLimit = 1 });

                // Make sure we have a device
                if (devices == null || devices.Count == 0)
                {
                    throw new InvalidOperationException("Datastore does not contain any devices");
                }

                Device messageRecipient = devices[0];

                Console.WriteLine("Messages will be send to: " + messageRecipient.Name);

                // Get the User who the messages will be sent from
                UserSearch userSearch = new UserSearch
                {
                    Name = username
                };
                IList <User> users = await api.CallAsync <List <User> >("Get", typeof(User), new { search = userSearch });

                if (users == null || users.Count == 0)
                {
                    throw new InvalidOperationException("Could not find the user you are authenticated in as");
                }
                User user = users[0];

                Console.WriteLine("Messages will be sent from: " + user.Name);

                /*
                 * Basic Message
                 * A basic text message with a string message.
                 */

                // Set up the message content
                TextContent messageContent = new TextContent("Testing: Geotab API example text message", false);

                // Construct the text message
                DateTime    utcNow           = DateTime.UtcNow;
                TextMessage basicTextMessage = new TextMessage(null, null, utcNow, utcNow, messageRecipient, user, messageContent, true, true, null, null, null);

                // Add the text message. MyGeotab will take care of the actual sending.
                basicTextMessage.Id = await api.CallAsync <Id>("Add", typeof(TextMessage), new { entity = basicTextMessage });

                /*
                 * Canned Response Message
                 * A canned response message is a text message with a list of predetermined responses the receiver can select from.
                 */

                // Example of sending a text message with canned a response.
                // Set up message and response options.
                CannedResponseContent cannedResponseContent = new CannedResponseContent
                {
                    Message = "Testing: Geotab API example text message with response options"
                };
                cannedResponseContent.CannedResponseOptions.Add(new CannedResponseOption("Ok"));

                // Construct the text message.
                TextMessage textMessageWithResponses = new TextMessage(messageRecipient, null, cannedResponseContent, true);

                // Add the text message, Geotab will take care of the sending process.
                textMessageWithResponses.Id = await api.CallAsync <Id>("Add", typeof(TextMessage), new { entity = textMessageWithResponses });

                Console.WriteLine("Text message sent");

                // Keep track of our last "known" sent date. We will send another message but for the purpose of this example we are going to pretend it's from a Device.
                DateTime lastKnownSentDate = DateTime.Now;

                //-------
                // START: MOCK A DEVICE REPLY.
                // **FOR EXAMPLE PURPOSES ONLY.**
                // THIS LOGIC IS HANDELED BY THE MYGEOTAB SYSTEM. YOU WOULD NOT NORMALLY DO THIS IN A WORKING ENVIRONMENT.
                //-------

                // Here we are adding a new text message with "isDirectionToVehicle = false", this means the message came from the device.
                // Normally, these will be sent by the Garmin device. This is just to show how to search for new responses.
                TextMessage textMessageFromDevice = new TextMessage(null, null, utcNow, utcNow, messageRecipient, user, new TextContent(cannedResponseContent.CannedResponseOptions[0].Text, false), false, true, null, null, textMessageWithResponses);
                textMessageFromDevice.Id = await api.CallAsync <Id>("Add", typeof(TextMessage), new { entity = textMessageFromDevice });

                Console.WriteLine("Response Sent");

                //-------
                // END: MOCK A DEVICE REPLY
                //-------

                // Request any messages that have been delivered/sent/read since the date provided.
                IList <TextMessage> textMessages = await api.CallAsync <IList <TextMessage> >("Get", typeof(TextMessage), new { search = new TextMessageSearch(ToDate(lastKnownSentDate)) });

                Console.WriteLine($"{textMessages.Count} delivered/sent/read");

                /*
                 * Location Message
                 * A location message is a message with a location. A series of location messages can be sent in succession to comprise a route.
                 * A clear message can be sent to clear any previous location messages.
                 */

                // Example of sending a text message with a GPS location

                // Set up message and GPS location
                LocationContent clearStopsContent = new LocationContent("Testing: Geotab API example clear all stops message", "Reset Stops", 0, 0);

                // Construct a "Clear Previous Stops" message
                TextMessage clearMessage = new TextMessage(messageRecipient, user, clearStopsContent, true);

                // Add the clear stops text message, Geotab will take care of the sending process.
                clearMessage.Id = await api.CallAsync <Id>("Add", typeof(TextMessage), new { entity = clearMessage });

                Console.WriteLine("Clear Stops Message sent");

                // Set up message and GPS location
                LocationContent withGPSLocation = new LocationContent("Testing: Geotab API example location message", "Geotab", 43.452879, -79.701648);

                // Construct the location text message.
                TextMessage locationMessage = new TextMessage(messageRecipient, user, withGPSLocation, true);

                // Add the text message, Geotab will take care of the sending process.
                locationMessage.Id = await api.CallAsync <Id>("Add", typeof(TextMessage), new { entity = locationMessage });

                Console.WriteLine("Address Message sent");
            }
            catch (Exception ex)
            {
                // Write any errors to the Console.
                Console.WriteLine(ex);
            }
        }
Пример #6
0
        PagedResponse <UserDto> IQuery <UserSearch, PagedResponse <UserDto> > .Execute(UserSearch search)
        {
            var query = context.Users.Include(x => x.UserUseCases).Include(u => u.Country).AsQueryable(); //spajam usera sa usecases

            if (!string.IsNullOrEmpty(search.FirstName) || !string.IsNullOrWhiteSpace(search.FirstName))
            {
                query = query.Where(x => x.FirstName.ToLower().Contains(search.FirstName.ToLower()));
            }

            if (!string.IsNullOrEmpty(search.LastName) || !string.IsNullOrWhiteSpace(search.LastName))
            {
                query = query.Where(x => x.LastName.ToLower().Contains(search.LastName.ToLower()));
            }

            if (!string.IsNullOrEmpty(search.Email) || !string.IsNullOrWhiteSpace(search.Email))
            {
                query = query.Where(x => x.Email.ToLower().Contains(search.Email.ToLower()));
            }


            return(query.Paged <UserDto, User>(search, mapper));
        }
Пример #7
0
 public IActionResult Get([FromQuery] UserSearch search, [FromServices] IGetUsersQuery query)
 {
     return(Ok(_executor.ExecuteQuery(query, search)));
 }
Пример #8
0
        public ActionResult SearchResults(UserSearch userSearch)
        {
            var searchResult = this.gitHubApi.GetUserDetails(userSearch.Username);

            return(View(searchResult));
        }
Пример #9
0
 public ActionResult SearchUsername(UserSearch userSearch)
 {
     return(RedirectToAction("SearchResults", userSearch));
 }
        public HttpResponseMessage Export(GlobalSolusindoDb Db, string fileName, UserSearchFilter filter)
        {
            _fileName = fileName;
            _workbook = new XSSFWorkbook(); //Creating New Excel object

            using (var userSearch = new UserSearch(Db))
            {
                var data       = userSearch.GetDataByFilter(filter);
                var dataExport = data.Records.Select(c => new UserExportDTO
                {
                    JoinDate             = c.JoinDate,
                    UserName             = c.Username,
                    KategoriJabatanTitle = c.KategoriJabatanTitle,
                    Name             = c.Name,
                    TglLahir         = c.TglLahir,
                    NoKTP            = c.NoKTP,
                    ReligionName     = c.Religion,         //?
                    CategoryContract = c.CategoryContract, //?
                    Project          = c.Project,          //?
                    Gender           = c.Gender,           //?
                    MartialStatus    = c.MaritalStatus,    //?
                    NPWP             = c.NPWP,             //?
                    BPJS             = c.BPJS,             //?
                    ContactNumber    = c.NoHP,
                    G1EmailID        = c.Email,
                    PersonalEmail    = c.PersonalEmail,
                    Address          = c.Address,
                    NamaBank         = c.BankName,      //?
                    NoRekening       = c.AccountNumber, //?
                    Salary           = c.Salary,        //?
                    Remark           = c.Description,   //?
                    Status           = null             //?
                }).ToList();


                WriteSheetData(dataExport, "UserUpload");
            }

            using (var jabatanQry = new KategoriJabatanQuery())
            {
                var data = jabatanQry.GetQuery().Select(c => new LOVDTO {
                    Id = c.KategoriJabatan_PK, Name = c.Title
                }).ToList();
                WriteSheetData(data, "Position");
            }
            //_workbook.Close();

            using (var memoryStream = new MemoryStream()) //creating memoryStream
            {
                _workbook.Write(memoryStream);
                var response = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new ByteArrayContent(memoryStream.ToArray())
                };

                response.Content.Headers.ContentType = new MediaTypeHeaderValue
                                                           ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                response.Content.Headers.ContentDisposition =
                    new ContentDispositionHeaderValue("attachment")
                {
                    FileName = $"{_fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"
                };

                return(response);
            }
        }