public void DeleteExtendedAttributes(ExtendedAttributes theExtendedAttributes)
        {
            try { m_ExtendedAttributesDictionary.Remove(theExtendedAttributes.ExtendedAttributes_ID); }
            catch { }

            IEditor theEditor = ArcMap.Editor;

            if (theEditor.EditState == esriEditState.esriStateNotEditing)
            {
                theEditor.StartEditing(m_theWorkspace);
            }
            theEditor.StartOperation();

            try
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = "ExtendedAttributes_ID = '" + theExtendedAttributes.ExtendedAttributes_ID + "'";

                m_ExtendedAttributesTable.DeleteSearchedRows(QF);

                theEditor.StopOperation("Delete ExtendedAttributes");
            }
            catch (Exception e) {
                string ex = e.Message;
                theEditor.StopOperation("ExtendedAttributes Management Failure");
            }
        }
Beispiel #2
0
        // Some fields that have a reserved spot in the header, may not fit in such field anymore, but they can fit in the
        // extended attributes. They get collected and saved in that dictionary, with no restrictions.
        private void CollectExtendedAttributesFromStandardFieldsIfNeeded()
        {
            ExtendedAttributes.Add(PaxEaName, _name);

            if (!ExtendedAttributes.ContainsKey(PaxEaMTime))
            {
                ExtendedAttributes.Add(PaxEaMTime, TarHelpers.GetTimestampStringFromDateTimeOffset(_mTime));
            }
            if (!string.IsNullOrEmpty(_gName))
            {
                TryAddStringField(ExtendedAttributes, PaxEaGName, _gName, FieldLengths.GName);
            }
            if (!string.IsNullOrEmpty(_uName))
            {
                TryAddStringField(ExtendedAttributes, PaxEaUName, _uName, FieldLengths.UName);
            }

            if (!string.IsNullOrEmpty(_linkName))
            {
                ExtendedAttributes.Add(PaxEaLinkName, _linkName);
            }

            if (_size > 99_999_999)
            {
                ExtendedAttributes.Add(PaxEaSize, _size.ToString());
            }
Beispiel #3
0
        public static IAttributes GetDefaultAttributes(List <TableStyleInfo> styleInfoList)
        {
            var attributes = new ExtendedAttributes();

            foreach (var styleInfo in styleInfoList)
            {
                var defaultValue = string.Empty;
                if (!string.IsNullOrEmpty(styleInfo.DefaultValue))
                {
                    defaultValue = styleInfo.DefaultValue;
                }
                else if (styleInfo.StyleItems != null)
                {
                    var defaultValues = new List <string>();
                    foreach (var styleItem in styleInfo.StyleItems)
                    {
                        if (styleItem.IsSelected)
                        {
                            defaultValues.Add(styleItem.ItemValue);
                        }
                    }
                    if (defaultValues.Count > 0)
                    {
                        defaultValue = TranslateUtils.ObjectCollectionToString(defaultValues);
                    }
                }

                if (!string.IsNullOrEmpty(defaultValue))
                {
                    attributes.Set(styleInfo.AttributeName, defaultValue);
                }
            }

            return(attributes);
        }
Beispiel #4
0
        public static void AddValuesToAttributes(ETableStyle tableStyle, string tableName, PublishmentSystemInfo publishmentSystemInfo, List <int> relatedIdentities, Control containerControl, NameValueCollection attributes)
        {
            var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities);

            foreach (var styleInfo in styleInfoList)
            {
                if (styleInfo.IsVisible == false)
                {
                    continue;
                }
                var theValue = GetValueByControl(styleInfo, publishmentSystemInfo, containerControl);

                if (!EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.TextEditor, EInputType.Image, EInputType.File, EInputType.Video) && styleInfo.AttributeName != BackgroundContentAttribute.LinkUrl)
                {
                    theValue = PageUtils.FilterSqlAndXss(theValue);
                }

                ExtendedAttributes.SetExtendedAttribute(attributes, styleInfo.AttributeName, theValue);
            }

            //ArrayList metadataInfoArrayList = TableManager.GetTableMetadataInfoArrayList(tableName);
            //foreach (TableMetadataInfo metadataInfo in metadataInfoArrayList)
            //{
            //    if (!isSystemContained && metadataInfo.IsSystem == EBoolean.True) continue;

            //    TableStyleInfo styleInfo = TableStyleManager.GetTableStyleInfo(tableType, metadataInfo, relatedIdentities);
            //    if (styleInfo.IsVisible == EBoolean.False) continue;

            //    string theValue = InputTypeParser.GetValueByControl(metadataInfo, styleInfo, publishmentSystemInfo, containerControl);
            //    ExtendedAttributes.SetExtendedAttribute(attributes, metadataInfo.AttributeName, theValue);
            //}
        }
        public void UpdateExtendedAttributes(ExtendedAttributes theExtendedAttributes)
        {
            try { m_ExtendedAttributesDictionary.Remove(theExtendedAttributes.ExtendedAttributes_ID); }
            catch { }

            theExtendedAttributes.RequiresUpdate = true;
            m_ExtendedAttributesDictionary.Add(theExtendedAttributes.ExtendedAttributes_ID, theExtendedAttributes);
        }
        private string GetAttributesHtml(NameValueCollection formCollection)
        {
            if (formCollection == null)
            {
                formCollection = Request.Form.Count > 0 ? Request.Form : new NameValueCollection();
            }

            var pageScripts = new NameValueCollection();

            if (_styleInfoList == null)
            {
                return(string.Empty);
            }

            var attributes = new ExtendedAttributes(formCollection);

            var builder = new StringBuilder();

            foreach (var styleInfo in _styleInfoList)
            {
                string extra;
                var    value = BackgroundInputTypeParser.Parse(SiteInfo, 0, styleInfo, attributes, pageScripts, out extra);
                if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra))
                {
                    continue;
                }

                if (InputTypeUtils.Equals(styleInfo.InputType, InputType.TextEditor))
                {
                    var commands = WebUtils.GetTextEditorCommands(SiteInfo, styleInfo.AttributeName);
                    builder.Append($@"
<div class=""form-group"">
    <label class=""control-label"">{styleInfo.DisplayName}</label>
    {commands}
    <hr />
    {value}
    {extra}
</div>");
                }
                else
                {
                    builder.Append($@"
<div class=""form-group"">
    <label class=""control-label"">{styleInfo.DisplayName}</label>
    {value}
    {extra}
</div>");
                }
            }

            foreach (string key in pageScripts.Keys)
            {
                builder.Append(pageScripts[key]);
            }

            return(builder.ToString());
        }
Beispiel #7
0
 public void ReadResultsToExtendedAttributes(IDataReader rdr, ExtendedAttributes attributes)
 {
     for (var i = 0; i < rdr.FieldCount; i++)
     {
         var columnName = rdr.GetName(i);
         var value      = Convert.ToString(rdr.GetValue(i));
         if (!string.IsNullOrEmpty(value))
         {
             value = PageUtils.UnFilterSql(value);
         }
         attributes.SetExtendedAttribute(columnName, value);
     }
 }
