示例#1
0
        public async Task <IActionResult> PutTicketItem(int id, TicketItem ticketItem)
        {
            if (id != ticketItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(ticketItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TicketItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#2
0
        public static void Print(PrintDestination printDestination, PosPrinter printer,
                                 Ticket ticket, TicketItemPrintOptions printOptions)
        {
            List <TicketItem> ticketItems = new List <TicketItem>(TicketItem.GetAll(ticket.PrimaryKey));

            Print(printDestination, printer, ticket, ticketItems, printOptions, false);
        }
        public void OnAddTicketItem(object parameter)
        {
            TicketItem.Theater = SelectedTheater;
            TicketItem.Validate();
            int value;

            if (TicketItem.IsValid)
            {
                if ((value = ClientSideWCF.Instance.TicketItemProxy.AddTicketItem(TicketItem)) != -1)
                {
                    if (value == -2)
                    {
                        MessageBox.Show("Seats are taken.");
                    }
                    else
                    {
                        MainWindowViewModel.Refresh.Execute(null);
                        LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.ERROR, "Add ticket success.");
                        Window.Close();
                    }
                }
                else
                {
                    LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.ERROR, "Add ticket error.");
                }
            }
        }
示例#4
0
 public void SyncTicketItem(TicketItem item, RetailTicketItem ticketItem)
 {
     item.Id                         = ticketItem.Id;
     item.HasModifiers               = ticketItem.Modifiers != null && ticketItem.Modifiers.Length == 0;
     item.Beverage                   = ticketItem.Beverage;
     item.GroupName                  = ticketItem.GroupName;
     item.CategoryName               = ticketItem.CategoryName;
     item.Discount                   = ticketItem.Discount;
     item.ItemId                     = ticketItem.ItemId;
     item.ItemName                   = ticketItem.ItemName;
     item.ItemPrice                  = ticketItem.ItemPrice;
     item.ItemTaxRate                = ticketItem.ItemTaxRate;
     item.ItemUnitName               = ticketItem.ItemUnitName;
     item.PrintedToKitchen           = ticketItem.Printed;
     item.PrintToKitchen             = ticketItem.Print;
     item.PrinterGroupId             = ticketItem.PrinterGroupId;
     item.SeatNumber                 = ticketItem.SeatNumber;
     item.Status                     = ticketItem.Status;
     item.TotalPrice                 = ticketItem.TotalPrice;
     item.TotalPriceWithoutModifiers = ticketItem.TotalPriceWithoutModifiers;
     item.Paid                       = ticketItem.Paid;
     item.Price                      = ticketItem.Price;
     item.Delivered                  = ticketItem.Delivered;
     item.Voided                     = ticketItem.Voided;
 }
        public void AddTicketItems(YearId primaryKey)
        {
            var ticketItems        = new List <TicketItem>(TicketItem.GetAll(primaryKey));
            var stackedTicketItems = new Stack <TicketItem>(ticketItems);

            foreach (TicketItem ticketItem in ticketItems)
            {
                if (ticketItem.IsCanceled &&
                    !(SessionManager.ActiveTicket.IsCanceled || SessionManager.ActiveTicket.IsClosed))
                {
                    continue;
                }
                if (ticketItem.ParentTicketItemId != null)
                {
                    continue;
                }
                int count        = 0;
                int ticketItemId = ticketItem.PrimaryKey.Id;
                foreach (TicketItem childTicketItem in stackedTicketItems
                         .Where(childTicketItem => childTicketItem.ParentTicketItemId != null)
                         .Where(childTicketItem => childTicketItem.ParentTicketItemId == ticketItemId))
                {
                    count++;
                    AddItemToOrder(childTicketItem, ((count == 1) ?
                                                     BranchType.Last : BranchType.Middle), false);
                }
                Items.Insert(0, new TicketItemTemplate(ticketItem));
            }
        }
        public void OnChangeTicketItem(object parameter)
        {
            LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Change TicketItem command.");
            if (TicketItem.Quantity == oldTicketItem.Quantity && TicketItem.Seats == oldTicketItem.Seats && TicketItem.Row == oldTicketItem.Row)
            {
            }
            else
            {
                if (TicketItem.Seats == oldTicketItem.Seats)
                {
                    TicketItem.Seats = TicketItem.Seats.Split('-')[0];
                }
                TicketItem.Validate();

                if (TicketItem.IsValid)
                {
                    if (ClientSideWCF.Instance.TicketItemProxy.ChangeTicketItem(TicketItem))
                    {
                        LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Change TicketItem command done.");

                        MainWindowViewModel.Refresh.Execute(null);
                        Window.Close();
                    }
                    else
                    {
                        MessageBox.Show("Seats are taken.");
                        LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Change TicketItem command (TicketItem info not valid) not done.");
                    }
                }
            }
        }
        public TicketItem AddItemToOrder(Item item)
        {
            double itemPrice = item.Price;

            // TODO: VIP! Check for special pricing
            foreach (ItemPricing price in ItemPricing.GetAll(item.Id, true, true))
            {
                itemPrice = price.Price;
            }

            TicketItem ticketItem =
                TicketItem.Add(SessionManager.ActiveTicket.PrimaryKey, item.Id, 1, itemPrice, null, null);

            if (item.IsGrouping)
            {
                var itemGroups  = new List <ItemGroup>(ItemGroup.GetAll(item.Id));
                var ticketItems = new Stack <TicketItem>();
                foreach (TicketItem childTicketItem in itemGroups
                         .Select(itemGroup =>
                                 TicketItem.Add(SessionManager.ActiveTicket.PrimaryKey, itemGroup.TargetItemId,
                                                1, 0, null, null, ticketItem.PrimaryKey.Id)))
                {
                    ticketItems.Push(childTicketItem);
                }

                AddItemToOrder(ticketItems.Pop(), BranchType.Last);
                foreach (TicketItem childTicketItem in ticketItems)
                {
                    AddItemToOrder(childTicketItem, BranchType.Middle);
                }
            }
            return(AddItemToOrder(ticketItem));
        }
        public async Task <ActionResult <TicketItem> > PostTicketItem(TicketItem item)
        {
            _context.TicketItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetTicketItem), new { id = item.Id }, item));
        }
