Пример #1
0
    /// <summary>
    /// Executes the SetTragetLayout client action using parameters passed in hidden fields.
    /// </summary>
    private void SetTargetLayout()
    {
        int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0);
        int targetLayoutId = ValidationHelper.GetInteger(TargetLayoutIdentifierHiddenField.Value, 0);

        using (var scope = new CMSTransactionScope())
        {
            LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
            if (sourceLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout"));
            }
            LayoutInfo targetLayout = LayoutInfoProvider.GetLayoutInfo(targetLayoutId);
            if (targetLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.notargetlayout"));
            }

            InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts()
                                                                      .Where("DeviceProfileID", QueryOperator.Equals, DeviceProfile.ProfileID)
                                                                      .Where("SourceLayoutID", QueryOperator.Equals, sourceLayout.LayoutId)
                                                                      .TypedResult
                                                                      .Items;

            DeviceProfileLayoutInfo binding = null;
            if (bindings.Count > 0)
            {
                binding = bindings[0];
            }
            else
            {
                binding = new DeviceProfileLayoutInfo
                {
                    DeviceProfileID = DeviceProfile.ProfileID,
                    SourceLayoutID  = sourceLayout.LayoutId
                };
            }
            binding.TargetLayoutID = targetLayout.LayoutId;
            DeviceProfileLayoutInfoProvider.SetDeviceProfileLayoutInfo(binding);
            scope.Commit();
        }
    }
Пример #2
0
    /// <summary>
    /// Executes the SetTragetLayout client action using parameters passed in hidden fields.
    /// </summary>
    private void SetTargetLayout()
    {
        int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0);
        int targetLayoutId = ValidationHelper.GetInteger(TargetLayoutIdentifierHiddenField.Value, 0);

        using (CMSTransactionScope scope = new CMSTransactionScope())
        {
            LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
            if (sourceLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout"));
            }
            LayoutInfo targetLayout = LayoutInfoProvider.GetLayoutInfo(targetLayoutId);
            if (targetLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.notargetlayout"));
            }
            string condition = String.Format("DeviceProfileID = {0:D} AND SourceLayoutID = {1:D}", DeviceProfile.ProfileID, sourceLayout.LayoutId);
            InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts(condition, null).Items;
            DeviceProfileLayoutInfo binding = null;
            if (bindings.Count > 0)
            {
                binding = bindings[0];
            }
            else
            {
                binding = new DeviceProfileLayoutInfo
                {
                    DeviceProfileID = DeviceProfile.ProfileID,
                    SourceLayoutID  = sourceLayout.LayoutId
                };
            }
            binding.TargetLayoutID = targetLayout.LayoutId;
            DeviceProfileLayoutInfoProvider.SetDeviceProfileLayoutInfo(binding);
            scope.Commit();
        }
    }