Exemplo n.º 1
0
        private void InitControlDependency(BizControl control)
        {
            if (control == null)
            {
                return;
            }

            if (control.QueryItems != null)
            {
                foreach (var item in control.QueryItems)
                {
                    foreach (var conditionParam in item.FindParamConditions())
                    {
                        if (conditionParam.ParamName.Length > 0 && conditionParam.ParamName[0] == '@')
                        {
                            var controlRef = conditionParam.ParamName.Substring(1);
                            FindControlAndSetDependent(controlRef, control);
                        }
                    }
                }
            }

            if (control.Children != null)
            {
                foreach (var child in control.Children)
                {
                    InitControlDependency(child);
                }
            }
        }
Exemplo n.º 2
0
        private void AddQueryItems(BizControl control, Control controlData)
        {
            if (control == null)
            {
                return;
            }
            if (_queryRepo == null)
            {
                return;
            }

            // if (control.Children == null) control.Children = new List<BizControl>();

            var en = DataContext.GetEntityDataContext().Entities;

            var children = en.Object_Defs_View
                           .Where(o => o.Parent_Id == controlData.Id && (o.Deleted == null || o.Deleted == false))
                           .OrderBy(o => o.Order_Index).Select(o => o.Id).ToList();

            foreach (var childId in children)
            {
                var childViewId = childId;
                var querySource = _queryRepo.FindJoinDef(childViewId);
                if (querySource != null)
                {
                    if (control.QueryItems == null)
                    {
                        control.QueryItems = new List <QueryItemDefData>();
                    }
                    control.QueryItems.Add(querySource);
                    continue;
                }

                var queryCondition = _queryRepo.FindConditionDef(childViewId);
                if (queryCondition != null)
                {
                    if (control.QueryItems == null)
                    {
                        control.QueryItems = new List <QueryItemDefData>();
                    }
                    control.QueryItems.Add(queryCondition);
                }
            }
        }
Exemplo n.º 3
0
        private void FindControlAndSetDependent(string controlRef, BizControl control)
        {
            var masterControl = FindControlByRef(controlRef);

            if (masterControl != null)
            {
                if (masterControl.Dependents == null)
                {
                    masterControl.Dependents = new List <Guid>();
                }
                masterControl.Dependents.Add(control.Id);

                if (control.Masters == null)
                {
                    control.Masters = new List <Guid>();
                }
                control.Masters.Add(masterControl.Id);
            }
        }
Exemplo n.º 4
0
        private void InitControl(BizControl control, Control controlData)
        {
            control.Id             = controlData.Id;
            control.Caption        = controlData.Full_Name;
            control.DefaultCaption = controlData.Full_Name;
            control.Name           = controlData.Name;
            control.Style          = controlData.Style;
            control.Title          = controlData.Title;
            control.LanguageId     = 0;
            control.Invisible      = controlData.Invisible ?? false;
            if (control is BizDataControl)
            {
                ((BizDataControl)control).ReadOnly = controlData.Read_Only ?? false;
            }
            if (controlData.Sort_Type == null)
            {
                control.SortType = SortType.None;
            }
            else if (controlData.Sort_Type == 0)
            {
                control.SortType = SortType.Ascending;
            }
            else
            {
                control.SortType = SortType.Descending;
            }

            if (controlData.Compare_Operation != null)
            {
                control.Operation = (CompareOperation)controlData.Compare_Operation;
            }
            else
            {
                control.Operation = CompareOperation.Equal;
            }

            //var permissionRepo = new PermissionRepository(DataContext);
            control.Permissions = _permissionRepo.GetObjectDefPermissions(controlData.Id);
        }
