Ejemplo n.º 1
0
        public static string OrderInfo(string storeId, string orderId)
        {
            Order order = TC.GetOrder(Convert.ToInt32(storeId), new Guid(orderId));
            Store store = TC.GetStore(Convert.ToInt32(storeId));

            List orderList = new List();

            string statusName = TCExtensions.GetOrderStatus(order.StoreId, order.OrderStatusId).Name.ToString();
            //bool positiveStatus = PositiveWord(statusName);

            //if (positiveStatus)
            //{
            //    statusName = "<b style='color: green;'>" + statusName + "</b>";
            //}
            //else
            //{
            //    statusName = "<b style='color: red;'>" + statusName + "</b>";
            //}

            ListItem detailsRow = new ListItem(
                title:
                    order.OrderNumber + "<br />",
                subtitle:
                    "City: " + order.Properties.Get("city").ToString() + "<br />" +
                    "Total Price: " + order.TotalPrice.Formatted + "<br />" +
                    "Date Created: " + order.DateCreated + "<br /><br />" +
                    "<span style='font-size: 1.3em; margin-top: 20px;'>" + "Email: <a href='mailto:" + order.Properties.Get("email").ToString() + "'>" + order.Properties.Get("email").ToString() + "</a></span><br />" +
                    "<span style='font-size: 1.3em;'>" + "Phone: " + order.Properties.Get("phone").ToString() + "</span>" +
                    "<br />" +
                    "<span style='font-size: 1.3em;'>Status: " + statusName + "</span>"
            );

            orderList.AddListItem(detailsRow);

            orderList.AddListItem(new ListItem(
                title: "Change Order Status",
                icon: GenericIcon.Tag,
                action: new Call("ChangeOrderStatus", new string[] { storeId, orderId })
            ));

            //This is not working at the moment because I was not able to find out the way to get the emailtemplates from the API
            //orderList.AddListItem(new ListItem(
            //    title: "Send Email",
            //    icon: GenericIcon.EnvelopeAlt
            //));

            return orderList.UmGo(order.OrderNumber);
        }
Ejemplo n.º 2
0
        public static string ViewData(String recordId)
        {
            FormStorage fs = new FormStorage();
            RecordStorage rs = new RecordStorage();

            Record record = rs.GetRecord(Guid.Parse(recordId));

            Umbraco.Forms.Core.Form form = fs.GetForm(record.Form);

            List calls = new List();

            calls.AddListItem(new ListItem("<b>Approve</b>",
                subtitle: "Approve record",
                icon: GenericIcon.Check,
                action: new Call("CheckRecordConfirm", new string[] { recordId })));

            calls.AddListItem(new ListItem("<b>Delete</b>",
                subtitle: "Delete record",
                icon: GenericIcon.Trash,
                action: new Call("DeleteRecordConfirm", new string[] { recordId })));

            calls.AddListItem(new ListItem("<b>Email</b>",
                subtitle: "Email record",
                icon: GenericIcon.EnvelopeAlt,
                action: new Call("EmailRecordForm", new string[] { recordId })));

            String data = string.Empty;

            data += "<p><b>State:</b><br/>" + record.State.ToString() + "</p><br />";
            data += "<p><b>Created:</b><br/>" + record.Created.ToString() + "</p><br />";
            data += "<p><b>Ip:</b><br/>" + record.IP + "</p><br />";

            foreach (Field field in form.AllFields)
            {
                string value = string.Empty;
                if (record.GetRecordField(field.Id) != null && record.GetRecordField(field.Id).Values.Count > 0)
                {
                    value = record.GetRecordField(field.Id).Values[0].ToString();
                }
                data += "<p><b>" + field.Caption + ":</b><br/>" + value + "</p><br />";
            }

            calls.AddListItem(new ListItem("<b>Record</b><br/><br />",
                subtitle: data));

            return calls.UmGo();
        }