示例#9
0
        private static string FormatLines(PrinterTemplate template, TicketItem ticketItem)
        {
            if (ticketItem.Gifted)
            {
                if (!string.IsNullOrEmpty(template.GiftLineTemplate))
                {
                    return(template.GiftLineTemplate.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                           .Aggregate("", (current, s) => current + ReplaceLineVars(s, ticketItem)));
                }
                return("");
            }

            if (ticketItem.Voided)
            {
                if (!string.IsNullOrEmpty(template.VoidedLineTemplate))
                {
                    return(template.VoidedLineTemplate.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                           .Aggregate("", (current, s) => current + ReplaceLineVars(s, ticketItem)));
                }
                return("");
            }

            if (!string.IsNullOrEmpty(template.LineTemplate))
            {
                return(template.LineTemplate.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                       .Aggregate("", (current, s) => current + ReplaceLineVars(s, ticketItem)));
            }
            return("");
        }
示例#10
0
        public async Task Test2()
        {
            // Arrange (ülesseadmine)
            var builder = new DbContextOptionsBuilder <TicketContext>()
                          .UseInMemoryDatabase("TicketList");
            var context    = new TicketContext(builder.Options);
            var controller = new TicketController(context);
            var tTicket    = new TicketItem()
            {
                Id = 123
            };
            await controller.PostTicketItem(tTicket);

            tTicket.query = "test";

            // Act (käivitad "system under test")
            var badRequestResult = await controller.PutTicketItem(999, tTicket);

            var correctResult = await controller.PutTicketItem(123, tTicket);


            // Assert
            Assert.IsType <BadRequestResult>(badRequestResult);
            var newContext = new TicketContext(builder.Options);

            var ticketFromDatabase = newContext.TicketItems.Single();

            Assert.True(ticketFromDatabase.query == "test");

            Assert.IsType <NoContentResult>(correctResult);
        }
示例#11
0
 public AppTicketItem(TicketItem ticket)
 {
     using (var dbContext = new TheaterContext())
     {
         foreach (Ticket item in dbContext.Tickets)
         {
             if (item.Id == ticket.TicketId)
             {
                 this.Ticket = item.Tag;
             }
         }
         foreach (Theater item in dbContext.Theaters)
         {
             if (item.Tag == ticket.TheaterId)
             {
                 this.Theater = item.Name;
             }
         }
         foreach (Auditorium item in dbContext.Auditoriums)
         {
             if (item.Id == ticket.Id)
             {
                 this.Auditorium = item.Number.ToString();
             }
         }
     }
     this.Id         = ticket.Id;
     this.Quantity   = ticket.Quantity.ToString();
     this.Seats      = ticket.Seats;
     this.Row        = ticket.Row.ToString();
     this.TotalPrice = ticket.TotalPrice;
 }
示例#12
0
        public async Task Test3()
        {
            // Arrange (ülesseadmine)
            var builder = new DbContextOptionsBuilder <TicketContext>()
                          .UseInMemoryDatabase("TicketList");
            var context       = new TicketContext(builder.Options);
            var controller    = new TicketController(context);
            var deletedTicket = new TicketItem()
            {
                Id = 123
            };
            await controller.PostTicketItem(deletedTicket);

            await controller.PostTicketItem(new TicketItem()
            {
                Id = 555
            });

            // Act (käivitad "system under test")
            var deleteRequest = await controller.DeleteTicketItem(deletedTicket.Id);

            var wrongKeyRequest = await controller.DeleteTicketItem(99);


            // Assert
            Assert.False(context.TicketItems.Any(x => x.Id == deletedTicket.Id));
            Assert.IsType <NotFoundResult>(wrongKeyRequest);
            Assert.IsType <NoContentResult>(deleteRequest);
        }
示例#13
0
        public async Task Test1()
        {
            // Arrange (ülesseadmine)
            var builder = new DbContextOptionsBuilder <TicketContext>()
                          .UseInMemoryDatabase("TicketList");
            var context    = new TicketContext(builder.Options);
            var controller = new TicketController(context);
            var tTicket    = new TicketItem()
            {
            };

            // Act (käivitad "system under test")
            var returnVal = await controller.PostTicketItem(tTicket);

            // Assert (vaatad et tulemus oleks nii nagu peab)
            var newContext = new TicketContext(builder.Options);

            var ticketFromDatabase = newContext.TicketItems.Single();

            Assert.True(newContext.TicketItems.Contains(tTicket)); // bugine tegelt... referencide teema

            Assert.IsType <CreatedAtActionResult>(returnVal.Result);

            var returnVal2 = returnVal.Result as CreatedAtActionResult;

            Assert.True(returnVal2.Value.Equals(tTicket));
        }
示例#14
0
        private static void LogDecreasedTicketItemLateCancels(Ticket ticket, TicketItem ticketItem)
        {
            int originalQuantity = ticketItem.GetCurrentQuantity();

            if (ticketItem.QuantityPending.HasValue && (ticketItem.QuantityPending < originalQuantity))
            {
                int             difference = originalQuantity - ticketItem.QuantityPending.Value;
                Item            item       = Item.Get(ticketItem.ItemId);
                PosDialogWindow window     =
                    CancelMadeUnmadeControl.CreateInDefaultWindow("Cancel: " + item.FullName +
                                                                  " (" + difference + ")");
                var control = window.DockedControl as CancelMadeUnmadeControl;
                window.ShowDialog();
                if (control != null && !control.IsMade.HasValue)
                {
                    ticketItem.SetQuantity(originalQuantity);
                }
                else
                {
                    TicketItem canceledTicketItem =
                        TicketItem.Add(ticket.PrimaryKey, ticketItem.ItemId, difference, ticketItem.Price,
                                       ticketItem.OrderTime, ticketItem.PreparedTime);
                    DuplicateItemOptions(ticketItem, canceledTicketItem);
                    Employee employee = SessionManager.PseudoEmployee ?? SessionManager.ActiveEmployee;
                    canceledTicketItem.Cancel(CancelType.DecreasedQuantity,
                                              employee.Id, control != null && control.IsMade.Value);
                }
            }
        }
示例#15
0
        private bool HasRestrictions(Coupon coupon, TicketItem ticketItem)
        {
            Item item = Item.Get(ticketItem.ItemId);
            // Coupon Category Restrictions
            List <CouponCategory> cats = new List <CouponCategory>(CouponCategory.GetAll(coupon.Id));

            if ((cats.Count > 0) && coupon.IsExclusive &&
                CouponCategory.FindByCategoryId(cats, item.CategoryId) == null)
            {
                return(true);
            }
            if ((cats.Count > 0) && !coupon.IsExclusive &&
                CouponCategory.FindByCategoryId(cats, item.CategoryId) != null)
            {
                return(true);
            }
            // Coupon Item Restrictions
            List <CouponItem> items = new List <CouponItem>(CouponItem.GetAll(coupon.Id));

            if ((items.Count > 0) && coupon.IsExclusive &&
                CouponItem.FindByItemId(items, item.Id) == null)
            {
                return(true);
            }
            if ((items.Count > 0) && !coupon.IsExclusive &&
                CouponItem.FindByItemId(items, item.Id) != null)
            {
                return(true);
            }
            return(false);
        }
示例#16
0
        private void LoadSuspendedTicket()
        {
            // Does the employee have any suspended tickets open
            Ticket ticket = Ticket.GetSuspendedTicket(SessionManager.ActiveEmployee.Id);

            if (ticket != null)
            {
                SetAndLoadActiveTicket(ticket);
                return;
            }

            // Also need to check for TicketItem's, on this employee's open Ticket's, that have
            // no TicketItemOrderTime set
            foreach (Ticket employeeTicket in
                     Ticket.GetAllActive(SessionManager.ActiveEmployee.Id)
                     .Where(employeeTicket => TicketItem.GetAll(employeeTicket.PrimaryKey, false, true).Any()))
            {
                // Skip future orders
                if ((employeeTicket.StartTime != null) && (employeeTicket.PrepareTime == null))
                {
                    continue;
                }
                // Load ticket
                SetAndLoadActiveTicket(employeeTicket);
                return;
            }
        }
        private void RemoveTicket()
        {
            if (!LockCheckPass(true, false, Types.Strings.TheSelectedTicketCanNotBeRemovedBecauseItAlreadyOpenedSomewhereElse))
            {
                return;
            }

            FormattedListBoxItem selected =
                (FormattedListBoxItem)listboxSourceTicket.SelectedItem;

            if (selected == null)
            {
                return;
            }
            if (TicketItem.GetAll(selected.ReferenceObject as YearId).Any())
            {
                // Remove the ticket
                TicketManager.Delete(selected.ReferenceObject as YearId);
                listboxSourceTicket.Items.Remove(listboxSourceTicket.SelectedItem);
            }
            else
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.YouCanNotRemoveATicketThatHasItemsOnItFirstTransferThoseItemsToADifferentTicket, Types.Strings.TicketNotEmpty);
            }
        }
        private YearId InitializeReceiptTape(YearId sourceTicket)
        {
            receiptTape.Items.Clear();
            if (sourceTicket == null)
            {
                sourceTicket = GetSelectedSourceTicketId();
            }
            if (sourceTicket == null)
            {
                return(null);
            }
            IEnumerable <TicketItem> items = TicketItem.GetAll(sourceTicket);

            foreach (TicketItem ticketItem in items)
            {
                if (ticketItem.IsCanceled)
                {
                    continue;
                }
                // Add items to the receipt tape
                TicketItemTemplate temp =
                    new TicketItemTemplate(ticketItem);
                receiptTape.Items.Insert(0, temp);
            }
            return(sourceTicket);
        }
示例#19
0
        public void crearTicketItems(TicketItem item)
        {
            try
            {
                connex = new POSConnection();
                connex.openConnection();

                string query = @"INSERT INTO Ticketitems(local,numTicket,fecRegistro,cantidad,valUnitario,ean,descripcion,observacion) 
                                            VALUES(@loc,@numtk,@fecReg,@cant,@valunit,@ean,@desc,@obs)";
                connex.cmd = new SqlCommand(query, connex.cnn);

                connex.cmd.Parameters.AddWithValue("@loc", item.LOCAL_ID);
                connex.cmd.Parameters.AddWithValue("@numtk", item.NUM_TICKET);
                connex.cmd.Parameters.AddWithValue("@fecReg", item.FEC_REGISTRO);
                connex.cmd.Parameters.AddWithValue("@cant", item.CANTIDAD);
                connex.cmd.Parameters.AddWithValue("@valunit", item.VAL_UNITARIO);
                connex.cmd.Parameters.AddWithValue("@ean", item.EAN);
                connex.cmd.Parameters.AddWithValue("@desc", item.DESCRIPCION);
                connex.cmd.Parameters.AddWithValue("@obs", item.OBSERVACION);

                int response = connex.cmd.ExecuteNonQuery();

                connex.closeConnection();

                //return response >= 1;
            }
            catch (SqlException e)
            {
                throw e;
            }
        }
 public TicketItemViewModel(TicketItem ticketItem, IServiceProvider serviceProvider) : base(ticketItem, serviceProvider)
 {
     _ticketItem  = ticketItem;
     RightsId     = _ticketItem.RightsId?.ToString() ?? "";
     AccessKey    = _ticketItem.AccessKey?.ToString() ?? "";
     PropertyMask = _ticketItem.PropertyMask.ToFlagsString();
 }
示例#21
0
 public TicketItemViewModel(TicketItem model)
 {
     _model = model;
     ResetSelectedQuantity();
     ItemSelectedCommand = new DelegateCommand <TicketItemViewModel>(OnItemSelected);
     Properties          = new ObservableCollection <TicketItemPropertyViewModel>(model.Properties.Select(x => new TicketItemPropertyViewModel(x)));
     UpdateItemColor();
 }
示例#22
0
 public static void ReturnTicketItem(TicketItem ticketItem, double amount)
 {
     TicketItemReturn.Add(RegisterManager.ActiveRegisterDrawer.Id,
                          SessionManager.ActiveEmployee.Id, SessionManager.ActiveTicket.PrimaryKey,
                          ticketItem.ItemId, ticketItem.QuantityPendingReturn,
                          amount);
     //AdjustInventory(ticketItem, increase)
 }
示例#23
0
        public static bool ConfirmEarlyCancelPrompt(TicketItem ticketItem)
        {
            bool result = (PosDialogWindow.ShowDialog(
                               Types.Strings.AreYouSureYouWantToCancelThisTicketItem, Types.Strings.CancelTicketItem,
                               DialogButtons.YesNo) == DialogButton.Yes);

            return(result);
        }
