ManagerUser IManagerUserManager.ReadManagerUser(
            IManagerUserStorage pStorage,
            int pUserID)
        {
            ManagerUser response = null;

            try
            {
                #region Verify argument

                Verify.ArgumentNotNull(pStorage, "pStorage");
                Verify.ArgumentNotSpecified(
                    pUserID <= 0,
                    "pUserID");
                #endregion

                response =
                    pStorage.ReadManagerUser(pUserID);
            }
            catch (Exception ex)
            {
                ExceptionHandler.DealWithException(ex);
            }

            return(response);
        }
        private string GetDefaultValueText(DefaultValue defaultValue)
        {
            Verify.ArgumentNotNull(defaultValue, "defaultValue");

            switch (defaultValue.ValueType)
            {
            case DefaultValueType.DateTimeNow:
                return("getdate()");

            case DefaultValueType.String:
            case DefaultValueType.Guid:
                return("N" + SqlQuoted(defaultValue.Value));

            case DefaultValueType.NewGuid:
                return("newid()");

            case DefaultValueType.Integer:
                return(defaultValue.Value.ToString());

            case DefaultValueType.Boolean:
                return((bool)defaultValue.Value ? "1" : "0");

            case DefaultValueType.DateTime:
                return(SqlQuoted(((DateTime)defaultValue.Value).ToString("yyyy-MM-dd HH:mm:ss")));

            case DefaultValueType.Decimal:
                return(((decimal)defaultValue.Value).ToString("F", CultureInfo.InvariantCulture));
            }

            throw new NotImplementedException("Supplied DefaultValue contains an unsupported DefaultValueType '{0}'."
                                              .FormatWith(defaultValue.ValueType));
        }
Пример #3
0
        /// <exclude />
        public static IPage MoveTo(this IPage page, Guid parentId, int localOrder, bool addNewPage)
        {
            Verify.ArgumentNotNull(page, nameof(page));

            lock (_lock)
            {
                IPageStructure pageStructure = DataFacade.GetData <IPageStructure>(f => f.Id == page.Id).FirstOrDefault();

                if (pageStructure != null)
                {
                    if (pageStructure.ParentId == parentId)
                    {
                        if (localOrder == pageStructure.LocalOrdering)
                        {
                            // If page is already has the right order - don't do anything
                            return(page);
                        }
                        if (localOrder > pageStructure.LocalOrdering)
                        {
                            localOrder--;
                        }
                    }
                    DataFacade.Delete(pageStructure);

                    if (pageStructure.ParentId != parentId)
                    {
                        FixOrder(pageStructure.ParentId);
                    }
                }

                return(InsertIntoPosition(page, parentId, localOrder, addNewPage));
            }
        }
Пример #4
0
        /// <exclude />
        public static Control Render(this IPage page, IEnumerable <IPagePlaceholderContent> placeholderContents, FunctionContextContainer functionContextContainer)
        {
            Verify.ArgumentNotNull(page, "page");
            Verify.ArgumentNotNull(functionContextContainer, "functionContextContainer");
            Verify.ArgumentCondition(functionContextContainer.XEmbedableMapper is XEmbeddedControlMapper,
                                     "functionContextContainer", $"Unknown or missing XEmbedable mapper on context container. Use {nameof(GetPageRenderFunctionContextContainer)}().");

            CurrentPage = page;

            using (GlobalInitializerFacade.CoreIsInitializedScope)
            {
                string url = PageUrls.BuildUrl(page);

                using (TimerProfilerFacade.CreateTimerProfiler(url ?? "(no url)"))
                {
                    var cultureInfo = page.DataSourceId.LocaleScope;
                    System.Threading.Thread.CurrentThread.CurrentCulture   = cultureInfo;
                    System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;

                    XEmbeddedControlMapper mapper = (XEmbeddedControlMapper)functionContextContainer.XEmbedableMapper;

                    XDocument document = TemplateInfo.GetTemplateDocument(page.TemplateId);

                    ResolvePlaceholders(document, placeholderContents);

                    Control c = Render(document, functionContextContainer, mapper, page);

                    return(c);
                }
            }
        }
        private string GetDefaultValueText(StoreFieldType storeFieldType)
        {
            Verify.ArgumentNotNull(storeFieldType, "storeFieldType");

            switch (storeFieldType.PhysicalStoreType)
            {
            case PhysicalStoreFieldType.String:
            case PhysicalStoreFieldType.LargeString:
                return("N''");

            case PhysicalStoreFieldType.Guid:
                return("'00000000-0000-0000-0000-000000000000'");

            case PhysicalStoreFieldType.Integer:
            case PhysicalStoreFieldType.Long:
            case PhysicalStoreFieldType.Decimal:
                return("0");

            case PhysicalStoreFieldType.Boolean:
                return("0");

            case PhysicalStoreFieldType.DateTime:
                return("getdate()");
            }

            throw new NotImplementedException("Supplied StoreFieldType contains an unsupported PhysicalStoreType '{0}'."
                                              .FormatWith(storeFieldType.PhysicalStoreType));
        }
