コード例 #1
0
    private List <MakeOrder> GetPredictions()
    {
        var predictions = new List <MakeOrder>();

        foreach (var master in StaticInventoryTracker.ProductMasterList) //.Where(p => p.MadeIn.Equals("Coating")))
        {
            double pieces = master.PiecesPerUnit * master.TargetSupply;

            StaticFunctions.OutputDebugLine("Creating new prediction for " + master);
            MakeOrder newOrder = new MakeOrder(master.MasterID, pieces)
            {
                DueDay = CurrentDay
            };
            // assume the current day is the due date unless we have inventory data (Could have no inventory)
            // forecast out when the order should be due
            var inv = CurrentInventory.FirstOrDefault(i => i.MasterID == master.MasterID);
            if (inv != null)
            {
                double currentInv  = inv.Units;
                double usedPerDay  = GetAvgUnitsPerDay(master) * 30;
                int    daysTillOut = (int)Math.Floor(currentInv / usedPerDay);
                newOrder.DueDay = CurrentDay.AddDays(daysTillOut);
                StaticFunctions.OutputDebugLine("Found inventory of " + currentInv + " for prediction " + master +
                                                " predicted to run out in " + daysTillOut + " days");
            }
            predictions.Add(newOrder);
        }

        return(predictions);
    }
コード例 #2
0
        public void Order(Pizzeria pizzeria, Pizzeria.Pizza pizza)
        {
            MakeOrder          += pizzeria.NewOrder;
            pizzeria.GivePizza += GetPizza;

            MakeOrder?.Invoke(pizza);
        }
コード例 #3
0
        public void Kør()
        {
            List <Customer> customers = new List <Customer>();
            List <Item>     items     = new List <Item>();

            int optionDecider;

            do
            {
                Console.WriteLine("1)  Ny Kunde \n2)  Ny Vare \n3)  Udskriv Order\n4)  Exit");
                optionDecider = int.Parse(Console.ReadLine());
                switch (optionDecider)
                {
                case 1:
                    customers.Add(MakeCustomer());
                    Console.WriteLine("Nuværende id: {0}", customers[customers.Count - 1].CustomerId);
                    break;

                case 2:
                    items.Add(MakeItem());
                    Console.WriteLine("Nuværnde pris og Id: {0} {1}", items[items.Count - 1].ItemPrice, items[items.Count - 1].ItemId);
                    break;

                case 3:
                    MakeOrder makeOrder = new MakeOrder(customers, items);
                    Console.WriteLine(makeOrder.GetOrder());
                    Console.ReadLine();
                    break;

                default:
                    break;
                }
            } while (Exit(optionDecider));
        }
コード例 #4
0
        public string ImportTrade(String InputJson)
        {
            try
            {
                string    mark       = InputJson.Substring(0, 2);
                string    jsonString = InputJson.Substring(2);
                MakeOrder order      = new MakeOrder();

                if (mark == "C1")
                {
                    order = (JsonConvert.DeserializeObject <MakeOrder>(jsonString));
                }

                List <MakeOrder> orders = new List <MakeOrder>();
                orders.Add(order);

                queue_prd_trade_from_tradeMonitor.GetQueue().Enqueue((object)orders);

                return("SUCCESS");
            }
            catch (Exception ex)
            {
                GlobalErrorLog.LogInstance.LogEvent("生成交易失败: " + InputJson);
                DBAccessLayer.LogSysInfo("HomeController", ex.ToString());
                return("FALSE");
            }
        }
コード例 #5
0
 private void createOrder()
 {
     if (addItem == null)
     {
         addItem = new MakeOrder();
         addItem.Show();
     }
 }
コード例 #6
0
        public static MakeOrder Create(MakeOrderView v)
        {
            var o = new MakeOrder();

            Copy.Members(v, o.Data);

            return(o);
        }
コード例 #7
0
        public static MakeOrderView Create(MakeOrder o)
        {
            var v = new MakeOrderView();

            Copy.Members(o.Data, v);

            return(v);
        }