Beispiel #8
0
        /// <summary>
        /// Gets the extended file attributes stored in the archive, if there are any.
        /// </summary>
        public ExtendedAttributes GetFileAttributes()
        {
            if (this.FileAttributes == null)
            {
                if (ContainsFile(ExtendedAttributes.InternalFileName))
                {
                    byte[] attributeData = ExtractFile(ExtendedAttributes.InternalFileName);
                    this.FileAttributes = new ExtendedAttributes(attributeData, this.Header.BlockTableEntryCount);
                }
            }

            return(this.FileAttributes);
        }
Beispiel #9
0
        // Returns a dictionary containing the extended attributes collected from the provided byte buffer.
        private void ReadExtendedAttributesFromBuffer(ReadOnlySpan <byte> buffer, string name)
        {
            string dataAsString = TarHelpers.GetTrimmedUtf8String(buffer);

            using StringReader reader = new(dataAsString);

            while (TryGetNextExtendedAttribute(reader, out string?key, out string?value))
            {
                if (ExtendedAttributes.ContainsKey(key))
                {
                    throw new FormatException(string.Format(SR.TarDuplicateExtendedAttribute, name));
                }
                ExtendedAttributes.Add(key, value);
            }
        }
        public void AddExtendedAttributes(string SqlWhereClause = null)
        {
            int idFld            = m_ExtendedAttributesTable.FindField("ExtendedAttributes_ID");
            int ownerTableFld    = m_ExtendedAttributesTable.FindField("OwnerTable");
            int ownerFld         = m_ExtendedAttributesTable.FindField("OwnerID");
            int propertyFld      = m_ExtendedAttributesTable.FindField("Property");
            int propertyValueFld = m_ExtendedAttributesTable.FindField("PropertyValue");
            int valueLinkFld     = m_ExtendedAttributesTable.FindField("ValueLinkID");
            int qualifierFld     = m_ExtendedAttributesTable.FindField("Qualifier");
            int dataSrcFld       = m_ExtendedAttributesTable.FindField("DataSourceID");
            int notesFld         = m_ExtendedAttributesTable.FindField("Notes");

            ICursor theCursor;

            if (SqlWhereClause == null)
            {
                theCursor = m_ExtendedAttributesTable.Search(null, false);
            }
            else
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = SqlWhereClause;
                theCursor      = m_ExtendedAttributesTable.Search(QF, false);
            }

            IRow theRow = theCursor.NextRow();

            while (theRow != null)
            {
                ExtendedAttributes anExtendedAttributes = new ExtendedAttributes();
                anExtendedAttributes.ExtendedAttributes_ID = theRow.get_Value(idFld).ToString();
                anExtendedAttributes.OwnerTable            = theRow.get_Value(ownerTableFld).ToString();
                anExtendedAttributes.OwnerID        = theRow.get_Value(ownerFld).ToString();
                anExtendedAttributes.Property       = theRow.get_Value(propertyFld).ToString();
                anExtendedAttributes.PropertyValue  = theRow.get_Value(propertyValueFld).ToString();
                anExtendedAttributes.ValueLinkID    = theRow.get_Value(valueLinkFld).ToString();
                anExtendedAttributes.Qualifier      = theRow.get_Value(qualifierFld).ToString();
                anExtendedAttributes.DataSourceID   = theRow.get_Value(dataSrcFld).ToString();
                anExtendedAttributes.Notes          = theRow.get_Value(notesFld).ToString();
                anExtendedAttributes.RequiresUpdate = true;

                m_ExtendedAttributesDictionary.Add(anExtendedAttributes.ExtendedAttributes_ID, anExtendedAttributes);

                theRow = theCursor.NextRow();
            }
        }
Beispiel #11
0
        /// <summary>
        /// Gets the extended file attributes stored in the archive, if there are any.
        /// </summary>
        public ExtendedAttributes GetFileAttributes()
        {
            ThrowIfDisposed();

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

            if (ContainsFile(ExtendedAttributes.InternalFileName))
            {
                byte[] attributeData = ExtractFile(ExtendedAttributes.InternalFileName);
                FileAttributes = new ExtendedAttributes(attributeData, Header.BlockTableEntryCount);
            }

            return(FileAttributes);
        }
        public RepositoryPluginSetting(PluginSetting setting)
            : base(setting)
        {
            // conns
            Conns = new Dictionary <KeyValuePair <string, string>, ExtendedAttributes>();

            if (setting.Node != null)
            {
                XmlNode connsnode = setting.Node.SelectSingleNode("conns");

                if (connsnode != null)
                {
                    DefaultConn       = XmlUtil.GetStringAttribute(connsnode, "default", string.Empty);
                    DefaultMasterConn = XmlUtil.GetStringAttribute(connsnode, "default_master", DefaultConn);

                    foreach (XmlNode conn in connsnode.ChildNodes)
                    {
                        string conn_name = XmlUtil.GetStringAttribute(conn, "conn", string.Empty);
                        if (string.IsNullOrEmpty(conn_name))
                        {
                            continue;
                        }

                        string table = XmlUtil.GetStringAttribute(conn, "table", string.Empty);
                        if (string.IsNullOrEmpty(table))
                        {
                            continue;
                        }

                        ExtendedAttributes attrs = new ExtendedAttributes();
                        foreach (XmlAttribute item in conn.Attributes)
                        {
                            attrs[item.Name] = item.Value;
                        }

                        Conns[new KeyValuePair <string, string>(conn_name, table)] = attrs;
                    }
                }
            }

            // use first connection string if not config
            if (string.IsNullOrEmpty(DefaultConn) && ConfigurationManager.ConnectionStrings.Count > 0)
            {
                DefaultConn = ConfigurationManager.ConnectionStrings[0].Name;
            }
        }
        public void AddExtendedAttributes(string SqlWhereClause = null)
        {
            int idFld = m_ExtendedAttributesTable.FindField("ExtendedAttributes_ID");
            int ownerTableFld = m_ExtendedAttributesTable.FindField("OwnerTable");
            int ownerFld = m_ExtendedAttributesTable.FindField("OwnerID");
            int propertyFld = m_ExtendedAttributesTable.FindField("Property");
            int propertyValueFld = m_ExtendedAttributesTable.FindField("PropertyValue");
            int valueLinkFld = m_ExtendedAttributesTable.FindField("ValueLinkID");
            int qualifierFld = m_ExtendedAttributesTable.FindField("Qualifier");
            int dataSrcFld = m_ExtendedAttributesTable.FindField("DataSourceID");
            int notesFld = m_ExtendedAttributesTable.FindField("Notes");

            ICursor theCursor;

            if (SqlWhereClause == null) { theCursor = m_ExtendedAttributesTable.Search(null, false); }
            else
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = SqlWhereClause;
                theCursor = m_ExtendedAttributesTable.Search(QF, false);
            }

            IRow theRow = theCursor.NextRow();

            while (theRow != null)
            {
                ExtendedAttributes anExtendedAttributes = new ExtendedAttributes();
                anExtendedAttributes.ExtendedAttributes_ID = theRow.get_Value(idFld).ToString();
                anExtendedAttributes.OwnerTable = theRow.get_Value(ownerTableFld).ToString();
                anExtendedAttributes.OwnerID = theRow.get_Value(ownerFld).ToString();
                anExtendedAttributes.Property = theRow.get_Value(propertyFld).ToString();
                anExtendedAttributes.PropertyValue = theRow.get_Value(propertyValueFld).ToString();
                anExtendedAttributes.ValueLinkID = theRow.get_Value(valueLinkFld).ToString();
                anExtendedAttributes.Qualifier = theRow.get_Value(qualifierFld).ToString();
                anExtendedAttributes.DataSourceID = theRow.get_Value(dataSrcFld).ToString();
                anExtendedAttributes.Notes = theRow.get_Value(notesFld).ToString();
                anExtendedAttributes.RequiresUpdate = true;

                m_ExtendedAttributesDictionary.Add(anExtendedAttributes.ExtendedAttributes_ID, anExtendedAttributes);

                theRow = theCursor.NextRow();
            }
        }