Пример #6
0
        /// <exclude />
        public static IEnumerable <IData> GetMetaData(string definitionName, Type metaDataType)
        {
            Verify.ArgumentNotNull(definitionName, nameof(definitionName));
            Verify.ArgumentNotNull(metaDataType, nameof(metaDataType));

            var parameterExpression = Expression.Parameter(metaDataType);

            var lambdaExpression = Expression.Lambda(
                Expression.Equal(
                    Expression.Property(
                        parameterExpression,
                        PageMetaDataFacade.GetDefinitionNamePropertyInfo(metaDataType)
                        ),
                    Expression.Constant(
                        definitionName,
                        typeof(string)
                        )
                    ),
                parameterExpression
                );

            var whereExpression = ExpressionCreator.Where(DataFacade.GetData(metaDataType).Expression, lambdaExpression);

            IEnumerable <IData> datas = ExpressionHelper.GetCastedObjects <IData>(metaDataType, whereExpression);

            return(datas);
        }
Пример #7
0
        public override bool TryConvert(object value, Type targetType, out object targetValue)
        {
            Verify.ArgumentNotNull(value, "value");

            if (targetType == typeof(XhtmlDocument) && value is XElement)
            {
                XElement valueCasted = (XElement)value;
                targetValue = new XhtmlDocument(valueCasted);
                return(true);
            }

            if (targetType == typeof(XElement) && value is XhtmlDocument)
            {
                XhtmlDocument valueCasted = (XhtmlDocument)value;
                targetValue = valueCasted.Root;
                return(true);
            }

            if (targetType == typeof(XNode) && value is XhtmlDocument)
            {
                XhtmlDocument valueCasted = (XhtmlDocument)value;
                targetValue = valueCasted.Root;
                return(true);
            }

            targetValue = null;
            return(false);
        }
Пример #8
0
        public static UrlString BuildUrl(PageUrlOptions options)
        {
            Verify.ArgumentNotNull(options, "options");
            Verify.ArgumentCondition(options.UrlType != UrlType.Undefined, "options", "Url type is undefined");

            return(BuildUrl(options.UrlType, options));
        }
        public MasterPagePageTemplateDescriptor(string filePath, string codeBehindFilePath)
        {
            Verify.ArgumentNotNull(filePath, "filePath");

            _filePath           = filePath;
            _codeBehindFilePath = codeBehindFilePath;
        }
Пример #10
0
        Vaccine IVaccineManager.ReadVaccine(
            IVaccineStorage pStorage,
            int pVaccineID)
        {
            Vaccine response = null;

            try
            {
                #region Verify argument

                Verify.ArgumentNotNull(pStorage, "pStorage");
                Verify.ArgumentNotSpecified(
                    pVaccineID <= 0,
                    "pVaccineID");
                #endregion

                response =
                    pStorage.ReadVaccine(pVaccineID);
            }
            catch (Exception ex)
            {
                ExceptionHandler.DealWithException(ex);
            }

            return(response);
        }
Пример #11
0
        internal static void AddSubMeasurement(Measurement measurement)
        {
            Verify.ArgumentNotNull(measurement, "measurement");

            Measurement         currentNode;
            Stack <Measurement> stack;
            bool isInParallel;

            if (!GetCurrentNode(out currentNode, out stack, out isInParallel))
            {
                return;
            }

            if (isInParallel)
            {
                lock (currentNode.SyncRoot)
                {
                    currentNode.ParallelNodes.Add(measurement);
                }
            }
            else
            {
                currentNode.Nodes.Add(measurement);
            }
        }
