コード例 #1
0
        public Search <HumanData> GetPersons()
        {
            using (var connection = new SqlConnection(props.connectionString))
            {
                var findres = new SearchRes <PersonalInfo>();
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction();

                SqlCommand command = new SqlCommand();
                command.Transaction = transaction;
                command.Connection  = connection;
                command.Parameters.AddWithValue("@Start", (int)props.criteria.start);
                command.Parameters.AddWithValue("@Count", (int)props.criteria.count);

                command.CommandType    = CommandType.StoredProcedure;
                command.CommandText    = props.StoredFunction;
                command.CommandTimeout = 45;

                var outputparam = new SqlParameter("@Total", SqlDbType.Int);
                outputparam.Direction = ParameterDirection.Output;
                command.Parameters.Add(outputparam);
                var entities = command.ReadAll <HumanData>();

                transaction.Commit();

                findres.Entities = entities;
                findres.Total    = Convert.ToInt32(outputparam.Value);
コード例 #2
0
        private void OnLogin_SearchRes(Datagram datagram)
        {
            SearchRes res = datagram.UnSerialData <SearchRes>();

            if (RunningDatas.RequestTable.TryGetValue(datagram.RequestID, out RequestSender value))
            {
                value.RequestCallback(res);
            }
        }
コード例 #3
0
        private void SearchBindData(bool newSearch)
        {
            try
            {
                if (newSearch && !CheckSearchRequest())
                {
                    return;
                }
                else if (newSearch || Mession.SearchData == null)
                {
                    SearchWhatFlags sw      = (SearchWhatFlags)System.Enum.Parse(typeof(SearchWhatFlags), listSearchWhat.SelectedValue);
                    SearchWhatFlags sfw     = (SearchWhatFlags)System.Enum.Parse(typeof(SearchWhatFlags), listSearchFromWho.SelectedValue);
                    int             forumID = int.Parse(listForum.SelectedValue);

                    DataTable searchDataTable = YAF.Classes.Data.DB.GetSearchResult(txtSearchStringWhat.Text,
                                                                                    txtSearchStringFromWho.Text, sfw, sw, forumID,
                                                                                    PageContext.PageUserID, PageContext.PageBoardID,
                                                                                    PageContext.BoardSettings.ReturnSearchMax,
                                                                                    PageContext.BoardSettings.UseFullTextSearch);
                    Pager.CurrentPageIndex = 0;
                    Pager.PageSize         = int.Parse(listResInPage.SelectedValue);
                    Pager.Count            = searchDataTable.DefaultView.Count;
                    Mession.SearchData     = searchDataTable;

                    bool bResults = (searchDataTable.DefaultView.Count > 0) ? true : false;

                    SearchRes.Visible = bResults;
                    NoResults.Visible = !bResults;
                }

                PagedDataSource pds = new PagedDataSource();
                pds.AllowPaging      = true;
                pds.DataSource       = Mession.SearchData.DefaultView;
                pds.PageSize         = Pager.PageSize;
                pds.CurrentPageIndex = Pager.CurrentPageIndex;

                UpdateHistory.AddEntry(Pager.CurrentPageIndex.ToString() + "|" + Pager.PageSize);

                SearchRes.DataSource = pds;
                SearchRes.DataBind();
            }
            catch (Exception x)
            {
                YAF.Classes.Data.DB.eventlog_create(PageContext.PageUserID, this, x);
                CreateMail.CreateLogEmail(x);

                if (PageContext.IsAdmin)
                {
                    PageContext.AddLoadMessage(string.Format("{0}", x));
                }
                else
                {
                    PageContext.AddLoadMessage("An error occured while searching.");
                }
            }
        }
コード例 #4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            tsLabel.Text = "Поиск...";
            Application.DoEvents();
            lvUsers.Items.Clear();
            try
            {
                String _strfilter = string.Empty;
                switch (Filter)
                {
                case 1: _strfilter = string.Format("(&((objectClass=user)(|(name={0}*)(sAMAccountName={0}*)(mail={0}*)))", tbUser.Text); break;

                case 2: _strfilter = string.Format("(&((objectClass=group)(name={0}*)))", tbUser.Text); break;

                default: _strfilter = string.Format("(&(|(objectClass=user)(objectClass=group))(|(name={0}*)(sAMAccountName={0}*)(mail={0}*)))", tbUser.Text); break;
                }
                DirectorySearcher      DirSearch    = new DirectorySearcher(rootEntry, _strfilter);
                SearchResultCollection SearchResult = DirSearch.FindAll();
                //ArrayList PathArr = new ArrayList();
                foreach (SearchResult SearchRes in SearchResult)
                {
                    ListViewItem lvi = new ListViewItem(SearchRes.GetDirectoryEntry().Properties["name"].Value.ToString());
                    try
                    {
                        lvi.Tag = SearchRes.GetDirectoryEntry().Properties["distinguishedName"].Value.ToString();
                        lvi.SubItems.Add(SearchRes.GetDirectoryEntry().Properties["sAMAccountName"].Value.ToString());
                    }
                    catch { }
                    try
                    {
                        lvi.SubItems.Add(SearchRes.GetDirectoryEntry().Properties["mail"].Value.ToString());
                    }
                    catch
                    {
                        lvi.SubItems.Add("");
                    }
                    try
                    {
                        lvi.SubItems.Add(ConvertSidToString((byte[])SearchRes.GetDirectoryEntry().Properties["objectSid"].Value));
                    }
                    catch {
                        lvi.SubItems.Add("");
                    }
                    //PathArr.Add(SearchRes.GetDirectoryEntry().Path);
                    lvUsers.Items.Add(lvi);
                }
                DirSearch.Dispose();
            }
            catch (Exception ee) {
                MessageBox.Show(ee.Message);
            }
            tsLabel.Text = string.Format("{0} объекта(ов) найдено", lvUsers.Items.Count);
        }
コード例 #5
0
        public static SearchResModel Map(SearchRes searchRes, UrlHelper urlHelper)
        {
            if (searchRes == null)
            {
                return(null);
            }

            var searchResModel = SearchResMapper.Map <SearchResModel>(searchRes);

            searchResModel.Url = urlHelper.Link(Config.QuestionsRoute, new { id = searchRes.PostId });

            return(searchResModel);
        }
コード例 #6
0
 private void SearchResCallback(SearchRes res)
 {
     LoadingOverlay.Instance.Hide();
     _friendModel.SearchFriendInfo = res.FriendBase;
     Debug.LogError(res.FriendBase);
     if (res.FriendBase != null)
     {
         MakeFriendsView.SetSearchFriendItem(_friendModel.SearchFriendInfo);
     }
     else
     {
         FlowText.ShowMessage(I18NManager.Get("Friend_NoThisFriend"));
     }
 }
コード例 #7
0
ファイル: servicelasses.cs プロジェクト: Daniil609/lr4
            public void GenerateXmlFile(SearchRes <PersonalInfo> data, string Pathtosave, string Filename)
            {
                List <PersonalInfo> list = new List <PersonalInfo>();

                foreach (var variable in data.Entities)
                {
                    list.Add(variable);
                }
                XmlSerializer formatter = new XmlSerializer(typeof(List <PersonalInfo>));

                using (FileStream fs = new FileStream(Path.Combine(Pathtosave, Filename), FileMode.Append))
                {
                    formatter.Serialize(fs, list);
                }
            }
コード例 #8
0
        public void RequestCallback(object response)
        {
            SearchBox.IsEnabled = true;
            OperationTimer.Stop();

            SearchRes res = response as SearchRes;

            if (SearchRes.SearchType_User == res.SearchType)
            {
                UserCallBack((SearchRes.UserSearchResult[])res.SearchResult);
            }
            else
            {
                UserCallBack((SearchRes.GroupSearchResult[])res.SearchResult);
            }
        }
コード例 #9
0
ファイル: reprozit.cs プロジェクト: Daniil609/lr4
        public SearchRes <PersonalInfo> GetPersons()
        {
            using (var connection = new SqlConnection(props.connectionString))
            {
                var findres = new SearchRes <PersonalInfo>();
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction();
                try
                {
                    SqlCommand command = new SqlCommand();
                    command.Transaction = transaction;
                    command.Connection  = connection;
                    command.Parameters.AddWithValue("@Start", (int)props.criteria.start);
                    command.Parameters.AddWithValue("@Count", (int)props.criteria.count);

                    command.CommandType    = CommandType.StoredProcedure;
                    command.CommandText    = props.StoredFunction;
                    command.CommandTimeout = 45;
                    // command.ExecuteNonQuery();

                    var outputparam = new SqlParameter("@Total", SqlDbType.Int);
                    outputparam.Direction = ParameterDirection.Output;
                    command.Parameters.Add(outputparam);
                    var entities = command.ReadAll <PersonalInfo>();

                    transaction.Commit();
                    // var findres = new SearchRes<PersonalInfo>
                    // {
                    findres.Entities = entities;
                    findres.Total    = Convert.ToInt32(outputparam.Value);
                    //  };
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    IErLogger logger = new Logger();
                    logger.WriteError(ex);
                }
                finally
                {
                    connection.Close();
                }

                return(findres);
            }
        }
コード例 #10
0
        public async Task <SearchRes> SearchAsync(SearchReq searchRequest)
        {
            try
            {
                if (searchRequest == null)
                {
                    throw new ArgumentNullException(nameof(searchRequest));
                }

                var       type         = _searchingHelpers.GetSearchTypeFromSearchReq(searchRequest);
                SearchRes searchResult = new SearchRes();

                var hotels = await _context.Hotels
                             .Where(x => x.DestinationCode == searchRequest.Destination)
                             .ToListAsync();

                var flights = await _context.Flights
                              .Where(x => x.ArrivalAirport == searchRequest.Destination && x.DepartureAirport == searchRequest.DepartureAirport)
                              .ToListAsync();

                var random = new Random();
                switch (type)
                {
                case Enums.SearchType.HotelOnly:
                    foreach (var hotel in hotels)
                    {
                        Option item = new Option();
                        item.OptionCode     = "random";
                        item.HotelCode      = hotel.HotelCode.ToString();
                        item.FlightCode     = "";
                        item.ArrivalAirport = searchRequest.Destination;
                        item.Price          = random.NextDouble(100, 999);

                        searchResult.Options.Add(item);
                    }
                    break;

                case Enums.SearchType.HotelAndFlight:
                    //do a HotelAndFlight search
                    //The response should be a combination of flights and hotels
                    foreach (var hotel in hotels)
                    {
                        Option item = new Option();


                        item.OptionCode     = "random";
                        item.HotelCode      = hotel.HotelCode.ToString();
                        item.FlightCode     = "";
                        item.ArrivalAirport = searchRequest.Destination;
                        item.Price          = random.NextDouble(100, 999);


                        searchResult.Options.Add(item);
                    }
                    foreach (var flight in flights)
                    {
                        Option item = new Option();
                        item.OptionCode     = "random";
                        item.HotelCode      = "";
                        item.FlightCode     = flight.FlightCode.ToString();
                        item.ArrivalAirport = searchRequest.Destination;
                        item.Price          = random.NextDouble(100, 999);


                        searchResult.Options.Add(item);
                    }
                    break;

                case Enums.SearchType.LastMinuteHotels:
                    foreach (var hotel in hotels)
                    {
                        Option item = new Option();
                        item.OptionCode     = "random";
                        item.HotelCode      = hotel.HotelCode.ToString();
                        item.FlightCode     = "";
                        item.ArrivalAirport = searchRequest.Destination;
                        item.Price          = 58;

                        searchResult.Options.Add(item);
                    }
                    break;

                default:
                    break;
                }

                return(searchResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }