示例#1
0
        public IActionResult Run(RunParams runParams)
        {
            decimal numberOfUnits = runParams.NumberOfUnits;

            #region Demo
            List <Product> sortedProducts;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                sortedProducts = session.Query <Product>()
                                 #endregion
                                 #region Step_2
                                 .Where(x => x.UnitsInStock > numberOfUnits)
                                 #endregion
                                 #region Step_3
                                 .OrderByDescending(x => x.UnitsInStock)
                                 #endregion
                                 #region Step_4
                                 .ThenBy(x => x.Name, OrderingType.AlphaNumeric)
                                 #endregion
                                 #region Step_5
                                 .ToList();
                #endregion
            }
            #endregion

            return(Ok(sortedProducts));
        }
示例#2
0
        /// <summary>
        /// Initializes the controls on the startup form
        /// </summary>
        public Start()
        {
            InitializeComponent();

            Array actions = Enum.GetValues(typeof(BotRegistry.BotActions));

            string[] names = new string[actions.Length];
            for (int i = 0; i < actions.Length; i++)
            {
                names[i] = GetDescription((Enum)actions.GetValue(i));
            }
            BotActionSelect.DataSource         = names;
            RotationBotActionSelect.DataSource = names;

            StartButtons = new List <Button>();
            StartButtons.Add(StartButton);
            StartButtons.Add(RotationStart);
            StartButtons.Add(PhasmatysStartButton);

            Settings  = new BotSettings();
            RunParams = Settings.LoadSettings();
            BotManagerType.SelectedIndex = RunParams.SelectedTab;
            SetSoloBotForm();

            //simple rotation
            SetRotationBotSelector(RunParams.SelectedRotationBot);
            WriteRotationSettings();

            //Phasmatys rotation
            SetPhasmatysBotSelector(RunParams.SelectedPhasmatysBot);
            WritePhasmatysSettings();

            SetIdleState();
        }
示例#3
0
        /// <summary>
        /// The execute run params.
        /// </summary>
        /// <param name="runParams">
        /// The run params.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        /// <exception cref="ApplicationException">
        /// </exception>
        private static int ExecuteRunParams(RunParams runParams)
        {
            var config = configService.ReadConfiguration();

            if (string.IsNullOrEmpty(config.SteamPath))
            {
                throw new ApplicationException("The steam path must be configured before execution login. Please run '<app> config -s <full_path_to_steam>'");
            }

            if (!File.Exists(config.SteamPath))
            {
                throw new ApplicationException("Looks like steam path is not valid. Please run 'config' with correct steam path once more.");
            }

            if (runParams.Number > 0 && !string.IsNullOrEmpty(runParams.User))
            {
                throw new ApplicationException("Both user number and name are provided. Only one of the following fields can be used.");
            }

            if (runParams.Number > 0)
            {
                steamService.RunForAccount(runParams.Number);
                return(ExitCodes.Ok);
            }

            if (!string.IsNullOrEmpty(runParams.User))
            {
                steamService.RunForAccount(runParams.User);
                return(ExitCodes.Ok);
            }

            throw new ApplicationException("For deleting the user entry, at least valid number or a name must be provided.");
        }
示例#4
0
        public IActionResult Run(RunParams runParams)
        {
            int startYear = runParams.StartYear ?? 1993;

            #region Demo
            List <Employees_ByWorkPeriod.EmployeeProjectedDetails> employeesSinceYear;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                var employeesQuery = session
                                     #region Step_5
                                     .Query <Employees_ByWorkPeriod.IndexEntry, Employees_ByWorkPeriod>()
                                     .Where(employee => employee.WorkingInCompanySince > startYear)
                                     #endregion
                                     #region Step_6
                                     .OfType <Employee>()
                                     .Select(employee => new Employees_ByWorkPeriod.EmployeeProjectedDetails
                {
                    FirstName = employee.FirstName,
                    Phone     = employee.HomePhone,
                    Location  = employee.Address.City + ' ' + employee.Address.Country
                });
                #endregion

                #region Step_7
                employeesSinceYear = employeesQuery.ToList();
                #endregion
            }
            #endregion

            return(Ok(employeesSinceYear));
        }
        public IActionResult Run(RunParams runParams)
        {
            int price = runParams.Price ?? 5;

            #region Demo
            List <Product> lowCostProducts;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_5
                lowCostProducts = session.Query <Products_ByPrice.IndexEntry, Products_ByPrice>()
                                  .Where(product => product.SalePrice < price)
                                  .OrderBy(x => x.SalePrice)
                                  .OfType <Product>()
                                  .ToList();
                #endregion
            }
            #endregion

            // Manipulate results to show because index fields are Not stored..
            List <DataToShow> productsData = new List <DataToShow>();
            foreach (var item in lowCostProducts)
            {
                productsData.Add(new DataToShow()
                {
                    ProductName   = item.Name,
                    OriginalPrice = item.PricePerUnit,
                    SalesPrice    = item.PricePerUnit - item.PricePerUnit / 100 * 25,
                    ProfitPrice   = item.PricePerUnit + item.PricePerUnit / 100 * 25
                });
            }

            return(Ok(productsData));
        }
        public IActionResult Run(RunParams runParams)
        {
            decimal pricePerUnit = runParams.PricePerUnit;
            string  phone        = runParams.Phone;

            #region Demo
            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                Product product = session
                                  .Include <Product>(x => x.Supplier)
                                  .Load <Product>("products/34-A");
                #endregion

                #region Step_2
                Supplier supplier = session.Load <Supplier>(product.Supplier);
                #endregion

                #region Step_3
                product.PricePerUnit = pricePerUnit;
                supplier.Phone       = phone;
                #endregion

                #region Step_4
                session.SaveChanges();
                #endregion
            }
            #endregion

            return(Ok($"Document {DocumentId} was edited successfully"));
        }
        public IActionResult Run(RunParams runParams)
        {
            int boost1 = runParams.Boost1 ?? 100;
            int boost2 = runParams.Boost2 ?? 20;
            int boost3 = runParams.Boost3 ?? 5;

            #region Demo
            List <Employee> employeesWithMatchingTerms;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                employeesWithMatchingTerms = session.Query <Employee>()
                                             #endregion
                                             #region Step_2
                                             .Search(x => x.Notes, "ph.d.", boost: boost1)
                                             .Search(x => x.Notes, "university", boost: boost2)
                                             .Search(x => x.Notes, "college", boost: boost3)
                                             #endregion
                                             #region Step_3
                                             .ToList();
                #endregion
            }
            #endregion

            return(Ok(employeesWithMatchingTerms));
        }
示例#8
0
        /// <summary>
        /// Saves the last used settings for all bot programs to disk
        /// </summary>
        /// <returns>true if the save is successful</returns>
        public bool SaveSettings(RunParams runParams)
        {
            bool        success  = false;
            Stream      stream   = null;
            XmlDocument document = new XmlDocument();

            SanitizeRunParams(runParams);

            try
            {
                Directory.CreateDirectory(directoryPath);   //create the directory if it doesn't already exist
                stream = File.Open(filePath, FileMode.Create);
                serializer.Serialize(stream, runParams);
                success = true;
            }
            catch
            {
                //TODO
            }
            finally
            {
                stream.Close();
            }
            return(success);
        }
示例#9
0
        /// <summary>
        /// Loads the last used settings for all bot programs
        /// </summary>
        /// <param name="botAction"></param>
        /// <returns>true if the load is successful</returns>
        public RunParams LoadSettings()
        {
            Stream      stream   = null;
            XmlDocument document = new XmlDocument();
            RunParams   runParams;

            try
            {
                Directory.CreateDirectory(directoryPath);   //create the directory if it doesn't already exist
                stream    = File.Open(filePath, FileMode.OpenOrCreate);
                runParams = (RunParams)serializer.Deserialize(stream);
            }
            catch
            {
                runParams = new RunParams();
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }

            return(runParams);
        }
        public IActionResult Run(RunParams runParams)
        {
            string country = runParams.Country;

            #region Demo
            List <Employee> filteredEmployees;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                IQueryable <Employee> filteredQuery = session.Query <Employee>()
                                                      #endregion
                                                      #region Step_2
                                                      .Where(x =>
                                                             x.FirstName.In("Anne", "John") ||

                                                             (x.Address.Country == country &&
                                                              x.Territories.Count > 2 &&
                                                              x.Title.StartsWith("Sales")));
                #endregion

                #region Step_3
                filteredEmployees = filteredQuery.ToList();
                #endregion
            }
            #endregion

            return(Ok(filteredEmployees));
        }
        public async Task <IActionResult> Run(RunParams runParams)
        {
            string companyName = runParams.CompanyName ?? "New Company Name";

            await SetRunPrerequisites();

            #region Demo
            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                Company company = session.Load <Company>("companies/5-A");
                #endregion

                #region Step_2
                company.Name = companyName;
                #endregion

                #region Step_3
                session.SaveChanges();
                #endregion
            }
            #endregion

            return(Ok($"Document {DocumentId} was edited successfully"));
        }
        public IActionResult Run(RunParams runParams)
        {
            string term1 = runParams.Term1 ?? "Spanish";
            string term2 = runParams.Term2 ?? "Portuguese";
            string term3 = runParams.Term3 ?? "Manager";

            #region Demo
            List <Employee> employeesWithMatchingTerms;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                employeesWithMatchingTerms = session.Query <Employee>()
                                             #endregion
                                             #region Step_2
                                             .Search(x => x.Notes, $"{term1} {term2}", @operator: SearchOperator.And)
                                             #endregion
                                             #region Step_3
                                             .Search(x => x.Notes, $"{term3}", options: SearchOptions.Or)
                                             #endregion
                                             #region Step_4
                                             .ToList();
                #endregion
            }
            #endregion

            return(Ok(employeesWithMatchingTerms));
        }
        public IActionResult Run(RunParams runParams)
        {
            string companyId = runParams.companyId ?? "companies/1-A";

            #region Demo
            List <OrdersQuantity_ByCompany.OrderProjectedDetails> ordersDetails;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                var ordersQuery = session
                                  #region Step_6
                                  .Query <OrdersQuantity_ByCompany.IndexEntry, OrdersQuantity_ByCompany>()
                                  .Where(order => order.Company == companyId)
                                  #endregion
                                  #region Step_7
                                  .ProjectInto <OrdersQuantity_ByCompany.OrderProjectedDetails>();
                #endregion

                #region Step_8
                ordersDetails = ordersQuery.ToList();
                #endregion
            }
            #endregion

            return(Ok(ordersDetails));
        }
示例#14
0
        public Run RunTask(long tntId, long runId, RunParams param)
        {
            string           exMsg = String.Empty;
            List <Hashtable> data  = new List <Hashtable>();

            Models.Run runModel = new Models.Run();
            RunResult  rs       = new RunResult()
            {
                result = new Hashtable()
            };
            // New Run Entity
            var run = new Data.Entities.Run();

            _addRunQueryProcessor.AddRun(run);

            // Chg: Preparation for Run
            var chgStateGrp = _chgStateGrpQueryProcessor.Get(Constants.ChgStateGrpNames.RunTask);

            rs.result.Add(Constants.RunScriptNames.RunScriptResult, Constants.PSReturnCodes.notrunned);
            rs.result.Add(Constants.RunScriptNames.RunScriptResultMessage, Constants.ChgStateNames.PrepareForRun);
            rs.result.Add(Constants.RunScriptNames.RunScriptData, null);

            // Get Tenant
            var tnt = _tntQueryProcessor.Get(tntId);

            // tenant present?
            if (tnt != null)
            {
                // ...
            }
            return(runModel);
        }
        public IActionResult Run(RunParams runParams)
        {
            string start           = runParams.Start ?? "ma";
            string end             = runParams.End ?? "lin";
            string middle          = runParams.Middle ?? "oliv";
            int    numberOfResults = runParams.NumberOfResults ?? 10;

            #region Demo
            List <LastFm> songsWithMatchingTerms;

            using (IDocumentSession session = DocumentStoreHolder.MediaStore.OpenSession())
            {
                #region Step_1
                songsWithMatchingTerms = session.Query <LastFm>()
                                         #endregion
                                         #region Step_2
                                         .Search(x => x.Artist, $"{start}* *{end}", @operator: SearchOperator.And)
                                         #endregion
                                         #region Step_3
                                         .Search(x => x.Title, $"*{middle}*")
                                         #endregion
                                         #region Step_4
                                         .Take(numberOfResults)
                                         .OrderBy(x => x.Artist)
                                         #endregion
                                         #region Step_5
                                         .ToList();
                #endregion
            }
            #endregion

            return(Ok(songsWithMatchingTerms));
        }
示例#16
0
        public IActionResult Run(RunParams runParams)
        {
            int resultsToSkip = runParams.ResultsToSkip ?? 10;
            int resultsToTake = runParams.ResultsToTake ?? 5;

            #region Demo
            List <Company> pagedResults;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                pagedResults = session.Query <Company>()
                               #endregion
                               #region Step_2
                               .Statistics(out QueryStatistics stats)
                               #endregion
                               #region Step_3
                               .Skip(resultsToSkip)
                               #endregion
                               #region Step_4
                               .Take(resultsToTake)
                               #endregion
                               #region Step_5
                               .ToList();
                #endregion

                #region Step_6
                int totalResults = stats.TotalResults;
                #endregion
            }
            #endregion

            return(Ok(pagedResults));
        }
        public IActionResult Run(RunParams runParams)
        {
            string searchTerm     = runParams.SearchTerm ?? "smile";
            string preTag         = runParams.PreTag ?? " (: ";
            string postTag        = runParams.PostTag ?? " :) ";
            int    fragmentLength = runParams.FragmentLength ?? 80;
            int    fragmentCount  = runParams.FragmentCount ?? 1;

            Highlightings highlightingsInfo;

            #region Demo
            List <ArtistsAllSongs.IndexEntry> artistsResults;

            using (IDocumentSession session = DocumentStoreHolder.MediaStore.OpenSession())
            {
                #region Step_6
                HighlightingOptions highlightOptions = new HighlightingOptions
                {
                    GroupKey = "Artist",
                    PreTags  = new[] { preTag },
                    PostTags = new[] { postTag }
                };
                #endregion

                #region Step_7
                artistsResults = session.Query <ArtistsAllSongs.IndexEntry, ArtistsAllSongs>()
                                 .Highlight(x => x.AllSongTitles, fragmentLength, fragmentCount, highlightOptions, out highlightingsInfo)
                                 .Search(x => x.AllSongTitles, searchTerm)
                                 .ToList();
                #endregion

                #region Step_8
                if (artistsResults.Count > 0)
                {
                    string[] songsFragments = highlightingsInfo.GetFragments(artistsResults[0].Artist);
                }
                #endregion
            }
            #endregion

            List <DataToShow> highlightResults = new List <DataToShow>();

            foreach (var artistItem in artistsResults)
            {
                string[] songsFragments = highlightingsInfo.GetFragments(artistItem.Artist);
                foreach (var fragment in songsFragments)
                {
                    DataToShow itemResults = new DataToShow
                    {
                        Artist       = artistItem.Artist,
                        SongFragment = fragment
                    };

                    highlightResults.Add(itemResults);
                }
            }

            return(Ok(highlightResults.OrderBy(x => x.Artist)));
        }
示例#18
0
        public IActionResult Run(RunParams runParams)
        {
            int radius = runParams.Radius ?? 2;

            List <EmployeeDetails> queryResults          = new List <EmployeeDetails>();
            List <Employee>        employeesWithinCircle = new List <Employee>();

            #region Demo
            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_1
                double centerPointLng = -122.3150148;
                double centerPointLat = 47.63016419999999;

                string wktCircle = $"CIRCLE({centerPointLng} {centerPointLat} d={radius})";
                #endregion

                #region Step_2
                employeesWithinCircle = session.Query <Employee>()
                                        .Spatial(
                    #endregion
                    #region Step_3
                    spatialField => spatialField.Point(x => x.Address.Location.Latitude,
                                                       x => x.Address.Location.Longitude),
                    #endregion

                    #region Step_4
                    spatialCriteria => spatialCriteria.RelatesToShape(wktCircle,
                                                                      SpatialRelation.Within,
                                                                      SpatialUnits.Miles))
                                        #endregion
                                        #region Step_5
                                        .OrderByDistance(
                    spatialField => spatialField.Point(x => x.Address.Location.Latitude,
                                                       x => x.Address.Location.Longitude),
                    centerPointLat,
                    centerPointLng)
                                        #endregion
                                        #region Step_6
                                        .ToList();
                #endregion
            }
            #endregion

            foreach (var item in employeesWithinCircle)
            {
                var detailedItem = new EmployeeDetails()
                {
                    EmployeeName = item.FirstName + ' ' + item.LastName,
                    Longitude    = item.Address.Location.Longitude,
                    Latitude     = item.Address.Location.Latitude
                };

                queryResults.Add(detailedItem);
            }

            return(Ok(queryResults));
        }
示例#19
0
        /// <summary>
        /// Populates the simple rotation manager form with the values of the selected bot
        /// </summary>
        private void WriteRotationSettings()
        {
            RunParams settings = RunParams.RotationParams[RotationBotSelection];

            RotationLogin.Text    = settings.Login;
            RotationPassword.Text = settings.Password;
            RotationBotActionSelect.SelectedIndex = (int)settings.BotAction;
            RotationIterations.Value = Math.Max(0, settings.Iterations);
        }
示例#20
0
        public IActionResult Run(RunParams runParams)
        {
            int start    = runParams.Start ?? 3;
            int pageSize = runParams.PageSize ?? 2;

            string include = runParams.IncludeRemainingTerms;
            bool   includeRemainingTerms = include == null || include == "true";

            #region Demo
            #region Step_2
            List <FacetBase> facets = new List <FacetBase>
            #endregion
            {
                #region Step_3
                new Facet
                {
                    FieldName = "CategoryName",
                    Options   = new FacetOptions()
                    {
                        Start    = start,
                        PageSize = pageSize,
                        IncludeRemainingTerms = includeRemainingTerms,
                        TermSortMode          = FacetTermSortMode.CountDesc
                    },
                },
                #endregion
                new Facet
                {
                    FieldName = "Supplier",
                    Options   = new FacetOptions()
                    {
                        Start    = start,
                        PageSize = pageSize,
                        IncludeRemainingTerms = includeRemainingTerms,
                        TermSortMode          = FacetTermSortMode.ValueAsc
                    }
                }
            };

            Dictionary <string, FacetResult> queryResults;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_4
                queryResults = session.Query <Product, Products_ByCategoryAndSupplier>()
                               .AggregateBy(facets)
                               .Execute();
                #endregion
            }
            #endregion

            return(Ok(queryResults));
        }
示例#21
0
        internal TaskToolWindow(RunParams runParams, Type configType, object config, Action <object, ITaskController> runTask)
        {
            InitializeComponent();
            pgConfigObject.SelectedObject = config;
            ConfigType = configType;

            RunTask = runTask;
            if (!runParams.Wait)
            {
                DoRunTask();
            }
        }
示例#22
0
 /// <summary>
 /// Collects start parameters from solo bot form and general settings
 /// </summary>
 /// <returns></returns>
 private void CollectGeneralSettings()
 {
     RunParams               = RunParams ?? new RunParams();
     RunParams.Login         = Login.Text;
     RunParams.Password      = Password.Text;
     RunParams.Iterations    = (int)Iterations.Value;
     RunParams.RunUntil      = RunUntil.Value;
     RunParams.BotAction     = (BotRegistry.BotActions)BotActionSelect.SelectedIndex;
     RunParams.JagexClient   = JagexClientLocation.Text;
     RunParams.OSBuddyClient = OSBuddyClientLocation.Text;
     RunParams.TaskComplete  = new BotResponse(BotDone);
 }
        public IActionResult Run(RunParams runParams)
        {
            string supplierName  = runParams.SupplierName ?? "Hibernating Rhinos";
            string supplierPhone = runParams.SupplierPhone ?? "(+972)52-5486969";
            string productName   = runParams.ProductName ?? "RavenDB";

            #region Demo
            #region Step_1
            Supplier supplier = new Supplier
            {
                Name  = supplierName,
                Phone = supplierPhone
            };

            Category category = new Category
            {
                Name        = "NoSQL Databases",
                Description = "Non-relational databases"
            };
            #endregion

            #region Step_2
            Product product = new Product
            {
                Name = productName
            };
            #endregion

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_3
                session.Store(supplier);
                session.Store(category);
                #endregion

                #region Step_4
                product.Supplier = supplier.Id;
                product.Category = category.Id;
                #endregion

                #region Step_5
                session.Store(product);
                #endregion

                #region Step_6
                session.SaveChanges();
                #endregion
            }
            #endregion

            return(Ok($"Document {product.Id} was created successfully"));
        }
示例#24
0
        public IActionResult Run(RunParams runParams)
        {
            int fragmentLength = runParams.FragmentLength ?? 50;
            int fragmentCount  = runParams.FragmentCount ?? 2;

            Highlightings notesHighlightings;

            #region Demo
            List <Employee> employeesResults;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_5
                employeesResults = session.Query <EmployeesDetails.IndexEntry, EmployeesDetails>()
                                   .Highlight("Notes", fragmentLength, fragmentCount, out notesHighlightings)
                                   .Search(x => x.Notes, "sales")
                                   .OfType <Employee>()
                                   .ToList();
                #endregion

                #region Step_6
                if (employeesResults.Count > 0)
                {
                    string   employeeId     = employeesResults[0].Id;
                    string[] notesFragments = notesHighlightings.GetFragments(employeeId);
                }
                #endregion
            }
            #endregion

            List <DataToShow> highlightResults = new List <DataToShow>();

            foreach (var employee in employeesResults)
            {
                string[] notesFragments = notesHighlightings.GetFragments(employee.Id);
                foreach (var item in notesFragments)
                {
                    DataToShow itemResults = new DataToShow
                    {
                        documentId = employee.Id,
                        indexField = notesHighlightings.FieldName,
                        fragment   = item
                    };

                    highlightResults.Add(itemResults);
                }
            }

            return(Ok(highlightResults.OrderByDescending(x => x.indexField)));
        }
        public IActionResult Run(RunParams runParams)
        {
            string cmpXchgKey   = runParams.CmpXchgKey ?? "*****@*****.**";
            string cmpXchgValue = runParams.CmpXchgValue ?? "employee/1-A";

            string result = null;

            #region Demo
            #region Step_1
            var putCmpXchgOperation =
                new PutCompareExchangeValueOperation <string>(cmpXchgKey, cmpXchgValue, 0);

            CompareExchangeResult <string> putCmpXchgResult =
                DocumentStoreHolder.Store.Operations.Send(putCmpXchgOperation);
            #endregion

            #region Step_2
            var success    = putCmpXchgResult.Successful;
            var putValue   = putCmpXchgResult.Value;
            var putVersion = putCmpXchgResult.Index;

            if (success == false)
            {
                result = "Key already exists";
            }
            #endregion

            #region Step_3
            var getCmpXchgOperation =
                new GetCompareExchangeValueOperation <string>(cmpXchgKey);

            CompareExchangeValue <string> getCmpXchgResult =
                DocumentStoreHolder.Store.Operations.Send(getCmpXchgOperation);
            #endregion

            #region Step_4
            var key                 = getCmpXchgResult.Key;
            var currentValue        = getCmpXchgResult.Value;
            var currentValueVersion = getCmpXchgResult.Index;
            var currentMetadata     = getCmpXchgResult.Metadata;
            #endregion
            #endregion

            result = result ?? $"Created a new Compare-Exchange Key: {key}, Value: {currentValue}, Value Version: {currentValueVersion}";
            return(Ok(result));
        }