コード例 #8
0
 public async Task HandleAsync(MakeOrder message, ISagaContext context)
 {
     _logger.LogInformation($"Started a saga for order: {message.OrderId}, customer: {message.CustomerId}," +
                            $"parcels: {message.ParcelId}");
     Data.ParcelIds.Add(message.ParcelId);
     Data.OrderId    = message.OrderId;
     Data.CustomerId = message.CustomerId;
     await _publisher.SendAsync(new CreateOrder(Data.OrderId, message.CustomerId), _accessor.CorrelationContext);
 }
コード例 #9
0
 public OrderForm()
 {
     InitializeComponent();
     getAll    = new GetAll();
     makeOrder = new MakeOrder();
     dishes    = new List <Dish>();
     foreach (var i in getAll.Dishes)
     {
         DishesComboBox.Items.Add(i.Name);
     }
 }
コード例 #10
0
 public MakeOrderViewModel(MakeOrder openOrder, tblDish dish, User user)
 {
     thisOrder = openOrder;
     pizza     = dish;
     newOrder  = new tblOrder()
     {
         dishId      = pizza.dishId,
         dateAndTime = DateTime.Now,
         status      = "waiting",
         username    = user.username
     };
 }
コード例 #11
0
 private void StartExecute()
 {
     try
     {
         MakeOrder create = new MakeOrder();
         main.Close();
         create.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #12
0
ファイル: ItemController.cs プロジェクト: mokth/orderAppAPI
        public JsonResult FavuoriteItems([FromBody] MakeOrder order)
        {
            FavouriteItemHelper hlp = new FavouriteItemHelper(_context);
            bool success            = hlp.AddFavourites(order);

            JsonResult restultJson = Json(new
            {
                ok    = (success) ? "yes" : "no",
                error = hlp.Errmsg
            });

            return(restultJson);
        }
コード例 #13
0
ファイル: OrderController.cs プロジェクト: mokth/orderAppAPI
        public JsonResult Post([FromBody] MakeOrder order)
        {
            OrderHelper hlp     = new OrderHelper(_context);
            int         success = hlp.MakeOrder(order);

            JsonResult restultJson = Json(new
            {
                ok         = (success == 0) ? "yes" : "no",
                returncode = success,
                error      = hlp.Errmsg
            });

            return(restultJson);
        }
コード例 #14
0
        public IActionResult MakeOrder(MakeOrder order)
        {
            try
            {
                long id_order = _context.MakeOrder(order.Phone_number, order.Id_order_type, order.Start_point_lat, order.Start_point_long,
                                                   order.End_point_lat, order.End_point_long, order.Child, order.Pets);
                if (id_order != 0)
                {
                    var   real_order = _context.Orders.Find(id_order);
                    Regex regex      = new Regex("^((375)+([0-9]){9})$");

                    if (regex.IsMatch(real_order.id_client))
                    {
                        var client = new Client(creds: new Nexmo.Api.Request.Credentials
                        {
                            ApiKey    = "4dd35858",
                            ApiSecret = "uEKy30WoKHpgQaBa"
                        });
                        SMS.SMSRequest sms = new SMS.SMSRequest()
                        {
                            from = "TaxiStation_Course",
                            //to = "375292953436",
                            to   = real_order.id_client,
                            text = "Security Code for order " + real_order.id + ": " + real_order.security_code
                        };

                        ////////var results = client.SMS.Send(sms);
                        ViewData["Id_order"] = id_order;
                        return(View("ConfirmOrder"));
                    }
                    else
                    {
                        throw new Exception(message: "Order didnt create!");
                    }
                }
                else
                {
                    throw new Exception(message: "Order didnt create!");
                }
            }
            catch (Exception sqlException)
            {
                ModelState.AddModelError("", sqlException.Message);
                return(View("MakeOrder"));
            }
        }
コード例 #15
0
        public string GetBatchTrade(string user)
        {
            try
            {
                List <string>    strs   = pythonOper.GetInstance().GetBatchTradeList();
                List <MakeOrder> orders = new List <MakeOrder>();

                foreach (string s in strs)
                {
                    try
                    {
                        string[] vars = s.Split('\t');

                        MakeOrder order = new MakeOrder()
                        {
                            belongStrategy  = "00",
                            User            = vars[0].Trim(),
                            exchangeId      = vars[1].Trim().ToUpper(),
                            cSecurityCode   = vars[2].Trim(),
                            nSecurityAmount = Convert.ToInt64(vars[3].Trim()),
                            dOrderPrice     = Convert.ToDouble(vars[4].Trim()),
                            cTradeDirection = vars[5].Trim(),
                            offsetflag      = vars[6].Trim(),
                            cSecurityType   = vars[7].Trim(),
                            OrderRef        = 0
                        };


                        orders.Add(order);
                    }
                    catch
                    {
                        GlobalErrorLog.LogInstance.LogEvent("批量交易生成部分失败:" + s);
                        return("FALSE");
                    }
                }

                return(JsonConvert.SerializeObject(orders));
            }
            catch (Exception ex)
            {
                DBAccessLayer.LogSysInfo("HomeController-ImportBatchTrades", ex.ToString());
                return(ex.ToString());
            }
        }
コード例 #16
0
 private void OrderPizzaExecute()
 {
     try
     {
         if (pizza != null)
         {
             MakeOrder newOrder = new MakeOrder(pizza, currentUser);
             newOrder.ShowDialog();
             if ((newOrder.DataContext as MakeOrderViewModel).isMade == true)
             {
                 btnToOrder       = Visibility.Collapsed;
                 myOrdersList     = Service.Service.GetOrdersByUsername(currentUser.username);
                 ordersVisibility = Visibility.Visible;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #17
0
ファイル: ProductService.cs プロジェクト: akshatdataman/Test
        public void MakeOrder(MakeOrder orderObj)
        {
            ProductOrder            productOrder;
            List <ProductOrderItem> productOrderItems;

            // Add order record.
            var order = new Order
            {
                CustomerId = orderObj.CustomerId,
                CreatedOn  = DateTime.UtcNow
            };

            _orderRepository.Add(order);

            // Add product order records.
            foreach (var op in orderObj.OrderedProducts)
            {
                productOrder = new ProductOrder
                {
                    Order     = order,
                    ProductId = op.ProductId
                };

                _productOrderRepository.Add(productOrder);

                // Add product order item records based on the needed count.
                List <ProductLineItem> availableItems = _orderRepository.GetAvailableItems(op.ProductId, op.Count);
                productOrderItems = availableItems.Select(a => new ProductOrderItem
                {
                    ProductLineItemId = a.Id,
                    ProductOrder      = productOrder
                }).ToList();

                _orderRepository.AddProductOrderItems(productOrderItems);
            }

            // Commit the changes to the database.
            _unitOfWork.Commit();
        }
コード例 #18
0
ファイル: Form1.cs プロジェクト: infra-hdc/LIBFL
        private void bCirculationMakeOrder_Click(object sender, EventArgs e)
        {
            CirculationInfo ci = new CirculationInfo();
            MakeOrder       mo = new MakeOrder();

            mo.BookId      = "BJACC_4381";
            mo.ReaderId    = 15;
            mo.OrderTypeId = 1;
            ci.MakeOrder(mo);


            //CirculationInfo ci = new CirculationInfo();
            //MakeOrder mo = new MakeOrder();
            ////mo.BookId = "BJVVV_1007658";
            ////mo.ReaderId = 100000;
            ////mo.OrderType = "Электронная выдача";
            ////ci.MakeOrder(mo);

            ////mo.BookId = "BJVVV_1310093";
            ////mo.ReaderId = 100000;
            ////mo.OrderType = "На дом";
            ////ci.MakeOrder(mo);

            //mo.BookId = "BJVVV_193768";
            //mo.ReaderId = 10000;
            //mo.OrderTypeId = 2;
            ////ci.MakeOrder(mo);

            //string jsonData = JsonConvert.SerializeObject(mo, ALISDateFormatJSONSettings);

            //using (HttpClient client = new HttpClient())
            //{
            //    var response = client.PostAsync(ALIS_ADDRESS + "Circulation/Order", new StringContent(jsonData, Encoding.UTF8, "application/json"));
            //    tbResponse.Text = response.Result.Content.ReadAsStringAsync().Result + " " + response.Result.StatusCode; ;
            //}
        }
コード例 #19
0
 public void exit()
 {
     addItem = null;
 }
コード例 #20
0
        public static void Register(HttpConfiguration config)
        {
            //// Uncomment the following to use the documentation from XML documentation file.
            config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/Documentation/documentation.xml")));

            //// Uncomment the following to use "sample string" as the sample for all actions that have string as the body parameter or return type.
            //// Also, the string arrays will be used for IEnumerable<string>. The sample objects will be serialized into different media type
            //// formats by the available formatters.
            //config.SetSampleObjects(new Dictionary<Type, object>
            //{
            //    {typeof(string), "sample string"},
            //    {typeof(IEnumerable<string>), new string[]{"sample 1", "sample 2"}}
            //});

            // Extend the following to provide factories for types not handled automatically (those lacking parameterless
            // constructors) or for which you prefer to use non-default property values. Line below provides a fallback
            // since automatic handling will fail and GeneratePageResult handles only a single type.
#if Handle_PageResultOfT
            config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult);
#endif

            // Extend the following to use a preset object directly as the sample for all actions that support a media
            // type, regardless of the body parameter or return type. The lines below avoid display of binary content.
            // The BsonMediaTypeFormatter (if available) is not used to serialize the TextSample object.
            config.SetSampleForMediaType(
                new TextSample("Binary JSON content. See http://bsonspec.org for details."),
                new MediaTypeHeaderValue("application/bson"));

            //// Uncomment the following to use "[0]=foo&[1]=bar" directly as the sample for all actions that support form URL encoded format
            //// and have IEnumerable<string> as the body parameter or return type.
            //config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable<string>));

            //// Uncomment the following to use "1234" directly as the request sample for media type "text/plain" on the controller named "Values"
            //// and action named "Put".
            //config.SetSampleRequest("1234", new MediaTypeHeaderValue("text/plain"), "Values", "Put");

            //// Uncomment the following to use the image on "../images/aspNetHome.png" directly as the response sample for media type "image/png"
            //// on the controller named "Values" and action named "Get" with parameter "id".
            //config.SetSampleResponse(new ImageSample("../images/aspNetHome.png"), new MediaTypeHeaderValue("image/png"), "Values", "Get", "id");

            //// Uncomment the following to correct the sample request when the action expects an HttpRequestMessage with ObjectContent<string>.
            //// The sample will be generated as if the controller named "Values" and action named "Get" were having string as the body parameter.
            //config.SetActualRequestType(typeof(string), "Values", "Get");

            //// Uncomment the following to correct the sample response when the action returns an HttpResponseMessage with ObjectContent<string>.
            //// The sample will be generated as if the controller named "Values" and action named "Post" were returning a string.
            //config.SetActualResponseType(typeof(string), "Values", "Post");


            ReaderInfo reader = ReaderInfo.GetReader(189245);
            //Readers.Get
            ReaderSimpleView rsv  = ReaderViewFactory.GetReaderSimpleView(reader);
            string           json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "Get");


            //Readers.GetByOauthToken
            AccessToken token = new AccessToken();
            token.TokenValue = "jhgfjfg*%&$*FKGfkfKfI^(*&^5&^TGVfjtgfdtre$E65r86T87t)(*7goYGV986T98^&Go8yg";
            json             = JsonConvert.SerializeObject(token, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetByOauthToken");

            json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetByOauthToken");

            ////Readers.ChangePasswordLocalReader
            //ChangePasswordLocalReader password = new ChangePasswordLocalReader();
            //password.DateBirth = "1984-02-14";// new DateTime(1984, 2, 14);
            //password.NewPassword = "******";
            //password.NumberReader = 189245;
            //json = JsonConvert.SerializeObject(password, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            //config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ChangePasswordLocalReader");

            //Readers.GetLoginType
            LoginType ltype = new LoginType();
            ltype.LoginTypeValue = "Email";
            json = JsonConvert.SerializeObject(ltype, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetLoginType");
            UserLogin ul = new UserLogin();
            ul.Login = "******";
            json     = JsonConvert.SerializeObject(ul, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "GetLoginType");


            //Readers.ByEmail
            UserEmail ue = new UserEmail();
            ue.Email = "*****@*****.**";
            json     = JsonConvert.SerializeObject(ue, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ByEmail");
            json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "ByEmail");



            //Readers.Authorize
            AuthorizeInfo aut = new AuthorizeInfo();
            aut.login    = "******";
            aut.password = "******";
            json         = JsonConvert.SerializeObject(aut, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "Authorize");
            config.SetSampleForType(aut, new MediaTypeHeaderValue("application/json"), typeof(AuthorizeInfo));
            config.SetActualRequestType(typeof(AuthorizeInfo), "Readers", "Authorize");
            json = JsonConvert.SerializeObject(rsv, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "Authorize");

            //Readers / IsBirthDateMatchReaderId
            BirthDateMatchReaderId match = new BirthDateMatchReaderId();
            match.DateBirth = "1984-02-14";
            match.ReaderId  = 189245;
            BooleanResponse br = new BooleanResponse();
            br.Result = true;
            json      = JsonConvert.SerializeObject(match, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "IsBirthDateMatchReaderId");
            json = JsonConvert.SerializeObject(br, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Readers", "IsBirthDateMatchReaderId");

            //Readers/SetPasswordLocalReader
            SetPasswordLocalReader spwd = new SetPasswordLocalReader();
            spwd.NewPassword = "******";
            spwd.ReaderId    = 189245;
            json             = JsonConvert.SerializeObject(spwd, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "SetPasswordLocalReader");


            //Books.Get
            BookSimpleView book;
            book = ViewFactory.GetBookSimpleView("BJVVV_1411951");
            json = JsonConvert.SerializeObject(book, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Books", "Get");

            //Circulation.InsertIntoUserBasket
            ImpersonalBasket basket = new ImpersonalBasket();
            basket.BookIdArray = new List <string>();
            basket.BookIdArray.AddRange(new string[] { "BJVVV_1299121", "BJVVV_1304618", "REDKOSTJ_31866", "REDKOSTJ_43090" });
            basket.ReaderId = 189245;
            json            = JsonConvert.SerializeObject(basket, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Circulation", "InsertIntoUserBasket");

            //Circulation.Basket
            CirculationInfo   circ       = new CirculationInfo();
            List <BasketInfo> UserBasket = circ.GetBasket(888);
            json = JsonConvert.SerializeObject(UserBasket, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "Basket");

            //Circulation.Order
            circ = new CirculationInfo();
            MakeOrder mo = new MakeOrder();
            mo.BookId      = "BJVVV_1078762";
            mo.ReaderId    = 100000;
            mo.OrderTypeId = 2;
            json           = JsonConvert.SerializeObject(mo, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Circulation", "Order");


            //Circulation.Orders
            List <OrderInfo> UserOrders = circ.GetOrders(155);
            json = JsonConvert.SerializeObject(UserOrders, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "Orders");
            //Circulation.Basket    Delete
            BasketDelete bd = new BasketDelete();
            bd.BooksToDelete.Add("BJVVV_1299121");
            bd.BooksToDelete.Add("BJVVV_1491232");
            bd.ReaderId = 200500;
            json        = JsonConvert.SerializeObject(bd, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Circulation", "DeleteFromBasket");

            //Circulation.OrdersHistory
            List <OrderHistoryInfo> UserOrdersHistory = circ.GetOrdersHistory(100000);
            json = JsonConvert.SerializeObject(UserOrdersHistory, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "OrdersHistory");


            //Readers.PreRegisterRemoteReader
            PreRegisterRemoteReader re = new PreRegisterRemoteReader();
            re.BirthDate   = "1975-05-05";//new DateTime(1975, 05, 05);
            re.CountryId   = 137;
            re.Email       = "*****@*****.**";
            re.FamilyName  = "Иванов";
            re.FatherName  = "Иванович";
            re.MobilePhone = "89551234567";
            re.Name        = "Иван";
            re.Password    = "******";
            json           = JsonConvert.SerializeObject(re, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "PreRegisterRemoteReader");

            //Readers.ConfirmRegistrationRemoteReader
            ConfirmRegistrationRemoteReader c = new ConfirmRegistrationRemoteReader();
            c.Url = "https://oauth.libfl.ru/activate/<activation code>";
            json  = JsonConvert.SerializeObject(c, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ConfirmRegistrationRemoteReader");

            //Readers.ChangePasswordByEmail
            ChangePasswordByEmail em = new ChangePasswordByEmail();
            em.Email = "*****@*****.**";
            json     = JsonConvert.SerializeObject(em, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "ChangePasswordByEmail");

            //Readers.SetPasswordRemoteReader
            SetPasswordRemoteReader set = new SetPasswordRemoteReader();
            set.Url      = "https://oauth.libfl.ru/recovery/<recovery code>";
            set.Password = "******";
            json         = JsonConvert.SerializeObject(set, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "SetPasswordRemoteReader");

            //Readers.CheckPasswordUrl
            CheckPasswordUrl check = new CheckPasswordUrl();
            check.Url = "https://oauth.libfl.ru/recovery/<recovery code>";
            json      = JsonConvert.SerializeObject(check, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleRequest(json, new MediaTypeHeaderValue("application/json"), "Readers", "CheckPasswordUrl");

            //GET Litres/Account/{ReaderId}
            LitresInfo li = new LitresInfo();
            li.Login    = "******";
            li.Password = "******";
            json        = JsonConvert.SerializeObject(li, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Litres", "LitresAccount");
            //POST Litres/AssignAccount/{ReaderId}
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Litres", "AssignLitresAccount");


            //Circulation / Orders / ById /{ OrderId}
            OrderInfo oi = circ.GetOrder(22);
            json = JsonConvert.SerializeObject(oi, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Circulation", "OrdersById");

            //Books/ElectronicCopy/{id}
            ElectronicCopyFullView ec = ViewFactory.GetElectronicCopyFullView("BJVVV_138023");
            json = JsonConvert.SerializeObject(ec, Formatting.Indented, ALISSettings.ALISDateFormatJSONSettings);
            config.SetSampleResponse(json, new MediaTypeHeaderValue("application/json"), "Books", "GetElectronicCopyFullView");
        }
コード例 #21
0
 public MakeOrderViewModel(MakeOrder open)
 {
     makeOrder = open;
     pizzaSize = p.GetAllPizzas();
     sides     = new List <SideDish>();
 }
コード例 #22
0
 public Task CompensateAsync(MakeOrder message, ISagaContext context)
 => Task.CompletedTask;
コード例 #23
0
ファイル: CirculationInfo.cs プロジェクト: infra-hdc/LIBFL
        public void MakeOrder(MakeOrder request)
        {
            //BookBase book = new BookBase()
            BJBookInfo     book           = BJBookInfo.GetBookInfoByPIN(request.BookId);
            BookSimpleView bookSimpleView = ViewFactory.GetBookSimpleView(request.BookId);

            ReaderInfo reader = ReaderInfo.GetReader(request.ReaderId);
            List <int> acceptableOrderTypes = GetAcceptableOrderTypesForReader(request.BookId, request.ReaderId);

            if (!acceptableOrderTypes.Contains(request.OrderTypeId))
            {
                throw new Exception("C013");
            }

            if (request.OrderTypeId == OrderTypes.ElectronicVersion.Id)
            {
                if (this.ElectronicIssueCount(reader) >= 5)
                {
                    throw new Exception("C001");
                }
                if (this.IsElectronicIssueAlreadyIssued(reader, book))
                {
                    throw new Exception("C002");
                }
                //в простой вид книги искусственно добавляется электронный экземпляр
                if (bookSimpleView.Exemplars.Count - this.GetBusyExemplarsCount(book) <= 0)
                {
                    throw new Exception("C003");
                }
                if (!this.IsTwentyFourHoursPastSinceReturn(reader, book))
                {
                    throw new Exception("C004");
                }
                BJElectronicExemplarInfo exemplar = new BJElectronicExemplarInfo(book.ID, book.Fund);
                //BJExemplarInfo exemplar = BJExemplarInfo(book.ID, book.Fund);
                this.NewOrder(exemplar, reader, request.OrderTypeId, 30);
            }
            else
            {
                if (this.IsBookAlreadyIssuedToReader(book, reader))
                {
                    throw new Exception("C006");
                }

                //ExemplarSimpleView exemplarSimpleView;
                bool IsOrderedSuccessfully = false;
                switch (request.OrderTypeId)
                {
                case OrderTypes.PaperVersion.Id:
                    //приоритет для книг, которые в хранении, чтобы их принесли на кафедру для читателя
                    foreach (BJExemplarInfo e in book.Exemplars)
                    {
                        if (e.Fields["899$a"].MNFIELD == 0)
                        {
                            continue;
                        }
                        if (e.ExemplarAccess.Access == 1000)
                        {
                            if (!this.IsExemplarIssued(e))
                            {
                                this.NewOrder(e, reader, OrderTypes.PaperVersion.Id, 4);
                                IsOrderedSuccessfully = true;
                                break;
                            }
                        }
                    }
                    if (IsOrderedSuccessfully)
                    {
                        break;
                    }
                    //если свободных книг в хранении не осталось, то ищем те, которые в отрытом доступе. это будет самостоятельный заказ
                    foreach (BJExemplarInfo e in book.Exemplars)
                    {
                        if (e.Fields["899$a"].MNFIELD == 0)
                        {
                            continue;
                        }
                        if ((e.ExemplarAccess.Access == 1006))
                        {
                            if (!this.IsExemplarIssued(e))
                            {
                                this.NewOrder(e, reader, OrderTypes.SelfOrder.Id, 4);
                                IsOrderedSuccessfully = true;
                                break;
                            }
                        }
                    }
                    if (IsOrderedSuccessfully)
                    {
                        break;
                    }
                    else
                    {
                        throw new Exception("C009");
                    }

                case OrderTypes.InLibrary.Id:
                    //тут опять приоритет у тех, которые надо заказать из книгохранения перед самостоятельным заказом
                    foreach (BJExemplarInfo e in book.Exemplars)
                    {
                        if (e.Fields["899$a"].MNFIELD == 0)
                        {
                            continue;
                        }
                        if ((e.ExemplarAccess.Access == 1005) || (e.ExemplarAccess.Access == 1012))
                        {
                            if (!this.IsExemplarIssued(e))
                            {
                                this.NewOrder(e, reader, OrderTypes.InLibrary.Id, 4);
                                IsOrderedSuccessfully = true;
                                break;
                            }
                        }
                    }
                    if (IsOrderedSuccessfully)
                    {
                        break;
                    }
                    //если свободных книг в хранении не осталось, то ищем те, которые в отрытом доступе. это будет самостоятельный заказ
                    foreach (BJExemplarInfo e in book.Exemplars)
                    {
                        if (e.Fields["899$a"].MNFIELD == 0)
                        {
                            continue;
                        }
                        if ((e.ExemplarAccess.Access == 1007) || (e.ExemplarAccess.Access == 1014))
                        {
                            if (!this.IsExemplarIssued(e))
                            {
                                this.NewOrder(e, reader, OrderTypes.SelfOrder.Id, 4);
                                IsOrderedSuccessfully = true;
                                break;
                            }
                        }
                    }
                    if (IsOrderedSuccessfully)
                    {
                        break;
                    }
                    else
                    {
                        throw new Exception("C010");
                    }

                //это никогда не придёт
                case OrderTypes.NoActionProvided.Id:
                    throw new Exception("C008");

                case OrderTypes.ClarifyAccess.Id:
                    throw new Exception("C008");

                default:
                    throw new Exception("C008");
                }
            }
        }