private void DocumentAfterCopy(Document sender, CopyEventArgs e)
        {
            if (sender.Level > 2 && sender.ContentType.Alias == Order.NodeAlias)
            {
                Guid currentGuid;
                var  orderGuid = sender.getProperty("orderGuid").Value.ToString();

                Guid.TryParse(orderGuid, out currentGuid);

                var order = OrderHelper.GetOrder(currentGuid);

                var newOrder = OrderHelper.CreateNewOrderFromExisting(order);

                IO.Container.Resolve <IOrderNumberService>().GenerateAndPersistOrderNumber(order);

                order.OrderNodeId = e.NewDocument.Id;
                order.Save();

                e.NewDocument.Text = order.OrderNumber;
                e.NewDocument.SetProperty("orderGuid", newOrder.UniqueOrderId.ToString());
                e.NewDocument.SetProperty("orderStatusPicker", newOrder.Status.ToString());

                e.NewDocument.Save();

                BasePage.Current.ClientTools.SyncTree(e.NewDocument.Parent.Path, false);
                BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("editContent.aspx?id=", e.NewDocument.Id));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Copy over the order from a given order to a new one and set that as the current order
 /// </summary>
 /// <param name="orderinfo"></param>
 /// <returns></returns>
 public static OrderInfo CreateNewOrderFromExisting(OrderInfo orderinfo)
 {
     return(OrderHelper.CreateNewOrderFromExisting(orderinfo));
 }