Пример #1
0
		protected void DoCustomElements(TextWriter contentsStream, ICmObject currentObject, XmlNode node)
		{
			string sClass = XmlUtils.GetManditoryAttributeValue(node, "class");
			string sType = XmlUtils.GetOptionalAttributeValue(node, "fieldType", "");
			int[] flids;
			if (!m_customFlids.TryGetValue(sClass + sType, out flids))
			{
				int clid = 0;
				try
				{
					clid = m_mdc.GetClassId(sClass);
				}
				catch
				{
					clid = 0;
				}
				if (clid == 0)
				{
					m_customFlids[sClass + sType] = new int[0];
					return; // we don't know what to do!
				}
				int[] flidsT = m_mdc.GetFields(clid, true, (int)CellarPropertyTypeFilter.All);
				List<int> rgcustom = new List<int>();
				for (int i = 0; i < flidsT.Length; ++i)
				{
					int flid = flidsT[i];
					if (!m_mdc.IsCustom(flid))
						continue;
					CellarPropertyType cpt = (CellarPropertyType)m_mdc.GetFieldType(flid);
					if ((sType == "simplestring" &&
						cpt != CellarPropertyType.Unicode &&
						cpt != CellarPropertyType.String) ||
						(sType == "mlstring" &&
						cpt != CellarPropertyType.MultiString &&
						cpt != CellarPropertyType.MultiUnicode))
					{
						continue;
					}
					rgcustom.Add(flid);
				}
				flids = rgcustom.ToArray();
				m_customFlids[sClass + sType] = flids;
			}
			if (flids.Length == 0)
				return; // nothing to do.

			for (int i = 0; i < flids.Length; ++i)
			{
				int flid = flids[i];
				XmlNode parentNode = node.Clone();
				string labelName = m_mdc.GetFieldLabel(flid);
				string fieldName = m_mdc.GetFieldName(flid);
				if (String.IsNullOrEmpty(labelName))
					labelName = fieldName;
				string sfMarker = m_customSfms[flid];
				ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("${fieldName}", fieldName);
				ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("${label}", labelName);
				ReplaceSubstringInAttr visitorSfm = new ReplaceSubstringInAttr("${sfm}", sfMarker);
				foreach (XmlNode xn in parentNode.ChildNodes)
				{
					XmlUtils.VisitAttributes(xn, visitorFn);
					XmlUtils.VisitAttributes(xn, visitorLab);
					XmlUtils.VisitAttributes(xn, visitorSfm);
				}
				if (parentNode.InnerText.Contains("${definition}"))
					FillInCustomFieldDefinition(parentNode, flid);
				if (parentNode.InnerText.Contains("${description}"))
					FillInCustomFieldDescription(parentNode, flid);
				DoChildren(contentsStream, currentObject, parentNode, null);
			}
		}
