public static SearchConditions AddPropertyCondition <T>(this SearchConditions search, object value, MFConditionType cType = MFConditionType.MFConditionTypeEqual) where T : IMFPropertyDefinition { int pd_id = (int)typeof(T).GetField("id").GetRawConstantValue(); MFDataType data_type = (MFDataType)typeof(T).GetField("data_type").GetRawConstantValue(); if (value is IObjVerEx) { search.AddPropertyCondition(pd_id, cType, data_type, (value as IObjVerEx).objVerEx.ToLookup()); } else if (value is IList) { Lookups lookups = new Lookups(); foreach (IObjVerEx objVerEx in (value as IList)) { if (objVerEx == null) { break; } lookups.Add(-1, objVerEx.objVerEx.ToLookup()); } search.AddPropertyCondition(pd_id, cType, data_type, lookups); } else { search.AddPropertyCondition(pd_id, cType, data_type, value); } return(search); }
public static void Add <T>(this IObjVerEx obj, int propertyId, T?value) where T : struct { if (typeof(T).IsEnum && (value != null && value.GetType() == typeof(T))) { Lookups lookups = obj.objVerEx.GetLookups(propertyId); string value_list_name = typeof(T).Name.Replace("VL", ""); if (!string.IsNullOrEmpty(value_list_name) && !char.IsDigit(value_list_name[1])) { value_list_name = value_list_name.Substring(1, value_list_name.Length - 1); } int ObjectType = (int)Enum.Parse(typeof(VL_ValueLists), value_list_name, true); Lookup lookupToAdd = new Lookup() { Item = Convert.ToInt32(value), ObjectType = ObjectType }; if (lookups.GetLookupIndexByItem(lookupToAdd.Item) == -1) { lookups.Add(-1, lookupToAdd); } PropertyValue propValue = new PropertyValue() { PropertyDef = (int)propertyId }; propValue.TypedValue.SetValueToMultiSelectLookup(lookups); obj.objVerEx.SetProperty(propValue); } }
public Lexicon.Type GetOrCreateDataTypeByName(ICSharpClosure closure, string name, Func <string, Lexicon.Type> create = null) { var dt = closure?.GetByName(name); if (dt != null) { return(dt); } dt = Objects.SingleOrDefault(ddt => ddt.FullName.Equals(name) && (ddt.Closure?.Equals(closure) ?? closure == ddt.Closure)); if (dt == null) { dt = Lookups.FirstOrDefault(ddt => ddt.FullName.Equals(name) && (ddt.FromClosure?.Equals(closure) ?? closure == ddt.FromClosure)); if (dt == null) { if (create == null) { LookupObjectType lt = new LookupObjectType(closure, name); dt = lt; Lookups.Add(lt); } else { Objects.Add(dt = create(name)); } } } return(dt); }
/// <exclude/> public Index(SerializationInfo serializationInfo, StreamingContext streamingContext) { if (SerializerHelper.UseFastSerialization) { _columns = null; using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[])))) { UniqueId = reader.ReadString(); Lookups.Add(UniqueId, this); _alias = reader.ReadString(); _columnIds = reader.ReadStringArray(); _enabled = reader.ReadBoolean(); _isUserDefined = reader.ReadBoolean(); _name = reader.ReadString(); // TODO: Parent _type = reader.ReadString(); _userOptions = (List <IUserOption>)reader.ReadObject(); } } else { int version = 0; if (SerializationVersionExists) { try { version = serializationInfo.GetInt32("SerializationVersion"); } catch (SerializationException) { // ignore SerializationVersionExists = false; } } _alias = serializationInfo.GetString("Alias"); _columns = (List <Column>)serializationInfo.GetValue("Columns", ModelTypes.ColumnList); _enabled = serializationInfo.GetBoolean("Enabled"); //this._exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object); _isUserDefined = serializationInfo.GetBoolean("IsUserDefined"); _name = serializationInfo.GetString("Name"); _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject); _type = serializationInfo.GetString("Type"); _userOptions = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList); for (int i = 0; i < _userOptions.Count; i++) { _userOptions[i].Owner = this; } if (version >= 8) { _description = serializationInfo.GetString("Description"); } } }
public static Lookups ToLookups <TKey, TValue>(this Dictionary <TKey, TValue> dictionary) { var lookups = new Lookups(); foreach (var item in dictionary) { lookups.Add(new Lookup(item.Key, item.Value)); } return(lookups); }
public static Lookups ToLookups <T, TValue>( this IEnumerable <Enumeration <T, TValue> > list) where T : Enumeration <T, TValue> where TValue : IComparable { var lookups = new Lookups(); foreach (var item in list) { lookups.Add(new Lookup(item.Value, item.Name)); } return(lookups); }
private void UpdateLookups() { _logger.Info("Updating lookup dictionary"); Lookups.Clear(); // Don't hammer the website: SurgeProtection.CheckBeforeRequest(); Uri categoryApiUri = new Uri(HostUri, "CategoryAPI"); string categoryApiPageSource; try { categoryApiPageSource = _webClient.DownloadString(categoryApiUri); _logger.Debug($"Downloaded '{categoryApiUri}'"); } catch (Exception ex) { _logger.Error(ex, $"The file '{categoryApiUri}' page failed to download because of an exception"); return; } HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(categoryApiPageSource); var nodes = doc.DocumentNode.SelectNodes(@"//*[@id='content']//*[contains(@class,'searchresults')]//a"); _logger.Debug($"Found {nodes.Count} categories for updating the lookup dictionary"); if (nodes.Any()) { foreach (var node in nodes) { string name = node.InnerText; string link = node.GetAttributeValue("href", string.Empty); int linkQueryIndex = link.IndexOf('?'); // Skip anything that looks like a category but has an invalid URI if (!Uri.TryCreate(HostUri, link.Substring(0, linkQueryIndex >= 0 ? linkQueryIndex : link.Length), out Uri uri)) { _logger.Warn($"Skipping category named '{name}' for lookup dictionary because it has an invalid URI: {link}"); continue; } Lookups.Add(name, uri); } } else { _logger.Warn("There weren't any items on the categories by name page to fill the lookup dictionary"); } }
void form_FormClosing(object sender, FormClosingEventArgs e) { var ref_column = (sender as SelectTableForm).SelectedObject as DBColumn; Lookups.Add(new DBFKConstraint { Action = DB.DBAction.Add , Column = ref_column , Connection = table.Connection , Schema = table.Schema , Name = string.Format("FK_{0}_{1}_{2}_ref_{3}_{4}_{5}", table.Schema.Name, table.Name, "column", ref_column.Schema.Name, ref_column.Parent.Name, ref_column.Name) , State = DBObject.DBObjectState.New }); }
/// <summary> /// Загружает значение lookup-свойства /// </summary> /// <param name="expressions">Лямбда-выражение(я), например (user) => user.City </param> /// <returns></returns> public RepositoryQuery <T> Include(params Expression <Func <T, object> >[] expressions) { if (expressions == null) { throw new ArgumentNullException("expressions"); } foreach (var expression in expressions) { Lookups.Add(expression); } return(this); }
public static PropertyValue ConvertValueListToLookups <T>(object id, MFDataType data_type, List <T?> vList) where T : struct { if (!typeof(T).IsEnum || vList == null) { PropertyValue pv = new PropertyValue() { PropertyDef = (int)id }; pv.TypedValue.SetValueToNULL(data_type); return(pv); } Lookups lookups = new Lookups(); foreach (T t in vList) { if (Equals(t, default(T))) { continue; } string value_list_name = typeof(T).Name.Replace("VL", ""); if (!string.IsNullOrEmpty(value_list_name) && !char.IsDigit(value_list_name[1])) { value_list_name = value_list_name.Substring(1, value_list_name.Length - 1); } int ObjectType = (int)Enum.Parse(typeof(VL_ValueLists), value_list_name, true); Lookup lookup = new Lookup() { Item = Convert.ToInt32(t), ObjectType = ObjectType }; if (lookups.GetLookupIndexByItem(lookup.Item) == -1) { lookups.Add(-1, lookup); } } PropertyValue propVal = new PropertyValue() { PropertyDef = (int)id }; propVal.TypedValue.SetValueToMultiSelectLookup(lookups); return(propVal); }
public static Lookups ToLookups <T>( this IEnumerable <T> list, Func <T, object> idFunc, Func <T, object> descriptionFunc) { var lookups = new Lookups(); foreach (var item in list) { lookups.Add(new Lookup(idFunc(item), descriptionFunc(item))); } return(lookups); }
public BlockLookupTable() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"LookupTable", "runtimeid_table.json"); var json = File.ReadAllText(path); var table = JsonConvert.DeserializeObject <List <LookUp> >(json); foreach (var t in table) { if (t.data.HasValue) { var key = CreateKey(t.id, t.data.Value); if (!Lookups.ContainsKey(key)) { Lookups.Add(key, t); } } } }
public static Lookups ToLookups(this List <ObjVerEx> objVerEx) { Lookups lookups = new Lookups(); foreach (ObjVerEx obj in objVerEx) { Lookup lu = new Lookup { ObjectType = obj.Type, Item = obj.ID, Version = -1 }; if (lookups.GetLookupIndexByItem(lu.Item) == -1) { lookups.Add(-1, lu); } } return(lookups); }
public static PropertyValue ConvertObjectToLookups <T>(object id, MFDataType data_type, List <T> objClass) where T : IObjVerEx { if (null == objClass) { PropertyValue pv = new PropertyValue() { PropertyDef = (int)id }; pv.TypedValue.SetValueToNULL(data_type); return(pv); } Lookups lookups = new Lookups(); foreach (T t in objClass) { if (null == t) { continue; } Lookup lookup = new Lookup() { Item = t.objVerEx.ID, ObjectType = t.objVerEx.Type }; if (lookups.GetLookupIndexByItem(lookup.Item) == -1) { lookups.Add(-1, lookup); } } PropertyValue propVal = new PropertyValue(); propVal.TypedValue.SetValueToMultiSelectLookup(lookups); propVal.PropertyDef = (int)id; return(propVal); }
public Lexicon.Type GetOrCreateArrayDataTypeByName(ICSharpClosure closure, Lexicon.Type type) { string name = type.FullName + "[]"; var dt = closure?.GetByName(name); if (dt != null) { return(dt); } dt = Objects.SingleOrDefault(ddt => ddt.FullName.Equals(name) && (ddt.Closure?.Equals(closure) ?? closure == ddt.Closure)); if (dt == null) { dt = Lookups.FirstOrDefault(ddt => ddt.FullName.Equals(name) && (ddt.FromClosure?.Equals(closure) ?? closure == ddt.FromClosure)); if (dt == null) { LookupObjectType lt = new LookupObjectType(closure, name); dt = lt; Lookups.Add(lt); } } return(dt); }
/// <exclude/> public StoredProcedure(SerializationInfo serializationInfo, StreamingContext streamingContext) { if (SerializerHelper.UseFastSerialization) { using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[])))) { UniqueId = reader.ReadString(); Lookups.Add(UniqueId, this); _alias = reader.ReadString(); _aliasPlural = reader.ReadString(); _columns = (List <Column>)reader.ReadObject(); // TODO: Database _enabled = reader.ReadBoolean(); _filters = (List <Filter>)reader.ReadObject(); _isUserDefined = reader.ReadBoolean(); _manyToManyRelationships = (List <ManyToManyRelationship>)reader.ReadObject(); _manyToOneRelationships = (List <ManyToOneRelationship>)reader.ReadObject(); _name = reader.ReadString(); _oneToManyRelationships = (List <OneToManyRelationship>)reader.ReadObject(); _oneToOneRelationships = (List <OneToOneRelationship>)reader.ReadObject(); _parameters = (List <Parameter>)reader.ReadObject(); _userOptions = (List <IUserOption>)reader.ReadObject(); _Schema = reader.ReadString(); _Associations = (List <Association>)reader.ReadObject(); foreach (Column column in _columns) { column.Parent = this; } foreach (Filter filter in _filters) { filter.Parent = this; } foreach (Association association in _Associations) { association.PrimaryObject = this; } foreach (ManyToManyRelationship relationship in _manyToManyRelationships) { relationship.Parent = this; } foreach (ManyToOneRelationship relationship in _manyToOneRelationships) { relationship.Parent = this; } foreach (OneToManyRelationship relationship in _oneToManyRelationships) { relationship.Parent = this; } foreach (OneToOneRelationship relationship in _oneToOneRelationships) { relationship.Parent = this; } for (int i = 0; i < _userOptions.Count; i++) { _userOptions[i].Owner = this; } } } else { _IsStoredProcedure = true; int version = 0; if (SerializationVersionExists) { try { version = serializationInfo.GetInt32("SerializationVersion"); } catch (SerializationException) { // ignore SerializationVersionExists = false; } } _alias = serializationInfo.GetString("Alias"); _aliasPlural = serializationInfo.GetString("AliasPlural"); _columns = (List <Column>)serializationInfo.GetValue("Columns", ModelTypes.ColumnList); _database = (Database)serializationInfo.GetValue("Database", ModelTypes.Database); _enabled = serializationInfo.GetBoolean("Enabled"); //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object); _filters = (List <Filter>)serializationInfo.GetValue("Filters", ModelTypes.FilterList); _isUserDefined = serializationInfo.GetBoolean("IsUserDefined"); _manyToManyRelationships = (List <ManyToManyRelationship>)serializationInfo.GetValue("ManyToManyRelationships", ModelTypes.ManyToManyRelationshipList); _manyToOneRelationships = (List <ManyToOneRelationship>)serializationInfo.GetValue("ManyToOneRelationships", ModelTypes.ManyToOneRelationshipList); _name = serializationInfo.GetString("Name"); _oneToManyRelationships = (List <OneToManyRelationship>)serializationInfo.GetValue("OneToManyRelationships", ModelTypes.OneToManyRelationshipList); _oneToOneRelationships = (List <OneToOneRelationship>)serializationInfo.GetValue("OneToOneRelationships", ModelTypes.OneToOneRelationshipList); _parameters = (List <Parameter>)serializationInfo.GetValue("Parameters", ModelTypes.ParameterList); _userOptions = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList); if (version > 0) { _Schema = serializationInfo.GetString("Schema"); if (version > 4) { _Errors = (List <string>)serializationInfo.GetValue("Errors", typeof(List <string>)); if (version >= 6) { _Associations = (List <Association>)serializationInfo.GetValue("Associations", typeof(List <Association>)); if (version >= 8) { _description = serializationInfo.GetString("Description"); } } } } } }
/// <exclude/> public MapColumn(SerializationInfo serializationInfo, StreamingContext streamingContext) { if (SerializerHelper.UseFastSerialization) { _relationshipPath = null; using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[])))) { UniqueId = reader.ReadString(); Lookups.Add(UniqueId, this); _alias = reader.ReadString(); _aliasDisplay = reader.ReadString(); _characterMaximumLength = reader.ReadInt32(); // TODO: CurrentParent _dataType = reader.ReadString(); _default = reader.ReadString(); _enabled = reader.ReadBoolean(); _foreignColumnId = reader.ReadString(); _inPrimaryKey = reader.ReadBoolean(); _isIdentity = reader.ReadBoolean(); _isNullable = reader.ReadBoolean(); _isUserDefined = reader.ReadBoolean(); _name = reader.ReadString(); _ordinalPosition = reader.ReadInt32(); // TODO: Parent _readOnly = reader.ReadBoolean(); _RelationshipPathIds = reader.ReadStringArray(); _userOptions = (List <IUserOption>)reader.ReadObject(); for (int i = 0; i < _userOptions.Count; i++) { _userOptions[i].Owner = this; } } } else { _IsMapColumn = true; int version = 0; if (SerializationVersionExists) { try { version = serializationInfo.GetInt32("SerializationVersion"); } catch (SerializationException) { // ignore SerializationVersionExists = false; } } _alias = serializationInfo.GetString("Alias"); _aliasDisplay = serializationInfo.GetString("AliasDisplay"); _characterMaximumLength = serializationInfo.GetInt32("CharacterMaximumLength"); _currentParent = (ScriptObject)serializationInfo.GetValue("CurrentParent", ModelTypes.ScriptObject); _dataType = serializationInfo.GetString("DataType"); _default = serializationInfo.GetString("Default"); _enabled = serializationInfo.GetBoolean("Enabled"); //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object); _foreignColumn = (Column)serializationInfo.GetValue("ForeignColumn", ModelTypes.Column); _inPrimaryKey = serializationInfo.GetBoolean("InPrimaryKey"); _isIdentity = serializationInfo.GetBoolean("IsIdentity"); _isNullable = serializationInfo.GetBoolean("IsNullable"); _isUserDefined = serializationInfo.GetBoolean("IsUserDefined"); _name = serializationInfo.GetString("Name"); _ordinalPosition = serializationInfo.GetInt32("OrdinalPosition"); _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject); _readOnly = serializationInfo.GetBoolean("ReadOnly"); _relationshipPath = (Relationship[])serializationInfo.GetValue("RelationshipPath", ModelTypes.RelationshipArray); _userOptions = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList); if (version >= 8) { _description = serializationInfo.GetString("Description"); } } }
/// <exclude/> public OneToManyRelationship(SerializationInfo serializationInfo, StreamingContext streamingContext) { if (SerializerHelper.UseFastSerialization) { _foreignColumns = null; using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[])))) { UniqueId = reader.ReadString(); Lookups.Add(UniqueId, this); _alias = reader.ReadString(); _enabled = reader.ReadBoolean(); _filterId = reader.ReadString(); _ForeignColumnIds = reader.ReadStringArray(); _ForeignRelationshipId = reader.ReadString(); _ForeignScriptObjectId = reader.ReadString(); _isUserDefined = reader.ReadBoolean(); _name = reader.ReadString(); // TODO: Parent string[] primaryColumnIds = reader.ReadStringArray(); foreach (string primaryColumnId in primaryColumnIds) { _primaryColumns.Add((Column)Lookups[primaryColumnId]); } // TODO: PrimaryScriptObject _userOptions = (List <IUserOption>)reader.ReadObject(); for (int i = 0; i < _userOptions.Count; i++) { _userOptions[i].Owner = this; } } } else { int version = 0; if (SerializationVersionExists) { try { version = serializationInfo.GetInt32("SerializationVersion"); } catch (SerializationException) { // ignore SerializationVersionExists = false; } } _alias = serializationInfo.GetString("Alias"); _enabled = serializationInfo.GetBoolean("Enabled"); //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object); _filter = (Filter)serializationInfo.GetValue("Filter", ModelTypes.Filter); _foreignColumns = (List <Column>)serializationInfo.GetValue("ForeignColumns", ModelTypes.ColumnList); _foreignRelationship = (Relationship)serializationInfo.GetValue("ForeignRelationship", ModelTypes.Relationship); _foreignScriptObject = (ScriptObject)serializationInfo.GetValue("ForeignScriptObject", ModelTypes.ScriptObject); _isUserDefined = serializationInfo.GetBoolean("IsUserDefined"); _name = serializationInfo.GetString("Name"); _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject); _primaryColumns = (List <Column>)serializationInfo.GetValue("PrimaryColumns", ModelTypes.ColumnList); _primaryScriptObject = (ScriptObject)serializationInfo.GetValue("PrimaryScriptObject", ModelTypes.ScriptObject); _userOptions = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList); if (version >= 8) { _description = serializationInfo.GetString("Description"); } } }
public void CreateChequeTest(StateEnvironment env) { var Vault = env.ObjVerEx.Vault; var oCurrObjVals = Vault.ObjectPropertyOperations.GetProperties(env.ObjVerEx.ObjVer); var VendorID = SearchPropertyValue(oCurrObjVals, Vendor_PD); List <InvoiceValue> InvoiceValues = new List <InvoiceValue>(); InvoiceValues.Add(new InvoiceValue() { PropertyID = Date_PD, TypedValue = SearchPropertyValue(oCurrObjVals, InvoiceDate_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = InvoiceNumber_PD, TypedValue = SearchPropertyValue(oCurrObjVals, InvoiceNumber_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = Vendor_PD, TypedValue = VendorID }); List <ObjVerEx> InvoiceObjVers = SearchForObjects(env, Invoice_CD, InvoiceValues); if (InvoiceObjVers != null) { InvoiceValues = new List <InvoiceValue>(); InvoiceValues.Add(new InvoiceValue() { PropertyID = Vendor_PD, TypedValue = VendorID }); InvoiceValues.Add(new InvoiceValue() { PropertyID = Date_PD, TypedValue = SearchPropertyValue(oCurrObjVals, ChequeDate_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = ChequeNumber_PD, TypedValue = SearchPropertyValue(oCurrObjVals, ChequeNumber_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = Amount_PD, TypedValue = SearchPropertyValue(oCurrObjVals, ChequeAmount_PD) }); List <ObjVerEx> ChequeObjVers = SearchForObjects(env, Cheque_CD, InvoiceValues); ObjVer oCheque; var propertyValues = new PropertyValues(); if (ChequeObjVers != null) { oCheque = Vault.ObjectOperations.CheckOut(ChequeObjVers[0].ObjID).ObjVer; } else { var classPropertyValue = new PropertyValue() { PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass }; classPropertyValue.Value.SetValue(MFDataType.MFDatatypeLookup, Vault.ClassOperations.GetObjectClass(Cheque_CD).ID); propertyValues.Add(-1, classPropertyValue); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, ChequeNumber_PD)); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, Date_PD, ChequeDate_PD)); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, Amount_PD, ChequeAmount_PD)); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, Vendor_PD)); ObjectVersionAndProperties ppts = Vault.ObjectOperations.CreateNewObject(Cheque_OT, propertyValues); oCheque = ppts.ObjVer; } var ChequeProps = Vault.ObjectPropertyOperations.GetProperties(oCheque); Lookups PaidInvoices = ChequeProps.SearchForProperty(PaidInvoices_PD).TypedValue.GetValueAsLookups(); bool FoundInvoice = false; foreach (Lookup PaidInvoicesItem in PaidInvoices) { if (PaidInvoicesItem.Item == InvoiceObjVers[0].ObjVer.ID) { FoundInvoice = true; break; } } if (!FoundInvoice) { var NewInvoice = new Lookup(); NewInvoice.ObjectType = InvoiceObjVers[0].ObjVer.Type; NewInvoice.Item = InvoiceObjVers[0].ObjVer.ID; NewInvoice.DisplayValue = InvoiceObjVers[0].Title; PaidInvoices.Add(-1, NewInvoice); var PaidIvc = new PropertyValue() { PropertyDef = PaidInvoices_PD //oCurrObjVals.SearchForProperty(PaidInvoices_PD).PropertyDef }; PaidIvc.Value.SetValueToMultiSelectLookup(PaidInvoices); Vault.ObjectPropertyOperations.SetProperty(oCheque, PaidIvc); } env.ObjVerEx.Vault.ObjectOperations.CheckIn(oCheque); } env.ObjVerEx.SetWorkflowState(SagePaymentWorkFlow, Processed_State); env.ObjVerEx.SaveProperties(); }
public string FindMultifile(Vault env) { var searchMultiFile = new MFSearchBuilder(env); searchMultiFile.Deleted(false); searchMultiFile.ObjType(MFBuiltInObjectType.MFBuiltInObjectTypeDocument); searchMultiFile.Conditions.AddPropertyCondition(22, MFConditionType.MFConditionTypeEqual, MFDataType.MFDatatypeBoolean, false); searchMultiFile.Class(this.Configuration.CurrentConfiguration.ProposalClass); var searchMFResults = searchMultiFile.FindEx(); foreach (var searchResult in searchMFResults) { // If it is an MFD with one file then convert back. if (searchResult.Info.FilesCount == 1) { // Set to SFD. searchResult.SaveProperty( (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefSingleFileObject, MFDataType.MFDatatypeBoolean, true); // Audit trail. // Done. return(""); } try { //Get multifile name var MFTitle = searchResult.Title; // Get a collection of documents for the document collection. var createdItems = new Lookups(); // Get a copy of the current object's properties. var propertiesCopy = this.GetNewObjectPropertyValues(searchResult.Properties); // For each file, create a new object. foreach (var file in searchResult.Info.Files.Cast <ObjectFile>()) { // Add Component Type based on Title if (file.Title.Contains("NPA")) { propertiesCopy.SetProperty(this.Configuration.CurrentConfiguration.ComponentTypeProperty, MFDataType.MFDatatypeLookup, 2); } else if (file.Title.Contains("EOI")) { propertiesCopy.SetProperty(this.Configuration.CurrentConfiguration.ComponentTypeProperty, MFDataType.MFDatatypeLookup, 3); } else if (file.Title.Contains("Price")) { propertiesCopy.SetProperty(this.Configuration.CurrentConfiguration.ComponentTypeProperty, MFDataType.MFDatatypeLookup, 4); } else if (file.Title.Contains("RFT")) { propertiesCopy.SetProperty(this.Configuration.CurrentConfiguration.ComponentTypeProperty, MFDataType.MFDatatypeLookup, 1); } else if (file.Title.Contains("RFP")) { propertiesCopy.SetProperty(this.Configuration.CurrentConfiguration.ComponentTypeProperty, MFDataType.MFDatatypeLookup, 1); } // Download the file. var sourceObjectFiles = this.GetNewObjectSourceFiles(env, file); propertiesCopy.SetProperty(0, MFDataType.MFDatatypeText, file.Title); // Create the new object. var createdObjectId = env.ObjectOperations .CreateNewObjectExQuick( (int)MFBuiltInObjectType.MFBuiltInObjectTypeDocument, propertiesCopy.Clone(), sourceObjectFiles, SFD: true); createdItems.Add(-1, new Lookup { ObjectType = (int)MFBuiltInObjectType.MFBuiltInObjectTypeDocument, Item = createdObjectId, // TODO: Version??? }); } // Add the created documents to a property for the collection. { var collectionMembersPropertyValue = new PropertyValue { PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefCollectionMemberDocuments }; collectionMembersPropertyValue.Value.SetValueToMultiSelectLookup(createdItems); propertiesCopy.Add(-1, collectionMembersPropertyValue); } propertiesCopy.SetProperty(0, MFDataType.MFDatatypeText, MFTitle); propertiesCopy.RemoveProperty(this.Configuration.CurrentConfiguration.ComponentTypeProperty); propertiesCopy.SetProperty(100, MFDataType.MFDatatypeLookup, this.Configuration.CurrentConfiguration.ProposalCollectionClass); // Create the document collection. var documentCollectionObjVer = new ObjVer { Type = (int)MFBuiltInObjectType.MFBuiltInObjectTypeDocumentCollection, ID = env.ObjectOperations.CreateNewObjectExQuick( (int)MFBuiltInObjectType.MFBuiltInObjectTypeDocumentCollection, propertiesCopy) }; // Can we reference the collection? if (this.Configuration.CurrentConfiguration.DocumentCollectionReference.IsResolved) { // Find items which referenced this (old) document and instead reference the collection. foreach (var objVerEx in env .ObjectOperations .GetRelationships(searchResult.ObjVer, MFRelationshipsMode.MFRelationshipsModeToThisObject) .Cast <ObjectVersion>() .Select(ov => new ObjVerEx(env, ov))) { var checkout = objVerEx.StartRequireCheckedOut(); objVerEx.AddLookup( this.Configuration.CurrentConfiguration.DocumentCollectionReference.ID, documentCollectionObjVer, exactVersion: false); objVerEx.SaveProperties(); objVerEx.EndRequireCheckedOut(checkout); } } //Remove orignal File { searchResult.Delete(); } } catch (Exception e) { SysUtils.ReportErrorToEventLog(e); // Throw. throw; } } return(""); }
/// <exclude/> public Filter(SerializationInfo serializationInfo, StreamingContext streamingContext) { if (SerializerHelper.UseFastSerialization) { using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[])))) { // TODO: Parent UniqueId = reader.ReadString(); Lookups.Add(UniqueId, this); _alias = reader.ReadString(); _createStoredProcedure = reader.ReadBoolean(); _customWhere = reader.ReadString(); _enabled = reader.ReadBoolean(); _filterColumns = (List <FilterColumn>)reader.ReadObject(); _isReturnTypeCollection = reader.ReadBoolean(); _isUserDefined = reader.ReadBoolean(); _name = reader.ReadString(); _orderByColumns = (List <OrderByColumn>)reader.ReadObject(); _useCustomWhere = reader.ReadBoolean(); _userOptions = (List <IUserOption>)reader.ReadObject(); for (int i = 0; i < _userOptions.Count; i++) { _userOptions[i].Owner = this; } foreach (FilterColumn filterColumn in _filterColumns) { filterColumn.Parent = this; } } } else { int version = 0; if (SerializationVersionExists) { try { version = serializationInfo.GetInt32("SerializationVersion"); } catch (SerializationException) { // ignore SerializationVersionExists = false; } } _alias = serializationInfo.GetString("Alias"); _createStoredProcedure = serializationInfo.GetBoolean("CreateStoredProcedure"); _customWhere = serializationInfo.GetString("CustomWhere"); _enabled = serializationInfo.GetBoolean("Enabled"); _filterColumns = (List <FilterColumn>)serializationInfo.GetValue("FilterColumns", ModelTypes.FilterColumnList); _isReturnTypeCollection = serializationInfo.GetBoolean("IsReturnTypeCollection"); _isUserDefined = serializationInfo.GetBoolean("IsUserDefined"); _name = serializationInfo.GetString("Name"); _orderByColumns = (List <OrderByColumn>)serializationInfo.GetValue("OrderByColumns", ModelTypes.OrderByColumnList); _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject); _useCustomWhere = serializationInfo.GetBoolean("UserCustomWhere"); _userOptions = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList); foreach (FilterColumn filterColumn in _filterColumns) { if (filterColumn != null) { filterColumn.Parent = this; } } if (version >= 8) { _description = serializationInfo.GetString("Description"); } } }
private void Lognotices(Vault vault, ObjVer objver, MfTask otask, string server) { // Writelog(string.Format("in Lognotices,objver.type={0},id={1},vaultname={2}", objver.Type, objver.ID, vault.Name)); var userIds = new Lookups(); try { userIds = vault.ObjectPropertyOperations.GetProperty(objver, (int)MFBuiltInPropertyDef. MFBuiltInPropertyDefAssignedTo) .Value.GetValueAsLookups(); } #region no propertydefassignedto catch (Exception ex) { // Writelog(string.Format("in Lognotices,big catch,type={0},id={1},vaultname={2},exception={3}", objver.Type, objver.ID, vault.Name,ex.Message )); try { var perms = vault.ObjectOperations.GetObjectPermissions(objver); var aceks = perms.CustomACL ? perms.AccessControlList.CustomComponent.AccessControlEntries. GetKeysWithPseudoUserDefinitions() : perms.NamedACL.AccessControlList.CustomComponent. AccessControlEntries.GetKeysWithPseudoUserDefinitions(); var aclc = perms.CustomACL ? perms.AccessControlList.CustomComponent : perms.NamedACL.AccessControlList.CustomComponent; Writelog(string.Format("perms:Count={0},CustomACL={1},Type={2},ID={3}", aceks.Count, perms.CustomACL, objver.Type, objver.ID)); foreach (AccessControlEntryKey acek in aceks) { Writelog(string.Format("perms:IsGroup={0},IsPseudoUser={1},PseudoUserID={2},UserOrGroupID={3}", acek.IsGroup, acek.IsPseudoUser, acek.PseudoUserID, acek.UserOrGroupID)); if (acek.UserOrGroupID == 1) { continue; //m-files api 获取结果不正确,暂时回避内部所有用户 } #region deal with group if (acek.IsGroup) { if (acek.IsPseudoUser) { foreach (UserOrUserGroupID uoug in acek.GetResolvedPseudoUserOrGroupIDs()) { #region deal with MFUserOrUserGroupTypeUserAccount if (uoug.UserOrGroupType == MFUserOrUserGroupType.MFUserOrUserGroupTypeUserAccount) { try { Writelog(string.Format("in Lognotices,big catch,first little try111,type={0},id={1},UserOrGroupID={2}", objver.Type, objver.ID, uoug.UserOrGroupID)); //var perm = aclc.GetACEByUserOrGroupID(uoug.UserOrGroupID, false); //Writelog(string.Format("in Lognotices,big catch,first little try222,type={0},id={1},vaultname={2}", objver.Type, objver.ID, vault.Name)); //var url = // string.Format( // "user1,AttachObjectsPermission={0},DeletePermission={1},ChangePermissionsPermission={2},EditPermission={3},ReadPermission={4},UserOrGroupID={5},CustomACL={6},ID={7}", // perm.AttachObjectsPermission, perm.DeletePermission, // perm.ChangePermissionsPermission, perm.EditPermission, perm.ReadPermission, uoug.UserOrGroupID, perms.CustomACL, objver.ID); //Writelog(string.Format("url:{0}", url)); //{"Id":1,"Name":"小白"} //if (Checkperm(perm)) continue; var lu = new Lookup { Item = uoug.UserOrGroupID }; if (userIds.GetLookupIndexByItem(lu.Item) < 0) { userIds.Add(-1, lu); } } catch (Exception ex1) { Writelog(string.Format("in Lognotices,big catch,first little catch,type={0},id={1},vaultname={2},exception={3}", objver.Type, objver.ID, vault.Name, ex1.Message)); } } #endregion deal with MFUserOrUserGroupTypeUserAccount #region deal with MFUserOrUserGroupTypeUserGroup else if (uoug.UserOrGroupType == MFUserOrUserGroupType.MFUserOrUserGroupTypeUserGroup) { try { Writelog(string.Format("in Lognotices,big catch,second little try 111,type={0},id={1},UserOrGroupID={2},acek.UserOrGroupID={3}", objver.Type, objver.ID, uoug.UserOrGroupID, acek.UserOrGroupID)); //var perm = aclc.GetACEByUserOrGroupID(uoug.UserOrGroupID, true); //Writelog(string.Format("in Lognotices,big catch,second little try 222,type={0},id={1},vaultname={2}", objver.Type, objver.ID, vault.Name)); //var url = // string.Format( // "group1,AttachObjectsPermission={0},DeletePermission={1},ChangePermissionsPermission={2},EditPermission={3},ReadPermission={4},UserOrGroupID={5},CustomACL={6},ID={7}", // perm.AttachObjectsPermission, perm.DeletePermission, // perm.ChangePermissionsPermission, perm.EditPermission, perm.ReadPermission, uoug.UserOrGroupID, perms.CustomACL, objver.ID); //Writelog(string.Format("url:{0}", url)); //{"Id":1,"Name":"小白"} //if (Checkperm(perm)) continue; var retul = GetUsers(vault, uoug.UserOrGroupID); foreach (var lu in retul) { if (userIds.GetLookupIndexByItem(lu.Item) < 0) { userIds.Add(-1, lu); } } } catch (Exception ex2) { Writelog(string.Format("in Lognotices,big catch,2nd little catch,type={0},id={1},vaultname={2},exception={3}", objver.Type, objver.ID, vault.Name, ex2.Message)); } } #endregion deal MFUserOrUserGroupTypeUserGroup // Writelog( //string.Format( // "in LogCheckInNotice,catch'catch,UserOrGroupID={0},IsPseudoUser={1},Type={2},ID={3},UserOrGroupID={4},UserOrGroupType={5}", // acek.UserOrGroupID, // acek.IsPseudoUser, objver.Type, objver.ID, uoug.UserOrGroupID, uoug.UserOrGroupType)); } continue; } IEnumerable <Lookup> ul = new List <Lookup>(); try { var perm = aclc.GetACEByUserOrGroupID(acek.UserOrGroupID, true); var url = string.Format( "group2,AttachObjectsPermission={0},DeletePermission={1},ChangePermissionsPermission={2},EditPermission={3},ReadPermission={4},UserOrGroupID={5},CustomACL={6},ID={7}", perm.AttachObjectsPermission, perm.DeletePermission, perm.ChangePermissionsPermission, perm.EditPermission, perm.ReadPermission, acek.UserOrGroupID, perms.CustomACL, objver.ID); Writelog(string.Format("url:{0}", url)); if (Checkperm(perm)) { continue; } ul = GetUsers(vault, acek.UserOrGroupID); // ul = GetUsers(vault, uoug.UserOrGroupID); } catch (Exception exson) { Writelog( string.Format( "in Lognotices,catch'catch,UserOrGroupID={0},IsPseudoUser={1},Type={2},ID={3},Message={4}", acek.UserOrGroupID, acek.IsPseudoUser, objver.Type, objver.ID, exson.Message)); } try { foreach (var lu in ul) { if (userIds.GetLookupIndexByItem(lu.Item) < 0) { userIds.Add(-1, lu); } } } catch (Exception ex3) { Writelog(string.Format("in Lognotices,big catch,third little catch,type={0},id={1},vaultname={2},exception={3}", objver.Type, objver.ID, vault.Name, ex3.Message)); } } #endregion deal with group else { try { var perm = aclc.GetACEByUserOrGroupID(acek.UserOrGroupID, false); var url = string.Format( "user2,AttachObjectsPermission={0},DeletePermission={1},ChangePermissionsPermission={2},EditPermission={3},ReadPermission={4},UserOrGroupID={5},CustomACL={6},ID={7}", perm.AttachObjectsPermission, perm.DeletePermission, perm.ChangePermissionsPermission, perm.EditPermission, perm.ReadPermission, acek.UserOrGroupID, perms.CustomACL, objver.ID); Writelog(string.Format("url:{0}", url)); //{"Id":1,"Name":"小白"} if (Checkperm(perm)) { continue; } var lu = new Lookup { Item = acek.UserOrGroupID }; if (userIds.GetLookupIndexByItem(lu.Item) < 0) { userIds.Add(-1, lu); } } catch (Exception ex4) { Writelog(string.Format("in Lognotices,big catch,4th little catch,type={0},id={1},vaultname={2},exception={3}", objver.Type, objver.ID, vault.Name, ex4.Message)); } } } } catch (Exception exx) { Writelog(string.Format("in Lognotices,in big catch,another catch,type={0},id={1},vaultname={2},exception={3}", objver.Type, objver.ID, vault.Name, exx.Message)); } // Writelog(string.Format("in Lognotices,end big catch,type={0},id={1},vaultname={2}", objver.Type, objver.ID, vault.Name)); } #endregion no propertydefassignedto try { foreach (Lookup a in userIds) { otask.UserIds.Add(a.Item.ToString(CultureInfo.InvariantCulture)); } //Writelog(string.Format("Users Info,type={0},id={1},vaultname={2},counts={3},users={4}", // objver.Type, objver.ID, vault.Name, userIds.Count, userIds.ToString())); Logonenotice(vault, otask, server); } catch (Exception ex) { Writelog(string.Format("in Lognotices,Logonetask,type={0},id={1},{2}", objver.Type, objver.ID, ex.Message)); } // Writelog(string.Format("in Lognotices,the end,type={0},id={1},vaultname={2}", objver.Type, objver.ID, vault.Name)); }
public void Search() { Assembly current = Assembly.GetAssembly(typeof(Tools)); Stream stream = current.GetManifestResourceStream(typeof(Tools), "VaultStructure.json"); if (stream == null) { Assert.Fail("Failed to load stream."); } TestVault vault = TestVault.FromStream(stream); PropertyValues pvs = new PropertyValues(); PropertyValue pv = new PropertyValue { PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass }; pv.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0); pvs.Add(-1, pv); vault.ObjectOperations.CreateNewObject(0, pvs); Assert.AreEqual(1, vault.ovaps.Count, "Number of objects != 1"); const int testPropID = 55; pv = new PropertyValue { PropertyDef = testPropID }; const int testLookupID = 77; Lookups lks = new Lookups(); Lookup lk = new Lookup { Item = testLookupID, ObjectType = 0 }; lks.Add(-1, lk); pv.TypedValue.SetValueToMultiSelectLookup(lks); pvs.Add(-1, pv); vault.ObjectOperations.CreateNewObject(0, pvs); Assert.AreEqual(2, vault.ovaps.Count, "Original does not have 2 objects"); SearchCondition c = new SearchCondition(); c.Expression.DataPropertyValuePropertyDef = testPropID; c.ConditionType = MFConditionType.MFConditionTypeEqual; c.TypedValue.SetValue(MFDataType.MFDatatypeLookup, testLookupID); SearchCondition sc = new SearchCondition(); sc.Expression.SetStatusValueExpression(MFStatusType.MFStatusTypeDeleted); sc.ConditionType = MFConditionType.MFConditionTypeEqual; sc.TypedValue.SetValue(MFDataType.MFDatatypeBoolean, false); SearchConditions search = new SearchConditions(); search.Add(-1, sc); search.Add(-1, c); ObjectSearchResults results = vault.ObjectSearchOperations.SearchForObjectsByConditionsEx(search, MFSearchFlags.MFSearchFlagDisableRelevancyRanking, false); Assert.AreEqual(1, results.Count); ObjectVersion ov = results[1]; Assert.NotNull(ov); ObjectVersions ovs = results.GetAsObjectVersions(); foreach (ObjectVersion result in ovs) { Assert.NotNull(result); } vault.ObjectOperations.CreateNewObject(2, pvs); results = vault.ObjectSearchOperations.SearchForObjectsByConditionsEx(search, MFSearchFlags.MFSearchFlagDisableRelevancyRanking, false); Assert.AreEqual(2, results.Count); sc = new SearchCondition(); sc.Expression.SetStatusValueExpression(MFStatusType.MFStatusTypeObjectTypeID); sc.ConditionType = MFConditionType.MFConditionTypeEqual; sc.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0); search.Add(-1, sc); results = vault.ObjectSearchOperations.SearchForObjectsByConditionsEx(search, MFSearchFlags.MFSearchFlagDisableRelevancyRanking, false); Assert.AreEqual(1, results.Count); }
/// <summary> /// TODO: I don't think this should be exposed to the user??? /// </summary> /// <param name="serializationInfo"></param> /// <param name="streamingContext"></param> public Column(SerializationInfo serializationInfo, StreamingContext streamingContext) { if (SerializerHelper.UseFastSerialization) { using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[])))) { UniqueId = reader.ReadString(); Lookups.Add(UniqueId, this); _alias = reader.ReadString(); _aliasDisplay = reader.ReadString(); _characterMaximumLength = reader.ReadInt32(); _dataType = reader.ReadString(); _default = reader.ReadString(); _enabled = reader.ReadBoolean(); _inPrimaryKey = reader.ReadBoolean(); _isIdentity = reader.ReadBoolean(); _isNullable = reader.ReadBoolean(); _isUserDefined = reader.ReadBoolean(); _name = reader.ReadString(); _ordinalPosition = reader.ReadInt32(); // Parent _readOnly = reader.ReadBoolean(); _userOptions = (List <IUserOption>)reader.ReadObject(); _IsCalculated = reader.ReadBoolean(); _precision = reader.ReadInt32(); _scale = reader.ReadInt32(); for (int i = 0; i < _userOptions.Count; i++) { _userOptions[i].Owner = this; } } } else { int version = 0; if (SerializationVersionExists) { try { version = serializationInfo.GetInt32("SerializationVersion"); } catch (SerializationException) { // ignore SerializationVersionExists = false; } } _alias = serializationInfo.GetString("Alias"); _aliasDisplay = serializationInfo.GetString("AliasDisplay"); _characterMaximumLength = serializationInfo.GetInt32("CharacterMaximumLength"); _dataType = serializationInfo.GetString("DataType"); _default = serializationInfo.GetString("Default"); _enabled = serializationInfo.GetBoolean("Enabled"); //this._exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ObjectType); _inPrimaryKey = serializationInfo.GetBoolean("InPrimaryKey"); _isIdentity = serializationInfo.GetBoolean("IsIdentity"); _isNullable = serializationInfo.GetBoolean("IsNullable"); _isUserDefined = serializationInfo.GetBoolean("IsUserDefined"); _name = serializationInfo.GetString("Name"); _ordinalPosition = serializationInfo.GetInt32("OrdinalPosition"); _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject); _readOnly = serializationInfo.GetBoolean("ReadOnly"); _userOptions = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList); if (version >= 2) { _IsCalculated = serializationInfo.GetBoolean("IsCalculated"); if (version >= 3) { _precision = serializationInfo.GetInt32("Precision"); _scale = serializationInfo.GetInt32("Scale"); if (version >= 8) { _description = serializationInfo.GetString("Description"); if (version >= 9) { _Lookup = (Lookup)serializationInfo.GetValue("Lookup", ModelTypes.Lookup); //_Lookup.SubscribingObjects.Add(this); } } } } } }