public TContentClient (GadgetTest gadget) : this () { if (gadget.NotNull ()) { Id = gadget.Id; Category = TCategoryType.ToValue (TCategory.Test); Name = gadget.GadgetName; Info = gadget.GadgetInfo; if (gadget.HasContent) { // Target if (gadget.HasContentTarget) { var contents = new Collection<GadgetTarget> (); gadget.RequestContent (contents); foreach (var item in contents) { ClientList.Add (new TContentClient (item)); } } // Test if (gadget.HasContentTest) { var contents = new Collection<GadgetTest> (); gadget.RequestContent (contents); foreach (var item in contents) { ClientList.Add (new TContentClient (item)); } } } } }
internal void RequestModel(TEntityAction action) { if (action.NotNull()) { action.SelectCategoryType(TCategoryType.Create(TCategory.Target)); action.CollectionAction.ExtensionNodeCollection.Clear(); ComponentModelProperty.RequestModel(action); if (action.SupportAction.SelectionInfo.Tag is Guid materialId) { action.ModelAction.ComponentStatusModel.UseNodeModel = true; action.ModelAction.ComponentStatusModel.NodeReverse = true; // Here gadget Material must be Parent action.ModelAction.ExtensionNodeModel.ChildId = ComponentModelProperty.Id; action.ModelAction.ExtensionNodeModel.ChildCategory = TCategoryType.ToValue(TCategory.Target); action.ModelAction.ExtensionNodeModel.ParentId = materialId; action.ModelAction.ExtensionNodeModel.ParentCategory = TCategoryType.ToValue(TCategory.Material); // update collection action.CollectionAction.ExtensionNodeCollection.Add(action.ModelAction.ExtensionNodeModel); } } }
static void Request (TContentClient rootClient, GadgetTest rootGadget) { if (rootClient.NotNull () && rootGadget.NotNull ()) { rootClient.RequestData (rootGadget); if (rootClient.ClientList.Any ()) { foreach (var client in rootClient.ClientList) { var category = TCategoryType.FromValue (client.Category); // Target if (category.Equals (TCategory.Target)) { var gadgetTarget = GadgetTarget.CreateDefault; client.RequestData (gadgetTarget); rootGadget.AddContent (gadgetTarget); } // Test if (category.Equals (TCategory.Test)) { var gadgetTest = GadgetTest.CreateDefault; Request (client, gadgetTest); rootGadget.AddContent (gadgetTest); } } } } }
internal void RequestModel(TEntityAction action) { action.ThrowNull(); foreach (var item in GadgetCheckedCollection) { // ensure ChildId diferent from ParentId if (item.Id.NotEquals(action.Id)) { var componentRelation = ComponentRelation.CreateDefault; componentRelation.ChildId = item.Id; componentRelation.ChildCategory = TCategoryType.ToValue(TCategory.Test); componentRelation.ParentId = action.Id; componentRelation.ParentCategory = TCategoryType.ToValue(action.CategoryType.Category); // Extension if (string.IsNullOrEmpty(action.ModelAction.ExtensionTextModel.Extension)) { action.ModelAction.ExtensionTextModel.Extension = m_CurrentMaterialGadget.GadgetName; } action.CollectionAction.ComponentRelationCollection.Add(componentRelation); } } // update rule action.SupportAction.Rule.Pump("gadget"); }
public static void Request (TActionComponent component, TEntityAction entityAction) { if (component.NotNull ()) { if (component.IsCategory (TCategory.Target)) { if (entityAction.NotNull ()) { entityAction.Id = component.Models.GadgetTargetModel.Id; entityAction.CategoryType.Select (TCategory.Target); entityAction.ModelAction.ComponentInfoModel.Name = component.Models.GadgetTargetModel.GadgetInfo; entityAction.ModelAction.ComponentStatusModel.Busy = component.Models.GadgetTargetModel.Busy; entityAction.ModelAction.ComponentInfoModel.Id = component.Models.GadgetTargetModel.Id; entityAction.ModelAction.ExtensionNodeModel.ChildId = component.Models.GadgetTargetModel.Id; entityAction.ModelAction.ExtensionNodeModel.ChildCategory = TCategoryType.ToValue (TCategory.Target); entityAction.ModelAction.ExtensionNodeModel.ParentId = component.Models.GadgetTargetModel.MaterialId; entityAction.ModelAction.ExtensionNodeModel.ParentCategory = TCategoryType.ToValue (TCategory.Material); entityAction.ModelAction.ExtensionTextModel.Id = component.Models.GadgetTargetModel.Id; entityAction.ModelAction.ExtensionTextModel.Text = component.Models.GadgetTargetModel.GadgetName; entityAction.ModelAction.ExtensionTextModel.Description = component.Models.GadgetTargetModel.Description; entityAction.ModelAction.ExtensionTextModel.Reference = component.Models.GadgetTargetModel.Reference; entityAction.ModelAction.ExtensionTextModel.Value = component.Models.GadgetTargetModel.Value; entityAction.ModelAction.ExtensionTextModel.ExternalLink = component.Models.GadgetTargetModel.ExternalLink; entityAction.ModelAction.ComponentInfoModel.Enabled = component.Models.GadgetTargetModel.Enabled; } } } }
static bool RequestComponent (Guid id, TModelContext context, TEntityAction action, TModelAction modelAction) { /* DATA OUT - action.ModelAction (model) */ bool res = false; try { // info var infoList = context.ComponentInfo.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; // info found if (infoList.Count.Equals (1)) { var model = infoList [0]; modelAction.ComponentInfoModel.CopyFrom (model); // update category if (action.CategoryType.IsCategory (TCategory.None)) { var descList = context.ComponentDescriptor.AsQueryable() .Where (p => p.Id.Equals (action.Id)) .ToList () ; // found if (descList.Count.Equals (1)) { var desc = descList [0]; action.SelectCategoryType (TCategoryType.Create (TCategoryType.FromValue (desc.Category))); } } } // status var statusList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; // status found if (statusList.Count.Equals (1)) { var model = statusList [0]; modelAction.ComponentStatusModel.CopyFrom (model); } res = true; } catch (Exception exception) { THelper.FormatException ("RequestComponent - TOperationSupport", exception, action); } return (res); }
public TContentClient () { Id = Guid.Empty; Category = TCategoryType.ToValue (TCategory.None); Name = string.Empty; Info = string.Empty; Value = string.Empty; ClientList = new Collection<TContentClient> (); }
public TContentClient (GadgetRegistration gadget) : this () { if (gadget.NotNull ()) { Id = gadget.Id; Category = TCategoryType.ToValue (TCategory.Registration); Name = gadget.GadgetName; Info = gadget.GadgetInfo; } }
public TContentClient (GadgetTarget gadget) : this () { if (gadget.NotNull ()) { Id = gadget.Id; Category = TCategoryType.ToValue (TCategory.Target); Name = gadget.GadgetName; Info = gadget.GadgetInfo; Value = gadget.Value; } }
public static void Request (TActionComponent component, TEntityAction entityAction) { if (component.NotNull ()) { if (component.IsCategory (TCategory.Result)) { var gadget = component.Models.GadgetResultModel; if (entityAction.NotNull ()) { entityAction.Id = gadget.Id; entityAction.CategoryType.Select (TCategory.Result); entityAction.ModelAction.ComponentInfoModel.Id = gadget.Id; entityAction.ModelAction.ComponentInfoModel.Name = gadget.GadgetInfo; entityAction.ModelAction.ComponentInfoModel.Enabled = gadget.Enabled; entityAction.ModelAction.ComponentStatusModel.Id = gadget.Id; entityAction.ModelAction.ComponentStatusModel.Busy = gadget.Busy; entityAction.ModelAction.ComponentStatusModel.Locked = gadget.Locked; entityAction.ModelAction.ExtensionTextModel.Id = gadget.Id; entityAction.ModelAction.ExtensionTextModel.Text = gadget.GadgetName; entityAction.ModelAction.ExtensionTextModel.Date = gadget.Date; entityAction.ModelAction.ExtensionTextModel.Description = gadget.Description; // Jason serializer var clientList = new Collection<TContentClient> (); var contentRegistration = GadgetRegistration.CreateDefault; gadget.RequestContent (contentRegistration); clientList.Add (new TContentClient (contentRegistration)); var contents = new Collection<GadgetTest> (); gadget.RequestContent (contents); foreach (var item in contents) { clientList.Add (new TContentClient (item)); } StringBuilder contentString = new StringBuilder (); foreach (var item in clientList) { var jason = new TJasonSerializer<TContentClient> (item); jason.ToJsonString (); var str = jason.JasonString + ";"; contentString.Append (str); } entityAction.ModelAction.ExtensionContentModel.Id = gadget.Id; entityAction.ModelAction.ExtensionContentModel.Category = TCategoryType.ToValue (TCategory.Result); entityAction.ModelAction.ExtensionContentModel.Contents = contentString.ToString (); } } } }
void SelectById (TModelContext context, TEntityAction action) { /* DATA IN - action.Id - action.CollectionAction.CategoryRelationCollection DATA OUT - action.ModelAction (model) - action.CollectionAction.ModeCollection {id, model} (for each node) - action.CollectionAction.EntityCollection {id, model} (for each relation) */ try { // Id must exist if (action.Id.IsEmpty ()) { action.Result = new TValidationResult ("[Select ById] Id can NOT be NULL or EMPTY!"); } else { action.Result = TValidationResult.Success; // desired result DO NOT MOVE FROM HERE // relation by id (use parent) action.CollectionAction.SelectComponentOperation (TComponentOperation.TInternalOperation.Id); action.ComponentOperation.SelectById (action.Id); var operationSupport = new TOperationSupport (context, action); operationSupport.RequestComponent (context, action); operationSupport.RequestExtension (context, action); TOperationSupport.RequestNode (context, action); TOperationSupport.RequestRelation (context, action); // use Parent relation if (action.ComponentOperation.ParentIdCollection.ContainsKey (action.Id)) { var componentRelationList = action.ComponentOperation.ParentIdCollection [action.Id]; foreach (var relation in componentRelationList) { var entityAction = TEntityAction.Create (TCategoryType.FromValue (relation.ChildCategory)); entityAction.CollectionAction.SetCollection (action.CollectionAction.CategoryRelationCollection); entityAction.Id = relation.ChildId; SelectById (context, entityAction); // my self (tree navigation) action.CollectionAction.EntityCollection.Add (relation.ChildId, entityAction); } } } } catch (Exception exception) { Server.Models.Infrastructure.THelper.FormatException ("Select ById", exception, action); } }
public void RequestExtension (TComponentExtension componentExtension) { if (componentExtension.NotNull ()) { // request CategoryRelation (Extension) var categoryValue = TCategoryType.ToValue (CategoryType.Category); var categoryRelationList = CollectionAction.CategoryRelationCollection .Where (p => p.Category.Equals (categoryValue)) .ToList () ; if (categoryRelationList.Count.Equals (1)) { var categoryRelation = categoryRelationList [0]; // get extension using TComponentExtension var extension = TComponentExtension.Create (categoryRelation.Extension); extension.Request (); componentExtension.CopyFrom (extension); } } }
public void Request (GadgetResult gadget) { if (gadget.NotNull ()) { var category = TCategoryType.FromValue (Category); // Registration if (category.Equals (TCategory.Registration)) { var gadgetRegistration = GadgetRegistration.CreateDefault; RequestData (gadgetRegistration); gadget.AddContent (gadgetRegistration); } // Test if (category.Equals (TCategory.Test)) { var gadgetTest = GadgetTest.CreateDefault; Request (this, gadgetTest); gadget.AddContent (gadgetTest); } } }
internal bool Add (Guid id, int categoryValue) { bool res = false; if (id.NotEmpty ()) { if (Contains (id).IsFalse ()) { var category = TCategoryType.FromValue (categoryValue); if (category.Equals (TCategory.Registration)) { Registration.Id = id; res = true; } if (category.Equals (TCategory.Test)) { IdCollection.Add (id); res = true; } } } return (res); }
// TODO: serve para que???? public override void SelectItem (TEntityAction action) { if (action.NotNull ()) { var categoryValue = TCategoryType.ToValue (action.CategoryType.Category); // Extension (CategoryRelationCollection) var categoryRelationList = action.CollectionAction.CategoryRelationCollection .Where (p => p.Category.Equals (categoryValue)) .ToList () ; if (categoryRelationList.Count.Equals (1)) { var categoryRelation = categoryRelationList [0]; // get extension using TComponentExtension var extension = TComponentExtension.Create (categoryRelation.Extension); extension.Request (); foreach (var item in action.CollectionAction.ModelCollection) { var modelStyle = TContentStyle.NONE; switch (StyleInfo.StyleMode) { case TContentStyle.Mode.Horizontal: modelStyle = item.Value.ExtensionLayoutModel.StyleHorizontal; break; case TContentStyle.Mode.Vertical: modelStyle = item.Value.ExtensionLayoutModel.StyleVertical; break; } if (modelStyle.Equals (StyleInfo.StyleString, StringComparison.InvariantCulture)) { } } } } }
void CollectionFull (TModelContext context, TEntityAction action) { /* DATA IN: action.Operation.CategoryType.Category action.CollectionAction.CategoryRelationCollection */ try { // select Id by Category var categoryValue = TCategoryType.ToValue (action.Operation.CategoryType.Category); var descriptors = context.ComponentDescriptor.AsQueryable() .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // found if (descriptors.Any ()) { // Component Info, Status action.CollectionAction.ComponentInfoCollection.Clear (); action.CollectionAction.ComponentStatusCollection.Clear (); foreach (var descriptor in descriptors) { // Info var infoList = context.ComponentInfo.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // Status var statusList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // info found if (infoList.Count.Equals (1)) { var infoModel = infoList [0]; action.CollectionAction.ComponentInfoCollection.Add (infoModel); } // status found if (statusList.Count.Equals (1)) { var statusModel = statusList [0]; action.CollectionAction.ComponentStatusCollection.Add (statusModel); } } // Component Relation // by Category action.CollectionAction.ComponentOperation.Clear (); action.CollectionAction.SelectComponentOperation (TComponentOperation.TInternalOperation.Category); action.CollectionAction.ComponentOperation.SelectByCategory (categoryValue); var componentRelationFullList = context.ComponentRelation .ToList () ; foreach (var itemCategory in action.CollectionAction.ComponentOperation.CategoryCollection) { // parent var parentList = componentRelationFullList .Where (p => p.ParentCategory.Equals (itemCategory)) .ToList () ; action.CollectionAction.ComponentOperation.SelectParent (itemCategory, parentList); // child var childList = componentRelationFullList .Where (p => p.ChildCategory.Equals (itemCategory)) .ToList () ; action.CollectionAction.ComponentOperation.SelectChild (itemCategory, childList); } // Extension (CategoryRelationCollection) var categoryRelationList = action.CollectionAction.CategoryRelationCollection .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // found if (categoryRelationList.Count.Equals (1)) { var categoryRelation = categoryRelationList [0]; // get extension using TComponentExtension var extension = TComponentExtension.Create (categoryRelation.Extension); extension.Request (); foreach (var item in action.CollectionAction.ComponentInfoCollection) { var id = item.Id; // Status var compStatus = Models.Component.ComponentStatus.CreateDefault; var statusList = action.CollectionAction.ComponentStatusCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (statusList.Count.Equals (1)) { compStatus.CopyFrom (statusList [0]); } foreach (var extensionName in extension.ExtensionList) { switch (extensionName) { case TComponentExtensionNames.Document: { //var list = context.ExtensionDocument // .Where (p => p.Id.Equals (id)) // .ToList () //; //if (list.Count.Equals (1)) { // action.CollectionAction.ExtensionDocumentCollection.Add (list [0]); //} } break; case TComponentExtensionNames.Geometry: { var list = context.ExtensionGeometry.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionGeometryCollection.Add (list [0]); } } break; case TComponentExtensionNames.Image: { var list = context.ExtensionImage.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionImageCollection.Add (list [0]); } } break; case TComponentExtensionNames.Layout: { var list = context.ExtensionLayout.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionLayoutCollection.Add (list [0]); } } break; case TComponentExtensionNames.Node: { var nodeModeldList = context.ExtensionNode.AsQueryable() .Where (p => p.ParentId.Equals (id)) .ToList () ; // Node Reverse if (compStatus.NodeReverse) { nodeModeldList = context.ExtensionNode.AsQueryable() .Where (p => p.ChildId.Equals (id)) .ToList () ; } // Node Model if (compStatus.UseNodeModel) { if (nodeModeldList.Count.Equals (1)) { action.ModelAction.ExtensionNodeModel.CopyFrom (nodeModeldList [0]); action.CollectionAction.ExtensionNodeCollection.Add (nodeModeldList [0]); } } // Node Collection if (compStatus.UseNodeCollection) { foreach (var nodeModel in nodeModeldList) { action.CollectionAction.ExtensionNodeCollection.Add (nodeModel); } } } break; case TComponentExtensionNames.Text: { var list = context.ExtensionText.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionTextCollection.Add (list [0]); } } break; case TComponentExtensionNames.Content: { var list = context.ExtensionContent.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionContentCollection.Add (list [0]); } } break; } } } } // populate ModelCollection action.CollectionAction.ModelCollection.Clear (); var componentExtension = TComponentExtension.CreateDefault; action.RequestExtension (componentExtension); foreach (var item in action.CollectionAction.ComponentInfoCollection) { // component // Info var id = item.Id; var models = TModelAction.CreateDefault; models.ComponentInfoModel.CopyFrom (item); // Status var compStatus = ComponentStatus.CreateDefault; var statusList = action.CollectionAction.ComponentStatusCollection .Where (p => p.Id.Equals (id)) .ToList () ; // found if (statusList.Count.Equals (1)) { models.ComponentStatusModel.CopyFrom (statusList [0]); compStatus.CopyFrom (statusList [0]); } // extension foreach (var extensionName in componentExtension.ExtensionList) { switch (extensionName) { case TComponentExtensionNames.Document: { //var list = action.CollectionAction.ExtensionDocumentCollection // .Where (p => p.Id.Equals (id)) // .ToList () //; //if (list.Count.Equals (1)) { // models.ExtensionDocumentModel.CopyFrom (list [0]); //} } break; case TComponentExtensionNames.Geometry: { var list = action.CollectionAction.ExtensionGeometryCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionGeometryModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Image: { var list = action.CollectionAction.ExtensionImageCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionImageModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Layout: { var list = action.CollectionAction.ExtensionLayoutCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionLayoutModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Node: { var nodeModellist = action.CollectionAction.ExtensionNodeCollection .Where (p => p.ParentId.Equals (id)) .ToList () ; if (compStatus.NodeReverse) { nodeModellist = action.CollectionAction.ExtensionNodeCollection .Where (p => p.ChildId.Equals (id)) .ToList () ; } if (compStatus.UseNodeModel) { if (nodeModellist.Count.Equals (1)) { models.ExtensionNodeModel.CopyFrom (nodeModellist [0]); } } } break; case TComponentExtensionNames.Text: { var list = action.CollectionAction.ExtensionTextCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionTextModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Content: { var list = action.CollectionAction.ExtensionContentCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionContentModel.CopyFrom (list [0]); } } break; } } action.CollectionAction.ModelCollection.Add (id, models); } } // ComponentOperation - Operation.Category if (action.CollectionAction.ComponentOperation.IsComponentOperation (TComponentOperation.TInternalOperation.Category)) { action.IdCollection.Clear (); var list = new Collection<ComponentRelation> (action.CollectionAction.ComponentOperation.RequestParentCategoryCollection ()); foreach (var relation in list) { if (relation.ChildId.NotEmpty ()) { action.IdCollection.Add (relation.ChildId); } } } action.Result = TValidationResult.Success; } catch (Exception exception) { Models.Infrastructure.THelper.FormatException ("Collection Full", exception, action); } }
void CollectionMinimum (TModelContext context, TEntityAction action) { /* DATA IN: action.Operation.CategoryType.Category action.CollectionAction.CategoryRelationCollection */ try { // select Id by Category var categoryValue = TCategoryType.ToValue (action.Operation.CategoryType.Category); var descriptors = context.ComponentDescriptor.AsQueryable() .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // found if (descriptors.Any ()) { // Component Info, Status action.CollectionAction.ComponentInfoCollection.Clear (); action.CollectionAction.ComponentStatusCollection.Clear (); foreach (var descriptor in descriptors) { // Info var infoList = context.ComponentInfo.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // Status var statusList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // info found if (infoList.Count.Equals (1)) { var infoModel = infoList [0]; action.CollectionAction.ComponentInfoCollection.Add (infoModel); } // status found if (statusList.Count.Equals (1)) { var statusModel = statusList [0]; action.CollectionAction.ComponentStatusCollection.Add (statusModel); } } // Extension (CategoryRelationCollection) var categoryRelationList = action.CollectionAction.CategoryRelationCollection .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // found if (categoryRelationList.Count.Equals (1)) { var categoryRelation = categoryRelationList [0]; // get extension using TComponentExtension var extension = TComponentExtension.Create (categoryRelation.Extension); extension.Request (); foreach (var item in action.CollectionAction.ComponentInfoCollection) { var id = item.Id; foreach (var extensionName in extension.ExtensionList) { switch (extensionName) { case TComponentExtensionNames.Layout: { var list = context.ExtensionLayout.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionLayoutCollection.Add (list [0]); } } break; } } } } // populate ModelCollection action.CollectionAction.ModelCollection.Clear (); var componentExtension = TComponentExtension.CreateDefault; action.RequestExtension (componentExtension); foreach (var item in action.CollectionAction.ComponentInfoCollection) { // component // Info var id = item.Id; var models = TModelAction.CreateDefault; models.ComponentInfoModel.CopyFrom (item); // Status var statusList = action.CollectionAction.ComponentStatusCollection .Where (p => p.Id.Equals (id)) .ToList () ; // found if (statusList.Count.Equals (1)) { models.ComponentStatusModel.CopyFrom (statusList [0]); } // extension foreach (var extensionName in componentExtension.ExtensionList) { switch (extensionName) { case TComponentExtensionNames.Layout: { var list = action.CollectionAction.ExtensionLayoutCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionLayoutModel.CopyFrom (list [0]); } } break; } } action.CollectionAction.ModelCollection.Add (id, models); } } action.Result = TValidationResult.Success; } catch (Exception exception) { Models.Infrastructure.THelper.FormatException ("Collection Full", exception, action); } }
void Insert (TModelContext context, TEntityAction action) { /* DATA IN: - action.Operation.CategoryType.Category - action.CollectionAction.CategoryRelationCollection - action.ModelAction - action.CollectionAction.ExtensionNodeCollection */ try { // Validate Name if (ValidateString (action)) { //Id var id = Guid.NewGuid (); var categoryValue = TCategoryType.ToValue (action.Operation.CategoryType.Category); // Descriptor action.ModelAction.ComponentDescriptorModel.Id = id; action.ModelAction.ComponentDescriptorModel.Category = categoryValue; var compDescriptor = ComponentDescriptor.CreateDefault; compDescriptor.CopyFrom (action.ModelAction.ComponentDescriptorModel); context.ComponentDescriptor.Add (compDescriptor); // Info action.ModelAction.ComponentInfoModel.Id = id; var compInfo = ComponentInfo.CreateDefault; compInfo.CopyFrom (action.ModelAction.ComponentInfoModel); context.ComponentInfo.Add (compInfo); // Status action.ModelAction.ComponentStatusModel.Id = id; var compStatus = ComponentStatus.CreateDefault; compStatus.CopyFrom (action.ModelAction.ComponentStatusModel); context.ComponentStatus.Add (compStatus); // status collection foreach (var item in action.CollectionAction.ComponentStatusCollection) { var list = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (item.Id)) .ToList () ; // already exist (update) if (list.Count.Equals (1)) { var model = list [0]; model.Change (item); context.ComponentStatus.Update (model); } // new (add) else { context.ComponentStatus.Add (item); } } // Component Relation Collection foreach (var item in action.CollectionAction.ComponentRelationCollection) { // change child status busy to true var childList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (item.ChildId)) .ToList () ; // found if (childList.Count.Equals (1)) { var child = childList [0]; child.Busy = true; context.ComponentStatus.Update (child); // update } item.ParentId = id; context.ComponentRelation.Add (item); // insert new } // extensions // Extension (CategoryRelationCollection) var categoryRelationList = action.CollectionAction.CategoryRelationCollection .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // found if (categoryRelationList.Count.Equals (1)) { var categoryRelation = categoryRelationList [0]; // get extension using TComponentExtension var extension = TComponentExtension.Create (categoryRelation.Extension); extension.Request (); foreach (var extensionName in extension.ExtensionList) { switch (extensionName) { case TComponentExtensionNames.Document: { //action.ModelAction.ExtensionDocumentModel.Id = id; //var extDocument = ExtensionDocument.CreateDefault; //extDocument.CopyFrom (action.ModelAction.ExtensionDocumentModel); //context.ExtensionDocument.Add (extDocument); } break; case TComponentExtensionNames.Geometry: { action.ModelAction.ExtensionGeometryModel.Id = id; var extGeometry = ExtensionGeometry.CreateDefault; extGeometry.CopyFrom (action.ModelAction.ExtensionGeometryModel); context.ExtensionGeometry.Add (extGeometry); } break; case TComponentExtensionNames.Image: { action.ModelAction.ExtensionImageModel.Id = id; var extImage = ExtensionImage.CreateDefault; extImage.CopyFrom (action.ModelAction.ExtensionImageModel); context.ExtensionImage.Add (extImage); } break; case TComponentExtensionNames.Layout: { action.ModelAction.ExtensionLayoutModel.Id = id; var extLayout = ExtensionLayout.CreateDefault; extLayout.CopyFrom (action.ModelAction.ExtensionLayoutModel); context.ExtensionLayout.Add (extLayout); } break; case TComponentExtensionNames.Node: { // Node reverse if (compStatus.NodeReverse) { // use Node from ModelAction (only) if (compStatus.UseNodeModel) { action.ModelAction.ExtensionNodeModel.ChildId = id; // update context.ExtensionNode.Add (action.ModelAction.ExtensionNodeModel); // update status var parentId = action.ModelAction.ExtensionNodeModel.ParentId; var statusList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (parentId)) .ToList () ; // found if (statusList.Count.Equals (1)) { var model = statusList [0]; model.Busy = true; context.ComponentStatus.Update (model); } context.SaveChanges (); // update all } } else { // use Node from ModelAction if (compStatus.UseNodeModel) { action.ModelAction.ExtensionNodeModel.ParentId = id; // update context.ExtensionNode.Add (action.ModelAction.ExtensionNodeModel); } // Use Node Collection if (compStatus.UseNodeCollection) { foreach (var nodeModel in action.CollectionAction.ExtensionNodeCollection) { nodeModel.ParentId = id; // for sure context.ExtensionNode.Add (nodeModel); } } context.SaveChanges (); // update all // update status var nodeList = context.ExtensionNode.AsQueryable() .Where (p => p.ParentId.Equals (id)) .ToList () ; foreach (var node in nodeList) { var statusList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (node.ChildId)) .ToList () ; // found if (statusList.Count.Equals (1)) { var model = statusList [0]; model.Busy = true; context.ComponentStatus.Update (model); } } context.SaveChanges (); // update all } } break; case TComponentExtensionNames.Text: { action.ModelAction.ExtensionTextModel.Id = id; var extText = ExtensionText.CreateDefault; extText.CopyFrom (action.ModelAction.ExtensionTextModel); context.ExtensionText.Add (extText); } break; case TComponentExtensionNames.Content: { action.ModelAction.ExtensionContentModel.Id = id; var extContent = ExtensionContent.CreateDefault; extContent.CopyFrom (action.ModelAction.ExtensionContentModel); context.ExtensionContent.Add (extContent); } break; } } } context.SaveChanges (); action.Result = TValidationResult.Success; } } catch (Exception exception) { Server.Models.Infrastructure.THelper.FormatException ("Insert", exception, action); } }
TOperationSupport () { Id = Guid.Empty; CategoryValue = TCategoryType.ToValue (TCategory.None); }
void SelectZap (TModelContext context, TEntityAction action) { /* DATA IN: action.IdCollection {id to zap} action.CategoryType DATA OUT: action.CollectionAction.ModelCollection [id] {Model} */ try { action.CollectionAction.ModelCollection.Clear (); var categoryValue = TCategoryType.ToValue (action.CategoryType.Category); // search Id by category var descriptors = context.ComponentDescriptor.AsQueryable() .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // zap foreach (var idToZap in action.IdCollection) { var zapList = descriptors .Where (p => p.Id.Equals (idToZap)) .ToList () ; // found if (zapList.Count.Equals (1)) { // update descriptors descriptors.Remove (zapList [0]); } } // Component Info, Status action.CollectionAction.ComponentInfoCollection.Clear (); action.CollectionAction.ComponentStatusCollection.Clear (); foreach (var descriptor in descriptors) { // Info var infoList = context.ComponentInfo.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // Status var statusList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // info found if (infoList.Count.Equals (1)) { var infoModel = infoList [0]; action.CollectionAction.ComponentInfoCollection.Add (infoModel); } // status found if (statusList.Count.Equals (1)) { var statusModel = statusList [0]; action.CollectionAction.ComponentStatusCollection.Add (statusModel); } } // Extension (CategoryRelationCollection) var categoryRelationList = action.CollectionAction.CategoryRelationCollection .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // found if (categoryRelationList.Count.Equals (1)) { var categoryRelation = categoryRelationList [0]; // get extension using TComponentExtension var extension = TComponentExtension.Create (categoryRelation.Extension); extension.Request (); foreach (var item in action.CollectionAction.ComponentInfoCollection) { var id = item.Id; foreach (var extensionName in extension.ExtensionList) { switch (extensionName) { //case TComponentExtensionNames.Document: { // var list = context.ExtensionDocument // .Where (p => p.Id.Equals (id)) // .ToList () // ; // if (list.Count.Equals (1)) { // action.CollectionAction.ExtensionDocumentCollection.Add (list [0]); // } // } // break; case TComponentExtensionNames.Geometry: { var list = context.ExtensionGeometry.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionGeometryCollection.Add (list [0]); } } break; case TComponentExtensionNames.Image: { var list = context.ExtensionImage.AsQueryable().Where (p => p.Id.Equals (id)).ToList (); if (list.Count.Equals (1)) { action.CollectionAction.ExtensionImageCollection.Add (list [0]); } } break; case TComponentExtensionNames.Layout: { var list = context.ExtensionLayout.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionLayoutCollection.Add (list [0]); } } break; case TComponentExtensionNames.Node: { // child first var childList = context.ExtensionNode.AsQueryable() .Where (p => p.ChildId.Equals (id)) .ToList () ; if (childList.Count.Equals (1)) { action.ModelAction.ExtensionNodeModel.CopyFrom (childList [0]); action.CollectionAction.ExtensionNodeCollection.Add (childList [0]); } else { // parent next var parentList = context.ExtensionNode.AsQueryable() .Where (p => p.ParentId.Equals (id)) .ToList () ; foreach (var model in parentList) { action.CollectionAction.ExtensionNodeCollection.Add (model); } } } break; case TComponentExtensionNames.Text: { var list = context.ExtensionText.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionTextCollection.Add (list [0]); } } break; case TComponentExtensionNames.Content: { var list = context.ExtensionContent.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionContentCollection.Add (list [0]); } } break; } } } } // populate ModelCollection action.CollectionAction.ModelCollection.Clear (); var componentExtension = TComponentExtension.CreateDefault; action.RequestExtension (componentExtension); foreach (var item in action.CollectionAction.ComponentInfoCollection) { // component // Info var id = item.Id; var models = TModelAction.CreateDefault; models.ComponentInfoModel.CopyFrom (item); // Status var statusList = action.CollectionAction.ComponentStatusCollection .Where (p => p.Id.Equals (id)) .ToList () ; // found if (statusList.Count.Equals (1)) { models.ComponentStatusModel.CopyFrom (statusList [0]); } // extension foreach (var extensionName in componentExtension.ExtensionList) { switch (extensionName) { case TComponentExtensionNames.Document: { //var list = action.CollectionAction.ExtensionDocumentCollection // .Where (p => p.Id.Equals (id)) // .ToList () //; //if (list.Count.Equals (1)) { // models.ExtensionDocumentModel.CopyFrom (list [0]); //} } break; case TComponentExtensionNames.Geometry: { var list = action.CollectionAction.ExtensionGeometryCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionGeometryModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Image: { var list = action.CollectionAction.ExtensionImageCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionImageModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Layout: { var list = action.CollectionAction.ExtensionLayoutCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionLayoutModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Node: { // child var list = action.CollectionAction.ExtensionNodeCollection .Where (p => p.ChildId.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionNodeModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Text: { var list = action.CollectionAction.ExtensionTextCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionTextModel.CopyFrom (list [0]); } } break; case TComponentExtensionNames.Content: { var list = action.CollectionAction.ExtensionContentCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { models.ExtensionContentModel.CopyFrom (list [0]); } } break; } } action.CollectionAction.ModelCollection.Add (id, models); } action.Result = TValidationResult.Success; } catch (Exception exception) { Server.Models.Infrastructure.THelper.FormatException ("Select Zap", exception, action); } }
void SelectSummary (TModelContext context, TEntityAction action) { /* DATA IN - action.Summary DATA OUT - action.Summary - action.CollectionAction.ComponentInfoCollection - action.CollectionAction.ComponentStatusCollection */ try { action.CollectionAction.ComponentInfoCollection.Clear (); action.CollectionAction.ComponentStatusCollection.Clear (); var categoryValue = TCategoryType.ToValue (action.SupportAction.SummaryInfo.Category); // search Id by category var descriptors = context.ComponentDescriptor.AsQueryable() .Where (p => p.Category.Equals (categoryValue)) .ToList () ; foreach (var descriptor in descriptors) { // Info var infoList = context.ComponentInfo.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // info found if (infoList.Count.Equals (1)) { var infoModel = infoList [0]; action.CollectionAction.ComponentInfoCollection.Add (infoModel); } // Status var statusList = context.ComponentStatus.AsQueryable() .Where (p => p.Id.Equals (descriptor.Id)) .ToList () ; // status found if (statusList.Count.Equals (1)) { var statusModel = statusList [0]; action.CollectionAction.ComponentStatusCollection.Add (statusModel); } } // apply zap var enabledZap = new Collection<Guid> (); var busyZap = new Collection<Guid> (); // zap Enabled = false (disable) if (action.SupportAction.SummaryInfo.ZapDisable) { foreach (var itemInfo in action.CollectionAction.ComponentInfoCollection) { // only Enabled if (itemInfo.Enabled.IsFalse ()) { enabledZap.Add (itemInfo.Id); } } } // zap Busy = true if (action.SupportAction.SummaryInfo.ZapBusy) { foreach (var itemStatus in action.CollectionAction.ComponentStatusCollection) { // only not busy if (itemStatus.Busy) { busyZap.Add (itemStatus.Id); } } } foreach (var id in enabledZap) { var list = action.CollectionAction.ComponentInfoCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ComponentInfoCollection.Remove (list [0]); } } foreach (var id in busyZap) { var list = action.CollectionAction.ComponentInfoCollection .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ComponentInfoCollection.Remove (list [0]); } } // Extension (CategoryRelationCollection) var categoryRelationList = action.CollectionAction.CategoryRelationCollection .Where (p => p.Category.Equals (categoryValue)) .ToList () ; // found if (categoryRelationList.Count.Equals (1)) { var categoryRelation = categoryRelationList [0]; // get extension using TComponentExtension var extension = TComponentExtension.Create (categoryRelation.Extension); extension.Request (); foreach (var item in action.CollectionAction.ComponentInfoCollection) { var id = item.Id; action.CollectionAction.ExtensionLayoutCollection.Clear (); // check for style only foreach (var extensionName in extension.ExtensionList) { switch (extensionName) { case TComponentExtensionNames.Layout: { var list = context.ExtensionLayout.AsQueryable() .Where (p => p.Id.Equals (id)) .ToList () ; if (list.Count.Equals (1)) { action.CollectionAction.ExtensionLayoutCollection.Add (list [0]); } } break; } } foreach (var layout in action.CollectionAction.ExtensionLayoutCollection) { action.SupportAction.SummaryInfo.Select (layout.StyleHorizontal, layout.StyleVertical); } } } action.Result = TValidationResult.Success; } catch (Exception exception) { Server.Models.Infrastructure.THelper.FormatException ("Select Summary", exception, action); } }
protected TEntityAction (TModelType model, TCollectionType collection, TCategory category, string connectionString, object param1, object param2) : base (TCategoryType.Create (category), connectionString, param1, param2) { ModelAction = model; CollectionAction = collection; }