Beispiel #14
0
        public static void AddValuesToAttributes(ETableStyle tableStyle, string tableName, PublishmentSystemInfo publishmentSystemInfo, List <int> relatedIdentities, NameValueCollection formCollection, NameValueCollection attributes, bool isBackground)
        {
            var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities);

            foreach (var styleInfo in styleInfoList)
            {
                if (styleInfo.IsVisible == false)
                {
                    continue;
                }
                var theValue = GetValueByForm(styleInfo, publishmentSystemInfo, formCollection);

                if (!EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.TextEditor, EInputType.Image, EInputType.File, EInputType.Video) && styleInfo.AttributeName != BackgroundContentAttribute.LinkUrl)
                {
                    theValue = PageUtils.FilterSqlAndXss(theValue);
                }

                ExtendedAttributes.SetExtendedAttribute(attributes, styleInfo.AttributeName, theValue);
            }
        }
Beispiel #15
0
        public static void AddSingleValueToAttributes(ETableStyle tableStyle, string tableName, PublishmentSystemInfo publishmentSystemInfo, List <int> relatedIdentities, NameValueCollection formCollection, string attributeName, NameValueCollection attributes, bool isSystemContained)
        {
            var metadataInfo = TableManager.GetTableMetadataInfo(tableName, attributeName);

            if (!isSystemContained && metadataInfo.IsSystem)
            {
                return;
            }

            var styleInfo = TableStyleManager.GetTableStyleInfo(tableStyle, tableName, attributeName, relatedIdentities);

            if (styleInfo.IsVisible == false)
            {
                return;
            }

            var theValue = GetValueByForm(styleInfo, publishmentSystemInfo, formCollection);

            ExtendedAttributes.SetExtendedAttribute(attributes, metadataInfo.AttributeName, theValue);
        }
        public string NewExtendedAttributes(string OwnerID, string OwnerTable, string Property, string PropertyValue,
                                            string ValueLinkID, string Qualifier, string DataSourceID, string Notes)
        {
            ExtendedAttributes newExtendedAttributes = new ExtendedAttributes();

            sysInfo SysInfoTable = new sysInfo(m_theWorkspace);

            newExtendedAttributes.ExtendedAttributes_ID = SysInfoTable.ProjAbbr + ".ExtendedAttributes." + SysInfoTable.GetNextIdValue("ExtendedAttributes");

            newExtendedAttributes.OwnerID       = OwnerID;
            newExtendedAttributes.OwnerTable    = OwnerTable;
            newExtendedAttributes.Property      = Property;
            newExtendedAttributes.PropertyValue = PropertyValue;
            newExtendedAttributes.ValueLinkID   = ValueLinkID;
            newExtendedAttributes.Qualifier     = Qualifier;
            newExtendedAttributes.DataSourceID  = DataSourceID;
            newExtendedAttributes.Notes         = Notes;

            m_ExtendedAttributesDictionary.Add(newExtendedAttributes.ExtendedAttributes_ID, newExtendedAttributes);

            return(newExtendedAttributes.ExtendedAttributes_ID);
        }
Beispiel #17
0
        protected override void Render(HtmlTextWriter output)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            var pageScripts = new NameValueCollection();

            var attributes = new ExtendedAttributes();

            attributes.Set(_attributeName, _value);

            var extraBuilder = new StringBuilder();
            var inputHtml    = BackgroundInputTypeParser.ParseTextEditor(attributes, _attributeName, _siteInfo, pageScripts, extraBuilder);

            output.Write(inputHtml + extraBuilder);

            foreach (string key in pageScripts.Keys)
            {
                output.Write(pageScripts[key]);
            }
        }
Beispiel #18
0
        public ExtendedAttributes GetFileAttributes()
        {
            ThrowIfDisposed();

            if (!ContainsFile(ExtendedAttributes.InternalFileName))
            {
                throw new FileNotFoundException(
                          "The archive does not contain any extended attributes.",
                          ExtendedAttributes.InternalFileName
                          );
            }

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

            var attributeData = ExtractFile(ExtendedAttributes.InternalFileName);

            _fileAttributes = new ExtendedAttributes(attributeData, Header.BlockTableEntryCount);

            return(_fileAttributes);
        }
Beispiel #19
0
        public static void AddValuesToAttributes(ETableStyle tableStyle, string tableName, PublishmentSystemInfo publishmentSystemInfo, List <int> relatedIdentities, NameValueCollection formCollection, NameValueCollection attributes, List <string> dontAddAttributes, bool isSaveImage)
        {
            var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableStyle, tableName, relatedIdentities);

            foreach (var styleInfo in styleInfoList)
            {
                if (styleInfo.IsVisible == false || dontAddAttributes.Contains(styleInfo.AttributeName.ToLower()))
                {
                    continue;
                }
                var theValue = GetValueByForm(styleInfo, publishmentSystemInfo, formCollection, isSaveImage);

                if (!EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.TextEditor, EInputType.Image, EInputType.File, EInputType.Video) && styleInfo.AttributeName != BackgroundContentAttribute.LinkUrl)
                {
                    theValue = PageUtils.FilterSqlAndXss(theValue);
                }

                ExtendedAttributes.SetExtendedAttribute(attributes, styleInfo.AttributeName, theValue);

                if (styleInfo.Additional.IsFormatString)
                {
                    var formatString    = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatStrong"]);
                    var formatEm        = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatEM"]);
                    var formatU         = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatU"]);
                    var formatColor     = formCollection[styleInfo.AttributeName + "_formatColor"];
                    var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);

                    ExtendedAttributes.SetExtendedAttribute(attributes, ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName), theFormatString);
                }

                if (EInputTypeUtils.EqualsAny(styleInfo.InputType, EInputType.Image, EInputType.Video, EInputType.File))
                {
                    var attributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
                    ExtendedAttributes.SetExtendedAttribute(attributes, attributeName, formCollection[attributeName]);
                }
            }
        }
        public void DeleteExtendedAttributes(ExtendedAttributes theExtendedAttributes)
        {
            try { m_ExtendedAttributesDictionary.Remove(theExtendedAttributes.ExtendedAttributes_ID); }
            catch { }

            IEditor theEditor = ArcMap.Editor;
            if (theEditor.EditState == esriEditState.esriStateNotEditing) { theEditor.StartEditing(m_theWorkspace);  }
            theEditor.StartOperation();

            try
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = "ExtendedAttributes_ID = '" + theExtendedAttributes.ExtendedAttributes_ID + "'";

                m_ExtendedAttributesTable.DeleteSearchedRows(QF);

                theEditor.StopOperation("Delete ExtendedAttributes");
            }
            catch (Exception e) { theEditor.StopOperation("ExtendedAttributes Management Failure");  }
        }