Пример #2
0
		protected void DoCustomElements(TextWriter contentsStream, CmObject currentObject, XmlNode node)
		{
			string sClass = XmlUtils.GetManditoryAttributeValue(node, "class");
			string sType = XmlUtils.GetOptionalAttributeValue(node, "fieldType", "");
			int[] flids;
			if (!m_customFlids.TryGetValue(sClass + sType, out flids))
			{
				int clid = 0;
				try
				{
					clid = (int)m_cache.MetaDataCacheAccessor.GetClassId(sClass);
				}
				catch
				{
					clid = 0;
				}
				if (clid == 0)
				{
					m_customFlids[sClass + sType] = new int[0];
					return;		// we don't know what to do!
				}
				StringBuilder sbTypes = new StringBuilder();
				switch (sType)
				{
					case "mlstring":
						sbTypes.AppendFormat(" AND Type IN ({0}, {1}, {2}, {3})",
							(int)CellarModuleDefns.kcptMultiUnicode,
							(int)CellarModuleDefns.kcptMultiBigUnicode,
							(int)CellarModuleDefns.kcptMultiString,
							(int)CellarModuleDefns.kcptMultiBigString);
						break;
					case "simplestring":
						sbTypes.AppendFormat(" AND Type IN ({0}, {1})",
							(int)CellarModuleDefns.kcptString,
							(int)CellarModuleDefns.kcptBigString);
						break;
				}
				StringBuilder sb = new StringBuilder("SELECT Id From Field$ WHERE Custom=1 AND Class=");
				sb.Append(clid.ToString());
				if (sbTypes.Length > 0)
					sb.Append(sbTypes.ToString());
				string sql = sb.ToString();
				flids = DbOps.ReadIntArrayFromCommand(m_cache, sql, null);
				m_customFlids[sClass + sType] = flids;
			}
			if (flids.Length == 0)
				return;		// nothing to do.
			for (int i = 0; i < flids.Length; ++i)
			{
				XmlNode parentNode = node.Clone();
				uint flid = (uint)flids[i];
				string labelName = m_cache.MetaDataCacheAccessor.GetFieldLabel(flid);
				string fieldName = m_cache.MetaDataCacheAccessor.GetFieldName(flid);
				string className = m_cache.MetaDataCacheAccessor.GetOwnClsName(flid);
				if (String.IsNullOrEmpty(labelName))
					labelName = fieldName;
				string sfMarker = "zz";
				if (fieldName.StartsWith("custom"))
				{
					sfMarker = String.Format("z{0}", fieldName.Substring(6));
					if (sfMarker == "z")
						sfMarker = "z0";
				}
				ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("${fieldName}", fieldName);
				ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("${label}", labelName);
				ReplaceSubstringInAttr visitorSfm = new ReplaceSubstringInAttr("${sfm}", sfMarker);
				foreach (XmlNode xn in parentNode.ChildNodes)
				{
					XmlUtils.VisitAttributes(xn, visitorFn);
					XmlUtils.VisitAttributes(xn, visitorLab);
					XmlUtils.VisitAttributes(xn, visitorSfm);
				}
				if (parentNode.InnerText.Contains("${definition}"))
					FillInCustomFieldDefinition(parentNode, flid);
				if (parentNode.InnerText.Contains("${description}"))
					FillInCustomFieldDescription(parentNode, flid);
				DoChildren(contentsStream, currentObject, parentNode, null);
			}
		}
Пример #3
0
		/// <summary>
		///
		/// </summary>
		/// <param name="output"></param>
		/// <param name="labelName"></param>
		/// <param name="fieldName"></param>
		/// <param name="customFieldId"></param>
		/// <param name="className"></param>
		protected void ReplaceParamsInAttributes(XmlNode output, string labelName, string fieldName, int customFieldId, string className)
		{
			SetupWsParams(output, customFieldId);
			ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("$fieldName", fieldName);
			XmlUtils.VisitAttributes(output, visitorFn);
			AppendClassAttribute(output, fieldName, className);
			ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("$label", labelName);
			XmlUtils.VisitAttributes(output, visitorLab);
			if (customFieldId != 0 && m_mdc is IFwMetaDataCacheManaged)
			{
				IFwMetaDataCacheManaged mdc = m_mdc as IFwMetaDataCacheManaged;
				if (mdc.IsCustom(customFieldId) && mdc.GetDstClsId(customFieldId) != 0)
				{
					Guid guidList = (m_mdc as IFwMetaDataCacheManaged).GetFieldListRoot(customFieldId);
					if (guidList != Guid.Empty)
					{
						string targetList;
						ICmPossibilityList list = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>().GetObject(guidList);
						if (list.Owner != null)
							targetList = String.Format("{0}.{1}", list.Owner.ClassName, mdc.GetFieldName(list.OwningFlid));
						else
							targetList = String.Format("unowned.{0}", guidList.ToString());
						ReplaceSubstringInAttr visitorTarg = new ReplaceSubstringInAttr("$targetList", targetList);
						XmlUtils.VisitAttributes(output, visitorTarg);
					}
				}
			}
		}
Пример #4
0
		private void ReplaceParamsInAttributes(XmlNode output, string labelName, string fieldName, uint customFieldId, string className)
		{
			SetupWsParams(output, customFieldId);
			ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("$fieldName", fieldName);
			XmlUtils.VisitAttributes(output, visitorFn);
			AppendClassAttribute(output, fieldName, className);
			ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("$label", labelName);
			XmlUtils.VisitAttributes(output, visitorLab);
		}