public static string CheckRecord(String recordId) { try { RecordStorage rs = new RecordStorage(); Record record = rs.GetRecord(Guid.Parse(recordId)); RecordService s = new RecordService(record); s.Approve(); } catch (Exception ex) { if (ex.Message.Contains("This license is invalid")) return new MessageBox("Record approved successfully", new Button("Ok", new Call("ViewData", new string[] { recordId }))).UmGo(); else return new MessageBox("Error to approved this record", new Button("Close")).UmGo("Warning"); } return new MessageBox("Record approved successfully", new Button("Ok", new Call("ViewData", new string[] { recordId }))) .UmGo(); }
public static string EmailRecord(String recordId) { String emailTo = Utils.GetPostParameter("email").ToString(); String emailFrom = umbraco.UmbracoSettings.NotificationEmailSender; FormStorage fs = new FormStorage(); RecordStorage rs = new RecordStorage(); Record record = rs.GetRecord(Guid.Parse(recordId)); Umbraco.Forms.Core.Form form = fs.GetForm(record.Form); string data = "<p><b>Form:</b> " + form.Name + "</p>"; data += "<p><b>State:</b><br/>" + record.State.ToString() + "</p>"; data += "<p><b>Created:</b><br/>" + record.Created.ToString() + "</p>"; data += "<p><b>Ip:</b><br/>" + record.IP + "</p>"; 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>"; } try { umbraco.library.SendMail(emailFrom, emailTo, "Contour record", data, true); } catch { return new MessageBox("Error to send record ", new Button("Close")).UmGo("Warning"); } return new MessageBox("Record sent successfully", new Button("Ok", new Call("ViewData", new string[] { recordId }))) .UmGo(); }
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(); }
public static string DeleteRecord(String recordId) { string formGuid = null; try { RecordStorage rs = new RecordStorage(); Record record = rs.GetRecord(Guid.Parse(recordId)); RecordService s = new RecordService(record); formGuid = record.Form.ToString(); s.Delete(); } catch (Exception ex) { if (ex.Message.Contains("This license is invalid")) return new MessageBox("Record deleted successfully", new Button("Ok", new Call("ListRecord", new string[] { formGuid, "1" }))).UmGo(); else return new MessageBox("Error to delete this record", new Button("Close")).UmGo("Warning"); } return new MessageBox("Record deleted successfully", new Button("Ok", new Call("ListRecord", new string[] { formGuid, "1" }))) .UmGo(); }