Beispiel #21
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            int insertChannelId;

            try
            {
                var channelId = AuthRequest.GetQueryInt("ChannelId");
                var nodeInfo  = new ChannelInfo
                {
                    ParentId                = channelId,
                    ContentModelPluginId    = DdlContentModelPluginId.SelectedValue,
                    ContentRelatedPluginIds =
                        ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds)
                };

                if (TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameArrayList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameArrayList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目添加失败,栏目索引已存在!");
                        return;
                    }
                }

                if (TbFilePath.Text.Length != 0)
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                    {
                        FailMessage("栏目页面路径不符合系统要求!");
                        return;
                    }

                    if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                    {
                        TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                    }

                    var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                    if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                    {
                        FailMessage("栏目添加失败,栏目页面路径已存在!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbChannelFilePathRule.Text))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(TbChannelFilePathRule.Text))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbContentFilePathRule.Text))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(TbContentFilePathRule.Text))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                var extendedAttributes = new ExtendedAttributes();
                var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
                var styleInfoList      = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities);
                BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
                var attributes = extendedAttributes.ToNameValueCollection();
                nodeInfo.Additional.Load(attributes);
                //foreach (string key in attributes)
                //{
                //    nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]);
                //}

                nodeInfo.ChannelName         = TbNodeName.Text;
                nodeInfo.IndexName           = TbNodeIndexName.Text;
                nodeInfo.FilePath            = TbFilePath.Text;
                nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text;

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection         = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl                    = TbImageUrl.Text;
                nodeInfo.Content                     = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                nodeInfo.Keywords                    = TbKeywords.Text;
                nodeInfo.Description                 = TbDescription.Text;
                nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
                nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);

                nodeInfo.LinkUrl  = TbLinkUrl.Text;
                nodeInfo.LinkType = DdlLinkType.SelectedValue;

                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));

                nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                nodeInfo.AddDate = DateTime.Now;
                insertChannelId  = DataProvider.ChannelDao.Insert(nodeInfo);
                //栏目选择投票样式后,内容
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                FailMessage(ex, $"栏目添加失败:{ex.Message}");
                return;
            }

            CreateManager.CreateChannel(SiteId, insertChannelId);

            AuthRequest.AddSiteLog(SiteId, "添加栏目", $"栏目:{TbNodeName.Text}");

            SuccessMessage("栏目添加成功!");
            AddWaitAndRedirectScript(ReturnUrl);
        }
Beispiel #22
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var isChanged = false;

            try
            {
                var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

                if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目修改失败,栏目索引已存在!");
                        return;
                    }
                }

                if (PhFilePath.Visible)
                {
                    TbFilePath.Text = TbFilePath.Text.Trim();
                    if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                        {
                            TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                        if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                        {
                            FailMessage("栏目修改失败,栏目页面路径已存在!");
                            return;
                        }
                    }
                }

                var extendedAttributes = new ExtendedAttributes();
                var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
                var styleInfoList      = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName,
                                                                                 relatedIdentities);
                BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
                if (extendedAttributes.ToNameValueCollection().Count > 0)
                {
                    nodeInfo.Additional.Load(extendedAttributes.ToNameValueCollection());
                }

                nodeInfo.ChannelName = TbNodeName.Text;
                nodeInfo.IndexName   = TbNodeIndexName.Text;
                if (PhFilePath.Visible)
                {
                    nodeInfo.FilePath = TbFilePath.Text;
                }

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl            = TbImageUrl.Text;
                nodeInfo.Content             = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                if (TbKeywords.Visible)
                {
                    nodeInfo.Keywords = TbKeywords.Text;
                }
                if (TbDescription.Visible)
                {
                    nodeInfo.Description = TbDescription.Text;
                }

                if (PhLinkUrl.Visible)
                {
                    nodeInfo.LinkUrl = TbLinkUrl.Text;
                }
                if (PhLinkType.Visible)
                {
                    nodeInfo.LinkType = DdlLinkType.SelectedValue;
                }
                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
                if (PhChannelTemplateId.Visible)
                {
                    nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                }
                nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                DataProvider.ChannelDao.Update(nodeInfo);

                AuthRequest.AddSiteLog(SiteId, _channelId, 0, "修改栏目", $"栏目:{nodeInfo.ChannelName}");

                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, $"栏目修改失败:{ex.Message}");
                LogUtils.AddErrorLog(ex);
            }

            if (isChanged)
            {
                CreateManager.CreateChannel(SiteId, _channelId);

                if (string.IsNullOrEmpty(_returnUrl))
                {
                    LayerUtils.Close(Page);
                }
                else
                {
                    LayerUtils.CloseAndRedirect(Page, _returnUrl);
                }
            }
        }
Beispiel #23
0
        public void createMyItem(string itemType)
        {
            try
            {
                // Get the service stub
                DataManagementService dmService   = DataManagementService.getService(Session.getConnection());
                ObjectOwner           objectOwner = new ObjectOwner();

                //根据物料号创建ITEMID
                ItemProperties itemProperty = new ItemProperties();

                itemProperty.ClientId    = "Maxtt-Test-demo10";                                   //物料名称
                itemProperty.ItemId      = "000092";                                              //物料代码
                itemProperty.RevId       = "00";                                                  //版本
                itemProperty.Name        = "Maxtt-Test";                                          //物料名称
                itemProperty.Type        = itemType;                                              //创建ITEM的类型
                itemProperty.Description = "Test Item for the SOA AppX sample application.Hello"; //描述
                //test
                itemProperty.Uom = "PCS";                                                         //单位

                //增加额外属性
                itemProperty.ExtendedAttributes = new ExtendedAttributes[2];   //增加多少个?
                ExtendedAttributes[] theExtendedAttr = new ExtendedAttributes[2];

                //第1个
                theExtendedAttr[0]            = new ExtendedAttributes();
                theExtendedAttr[0].Attributes = new Hashtable();
                theExtendedAttr[0].ObjectType = "Item Master";      //对应哪个form表
                theExtendedAttr[0].Attributes["project_id"] = "project_id";
                itemProperty.ExtendedAttributes[0]          = theExtendedAttr[0];

                //第2个
                theExtendedAttr[1]            = new ExtendedAttributes();
                theExtendedAttr[1].Attributes = new Hashtable();
                theExtendedAttr[1].ObjectType = "ItemRevision Master";      //对应哪个form表
                theExtendedAttr[1].Attributes["user_data_2"] = "data_2";
                itemProperty.ExtendedAttributes[1]           = theExtendedAttr[1];



                //链接服务器创建
                CreateItemsResponse response = dmService.CreateItems(new ItemProperties[] { itemProperty }, null, "");

                //调用查询构建器,查询ITEM和ITEMRevision
                ModelObject itemObj       = findModel("Item ID", new string[] { "Item ID" }, new string[] { itemProperty.ItemId });
                ModelObject itemReversion = findModel("MY_WEB_ITEM_REVISION", new string[] { "iid", "vid" }, new string[] { itemProperty.ItemId, itemProperty.RevId });


                //修改ITEM所有者
                //changeOnwer("maxtt", "项目管理", itemObj);
                //changeOnwer("maxtt", "项目管理", itemReversion);

                //新增版本--不能修改所有者不是infodba用户的ITEM
                //reviseItem(itemReversion);

                //修改原有的版本


                //deleteItems_single(itemReversion);

                //发布流程
                wf("MyRelease", itemReversion);
            }
            //catch (ServiceException e)
            catch (Exception e)
            {
                System.Console.Out.WriteLine(e.Message);
            }
        }
        public void UpdateExtendedAttributes(ExtendedAttributes theExtendedAttributes)
        {
            try { m_ExtendedAttributesDictionary.Remove(theExtendedAttributes.ExtendedAttributes_ID); }
            catch { }

            theExtendedAttributes.RequiresUpdate = true;
            m_ExtendedAttributesDictionary.Add(theExtendedAttributes.ExtendedAttributes_ID, theExtendedAttributes);
        }
