Exemplo n.º 1
0
 static void TestException(ProductServiceClient client, int id)
 {
     Console.WriteLine("\n\nTest {0} Fault Exception for product id {1}...", (id != 999) ? "handled" : "unhandled", id);
     try
     {
         client.GetProduct(id);
     }
     catch (TimeoutException ex)
     {
         Console.WriteLine("The service operation timed out." + ex.Message);
     }
     catch (FaultException<ProductFault> ex)
     {
         Console.WriteLine("ProductFault: " + ex);
     }
     catch (FaultException ex)
     {
         Console.WriteLine("Unknown Fault: " + ex);
     }
     catch (CommunicationException ex)
     {
         Console.WriteLine("There was a communication problem. " + ex.Message + ex.StackTrace);
     }
     Console.WriteLine("\n\nChannel Status after the exception: " + client.InnerChannel.State);
     Console.WriteLine("Press any key to continue ...");
     Console.ReadKey();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ProductServiceClient client =
                new ProductServiceClient();
            Product product = client.GetProduct(23);
            Console.WriteLine("product name is " +
                    product.ProductName);
            Console.WriteLine("product price is " +
                        product.UnitPrice.ToString());
            product.UnitPrice = 20.0m;
            string message = "";
            bool result = client.UpdateProduct(product,
                ref message);
            Console.WriteLine("Update result is " +
                                result.ToString());
            Console.WriteLine("Update message is " +
                                message);
            // FaultException
            TestException(client, 0);
            // regular C# exception
            TestException(client, 999);

            Console.WriteLine("Press any key to continue ...");
            Console.ReadLine();
        }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     ProductServiceClient client = new ProductServiceClient("WSHttpBinding_IProductService", "http://192.168.139.93:8732/ProductService/ws");
     Product p = client.GetProduct("1");
     Console.WriteLine("Productname: " + p.ProductName);
     Console.ReadLine();
 }
Exemplo n.º 4
0
        private string GetProduct(TextBox txtProductID,
                          ref Product product)
        {
            string result = "";

            try
            {
                int productID = Int32.Parse(txtProductID.Text);
                var client = new ProductServiceClient();
                product = client.GetProduct(productID);

                var sb = new StringBuilder();
                sb.Append("ProductID:" +
                    product.ProductID.ToString() + "\n");
                sb.Append("ProductName:" +
                    product.ProductName + "\n");
                sb.Append("UnitPrice:" +
                    product.UnitPrice.ToString() + "\n");
                sb.Append("RowVersion:");
                foreach (var x in product.RowVersion.AsEnumerable())
                {
                    sb.Append(x.ToString());
                    sb.Append(" ");
                }
                result = sb.ToString();

            }
            catch (Exception ex)
            {
                result = "Exception: " + ex.Message.ToString();
            }

            return result;
        }
Exemplo n.º 5
0
        //public ActionResult ProductsPartial(string categoryId = null)
        //{
        //    using (var proxy = new ProductServiceClient())
        //    {
        //        IEnumerable<ProductDto> products = null;
        //        products = string.IsNullOrEmpty((categoryId)) ? proxy.GetProducts() : proxy.GetProductsForCategory(new Guid(categoryId));
        //        if (string.IsNullOrEmpty(categoryId))
        //            ViewBag.CategoryName = "所有商品";
        //        else
        //        {
        //            var category = proxy.GetCategoryById(new Guid(categoryId));
        //            ViewBag.CategoryName = category.Name;
        //        }

        //        ViewBag.CategoryId = categoryId;
        //        return PartialView(products);
        //    }
        //}

        /// <summary>
        /// 商品页面的分页支持
        /// </summary>
        /// <param name="categoryId">类别Id</param>
        /// <param name="fromIndexPage">是否来源首页点击</param>
        /// <param name="pageNumber">页数</param>
        /// <returns></returns>
        public ActionResult ProductsPartial(string categoryId = null, bool? fromIndexPage = null, int pageNumber =1)
        {
            using (var proxy = new ProductServiceClient())
            {
                var numberOfProductsPerPage = int.Parse(ConfigurationManager.AppSettings["productsPerPage"]);
                var pagination = new Pagination { PageSize = numberOfProductsPerPage, PageNumber = pageNumber };
                ProductDtoWithPagination productsDtoWithPagination = null;

                productsDtoWithPagination = string.IsNullOrEmpty((categoryId)) ? 
                    proxy.GetProductsWithPagination(pagination) : 
                    proxy.GetProductsForCategoryWithPagination(new Guid(categoryId), pagination);
                
                if (string.IsNullOrEmpty(categoryId))
                    ViewBag.CategoryName = "所有商品";
                else
                {
                    var category = proxy.GetCategoryById(new Guid(categoryId));
                    ViewBag.CategoryName = category.Name;
                }

                ViewBag.CategoryId = categoryId;
                ViewBag.FromIndexPage = fromIndexPage;
                if (fromIndexPage == null || fromIndexPage.Value)
                    ViewBag.Action = "Index";
                else
                    ViewBag.Action = "Category"; 
                ViewBag.IsFirstPage = productsDtoWithPagination.Pagination.PageNumber == 1;
                ViewBag.IsLastPage = productsDtoWithPagination.Pagination.PageNumber == productsDtoWithPagination.Pagination.TotalPages;
                return PartialView(productsDtoWithPagination);
            }
        }
Exemplo n.º 6
0
 public ActionResult Categories()
 {
     using (var proxy = new ProductServiceClient())
     {
         var categories = proxy.GetCategories();
         return View(categories);
     }
 }
Exemplo n.º 7
0
 public ActionResult EditCategory(string id)
 {
     using (var proxy = new ProductServiceClient())
     {
         var category = proxy.GetCategoryById(new Guid(id));
         return View(category);
     }
 }
Exemplo n.º 8
0
 public ActionResult NewProductsPartial()
 {
     using (var proxy = new ProductServiceClient())
     {
         var newProducts = proxy.GetNewProducts(4);
         return PartialView(newProducts);
     }
 }
Exemplo n.º 9
0
 public ActionResult ProductDetail(string id)
 {
     using (var proxy = new ProductServiceClient())
     {
         var product = proxy.GetProductById(new Guid(id));
         return View(product);
     }
 }
Exemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ServiceReference1.ProductServiceClient pc=new ProductServiceClient();
     var product = pc.GetProducts();
     Response.Write("<table border='1'> <tr><th>ID</th><th>Name</th><th>Unit Price</th><th>Quantity</th><th>Total</th></tr>");
     foreach (var p in product)
     {
         Response.Write("<tr><td>" + p.Id + "</td><td>" + p.Name + "</td><td>" + p.UnitPrice + "</td><td>" + p.Quantity + "</td><td>"+p.Total+"</td></tr>");
     }
     Response.Write("</table>");
 }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var client = new ProductServiceClient();
            var product = client.GetProduct(23);

            Console.WriteLine("name: " + product.ProductName);
            Console.WriteLine("price: " + product.UnitPrice.ToString());

            product.UnitPrice = 20.0m;
            var message = "";
            var result = client.UpdateProduct(product, ref message);

            Console.WriteLine("result: " + result.ToString());
            Console.WriteLine("message: " + message);
            Console.ReadLine();
        }
Exemplo n.º 12
0
        private static void MainOld(string[] args)
        {
            var client = new ProductServiceClient();
            var product = client.GetProduct(23);
            Console.WriteLine("product name is " + product.ProductName);
            Console.WriteLine("product price is " + product.UnitPrice.ToString(CultureInfo.InvariantCulture));
            product.UnitPrice = (decimal) 20.0;
            var result = client.UpdateProduct(product);
            Console.WriteLine("Update result is " + result.ToString(CultureInfo.InvariantCulture));

            TestException(client, 0); // channel is still open after a FaultException
            TestException(client, 999); // channel is Faulted after a non handled fault exception
            Console.WriteLine("\n\nTest Faulted client ...");
            client.GetProduct(20); // can't use a client with a Faulted channel
            Console.WriteLine("Press any key to continue ...");
            Console.ReadLine();
        }
Exemplo n.º 13
0
 static void Main(string[] args)
 {
     try
     {
         Stopwatch sw = new Stopwatch();
         sw.Start();
         ProductServiceClient client = new ProductServiceClient();
         Product product = client.GetProduct(23);
         Console.WriteLine("product name is " + product.ProductName);
         Console.WriteLine("product price is " + product.UnitPrice.ToString());
         product.UnitPrice = 20.0m;
         string message = "";
         bool result = client.UpdateProduct(product, ref message);
         Console.WriteLine("Update result is " + result.ToString());
         Console.WriteLine("Update message is " + message);
         sw.Stop();
         Console.WriteLine("TCP Elapsed: " + sw.Elapsed);
     }
     catch (FaultException<ProductFault> ex)
     {
         Console.WriteLine("ProductFault. ");
         Console.WriteLine("\tFault reason:" + ex.Reason);
         Console.WriteLine("\tFault message:" + ex.Detail.FaultMessage);
     }
     catch (FaultException ex)
     {
         Console.WriteLine("Unknown Fault");
         Console.WriteLine(ex.Message);
     }
     catch (CommunicationException ex)
     {
         Console.WriteLine("Communication exception");
         Console.WriteLine(ex.Message);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unknown exception");
         Console.WriteLine(ex.Message);
     }
     Console.ReadLine();
 }
Exemplo n.º 14
0
        static void TestException(ProductServiceClient client,
            int id)
        {
            if (id != 999)
                Console.WriteLine("\n\nTest Fault Exception");
            else
                Console.WriteLine("\n\nTest normal Exception");

            try
            {
                Product product = client.GetProduct(id);
            }
            catch (TimeoutException ex)
            {
                Console.WriteLine("Timeout exception");
            }
            catch (FaultException<ProductFault> ex)
            {
                Console.WriteLine("ProductFault. ");
                Console.WriteLine("\tFault reason:" +
                    ex.Reason);
                Console.WriteLine("\tFault message:" +
                    ex.Detail.FaultMessage);
            }
            catch (FaultException ex)
            {
                Console.WriteLine("Unknown Fault");
                Console.WriteLine(ex.Message);
            }
            catch (CommunicationException ex)
            {
                Console.WriteLine("Communication exception");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unknown exception");
            }
        }
        public ActionResult Index(FormCollection collection)
        {
            ShoppingCart = (List <SalesLineItem>)Session["ShoppingCart"];
            sessionOrder = (Order)Session["SessionOrder"];

            // få fat i kunden
            CustomerServiceReference.Customer customer = (CustomerServiceReference.Customer)Session["LoggedInUser"];

            // tjek om der er noget i kurv
            if (ShoppingCart == null || ShoppingCart.Count == 0)
            {
                return(View("NoItemsInCart"));
            }

            // tjek om der er nok af alle produkter på lager. Send en fejlbesked hvis ikke
            ProductServiceClient productService = new ProductServiceClient();

            foreach (var item in ShoppingCart)
            {
                int stock = productService.GetStock(item.Product.StyleNumber, item.ProductVersion.SizeCode, item.ProductVersion.ColorCode);
                if (stock < item.amount)
                {
                    ViewModelProductStock model = new ViewModelProductStock()
                    {
                        SalesLineItem = item,
                        Stock         = stock
                    };
                    return(View("ItemNotInStock", model));
                }
            }

            if (customer != null)
            {
                // opret ordre
                OrderService.Order order = new OrderService.Order()
                {
                    CustomerId = customer.CustomerID,
                    Date       = DateTime.Now,
                    Status     = false
                };

                // indsæt ordre til database og få genereret id ud og sat ind i objektet
                ServiceOrder service = new ServiceOrder();
                int          id      = service.AddOrder(order);
                order.OrderId = id;

                // add orderID to the saleslineitems
                foreach (var sli in ShoppingCart)
                {
                    sli.Order = order;
                }

                // adding the saleslineitems to the order
                //order.SalesLineItems = sliList.ToArray();
                order.SalesLineItems = ShoppingCart.ToArray();

                // add order to session
                Session["SessionOrder"] = order;

                return(View(order));
            }
            else
            {
                return(View("NoCustomerLoggedIn"));
            }
        }
Exemplo n.º 16
0
 private static System.ServiceModel.Channels.Binding GetDefaultBinding()
 {
     return(ProductServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpsBinding_IProductService));
 }
Exemplo n.º 17
0
        private async void loadOrders()
        {
            if (orders == null)
            {
                ProductServiceClient            client = new ProductServiceClient();
                ObservableCollection <OrderDTO> tmp    = new ObservableCollection <OrderDTO>();
                orders = new ObservableCollection <PrintableOrder>();
                tmp    = await client.getOrdersByClientAsync(loggedClientId);

                string prodN, shippN;
                foreach (OrderDTO o in tmp)
                {
                    prodN  = getProductNameById(o.ProductID);
                    shippN = getShipperNameById(o.ShipperID);
                    orders.Add(new PrintableOrder(o, prodN, shippN));
                    containedOrderIds.Add(o.OrderID);
                }
                ObservableCollection <PendingOrderDTO> pos = new ObservableCollection <PendingOrderDTO>();
                pos = await client.getPendingOrdersByClientAsync(loggedClientId);

                foreach (PendingOrderDTO po in pos)
                {
                    prodN  = getProductNameById(po.ProductID);
                    shippN = getShipperNameById(po.ShipperID);
                    orders.Add(new PrintableOrder(po, prodN, shippN));
                    containedOrderIds.Add(po.OrderID);
                }
                //ordersListView.ItemsSource = orders;
                await client.CloseAsync();
            }
            else
            {
                //only loading new orders into current collection
                ProductServiceClient            client = new ProductServiceClient();
                ObservableCollection <OrderDTO> tmp    = new ObservableCollection <OrderDTO>();
                tmp = await client.getOrdersByClientAsync(loggedClientId);

                string prodN, shippN;
                foreach (OrderDTO o in tmp)
                {
                    if (!containedOrderIds.Contains(o.OrderID))
                    {
                        prodN  = getProductNameById(o.ProductID);
                        shippN = getShipperNameById(o.ShipperID);
                        orders.Add(new PrintableOrder(o, prodN, shippN));
                        containedOrderIds.Add(o.OrderID);
                    }
                }

                ObservableCollection <PendingOrderDTO> tmp2 = new ObservableCollection <PendingOrderDTO>();
                tmp2 = await client.getPendingOrdersByClientAsync(loggedClientId);

                foreach (PendingOrderDTO o in tmp2)
                {
                    if (!containedOrderIds.Contains(o.OrderID))
                    {
                        prodN  = getProductNameById(o.ProductID);
                        shippN = getShipperNameById(o.ShipperID);
                        orders.Add(new PrintableOrder(o, prodN, shippN));
                        containedOrderIds.Add(o.OrderID);
                    }
                }
            }
        }
Exemplo n.º 18
0
 public AddPhone(ProductServiceClient productServiceClient, ManufacturerServiceClient manufacturerServiceClient)
 {
     InitializeComponent();
     _productServiceClient      = productServiceClient;
     _manufacturerServiceClient = manufacturerServiceClient;
 }
Exemplo n.º 19
0
 public ProductServiceClient(EndpointConfiguration endpointConfiguration) :
     base(ProductServiceClient.GetBindingForEndpoint(endpointConfiguration), ProductServiceClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
        public int GetStock(int styleNumber, string sizeCode, string colorCode)
        {
            ProductServiceClient proxy = new ProductServiceClient();

            return(proxy.GetStock(styleNumber, sizeCode, colorCode));
        }
Exemplo n.º 21
0
 public ActionResult EditCategory(CategoryDto category)
 {
     using (var proxy = new ProductServiceClient())
     {
         var categoryList = new List<CategoryDto>() {category};
         proxy.UpdateCategories(categoryList.ToArray());
         return RedirectToSuccess("更新商品分类成功!", "Categories","Admin");
     }
 }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            ProductServiceClient client = new ProductServiceClient();

            printWelcome();
            printOptions();
            int op = getIntegerFromUserInput();

            while (op != -1)
            {
                if (op == 1)
                {
                    List <OrderDTO> orders = client.getOrders().ToList();
                    pl("Orders already done:");
                    pl("OrderID, ClientID, ProductID, Quantity, Date, ShipperID");
                    pl("-------------------------------------------------------");
                    foreach (OrderDTO o in orders)
                    {
                        pl(o.OrderID + ", " + o.ClientID + ", " + o.ProductID + ", " + o.Quantity + ", " + o.Date.ToShortDateString() + ", " + o.ShipperID);
                    }
                }
                else if (op == 2)
                {
                    List <PendingOrderDTO> orders = client.getPendingOrders().ToList();
                    pl("Orders pending to be accepted:");
                    pl("OrderID, ClientID, ProductID, Quantity, Date, ShipperID");
                    pl("-------------------------------------------------------");
                    foreach (PendingOrderDTO o in orders)
                    {
                        pl(o.OrderID + ", " + o.ClientID + ", " + o.ProductID + ", " + o.Quantity + ", " + o.Date.ToShortDateString() + ", " + o.ShipperID);
                    }
                }
                else if (op == 3)
                {
                    p("Client identifier > ");
                    int clientId = getIntegerFromUserInput();
                    p("Product identifier > ");
                    int productId = getIntegerFromUserInput();
                    p("Quantity of the product > ");
                    int quantity = getIntegerFromUserInput();
                    p("Date (dd/mm/yyyy) > ");
                    String date = getStringFromUserInput();
                    p("Shipper identifier > ");
                    int shipperId = getIntegerFromUserInput();
                    int orderId   =
                        client.requestOrder(clientId, productId, quantity, date, shipperId);
                    if (orderId > 0)
                    {
                        pl("Order has been requested, the following identifies has been generated: " + orderId);
                    }
                    else
                    {
                        pl("Some error happened and the request could not be registered.");
                    }
                }
                else if (op == 4)
                {
                    List <ClientDTO> clients = client.getClients().ToList();
                    pl("Clients in database:");
                    pl("Identifier, Name, City, Prefered format");
                    pl("-------------------------------------");
                    foreach (ClientDTO c in clients)
                    {
                        pl(c.ClientID + ", " + c.Name + ", " + c.City + ", " + c.PreferedFormat);
                    }
                }
                else if (op == 5)
                {
                    List <ProductDTO> products = client.getProducts().ToList();
                    pl("Products in database:");
                    pl("Identifier, Name, Type, Local stock, Price, Cost");
                    pl("------------------------------------------------");
                    foreach (ProductDTO p in products)
                    {
                        pl(p.ProductID + ", " + p.ProductName + ", " + p.Type + ", " + p.Quantity + ", " + p.Price + ", " + p.Cost);
                    }
                }
                else if (op == 6)
                {
                    List <ShipperDTO> shippers = client.getShippers().ToList();
                    pl("Shippers in database:");
                    pl("Identifier, Name, City, Cost per ton");
                    pl("------------------------------------");
                    foreach (ShipperDTO s in shippers)
                    {
                        pl(s.ShipperID + ", " + s.Name + ", " + s.City + ", " + s.CostPerTon);
                    }
                }
                else if (op == -1)
                {
                    client.Close();
                    return;
                }
                else
                {
                    pl("Please input a valid option.");
                }
                pl(" ");
                printOptions();
                op = getIntegerFromUserInput();
            }
        }
Exemplo n.º 23
0
 public ProductManagerForm(ProductServiceClient client)
 {
     Client = client;
     InitializeComponent();
     Filter = (int)ID;
 }
Exemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string eventID = Request.QueryString["ev"];
            // GetNumViews(string eventID, string Type)
            EventServiceClient  esv          = new EventServiceClient();
            ReportServiceClient reportClient = new ReportServiceClient();
            EventModel          myEvent      = new EventModel();
            //Get Number of Event Vies
            int    EventViews      = esv.GetNumViews(eventID, "Views");
            int    EventShares     = esv.GetNumViews(eventID, "Shares");
            string RecentShareDate = reportClient.GetLatestView(eventID, "Shares");
            string RecentViewDate  = reportClient.GetLatestView(eventID, "Views");

            numViews.InnerHtml  = Convert.ToString(EventViews);
            numShares.InnerHtml = Convert.ToString(EventShares);
            ViewDate.InnerHtml  = RecentViewDate;
            shareDate.InnerHtml = RecentShareDate;
            //Get Event Details
            myEvent = esv.findByEventID(eventID);

            //EventProduct
            //getProductByEventID(string EventID)
            ProductServiceClient psv     = new ProductServiceClient();
            List <EventProduct>  product = new List <EventProduct>();

            product = psv.getProductByEventID(eventID);
            if (product.Count() != 0)
            {
                string htmtag = "";
                int    count  = 1;
                foreach (EventProduct _prod in product)
                {
                    double productSold = _prod._Quantity - _prod.ProdRemaining;

                    double half = Math.Round((double)(_prod._Quantity) / 2, 2);
                    double perc = Math.Round((productSold / _prod._Quantity) * 100);
                    htmtag += "<tr>";
                    htmtag += "<td scope ='row' style='text-align:center;'>" + count + "</td>";
                    htmtag += "<td style='text-align:center;'>" + _prod._Name + "</td>";
                    if (productSold > _prod.ProdRemaining)  //sold more than half of toltal product
                    {
                        htmtag += "<td style='text-align:center;'><span class='label label-success'>" + productSold + "</span></td>";
                        htmtag += "<td style='text-align:center;'><span class='label label-success'>" + _prod.ProdRemaining + "</span></td>";
                        htmtag += "<td style='text-align:center;'><h5>" + perc + "%<i class='fa fa-level-up'></i></h5></td></tr>";
                    }
                    else //Less than half of the product were sold
                    {
                        htmtag += "<td style='text-align:center;'><span class='label label-danger'>" + productSold + "</span></td>";
                        htmtag += "<td style='text-align:center;'><span class='label label-danger'>" + _prod.ProdRemaining + "</span></td>";
                        htmtag += "<td style='text-align:center;'><h5>" + perc + "%<i class='fa fa-level-down'></i></h5></td></tr>";
                    }
                    count++;
                }
                ProductRowDiv.InnerHtml = htmtag;


                //Number Scans Per Work Stations
                //string html = "";
                //int count = 0;
                //for (int i = 0; i < 4; i++)
                //{
                //    count = i + 50;
                //    html += "<div class='col-md-3 col-sm-6'>";
                //    html += "<div class='our-progress' >";
                //    html += "<div class='chart' data-percent='" + count + "'>";
                //    html += "<span class='percent'>" + count + "</span>";
                //    html += "</div></div></div>";
                //    count += 20;
                //}
                //piechart.InnerHtml = html;
                //  String request = (Request.QueryString["EventID"]);
                // string eventID = Request.QueryString["EventID"];
                List <StaffModel>   StaffList      = new List <StaffModel>();
                List <double>       percentageList = new List <double>();
                ReportServiceClient _report        = new ReportServiceClient();
                StaffList = _report.GetMostUsedWorkstation(eventID);
                if (StaffList != null)
                {
                    percentageList = calculatepercentage(StaffList);
                    string html = "";
                    for (int i = 0; i < percentageList.Count(); i++)
                    {
                        html += "<div class='col-md-3 col-sm-6'>";
                        html += "<div class='Number of Tickets by Type' >";
                        html += "<div class='chart' data-percent='" + percentageList[i] + "'>";
                        html += "<span class='percent'>" + percentageList[i] + "</span></div>";
                        html += "<span>" + StaffList[i].NAME + "</span>";
                        html += "<span>" + StaffList[i].WorkStation + "</span>";
                        html += "</div></div>";
                    }
                    piechart.InnerHtml = html;
                }
                //Track Most CHecked In Entrance
                List <StaffModel> ch_StaffList      = new List <StaffModel>();
                List <double>     ch_percentageList = new List <double>();
                ch_StaffList = _report.GetMostCheckedinEntrance(eventID);
                if (ch_StaffList != null)
                {
                    ch_percentageList = calculatepercentage(ch_StaffList);
                    string html = "";
                    for (int i = 0; i < ch_percentageList.Count(); i++)
                    {
                        html += "<div class='col-md-3 col-sm-6'>";
                        html += "<div class='Number of Tickets by Type' >";
                        html += "<div class='chart' data-percent='" + ch_percentageList[i] + "'>";
                        html += "<span class='percent'>" + ch_percentageList[i] + "</span></div>";
                        html += "<span>" + ch_StaffList[i].NAME + "</span>";
                        html += "<span>" + ch_StaffList[i].WorkStation + "</span>";
                        html += "</div></div>";
                    }
                    DivCheckedIn.InnerHtml = html;
                }
            }
            //Declined Guest
            List <GuestModel> Declinedguests = new List <GuestModel>();

            Declinedguests = reportClient.RSVPGuest(eventID, "Declined");
            //declinedRSVP.InnerHtml = Convert.ToString(Declinedguests.Count());
            //list of RSVP'd geust
            //RSVPd_Guest
            if (Declinedguests.Count() != 0)
            {
                string htmltage = "";
                foreach (GuestModel guest in Declinedguests)
                {
                    htmltage += "<li>Guest Name: " + guest.NAME + ", Email: " + guest.EMAIL + "</li>";
                }
                //Send to front End
            }


            //Get Number of RSVP'd guest
            List <GuestModel> Confirmedguests = new List <GuestModel>();

            Confirmedguests = reportClient.RSVPGuest(eventID, "Confirmed");
            // confirmedRSVP.InnerHtml = Convert.ToString(Confirmedguests.Count());
            //list of RSVP'd geust
            //RSVPd_Guest
            if (Confirmedguests.Count() != 0)
            {
                string htmltage = "";
                foreach (GuestModel guest in Confirmedguests)
                {
                    htmltage += "<li>Guest Name: " + guest.NAME + ", Email: " + guest.EMAIL + "</li>";
                }
                //Send to front End
                // RSVPd_Guest.InnerHtml = htmltage;
            }
        }
Exemplo n.º 25
0
        private async void RefreshProducts(int supplierId)
        {
            ProductServiceClient productServiceClient = new ProductServiceClient();

            IEnumerable<ProductModel> products = await productServiceClient.ProductsFromAsync(supplierId);

            (DataContext as PlaceOrderViewModel).Products = products.Select(p => Tuple.Create(p.Code, p.Name));
        }
Exemplo n.º 26
0
        string ImportData(FileUpload flInfo, int EventID)
        {
            string         path                 = "";
            string         response             = "";
            bool           isValidGuestColumn   = false;
            bool           isValidStaffColumn   = false;
            bool           isValidProductColumn = false;
            int            startColumn;
            int            startRow;
            ExcelWorksheet GuestworkSheet;
            ExcelWorksheet StaffworkSheet;
            ExcelWorksheet ProductworkSheet;
            int            count = 0;

            if (flInfo.HasFile)
            {
                try
                {
                    string filename       = Path.GetFileName(flInfo.FileName);
                    string serverLocation = "~/Temp/" + "/" + filename;
                    string SaveLoc        = Server.MapPath(serverLocation);
                    flInfo.SaveAs(SaveLoc);
                    path = Server.MapPath("/") + "\\Temp\\" + filename;

                    var package = new ExcelPackage(new System.IO.FileInfo(path));
                    ////  package.Workbook.Worksheets["TABNAME"].View.TabSelected = true;
                    startColumn      = 1;                              //where the file in the class excel start
                    startRow         = 2;
                    GuestworkSheet   = package.Workbook.Worksheets[1]; //read sheet one
                    StaffworkSheet   = package.Workbook.Worksheets[2]; //read sheet two
                    ProductworkSheet = package.Workbook.Worksheets[3];

                    isValidGuestColumn   = ValidateGuestColumns(GuestworkSheet);
                    isValidStaffColumn   = ValidateStaffColumns(StaffworkSheet);
                    isValidProductColumn = ValidateProductColumns(ProductworkSheet);
                    // isValidColumn = true;
                }
                catch
                {
                    response = "Failed";
                    return(response);
                }
                //check staff sheet
                object data = null;
                if (isValidStaffColumn == true && isValidGuestColumn == true && isValidProductColumn == true)
                {
                    do
                    {
                        data = StaffworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        //read column class name
                        object     Name       = StaffworkSheet.Cells[startRow, startColumn].Value;
                        object     Email      = StaffworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Occupation = StaffworkSheet.Cells[startRow, startColumn + 2].Value;
                        StaffModel _staff     = new StaffModel();
                        _staff.NAME       = Name.ToString();
                        _staff.EMAIL      = Email.ToString();
                        _staff.Occupation = Occupation.ToString();
                        _staff.PASS       = "******";
                        _staff.EventID    = EventID;
                        //edit to db
                        StaffServiceClient ssv = new StaffServiceClient();
                        bool isCreated         = ssv.createStaff(_staff);
                        if (isCreated == true)
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);

                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = GuestworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object     Name    = GuestworkSheet.Cells[startRow, startColumn].Value;
                        object     Surname = GuestworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Email   = GuestworkSheet.Cells[startRow, startColumn + 2].Value;
                        GuestModel _guest  = new GuestModel();
                        _guest.NAME    = Name.ToString();
                        _guest.SURNAME = Surname.ToString();
                        _guest.EMAIL   = Email.ToString();
                        _guest.PASS    = "******";
                        _guest.TYPE    = "Private";
                        Eventrix_Client.Registration reg = new Eventrix_Client.Registration();
                        //  response = reg.RegisterGuest(_guest);
                        if (response.Contains("successfully"))
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);

                    //upload product details
                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = ProductworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object       Name        = ProductworkSheet.Cells[startRow, startColumn].Value;
                        object       Description = ProductworkSheet.Cells[startRow, startColumn + 1].Value;
                        object       Quantity    = ProductworkSheet.Cells[startRow, startColumn + 2].Value;
                        object       Price       = ProductworkSheet.Cells[startRow, startColumn + 3].Value;
                        EventProduct _product    = new EventProduct();
                        _product._Name     = Name.ToString();
                        _product._Desc     = Description.ToString();
                        _product._Quantity = Convert.ToInt32(Quantity.ToString());
                        _product._Price    = Convert.ToInt32(Price.ToString());
                        _product.EventID   = EventID;
                        ProductServiceClient psv = new ProductServiceClient();
                        //  string isProductUpdated = psv.createProduct(_product);
                        string isProductUpdated = psv.createProduct(_product);
                        if (isProductUpdated.Contains("success"))
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);
                    //check record
                    if (count == (GuestworkSheet.Dimension.Rows - 1) + (StaffworkSheet.Dimension.Rows - 1) + (ProductworkSheet.Dimension.Rows - 1))
                    {
                        response = "success: All Records uploaded";
                    }
                    else
                    {
                        response = "success: Not All Records uploaded";
                    }
                }
                else
                {
                    response += " Failed to upload Exceel: Check columns";
                }
            }
            else
            {
                response = "Failed: File not found";
            }

            //Directory.Delete(path, true);
            return(response);
        }
Exemplo n.º 27
0
        // string reqEventID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            String request = (Request.QueryString["EventID"]);

            // reqEventID = request;
            if (!IsPostBack)
            {
                if (request == null)
                {
                    request = (Request.QueryString["ed"]);
                }
                int EventID = Convert.ToInt32(request);
                strEventID = EventID;
                EventModel          em           = new EventModel();
                ImageFile           img          = new ImageFile();
                List <EventProduct> products     = new List <EventProduct>();
                EventTicket         EB_tickets   = new EventTicket();
                EventTicket         REG_tickets  = new EventTicket();
                EventTicket         VIP_tickets  = new EventTicket();
                EventTicket         VVIP_tickets = new EventTicket();
                EventAddress        _address     = new EventAddress();
                //Service Clients
                EventServiceClient   eventClient = new EventServiceClient();
                FileUploadClient     fuc         = new FileUploadClient();
                TicketServiceClient  tsc         = new TicketServiceClient();
                ProductServiceClient psc         = new ProductServiceClient();
                MappingClient        mc          = new MappingClient();

                //Gett Functions
                em = eventClient.findByEventID(request);
                string addID = Convert.ToString(em.EventAddress);
                AddressID    = Convert.ToInt32(addID);
                img          = fuc.getImageById(request);
                EB_tickets   = tsc.getEBTicket(request);
                REG_tickets  = tsc.getRegularTicket(request);
                VIP_tickets  = tsc.getVIPTicket(request);
                VVIP_tickets = tsc.getVVIPTicket(request);
                products     = psc.getProductByEventID(request);
                _address     = mc.getAddressById(addID);
                //First Tab
                divHearderName.InnerHtml = "Edit " + em.Name;
                txtEventName.Text        = em.Name;
                txtDesc.Text             = em.Desc;
                txtStart.Text            = Convert.ToString(em.sDate);
                txtEnd.Text = Convert.ToString(em.eDate);

                //Ticket Section
                if (EB_tickets == null)
                {
                    txtE_Price.Text       = "";
                    txtE_Quantity.Text    = "";
                    txtE_Token.Text       = "";
                    txtE_OpenDate.Text    = "";
                    txtE_ClosingDate.Text = "";
                }
                else
                {
                    txtE_Price.Text       = Convert.ToString(EB_tickets._Price);
                    txtE_Quantity.Text    = Convert.ToString(em.EB_Quantity);
                    txtE_Token.Text       = Convert.ToString(EB_tickets._Credit);
                    txtE_OpenDate.Text    = Convert.ToString(EB_tickets._StartDate);
                    txtE_ClosingDate.Text = Convert.ToString(EB_tickets._EndDate);
                }

                if (REG_tickets == null)
                {
                    txtR_Price.Text       = "";
                    txtR_Quantity.Text    = "";
                    txtR_Token.Text       = "";
                    txtR_OpenDate.Text    = "";
                    txtR_ClosingDate.Text = "";
                }
                else
                {
                    txtR_Price.Text       = Convert.ToString(REG_tickets._Price);
                    txtR_Quantity.Text    = Convert.ToString(em.Reg_Quantity);
                    txtR_Token.Text       = Convert.ToString(REG_tickets._Credit);
                    txtR_OpenDate.Text    = Convert.ToString(REG_tickets._StartDate);
                    txtR_ClosingDate.Text = Convert.ToString(REG_tickets._EndDate);
                }
                if (VIP_tickets == null)
                {
                    txtV_Price.Text       = "";
                    txtV_Quantity.Text    = "";
                    txtV_Token.Text       = "";
                    txtV_OpenDate.Text    = "";
                    txtV_ClosingDate.Text = "";
                }
                else
                {
                    txtV_Price.Text       = Convert.ToString(VIP_tickets._Price);
                    txtV_Quantity.Text    = Convert.ToString(em.VIP_Quantity);
                    txtV_Token.Text       = Convert.ToString(VIP_tickets._Credit);
                    txtV_OpenDate.Text    = Convert.ToString(VIP_tickets._StartDate);
                    txtV_ClosingDate.Text = Convert.ToString(VIP_tickets._EndDate);
                }

                if (VVIP_tickets == null)
                {
                    txtVV_Price.Text       = "";
                    txtVV_Quantity.Text    = "";
                    txtVV_Token.Text       = "";
                    txtVV_OpenDate.Text    = "";
                    txtVV_ClosingDate.Text = "";
                }
                else
                {
                    txtVV_Price.Text       = Convert.ToString(VVIP_tickets._Price);
                    txtVV_Quantity.Text    = Convert.ToString(em.VVIP_Quantity);
                    txtVV_Token.Text       = Convert.ToString(VVIP_tickets._Credit);
                    txtVV_OpenDate.Text    = Convert.ToString(VVIP_tickets._StartDate);
                    txtVV_ClosingDate.Text = Convert.ToString(VVIP_tickets._EndDate);
                }

                //Address
                txtStreet.Text   = _address.STREET;
                txtCity.Text     = _address.CITY;
                txtProvince.Text = _address.PROVINCE;
                txtCountry.Text  = _address.COUNTRY;
            }
        }
Exemplo n.º 28
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string EVENT_TRACKER;
            string SUBFOLDER = "Main_Image";
            int    hostID    = Convert.ToInt32(Session["ID"].ToString());
            String request   = (Request.QueryString["EventID"]);

            if (request == null)
            {
                request = (Request.QueryString["ed"]);
            }
            EventServiceClient _eventClient = new EventServiceClient();
            EventModel         oldEvent     = new EventModel();

            oldEvent = _eventClient.findByEventID(request);

            //Editing  Address
            EventAddress  currentAdd = new EventAddress();
            EventAddress  Oldadd     = new EventAddress();
            MappingClient mc         = new MappingClient();

            currentAdd = mc.getAddressById(Convert.ToString(oldEvent.EventAddress));
            if (txtCountry.Text.Equals(""))
            {
                Oldadd.COUNTRY = currentAdd.COUNTRY;
            }
            else
            {
                Oldadd.COUNTRY = txtCountry.Text;
            }
            if (txtCity.Text.Equals(""))
            {
                Oldadd.CITY = currentAdd.CITY;
            }
            else
            {
                Oldadd.CITY = txtCity.Text;
            }
            if (txtStreet.Text.Equals(""))
            {
                Oldadd.STREET = currentAdd.STREET;
            }
            else
            {
                Oldadd.STREET = txtStreet.Text;
            }
            if (txtProvince.Text.Equals(""))
            {
                Oldadd.PROVINCE = currentAdd.PROVINCE;
            }
            else
            {
                Oldadd.PROVINCE = txtProvince.Text;
            }
            EventAddress newAddress = new EventAddress();

            newAddress = mc.EditAddress(Oldadd, Convert.ToString(oldEvent.EventAddress));

            EventModel _event = new EventModel();

            _event.HostID = oldEvent.HostID;
            _event.Name   = txtEventName.Text;  //Event Name
            if (chkBoxPrivate.Checked == true)  //Public or Private Event
            {
                _event.Type = "Private";
            }
            else
            {
                _event.Type = "Public";
            }
            _event.Desc = txtDesc.Text; //Event Description
            string startdate = "";
            string enddate   = "";

            //DateTime sDate = DateTime.ParseExact(startdate, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            //DateTime eDate = DateTime.ParseExact(enddate, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            //_event.sDate = sDate; //Event Start Date
            //_event.eDate = eDate; //Event End Date

            if (txtStart.Text.Equals(""))
            {
                _event.sDate = oldEvent.sDate;
            }
            else
            {
                // _event.sDate = DateTime.ParseExact(txtStart.Text, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
                //var date = DateTime.Parse(strDate,new CultureInfo("en-US", true))
                _event.sDate = Convert.ToString(DateTime.Parse(txtStart.Text, new CultureInfo("en-US", true)));
            }
            if (txtEnd.Text.Equals(""))
            {
                _event.eDate = oldEvent.eDate;
            }
            else
            {
                //  _event.eDate = DateTime.ParseExact(txtEnd.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
                _event.eDate = Convert.ToString(DateTime.Parse(txtEnd.Text, new CultureInfo("en-US", true)));
            }
            _event.EventAddress = newAddress.ID;   //Event's address ID
            //check ticket field
            if (!txtE_Quantity.Text.Equals(""))
            {
                _event.EB_Quantity = Convert.ToInt32(txtE_Quantity.Text);
            }
            else
            {
                _event.EB_Quantity = 0;
            }

            if (!txtR_Quantity.Text.Equals(""))
            {
                _event.Reg_Quantity = Convert.ToInt32(txtR_Quantity.Text);
            }
            else
            {
                _event.Reg_Quantity = 0;
            }

            if (!txtV_Quantity.Text.Equals(""))
            {
                _event.VIP_Quantity = Convert.ToInt32(txtV_Quantity.Text);
            }
            else
            {
                _event.VIP_Quantity = 0;
            }
            if (!txtVV_Quantity.Text.Equals(""))
            {
                _event.VVIP_Quantity = Convert.ToInt32(txtVV_Quantity.Text);
            }
            else
            {
                _event.VVIP_Quantity = 0;
            }
            //Edit Event Event
            EventServiceClient _editEvent = new EventServiceClient();
            EventModel         newEvent   = new EventModel();

            newEvent = _editEvent.updateEvent(_event, request);
            bool isCreatedTicket = false;   //Ticket Controller

            EVENT_TRACKER = "Event Edited successfully";
            //Import users
            //string ImportSpreadsheet = "";
            //ImportSpreadsheet = ImportData(flGuest, newEvent.EventID);

            //===================Import guest,staff and products============================//

            string         path                 = "";
            string         response             = "";
            bool           isValidGuestColumn   = false;
            bool           isValidStaffColumn   = false;
            bool           isValidProductColumn = false;
            int            startColumn          = 0;
            int            startRow             = 0;
            ExcelWorksheet GuestworkSheet       = null;
            ExcelWorksheet StaffworkSheet       = null;
            ExcelWorksheet ProductworkSheet     = null;
            int            count                = 0;

            if (flGuest.HasFile)
            {
                try
                {
                    string filename       = Path.GetFileName(flGuest.FileName);
                    string serverLocation = "~/Temp/" + "/" + filename;
                    string SaveLoc        = Server.MapPath(serverLocation);
                    flGuest.SaveAs(SaveLoc);
                    path = Server.MapPath("/") + "\\Temp\\" + filename;

                    var package = new ExcelPackage(new System.IO.FileInfo(path));
                    ////  package.Workbook.Worksheets["TABNAME"].View.TabSelected = true;
                    startColumn      = 1;                              //where the file in the class excel start
                    startRow         = 2;
                    GuestworkSheet   = package.Workbook.Worksheets[1]; //read sheet one
                    StaffworkSheet   = package.Workbook.Worksheets[2]; //read sheet two
                    ProductworkSheet = package.Workbook.Worksheets[3];

                    isValidGuestColumn   = ValidateGuestColumns(GuestworkSheet);
                    isValidStaffColumn   = ValidateStaffColumns(StaffworkSheet);
                    isValidProductColumn = ValidateProductColumns(ProductworkSheet);
                    // isValidColumn = true;
                }
                catch
                {
                    response += "Failed";
                }
                //check staff sheet
                object data = null;
                if (isValidStaffColumn == true && isValidGuestColumn == true && isValidProductColumn == true)
                {
                    do
                    {
                        data = StaffworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        //read column class name
                        object     Name       = StaffworkSheet.Cells[startRow, startColumn].Value;
                        object     Email      = StaffworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Occupation = StaffworkSheet.Cells[startRow, startColumn + 2].Value;
                        StaffModel _staff     = new StaffModel();
                        _staff.NAME       = Name.ToString();
                        _staff.EMAIL      = Email.ToString();
                        _staff.Occupation = Occupation.ToString();
                        _staff.PASS       = "******";
                        _staff.EventID    = newEvent.EventID;
                        //edit to db
                        StaffServiceClient ssv = new StaffServiceClient();
                        bool isCreated         = ssv.createStaff(_staff);
                        if (isCreated == true)
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);

                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = GuestworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object     Name    = GuestworkSheet.Cells[startRow, startColumn].Value;
                        object     Surname = GuestworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Email   = GuestworkSheet.Cells[startRow, startColumn + 2].Value;
                        GuestModel _guest  = new GuestModel();
                        _guest.NAME    = Name.ToString();
                        _guest.SURNAME = Surname.ToString();
                        _guest.EMAIL   = Email.ToString();
                        _guest.PASS    = "******";
                        _guest.TYPE    = "Private";
                        Eventrix_Client.Registration reg = new Eventrix_Client.Registration();
                        //   response = reg.RegisterGuest(_guest);
                        sendMsg(_guest, _event);
                        if (response.Contains("successfully"))
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);

                    //upload product details
                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = ProductworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object       Name        = ProductworkSheet.Cells[startRow, startColumn].Value;
                        object       Description = ProductworkSheet.Cells[startRow, startColumn + 1].Value;
                        object       Quantity    = ProductworkSheet.Cells[startRow, startColumn + 2].Value;
                        object       Price       = ProductworkSheet.Cells[startRow, startColumn + 3].Value;
                        EventProduct _product    = new EventProduct();
                        _product._Name = Name.ToString();
                        //     _product._Desc = Description.ToString();
                        _product._Quantity = Convert.ToInt32(Quantity.ToString());
                        _product._Price    = Convert.ToInt32(Price.ToString());
                        _product.EventID   = newEvent.EventID;
                        ProductServiceClient psv = new ProductServiceClient();
                        //  string isProductUpdated = psv.createProduct(_product);
                        string isProductUpdated = psv.createProduct(_product);
                        if (isProductUpdated.Contains("success"))
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);
                    //check record
                    if (count == (GuestworkSheet.Dimension.Rows - 1) + (StaffworkSheet.Dimension.Rows - 1) + (ProductworkSheet.Dimension.Rows - 1))
                    {
                        response = "success: All Records uploaded";
                    }
                    else
                    {
                        response = "success: Not All Records uploaded";
                    }
                }
                else
                {
                    response += " Failed to upload Exceel: Check columns";
                }
            }
            else
            {
                response = "Failed: File not found";
            }


            //==============================================================================//
            if (response.Contains("success"))
            {
                EVENT_TRACKER += "\n Spreadsheet Uploaded";
                //Create Tickets
                isCreatedTicket = isLoadedTicket(newEvent, newEvent.EventID);
                if (isCreatedTicket == true)
                {
                    EVENT_TRACKER += "\n Ticket Created";
                }
                else
                {
                    EVENT_TRACKER += "\n Failed to upload ticket";
                }
            }
            else
            {
                EVENT_TRACKER += "\n Spreadsheet Uploaded";
                //Create Tickets
                isCreatedTicket = isLoadedTicket(newEvent, newEvent.EventID);
                if (isCreatedTicket == true)
                {
                    EVENT_TRACKER += "\n Ticket Created";
                }
                else
                {
                    EVENT_TRACKER += "\n Failed to upload ticket";
                }
                //Unable to upload guest
                EVENT_TRACKER += "\n failed to upload spreadsheet";
            }

            ////Upload images
            ImageFile mainPic = new ImageFile();

            mainPic = UploadFile(flEventImages, Convert.ToString(newEvent.EventID), SUBFOLDER); //Upload Event Main's Image to client directory
            if (mainPic != null)
            {
                FileUploadClient fuc    = new FileUploadClient();
                string           res1   = fuc.saveImage(mainPic); //Upload Event Main's Image to Database
                string           number = res1;
            }
            Response.Redirect("EventDetails.aspx?EventID=" + newEvent.EventID);

            //  Response.Write("<script> Alert("+ EVENT_TRACKER + ");</script>");
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            ProductServiceReference.ProductServiceClient client =
                new ProductServiceReference.ProductServiceClient();
            string line;

            Console.WriteLine("Insert an option\n1 - show available chocolates\n2 - insert new chocolate\n3 - update existing product\nexit - finish program");
            Console.Write(">");
            while ((line = Console.ReadLine()) != null)
            {
                if (line == "1")
                {
                    ProductServiceReference.Product[]            all    = client.GetProducts();
                    ProductServiceReference.ProductServiceClient client =
                        new ProductServiceClient();
                    OrderDTO o;

                    for (int i = 0; i < all.Length; i++)
                    {
                        Console.WriteLine("id " + all[i].ID + ": "
                                          + all[i].Name + " ("
                                          + all[i].Type + ") - "
                                          + all[i].Quantity
                                          + " unit(s) - Price: EUR " + all[i].Price
                                          + ", Cost: EUR " + all[i].Cost);
                    }
                }
                else if (line == "2")
                {
                    Product newProd = new Product();
                    Console.Write("Insert unique Id: ");
                    newProd.ID = Int32.Parse(Console.ReadLine().Split()[0]);


                    Console.Write("Name of the product: ");
                    newProd.Name = Console.ReadLine().Split()[0].Trim();

                    Console.Write("Type: ");
                    newProd.Type = Console.ReadLine().Split()[0].Trim();

                    Console.Write("Insert number of units: ");
                    newProd.Quantity = Int32.Parse(Console.ReadLine().Split()[0]);

                    Console.Write("Insert price and cost (separated by a space): ");
                    string tmp = Console.ReadLine();
                    newProd.Price = Int32.Parse(tmp.Split()[0]);
                    newProd.Cost  = Int32.Parse(tmp.Split()[1]);

                    if (client.newProduct(newProd.ID, newProd.Name, newProd.Type, newProd.Quantity, newProd.Price, newProd.Cost))
                    {
                        Console.WriteLine("Chocolate with name " + newProd.Name + " was inserted successfully.");
                    }
                    else
                    {
                        Console.WriteLine("Unfortunately this chocolate could not be added.");
                    }
                }
                else if (line == "3")
                {
                    Console.Write("Insert ID of the product to modify: ");
                    int  id = Int32.Parse(Console.ReadLine().Split()[0]);
                    int  q, p, c;
                    bool worked = false;
                    Console.Write("Insert which parameter you want to modify (Q for quantity, P for price or C for cost:");
                    string op = Console.ReadLine().Split()[0];
                    if (op[0].Equals('Q') || op[0].Equals('q'))
                    {
                        Console.Write("New Quantity: ");
                        q      = Int32.Parse(Console.ReadLine().Split()[0]);
                        worked = client.updateProduct(id, q, -1, -1);
                    }
                    else if (op[0].Equals('P') || op[0].Equals('p'))
                    {
                        Console.Write("New Price: ");
                        p      = Int32.Parse(Console.ReadLine().Split()[0]);
                        worked = client.updateProduct(id, -1, p, -1);
                    }
                    else if (op[0].Equals('C') || op[0].Equals('c'))
                    {
                        Console.Write("New Cost: ");
                        c      = Int32.Parse(Console.ReadLine().Split()[0]);
                        worked = client.updateProduct(id, -1, -1, c);
                    }
                    else
                    {
                        Console.WriteLine("Invalid operation. Try again.");
                    }
                    if (worked)
                    {
                        Console.WriteLine("Product with id " + id + " has been updated successfully.");
                    }
                    else
                    {
                        Console.WriteLine("No product has been updated due to errors happened.");
                    }
                }
                else if (line == "exit")
                {
                    Console.WriteLine("exiting the application...");
                    break;
                }
                else
                {
                    Console.WriteLine("Enter a valid option.");
                }
                Console.WriteLine();
                Console.WriteLine("Insert an option\n1 - show available chocolates\n2 - insert new chocolate\n3 - update existing product\nexit - finish program");
                Console.Write(">");
            }
        }
Exemplo n.º 30
0
 public MainWindowViewModel()
 {
     this.client = new ProductServiceClient();
 }
 public ComponentController()
 {
     myProxy = new ProductServiceClient();
 }
Exemplo n.º 32
0
        string ImportData(FileUpload flInfo, int EventID, EventModel _event)
        {
            string         path                 = "";
            string         response             = "";
            bool           isValidGuestColumn   = false;
            bool           isValidStaffColumn   = false;
            bool           isValidProductColumn = false;
            int            startColumn;
            int            startRow;
            ExcelWorksheet GuestworkSheet;
            ExcelWorksheet StaffworkSheet;
            ExcelWorksheet ProductworkSheet;
            int            count = 0;

            if (flInfo.HasFile)
            {
                try
                {
                    string filename       = Path.GetFileName(flInfo.FileName);
                    string serverLocation = "~/temp/" + "/" + filename;
                    string SaveLoc        = Server.MapPath(serverLocation);
                    flInfo.SaveAs(SaveLoc);
                    path = Server.MapPath("/") + "\\temp\\" + filename;

                    var package = new ExcelPackage(new System.IO.FileInfo(path));
                    ////  package.Workbook.Worksheets["TABNAME"].View.TabSelected = true;
                    startColumn      = 1;                              //where the file in the class excel start
                    startRow         = 2;
                    GuestworkSheet   = package.Workbook.Worksheets[1]; //read sheet one
                    StaffworkSheet   = package.Workbook.Worksheets[2]; //read sheet two
                    ProductworkSheet = package.Workbook.Worksheets[3];

                    isValidGuestColumn   = ValidateGuestColumns(GuestworkSheet);
                    isValidStaffColumn   = ValidateStaffColumns(StaffworkSheet);
                    isValidProductColumn = ValidateProductColumns(ProductworkSheet);
                    // isValidColumn = true;
                }
                catch
                {
                    response = "Failed";
                    return(response);
                }
                //check staff sheet
                object data = null;
                if (isValidStaffColumn == true && isValidGuestColumn == true && isValidProductColumn == true)
                {
                    do
                    {
                        data = StaffworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        //read column class name
                        object     Name       = StaffworkSheet.Cells[startRow, startColumn].Value;
                        object     Email      = StaffworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Occupation = StaffworkSheet.Cells[startRow, startColumn + 2].Value;
                        StaffModel _staff     = new StaffModel();
                        _staff.NAME       = Name.ToString();
                        _staff.EMAIL      = Email.ToString();
                        _staff.Occupation = Occupation.ToString();
                        _staff.PASS       = "******";
                        _staff.EventID    = EventID;
                        //import db
                        Eventrix_Client.Registration reg = new Eventrix_Client.Registration();
                        response = reg.RegisterStaff(_staff);
                        if (response.Contains("successfully"))
                        {
                            count++;
//====================-----------Send Email TO Staff-----------------=====================================//


//=========================================================================================================//
                        }
                        startRow++;
                    } while (data != null);

                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = GuestworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object     Name         = GuestworkSheet.Cells[startRow, startColumn].Value;
                        object     Surname      = GuestworkSheet.Cells[startRow, startColumn + 1].Value;
                        object     Email        = GuestworkSheet.Cells[startRow, startColumn + 2].Value;
                        object     Tyicket_Type = GuestworkSheet.Cells[startRow, startColumn + 3].Value;
                        GuestModel _guest       = new GuestModel();
                        _guest.NAME    = Name.ToString();
                        _guest.SURNAME = Surname.ToString();
                        _guest.EMAIL   = Email.ToString();
                        _guest.PASS    = "******";
                        _guest.TYPE    = Tyicket_Type.ToString();

                        Eventrix_Client.Registration reg = new Eventrix_Client.Registration();
                        int G_ID = reg.RegisterGuest(_guest);
                        //Generate OTP
                        string pass = genCode(Convert.ToString(G_ID));
                        //HashPass
                        GuestModel gWithPass = new GuestModel();
                        gWithPass.PASS = pass;
                        response       = reg.InsertOTP(gWithPass, Convert.ToString(G_ID));
                        //  response = reg.RegisterGuest(_guest);
                        if (G_ID != -1)
                        {
                            count++;
//====================-----------Send Invitation Email-----------------=====================================//

                            EmailClient email = new EmailClient();
                            email.sendMsgInvite(_guest, _event, pass, EventID);

//=========================================================================================================//
                        }
                        startRow++;
                    } while (data != null);

                    //upload product details
                    data        = null;
                    startColumn = 1;  //where the file in the class excel start
                    startRow    = 2;
                    do
                    {
                        data = ProductworkSheet.Cells[startRow, startColumn].Value; //column Number
                        if (data == null)
                        {
                            continue;
                        }
                        object       Name        = ProductworkSheet.Cells[startRow, startColumn].Value;
                        object       Description = ProductworkSheet.Cells[startRow, startColumn + 1].Value;
                        object       Quantity    = ProductworkSheet.Cells[startRow, startColumn + 2].Value;
                        object       Price       = ProductworkSheet.Cells[startRow, startColumn + 3].Value;
                        EventProduct _product    = new EventProduct();
                        _product._Name = Name.ToString();
                        //     _product._Desc = Description.ToString();
                        _product._Quantity     = Convert.ToInt32(Quantity.ToString());
                        _product.ProdRemaining = Convert.ToInt32(Quantity.ToString());
                        _product._Price        = Convert.ToInt32(Price.ToString());
                        _product.EventID       = EventID;
                        ProductServiceClient psv = new ProductServiceClient();
                        string isProductUpdated  = psv.createProduct(_product);
                        if (isProductUpdated.Contains("success"))
                        {
                            count++;
                        }
                        startRow++;
                    } while (data != null);
                    //check record
                    if (count == (GuestworkSheet.Dimension.Rows - 1) + (StaffworkSheet.Dimension.Rows - 1) + (ProductworkSheet.Dimension.Rows - 1))
                    {
                        response = "success: All Records uploaded";
                    }
                    else
                    {
                        response = "success: Not All Records uploaded";
                    }
                }
                else
                {
                    response += " Failed to upload Exceel: Check columns";
                }
            }
            else
            {
                response = "Failed: File not found";
            }

            return(response);
        }
Exemplo n.º 33
0
        public IActionResult GetProducts()
        {
            var productsReply = ProductServiceClient.GetProducts();

            return(Ok(productsReply.Products));
        }
Exemplo n.º 34
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //delete event trigger===========================================
            string Status        = "";
            String deleterequest = (Request.QueryString["dl"]);

            if (deleterequest != null)
            {
                //delete QR Code;
                TicketServiceClient ticketToDelete = new TicketServiceClient();
                string dl_GT_BridgingTable         = "";
                string dl_ticket_template          = "";
                string dl_QRCode = ticketToDelete.dl_QRCodeByEventID(deleterequest);
                if (dl_QRCode.ToLower().Contains("success"))
                {
                    dl_GT_BridgingTable = ticketToDelete.dl_GuestTicket_BT_ByEventID(deleterequest);
                    if (dl_GT_BridgingTable.ToLower().Contains("success"))
                    {
                        dl_ticket_template = ticketToDelete.dl_TicketTemplate_byEventID(deleterequest);
                        if (dl_ticket_template.ToLower().Contains("success"))
                        {
                            Status = "\n All tickets Deleted";
                        }
                    }
                }
                FileUploadClient img         = new FileUploadClient();
                string           deleteImage = img.deleteImagebyEventID(deleterequest);
                if (deleteImage.ToLower().Contains("Failed"))
                {
                    Status += "\n Image not Delete";
                }
                else
                {
                    Status += "\n Image Delete";
                }
                StaffServiceClient ssc         = new StaffServiceClient();
                string             deletestaff = ssc.deleteStaffByEventID(deleterequest);
                if (deletestaff.ToLower().Contains("Failed"))
                {
                    Status += "\n Staff not Deleted";
                }
                else
                {
                    Status += "\n Staff Deleted";
                }
                ProductServiceClient psc = new ProductServiceClient();
                string deleteProduct     = psc.DeleteProductByEventID(deleterequest);
                if (deleteProduct.ToLower().Contains("Failed"))
                {
                    Status += "\n Product not Deleted";
                }
                else
                {
                    Status += "\n Product Deleted";
                }
                EventServiceClient esc = new EventServiceClient();
                EventModel         ev  = new EventModel();
                ev = esc.findByEventID(deleterequest);
                string deleteEvent = esc.deleteEventByID(deleterequest);
                if (deleteEvent.ToLower().Contains("Failed"))
                {
                    Status += "\n Event not Deleted";
                }
                else
                {
                    Status += "\n Event Deleted";
                    //delete event's address
                    try
                    {
                        int           Address_ID = ev.EventAddress;
                        MappingClient mapping    = new MappingClient();
                        mapping.deleteAddressByID(Convert.ToString(Address_ID));
                    }
                    catch (Exception)
                    {
                        Status += "Event Already Deleted";
                    }
                    int LoggedID = Convert.ToInt32(Session["ID"]);
                    Response.Redirect("EventManagement.aspx?HostID=" + LoggedID);
                }
            }   //done deleting an event============================================

            //display event list
            List <EventModel> display = new List <EventModel>();
            int intUserID;

            intUserID = Convert.ToInt32(Session["ID"]);
            String request = (Request.QueryString["ME"]);

            if (request != null) //If request is made
            {
                //guest's events
                //    int reqID = Convert.ToInt32(request);
                string sessionlevel = Convert.ToString(Session["Level"]);
                if (sessionlevel.ToLower().Equals("guest") && request.ToLower().Equals("1"))
                {
                    string GuestID = Convert.ToString(Session["ID"]);
                    Response.Redirect("GuestEventList.aspx?GuestID=" + GuestID);
                }

                if (request.Equals("Edit")) //Edit Event
                {
                    ImageFile        img = new ImageFile();
                    FileUploadClient fuc = new FileUploadClient();
                    display = GetEvent(intUserID);
                    string htmltag = "";
                    foreach (EventModel em in display)
                    {
                        strEventID = em.EventID;
                        string EventID     = Convert.ToString(em.EventID);
                        string imgLocation = "";
                        string output      = ""; //trim string path from Event
                                                 //   string strout = output;
                        img = fuc.getImageById(EventID);
                        if (img == null)
                        {
                            output = "Events/Eventrix_Default_Image.png";
                        }
                        else
                        {
                            imgLocation = img.Location;
                            output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                        }
                        htmltag += "<div class='portfolio-item col-sm-6 col-md-4' data-groups='['all', 'numbers', 'blue', 'square']'>";
                        htmltag += "<div class='single-portfolio'>";
                        htmltag += "<img src='" + output + "' alt='' style='width: 317px; height: 190px'>";
                        //   htmltag += "<asp:Button style='padding:10px 130px;' class='btn btn-primary animated lightSpeedIn' OnClick='btnDelete_Click'><a style='color:white;' href='EditEvent.aspx?EventID=" + em.EventID + "'>Edit Event</a></asp:Button>";
                        htmltag += "<a style='padding:10px 130px;' class='btn btn-primary animated bounceIn' href='EditEvent.aspx?ed=" + em.EventID + "'>Edit Event</a>";
                        htmltag += "<div class='portfolio-links' style='width: 200px; margin-left: -120px;'>";
                        htmltag += "<li class='fa fa-link'>";
                        htmltag += "<a href='#' style='font-size:18px;";
                        htmltag += "font-family:'Roboto',sans-serif;";
                        htmltag += "color:white;'>";
                        htmltag += "<p>" + em.Name + "</p>";
                        htmltag += "<p> " + em.sDate + " </p></a>";
                        htmltag += "</li>";
                        htmltag += "<a class='image-link' href='" + output + "'><i class='fa fa-search-plus'></i></a>";
                        htmltag += "<a href='EventDetails.aspx?EventID=" + em.EventID + "'><i class='fa fa-link'></i></a>";
                        htmltag += "</div><!-- /.links -->";
                        htmltag += "</div><!-- /.single-portfolio -->";
                        htmltag += "</div><!-- /.portfolio-item -->";
                    }
                    grid.InnerHtml = htmltag;
                }
                else if (request.Equals("Delete")) //Delete Event
                {
                    ImageFile        img = new ImageFile();
                    FileUploadClient fuc = new FileUploadClient();
                    display = GetEvent(intUserID);
                    string htmltag     = "";
                    string imgLocation = "";
                    foreach (EventModel em in display)
                    {
                        string output  = "";
                        string EventID = Convert.ToString(em.EventID);
                        img = fuc.getImageById(EventID);
                        if (img == null)
                        {
                            output = "Events/Eventrix_Default_Image.png";
                        }
                        else
                        {
                            imgLocation = img.Location;
                            output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                        }                                                                  //                                                                 //   string strout = output;
                                                                                           //    htmltag += "<a href='EventDetails.aspx'><i class='fa fa-link'></i></a>";
                        htmltag += "<div class='portfolio-item col-sm-6 col-md-4' data-groups='['all', 'numbers', 'blue', 'square']'>";
                        htmltag += "<div class='single-portfolio'>";
                        htmltag += "<img src='" + output + "' alt='' style='width: 317px; height: 190px'>";
                        htmltag += "<a style='padding:10px 130px;' class='btn btn-primary animated bounceIn' href='EventList.aspx?dl=" + em.EventID + "'>Delete Event</a>";
                        htmltag += "<div class='portfolio-links' style='width: 200px; margin-left: -120px;'>";
                        htmltag += "<li class='fa fa-link'>";
                        htmltag += "<a href='#' style='font-size:18px;";
                        htmltag += "font-family:'Roboto',sans-serif;";
                        htmltag += "color:white;'>";
                        htmltag += "<p>" + em.Name + "</p>";
                        htmltag += "<p>" + em.sDate + " </p></a>";
                        htmltag += "</li>";
                        htmltag += "<a class='image-link' href='" + output + "'><i class='fa fa-search-plus'></i></a>";
                        htmltag += "<a href='EventDetails.aspx?EventID=" + em.EventID + "'><i class='fa fa-link'></i></a>";
                        htmltag += "</div><!-- /.links -->";
                        htmltag += "</div><!-- /.single-portfolio -->";
                        htmltag += "</div><!-- /.portfolio-item -->";
                    }
                    grid.InnerHtml = htmltag;
                }
                else if (request.Equals("EventReport"))  //Event Report
                {
                    ImageFile        img = new ImageFile();
                    FileUploadClient fuc = new FileUploadClient();
                    display = GetEvent(intUserID);
                    string htmltag     = "";
                    string imgLocation = "";
                    foreach (EventModel em in display)
                    {
                        string output  = "";
                        string EventID = Convert.ToString(em.EventID);
                        img = fuc.getImageById(EventID);
                        if (img == null)
                        {
                            output = "Events/Eventrix_Default_Image.png";
                        }
                        else
                        {
                            imgLocation = img.Location;
                            output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                        }                                                                  //                                                                 //   string strout = output;
                                                                                           //    htmltag += "<a href='EventDetails.aspx'><i class='fa fa-link'></i></a>";
                        htmltag += "<div class='portfolio-item col-sm-6 col-md-4' data-groups='['all', 'numbers', 'blue', 'square']'>";
                        htmltag += "<div class='single-portfolio'>";
                        htmltag += "<img src='" + output + "' alt='' style='width: 317px; height: 190px'>";
                        //AAFReport.aspx?eventID=" + strEventID
                        htmltag += "<a style='padding:10px 130px;' class='btn btn-primary animated bounceIn' href='AAFReport.aspx?eventID=" + em.EventID + "'>Event Report</a>";
                        htmltag += "<div class='portfolio-links' style='width: 200px; margin-left: -120px;'>";
                        htmltag += "<li class='fa fa-link'>";
                        htmltag += "<a href='#' style='font-size:18px;";
                        htmltag += "font-family:'Roboto',sans-serif;";
                        htmltag += "color:white;'>";
                        htmltag += "<p>" + em.Name + "</p>";
                        htmltag += "<p>" + em.sDate + " </p></a>";
                        htmltag += "</li>";
                        htmltag += "<a class='image-link' href='" + output + "'><i class='fa fa-search-plus'></i></a>";
                        htmltag += "<a href='EventDetails.aspx?EventID=" + em.EventID + "'><i class='fa fa-link'></i></a>";
                        htmltag += "</div><!-- /.links -->";
                        htmltag += "</div><!-- /.single-portfolio -->";
                        htmltag += "</div><!-- /.portfolio-item -->";
                    }
                    grid.InnerHtml = htmltag;
                }
                else //View "My Event"
                {
                    Response.Redirect("HostEventList.aspx?HostID=" + intUserID);
                }
            }
        }
Exemplo n.º 35
0
 public ActionResult DeleteCategory(string id)
 {
     using (var proxy = new ProductServiceClient())
     {
         proxy.DeleteCategories(new List<string> { id }.ToArray());
         return RedirectToSuccess("删除商品分类成功!", "Categories", "Admin");
     }
 }
Exemplo n.º 36
0
 public ActionResult AddCategory(CategoryDto category)
 {
     using (var proxy = new ProductServiceClient())
     {
         proxy.CreateCategories(new List<CategoryDto> { category }.ToArray());
         return RedirectToSuccess("添加商品分类成功!", "Categories", "Admin");
     }
 }
Exemplo n.º 37
0
 public ProductServiceClient() :
     base(ProductServiceClient.GetDefaultBinding(), ProductServiceClient.GetDefaultEndpointAddress())
 {
     this.Endpoint.Name = EndpointConfiguration.BasicHttpsBinding_IProductService.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 38
0
 public ActionResult Products()
 {
     using (var proxy = new ProductServiceClient())
     {
         var model = proxy.GetProducts();
         return View(model);
     }
 }
Exemplo n.º 39
0
 public ProductServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(ProductServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 40
0
 public ActionResult EditProduct(string id)
 {
     using (var proxy = new ProductServiceClient())
     {
         var model = proxy.GetProductById(new Guid(id));
         var categories = proxy.GetCategories();
         categories.ToList().Insert(0, new CategoryDto(){  Id = Guid.Empty.ToString(), Name = "(未分类)", Description = "(未分类)" });
         if (model.Category != null)
             ViewData["categories"] = new SelectList(categories, "Id", "Name", model.Category.Id);
         else
             ViewData["categories"] = new SelectList(categories, "Id", "Name", Guid.Empty.ToString());
         return View(model);
     }
 }
Exemplo n.º 41
0
 private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
 {
     return(ProductServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpsBinding_IProductService));
 }
Exemplo n.º 42
0
 public ActionResult EditProduct(ProductDto product)
 {
     using (var proxy = new ProductServiceClient())
     {
         proxy.UpdateProducts(new List<ProductDto> { product }.ToArray());
         if (product.Category.Id != Guid.Empty.ToString())
             proxy.CategorizeProduct(new Guid(product.Id), new Guid(product.Category.Id));
         else
             proxy.UncategorizeProduct(new Guid(product.Id));
         return RedirectToSuccess("更新商品信息成功!", "Products", "Admin");
     }
 }
Exemplo n.º 43
0
 private void button1_Click(object sender, EventArgs e)
 {
     ProductServiceClient client = new ProductServiceClient();
     string result = "";
 }
Exemplo n.º 44
0
 public ActionResult AddProduct()
 {
     using (var proxy = new ProductServiceClient())
     {
         var categories = proxy.GetCategories();
         categories.ToList().Insert(0, new CategoryDto() { Id = Guid.Empty.ToString(), Name = "(未分类)", Description = "(未分类)" });
         ViewData["categories"] = new SelectList(categories, "Id", "Name", Guid.Empty.ToString());
         return View();
     }
 }
Exemplo n.º 45
0
        private string UpdatePrice(
            TextBox txtNewPrice,
            ref Product product,
            ref bool updateResult)
        {
            string result = "";
            string message = "";

            try
            {
                product.UnitPrice =
                    Decimal.Parse(txtNewPrice.Text);

                var client =
                    new ProductServiceClient();
                updateResult =
                    client.UpdateProduct(ref product, ref message);
                var sb = new StringBuilder();

                if (updateResult == true)
                {
                    sb.Append("Price updated to ");
                    sb.Append(txtNewPrice.Text.ToString());
                    sb.Append("\n");
                    sb.Append("Update result:");
                    sb.Append(updateResult.ToString());
                    sb.Append("\n");
                    sb.Append("Update message:");
                    sb.Append(message);
                    sb.Append("\n");
                    sb.Append("New RowVersion:");
                }
                else
                {
                    sb.Append("Price not updated to ");
                    sb.Append(txtNewPrice.Text.ToString());
                    sb.Append("\n");
                    sb.Append("Update result:");
                    sb.Append(updateResult.ToString());
                    sb.Append("\n");
                    sb.Append("Update message:");
                    sb.Append(message);
                    sb.Append("\n");
                    sb.Append("Old RowVersion:");
                }
                foreach (var x in product.RowVersion.AsEnumerable())
                {
                    sb.Append(x.ToString());
                    sb.Append(" ");
                }

                result = sb.ToString();
            }
            catch (Exception ex)
            {
                result = "Exception: " + ex.Message;
            }

            return result;
        }
Exemplo n.º 46
0
 public ActionResult AddProduct(ProductDto product)
 {
     using (var proxy = new ProductServiceClient())
     {
         if (string.IsNullOrEmpty(product.ImageUrl))
         {
             var fileName = Guid.NewGuid() + ".png";
             System.IO.File.Copy(Server.MapPath("~/Images/Products/ProductImage.png"), Server.MapPath(string.Format("~/Images/Products/{0}", fileName)));
             product.ImageUrl = fileName;
         }
         var addedProducts = proxy.CreateProducts(new List<ProductDto> { product }.ToArray());
         if (product.Category != null &&
             product.Category.Id != Guid.Empty.ToString())
             proxy.CategorizeProduct(new Guid(addedProducts[0].Id), new Guid(product.Category.Id));
         return RedirectToSuccess("添加商品信息成功!", "Products", "Admin");
     }
 }
Exemplo n.º 47
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string eventID = Request.QueryString["ev"];

            // GetNumViews(string eventID, string Type)
            EventServiceClient  esv          = new EventServiceClient();
            ReportServiceClient reportClient = new ReportServiceClient();
            EventModel          myEvent      = new EventModel();
            //Get Number of Event Vies
            int    EventViews      = esv.GetNumViews(eventID, "Views");
            int    EventShares     = esv.GetNumViews(eventID, "Shares");
            string RecentShareDate = reportClient.GetLatestView(eventID, "Shares");
            string RecentViewDate  = reportClient.GetLatestView(eventID, "Views");

            numViews.InnerHtml  = Convert.ToString(EventViews);
            numShares.InnerHtml = Convert.ToString(EventShares);
            ViewDate.InnerHtml  = RecentViewDate;
            shareDate.InnerHtml = RecentShareDate;



            String request   = (Request.QueryString["ev"]);
            string HostLevel = Convert.ToString(Session["Level"]);
            int    HostID    = Convert.ToInt32(Session["ID"]);

            //Trigger event views
            EventServiceClient evsc    = new EventServiceClient();
            EventViews         newView = new EventViews();

            newView.E_ID = Convert.ToInt32(request);
            if (HostLevel.ToLower().Equals("host"))
            {
                MapVsReportContainer.InnerHtml = "<span class='title' style='text-align:center;'>Ticket Statistics</span>";
                EventServiceClient Service_Client = new EventServiceClient();
                EventModel         _event         = new EventModel();
                _event = Service_Client.findByEventID(request);
                if (_event.HostID == HostID)
                {
                    btnDelete.Visible = true;
                    btnEdit.Visible   = true;
                    btnReport.Visible = true;


                    googleMap.Visible = false;
                    PieChart.Visible  = true;
                    market.Visible    = true;
                    ticket.Visible    = false;
                }
                else
                {
                    btnDelete.Visible = false;
                    btnEdit.Visible   = false;
                    btnReport.Visible = false;


                    googleMap.Visible = true;
                    PieChart.Visible  = false;
                    market.Visible    = false;
                    ticket.Visible    = true;
                }


                EventModel view = new EventModel();
                view.EventID = Convert.ToInt32(request);
                view.HostID  = Convert.ToInt32(HostID);
                view.Type    = "Views";
                evsc.addEventView(view);
            }
            else if (HostLevel.ToLower().Equals("guest"))
            {
                MapVsReportContainer.InnerHtml = "<span class='title' style='text-align:center;'>Get Directions</span>";
                btnDelete.Visible = false;
                btnEdit.Visible   = false;
                btnReport.Visible = false;

                googleMap.Visible = true;
                PieChart.Visible  = false;
                market.Visible    = false;
                ticket.Visible    = true;

                EventModel view = new EventModel();
                view.EventID = Convert.ToInt32(request);
                view.GuestID = Convert.ToInt32(HostID);
                view.Type    = "View";
                evsc.addEventView(view);
            }
            else
            {
                MapVsReportContainer.InnerHtml = "<span class='title' style='text-align:center;'>Get Directions</span>";
                btnDelete.Visible = false;
                btnEdit.Visible   = false;
                btnReport.Visible = false;

                googleMap.Visible = true;
                PieChart.Visible  = false;
                market.Visible    = false;
                ticket.Visible    = true;
            }

            //bool addViews = false;
            EventModel _View = new EventModel();

            _View.EventID   = Convert.ToInt32(request);
            _View.EventView = EventViews;
            DateTime dummyTime = new DateTime();

            dummyTime   = DateTime.Now;
            _View.sDate = Convert.ToString(dummyTime);
            _View.eDate = Convert.ToString(dummyTime);

            int EventID = Convert.ToInt32(request);

            strEventID = EventID;
            EventModel           em           = new EventModel();
            ImageFile            img          = new ImageFile();
            List <ImageFile>     listimages   = new List <ImageFile>();
            List <EventProduct>  products     = new List <EventProduct>();
            EventTicket          EB_tickets   = new EventTicket();
            EventTicket          REG_tickets  = new EventTicket();
            EventTicket          VIP_tickets  = new EventTicket();
            EventTicket          VVIP_tickets = new EventTicket();
            EventServiceClient   eventClient  = new EventServiceClient();
            FileUploadClient     fuc          = new FileUploadClient();
            TicketServiceClient  tsc          = new TicketServiceClient();
            ProductServiceClient psc          = new ProductServiceClient();

            em         = eventClient.findByEventID(request);
            img        = fuc.getImageById(request);
            listimages = fuc.getMultipleImagesById(request);
            string    output      = "";
            string    imgLocation = "";
            ImageFile mainPic     = new ImageFile();

            if (listimages.Count == 0)
            {
                output = "/Events/Eventrix_Default_Image.png";
                string strIhtml = "<img src='" + output + "' class='img-responsive' alt=''/>";
                divImageSlider.InnerHtml = strIhtml;
                //secondaryImageSlider.Visible = false;
            }
            else
            if (listimages.Count == 1)  //one pic uploaded
            {
                imgLocation = img.Location;
                output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                                                                               //image slider
                string strIhtml = "<img src='" + output + "' class='img-responsive' alt=''/>";
                divImageSlider.InnerHtml = strIhtml;
                //  secondaryImageSlider.Visible = false;
            }
            string htmltag = "";

            htmltag         = "Event Name: " + em.Name;
            EName.InnerHtml = htmltag;

            htmltag             = "<span class='title'>Start Date : </span>" + em.sDate;
            StartDate.InnerHtml = htmltag;

            htmltag           = "<span class='title'>End Date : </span>" + em.eDate;
            EndDate.InnerHtml = htmltag;

            htmltag = em.Desc;
            Description.InnerHtml = htmltag;

            htmltag      = ""; //clean string
            EB_tickets   = tsc.getEBTicket(request);
            REG_tickets  = tsc.getRegularTicket(request);
            VIP_tickets  = tsc.getVIPTicket(request);
            VVIP_tickets = tsc.getVVIPTicket(request);
            if (EB_tickets != null)
            {
                if (EB_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>Early Bird Tickets :Available  " + em.EB_Quantity + " </span> Price: For Free!, Available Till: " + EB_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>Early Bird Tickets :Available  " + em.EB_Quantity + "  </span> Price: R" + EB_tickets._Price + ", Available Till: " + EB_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?EBT_ID=" + EB_tickets._TicketID + "&E_ID=" + request + "'>Buy Early Bird Ticket</a></li><hr/>";
            }

            if (REG_tickets != null)
            {
                if (REG_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>Regular Tickets :Available " + em.Reg_Quantity + " </span> Price: For Free!, Available Till: " + REG_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>Regular Tickets :Available " + em.Reg_Quantity + " </span> Price: R" + REG_tickets._Price + ", Available Till: " + REG_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?RBT_ID=" + REG_tickets._TicketID + "&E_ID=" + request + "'>Buy Regular Ticket</a></li><hr/>";
            }
            if (VIP_tickets != null)
            {
                if (VIP_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>VIP Tickets :Available " + em.VIP_Quantity + " </span> Price: For Free!, Available Till: " + VIP_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>VIP Tickets :Available " + em.VIP_Quantity + " </span> Price: R" + VIP_tickets._Price + ", Available Till: " + VIP_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?VT_ID=" + VIP_tickets._TicketID + "&E_ID=" + request + "'>Buy VIP Ticket</a></li><hr/>";
            }
            if (VVIP_tickets != null)
            {
                if (VVIP_tickets._Price.Equals(0))
                {
                    htmltag += "<li><span class='title'>VVIP Tickets :Available " + em.VVIP_Quantity + " </span> Price: For Free!, Available Till: " + VVIP_tickets._EndDate + "</li>";
                }
                else
                {
                    htmltag += "<li><span class='title'>VVIP Tickets :Available " + em.VVIP_Quantity + " </span> Price: R" + VVIP_tickets._Price + ", Available Till: " + VVIP_tickets._EndDate + "</li>";
                }
                htmltag += "<li><a class='btn btn-primary animated bounceIn' href ='PurchaseTicket.aspx?VVT_ID=" + VVIP_tickets._TicketID + "&E_ID=" + request + "'>Buy VVIP Ticket</a></li><hr/>";
            }
            ticketInfo.InnerHtml = htmltag;

            //check if ticket entrance is for free
            if (EB_tickets == null && REG_tickets == null && VIP_tickets == null && VVIP_tickets == null)
            {
                AttendEvent.Visible = true;
            }
            else
            {
                AttendEvent.Visible = false;
            }

            htmltag  = ""; //clean string
            products = psc.getProductByEventID(request);
            int PC = products.Count();

            int count = 1;

            if (products != null)
            {
                if (PC != 0)
                {
                    htmltag = "<span class='title'>Products Sold</span>";
                    //    ProductsHeading.InnerHtml = htmltag;
                    htmltag = "";
                }
                foreach (EventProduct ep in products)
                {
                    htmltag += "<li><span class='title'>" + count + ". " + ep._Name + "</span>Price: R" + ep._Price + "</li>";
                    count++;
                }
                Products.InnerHtml = htmltag;
            }
        }
Exemplo n.º 48
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     MessageBox.Show(MessagingShared.GetMessage("000002", "入力済み", "データ"));
     Product ret = new ProductServiceClient().GetProductByID(12);
     MessageBox.Show(ret.Name);
 }