Exemplo n.º 5
0
        /*private void InitComboBox(BizComboBox combo, AttrDef attr)
         * {
         *  if (attr == null) return;
         *
         *  //InitComboBoxItems(combo, attr);
         * }*/

        /*private void InitComboBox(BizComboBox combo, SystemIdent ident)
         * {
         *  switch (ident)
         *  {
         *      case SystemIdent.OrgId:
         *      case SystemIdent.OrgCode:
         *      case SystemIdent.OrgName:
         *          combo.Items = GetComboBoxOrganizations(combo.DetailAttributeId);
         *          break;
         *      default:
         *          combo.Items = new List<EnumValue>();
         *          break;
         *  }
         * }*/

        /*public void InitComboBoxItems(BizComboBox combo, AttrDef attr)
         * {
         *  if (attr == null)
         *  {
         *      switch (combo.Ident)
         *      {
         *          case SystemIdent.OrgId:
         *          case SystemIdent.OrgCode:
         *          case SystemIdent.OrgName:
         *              combo.Items = GetComboBoxOrganizations(combo.DetailAttributeId);
         *              break;
         *          case SystemIdent.UserId:
         *          case SystemIdent.UserName:
         *              combo.Items = GetComboBoxUsers();
         *              break;
         *          default:
         *              combo.Items = new List<EnumValue>();
         *              break;
         *      }
         *      return;
         *  }
         *
         *  switch (attr.Type.Id)
         *  {
         *      case (short) CissaDataType.Enum:
         *          if (attr.EnumDefType != null)
         *              combo.Items =
         *                  new List<EnumValue>(
         *                      _enumRepo.GetEnumItems(attr.EnumDefType.Id));
         *          break;
         *      case (short) CissaDataType.Doc:
         *          combo.Items = GetComboBoxDocuments(combo, attr.DocDefType);
         *          break;
         *      case (short) CissaDataType.Organization:
         *          combo.Items = GetComboBoxOrganizations(attr.OrgTypeId);
         *          break;
         *      case (short) CissaDataType.User:
         *          combo.Items = GetComboBoxUsers();
         *          break;
         *  }
         * }*/

        /*public List<EnumValue> GetComboBoxOrganizations(Guid? orgTypeId)
         * {
         *  //var provider = new ComboBoxEnumProvider(DataContext, UserId);
         *  return _comboBoxEnumProv.GetEnumOrganizationValues(orgTypeId);
         * }
         *
         * public List<EnumValue> GetComboBoxUsers()
         * {
         *  //var provider = new ComboBoxEnumProvider(DataContext, UserId);
         *  return _comboBoxEnumProv.GetEnumUserValues();
         * }
         *
         * public List<EnumValue> GetComboBoxDocuments(BizComboBox combo, DocDef detailDocDef)
         * {
         *  //var provider = new ComboBoxEnumProvider(DataContext, UserId);
         *  return _comboBoxEnumProv.GetEnumDocumentValues(combo, detailDocDef);
         * /*
         *  var list = new List<EnumValue>();
         *
         *  if (detailDocDef == null) return list;
         *
         *  var docDef = _docDefRepo.DocDefById(detailDocDef.Id);
         *
         *  AttrDef detailAttrDef;
         *  if (combo.DetailAttributeId != null)
         *      detailAttrDef = docDef.Attributes.FirstOrDefault(ad => ad.Id == combo.DetailAttributeId);
         *  else
         *  {
         *      detailAttrDef =
         *          docDef.Attributes.FirstOrDefault(
         *              ad => String.Compare(ad.Name, combo.DetailAttributeName, StringComparison.OrdinalIgnoreCase) == 0);
         *      if (detailAttrDef == null)
         *          detailAttrDef =
         *              docDef.Attributes.FirstOrDefault(
         *                  ad => ad.Type.Id == (int) CissaDataType.Text);
         *  }
         *
         *  if (detailAttrDef == null) return list;
         *
         *  using (var query = new SqlQuery(DataContext, docDef, UserId))
         *  {
         *      query.AddAttribute("&Id");
         *      query.AddAttribute(detailAttrDef.Id);
         *      query.AddOrderAttribute(detailAttrDef.Id);
         *      using (var reader = new SqlQueryReader(DataContext, query))
         *      {
         *          while (reader.Read())
         *          {
         *              var detail = !reader.IsDbNull(1) ? reader.GetString(1) : String.Empty;
         *
         *              list.Add(new EnumValue
         *              {
         *                  Id = reader.GetGuid(0),
         *                  Value = detail,
         *                  DefaultValue = detail
         *              });
         *          }
         *      }
         *  }
         *
         *  return list;
         #1#
         * }*/

        /*[Obsolete("Устаревший метод")]
         * private void InitComboBox(BizComboBox control, Attribute_Def def)
         * {
         *  if (def == null) return;
         *
         *  control.AttributeDefId = def.Id;
         *
         *  if (def.Type_Id == (short)CissaDataType.Enum && def.Enum_Id != null)
         *  {
         *      control.Items =
         *          new List<EnumValue>(
         *              _enumRepo.GetEnumItems((Guid) def.Enum_Id));
         *  }
         *  else if (def.Type_Id == (short)CissaDataType.Doc)
         *  {
         *      var en = DataContext.Entities;
         *
         *      var docDef = _docDefRepo.DocDefById(def.Document_Id ?? Guid.Empty);
         *      //GetDocumentAttributes(def.Document_Id ?? Guid.Empty, Guid.Empty);
         *
         *      AttrDef detailAttrDef;
         *      if (control.DetailAttributeId != null)
         *          detailAttrDef = docDef.Attributes.FirstOrDefault(ad => ad.Id == control.DetailAttributeId);
         *      else
         *      {
         *          detailAttrDef =
         *              docDef.Attributes.FirstOrDefault(
         *                  ad => String.Compare(ad.Name, control.DetailAttributeName, StringComparison.OrdinalIgnoreCase) == 0);
         *      }
         *
         *      if (detailAttrDef == null) return;
         *
         *      var list = new List<EnumValue>();
         *
         *      // DONE: Изменить доступ к документам в ComboBox
         *      foreach (var doc in en.Documents
         *          .Where(d => d.Def_Id == def.Document_Id && (d.Deleted == null || d.Deleted == false)))
         *      {
         *          var document = _docRepo.LoadById(doc.Id);
         *          var attr = _attrRepo.GetAttributeById(detailAttrDef.Id, document);
         *
         *          list.Add(new EnumValue
         *                       {
         *                           Id = doc.Id,
         *                           Value = (attr != null ? (string) attr.ObjectValue : ""),
         *                           DefaultValue = (attr != null ? (string) attr.ObjectValue : "")
         *                       });
         *      }
         *      control.Items = list;
         *  }
         * }*/

        private void AddChildren(BizControl control, Control controlData, DocDef def)
        {
            if (control == null)
            {
                return;
            }

            if (control.Children == null)
            {
                control.Children = new List <BizControl>();
            }

//            if (!controlData.Children.IsLoaded) controlData.Children.Load();

            var en = DataContext.GetEntityDataContext().Entities;

            /*            var children = en.CreateQuery<Guid>(
             *                  "SELECT od FROM Object_Defs AS od WHERE od.Parent_Id = @PID AND (od.Deleted IS NULL OR od.Deleted = False) " +
             *                  "ORDER BY od.Order_Index", new ObjectParameter("PID", controlData.Id));*/
            //            children.MergeOption = MergeOption.NoTracking;

            /*.Where(c => c.Parent_Id == controlData.Id && (c.Deleted == null || c.Deleted == false))
             *  .OrderBy(c => c.Order_Index).Select(od => od.Id));*/

            var children = en.Object_Defs_View
                           .Where(o => o.Parent_Id == controlData.Id && (o.Deleted == null || o.Deleted == false))
                           .OrderBy(o => o.Order_Index).Select(o => o.Id).ToList();

            foreach (var childId in children)
            {
                //Object_Defs_View childView = child;
                var childViewId = childId;

                var editor = en.Object_Defs.OfType <Editor>().FirstOrDefault(c => c.Id == childViewId);
                if (editor != null)
                {
                    var sub = CreateEditor(editor, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var button = en.Object_Defs.OfType <Button>().FirstOrDefault(c => c.Id == childViewId);
                if (button != null)
                {
                    var sub = CreateButton(button, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var combo = en.Object_Defs.OfType <Combo_Box>().FirstOrDefault(c => c.Id == childViewId);
                if (combo != null)
                {
                    var sub = CreateComboBox(combo, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var text = en.Object_Defs.OfType <Text>().FirstOrDefault(c => c.Id == childViewId);
                if (text != null)
                {
                    var sub = CreateText(text, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var panel = en.Object_Defs.OfType <Panel>().FirstOrDefault(c => c.Id == childViewId);
                if (panel != null)
                {
                    var sub = CreatePanel(panel, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var docControl = en.Object_Defs.OfType <DocumentControl>().FirstOrDefault(c => c.Id == childViewId);
                if (docControl != null)
                {
                    var sub = CreateDocumentControl(docControl, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var docList = en.Object_Defs.OfType <DocumentList_Form>().FirstOrDefault(c => c.Id == childViewId);
                if (docList != null)
                {
                    var sub = CreateDocumentListForm(docList, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var grid = en.Object_Defs.OfType <Grid>().FirstOrDefault(c => c.Id == childViewId);
                if (grid != null)
                {
                    var sub = CreateGrid(grid, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var menu = en.Object_Defs.OfType <Menu>().FirstOrDefault(c => c.Id == childViewId);
                if (menu != null)
                {
                    var sub = CreateMenu(menu);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var column = en.Object_Defs.OfType <Table_Column>().FirstOrDefault(c => c.Id == childViewId);
                if (column != null)
                {
                    var sub = CreateTableColumn(column, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var dynamic = en.Object_Defs.OfType <DynamicDocumentList>().FirstOrDefault(c => c.Id == childViewId);
                if (dynamic != null)
                {
                    var sub = CreateDynamicDocumentListForm(dynamic, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var tabControl = en.Object_Defs.OfType <Tab_Control>().FirstOrDefault(c => c.Id == childViewId);
                if (tabControl != null)
                {
                    var sub = CreateTabControl(tabControl, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                var image = en.Object_Defs.OfType <Image>().FirstOrDefault(c => c.Id == childViewId);
                if (image != null)
                {
                    var sub = CreateImage(image, def);
                    if (sub != null)
                    {
                        control.Children.Add(sub);
                    }
                    continue;
                }

                if (_queryRepo != null)
                {
                    var querySource = _queryRepo.FindJoinDef(childViewId);
                    if (querySource != null)
                    {
                        if (control.QueryItems == null)
                        {
                            control.QueryItems = new List <QueryItemDefData>();
                        }
                        control.QueryItems.Add(querySource);
                        continue;
                    }

                    var queryCondition = _queryRepo.FindConditionDef(childViewId);
                    if (queryCondition != null)
                    {
                        if (control.QueryItems == null)
                        {
                            control.QueryItems = new List <QueryItemDefData>();
                        }
                        control.QueryItems.Add(queryCondition);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private DocDef FindControlAttributeDocDef(BizControl control, DocDef parentDocDef, Guid attrId)
        {
            var docControl = control as BizDocumentControl;

            if (docControl != null)
            {
                if (docControl.AttributeDefId != null)
                {
                    var docControlAttrDef = parentDocDef.Attributes.FirstOrDefault(a => a.Id == (Guid)docControl.AttributeDefId);
                    if (docControlAttrDef != null && docControlAttrDef.DocDefType != null)
                    {
                        var docDef = _docDefRepo.Find(docControlAttrDef.DocDefType.Id);
                        if (docDef != null)
                        {
                            if (docDef.Attributes.FirstOrDefault(a => a.Id == attrId) != null)
                            {
                                return(docDef);
                            }

                            if (docControl.Children != null)
                            {
                                foreach (var child in control.Children)
                                {
                                    var attrDocDef = FindControlAttributeDocDef(child, docDef, attrId);
                                    if (attrDocDef != null)
                                    {
                                        return(attrDocDef);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                var docList = control as BizDocumentListForm;
                if (docList != null)
                {
                    if (docList.AttributeDefId != null)
                    {
                        var docListAttrDef = parentDocDef.Attributes.FirstOrDefault(a => a.Id == (Guid)docList.AttributeDefId);
                        if (docListAttrDef != null && docListAttrDef.DocDefType != null)
                        {
                            var docDef = _docDefRepo.Find(docListAttrDef.DocDefType.Id);
                            if (docDef != null)
                            {
                                if (docDef.Attributes.FirstOrDefault(a => a.Id == attrId) != null)
                                {
                                    return(docDef);
                                }

                                if (docList.Children != null)
                                {
                                    foreach (var child in control.Children)
                                    {
                                        var attrDocDef = FindControlAttributeDocDef(child, docDef, attrId);
                                        if (attrDocDef != null)
                                        {
                                            return(attrDocDef);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        var dlForm = docList.TableForm ??
                                     (docList.FormId != null ? _formRepo.FindTableForm((Guid)docList.FormId) : null);

                        if (dlForm != null && dlForm.DocumentDefId != null)
                        {
                            var docDef = _docDefRepo.Find((Guid)dlForm.DocumentDefId);
                            if (docDef != null)
                            {
                                if (docDef.Attributes.FirstOrDefault(a => a.Id == attrId) != null)
                                {
                                    return(docDef);
                                }

                                if (dlForm.Children != null)
                                {
                                    foreach (var child in dlForm.Children)
                                    {
                                        var attrDocDef = FindControlAttributeDocDef(child, docDef, attrId);
                                        if (attrDocDef != null)
                                        {
                                            return(attrDocDef);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    var tableColumn = control as BizTableColumn;
                    if (tableColumn != null && tableColumn.AttributeDefId != null)
                    {
                        var tableColumnAttrDef = parentDocDef.Attributes.FirstOrDefault(a => a.Id == (Guid)tableColumn.AttributeDefId);
                        if (tableColumnAttrDef != null && tableColumnAttrDef.DocDefType != null)
                        {
                            var docDef = _docDefRepo.Find(tableColumnAttrDef.DocDefType.Id);
                            if (docDef != null)
                            {
                                if (docDef.Attributes.FirstOrDefault(a => a.Id == attrId) != null)
                                {
                                    return(docDef);
                                }

                                if (tableColumn.Children != null)
                                {
                                    foreach (var child in tableColumn.Children)
                                    {
                                        var attrDocDef = FindControlAttributeDocDef(child, docDef, attrId);
                                        if (attrDocDef != null)
                                        {
                                            return(attrDocDef);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 7
0
 public ControlFinder(BizControl control)
 {
     Control = control;
 }