示例#24
0
        private static string ReplaceLineVars(string line, TicketItem ticketItem)
        {
            string result = line;

            if (ticketItem != null)
            {
                result = FormatData(result, Resources.TF_LineItemQuantity, () => ticketItem.Quantity.ToString("#,#0.##"));
                result = FormatData(result, Resources.TF_LineItemName, () => ticketItem.MenuItemName + ticketItem.GetPortionDesc());
                result = FormatData(result, Resources.TF_LineItemPrice, () => ticketItem.Price.ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineItemTotal, () => ticketItem.GetItemPrice().ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineItemTotalAndQuantity, () => ticketItem.GetItemValue().ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineItemPriceCents, () => (ticketItem.Price * 100).ToString("#,##"));
                result = FormatData(result, Resources.TF_LineItemTotalWithoutGifts, () => ticketItem.GetTotal().ToString("#,#0.00"));
                result = FormatData(result, Resources.TF_LineOrderNumber, () => ticketItem.OrderNumber.ToString());
                result = FormatData(result, Resources.TF_LineGiftOrVoidReason, () => AppServices.MainDataContext.GetReason(ticketItem.ReasonId));
                result = FormatData(result, "{MENU ITEM GROUP}", () => GetMenuItemGroup(ticketItem));
                result = FormatData(result, "{MENU ITEM TAG}", () => GetMenuItemTag(ticketItem));
                result = FormatData(result, "{PRICE TAG}", () => ticketItem.PriceTag);
                result = FormatData(result, "{ITEM TAG}", () => ticketItem.Tag);

                while (Regex.IsMatch(result, "{ITEM TAG:[^}]+}", RegexOptions.Singleline))
                {
                    var tags    = ticketItem.Tag.Split('|');
                    var match   = Regex.Match(result, "{ITEM TAG:([^}]+)}");
                    var tagName = match.Groups[0].Value;
                    int index;
                    int.TryParse(match.Groups[1].Value, out index);
                    var value = tags.Count() > index ? tags[index].Trim() : "";
                    result = result.Replace(tagName, value);
                }

                if (result.Contains(Resources.TF_LineItemDetails.Substring(0, Resources.TF_LineItemDetails.Length - 1)))
                {
                    string lineFormat = result;
                    if (ticketItem.Properties.Count > 0)
                    {
                        string label = "";
                        foreach (var property in ticketItem.Properties)
                        {
                            var itemProperty = property;
                            var lineValue    = FormatData(lineFormat, Resources.TF_LineItemDetails, () => itemProperty.Name);
                            lineValue = FormatData(lineValue, Resources.TF_LineItemDetailQuantity, () => itemProperty.Quantity.ToString("#.##"));
                            lineValue = FormatData(lineValue, Resources.TF_LineItemDetailPrice, () => itemProperty.CalculateWithParentPrice ? "" : itemProperty.PropertyPrice.Amount.ToString("#,#0.00"));
                            label    += lineValue + "\r\n";
                        }
                        result = "\r\n" + label;
                    }
                    else
                    {
                        result = "";
                    }
                }

                result = UpdateGlobalValues(result);
                result = result.Replace("<", "\r\n<");
            }
            return(result);
        }
示例#25
0
        private async Task UpdateTicketStats(TicketItem ticketItem)
        {
            var ticket = await _ticketRepo.GetById(ticketItem.TicketId);

            ticket.LastMessageText = ticketItem.Message;
            ticket.UpdatedOn       = DateTime.Now;
            ticket.TicketOwnerUnReadedMessagesCount++;
            await _ticketRepo.EditAsync(ticket);
        }
示例#26
0
        public void TicketOutdated()
        {
            TicketItem i = new TicketItem {
                Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 0, Quality = 20
            };

            i.ChangeQuality();
            Assert.AreEqual(0, i.Quality);
        }
示例#27
0
        [HttpGet("{id}", Name = "GetTicket")]  // Name is route name
        public IActionResult GetById(long id)
        {
            TicketItem ticket = _context.TicketItems.FirstOrDefault(t => t.Id == id);

            if (ticket == null)
            {
                return(NotFound());           // 404
            }
            return(new ObjectResult(ticket)); // 200
        }
示例#28
0
 private static void DuplicateItemOptions(TicketItem ticketItem, TicketItem canceledTicketItem)
 {
     foreach (TicketItemOption ticketItemOption in
              TicketItemOption.GetAll(ticketItem.PrimaryKey))
     {
         TicketItemOption.Add(canceledTicketItem.PrimaryKey.Id,
                              ticketItemOption.ItemOptionId, ticketItemOption.Type,
                              ticketItemOption.ChangeCount);
     }
 }
示例#29
0
        private void btnAddLine_Click(object sender, EventArgs e)
        {
            LineItem item = new LineItem();

            SelectedTicket.Items.Insert(0, item);
            UpdateTicketLayout();
            SelectedItem = item;
            isChanged    = true;
            UpdateSaveButton();
        }
示例#30
0
        private static string GetMenuItemTag(TicketItem ticketItem)
        {
            var result = Dao.SingleWithCache <MenuItem>(x => x.Id == ticketItem.MenuItemId).Tag;

            if (string.IsNullOrEmpty(result))
            {
                result = ticketItem.MenuItemName;
            }
            return(result);
        }
示例#31
0
    private void obj2form(TicketItem obj)
    {
        Utility.SetDropByValue(DropCategories, obj.ThreadRoot.CategoryId.ToString());
        Utility.SetDropByValue(DropPriority, obj.ThreadRoot.CustomInt2.ToString());
        Utility.SetDropByValue(DropCustomers, obj.ThreadRoot.CustomInt3.ToString());
        Utility.SetDropByValue(DropTemplates, "0");

        TxtTitle.Text = obj.ThreadRoot.Title;

        string description = "";
        obj.DescriptionTranslations.TryGetValue(Config.CultureDefault, out description);
        TxtDescription.Text = description;

        ChkSendEmailToUserInserted.Text = "";
        if (string.IsNullOrEmpty(obj.ThreadRoot.UserInserted))
            ChkSendEmailToUserInserted.Text = PgnUserCurrent.Current.Email;
        else
        {
            var member = Membership.GetUser(obj.ThreadRoot.UserInserted);
            if (member != null)
            {
                if (Utility.IsValidEmail(member.Email))
                    ChkSendEmailToUserInserted.Text = member.Email;
            }
        }
    }
