internal static SmartFormatProperties CreateSmartFormatProperties( string soGuid, string server, string name, string displayname, string methodname, string methoddisplayname, bool methodislist, System.Collections.Generic.Dictionary <string, K2Field> SOInputs, System.Collections.Generic.Dictionary <string, K2Field> SOReturns, string connection) { Guid smoGuid; SmartObjectClientServer svr = new SmartObjectClientServer(); svr.CreateConnection(); svr.Connection.Open(connection); SmartObject so = svr.GetSmartObject(name); smoGuid = so.Guid; SmartFormatProperties properties = new SmartFormatProperties(); properties.Locals["Guid"] = new Local("Guid", soGuid); //properties.Locals["Server"] = new Local("Server", "Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=Localhost;Port=5555"); properties.Locals["Server"] = new Local("Server", connection); properties.Locals["Name"] = new Local("Name", name); properties.Locals["DisplayName"] = new Local("DisplayName", displayname); properties.Locals["MethodName"] = new Local("MethodName", methodname); properties.Locals["MethodDisplayName"] = new Local("MethodDisplayName", methoddisplayname); properties.Locals["IsList"] = new Local("IsList", new K2Field(new K2FieldPart[] { new ValueTypePart(methodislist) })); properties.Locals["MethodType"] = new Local("MethodType", "execute"); foreach (SmartProperty item in so.Properties) { properties.Properties.Add(item.Name, new Property(item.Name, item.Name, null, item.Type.ToString(), item.IsUnique)); } //Add inputs foreach (var item in SOInputs) { if (so.Methods[methodname].InputProperties.Contains(item.Key)) { SmartProperty prop = so.Methods[methodname].InputProperties[item.Key]; properties.Inputs.Add(prop.Name, new Input(prop.Name, prop.Type.ToString(), item.Value)); } foreach (SmartParameter itemParams in so.Methods[methodname].Parameters) { if (itemParams.Name == item.Key) { SmartProperty prop = so.Methods[methodname].Parameters[item.Key]; properties.Inputs.Add(prop.Name, new Input(prop.Name, prop.Type.ToString(), item.Value)); } } } //Map return properties foreach (SmartProperty item in so.Methods[methodname].ReturnProperties) { bool found = false; //Search and see if we have passed a mapped item if (SOReturns != null) { foreach (var SetReturnItem in SOReturns) { if (SetReturnItem.Key == item.Name) { SmartProperty prop = so.Methods[methodname].ReturnProperties[SetReturnItem.Key]; properties.Returns.Add(prop.Name, new Return(prop.Name, SetReturnItem.Value, prop.Type.ToString())); found = true; } } } //If no mapped item found set a null value. if (found == false) { properties.Returns.Add(item.Name, new Return(item.Name, item.Name, item.IsUnique, null, item.Type.ToString())); } } return(properties); }
internal static SmartFormatProperties CreateSmartFormatProperties( string soGuid, string server, string name, string displayname, string methodname, string methoddisplayname, bool methodislist, System.Collections.Generic.Dictionary<string, K2Field> SOInputs, System.Collections.Generic.Dictionary<string, K2Field> SOReturns, string connection) { Guid smoGuid; SmartObjectClientServer svr = new SmartObjectClientServer(); svr.CreateConnection(); svr.Connection.Open(connection); SmartObject so = svr.GetSmartObject(name); smoGuid = so.Guid; SmartFormatProperties properties = new SmartFormatProperties(); properties.Locals["Guid"] = new Local("Guid", soGuid); //properties.Locals["Server"] = new Local("Server", "Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=Localhost;Port=5555"); properties.Locals["Server"] = new Local("Server", connection); properties.Locals["Name"] = new Local("Name", name); properties.Locals["DisplayName"] = new Local("DisplayName", displayname); properties.Locals["MethodName"] = new Local("MethodName", methodname); properties.Locals["MethodDisplayName"] = new Local("MethodDisplayName", methoddisplayname); properties.Locals["IsList"] = new Local("IsList", new K2Field(new K2FieldPart[] { new ValueTypePart(methodislist) })); properties.Locals["MethodType"] = new Local("MethodType", "execute"); foreach (SmartProperty item in so.Properties) { properties.Properties.Add(item.Name, new Property(item.Name, item.Name, null, item.Type.ToString(), item.IsUnique)); } //Add inputs foreach (var item in SOInputs) { if (so.Methods[methodname].InputProperties.Contains(item.Key)) { SmartProperty prop = so.Methods[methodname].InputProperties[item.Key]; properties.Inputs.Add(prop.Name, new Input(prop.Name, prop.Type.ToString(), item.Value)); } foreach (SmartParameter itemParams in so.Methods[methodname].Parameters) { if (itemParams.Name == item.Key) { SmartProperty prop = so.Methods[methodname].Parameters[item.Key]; properties.Inputs.Add(prop.Name, new Input(prop.Name, prop.Type.ToString(), item.Value)); } } } //Map return properties foreach (SmartProperty item in so.Methods[methodname].ReturnProperties) { bool found = false; //Search and see if we have passed a mapped item if (SOReturns != null) { foreach (var SetReturnItem in SOReturns) { if (SetReturnItem.Key == item.Name) { SmartProperty prop = so.Methods[methodname].ReturnProperties[SetReturnItem.Key]; properties.Returns.Add(prop.Name, new Return(prop.Name, SetReturnItem.Value, prop.Type.ToString())); found = true; } } } //If no mapped item found set a null value. if (found == false) { properties.Returns.Add(item.Name, new Return(item.Name, item.Name, item.IsUnique, null, item.Type.ToString())); } } return properties; }