Пример #12
0
        IList <Vaccine> IVaccineManager.GetVaccineList(
            IVaccineStorage pStorage,
            QueryVaccine pQueryVaccine)
        {
            IList <Vaccine> response = null;

            try
            {
                #region Verify argument

                Verify.ArgumentNotNull(pStorage, "pStorage");
                Verify.ArgumentNotNull(pQueryVaccine, "pQueryVaccine");

                #endregion

                response =
                    pStorage.ListVaccine(pQueryVaccine);
            }
            catch (Exception ex)
            {
                ExceptionHandler.DealWithException(ex);
            }

            return(response);
        }
Пример #13
0
        /// <summary>
        /// This method will return the data type descriptor for the given data type id.
        /// If the data type descriptor has not yet been created (file not existing) and
        /// the <paramref name="allowTypeMetaDataCreation"/> is set to true,
        /// this method will try getting it through the <see cref="Composite.Data.DynamicTypes.Foundation.ReflectionBasedDescriptorBuilder"/>
        /// based on <paramref name="interfaceType"/>.
        /// </summary>
        /// <param name="interfaceType">The data type.</param>
        /// <param name="allowTypeMetaDataCreation">
        /// If this is true and the data type descriptor does not exists, it will be created.
        /// </param>
        /// <returns></returns>
        public static DataTypeDescriptor GetDataTypeDescriptor(Type interfaceType, bool allowTypeMetaDataCreation = false)
        {
            Verify.ArgumentNotNull(interfaceType, nameof(interfaceType));

            Initialize();

            DataTypeDescriptor dataTypeDescriptor;

            Guid dataTypeId = interfaceType.GetImmutableTypeId();

            _dataTypeDescriptorCache.TryGetValue(dataTypeId, out dataTypeDescriptor);

            if (dataTypeDescriptor != null)
            {
                return(dataTypeDescriptor);
            }

            if (!allowTypeMetaDataCreation)
            {
                return(null);
            }

            var newDataTypeDescriptor = ReflectionBasedDescriptorBuilder.Build(interfaceType);

            PersistMetaData(newDataTypeDescriptor);

            return(newDataTypeDescriptor);
        }
        /// <exclude />
        public RelationshipGraph(EntityToken sourceEntityToken, RelationshipGraphSearchOption searchOption, bool lazyEvaluation, bool excludeReoccuringNodes)
        {
            _excludeReoccuringNodes = excludeReoccuringNodes;

            Verify.ArgumentNotNull(sourceEntityToken, "sourceEntityToken");

            _searchOption = searchOption;

            RelationshipGraphNode node = new RelationshipGraphNode(sourceEntityToken, 0, RelationshipGraphNodeType.Entity);

            _levels.Add(0, new List <RelationshipGraphNode> {
                node
            });

            string userName = UserValidationFacade.IsLoggedIn() ? UserSettings.Username : null;

            ExpandNextLevel(userName);

            if (lazyEvaluation == false)
            {
                while (_moreLevelsToExpend)
                {
                    ExpandNextLevel(userName);
                }
            }
        }
        /// <exclude />
        public static bool HasFolderData(this IPage page, Type pageFolderType)
        {
            Verify.ArgumentNotNull(page, "page");

            //TODO: Consider caching here
            ParameterExpression parameterExpression = Expression.Parameter(pageFolderType);

            LambdaExpression lambdaExpression = Expression.Lambda(
                Expression.Equal(
                    Expression.Property(
                        parameterExpression,
                        PageMetaDataFacade.GetDefinitionPageReferencePropertyInfo(pageFolderType)
                        ),
                    Expression.Constant(
                        page.Id,
                        typeof(Guid)
                        )
                    ),
                parameterExpression
                );

            Expression whereExpression = ExpressionCreator.Where(DataFacade.GetData(pageFolderType).Expression, lambdaExpression);

            //TODO: Possible optimization here
            return(DataFacade.GetData(pageFolderType).Provider.CreateQuery(whereExpression).ToEnumerableOfObjects().Any());
        }
