예제 #1
0
        public void ModifyData(DataStoreModifyDataEventArgs args)
        {
            var modificationResultIdentities = new List <ParameterValue>();

            foreach (ModificationStatement stm in args.ModificationStatements)
            {
                if (stm.TableName == "XPObjectType")
                {
                    foreach (var dataLayer in _dataStoreManager.SimpleDataLayers.Select(pair => pair.Value))
                    {
                        modificationResultIdentities.AddRange(dataLayer.ModifyData(stm).Identities);
                    }
                }
                else
                {
                    string             key = _dataStoreManager.GetKeyInfo(stm.TableName);
                    ModificationResult modificationResult = _dataStoreManager.SimpleDataLayers[key].ModifyData(stm);
                    if (modificationResult != null)
                    {
                        modificationResultIdentities.AddRange(modificationResult.Identities);
                    }
                }
            }
            args.ModificationResult = new ModificationResult(modificationResultIdentities);
        }
예제 #2
0
    public ModificationResult Modify(Translation translation)
    {
        var t = (TextEntryTranslation)translation;

        this.saveTranslation(t);
        this.translation = t;
        return(ModificationResult.WithSuccess(t));
    }
        public async Task <ModificationResult> ModifyDataAsync(CancellationToken cancellationToken, params ModificationStatement[] dmlStatements)
        {
            string serialized_modstatement = Serialize(dmlStatements);
            var    content = new StringContent(JsonSerializer.Serialize(serialized_modstatement), Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync($"api/xpo/modifydataasync", content, cancellationToken).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            string             result = JsonSerializer.Deserialize <string>(await response.Content.ReadAsStringAsync().ConfigureAwait(false));
            ModificationResult response_deserialized = Deserialize <OperationResult <ModificationResult> >(result).Result;

            return(response_deserialized);
        }
예제 #4
0
 ModificationResult ModifyXPObjectTable(ModificationStatement[] dmlStatements, InsertStatement insertStatement, ModificationResult modificationResult) {
     foreach (var simpleDataLayer in _dataStoreManager.SimpleDataLayers) {
         var dataLayer = simpleDataLayer.Value;
         if (!TypeExists(dataLayer, insertStatement)) {
             if (!IsMainLayer(dataLayer.Connection)) {
                 _xpoObjectHacker.CreateObjectTypeIndetifier(insertStatement, _dataStoreManager.SimpleDataLayers[DataStoreManager.StrDefault]);
             }
             var modifyData = dataLayer.ModifyData(dmlStatements);
             if (modifyData.Identities.Count() > 0)
                 modificationResult = modifyData;
         }
     }
     return modificationResult;
 }
예제 #5
0
 public override ModificationResult ModifyData(params ModificationStatement[] dmlStatements) {
     var dataStoreModifyDataEventArgs = new DataStoreModifyDataEventArgs(dmlStatements);
     OnDataStoreModifyData(dataStoreModifyDataEventArgs);
     var name = typeof(XPObjectType).Name;
     var insertStatement = dataStoreModifyDataEventArgs.ModificationStatements.OfType<InsertStatement>().FirstOrDefault(statement => statement.TableName == name);
     var modificationResult = new ModificationResult();
     if (insertStatement != null) {
         modificationResult = ModifyXPObjectTable(dmlStatements, insertStatement, modificationResult);
     } else {
         var key = _dataStoreManager.GetKeyInfo(dmlStatements[0].TableName);
         modificationResult = _dataStoreManager.SimpleDataLayers[key].ModifyData(dmlStatements);
     }
     if (modificationResult != null) return modificationResult;
     throw new NotImplementedException();
 }
예제 #6
0
 ModificationResult ModifyXPObjectTable(ModificationStatement[] dmlStatements, InsertStatement insertStatement, ModificationResult modificationResult) {
     foreach (var simpleDataLayer in _dataStoreManager.GetDataLayers(DataStore)) {
         if (!simpleDataLayer.Value.IsLegacy) {
             var dataLayer = simpleDataLayer.Value;
             if (!TypeExists(dataLayer, insertStatement)) {
                 if (!dataLayer.IsMainLayer) {
                     _xpoObjectHacker.CreateObjectTypeIndetifier(insertStatement, _dataStoreManager.GetDataLayer(DataStoreManager.StrDefault,DataStore));
                 }
                 var modifyData = dataLayer.ModifyData(dmlStatements);
                 if (modifyData.Identities.Any())
                     modificationResult = modifyData;
             }
         }
     }
     return modificationResult;
 }
예제 #7
0
        public static ModificationResult Delete <T>(this Session session, CriteriaOperator criteria) where T : IXPObject
        {
            if (ReferenceEquals(criteria, null))
            {
                criteria = CriteriaOperator.Parse("True");
            }
            XPClassInfo classInfo                   = session.GetClassInfo(typeof(T));
            var         batchWideData               = new BatchWideDataHolder4Modification(session);
            var         recordsAffected             = (int)session.Evaluate <T>(CriteriaOperator.Parse("Count()"), criteria);
            List <ModificationStatement> collection = DeleteQueryGenerator.GenerateDelete(classInfo, ObjectGeneratorCriteriaSet.GetCommonCriteriaSet(criteria), batchWideData);

            foreach (ModificationStatement item in collection)
            {
                item.RecordsAffected = recordsAffected;
            }
            ModificationStatement[] collectionToArray = collection.ToArray <ModificationStatement>();
            ModificationResult      result            = session.DataLayer.ModifyData(collectionToArray);

            return(result);
        }
예제 #8
0
        public override ModificationResult ModifyData(params ModificationStatement[] dmlStatements)
        {
            var dataStoreModifyDataEventArgs = new DataStoreModifyDataEventArgs(dmlStatements);

            OnDataStoreModifyData(dataStoreModifyDataEventArgs);
            var name               = typeof(XPObjectType).Name;
            var insertStatement    = dataStoreModifyDataEventArgs.ModificationStatements.OfType <InsertStatement>().FirstOrDefault(statement => statement.TableName == name);
            var modificationResult = new ModificationResult();

            if (insertStatement != null)
            {
                modificationResult = ModifyXPObjectTable(dmlStatements, insertStatement, modificationResult);
            }
            else
            {
                var key = _dataStoreManager.GetKeyInfo(dmlStatements[0].TableName);
                modificationResult = _dataStoreManager.SimpleDataLayers[key].ModifyData(dmlStatements);
            }
            if (modificationResult != null)
            {
                return(modificationResult);
            }
            throw new NotImplementedException();
        }
예제 #9
0
 ModificationResult ModifyXPObjectTable(ModificationStatement[] dmlStatements, InsertStatement insertStatement, ModificationResult modificationResult)
 {
     foreach (var simpleDataLayer in _dataStoreManager.SimpleDataLayers)
     {
         if (!simpleDataLayer.Value.IsLegacy)
         {
             var dataLayer = simpleDataLayer.Value;
             if (!TypeExists(dataLayer, insertStatement))
             {
                 if (!dataLayer.IsMainLayer)
                 {
                     _xpoObjectHacker.CreateObjectTypeIndetifier(insertStatement, _dataStoreManager.SimpleDataLayers[DataStoreManager.StrDefault]);
                 }
                 var modifyData = dataLayer.ModifyData(dmlStatements);
                 if (modifyData.Identities.Any())
                 {
                     modificationResult = modifyData;
                 }
             }
         }
     }
     return(modificationResult);
 }
예제 #10
0
        public ModificationResult ComputeResults(Modifications a, Modifications b)
        {
            ModificationResult result = new ModificationResult();

            // Add all the A operations, provided they're not in B, or equal.
            // Remove all B operations with identical key.
            foreach (KeyValuePair <int, Operation <int, Line> > pair in a.textKeyOperations)
            {
                var key   = pair.Key;
                var opA   = pair.Value;
                var valid = true;
                if (b.textKeyOperations.TryGetValue(key, out Operation <int, Line> opB))
                {
                    valid = opB.Equals(opA);
                }

                if (valid)
                {
                    result.textKeyOperations.Add(opA);
                }
                else
                {
                    result.m_invalidOperations.Add(new Tuple <Operation, Operation>(opA, opB));
                }

                b.textKeyOperations.Remove(key);
            }

            foreach (KeyValuePair <int, Operation <int, Line> > pair in a.versionOperations)
            {
                var key   = pair.Key;
                var opA   = pair.Value;
                var valid = true;
                if (b.versionOperations.TryGetValue(key, out Operation <int, Line> opB))
                {
                    valid = opB.Equals(opA);
                }

                if (valid)
                {
                    result.versionOperations.Add(opA);
                }
                else
                {
                    result.m_invalidOperations.Add(new Tuple <Operation, Operation>(opA, opB));
                }

                b.versionOperations.Remove(key);
            }

            foreach (KeyValuePair <string, Operation <string, (Line, Line)?> > pair in a.textCollectionOperations)
            {
                var key   = pair.Key;
                var opA   = pair.Value;
                var valid = true;
                if (b.textCollectionOperations.TryGetValue(key, out Operation <string, (Line, Line)?> opB))
                {
                    valid = opB.Equals(opA);
                }

                if (valid)
                {
                    result.textCollectionOperations.Add(opA);
                }
                else
                {
                    result.m_invalidOperations.Add(new Tuple <Operation, Operation>(opA, opB));
                }

                b.textCollectionOperations.Remove(key);
            }

            // Add the remaining B operations
            foreach (KeyValuePair <int, Operation <int, Line> > operation in b.textKeyOperations)
            {
                result.textKeyOperations.Add(operation.Value);
            }

            foreach (KeyValuePair <int, Operation <int, Line> > operation in b.versionOperations)
            {
                result.versionOperations.Add(operation.Value);
            }

            foreach (KeyValuePair <string, Operation <string, (Line, Line)?> > operation in b.textCollectionOperations)
            {
                result.textCollectionOperations.Add(operation.Value);
            }

            return(result);
        }
예제 #11
0
        public ModificationResult ModifyData(params ModificationStatement[] dmlStatements)
        {
            ModificationResult modificationResult = this.IDataStore.ModifyData(dmlStatements);

            return(modificationResult);
        }