private SourceCode.SmartObjects.Authoring.SmartObjectDefinition CreateSmartBoxSmartObject(SourceCode.SmartObjects.Management.SmartObjectManagementServer SmartObjectManagementSvr, K2Field.Apps.Framework.Build.SmartObjectDefinition SmO, string DeploymentCategory) { ServiceInstance serviceInstance = ServiceInstance.Create(SmartObjectManagementSvr.GetServiceInstanceForExtend(SmO.ServiceInstanceId, string.Empty)); ExtendObject extendObject = serviceInstance.GetCreateExtender(); // do set ID here - set on SmartObjectDefinition - extender is specifically for SmartBox //extendObject.Guid = SmO.Id; extendObject.Name = SmO.SystemName; extendObject.Metadata.DisplayName = SmO.DisplayName; extendObject.Metadata.Description = SmO.Description; foreach(K2Field.Apps.Framework.Build.SmartObjectProperty prop in SmO.Properties) { ExtendObjectProperty SoProp = new ExtendObjectProperty(); SoProp.Guid = prop.Id; SoProp.Name = prop.SystemName.Replace(" ", "_").Replace(".", "_"); SoProp.Metadata.DisplayName = prop.DisplayName; SoProp.Type = (PropertyDefinitionType)prop.DataType; SoProp.ExtendType = (SourceCode.SmartObjects.Authoring.ExtendPropertyType)prop.ExtendType; if (prop.DataType == SmODataType.Text) { if (prop.MaxSize.HasValue && prop.MaxSize.Value > 0) { SoProp.Metadata.AddServiceElement("maxsize", prop.MaxSize.Value.ToString()); } else { SoProp.Metadata.AddServiceElement("maxsize", "200"); } } if (!extendObject.Properties.ContainsName(prop.SystemName)) { extendObject.Properties.Add(SoProp); } } SourceCode.SmartObjects.Authoring.SmartObjectDefinition smoDefinition = new SourceCode.SmartObjects.Authoring.SmartObjectDefinition(); try { // Create SmartObject Definition smoDefinition.Create(extendObject); // must set the SmartObject Id here smoDefinition.Guid = SmO.Id; smoDefinition.AddDeploymentCategory(DeploymentCategory); smoDefinition.Build(); } catch (SmartObjectDefinitionException defEx) { MessageBox.Show(defEx.Message); throw; } return smoDefinition; }
public static K2Field CreateK2Field(Type valueType) { K2Field field = new K2Field(); field.ValueType = valueType; return(field); }
public static K2Field CreateK2Field(Type valueType, params K2FieldPart[] fieldParts) { K2Field field = new K2Field(fieldParts); field.ValueType = valueType; return(field); }
public override T Clone <T>() { PowerShellEventItem item = base.Clone <PowerShellEventItem>(); if (!K2Field.IsNullOrEmpty(_powerShellScript)) { item.PowerShellScript = _powerShellScript.Clone <K2Field>(); } if (_inputVariables != null) { foreach (VariableItem varItem in _inputVariables) { item.InputVariables.Add(varItem.Clone <VariableItem>()); } } if (_outputVariables != null) { foreach (VariableItem varItem in _outputVariables) { item.OutputVariables.Add(varItem.Clone <VariableItem>()); } } return(item as T); }
private K2FieldPart Simplify(K2FieldPart fieldPart) { if (!(fieldPart is K2Field)) { return(fieldPart); } K2Field field = (K2Field)fieldPart; while (field.Parts.Count > 0) { if (field.Parts.Count != 1) { return(fieldPart); } if (field.Parts[0] is K2Field) { field = (K2Field)field.Parts[0]; } else { return(field.Parts[0]); } } return(field); }
private Type ResolveTypeSupportingObject(K2Field field) { Type valueType; if (Simplify(field) == null) { valueType = typeof(string); } else { valueType = Simplify(field).ValueType; } if (valueType == null) { valueType = typeof(object); } if (valueType.IsArray && (valueType != typeof(byte[]))) { valueType = valueType.GetElementType(); } if (valueType == typeof(Uri)) { valueType = typeof(string); } return(valueType); }
private static K2Field CreateK2Field <TValueType>(K2FieldPart fieldPart) { K2Field field = new K2Field(fieldPart); field.ValueType = typeof(TValueType); return(field); }
protected override void OnSave(ISerializationInfo content) { base.OnSave(content); if (!K2Field.IsNullOrEmpty(SmartObjectServer)) { content.SetProperty("SmartObjectServer", SmartObjectServer); } if (!K2Field.IsNullOrEmpty(CRMFunctionsSmartObject)) { content.SetProperty("CRMFunctionsSmartObject", CRMFunctionsSmartObject); } if (!K2Field.IsNullOrEmpty(CRMServerURL)) { content.SetProperty("CRMServerURL", CRMServerURL); } if (!K2Field.IsNullOrEmpty(CRMOrganisation)) { content.SetProperty("CRMOrganisation", CRMOrganisation); } if (!K2Field.IsNullOrEmpty(CRMEntityId)) { content.SetProperty("CRMEntityId", CRMEntityId); } if (!K2Field.IsNullOrEmpty(CRMEntityType)) { content.SetProperty("CRMEntityType", CRMEntityType); } //if (!K2Field.IsNullOrEmpty(CustomServiceURL)) //{ // content.SetProperty("CustomServiceURL", CustomServiceURL); //} }
protected override void OnSave(Framework.ISerializationInfo content) { base.OnSave(content); if (!K2Field.IsNullOrEmpty(_variableValue)) { content.SetProperty(VARIABLEVALUE, _variableValue); } if (!string.IsNullOrEmpty(_variableName)) { content.SetProperty(VARIABLENAME, _variableName); } }
protected override void OnLoad(Framework.ISerializationInfo content) { base.OnLoad(content); if (content.HasProperty(VARIABLEVALUE)) { this.VariableValue = (K2Field)content.GetPropertyAsPersistableObject(VARIABLEVALUE); } if (content.HasProperty(VARIABLENAME)) { this.Name = content.GetPropertyAsString(VARIABLENAME); } }
protected override void Dispose(bool disposing) { if (disposing) { if (_variableValue != null) { _variableValue.Dispose(); } } _variableName = null; _variableValue = null; base.Dispose(disposing); }
protected override void OnSave(ISerializationInfo content) { base.OnSave(content); if (!K2Field.IsNullOrEmpty(_powerShellScript)) { content.SetProperty(POWERSHELLSCRIPT, _powerShellScript); } if (_inputVariables != null && _inputVariables.Count > 0) { content.SetListProperty(INPUTVARIABLES, _inputVariables); } if (_outputVariables != null && _outputVariables.Count > 0) { content.SetListProperty(OUTPUTVARIABLES, _outputVariables); } }
//private string _SN = null; //public string SN //{ // get // { // return _SN; // } // set // { // base.OnNotifyPropertyChanged<string>("SN", ref _SN, value); // } //} #endregion #region Override Methods protected override void Dispose(bool disposing) { if (base.IsDisposed) { return; } _ActivityName = null; _ProcessName = null; _SmartObjectServer = null; _CRMFunctionsSmartObject = null; _ProcessName = null; _ActivityName = null; _CRMEntityId = null; _CRMEntityType = null; _CRMEntityForm = null; _CRMFormURL = null; _CRMOrganisation = null; _CRMServerURL = null; _CRMCustomSNParameter = null; _InternetPlatform = null; _SN = null; _TaskCategory = null; _TaskDescription = null; _TaskDueDate = null; _TaskDuration = null; _TaskOwner = null; _TaskOwnerFQN = null; _TaskOwnerId = null; _TaskPriority = null; _TaskRegarding = null; _TaskRegardingId = null; _TaskState = null; _TaskStatus = null; _TaskSubcategory = null; _TaskSubject = null; //ALWAYS call the base.Dispose(disposing); method last base.Dispose(disposing); }
public static K2Field CreateConfigSettingField <T>(K2Field k2field) { K2Field newField = new K2Field(); if (k2field != null) { newField.Parts.AddRange(k2field.Parts.ToArray()); } if (newField.Parts.Count == 0) { ValueTypePart val = new ValueTypePart(); val.Value = default(T); newField.Parts.Add(val); } newField.ValueType = typeof(T); foreach (K2FieldPart part in newField.Parts) { part.ValueType = typeof(T); } return(newField); }
public VariableItem(string variableName, K2Field variableValue) : this() { this.Name = variableName; this.VariableValue = variableValue; }
//When your project is saved, this override determines which properties you have defined //gets saved and can ba accessed once the project is reopened protected override void OnSave(ISerializationInfo content) { base.OnSave(content); if (!string.IsNullOrEmpty(InternetPlatform)) { content.SetProperty("InternetPlatform", InternetPlatform); } content.SetProperty("InsertSN", InsertSN); content.SetProperty("CreateTasks", CreateTasks); if (!K2Field.IsNullOrEmpty(SN)) { content.SetProperty("SN", SN); } if (!K2Field.IsNullOrEmpty(ActivityName)) { content.SetProperty("ActivityName", ActivityName); } if (!K2Field.IsNullOrEmpty(ProcessName)) { content.SetProperty("ProcessName", ProcessName); } if (!K2Field.IsNullOrEmpty(SmartObjectServer)) { content.SetProperty("SmartObjectServer", SmartObjectServer); } if (!K2Field.IsNullOrEmpty(CRMFunctionsSmartObject)) { content.SetProperty("CRMFunctionsSmartObject", CRMFunctionsSmartObject); } //if (!K2Field.IsNullOrEmpty(CustomServiceURL)) //{ // content.SetProperty("CustomServiceURL", CustomServiceURL); //} if (!K2Field.IsNullOrEmpty(CRMServerURL)) { content.SetProperty("CRMServerURL", CRMServerURL); } if (!K2Field.IsNullOrEmpty(CRMOrganisation)) { content.SetProperty("CRMOrganisation", CRMOrganisation); } if (!K2Field.IsNullOrEmpty(CRMFormURL)) { content.SetProperty("CRMFormURL", CRMFormURL); } if (!K2Field.IsNullOrEmpty(CRMEntityId)) { content.SetProperty("CRMEntityId", CRMEntityId); } if (!K2Field.IsNullOrEmpty(CRMEntityType)) { content.SetProperty("CRMEntityType", CRMEntityType); } if (!K2Field.IsNullOrEmpty(CRMEntityForm)) { content.SetProperty("CRMEntityForm", CRMEntityForm); } if (!K2Field.IsNullOrEmpty(CRMCustomSNParameter)) { content.SetProperty("CRMCustomSNParameter", CRMCustomSNParameter); } if (!K2Field.IsNullOrEmpty(TaskCategory)) { content.SetProperty("TaskCategory", TaskCategory); } if (!K2Field.IsNullOrEmpty(TaskDescription)) { content.SetProperty("TaskDescription", TaskDescription); } if (!K2Field.IsNullOrEmpty(TaskDueDate)) { content.SetProperty("TaskDueDate", TaskDueDate); } if (!K2Field.IsNullOrEmpty(TaskDuration)) { content.SetProperty("TaskDuration", TaskDuration); } if (!K2Field.IsNullOrEmpty(TaskOwnerFQN)) { content.SetProperty("TaskOwnerFQN", TaskOwnerFQN); } if (!K2Field.IsNullOrEmpty(TaskOwner)) { content.SetProperty("TaskOwner", TaskOwner); } if (!K2Field.IsNullOrEmpty(TaskOwnerId)) { content.SetProperty("TaskOwnerId", TaskOwnerId); } if (!K2Field.IsNullOrEmpty(TaskPriority)) { content.SetProperty("TaskPriority", TaskPriority); } if (!K2Field.IsNullOrEmpty(TaskRegarding)) { content.SetProperty("TaskRegarding", TaskRegarding); } if (!K2Field.IsNullOrEmpty(TaskRegardingId)) { content.SetProperty("TaskRegardingId", TaskRegardingId); } if (!K2Field.IsNullOrEmpty(TaskState)) { content.SetProperty("TaskState", TaskState); } if (!K2Field.IsNullOrEmpty(TaskStatus)) { content.SetProperty("TaskStatus", TaskStatus); } if (!K2Field.IsNullOrEmpty(TaskSubcategory)) { content.SetProperty("TaskSubcategory", TaskSubcategory); } if (!K2Field.IsNullOrEmpty(TaskSubject)) { content.SetProperty("TaskSubject", TaskSubject); } this.EnsureThatRequiredProcessFieldsExists(); }
public static K2Field CreateK2FieldFormat(string format, params object[] args) { K2Field field = new K2Field(); field.ValueType = typeof(string); if (args.Length == 0) { field.Value = format; return(field); } int state = 0; StringBuilder buffer = new StringBuilder(); foreach (char c in format) { switch (c) { case '{': if (state != 0) { throw new FormatException("Input string was not in a correct format."); } state = 1; break; case '}': if (state != 2) { throw new FormatException("Input string was not in a correct format."); } state = 3; break; } switch (state) { case 0: // normal buffer.Append(c); break; case 1: // begin indexer if (buffer.Length > 0) { if (field.Parts.Count > 0 && field.Parts[field.Parts.Count - 1] is ValueTypePart) { field.Parts[field.Parts.Count - 1].Value = string.Concat(field.Parts[field.Parts.Count - 1].Value, buffer.ToString()); } else { field.Parts.Add(new ValueTypePart(buffer.ToString())); } } buffer = new StringBuilder(); state = 2; break; case 2: // inside indexer buffer.Append(c); break; case 3: // end indexer int idx = int.Parse(buffer.ToString()); if (args[idx] == null) { throw new InvalidOperationException("One of the arguments have a null value."); } K2FieldPart partToAdd = null; if (args[idx].GetType().IsValueType) { partToAdd = new ValueTypePart(args[idx].ToString()); } else if (args[idx] is K2FieldPart) { partToAdd = args[idx] as K2FieldPart; } else if (args[idx] is string) { partToAdd = new ValueTypePart(args[idx] as string); } else { throw new InvalidOperationException("One of the arguments have is an unsupported type."); } if (field.Parts.Count >= 1 && partToAdd is ValueTypePart) { // If the previous field part is also a value type part // merge the values if (field.Parts[field.Parts.Count - 1] is ValueTypePart) { field.Parts[field.Parts.Count - 1].Value = string.Concat(field.Parts[field.Parts.Count - 1].Value, partToAdd.Value); } } else { field.Parts.Add(partToAdd); } buffer = new StringBuilder(); state = 0; break; } } // process last part of the buffer if (buffer.Length > 0) { if (field.Parts.Count == 0) { field.Parts.Add(new ValueTypePart(buffer.ToString())); } else if (field.Parts[field.Parts.Count - 1] is ValueTypePart) { field.Parts[field.Parts.Count - 1].Value = string.Concat(field.Parts[field.Parts.Count - 1].Value, buffer.ToString()); } else { field.Parts.Add(new ValueTypePart(buffer.ToString())); } } return(field); }
void K2TestHelper_SendTestResult(object sender, K2Field.Utilities.Testing.WF.Core.TestResultArgs e) { //now we have the results from the test, lets display them bool isDisplayed = false; if (e.ResultStage == TestResultStage.NewProcessTestStarting && !isDisplayed) { AddResult("\r"); AddResult(e.ResultStage.ToString() + " " + e.ExtraDetails); isDisplayed = true; } if (e.ResultStage == TestResultStage.ProcessStarted && !isDisplayed) { if (this.chkCreateViewFlowTabs.Checked) { AddResult("\t" + e.ResultStage.ToString() + " " + e.ExtraDetails); Thread.Sleep(2000); AddNewViewFlowTab(e.CurrentProcess.Description, e.CurrentProcess.ProcessInstanceID); } isDisplayed = true; } if (e.ResultStage == TestResultStage.CreateTask && !isDisplayed) { AddResult("\t" + e.ResultStage.ToString() + " " + e.ExtraDetails); Thread.Sleep(2000); AddNewTaskTab(); isDisplayed = true; } if (e.ResultStage == TestResultStage.ActivityActioned && !isDisplayed) { AddResult("\t" + e.ResultStage.ToString() + " " + e.ExtraDetails); isDisplayed = true; } if (e.ResultStage.ToString().Contains("Activity") && !isDisplayed) { AddResult("\t" + e.ResultStage.ToString() + " " + e.ExtraDetails); isDisplayed = true; } if (e.ResultStage == TestResultStage.TestEngineEnded && !isDisplayed) { this.statusStripTimer.Enabled = false; isDisplayed = true; ReportResults(K2TestHelper.GlobalProcesses); } if (e.ResultStage == TestResultStage.DebugMessage && chkDebug.Checked) { isDisplayed = false; } else if (e.ResultStage == TestResultStage.DebugMessage) { isDisplayed = true; } if (!isDisplayed) { AddResult(e.ResultStage.ToString() + " " + e.ExtraDetails); } }
//When your wizard page is loaded, this override determines what values exist already and loads those //values into the wizard for display. I.e. if you have a value of "123" that was previously entered into a textbox //on your wizard, this override will load it into memory and on you Wizard page's "OnActivate", this value //can be retrieved and displayed in your text box. protected override void OnLoad(ISerializationInfo content) { base.OnLoad(content); if (content.HasProperty("InternetPlatform")) { _InternetPlatform = content.GetPropertyAsString("InternetPlatform"); } if (content.HasProperty("InsertSN")) { _InsertSN = content.GetPropertyAsBoolean("InsertSN"); } if (content.HasProperty("CreateTasks")) { _CreateTasks = content.GetPropertyAsBoolean("CreateTasks"); } if (content.HasProperty("SN")) { this.SN = (K2Field)content.GetPropertyAsPersistableObject("SN"); } if (content.HasProperty("ActivityName")) { this.ActivityName = (K2Field)content.GetPropertyAsPersistableObject("ActivityName"); } if (content.HasProperty("ProcessName")) { this.ProcessName = (K2Field)content.GetPropertyAsPersistableObject("ProcessName"); } if (content.HasProperty("SmartObjectServer")) { this.SmartObjectServer = (K2Field)content.GetPropertyAsPersistableObject("SmartObjectServer"); } if (content.HasProperty("CRMFunctionsSmartObject")) { this.CRMFunctionsSmartObject = (K2Field)content.GetPropertyAsPersistableObject("CRMFunctionsSmartObject"); } //if (content.HasProperty("CustomServiceURL")) //{ // this.CustomServiceURL = (K2Field)content.GetPropertyAsPersistableObject("CustomServiceURL"); //} if (content.HasProperty("CRMServerURL")) { this.CRMServerURL = (K2Field)content.GetPropertyAsPersistableObject("CRMServerURL"); } if (content.HasProperty("CRMOrganisation")) { this.CRMOrganisation = (K2Field)content.GetPropertyAsPersistableObject("CRMOrganisation"); } if (content.HasProperty("CRMFormURL")) { this.CRMFormURL = (K2Field)content.GetPropertyAsPersistableObject("CRMFormURL"); } if (content.HasProperty("CRMEntityId")) { this.CRMEntityId = (K2Field)content.GetPropertyAsPersistableObject("CRMEntityId"); } if (content.HasProperty("CRMEntityType")) { this.CRMEntityType = (K2Field)content.GetPropertyAsPersistableObject("CRMEntityType"); } if (content.HasProperty("CRMEntityForm")) { this.CRMEntityForm = (K2Field)content.GetPropertyAsPersistableObject("CRMEntityForm"); } if (content.HasProperty("CRMCustomSNParameter")) { this.CRMCustomSNParameter = (K2Field)content.GetPropertyAsPersistableObject("CRMCustomSNParameter"); } if (content.HasProperty("TaskCategory")) { this.TaskCategory = (K2Field)content.GetPropertyAsPersistableObject("TaskCategory"); } if (content.HasProperty("TaskDescription")) { this.TaskDescription = (K2Field)content.GetPropertyAsPersistableObject("TaskDescription"); } if (content.HasProperty("TaskDueDate")) { this.TaskDueDate = (K2Field)content.GetPropertyAsPersistableObject("TaskDueDate"); } if (content.HasProperty("TaskDuration")) { this.TaskDuration = (K2Field)content.GetPropertyAsPersistableObject("TaskDuration"); } if (content.HasProperty("TaskOwnerFQN")) { this.TaskOwnerFQN = (K2Field)content.GetPropertyAsPersistableObject("TaskOwnerFQN"); } if (content.HasProperty("TaskOwner")) { this.TaskOwner = (K2Field)content.GetPropertyAsPersistableObject("TaskOwner"); } if (content.HasProperty("TaskOwnerId")) { this.TaskOwnerId = (K2Field)content.GetPropertyAsPersistableObject("TaskOwnerId"); } if (content.HasProperty("TaskPriority")) { this.TaskPriority = (K2Field)content.GetPropertyAsPersistableObject("TaskPriority"); } if (content.HasProperty("TaskRegarding")) { this.TaskRegarding = (K2Field)content.GetPropertyAsPersistableObject("TaskRegarding"); } if (content.HasProperty("TaskRegardingId")) { this.TaskRegardingId = (K2Field)content.GetPropertyAsPersistableObject("TaskRegardingId"); } if (content.HasProperty("TaskState")) { this.TaskState = (K2Field)content.GetPropertyAsPersistableObject("TaskState"); } if (content.HasProperty("TaskStatus")) { this.TaskStatus = (K2Field)content.GetPropertyAsPersistableObject("TaskStatus"); } if (content.HasProperty("TaskSubcategory")) { this.TaskSubcategory = (K2Field)content.GetPropertyAsPersistableObject("TaskSubcategory"); } if (content.HasProperty("TaskSubject")) { this.TaskSubject = (K2Field)content.GetPropertyAsPersistableObject("TaskSubject"); } this.EnsureThatRequiredProcessFieldsExists(); }