Ejemplo n.º 3
0
        public static string ListRecord(String formGuid, String pageStr)
        {
            FormState state = FormState.Approved;
            Range range = Range.Day;
            Show show = Show.five;
            int page = int.Parse(pageStr);

            if (Utils.GetPostParameter("State") != null && !string.IsNullOrEmpty(Utils.GetPostParameter("State").ToString()))
                HttpContext.Current.Session["State"] = Utils.GetPostParameter("State").ToString();

            if (Utils.GetPostParameter("Range") != null && !string.IsNullOrEmpty(Utils.GetPostParameter("Range").ToString()))
                HttpContext.Current.Session["Range"] = Utils.GetPostParameter("Range").ToString();

            if (Utils.GetPostParameter("Show") != null && !string.IsNullOrEmpty(Utils.GetPostParameter("Show").ToString()))
                HttpContext.Current.Session["Show"] = Utils.GetPostParameter("Show").ToString();

            if (HttpContext.Current.Session["State"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["State"].ToString()))
                state = (FormState)Enum.Parse(typeof(FormState), HttpContext.Current.Session["State"].ToString());

            if (HttpContext.Current.Session["Range"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["Range"].ToString()))
                range = (Range)Enum.Parse(typeof(Range), HttpContext.Current.Session["Range"].ToString());

            if (HttpContext.Current.Session["Show"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["Show"].ToString()))
                show = (Show)Enum.Parse(typeof(Show), HttpContext.Current.Session["Show"].ToString());

            FormStorage fs = new FormStorage();
            RecordsViewer rv = new RecordsViewer();

            RecordStorage recordStorage = new RecordStorage();

            Umbraco.Forms.Core.Form form = fs.GetForm(Guid.Parse(formGuid));

            System.Collections.Generic.List<Record> records = rv.GetRecords(0, 0, form, Sorting.descending, new List<FormState> { state });

            List calls = new List();

            calls.AddListItem(new ListItem("<b>Filter</b>",
                subtitle: state.ToString() + ", Last " + range.ToString() + ", " + (int)show + " records per page",
                icon: GenericIcon.Filter,
                action: new Call("ConfigFilter", new string[] { formGuid })));

            DateTime minDate = DateTime.Now;
            switch (range)
            {
                case Range.hour:
                    minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0);
                    break;

                case Range.Month:
                    minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                    break;

                case Range.Year:
                    minDate = new DateTime(DateTime.Now.Year, 1, 1);
                    break;

                case Range.Decade:
                    minDate = DateTime.MinValue;
                    break;

                case Range.Day:
                default:
                    minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                    break;
            }

            if (records.Where(r => r.Created > minDate).Any())
            {

                int total = records.Where(r => r.Created > minDate).Count();
                IEnumerable<Record> results = records.Where(r => r.Created > minDate).OrderByDescending(r => r.Created).Skip((page - 1) * (int)show).Take((int)show);

                Button nextButton = null;
                if (total > (results.Count() + (page - 1) * (int)show))
                    nextButton = new Button(icon: GenericIcon.ArrowRight, action: new Call("ListRecord", new string[] { formGuid, (page + 1).ToString() }));

                calls.AddListItem(new ListItem("<b>Total result:</b> " + total.ToString(), subtitle: "Page <b>" + page.ToString() + "</b> to <b>" + (((int)(total / (int)show)) + 1).ToString() + "</b>", contextual_button: nextButton));

                foreach (Record record in results)
                {
                    calls.AddListItem(new ListItem(record.Created.ToString(),
                    subtitle: "Ip: " + record.IP,
                    action: new Call("ViewData", new string[] { record.Id.ToString() })));
                }

            }
            else
            {
                calls.AddListItem(new ListItem("<b>Total result:</b> 0", subtitle: "Page <b>0</b> to <b>0</b>"));
            }

            return calls.UmGo();
        }
Ejemplo n.º 4
0
        public static string ListForm()
        {
            FormStorage fs = new FormStorage();
            System.Collections.Generic.List<Umbraco.Forms.Core.Form> forms = fs.GetAllForms();

            List calls = new List();

            foreach (Umbraco.Forms.Core.Form form in forms)
            {
                calls.AddListItem(new ListItem(form.Name,
                subtitle: "Created: " + form.Created.ToString(),
                icon: GenericIcon.FolderClose,
                action: new Call("ListRecord", new string[] { form.Id.ToString(), "1" })));
            }

            return calls.UmGo();
        }
Ejemplo n.º 5
0
        public static string Orders()
        {
            List list = new List();

            Store currentStore = TC.GetStore(1);
            XElement allOrders = TC.GetAllFinalizedOrdersAsXml(1);

            var ordersList = (from order in allOrders.Elements("order")
                              orderby DateTime.Parse(order.Attribute("dateCreated").Value)
                              descending
                              select order.Attribute("id").Value);

            if (ordersList.Any())
            {
                foreach (var orderId in ordersList)
                {
                    Order order = TC.GetOrder(1, new Guid(orderId));
                    list.AddListItem(new ListItem(order.OrderNumber + "<b style='float: right;'>" + order.TotalPrice.Formatted + "</b>",
                        subtitle: "<span style='float: right;'>" + order.Properties.Get("email") + "</span>" + TCExtensions.GetOrderStatus(order.StoreId, order.OrderStatusId).Name.ToString() + "<br /><span style='float: right;'>" + order.Properties.Get("city") + "</span>" + order.DateCreated,
                        icon: GenericIcon.ShoppingCart,
                        action: new Call("OrderInfo", new string[] { order.StoreId.ToString(), order.Id.ToString() })
                    ));
                }
            }

            return list.UmGo();
        }