Beispiel #25
0
        // Reads the elements from the passed dictionary, which comes from the previous extended attributes entry,
        // and inserts or replaces those elements into the current header's dictionary.
        // If any of the dictionary entries use the name of a standard attribute, that attribute's value gets replaced with the one from the dictionary.
        // Unlike the historic header, numeric values in extended attributes are stored using decimal, not octal.
        // Throws if any conversion from string to the expected data type fails.
        internal void ReplaceNormalAttributesWithExtended(Dictionary <string, string>?dictionaryFromExtendedAttributesHeader)
        {
            if (dictionaryFromExtendedAttributesHeader == null || dictionaryFromExtendedAttributesHeader.Count == 0)
            {
                return;
            }

            InitializeExtendedAttributesWithExisting(dictionaryFromExtendedAttributesHeader);

            // Find all the extended attributes with known names and save them in the expected standard attribute.

            // The 'name' header field only fits 100 bytes, so we always store the full name text to the dictionary.
            if (ExtendedAttributes.TryGetValue(PaxEaName, out string?paxEaName))
            {
                _name = paxEaName;
            }

            // The 'linkName' header field only fits 100 bytes, so we always store the full linkName text to the dictionary.
            if (ExtendedAttributes.TryGetValue(PaxEaLinkName, out string?paxEaLinkName))
            {
                _linkName = paxEaLinkName;
            }

            // The 'mtime' header field only fits 12 bytes, so a more precise timestamp goes in the extended attributes
            if (TarHelpers.TryGetDateTimeOffsetFromTimestampString(ExtendedAttributes, PaxEaMTime, out DateTimeOffset mTime))
            {
                _mTime = mTime;
            }

            // The user could've stored an override in the extended attributes
            if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaMode, out int mode))
            {
                _mode = mode;
            }

            // The 'size' header field only fits 12 bytes, so the data section length that surpases that limit needs to be retrieved
            if (TarHelpers.TryGetStringAsBaseTenLong(ExtendedAttributes, PaxEaSize, out long size))
            {
                _size = size;
            }

            // The 'uid' header field only fits 8 bytes, or the user could've stored an override in the extended attributes
            if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaUid, out int uid))
            {
                _uid = uid;
            }

            // The 'gid' header field only fits 8 bytes, or the user could've stored an override in the extended attributes
            if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaGid, out int gid))
            {
                _gid = gid;
            }

            // The 'uname' header field only fits 32 bytes
            if (ExtendedAttributes.TryGetValue(PaxEaUName, out string?paxEaUName))
            {
                _uName = paxEaUName;
            }

            // The 'gname' header field only fits 32 bytes
            if (ExtendedAttributes.TryGetValue(PaxEaGName, out string?paxEaGName))
            {
                _gName = paxEaGName;
            }

            // The 'devmajor' header field only fits 8 bytes, or the user could've stored an override in the extended attributes
            if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaDevMajor, out int devMajor))
            {
                _devMajor = devMajor;
            }

            // The 'devminor' header field only fits 8 bytes, or the user could've stored an override in the extended attributes
            if (TarHelpers.TryGetStringAsBaseTenInteger(ExtendedAttributes, PaxEaDevMinor, out int devMinor))
            {
                _devMinor = devMinor;
            }
        }