Пример #16
0
        /// <summary>
        /// Returns the value of the XElement attribute with the specified name.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="attributeXName">XName of the attribute.</param>
        /// <returns>
        /// The value of the attribute or null if the attribute does not exist.
        /// </returns>
        public static string GetAttributeValue(this XElement element, XName attributeXName)
        {
            Verify.ArgumentNotNull(element, "element");
            Verify.ArgumentNotNull(attributeXName, "attributeXName");

            return((string)element.Attribute(attributeXName));
        }
        /// <summary>
        /// Returns (if any) folder types that are defined on the given page
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public static IEnumerable <Type> GetDefinedFolderTypes(this IPage page)
        {
            Verify.ArgumentNotNull(page, nameof(page));

            var folderDefinitions = DataFacade.GetData <IPageFolderDefinition>();

            IEnumerable <Guid> typeIds;

            if (folderDefinitions.IsEnumerableQuery())
            {
                typeIds = folderDefinitions
                          .Evaluate()
                          .Where(f => f.PageId == page.Id)
                          .Select(f => f.FolderTypeId);
            }
            else
            {
                typeIds = folderDefinitions
                          .Where(f => f.PageId == page.Id)
                          .Select(f => f.FolderTypeId)
                          .Evaluate();
            }

            foreach (Guid typeId in typeIds)
            {
                var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(typeId);
                Verify.IsNotNull(dataTypeDescriptor, "Missing a page data folder type with id '{0}', referenced by a IPageFolderDefinition record", typeId);

                yield return(TypeManager.GetType(dataTypeDescriptor.TypeManagerTypeName));
            }
        }
Пример #18
0
        public IQueryable <S> CreateQuery <S>(Expression expression)
        {
            Verify.ArgumentNotNull(expression, "expression");
            Verify.ArgumentCondition(typeof(IQueryable <S>).IsAssignableFrom(expression.Type), "expression", "Incorrect expression type");

            return(new DataFacadeQueryable <S>(_sources, expression));
        }
        IList <ManagerUser> IManagerUserManager.GetManagerUserList(
            IManagerUserStorage pStorage,
            QueryManagerUser pQueryManagerUser)
        {
            IList <ManagerUser> response = null;

            try
            {
                #region Verify argument

                Verify.ArgumentNotNull(pStorage, "pStorage");
                Verify.ArgumentNotNull(pQueryManagerUser, "pQueryManagerUser");

                #endregion

                response =
                    pStorage.ListManagerUser(pQueryManagerUser);
            }
            catch (Exception ex)
            {
                ExceptionHandler.DealWithException(ex);
            }

            return(response);
        }
Пример #20
0
        InjectionMessage IInjectionMessageManager.CreateInjectionMessage(
            IInjectionMessageStorage pStorage,
            InjectionMessage pInjectionMessage)
        {
            InjectionMessage response = null;

            try
            {
                #region Verify argument

                Verify.ArgumentNotNull(pInjectionMessage, "pInjectionMessage");

                Verify.ArgumentNotNull(
                    pInjectionMessage.InjectorID,
                    "pInjectionMessage.InjectorID");

                Verify.ArgumentNotNull(
                    pInjectionMessage.VaccineID,
                    "pInjectionMessage.VaccineID");

                Verify.ArgumentNotNull(
                    pInjectionMessage.InjectionMessageSite,
                    "pInjectionMessage.InjectionMessageSite");


                Verify.ArgumentNotNull(
                    pInjectionMessage.InjectionMessageDoctor,
                    "pInjectionMessage.InjectionMessageDoctor");



                Verify.ArgumentNotSpecified(
                    (pInjectionMessage.InjectorID <= 0),
                    "pInjectionMessage.InjectorID");

                Verify.ArgumentNotSpecified(
                    (pInjectionMessage.VaccineID <= 0),
                    "pInjectionMessage.VaccineID");

                Verify.ArgumentNotSpecified(
                    (pInjectionMessage.InjectionMessageSite.Length == 0),
                    "pInjectionMessage.InjectionMessageSite");


                Verify.ArgumentNotSpecified(
                    (pInjectionMessage.InjectionMessageDoctor.Length == 0),
                    "pInjectionMessage.InjectionMessageDoctor");

                #endregion

                response = pStorage.CreateInjectionMessage(pInjectionMessage);
            }
            catch (Exception ex)
            {
                ExceptionHandler.DealWithException(ex);
            }

            return(response);
        }