示例#26
0
        public IActionResult Run(RunParams runParams)
        {
            string country = runParams.Country;
            int    numberOfEmployeesFromCountry;

            #region Demo
            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_5
                Employees_ByCountry.Result queryResult = session.Query <Employees_ByCountry.Result, Employees_ByCountry>()
                                                         .FirstOrDefault(x => x.Country == country);

                numberOfEmployeesFromCountry = queryResult?.CountryCount ?? 0;
                #endregion
            }
            #endregion

            return(Ok($"Number of employees from : {country.ToUpper()} is: {numberOfEmployeesFromCountry}"));
        }
        public IActionResult Run(RunParams runParams)
        {
            string searchTerm = runParams.SearchTerm ?? "Pasta";

            #region Demo
            List <Category> categoriesWithSearchTerm;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_5
                categoriesWithSearchTerm = session.Query <Categories_DescriptionText.IndexEntry, Categories_DescriptionText>()
                                           .Where(x => x.CategoryDescription == searchTerm)
                                           .OfType <Category>()
                                           .ToList();
                #endregion
            }
            #endregion

            return(Ok(categoriesWithSearchTerm));
        }
示例#28
0
        public IActionResult Run(RunParams runParams)
        {
            string namePrefix = runParams.NamePrefix ?? "A";

            #region Demo
            List <CompaniesAndSuppliers_ByName.IndexEntry> companiesAndSuppliersNames;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_4
                companiesAndSuppliersNames = session.Query <CompaniesAndSuppliers_ByName.IndexEntry, CompaniesAndSuppliers_ByName>()
                                             .Where(doc => doc.Name.StartsWith(namePrefix))
                                             .ToList();

                #endregion
            }
            #endregion

            return(Ok(companiesAndSuppliersNames));
        }
        public IActionResult Run(RunParams runParams)
        {
            int minValue = runParams.MinValue ?? 25;

            #region Demo
            List <Product> products;

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_4
                products = session.Query <Products_ByUnitsInStock.IndexEntry, Products_ByUnitsInStock>()
                           .Where(indexEntry => indexEntry.UnitsInStock > minValue)
                           .OfType <Product>()
                           .ToList();
                #endregion
            }
            #endregion

            return(Ok(products));
        }
示例#30
0
        public IActionResult Run(RunParams runParams)
        {
            string companyName  = runParams.CompanyName;
            string companyPhone = runParams.CompanyPhone;
            string contactName  = runParams.ContactName;
            string contactTitle = runParams.ContactTitle;

            string theNewDocumentId;

            #region Demo
            #region Step_1
            Company newCompany = new Company
            {
                Name    = companyName,
                Phone   = companyPhone,
                Contact = new Contact
                {
                    Name  = contactName,
                    Title = contactTitle
                }
            };
            #endregion

            using (IDocumentSession session = DocumentStoreHolder.Store.OpenSession())
            {
                #region Step_2
                session.Store(newCompany);
                #endregion

                #region Step_3
                theNewDocumentId = newCompany.Id;
                #endregion

                #region Step_4
                session.SaveChanges();
                #endregion
            }
            #endregion

            return(Ok($"Document {theNewDocumentId} was created successfully"));
        }