Beispiel #26
0
        /// <summary>
        /// </summary>
        /// <param name="itemType">创建TC中ITEM的类型</param>
        /// <param name="codeNumber">物料号</param>
        /// <param name="CodeName">物料名称</param>
        /// <param name="longDetail">详细描述</param>
        /// <param name="unit">单位</param>
        /// <param name="productionType">物料属性(自制、外购、委外)</param>
        /// <param name="ReqName">物料申请人</param>
        public String createTCItem(String codeNumber, String CodeName, String longDetail, String unit, String productionType, String ReqName, String group)
        {
            String erroMsg = "";

            //处理详细描述,10-79插入详细描述,80-90不插入详细描述
            longDetail = codeNumber.Length < 2 ? ""
                        : (codeNumber.Substring(0, 2).CompareTo("80") >= 0 ? "" : longDetail);

            String itemType = codeNumber.Length >= 2 && codeNumber.Substring(0, 2).Equals("80") ?
                              cfg.get("CPTyep") : cfg.get("LBJType");

            try
            {
                DataManagementService dmService = DataManagementService.getService(Session.getConnection());

                //查询最新的ITEM版本
                //ModelObject LastestRevision = findModel("MY_WEB_ITEM_REVISION", new string[] { "iid" }, new string[] { codeNumber });
                ModelObject LastestRevision = findModel(cfg.get("query_builder_lastestRevisionById_name")
                                                        , new string[] { cfg.get("query_builder_lastestRevisionById_queryKey") }, new string[] { codeNumber });
                if (null != LastestRevision && !string.IsNullOrEmpty(LastestRevision.Uid))
                {
                    dmService.GetProperties(new ModelObject[] { LastestRevision }, new string[] { "release_status_list" });
                    dmService.GetProperties(new ModelObject[] { LastestRevision }, new string[] { "item_revision_id" });
                    dmService.GetProperties(new ModelObject[] { LastestRevision }, new string[] { "object_name" });
                    dmService.GetProperties(new ModelObject[] { LastestRevision }, new string[] { "IMAN_master_form_rev" });
                    var master = LastestRevision.GetProperty("IMAN_master_form_rev").ModelObjectArrayValue[0];
                    dmService.GetProperties(new ModelObject[] { master }, new string[] { cfg.get("exAttr_detail") });
                    dmService.GetProperties(new ModelObject[] { LastestRevision }, new string[] { "IMAN_specification" });
                    String item_revision_id = LastestRevision.GetProperty("item_revision_id").StringValue.ToString();

                    //如果名称、规格相同,不执行更新。
                    if (LastestRevision.GetProperty("object_name").StringValue.Equals(CodeName) &&
                        master.GetProperty(cfg.get("exAttr_detail")).StringValue.Equals(longDetail))
                    {
                        return(erroMsg);
                    }

                    if (LastestRevision.GetProperty("IMAN_specification").ModelObjectArrayValue.Length > 0)
                    {
                        return(codeNumber + "/" + item_revision_id + ":有图纸,请在TC中更新。");
                    }

                    ModelObject release_status_obj = null;
                    if (LastestRevision.GetProperty("release_status_list").ModelObjectArrayValue.Length > 0)
                    {
                        release_status_obj = LastestRevision.GetProperty("release_status_list").ModelObjectArrayValue[0];
                        dmService.GetProperties(new ModelObject[] { release_status_obj }, new string[] { "name" });
                    }
                    String release_status = null == release_status_obj ? "" : release_status_obj.GetProperty("name").StringValue;

                    //查询是否存在未发布版本
                    if (!release_status.Equals(cfg.get("publish_status_value")))
                    {
                        workflow_publish(cfg.get("publish_workflow"), LastestRevision);
                    }

                    //创建新版本前,修改ITEM数据
                    updateItem(codeNumber, CodeName, longDetail);
                    //创建新版本
                    reviseItem(LastestRevision, CodeName, longDetail, productionType, item_revision_id);
                }
                else
                {
                    //开始新增ITEM
                    //根据物料号创建ITEMID
                    ItemProperties itemProperty = new ItemProperties();
                    itemProperty.Type        = itemType;   //创建ITEM的类型
                    itemProperty.ItemId      = codeNumber; //物料代码
                    itemProperty.Name        = CodeName;   //物料名称
                    itemProperty.RevId       = "00";       //版本
                    itemProperty.Description = "";         //描述
                    itemProperty.Uom         = unit;       //单位

                    //增加额外属性-对于同一个form,只用一次ExtendedAttributes,多个属性写在Hashtable上
                    ExtendedAttributes exAttr = new ExtendedAttributes();
                    exAttr.Attributes = new Hashtable();
                    exAttr.ObjectType = itemType + "RevisionMaster";      //对应哪个form表
                    exAttr.Attributes[cfg.get("exAttr_productionType")] = productionType;
                    exAttr.Attributes[cfg.get("exAttr_detail")]         = longDetail;

                    itemProperty.ExtendedAttributes = new ExtendedAttributes[] { exAttr };

                    //创建前查找文件路径
                    var RootFile = (Teamcenter.Soa.Client.Model.Strong.Folder)findModel(cfg.get("query_builder_folder_name")
                                                                                        , new string[] { cfg.get("query_builder_folder_queryKey1"), cfg.get("query_builder_folder_queryKey2") }
                                                                                        , new string[] { cfg.get("query_builder_folder_queryval1"), cfg.get("query_builder_folder_queryval2") });

                    var TargetFolder = findFolder(group, RootFile, cfg.get("group_split_flag"));

                    //链接服务器创建Item
                    CreateItemsResponse response = dmService.CreateItems(new ItemProperties[] { itemProperty }, TargetFolder, "contents");
                    //CreateItemsResponse response = dmService.CreateItems(new ItemProperties[] { itemProperty }, null, "");
                    if (response.ServiceData.sizeOfPartialErrors() > 0)
                    {
                        return("创建ITEM失败。" + response.ServiceData.GetPartialError(0).Messages[0]);
                    }
                    //结束新增ITEM

                    //新增完后附加文件。
                    ModelObject itemReversion2add = findModel(cfg.get("query_builder_lastestRevisionById_name")
                                                              , new string[] { cfg.get("query_builder_lastestRevisionById_queryKey") }, new string[] { codeNumber });

                    //ModelObject datasets = createEmptyFile("Text",codeNumber, "./template/url.txt", "Text");
                    //createRelations(itemReversion2add, datasets, "IMAN_specification");
                    //changeOnwer(ReqName, datasets);

                    //创建dataset并关联,修改所有者

                    if (codeNumber.Length > 4 &&
                        //codeNumber.Substring(0,2).CompareTo("80") >= 0)
                        codeNumber.Substring(0, 2).Equals("80"))
                    {
                        var subCodeNumber    = codeNumber.Substring(0, 4);
                        var uploadCfgPramary = subCodeNumber.Equals("8102") || subCodeNumber.Equals("8301") ?
                                               "uploadFile_part" : "uploadFile_asm";
                        var cfgList = cfg.tc[uploadCfgPramary].ToObject <ArrayList>();
                        foreach (var uploadObj in cfgList)
                        {
                            var         uploadCfg     = JObject.Parse(uploadObj.ToString());
                            ModelObject datasets_temp = createEmptyFile(uploadCfg["datasetType"].ToString()
                                                                        , codeNumber
                                                                        , uploadCfg["filePath"].ToString()
                                                                        , uploadCfg["fileRefName"].ToString()
                                                                        , itemReversion2add
                                                                        , uploadCfg["relationType"].ToString()
                                                                        );
                            //createRelations(itemReversion2add, datasets_temp, uploadCfg["relationType"].ToString());
                            changeOnwer(ReqName, datasets_temp);
                        }
                    }
                }

                //调用查询构建器,查询ITEM和ITEMRevision
                ModelObject itemObj = findModel(cfg.get("query_builder_ItemById_name")
                                                , new string[] { cfg.get("query_builder_ItemById_queryKey") }, new string[] { codeNumber });
                ModelObject itemReversion = findModel(cfg.get("query_builder_lastestRevisionById_name")
                                                      , new string[] { cfg.get("query_builder_lastestRevisionById_queryKey") }, new string[] { codeNumber });
                if (null == itemObj || null == itemReversion)
                {
                    return("查询构建器失败。");
                }

                //修改所有者
                changeOnwer(ReqName, itemObj);
                changeOnwer(ReqName, itemReversion);

                //发布-外购件
                if (codeNumber.Length >= 2 && (codeNumber.Substring(0, 2).CompareTo("80") < 0))
                {
                    workflow_publish(cfg.get("publish_workflow"), itemReversion);
                }
            }
            catch (Exception e)
            {
                deleteItem(codeNumber);
                throw e;
            }

            return(erroMsg);
        }