Пример #21
0
        private SqlDataTypeStore TryGetsqlDataTypeStore(Type interfaceType)
        {
            Verify.ArgumentNotNull(interfaceType, "interfaceType");

            SqlDataTypeStore result;

            return(_sqlDataTypeStores.TryGetValue(interfaceType, out result) ? result : null);
        }
Пример #22
0
        /// <exclude />
        public AddNewTreeRefresher(EntityToken parentEntityToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            Verify.ArgumentNotNull(parentEntityToken, "parentEntityToken");
            Verify.ArgumentNotNull(flowControllerServicesContainer, "flowControllerServicesContainer");

            _beforeGraph = new RelationshipGraph(parentEntityToken, RelationshipGraphSearchOption.Both, false, false);
            _flowControllerServicesContainer = flowControllerServicesContainer;
        }
Пример #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PageUrlData"/> class.
        /// </summary>
        /// <param name="page">The page.</param>
        public PageUrlData(IPage page)
        {
            Verify.ArgumentNotNull(page, "page");

            PageId = page.Id;
            this.PublicationScope  = page.DataSourceId.PublicationScope;
            this.LocalizationScope = page.DataSourceId.LocaleScope;
        }
Пример #24
0
        /// <exclude />
        public static bool IsNotReferenceable(this Type interfaceType)
        {
            Verify.ArgumentNotNull(interfaceType, "interfaceType");

            var map = _resourceLocker.Resources.InterfaceToNotReferenceableCache;

            return(map.GetOrAdd(interfaceType, type => type.GetCustomInterfaceAttributes <NotReferenceableAttribute>().Any()));
        }
Пример #25
0
        /// <exclude />
        public DeleteTreeRefresher(EntityToken beforeDeleteEntityToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            Verify.ArgumentNotNull(beforeDeleteEntityToken, "beforeDeleteEntityToken");
            Verify.ArgumentNotNull(flowControllerServicesContainer, "flowControllerServicesContainer");

            _beforeGraph = new RelationshipGraph(beforeDeleteEntityToken, RelationshipGraphSearchOption.Both);
            _flowControllerServicesContainer = flowControllerServicesContainer;
        }
        internal static bool CascadeDeleteAllowed(this IData data, Type referencedType)
        {
            Verify.ArgumentNotNull(data, "data");
            Verify.ArgumentNotNull(referencedType, "referencedType");

            return(GetForeignKeyProperties(data.DataSourceId.InterfaceType, referencedType)
                   .All(_ => _.AllowCascadeDeletes));
        }
Пример #27
0
        /// <exclude />
        public static IQueryable <IPage> GetChildren(this IPage page)
        {
            Verify.ArgumentNotNull(page, nameof(page));
            Verify.ArgumentCondition(page.DataSourceId.ExistsInStore, nameof(page),
                                     "The given data have not been added yet");

            return(GetChildren(page.Id));
        }
Пример #28
0
        /// <exclude />
        public static Guid GetParentId(this IPage page)
        {
            Verify.ArgumentNotNull(page, nameof(page));
            Verify.ArgumentCondition(page.DataSourceId.ExistsInStore, nameof(page),
                                     "The given data have not been added yet");

            return(PageManager.GetParentId(page.Id));
        }
Пример #29
0
        public static IEnumerable <PermissionType> DeserializePermissionTypes(this string serializedPermissionTypes)
        {
            Verify.ArgumentNotNull(serializedPermissionTypes, "serializedPermissionTypes");

            var split = serializedPermissionTypes.Split(new[] { '�' }, StringSplitOptions.RemoveEmptyEntries);

            return(split.Select(s => (PermissionType)Enum.Parse(typeof(PermissionType), s)));
        }
        internal SqlDataProviderStoreManipulator(string connectionString, IEnumerable <InterfaceConfigurationElement> generatedInterfaces)
        {
            Verify.ArgumentNotNullOrEmpty(connectionString, "connectionString");
            Verify.ArgumentNotNull(generatedInterfaces, "generatedInterfaces");

            _connectionString    = connectionString;
            _generatedInterfaces = generatedInterfaces;
        }