protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["PiggyBagId"] == null) { ElementInformationPlaceHolder.Controls.Add(new LiteralControl("No entity token.... nothing to do.... ")); return; } Guid piggybagId = new Guid(Request.QueryString["PiggyBagId"]); string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.showinfo", piggybagId)); string[] showinfo = C1File.ReadAllLines(filename); string serializedEntityToken = showinfo[0]; string serializedPiggyBag = showinfo[1]; EntityToken entityToken = EntityTokenSerializer.Deserialize(serializedEntityToken); Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedPiggyBag); Dictionary <string, string> piggybag = new Dictionary <string, string>(); foreach (var kvp in dic) { piggybag.Add(kvp.Key, StringConversionServices.DeserializeValueString(kvp.Value)); } string entityTokenHtml = entityToken.GetPrettyHtml(piggybag); ElementInformationPlaceHolder.Controls.Add(new LiteralControl(entityTokenHtml)); }
/// <exclude /> public override string Serialize() { StringBuilder sb = new StringBuilder(); DoSerialize(sb); if (!_payload.IsNullOrEmpty()) { StringConversionServices.SerializeKeyValuePair(sb, "Payload", _payload, typeof(string)); } foreach (var kvp in this.GroupingValues.SortByKeys()) { if (kvp.Value != null) { StringConversionServices.SerializeKeyValuePair(sb, kvp.Key, kvp.Value, kvp.Value.GetType()); } else { StringConversionServices.SerializeKeyValuePair(sb, kvp.Key, _magicNullValue, typeof(string)); } } return(sb.ToString()); }
private void packageInfoCodeActivity_ExecuteCode(object sender, EventArgs e) { var package = PackageCreatorFacade.GetPackageInformation("New"); if (!string.IsNullOrEmpty(Payload)) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(Payload); if (dic.ContainsKey("Name")) { var name = StringConversionServices.DeserializeValueString(dic["Name"]); package.Name = name; if (dic.ContainsKey("GroupName")) { var readMoreUrl = StringConversionServices.DeserializeValueString(dic["ReadMoreUrl"]); package.ReadMoreUrl = readMoreUrl; var groupName = StringConversionServices.DeserializeValueString(dic["GroupName"]); package.GroupName = groupName; } else { package.GroupName = name.Substring(0, name.LastIndexOf(".")); } } } if (this.BindingExist("Package") == false) { this.Bindings.Add("Package", package); } }
private void saveInfoCodeActivity_ExecuteCode(object sender, EventArgs e) { var package = this.GetBinding <PackageInformation>("Package"); PackageCreatorFacade.SavePackageInformation(package); if (!string.IsNullOrEmpty(Payload)) { var type = StringConversionServices.DeserializeValueString(StringConversionServices.ParseKeyValueCollection(Payload)["ActionToken"]); ActionToken actionToken = ActionTokenSerializer.Deserialize(type); ActionExecutorFacade.Execute(package.GetEntityToken(), actionToken, WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId)); } else { ActionExecutorFacade.Execute( package.GetEntityToken(), new SetActivePackageActionToken(), WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId)); } SpecificTreeRefresher treeRefresher = this.CreateSpecificTreeRefresher(); treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken()); }
/// <summary> /// Serialize to string /// </summary> /// <returns>Serialized as string</returns> public string Serialize() { IDataId dataId = EnsureDataIdType(_dataId); if ((_serializedData == null) || (dataId != _dataId)) { string s = SerializationFacade.Serialize(this.DataId); System.Text.StringBuilder sb = new System.Text.StringBuilder(); StringConversionServices.SerializeKeyValuePair(sb, "_dataId_", s); StringConversionServices.SerializeKeyValuePair(sb, "_dataIdType_", TypeManager.SerializeType(this.DataId.GetType())); if (_providerName != DataProviderRegistry.DefaultDynamicTypeDataProviderName) { StringConversionServices.SerializeKeyValuePair(sb, "_providerName_", _providerName); } StringConversionServices.SerializeKeyValuePair(sb, "_interfaceType_", TypeManager.SerializeType(_interfaceType)); StringConversionServices.SerializeKeyValuePair(sb, "_dataScope_", DataScopeIdentifier.Serialize()); StringConversionServices.SerializeKeyValuePair(sb, "_localeScope_", LocaleScope.Name); _serializedData = sb.ToString(); } return(_serializedData); }
internal static PageMetaDataDescription Deserialize(string serializedData) { // DataAssociationVisabilityRuleType is here for backwards compatibility - after 1.3 its not used any more Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); if (((dic.ContainsKey("DataAssociationVisabilityRuleType") == false) && (dic.ContainsKey("_PageMetaDataDescriptionType_") == false)) || (dic.ContainsKey("_StartLevel_") == false) || (dic.ContainsKey("_Levels_") == false)) { throw new ArgumentException(string.Format("The serializedData is not a serialized '{0}'", typeof(PageMetaDataDescription)), "serializedData"); } string serializedDataAssociationVisabilityRuleType; if (dic.ContainsKey("_PageMetaDataDescriptionType_")) { serializedDataAssociationVisabilityRuleType = StringConversionServices.DeserializeValueString(dic["_PageMetaDataDescriptionType_"]); } else { serializedDataAssociationVisabilityRuleType = StringConversionServices.DeserializeValueString(dic["DataAssociationVisabilityRuleType"]); } PageMetaDataDescriptionType type = (PageMetaDataDescriptionType)Enum.Parse(typeof(PageMetaDataDescriptionType), serializedDataAssociationVisabilityRuleType); string serializedStartLevel = StringConversionServices.DeserializeValueString(dic["_StartLevel_"]); string serializedLevels = StringConversionServices.DeserializeValueString(dic["_Levels_"]); int startLevel = int.Parse(serializedStartLevel); int levels = int.Parse(serializedLevels); return(new PageMetaDataDescription(type, startLevel, levels)); }
private void codeActivity_ExecuteCode(object sender, EventArgs e) { var type = StringConversionServices.DeserializeValueType(StringConversionServices.ParseKeyValueCollection(Payload)["ActionToken"]); ActionToken actionToken = (ActionToken)Activator.CreateInstance(type); ActionExecutorFacade.Execute(this.EntityToken, actionToken, WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId)); }
public static ActionToken Deserialize(string serializedData) { var dic = StringConversionServices.ParseKeyValueCollection(serializedData); var cultureName = StringConversionServices.DeserializeValueString(dic["_cultureName"]); return(new AddLocalizationActionToken(cultureName)); }
public override string Serialize() { var sb = new StringBuilder(); StringConversionServices.SerializeKeyValuePair <string>(sb, "_cultureName", CultureName); return(sb.ToString()); }
} // Optional /// <exclude /> protected override void OnAddAction(Action <ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext) { var payload = new StringBuilder(); this.Serialize(payload); StringConversionServices.SerializeKeyValuePair(payload, "_IconResourceName_", Icon.ResourceName); if (!String.IsNullOrEmpty(CustomFormMarkupPath)) { StringConversionServices.SerializeKeyValuePair(payload, "_CustomFormMarkupPath_", CustomFormMarkupPath); actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericEditDataWorkflow"), this.PermissionTypes) { Payload = payload.ToString() })) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); } else { actionAdder(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Edit, this.PermissionTypes))) { VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext) }); } }
private void Initialize() { if (_dataTypeDescriptorFormsHelper == null) { if (String.IsNullOrEmpty(this.Payload)) { throw new InvalidOperationException("The interface type should be a part of the workflows payload"); } Dictionary <string, string> serializedValues = StringConversionServices.ParseKeyValueCollection(this.Payload); _dataPayload = serializedValues; } if (!PermissionsFacade.GetPermissionsForCurrentUser(EntityToken).Contains(PermissionType.Publish) || !typeof(IPublishControlled).IsAssignableFrom(InterfaceType)) { FormData formData = WorkflowFacade.GetFormData(InstanceId, true); if (formData.ExcludedEvents == null) { formData.ExcludedEvents = new List <string>(); } formData.ExcludedEvents.Add("SaveAndPublish"); } }
public override string Serialize() { StringBuilder stringBuilder = new StringBuilder(base.Serialize()); StringConversionServices.SerializeKeyValuePair(stringBuilder, "_PageTypeId_", _pageTypeId); return(stringBuilder.ToString()); }
/// <exclude /> public string Serialize() { StringBuilder stringBuilder = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(stringBuilder, "_ActionIdentifier_", _value); return(stringBuilder.ToString()); }
public static ActionToken Deserialize(string serializedData) { var dic = StringConversionServices.ParseKeyValueCollection(serializedData); var name = StringConversionServices.DeserializeValueString(dic["name"]); return(new DownloadPackageActionToken(name)); }
public static FlowToken Deserialize(string serialziedFlowToken, bool includeHashValue) { if (string.IsNullOrEmpty(serialziedFlowToken)) { throw new ArgumentNullException("serialziedFlowToken"); } Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serialziedFlowToken); if ((dic.ContainsKey("flowTokenType") == false) || (dic.ContainsKey("flowToken") == false) || ((includeHashValue) && (dic.ContainsKey("flowTokenHash") == false))) { throw new ArgumentException("The serialziedFlowToken is not a serialized flowToken", "serialziedFlowToken"); } string flowTokenTypeString = StringConversionServices.DeserializeValueString(dic["flowTokenType"]); string flowTokenString = StringConversionServices.DeserializeValueString(dic["flowToken"]); if (includeHashValue) { string flowTokenHash = StringConversionServices.DeserializeValueString(dic["flowTokenHash"]); HashValue hashValue = HashValue.Deserialize(flowTokenHash); if (HashSigner.ValidateSignedHash(flowTokenString, hashValue) == false) { throw new SecurityException("Serialized flow token is tampered"); } } Type flowType = TypeManager.GetType(flowTokenTypeString); MethodInfo methodInfo = flowType.GetMethod("Deserialize", BindingFlags.Public | BindingFlags.Static); if (methodInfo == null || !(typeof(FlowToken).IsAssignableFrom(methodInfo.ReturnType))) { throw new InvalidOperationException(string.Format("The flow token {0} is missing a public static Deserialize method taking a string as parameter and returning an {1}", flowType, typeof(FlowToken))); } FlowToken flowToken; try { flowToken = (FlowToken)methodInfo.Invoke(null, new object[] { flowTokenString }); } catch (Exception ex) { throw new InvalidOperationException(string.Format("The flow token {0} is missing a public static Deserialize method taking a string as parameter and returning an {1}", flowType, typeof(FlowToken)), ex); } if (flowToken == null) { throw new InvalidOperationException(string.Format("public static Deserialize method taking a string as parameter and returning an {1} on the flow token {0} did not return an object", flowType, typeof(FlowToken))); } return(flowToken); }
/// <exclude /> public static EntityToken Deserialize(string serialziedEntityToken, bool includeHashValue) { if (string.IsNullOrEmpty(serialziedEntityToken)) { throw new ArgumentNullException("serialziedEntityToken"); } Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serialziedEntityToken); if (!dic.ContainsKey("entityTokenType") || !dic.ContainsKey("entityToken") || (includeHashValue && !dic.ContainsKey("entityTokenHash"))) { throw new ArgumentException("Failed to deserialize the value. Is has to be searized with EntityTokenSerializer.", "serialziedEntityToken"); } string entityTokenTypeString = StringConversionServices.DeserializeValueString(dic["entityTokenType"]); string entityTokenString = StringConversionServices.DeserializeValueString(dic["entityToken"]); if (includeHashValue) { string entityTokenHash = StringConversionServices.DeserializeValueString(dic["entityTokenHash"]); HashValue hashValue = HashValue.Deserialize(entityTokenHash); if (!HashSigner.ValidateSignedHash(entityTokenString, hashValue)) { throw new SecurityException("Serialized entity token is tampered"); } } Type entityType = TypeManager.GetType(entityTokenTypeString); MethodInfo methodInfo = entityType.GetMethod("Deserialize", BindingFlags.Public | BindingFlags.Static); if (methodInfo == null) { throw new InvalidOperationException(string.Format("The entity token {0} is missing a public static Deserialize method taking a string as parameter and returning an {1}", entityType, typeof(EntityToken))); } EntityToken entityToken; try { entityToken = (EntityToken)methodInfo.Invoke(null, new object[] { entityTokenString }); } catch (Exception ex) { throw new EntityTokenSerializerException("Failed to deserialize entity token '{0}'".FormatWith(entityTokenString), ex); } if (entityToken == null) { throw new EntityTokenSerializerException("Deserialization function returned null value. EntityToken: '{0}'".FormatWith(entityTokenString)); } return(entityToken); }
public object Deserialize(string serializedObject) { Dictionary <string, string> serializationData = StringConversionServices.ParseKeyValueCollection(serializedObject); if (serializationData.ContainsKey("_IsNew_") == false) { throw new ArgumentException("serializedObject is of wrong format"); } IData data = null; bool isNew = StringConversionServices.DeserializeValueBool(serializationData["_IsNew_"]); if (isNew) { if (serializationData.ContainsKey("_Type_") == false) { throw new ArgumentException("serializedObject is of wrong format"); } string typeString = StringConversionServices.DeserializeValueString(serializationData["_Type_"]); Type interfaceType = TypeManager.GetType(typeString); data = DataFacade.BuildNew(interfaceType); } else { if (serializationData.ContainsKey("_DataSourceId_") == false) { throw new ArgumentException("serializedObject is of wrong format"); } string dataSourceIdString = StringConversionServices.DeserializeValueString(serializationData["_DataSourceId_"]); DataSourceId dataSourceId = DataSourceId.Deserialize(dataSourceIdString); data = DataFacade.GetDataFromDataSourceId(dataSourceId); if (data == null) { throw new DataSerilizationException(string.Format("Failed to get the '{0}' with the given data source '{1}', data might have been deleted sinse this serialized data was created", dataSourceId.InterfaceType, dataSourceId)); } } Type dataType = data.DataSourceId.InterfaceType; DeserializePropertiesFromInterface(serializationData, dataType, false, data); foreach (var inheritedInterface in dataType.GetInterfaces()) { if (inheritedInterface == typeof(IData)) { continue; // DataSourceId is already deserialized so we're skipping it here } DeserializePropertiesFromInterface(serializationData, inheritedInterface, true, data); } return(data); }
public ConfirmWorkflowActionToken(string confirmMessage, Type actionTokenType) : base(typeof(ConfirmPackageWorkflow), new PermissionType[] { PermissionType.Administrate }) { StringBuilder sb = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(sb, "ConfirmMessage", confirmMessage); StringConversionServices.SerializeKeyValuePair <Type>(sb, "ActionToken", actionTokenType); Payload = sb.ToString(); }
public static EntityToken Deserialize(string serializedData) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); var xpath = StringConversionServices.DeserializeValueString(dic["_xpath"]); var source = StringConversionServices.DeserializeValueString(dic["_source"]); return(new XmlNodeAttributeProviderEntityToken(xpath, source)); }
public override string Serialize() { StringBuilder sb = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(sb, "Name", this.FunctionName); StringConversionServices.SerializeKeyValuePair(sb, "IsWidget", this.IsWidgetFunction); return(sb.ToString()); }
public static ActionToken Deserialize(string serializedData) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); string name = StringConversionServices.DeserializeValueString(dic["Name"]); bool isWidget = StringConversionServices.DeserializeValueBool(dic["IsWidget"]); return(new FunctionInfoActionToken(name, isWidget)); }
/// <exclude /> public override string Serialize() { StringBuilder stringBuilder = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(stringBuilder, "_ActionIdentifier_", ActionIdentifier.Serialize()); StringConversionServices.SerializeKeyValuePair(stringBuilder, "_PermissionTypes_", PermissionTypes.SerializePermissionTypes()); return(stringBuilder.ToString()); }
public override string Serialize() { StringBuilder sb = new StringBuilder(); StringConversionServices.SerializeKeyValuePair <Guid>(sb, "_xpath", _id); StringConversionServices.SerializeKeyValuePair <Guid>(sb, "_source", _source); return(sb.ToString()); }
public static ActionToken Deserialize(string serializedData) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); string categoryName = StringConversionServices.DeserializeValueString(dic["_categoryName"]); string name = StringConversionServices.DeserializeValueString(dic["_name"]); return(new PackageCreatorActionToken(categoryName, name)); }
public override string Serialize() { StringBuilder sb = new StringBuilder(); StringConversionServices.SerializeKeyValuePair <string>(sb, "_categoryName", _categoryName); StringConversionServices.SerializeKeyValuePair <string>(sb, "_name", _name); return(sb.ToString()); }
/// <exclude /> public static StoreFieldType Deserialize(string serializedData) { using (TimerProfiler timerProfiler = TimerProfilerFacade.CreateTimerProfiler()) { if (string.IsNullOrEmpty(serializedData)) { throw new ArgumentNullException("serializedData"); } Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); if (dic.ContainsKey("PhysicalStoreType") == false) { throw new ArgumentException("Wrong serialized format"); } string physicalStoreFieldTypeString = StringConversionServices.DeserializeValue <string>(dic["PhysicalStoreType"]); PhysicalStoreFieldType physicalStoreFieldType = (PhysicalStoreFieldType)Enum.Parse(typeof(PhysicalStoreFieldType), physicalStoreFieldTypeString); switch (physicalStoreFieldType) { case PhysicalStoreFieldType.String: if (dic.ContainsKey("Length") == false) { throw new ArgumentException("Wrong serialized format"); } int length = StringConversionServices.DeserializeValueInt(dic["Length"]); return(new StoreFieldType(physicalStoreFieldType, length)); case PhysicalStoreFieldType.Decimal: if (dic.ContainsKey("Precision") == false) { throw new ArgumentException("Wrong serialized format"); } if (dic.ContainsKey("Scale") == false) { throw new ArgumentException("Wrong serialized format"); } int precision = StringConversionServices.DeserializeValueInt(dic["Precision"]); int scale = StringConversionServices.DeserializeValueInt(dic["Scale"]); return(new StoreFieldType(physicalStoreFieldType, precision, scale)); case PhysicalStoreFieldType.Boolean: case PhysicalStoreFieldType.DateTime: case PhysicalStoreFieldType.Guid: case PhysicalStoreFieldType.Integer: case PhysicalStoreFieldType.LargeString: case PhysicalStoreFieldType.Long: return(new StoreFieldType(physicalStoreFieldType)); } throw new NotImplementedException(); } }
/// <exclude /> public override string Serialize() { StringBuilder sb = new StringBuilder(); DoSerialize(sb); StringConversionServices.SerializeKeyValuePair(sb, "root", RelativeRootPath); return(sb.ToString()); }
/// <exclude /> public override string Serialize() { StringBuilder builder = new StringBuilder(); StringConversionServices.SerializeKeyValuePair <string>(builder, "id", _id); StringConversionServices.SerializeKeyValuePair <string>(builder, "source", _source); StringConversionServices.SerializeKeyValuePair <string>(builder, "connectionId", _connectionId); return(builder.ToString()); }
/// <exclude /> public static EntityToken Deserialize(string serializedData) { IDictionary <string, string> result = StringConversionServices.ParseKeyValueCollection(serializedData); string id = StringConversionServices.DeserializeValueString(result["id"]); string source = StringConversionServices.DeserializeValueString(result["source"]); string connectionId = StringConversionServices.DeserializeValueString(result["connectionId"]); return(new SqlFunctionProviderFolderEntityToken(id, source, connectionId)); }
public ConfirmWorkflowActionToken(string confirmMessage, Type type, IEnumerable <PermissionType> permmissionType) : base(typeof(ConfirmWorkflow), permmissionType) { var sb = new StringBuilder(); StringConversionServices.SerializeKeyValuePair(sb, "ConfirmMessage", confirmMessage); StringConversionServices.SerializeKeyValuePair <Type>(sb, "Type", type); Payload = sb.ToString(); }