示例#32
0
    private bool saveForm(bool saveAndClose)
    {
        bool res = false;
        LblErr.Text = "";
        LblOk.Text = "";
        string extraMessage = "";
        bool sendMessageToUserInserted = false;

        try
        {
            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>();
            if (CurrentId == 0)
            {
                form2obj(o1);

                if (o1.IsThreadRoot)
                {
                    string role2Add = "";
                    if (Roles.IsUserInRole(SUPPORT_USER_ROLE))
                        role2Add = PgnUserCurrent.Current.UserName;  //role as username

                    o1.ReadAccessType = MenuAccesstype.Registered;
                    o1.ReadRolenames.Add(SUPPORT_OPERATOR_ROLE);
                    o1.ReadRolenames.Add(role2Add);
                    //o1.ReadRolenames.Add(SUPPORT_MANAGER_ROLE);
                }

                o1 = man.Insert(o1);
                if (!o1.IsThreadRoot)
                {
                    var root = new TicketItem();
                    root = man.GetByKey(o1.ThreadId);
                    man.Update(root);   //update dateUpdated
                    extraMessage = "new answer inserted";
                }
                else
                    extraMessage = "new ticket inserted";

                //copy temp attachments in item folder
                new FilesGallery("~/Public/Files/items/", o1.Id.ToString()).MoveTempFiles();

                loadGrid();
            }
            else
            {
                o1 = man.GetByKey(CurrentId);
                form2obj(o1);
                man.Update(o1);
                extraMessage = "ticket updated";
            }

            if (saveAndClose)
            {
                changeThreadStatus(o1.ThreadId, "close");
                extraMessage = "ticket closed";
            }

            sendMessage(o1.UserAssigned, o1, "MessageTicketTitle", "MessageTicketDescription", extraMessage);
            sendMessage(filterSystemMessagesManager(o1.CategoryId), o1, "MessageTicketTitle", "MessageTicketDescription", extraMessage);

            if (ChkSendEmailToUserInserted.Visible == false)
                sendMessageToUserInserted = true;
            else
                sendMessageToUserInserted = ChkSendEmailToUserInserted.Checked;

            if (sendMessageToUserInserted && !o1.UserInserted.Equals(o1.UserAssigned))
                sendMessage(o1.UserInserted, o1, "MessageTicketTitle", "MessageTicketDescription", extraMessage);

            loadThread(o1.ThreadId);
            LblOk.Text = Utility.GetLabel("RECORD_SAVED_MSG");
            res = true;
        }
        catch (CustomException e1)
        {
            LblErr.Text = e1.CustomMessage;
        }
        catch (Exception e1)
        {
            LblErr.Text = Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString();
        }
        finally
        {
        }
        return res;
    }
示例#33
0
 private void sendMessage(string toUsers, TicketItem ticket, string titleLabel, string descriptionLabel, string extra)
 {
     if (string.IsNullOrEmpty(toUsers))
         return;
     sendMessage(Utility.String2List(toUsers, ";"), ticket, titleLabel, descriptionLabel, extra);
 }
示例#34
0
    private void sendMessage(List<string> toUsers, TicketItem ticket, string titleLabel, string descriptionLabel, string extra)
    {
        if (toUsers.Count == 0)
            return;

        var msg = new Message();
        msg.Title = fillMessagePlaceholders(ticket, base.GetLabel(titleLabel), extra);
        msg.Description = fillMessagePlaceholders(ticket, base.GetLabel(descriptionLabel), extra);
        msg.ItemId = ticket.Id;
        MessageProvider.SendMessage(toUsers, msg,
            MessageProvider.SendMessageEnum.UserSetting,
            MessageProvider.SendMessageEnum.UserSetting);
    }
