protected override void RaiseImplement() { Guid? id = this.Paper.Dynamic.Id; Guid metadataId = this.Paper.Dynamic.MetadataId; DTObjects answers = this.Paper.Dynamic.Answers; if (id == null) { var para = answers.Select((item) => { return(item.GetValue <Guid>("questionId"), item.GetValue <string>("content")); }); var cmd = new CreatePaper(metadataId, para); var paper = cmd.Execute(); this.Id = paper.Id; } else { var para = answers == null ? null : answers.Select((item) => { return(item.GetValue <Guid>("id", Guid.Empty), item.GetValue <Guid>("questionId"), item.GetValue <string>("content")); }); var cmd = new UpdatePaper(id.Value, para); var paper = cmd.Execute(); this.Id = paper.Id; } }
public void Set(DTObjects values) { using (var temp = StringPool.Borrow()) { var code = temp.Item; code.AppendFormat("{0}.proxy().set({1});", this.Id, values.GetCode(false)); this.View.WriteCode(code.ToString()); } }
private static List <UIMenuItem> MapChildItems(DTObjects data) { List <UIMenuItem> items = new List <UIMenuItem>(); foreach (var itemData in data) { FillItems(itemData, items); } return(items); }
/// <summary> /// 刷新列表 /// </summary> /// <param name="deletedItems">指示哪些项被删除,如果没有删除项,那么传null</param> public void Reload(DTObjects deletedValues = null) { if (deletedValues == null) { this.View.WriteCode(string.Format("{0}.proxy().reload();", this.Id)); } else //传递项被删除,主要是为了dataTable组件记录的selectValues也可以同步删除,否则会可能浏览器内存占用过大 { this.View.WriteCode(string.Format("{0}.proxy().reload({1});", this.Id, deletedValues.GetCode(false))); } }
private object GetListValue(DomainProperty property, DTObjects values) { IList list = property.PropertyType.CreateInstance() as IList; if (list == null) { throw new DomainDrivenException(string.Format(Strings.DynamicObjectLoadError, this.Define.TypeName)); } switch (property.DomainPropertyType) { case DomainPropertyType.AggregateRootList: case DomainPropertyType.EntityObjectList: case DomainPropertyType.EntityObjectProList: case DomainPropertyType.ValueObjectList: { var elementType = property.DynamicType as RuntimeObjectType; if (elementType == null) { throw new DomainDrivenException(string.Format(Strings.DynamicObjectLoadError, this.Define.TypeName)); } var objDefine = elementType.Define; foreach (DTObject value in values) { DynamicObject obj = objDefine.CreateInstance(value); list.Add(obj); } return(list); } case DomainPropertyType.PrimitiveList: { foreach (DTObject value in values) { if (!value.IsSingleValue) { throw new DomainDrivenException(string.Format(Strings.DynamicObjectLoadError, this.Define.TypeName)); } list.Add(value.GetValue()); } return(list); } } throw new DomainDrivenException(string.Format(Strings.DynamicObjectLoadError, this.Define.TypeName)); }
public void CreateListDTO() { DTObject dto = DTObject.CreateReusable("{id,name,hobby:[{v,n}]}"); dto.SetValue("id", 1); dto.SetValue("name", "Louis"); DTObject obj = dto.CreateAndPush("hobby"); obj.SetValue("v", 0); obj.SetValue("n", string.Format("LS{0}", 0)); obj = dto.CreateAndPush("hobby"); obj.SetValue("v", 1); obj.SetValue("n", string.Format("LS{0}", 1)); DTObjects list = dto.GetList("hobby"); for (int i = 0; i < list.Count; i++) { Assert.AreEqual(i, list[i].GetValue <int>("v")); Assert.AreEqual(string.Format("LS{0}", i), list[i].GetValue <string>("n")); } Assert.AreEqual(1, dto.GetValue <int>("id")); Assert.AreEqual("Louis", dto.GetValue <string>("name")); //Assert.AreEqual("{\"id\",\"name\",\"hobby\":[{\"v\",\"n\"}]}", dto.GetCode(false)); //Assert.AreEqual("{\"id\":1,\"name\":\"Louis\",\"hobby\":[{\"v\":0,\"n\":\"LS0\"},{\"v\":1,\"n\":\"LS1\"}]}", dto.GetCode()); var code = dto.GetCode(); var copy = DTObject.CreateReusable(code); list = dto.GetList("hobby"); for (int i = 0; i < list.Count; i++) { Assert.AreEqual(i, list[i].GetValue <int>("v")); Assert.AreEqual(string.Format("LS{0}", i), list[i].GetValue <string>("n")); } Assert.AreEqual(1, dto.GetValue <int>("id")); Assert.AreEqual("Louis", dto.GetValue <string>("name")); }
//private DateTime _value = DateTime.MinValue; //public DateTime Value //{ // get // { // if (_value == DateTime.MinValue) // _value = this.Metadata.GetValue<DateTime>("value", DateTime.MinValue); // return _value; // } //} #region 发射命令 /// <summary> /// 设置值 /// </summary> public void SetConfig(DTObjects config) { this.View.WriteCode(string.Format("{0}.proxy().setConfig({1});", this.Id, config.GetCode(false))); }
/// <summary> /// /// </summary> /// <param name="seriesItemName">每个饼状图区域的名称</param> /// <param name="seriesData">格式为:[{name,value}]</param> public void SetPie(string seriesItemName, DTObjects seriesData) { SetPie(default((string, string, string)), seriesItemName, seriesData); }
public void SetValue(DTObjects value) { this.View.WriteCode(string.Format("{0}.proxy().set({1});", this.Id, value.GetCode(false))); }
/// <summary> /// 设置值 /// </summary> public void SetValue(DTObject[] value) { DTObjects list = new DTObjects(value); this.View.WriteCode(string.Format("{0}.proxy().set({1});", this.Id, list.GetCode(false))); }
public void SetData(DTObjects data) { this.View.WriteCode(string.Format("{0}.proxy().setData({1});", this.Id, data.GetCode(false))); }
/// <summary> /// 对列表进行赋值操作 /// </summary> /// <param name="value"></param> public void SetData(DTObject[] data) { DTObjects list = new DTObjects(data); this.View.WriteCode(string.Format("{0}.proxy().setData({1});", this.Id, list.GetCode(false))); }