Beispiel #27
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                int insertNodeId;
                try
                {
                    var nodeId   = Body.GetQueryInt("NodeID");
                    var nodeInfo = new NodeInfo
                    {
                        ParentId       = nodeId,
                        ContentModelId = ContentModelID.SelectedValue
                    };

                    if (NodeIndexName.Text.Length != 0)
                    {
                        var nodeIndexNameArrayList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId);
                        if (nodeIndexNameArrayList.IndexOf(NodeIndexName.Text) != -1)
                        {
                            FailMessage("栏目添加失败,栏目索引已存在!");
                            return;
                        }
                    }

                    if (FilePath.Text.Length != 0)
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(FilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(FilePath.Text))
                        {
                            FilePath.Text = PageUtils.Combine(FilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId);
                        if (filePathArrayList.IndexOf(FilePath.Text) != -1)
                        {
                            FailMessage("栏目添加失败,栏目页面路径已存在!");
                            return;
                        }
                    }

                    if (!string.IsNullOrEmpty(ChannelFilePathRule.Text))
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(ChannelFilePathRule.Text))
                        {
                            FailMessage("栏目页面命名规则不符合系统要求!");
                            return;
                        }
                        if (PathUtils.IsDirectoryPath(ChannelFilePathRule.Text))
                        {
                            FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                            return;
                        }
                    }

                    if (!string.IsNullOrEmpty(ContentFilePathRule.Text))
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(ContentFilePathRule.Text))
                        {
                            FailMessage("内容页面命名规则不符合系统要求!");
                            return;
                        }
                        if (PathUtils.IsDirectoryPath(ContentFilePathRule.Text))
                        {
                            FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                            return;
                        }
                    }

                    var extendedAttributes = new ExtendedAttributes();
                    var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);
                    BackgroundInputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes);
                    var attributes = extendedAttributes.Attributes;
                    foreach (string key in attributes)
                    {
                        nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]);
                    }

                    nodeInfo.NodeName            = NodeName.Text;
                    nodeInfo.NodeIndexName       = NodeIndexName.Text;
                    nodeInfo.FilePath            = FilePath.Text;
                    nodeInfo.ChannelFilePathRule = ChannelFilePathRule.Text;
                    nodeInfo.ContentFilePathRule = ContentFilePathRule.Text;

                    var list = new ArrayList();
                    foreach (ListItem item in NodeGroupNameCollection.Items)
                    {
                        if (item.Selected)
                        {
                            list.Add(item.Value);
                        }
                    }
                    nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                    nodeInfo.ImageUrl    = NavigationPicPath.Text;
                    nodeInfo.Content     = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor);
                    nodeInfo.Keywords    = Keywords.Text;
                    nodeInfo.Description = Description.Text;
                    nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(IsChannelAddable.SelectedValue);
                    nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(IsContentAddable.SelectedValue);

                    nodeInfo.LinkUrl           = LinkURL.Text;
                    nodeInfo.LinkType          = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue);
                    nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0;
                    nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0;

                    nodeInfo.AddDate = DateTime.Now;
                    insertNodeId     = DataProvider.NodeDao.InsertNodeInfo(nodeInfo);
                    //栏目选择投票样式后,内容
                }
                catch (Exception ex)
                {
                    FailMessage(ex, $"栏目添加失败:{ex.Message}");
                    LogUtils.AddErrorLog(ex);
                    return;
                }

                CreateManager.CreateChannel(PublishmentSystemId, insertNodeId);

                Body.AddSiteLog(PublishmentSystemId, "添加栏目", $"栏目:{NodeName.Text}");

                SuccessMessage("栏目添加成功!");
                AddWaitAndRedirectScript(_returnUrl);
            }
        }
Beispiel #28
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            ChannelInfo nodeInfo;

            try
            {
                nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
                if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目属性修改失败,栏目索引已存在!");
                        return;
                    }
                }

                if (nodeInfo.ContentModelPluginId != DdlContentModelPluginId.SelectedValue)
                {
                    nodeInfo.ContentModelPluginId = DdlContentModelPluginId.SelectedValue;
                    nodeInfo.ContentNum           = DataProvider.ContentDao.GetCount(ChannelManager.GetTableName(SiteInfo, nodeInfo.ContentModelPluginId), nodeInfo.Id);
                }

                nodeInfo.ContentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds);

                TbFilePath.Text = TbFilePath.Text.Trim();
                if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
                {
                    if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                    {
                        FailMessage("栏目页面路径不符合系统要求!");
                        return;
                    }

                    if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                    {
                        TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                    }

                    var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                    if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                    {
                        FailMessage("栏目修改失败,栏目页面路径已存在!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
                {
                    var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
                {
                    var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                var extendedAttributes = new ExtendedAttributes();
                var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
                var styleInfoList      = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities);
                BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
                var attributes = extendedAttributes.ToNameValueCollection();
                foreach (string key in attributes)
                {
                    nodeInfo.Additional.Set(key, attributes[key]);
                }

                nodeInfo.ChannelName         = TbNodeName.Text;
                nodeInfo.IndexName           = TbNodeIndexName.Text;
                nodeInfo.FilePath            = TbFilePath.Text;
                nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text;

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl            = TbImageUrl.Text;
                nodeInfo.Content             = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);

                nodeInfo.Keywords    = TbKeywords.Text;
                nodeInfo.Description = TbDescription.Text;

                nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
                nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);

                nodeInfo.LinkUrl  = TbLinkUrl.Text;
                nodeInfo.LinkType = DdlLinkType.SelectedValue;
                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
                nodeInfo.ChannelTemplateId           = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                nodeInfo.ContentTemplateId           = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                DataProvider.ChannelDao.Update(nodeInfo);
            }
            catch (Exception ex)
            {
                FailMessage(ex, $"栏目修改失败:{ex.Message}");
                LogUtils.AddSystemErrorLog(ex);
                return;
            }

            CreateManager.CreateChannel(SiteId, nodeInfo.Id);

            Body.AddSiteLog(SiteId, "修改栏目", $"栏目:{TbNodeName.Text}");

            SuccessMessage("栏目修改成功!");
            PageUtils.Redirect(ReturnUrl);
        }
Beispiel #29
0
 public void Init()
 {
     extendedAttribute = new ExtendedAttributes();
     AddActionClassesToList(extendedAttribute);
 }
Beispiel #30
0
 /// <summary>
 /// Is key associated with a value (even a null one) in the extended attributes?
 ///
 /// Note this will not return true for the inline attributes DP, GQ, AD, or PL
 /// </summary>
 /// <param name="key"> a non-null string key to check for an association </param>
 /// <returns> true if key has a value in the extendedAttributes </returns>
 public virtual bool HasExtendedAttribute(string key)
 {
     return(ExtendedAttributes.ContainsKey(key));
 }