示例#35
0
    private void changeAssignedUser(int threadId, string userAssigned)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        try
        {
            if (!PgnUserCurrent.IsAuthenticated)
                throw new Exception("user not authenticated");

            string previousUser = "";
            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>(true, true);
            o1 = man.GetByKey(threadId);  //precarico i campi esistenti e nn gestiti dal form
            previousUser = o1.UserAssigned;
            o1.UserAssigned = userAssigned;
            man.Update(o1);

            sendMessage(previousUser, o1, "MessageTicketTitle", "MessageTicketDescription", "user assigned changed from " + previousUser + " to " + userAssigned);
            sendMessage(o1.UserAssigned, o1, "MessageTicketTitle", "MessageTicketDescription", "user assigned changed from " + previousUser + " to " + userAssigned);
            sendMessage(filterSystemMessagesManager(o1.CategoryId), o1, "MessageTicketTitle", "MessageTicketDescription", "user assigned changed from " + previousUser + " to " + userAssigned);

            loadThread(threadId);
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#36
0
    private void changeCustomer(int threadId, int customerId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        try
        {
            if (!PgnUserCurrent.IsAuthenticated)
                throw new Exception("user not authenticated");

            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>(true, true);
            o1 = man.GetByKey(threadId);  //precarico i campi esistenti e nn gestiti dal form
            o1.CustomerId = customerId;
            man.Update(o1);

            loadThread(threadId);
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#37
0
    private void changeThreadStatus(int threadId, string statusCommand)
    {
        LblOk.Text = "";
        LblErr.Text = "";
        bool sendMessageToUserInserted = false;
        try
        {
            if (!PgnUserCurrent.IsAuthenticated)
                throw new Exception("user not authenticated");

            string previousStatus = "";
            string nextStatus = "";

            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>();
            o1 = man.GetByKey(threadId);  //precarico i campi esistenti e nn gestiti dal form

            try { previousStatus = Enum.GetName(typeof(TicketItem.TicketStatusEnum), o1.Status); }
            catch { }

            switch (statusCommand)
            {
                case "close":
                    o1.Status =  (int)TicketItem.TicketStatusEnum.Closed;
                    sendMessageToUserInserted = true;
                    break;
                case "open":
                    o1.Status =  (int)TicketItem.TicketStatusEnum.Open;
                    break;
                case "working":
                    o1.Status = (int)TicketItem.TicketStatusEnum.WorkInProgress;
                    sendMessageToUserInserted = true;
                    break;
                case "lock":
                    o1.Status =  (int)TicketItem.TicketStatusEnum.Locked;
                    break;
                default:
                    break;
            }
            man.Update(o1);

            try { nextStatus = Enum.GetName(typeof(TicketItem.TicketStatusEnum), o1.Status); }
            catch { }

            previousStatus = base.GetLabel(previousStatus, previousStatus);
            nextStatus = base.GetLabel(nextStatus, nextStatus);

            sendMessage(o1.UserAssigned, o1, "MessageTicketTitle", "MessageTicketDescription", "status changed from "+ previousStatus +" to "+ nextStatus);
            sendMessage(filterSystemMessagesManager(o1.CategoryId), o1, "MessageTicketTitle", "MessageTicketDescription", "status changed from " + previousStatus + " to " + nextStatus);
            if (sendMessageToUserInserted && !o1.UserInserted.Equals(o1.UserAssigned))
                sendMessage(o1.UserInserted, o1, "MessageTicketTitle", "MessageTicketDescription", "status changed from " + previousStatus + " to " + nextStatus);

            loadThread(threadId);
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#38
0
 private string fillMessagePlaceholders(TicketItem ticket, string textToParse, string extra)
 {
     textToParse = textToParse.Replace("[[ItemId]]", ticket.ThreadId.ToString())
         .Replace("[[ItemTitle]]", ticket.Title)
         .Replace("[[ItemDescription]]", ticket.Description)
         .Replace("[[ItemUserUpdated]]", ticket.UserUpdated)
         .Replace("[[ItemDateUpdated]]", ticket.DateUpdated.ToLongDateString())
         .Replace("[[Extra]]", extra);
     return textToParse;
 }
示例#39
0
    private void form2obj(TicketItem obj)
    {
        obj.ThreadId = this.CurrentThreadId;
        obj.Id = this.CurrentId;
        obj.Enabled = true;
        obj.CategoryId = int.Parse(DropCategories.SelectedValue);
        obj.Priority = int.Parse(DropPriority.SelectedValue);

        try { obj.CustomerId = int.Parse(DropCustomers.SelectedValue); }
        catch { }

        obj.TitleTranslations.Clear();
        obj.TitleTranslations.Add(Config.CultureDefault, TxtTitle.Text);

        obj.DescriptionTranslations.Clear();
        obj.DescriptionTranslations.Add(Config.CultureDefault, TxtDescription.Text);
    }
示例#40
0
    private void loadDropThreadActions(int threadId)
    {
        DropThreadActions.Items.Clear();

        var o1 = new TicketItem();
        if (threadId > 0)
        {
            o1 = new ItemsManager<TicketItem, TicketItemFilter>(true, true).GetByKey(threadId);

            var status = TicketItem.TicketStatusEnum.Open;
            status = (TicketItem.TicketStatusEnum)int.Parse(o1.Status.ToString());

            DropThreadActions.Items.Add(new ListItem(base.GetLabel("Actions", "--actions--"), ""));

            if (Roles.IsUserInRole("admin")
                || Roles.IsUserInRole(SUPPORT_MANAGER_ROLE)
                || Roles.IsUserInRole(SUPPORT_OPERATOR_ROLE))
            {
                //DropThreadActions.Items.Add(new ListItem(base.GetLabel("Close", "close"), "close"));
                DropThreadActions.Items.Add(new ListItem(base.GetLabel("Working", "in progress"), "working"));
                DropThreadActions.Items.Add(new ListItem(base.GetLabel("Reopen", "re-open"), "open"));
                DropThreadActions.Items.Add(new ListItem(base.GetLabel("Lock", "lock"), "lock"));
            }
            else if (Roles.IsUserInRole(SUPPORT_USER_ROLE))
            {
                if (status == TicketItem.TicketStatusEnum.Locked)
                { }
                else if (status == TicketItem.TicketStatusEnum.Open || status == TicketItem.TicketStatusEnum.WorkInProgress)
                {
                    //DropThreadActions.Items.Add(new ListItem(base.GetLabel("Close", "close"), "close"));
                }
                else if (status == TicketItem.TicketStatusEnum.Closed)
                {
                    DropThreadActions.Items.Add(new ListItem(base.GetLabel("Reopen", "re-open"), "open"));
                }
            }
        }
    }
示例#41
0
    private void loadThread(int ticketItemdId)
    {
        this.CurrentThreadId = ticketItemdId;
        loadDropThreadActions(ticketItemdId);
        loadDropAssignedUser(ticketItemdId);
        loadDropThreadOrder();

        var currItem = new TicketItem();
        if (ticketItemdId > 0)
            currItem = new ItemsManager<TicketItem, TicketItemFilter>(true, true)
                .GetByKey(ticketItemdId);

        if (currItem.Status == (int)TicketItem.TicketStatusEnum.Locked)
            BtnReply.Visible = false;
        else
            BtnReply.Visible = true;

        int counter = 0;
        string status = Enum.GetName(typeof(TicketItem.TicketStatusEnum), currItem.Status);
        status = base.GetLabel(status, status);
        string userAssigned = base.GetLabel("NotAssigned", "not assigned");
        if (!string.IsNullOrEmpty(currItem.UserAssigned))
            userAssigned = currItem.UserAssigned;

        ListString = base.GetLabel("Status", "Status") + ": <i>" + status + "</i><br />";
        ListString += base.GetLabel("AssignedTo", "Assigned to") + ": <i>" + userAssigned + "</i><br />";
        if (currItem.CustomerId > 0)
            ListString += base.GetLabel("Customer", "Customer") + ": <i>" + currItem.Customer.CompanyName + "</i><br />";
        ListString += base.GetLabel("TicketId", "Ticket ID") + ": <i>" + currItem.Id + "</i><br />";

        string flagged = "";
        if (currItem.Flagged)
            flagged += "<img src='"+ Utility.GetThemedImageSrc("starOn.png") +"' alt='flag' />&nbsp;";

        ListString += "<div class='itemTitle'>"+ flagged + base.GetLabel("Subject", "Subject") + ": " + currItem.Title + "</div>";

        var comparer = new Item.ItemComparer("", this.ThreadSortDirection);
        currItem.ThreadList.Sort(comparer);

        ListString += "<ul class='"+ base.BaseModule.CssClass +"'>";
        for (int i = 0; i < currItem.ThreadList.Count; i++)
        {
            var item = currItem.ThreadList[i];
            string imgUrl = "";
            string link = "";
            string sFiles = "";
            string sImages = "";
            string cssClass = base.BaseModule.CssClass;

            if (item.Files.Count > 0)
            {
                sFiles = "<ul class='" + base.BaseModule.CssClass + "'>";
                foreach (var file in item.Files)
                {
                    sFiles += "<li class='" + base.BaseModule.CssClass + "'>"
                    + "<a class='" + base.BaseModule.CssClass + "' href='" + file.FileUrl + "' "
                    + Utility.AddTracking(file.FileUrl, this.StaticFilesTracking) + " target='blank'>"
                    + "<img src='" + PhotoManager.GetFileIconSrc(file) + "' />"
                    + "<span>" + file.FileName + "</span>"
                    + "</a>"
                    + "</li>";
                }
                sFiles += "</ul>";
            }
            if (item.Images.Count > 0)
            {
                sImages = "<ul class='" + base.BaseModule.CssClass + "'>";
                foreach (var file in item.Images)
                {
                    sImages += "<li class='" + base.BaseModule.CssClass + "'>"
                    + "<a class='" + base.BaseModule.CssClass + "' href='" + file.FileUrl + "' "
                    + Utility.AddTracking(file.FileUrl, this.StaticFilesTracking) + " target='blank'>"
                    + "<span>" + file.FileName + "</span>"
                    + "</a>"
                    + "</li>";
                }
                sImages += "</ul>";
            }

            //link = base.GetLinkAddress(item);
            ListString += "<li class='" + cssClass + "'>"
            + "<div class='" + cssClass + " itemDate'>" + item.DateInserted + " - "+ item.UserInserted +"</div>"
            + "<div class='" + cssClass + " itemUser'></div>"
            + "<div class='" + cssClass + " itemTitle'></div>"
            + "<div class='" + cssClass + " itemDescription'>" + item.DescriptionParsed + "</div>"
            + "<div class='" + cssClass + " itemFiles'>" + sFiles + "</div>"
            + "<div class='" + cssClass + " itemImages'>" + sImages + "</div>"
            + "</li>";

            counter++;
        }
        ListString += "</ul>";
        MultiView1.ActiveViewIndex = VIEW_THREAD;
    }