public static List <ComponentView> GetComponentList(string viewPath) { IComponentViewDataAccess cv = new ComponentViewDataAccess(viewPath); ComponentViewManager vm = new ComponentViewManager(cv); return(vm.GetViews()); }
private void Form1_Load(object sender, EventArgs e) { // var path= @"C:\WorkingFolder-Custom\TZ.BigDataScript\TZ.ImportDesk\ComponentLibrary"; ComponentView vm = new ComponentView(); ComponentViewManager cvm = new ComponentViewManager(new ComponentViewDataAccess(path)); // Views = cvm.GetViews(); //var view= cvm.NewView("EmployeeView"); // ComponentManager cmg = new ComponentManager("ed04c35e434145bba3529d7365ff1ff5186455310", new ComponentDataAccess(path) { }); // view.Components.Add( cmg.GetComponent()); // cvm.Save(view); //cmbData.Items.Add("Choose from the list"); //cmbData.SelectedIndex = 0; //foreach (ComponentView cv in Views) { // cmbData.Items.Add(cv.Name); //} //TZ.CompExtention. Component c = new CompExtention.Component(); // c.ID = ""; // c.Name = "Employee"; // c.TableName = "sys_user"; // c.Keys = new List<IAttribute>(); // c.Keys.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "1", // Name = "UserID", // DisplayName = "User Key", // Type = AttributeType._number, // IsKey = true, // IsUnique = true, // }); // c.Attributes = new List<IAttribute>(); // c.Attributes.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "1", // Name = "UserID", // DisplayName = "User Key", // Type = AttributeType._number, // IsKey = true, // IsUnique = true, // }); // c.Attributes.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "2", // Name = "F_200005", // DisplayName = "Employee No", // Type = AttributeType._string, // IsKey = false, // IsUnique = true, // }); // c.Attributes.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "3", // Name = "F_200015", // DisplayName = "Employee Name", // Type = AttributeType._string, // IsKey = false, // IsUnique = false, // }); // c.Attributes.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "4", // Name = "F_200115", // DisplayName = "Email", // Type = AttributeType._string, // IsKey = false, // IsUnique = false, // }); // c.Attributes.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "5", // Name = "F_200040", // DisplayName = "Gender", // Type = AttributeType._lookup, // IsKey = false, // IsUnique = false, // LookupInstanceID ="102", // LookupDisplayField ="Description", // }); // c.Attributes.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "6", // Name = "F_200050", // DisplayName = "Nationality", // Type = AttributeType._lookup, // IsKey = false, // IsUnique = false, // LookupInstanceID = "107", // LookupDisplayField = "Description", // }); // c.Attributes.Add(new TZ.CompExtention.Attribute() // { // ComponentID = c.ID, // ID = "7", // Name = "F_31075", // DisplayName = "Marital Status", // Type = AttributeType._lookup, // IsKey = false, // IsUnique = false, // LookupInstanceID = "254", // LookupDisplayField = "Description", // }); // cmg.Save(c); }
public void LoadView(int clientID) { ComponentViewManager cvm = new ComponentViewManager(this.ViewID, clientID, new TZ.CompExtention.DataAccess.ComponentViewHandler(this.Connection, clientID)); cvm.LoadViewComponents(); this.View = (ComponentView)cvm.View; if (this.Type == TemplateType.PIVOT) { Attribute PivotCol = new Attribute(); var cField = this.TemplateFields.Where(x => x.IsColumn == true).FirstOrDefault(); if (cField != null) { foreach (Component c in this.View.Components) { int attCount = c.Attributes.Count; for (int i = 0; i < attCount; i++) { var att = c.Attributes[i]; if (att.ID == cField.ID) { PivotCol = att; if (PivotCol.Type == AttributeType._lookup) { var dm = new DataManager(); dm.tableName("sys_fieldinstancelookup"); dm.SelectFields("fieldinstanceid", "sys_FieldInstanceLookup", FieldType._string); dm.SelectFields("LookUpID", "sys_FieldInstanceLookup", FieldType._string); dm.SelectFields("LookUpDescription", "sys_FieldInstanceLookup", FieldType._string); dm.SelectFields("LookUpCode", "sys_FieldInstanceLookup", FieldType._string); dm.Where("sys_FieldInstanceLookup", "clientid", "=", Convert.ToString(clientID)); dm.Where("sys_FieldInstanceLookup", "fieldinstanceid", "=", Convert.ToString(PivotCol.LookupInstanceID)); var dt = dm.GetData(Connection); int index = 0; foreach (DataRow dr in dt.Rows) { bool isRequired = false; if (index == 0) { isRequired = true; } c.AddAttribute(new Attribute() { ID = PivotCol.ID + "_" + dr["LookUpID"].ToString(), Name = dr["LookUpDescription"].ToString(), DisplayName = dr["LookUpDescription"].ToString(), Type = AttributeType._string, IsKey = false, IsRequired = isRequired, ClientID = clientID, ComponentID = c.ID, LookupInstanceID = PivotCol.LookupInstanceID, }); index = index + 1; this.TemplateFields.Add(new TemplateField() { ID = PivotCol.ID + "_" + dr["LookUpID"].ToString(), IsColumn = true, IsKey = false, IsDefault = true, IsRequired = isRequired, }); } } } } c.Attributes.Remove(PivotCol); var pField = this.TemplateFields.Where(x => x.IsPivot == true).FirstOrDefault(); if (pField != null) { c.Attributes.Remove(c.Attributes.Where(x => x.ID == pField.ID).FirstOrDefault()); this.TemplateFields.Remove(pField); } } } } }