Example #1
0
        public DynaDoc(Guid docId, Guid userId, IDataContext dataContext)
        {
            var factory = AppServiceProviderFactoryProvider.GetFactory();

            Provider     = factory.Create();
            _ownProvider = true;

            if (dataContext == null)
            {
                DataContext = Provider.Get <IDataContext>(); //new DataContext();
                // _ownDataContext = true;
            }
            else
            {
                DataContext = dataContext;
            }

            UserId = userId;

            _docRepo      = Provider.Get <IDocRepository>();
            _docStateRepo = Provider.Get <IDocStateRepository>();
            _userRepo     = Provider.Get <IUserRepository>();

            Doc = _docRepo.LoadById(docId);
        }
        public BizDetailForm GetDetailFormWithData(Guid formId, Guid docId, int languageId = 0)
        {
            var form = GetDetailForm(formId, languageId);

            var doc = _docRepo.LoadById(docId);

            if (doc != null)
            {
                SetFormDoc(form, doc);
            }

            return(form);
        }
        public XElement GetValueElement(SqlQueryReader reader, SqlQueryField field)
        {
            var name = GetFieldElementName(field);

            if (reader.IsDbNull(field.Index))
            {
                return(new XElement(name, ""));
            }

            if (field.AttrDef != null)
            {
                switch (field.AttrDef.Type.Id)
                {
                case (short)CissaDataType.Enum:
                    if (field.AttrDef.EnumDefType == null)
                    {
                        break;
                    }
                    var enumDef  = _enumRepo.Get(field.AttrDef.EnumDefType.Id);
                    var enumItem = enumDef.EnumItems.FirstOrDefault(i => i.Id == reader.GetGuid(field.Index));
                    if (enumItem != null)
                    {
                        return(new XElement(name, new XElement("Id", enumItem.Id),
                                            new XElement("Value", enumItem.Value)));
                    }
                    break;

                case (short)CissaDataType.Doc:
                    if (PublicDocAttribute(field.AttrDef))
                    {
                        var doc = _docRepo.LoadById(reader.GetGuid(field.Index));
                        return(new XElement(name, GetDocElement(doc)));
                    }
                    break;

/*
 *                          case (short) CissaDataType.DocList:
 *                              if (PublicDocAttribute(field.AttrDef))
 *                              {
 *                                  DocRepo.Ge
 *                                  var docList = new DocList(DataContext);
 *                                  return new XElement(name, GetDocListElement(doc));
 *                              }
 *                              break;
 */
                }
            }
            return(new XElement(name, reader.GetValue(field.Index)));
        }
Example #4
0
        public DynaDoc(Guid docId, Guid userId, IAppServiceProvider provider)
        {
            Provider = provider;
            if (userId == Guid.Empty)
            {
                // var userData = Provider.Get<IUserDataProvider>();
                UserId = provider.GetCurrentUserId();
            }
            else
            {
                UserId = userId;
            }

            _docRepo      = Provider.Get <IDocRepository>();
            _docStateRepo = Provider.Get <IDocStateRepository>();
            _userRepo     = Provider.Get <IUserRepository>();

            Doc = _docRepo.LoadById(docId);
        }
Example #5
0
 public Doc GetDoc(Guid docId)
 {
     return(_docRepo.LoadById(docId));
 }