Beispiel #31
0
        /**
         * Create Items
         *
         * @param itemIds        Array of Item and Revision IDs
         * @param itemType       Type of item to create
         *
         * @return Set of Items and ItemRevisions
         *
         * @throws ServiceException  If any partial errors are returned
         */
        public CreateItemsOutput[] createItems(ItemIdsAndInitialRevisionIds[] itemIds, String itemType)
        //       throws ServiceException
        {
            // Get the service stub
            DataManagementService dmService = DataManagementService.getService(MyFormAppSession.getConnection());
            // Populate form type
            GetItemCreationRelatedInfoResponse relatedResponse = dmService.GetItemCreationRelatedInfo(itemType, null);

            String[] formTypes = new String[0];
            if (relatedResponse.ServiceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.getItemCretionRelatedInfo returned a partial error.");
            }

            formTypes = new String[relatedResponse.FormAttrs.Length];
            for (int i = 0; i < relatedResponse.FormAttrs.Length; i++)
            {
                FormAttributesInfo attrInfo = relatedResponse.FormAttrs[i];
                formTypes[i] = attrInfo.FormType;
            }

            ItemProperties[] itemProps = new ItemProperties[itemIds.Length];
            for (int i = 0; i < itemIds.Length; i++)
            {
                // Create form in cache for form property population
                ModelObject[] forms = createForms(itemIds[i].NewItemId, formTypes[0],
                                                  itemIds[i].NewRevId, formTypes[1],
                                                  null, false);
                ItemProperties itemProperty = new ItemProperties();

                itemProperty.ClientId    = "AppX-Test";
                itemProperty.ItemId      = itemIds[i].NewItemId;
                itemProperty.RevId       = itemIds[i].NewRevId;
                itemProperty.Name        = "AppX-Test";
                itemProperty.Type        = itemType;
                itemProperty.Description = "Test Item for the SOA AppX sample application.";
                itemProperty.Uom         = "";

                // Retrieve one of form attribute value from Item master form.
                ServiceData serviceData = dmService.GetProperties(forms, new String[] { "project_id" });
                if (serviceData.sizeOfPartialErrors() > 0)
                {
                    throw new ServiceException("DataManagementService.getProperties returned a partial error.");
                }
                Property property = null;
                try
                {
                    property = forms[0].GetProperty("project_id");
                }
                catch (NotLoadedException /*ex*/) {}


                // Only if value is null, we set new value
                if (property == null || property.StringValue == null || property.StringValue.Length == 0)
                {
                    itemProperty.ExtendedAttributes = new ExtendedAttributes[1];
                    ExtendedAttributes theExtendedAttr = new ExtendedAttributes();
                    theExtendedAttr.Attributes = new Hashtable();
                    theExtendedAttr.ObjectType = formTypes[0];
                    theExtendedAttr.Attributes["project_id"] = "project_id";
                    itemProperty.ExtendedAttributes[0]       = theExtendedAttr;
                }
                itemProps[i] = itemProperty;
            }


            // *****************************
            // Execute the service operation
            // *****************************
            CreateItemsResponse response = dmService.CreateItems(itemProps, null, "");

            // before control is returned the ChangedHandler will be called with
            // newly created Item and ItemRevisions



            // The AppXPartialErrorListener is logging the partial errors returned
            // In this simple example if any partial errors occur we will throw a
            // ServiceException
            if (response.ServiceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.createItems returned a partial error.");
            }

            return(response.Output);
        }
 public static byte[] SerializeExtendedAttributes(ExtendedAttributes xattrs) => serializer.Serialize(xattrs);
Beispiel #33
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var isChanged = false;

                try
                {
                    var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId);

                    if (NodeIndexNameRow.Visible)
                    {
                        if (!nodeInfo.NodeIndexName.Equals(NodeIndexName.Text) && NodeIndexName.Text.Length != 0)
                        {
                            var nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId);
                            if (nodeIndexNameList.IndexOf(NodeIndexName.Text) != -1)
                            {
                                FailMessage("栏目修改失败,栏目索引已存在!");
                                return;
                            }
                        }
                    }

                    if (FilePathRow.Visible)
                    {
                        FilePath.Text = FilePath.Text.Trim();
                        if (!nodeInfo.FilePath.Equals(FilePath.Text) && FilePath.Text.Length != 0)
                        {
                            if (!DirectoryUtils.IsDirectoryNameCompliant(FilePath.Text))
                            {
                                FailMessage("栏目页面路径不符合系统要求!");
                                return;
                            }

                            if (PathUtils.IsDirectoryPath(FilePath.Text))
                            {
                                FilePath.Text = PageUtils.Combine(FilePath.Text, "index.html");
                            }

                            var filePathArrayList = DataProvider.NodeDao.GetAllFilePathByPublishmentSystemId(PublishmentSystemId);
                            if (filePathArrayList.IndexOf(FilePath.Text) != -1)
                            {
                                FailMessage("栏目修改失败,栏目页面路径已存在!");
                                return;
                            }
                        }
                    }

                    if (channelControl.Visible)
                    {
                        var extendedAttributes = new ExtendedAttributes();
                        var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);
                        InputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes);
                        if (extendedAttributes.Attributes.Count > 0)
                        {
                            nodeInfo.Additional.SetExtendedAttribute(extendedAttributes.Attributes);
                        }
                    }

                    if (NodeNameRow.Visible)
                    {
                        nodeInfo.NodeName = NodeName.Text;
                    }
                    if (NodeIndexNameRow.Visible)
                    {
                        nodeInfo.NodeIndexName = NodeIndexName.Text;
                    }
                    if (FilePathRow.Visible)
                    {
                        nodeInfo.FilePath = FilePath.Text;
                    }

                    if (NodeGroupNameCollectionRow.Visible)
                    {
                        var list = new ArrayList();
                        foreach (ListItem item in NodeGroupNameCollection.Items)
                        {
                            if (item.Selected)
                            {
                                list.Add(item.Value);
                            }
                        }
                        nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                    }
                    if (ImageUrlRow.Visible)
                    {
                        nodeInfo.ImageUrl = tbImageUrl.Text;
                    }
                    if (ContentRow.Visible)
                    {
                        nodeInfo.Content = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor);
                    }
                    if (Keywords.Visible)
                    {
                        nodeInfo.Keywords = Keywords.Text;
                    }
                    if (Description.Visible)
                    {
                        nodeInfo.Description = Description.Text;
                    }



                    if (LinkUrlRow.Visible)
                    {
                        nodeInfo.LinkUrl = LinkUrl.Text;
                    }
                    if (LinkTypeRow.Visible)
                    {
                        nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue);
                    }
                    if (ChannelTemplateIDRow.Visible)
                    {
                        nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0;
                    }
                    if (ContentTemplateIDRow.Visible)
                    {
                        nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0;
                    }

                    DataProvider.NodeDao.UpdateNodeInfo(nodeInfo);

                    Body.AddSiteLog(PublishmentSystemId, _nodeId, 0, "修改栏目", $"栏目:{nodeInfo.NodeName}");

                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, $"栏目修改失败:{ex.Message}");
                    LogUtils.AddErrorLog(ex);
                }

                if (isChanged)
                {
                    CreateManager.CreateChannel(PublishmentSystemId, _nodeId);

                    if (string.IsNullOrEmpty(_returnUrl))
                    {
                        PageUtils.CloseModalPage(Page);
                    }
                    else
                    {
                        PageUtils.CloseModalPageAndRedirect(Page, _returnUrl);
                    }
                }
            }
        }
        public string NewExtendedAttributes(string OwnerID, string OwnerTable, string Property, string PropertyValue,
            string ValueLinkID, string Qualifier, string DataSourceID, string Notes)
        {
            ExtendedAttributes newExtendedAttributes = new ExtendedAttributes();

            sysInfo SysInfoTable = new sysInfo(m_theWorkspace);
            newExtendedAttributes.ExtendedAttributes_ID = SysInfoTable.ProjAbbr + ".ExtendedAttributes." + SysInfoTable.GetNextIdValue("ExtendedAttributes");

            newExtendedAttributes.OwnerID = OwnerID;
            newExtendedAttributes.OwnerTable = OwnerTable;
            newExtendedAttributes.Property = Property;
            newExtendedAttributes.PropertyValue = PropertyValue;
            newExtendedAttributes.ValueLinkID = ValueLinkID;
            newExtendedAttributes.Qualifier = Qualifier;
            newExtendedAttributes.DataSourceID = DataSourceID;
            newExtendedAttributes.Notes = Notes;

            m_ExtendedAttributesDictionary.Add(newExtendedAttributes.ExtendedAttributes_ID, newExtendedAttributes);

            return newExtendedAttributes.ExtendedAttributes_ID;
        }