コード例 #1
0
 /// <summary>
 /// Executes the changeset. Operation is persisting changes to database.
 /// </summary>
 /// <param name="changeset">The changeset that is persisted.</param>
 public override void ExecuteChangeset(DBXml changeset)
 {
     if (this.executionMode == 1)
     {
         repository.ExecuteOperations(changeset);
     }
     else
     {
         DBXml   xml = new DBXml();
         DBTable tab = xml.AddTable(this.MainObjectTag);
         foreach (var valuation in changeset.Table(this.MainObjectTag).Rows)
         {
             Guid?savepointName = null;
             var  row           = tab.AddRow(valuation);
             try
             {
                 savepointName = Guid.NewGuid();
                 this.repository.CreateSavepoint(savepointName.ToString());
                 repository.ExecuteOperations(xml);
             }
             catch (SqlException)
             {
                 if (savepointName.HasValue)
                 {
                     this.repository.RollbackToSavepoint(savepointName.ToString());
                 }
             }
             row.Remove();
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Gets the number indicating previous version of bussiness object within database xml.
        /// </summary>
        /// <param name="dbXml">The database xml.</param>
        /// <returns>Previous version of bussiness object.</returns>
        public virtual Dictionary <string, string> GetPreviousVersion(DBXml dbXml)
        {
            var result = new Dictionary <string, string>(1);

            if (dbXml.Table(MainObjectTag).FirstRow().Action == DBRowState.Delete)
            {
                var ver = dbXml.Table(MainObjectTag).FirstRow().Element("version");
                if (ver != null)
                {
                    result.Add(String.Empty, dbXml.Table(MainObjectTag).FirstRow().Element("version").Value);
                }
                else
                {
                    return(null);
                }
            }
            else if (dbXml.PreviousVersion != null)
            {
                result.Add(String.Empty, dbXml.PreviousVersion);
            }
            else
            {
                return(null);
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Executes the changeset. Operation is persisting changes to database.
        /// </summary>
        /// <param name="changeset">The changeset that is persisted.</param>
        public override void ExecuteChangeset(DBXml changeset)
        {
            this.repository.ExecuteOperations(changeset);

            List <string> indexedContractors = new List <string>();
            XDocument     xml      = XDocument.Parse("<root businessObjectId=\"\" mode=\"\" />");
            var           mainItem = this.CurrentPackage.Xml.Root.Descendants("contractorId").FirstOrDefault();

            if (mainItem != null)
            {
                xml.Root.Attribute("businessObjectId").Value = mainItem.Value;
                xml.Root.Attribute("mode").Value             = DBRowState.Update.ToStateName();
                this.repository.IndexContractor(xml);
                indexedContractors.Add(xml.Root.Attribute("businessObjectId").Value);
            }

            foreach (DBRow row in changeset.Table(MainObjectTag).Rows)
            {
                if (row.Action == DBRowState.Delete)
                {
                    continue;
                }

                string id = row.Element("relatedContractorId").Value;
                if (indexedContractors.Contains(id) == true)
                {
                    continue;
                }

                xml.Root.Attribute("businessObjectId").Value = id;
                xml.Root.Attribute("mode").Value             = DBRowState.Update.ToStateName();
                indexedContractors.Add(xml.Root.Attribute("businessObjectId").Value);
                this.repository.IndexContractor(xml);
            }
        }
コード例 #4
0
        public DepartmentStatistics GetDetailedStatistics(Guid branchId)
        {
            if (this.database.State != ConnectionState.Open)
            {
                this.database.Open();
            }

            using (SqlCommand cmd = this.helper.CreateCommand(StoredProcedure.communication_p_getStatisticsDetails.ToProcedureName(),
                                                              new SqlParameter("@branchId", SqlDbType.UniqueIdentifier),
                                                              branchId))
            {
                XDocument statisticsXml = this.helper.GetXmlDocument(cmd.ExecuteXmlReader());
                DBRow     statistics    = new DBXml(statisticsXml).Table("statistics").FirstRow();

                DepartmentStatistics branchStats = new DepartmentStatistics();
                branchStats.CurrentTime = DateTime.Parse(statistics.Element("currentTime").Value).Round(DateTimeAccuracy.Second);
                branchStats.SystemTime  = DateTime.Now.Round(DateTimeAccuracy.Second);
                if (statistics.Element("executionMessageTime") != null)
                {
                    branchStats.LastExecutionMessage = new MessageData(statistics.Element("lastExecutionMessage").Value, DateTime.Parse(statistics.Element("executionMessageTime").Value).Round(DateTimeAccuracy.Second));
                }
                if (statistics.Element("receiveMessageTime") != null)
                {
                    branchStats.LastReceiveMessage = new MessageData(statistics.Element("lastReceiveMessage").Value, DateTime.Parse(statistics.Element("receiveMessageTime").Value).Round(DateTimeAccuracy.Second));
                }
                if (statistics.Element("sentMessageTime") != null)
                {
                    branchStats.LastSendMessage = new MessageData(statistics.Element("lastSentMessage").Value, DateTime.Parse(statistics.Element("sentMessageTime").Value).Round(DateTimeAccuracy.Second));
                }

                SynchronizeStatisticTime(branchStats);

                return(branchStats);
            }
        }
コード例 #5
0
ファイル: PaymentScript.cs プロジェクト: MakoLab/fractus
        /// <summary>
        /// Gets the number indicating previous version of bussiness object within database xml.
        /// </summary>
        /// <param name="dbXml">The database xml.</param>
        /// <returns>Previous version of bussiness object.</returns>
        public override Dictionary <string, string> GetPreviousVersion(DBXml dbXml)
        {
            if (dbXml.Table(MainObjectTag).Rows.Count() == 0)
            {
                return(null);
            }

            var result      = new Dictionary <string, string>(dbXml.Table(MainObjectTag).Rows.Count());
            var deletedRows = dbXml.Table(MainObjectTag).Rows.Where(r => r.Action == DBRowState.Delete);

            if (deletedRows.Count() > 0)
            {
                foreach (var row in deletedRows)
                {
                    var ver = row.Element("previousVersion");
                    if (ver != null)
                    {
                        result.Add(row.Element("id").Value, ver.Value);
                    }
                }
            }
            else if (dbXml.PreviousVersion != null)
            {
                result.Add(String.Empty, dbXml.PreviousVersion);
            }
            else
            {
                return(null);
            }

            return(result);
        }
コード例 #6
0
        private static bool IsSourceBranch(DBXml shiftDocument)
        {
            Guid branchId = Guid.Empty;

            if (IsOutcomeshift(shiftDocument) == true)
            {
                branchId = new Guid(shiftDocument.Table("warehouseDocumentHeader").FirstRow().Element("branchId").Value);
            }
            else
            {
                string targetWarehouseId        = null;
                string oppositeWarehouseFieldId = DictionaryMapper.Instance.GetDocumentField(Makolab.Fractus.Kernel.Enums.DocumentFieldName.ShiftDocumentAttribute_OppositeWarehouseId).Id.Value.ToString().ToUpperInvariant();
                targetWarehouseId = shiftDocument.Xml.Root.Element("documentAttrValue").Elements()
                                    .Where(row => row.Element("documentFieldId").Value.Equals(oppositeWarehouseFieldId))
                                    .Select(row => row.Element("textValue").Value)
                                    .SingleOrDefault();
                if (targetWarehouseId == null)
                {
                    throw new InvalidDataException("Missing target warehouse id.");
                }
                Warehouse targetWarehouse = DictionaryMapper.Instance.GetWarehouse(new Guid(targetWarehouseId));
                branchId = targetWarehouse.BranchId;
            }

            return(Makolab.Fractus.Kernel.Mappers.ConfigurationMapper.Instance.DatabaseId == DictionaryMapper.Instance.GetBranch(branchId).DatabaseId);
        }
コード例 #7
0
 /// <summary>
 /// Executes the changeset. Operation is persisting changes to database.
 /// </summary>
 /// <param name="changeset">The changeset that is persisted.</param>
 public override void ExecuteChangeset(DBXml changeset)
 {
     if (this.IsHeadquarter == true && IsLocal(this.CurrentPackage) == false)
     {
         base.ExecuteChangeset(changeset);
     }
 }
コード例 #8
0
        //Added by Manjot on 08/Aug/2017
        public ActionResult GetXMLPath(string FileName, int RecordID)
        {
            Ctx   ct   = Session["ctx"] as Ctx;
            DBXml _obj = new DBXml();

            return(Json(JsonConvert.SerializeObject(_obj.CreateJDBCDataSourceXml(ct, FileName, RecordID)), JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        ///// <summary>
        ///// Check whether database xml from communication has correct version.
        ///// </summary>
        ///// <param name="commSnapshot">The snapshot from other branch.</param>
        ///// <param name="dbXml">The snapshot created from database.</param>
        ///// <returns><c>true</c> if database xml from communication has correct version; otherwise, <c>false</c>.</returns>
        //public virtual bool ValidateVersion(DBXml commSnapshot, DBXml dbXml)
        //{
        //    return GetPreviousVersion(commSnapshot)[null].Equals(dbXml.Table(MainObjectTag).FirstRow().Element("version").Value,
        //                                                   StringComparison.OrdinalIgnoreCase);
        //}

        /// <summary>
        /// Gets the number indicating previous version of bussiness object within database xml.
        /// </summary>
        /// <param name="dbXml">The database xml.</param>
        /// <returns>Previous version of bussiness object.</returns>
        public static Dictionary <string, string> GetPreviousVersion(DBXml dbXml, string mainObjectTag)
        {
            var result = new Dictionary <string, string>();

            foreach (DBRow row in dbXml.Table(mainObjectTag).Rows)
            {
                if (row.Action == DBRowState.Delete)
                {
                    var ver = row.Element("version");
                    if (ver != null)
                    {
                        result.Add(row.Element("id").Value, ver.Value);
                    }
                }
                else if (row.PreviousVersion != null)
                {
                    result.Add(row.Element("id").Value, row.PreviousVersion);
                }
            }
            if (result.Count == 0)
            {
                return(null);
            }
            else
            {
                return(result);
            }
        }
コード例 #10
0
        /// <summary>
        /// Extracts the payment package from another package.
        /// </summary>
        /// <param name="communicationXml">The communication XML.</param>
        /// <param name="communicationPackage">The communication package.</param>
        /// <returns>Extracted payment <c>CommunicationPackage</c> object if <b>communicationXml</b> has payment data; otherwise, <c>null</c>.</returns>
        public static CommunicationPackage ExtractPaymentPackage(DBXml communicationXml, ICommunicationPackage communicationPackage)
        {
            if (communicationXml.Table("payment") == null || communicationXml.Table("payment").HasRows == false)
            {
                return(null);
            }

            XDocument commXml = XDocument.Parse("<root/>");

            commXml.Root.Add(communicationXml.Table("payment").Xml);

            var settlements = communicationXml.Table("paymentSettlement");

            if (settlements != null && settlements.HasRows == true)
            {
                commXml.Root.Add(settlements.Xml);
            }

            XmlTransferObject commPkgData = new XmlTransferObject
            {
                DeferredTransactionId = communicationPackage.XmlData.DeferredTransactionId,
                Id = Guid.NewGuid(),
                LocalTransactionId = communicationPackage.XmlData.LocalTransactionId,
                XmlType            = CommunicationPackageType.Payment.ToString(),
                Content            = commXml.ToString(SaveOptions.DisableFormatting)
            };

            return(new CommunicationPackage(commPkgData)
            {
                DatabaseId = communicationPackage.DatabaseId
            });;
        }
コード例 #11
0
 /// <summary>
 /// Executes the changeset. Operation is persisting changes to database.
 /// </summary>
 /// <param name="changeset">The changeset that is persisted.</param>
 public override void ExecuteChangeset(DBXml changeset)
 {
     if (changeset != null)
     {
         repository.ExecuteOperations(changeset);
     }
 }
コード例 #12
0
        /// <summary>
        /// Generates the changeset - diff beetween two snapshots.
        /// </summary>
        /// <param name="commSnapshot">The snapshot from other branch.</param>
        /// <param name="dbSnapshot">The snapshot created from database.</param>
        /// <returns>Generated xml changeset.</returns>
        public override DBXml GenerateChangeset(DBXml commSnapshot, DBXml dbSnapshot)
        {
            var entries = commSnapshot.Tables.SelectMany(tab => tab.Rows);

            foreach (var entry in entries)
            {
                if (entry.Element("id") == null)
                {
                    entry.AddElement("id", entry.Element("contractorId").Value);
                }
            }

            if (dbSnapshot != null)
            {
                entries = dbSnapshot.Tables.SelectMany(tab => tab.Rows);
                foreach (var entry in entries)
                {
                    if (entry.Element("id") == null)
                    {
                        entry.AddElement("id", entry.Element("contractorId").Value);
                    }
                }
            }
            this.currentContractor = dbSnapshot;
            return(base.GenerateChangeset(commSnapshot, dbSnapshot));
        }
コード例 #13
0
        /// <summary>
        /// Gets xml representation of bussiness object with related objects.
        /// </summary>
        /// <param name="objectId">The object id.</param>
        /// <returns>
        ///     <see cref="DBXml"/> from database with specified id.
        /// </returns>
        public override DBXml GetCurrentSnapshot(Guid objectId)
        {
            DBXml snapshot = this.repository.FindCommercialWarehouseValuations(new List <Guid> {
                objectId
            });

            return(GetSnapshotOrNull(snapshot));
        }
コード例 #14
0
        /// <summary>
        /// Gets xml representation of bussiness object with related objects.
        /// </summary>
        /// <param name="objectId">The object id.</param>
        /// <returns>
        ///     <see cref="DBXml"/> from database with specified id.
        /// </returns>
        public override DBXml GetCurrentSnapshot(Guid objectId)
        {
            DBXml snapshot = this.repository.FindIncomeOutcomeRelation(new List <Guid> {
                objectId
            });

            return(GetSnapshotOrNull(snapshot));
        }
コード例 #15
0
        private static bool IsIncomeshift(DBXml shiftDocument)
        {
            DocumentType docType = DictionaryMapper.Instance.GetDocumentType(new Guid(
                                                                                 shiftDocument.Table("warehouseDocumentHeader")
                                                                                 .FirstRow().Element("documentTypeId").Value));

            return(docType.WarehouseDocumentOptions.WarehouseDirection == Makolab.Fractus.Kernel.Enums.WarehouseDirection.IncomeShift);
        }
コード例 #16
0
        /// <summary>
        /// Executes the changeset. Operation is persisting changes to database.
        /// </summary>
        /// <param name="changeset">The changeset that is persisted.</param>
        public override void ExecuteChangeset(DBXml changeset)
        {
            this.repository.ExecuteOperations(changeset);

            XDocument xml = XDocument.Parse("<root businessObjectId=\"\" mode=\"\" />");

            xml.Root.Attribute("businessObjectId").Value = this.CurrentPackage.Table(this.MainObjectTag).FirstRow().Element("id").Value;
            xml.Root.Attribute("mode").Value             = changeset.Table(this.MainObjectTag).FirstRow().Xml.Attribute("action").Value;
            this.repository.IndexContractor(xml);
        }
コード例 #17
0
 public static void SetPreviousVersion(DBXml dbXml, Dictionary <string, string> previousVersions, string mainObjectTag)
 {
     foreach (var element in previousVersions)
     {
         var row = dbXml.Table(mainObjectTag).FindRow(element.Key);
         if (row != null && row.Element("version") == null)
         {
             row.AddElement("version", element.Value);
         }
     }
 }
コード例 #18
0
        /// <summary>
        /// Executes the changeset. Operation is persisting changes to database.
        /// </summary>
        /// <param name="changeset">The changeset that is persisted.</param>
        public override void ExecuteChangeset(Makolab.Fractus.Communication.DBLayer.DBXml changeset)
        {
            //remove valuations that link to lines marked as deleted
            if (changeset.Table("warehouseDocumentValuation") != null && changeset.Table("warehouseDocumentLine") != null)
            {
                List <DBRow> deletedValuations = new List <DBRow>();
                foreach (var line in changeset.Table("warehouseDocumentLine").Rows.Where(l => l.Action == DBRowState.Delete))
                {
                    foreach (var valuation in changeset.Table("warehouseDocumentValuation").Rows)
                    {
                        if (valuation.Element("incomeWarehouseDocumentLineId").Value.Equals(line.Element("id").Value, StringComparison.OrdinalIgnoreCase) ||
                            valuation.Element("outcomeWarehouseDocumentLineId").Value.Equals(line.Element("id").Value, StringComparison.OrdinalIgnoreCase))
                        {
                            deletedValuations.Add(valuation);
                        }
                    }
                }
                deletedValuations.ForEach(v => v.Remove());
            }


            //TODO kod dodany by wykorzystywac mechanizm savepointow, ale dziwia warunki na korekte pz/wz
            //TODO nalezy sprawdzi czy zmiana wycen rusza wersje obiektu glownego bo wyglda na to ze nie
            var docType = Makolab.Fractus.Kernel.Mappers.DictionaryMapper.Instance.GetDocumentType(
                new Guid(this.CurrentPackage.Table(this.MainObjectTag).FirstRow().Element("documentTypeId").Value));

            if ((docType.DocumentCategory == Makolab.Fractus.Kernel.Enums.DocumentCategory.IncomeWarehouseCorrection ||
                 docType.DocumentCategory == Makolab.Fractus.Kernel.Enums.DocumentCategory.OutcomeWarehouseCorrection) &&
                changeset.Table("warehouseDocumentValuation") != null)
            {
                var warehouseValuationTable = changeset.Table("warehouseDocumentValuation");
                warehouseValuationTable.Remove();
                DBXml valuationXml = new DBXml();
                valuationXml.AddTable(warehouseValuationTable);

                this.Repository.ExecuteOperations(changeset);

                WarehouseDocumentValuation valuationProcessor = new WarehouseDocumentValuation(this.UnitOfWork, this.ExecutionController, this.IsHeadquarter);
                valuationProcessor.Log = this.Log;
                valuationProcessor.LocalTransactionId = this.LocalTransactionId;
                CommunicationPackage valuationPackage = new CommunicationPackage(new XmlTransferObject()
                {
                    Content = valuationXml.Xml.ToString(SaveOptions.DisableFormatting)
                });
                valuationPackage.DatabaseId = this.package.DatabaseId;
                valuationPackage.XmlData.LocalTransactionId    = this.package.XmlData.LocalTransactionId;
                valuationPackage.XmlData.DeferredTransactionId = this.package.XmlData.DeferredTransactionId;
                valuationProcessor.ExecutePackage(valuationPackage, 0);
            }
            else
            {
                this.Repository.ExecuteOperations(changeset);
            }
        }
コード例 #19
0
 public void ExecuteOperations(Action <XDocument> action, DBXml operations)
 {
     if (this.isDeffered == true)
     {
         this.ChangesetBuffer.AddOrReplaceData(operations.Tables);
     }
     else
     {
         action.Invoke(operations.Xml);
     }
 }
コード例 #20
0
 /// <summary>
 /// Generates the changeset - diff beetween two snapshots.
 /// </summary>
 /// <param name="commSnapshot">The snapshot from other branch.</param>
 /// <param name="dbSnapshot">The snapshot created from database.</param>
 /// <returns>Generated xml changeset.</returns>
 public override DBXml GenerateChangeset(DBXml commSnapshot, DBXml dbSnapshot)
 {
     if (dbSnapshot == null)
     {
         return(base.GenerateChangeset(commSnapshot, null));
     }
     else
     {
         return(null);
     }
 }
コード例 #21
0
 public static void RemoveDeletedRows(DBXml currentXml, DBXml dbXml, string mainObjectTag, ICommunicationLog log)
 {
     currentXml.Table(mainObjectTag).Rows
     .Where(r => r.Action == DBRowState.Delete)
     .Except(dbXml == null ? new List <DBRow>(0) : dbXml.Table(mainObjectTag).Rows, new DBRowIdComparer())
     .ToList()
     .ForEach(row =>
     {
         log.Info(mainObjectTag + " id=" + row.Element("id").Value + " is already deleted, skipping row");
         row.Remove();
     });
 }
コード例 #22
0
        /// <summary>
        /// Removes the previous version number from database xml.
        /// </summary>
        /// <param name="dbXml">The db XML.</param>
        /// <returns>Specified database xml without previous version number.</returns>
        public static DBXml RemovePreviousVersion(DBXml dbXml)
        {
            foreach (var table in dbXml.Tables)
            {
                foreach (var row in table.Rows)
                {
                    row.RemovePreviousVersion();
                }
            }

            return(dbXml);
        }
コード例 #23
0
 public virtual void SetPreviousVersion(DBXml dbXml, Dictionary <string, string> previousVersions)
 {
     // TODO zamienic na jakis inny wyjatek
     if (previousVersions.ContainsKey(String.Empty) == false)
     {
         throw new Exception("Previous version is not present in collection uder null key");
     }
     if (dbXml.Table(MainObjectTag).FirstRow().Element("version") == null)
     {
         dbXml.Table(MainObjectTag).FirstRow().AddElement("version", previousVersions[String.Empty]);
     }
 }
コード例 #24
0
        /// <summary>
        /// Process communication package persisting it's data to database.
        /// </summary>
        /// <param name="communicationPackage">The communication package to execute.</param>
        /// <returns>
        ///     <c>true</c> if execution succeeded; otherwise, <c>false</c>
        /// </returns>
        public override bool ExecutePackage(ICommunicationPackage communicationPackage)
        {
            SessionManager.VolatileElements.DeferredTransactionId = communicationPackage.XmlData.DeferredTransactionId;
            SessionManager.VolatileElements.LocalTransactionId    = this.LocalTransactionId;

            this.CurrentPackage = new DBXml(XDocument.Parse(communicationPackage.XmlData.Content));

            List <Guid> relationsId = new List <Guid>();

            foreach (DBRow row in this.CurrentPackage.Table(this.MainObjectTag).Rows)
            {
                Guid relationId = new Guid(row.Element("id").Value);
                relationsId.Add(relationId);
            }

            DBXml dbSnapshot = GetCurrentSnapshot(relationsId);

            try
            {
                // TODO conflict detection & resolution
                //// Conflict detection
                //if (dbSnapshot != null && ValidateVersion(CurrentPackage, dbSnapshot) == false)
                //{
                //    throw new ConflictException("Conflict detected while changing " + this.MainObjectTag + " id: " + mainObjectId.ToString());
                //}

                PackageExecutionHelper.RemoveDeletedRows(this.CurrentPackage, dbSnapshot, this.MainObjectTag, this.Log);

                if (this.CurrentPackage.Table(MainObjectTag).HasRows == false)
                {
                    return(true);
                }
                //else do the rest

                DBXml changeset = GenerateChangeset(CurrentPackage, dbSnapshot);
                ExecuteChangeset(changeset);
            }
            catch (SqlException e)
            {
                if (e.Number == 50012) // Conflict detection
                {
                    throw new ConflictException("Conflict detected while changing " + this.MainObjectTag);
                }
                else
                {
                    this.Log.Error("SnapshotScript:ExecutePackage " + e.ToString());
                    return(false);
                }
            }

            return(true);
        }
コード例 #25
0
 /// <summary>
 /// Executes the changeset. Operation is persisting changes to database.
 /// </summary>
 /// <param name="changeset">The changeset that is persisted.</param>
 public override void ExecuteChangeset(DBXml changeset)
 {
     repository.ExecuteOperations(changeset);
     //because
     if (changeset.Table(this.MainObjectTag) != null)
     {
         bool      isNew = (changeset.Table(this.MainObjectTag).FirstRow().Action.Value == DBRowState.Insert) ? true : false;
         XDocument xml   = XDocument.Parse("<root businessObjectId=\"\" mode=\"\" />");
         xml.Root.Attribute("businessObjectId").Value = this.CurrentPackage.Table(this.MainObjectTag).FirstRow().Element("id").Value;
         xml.Root.Attribute("mode").Value             = changeset.Table(this.MainObjectTag).FirstRow().Xml.Attribute("action").Value;
         this.repository.IndexDocument(xml, isNew);
     }
 }
コード例 #26
0
 public override void SetPreviousVersion(DBXml dbXml, Dictionary <string, string> previousVersions)
 {
     base.SetPreviousVersion(dbXml, previousVersions);
     foreach (var objectVersion in previousVersions)
     {
         if (objectVersion.Key.Length > 0)
         {
             var row = dbXml.FindRow(r => r.Element("_commReq") != null && r.Element("_commReq").Value == objectVersion.Key);
             if (row != null)
             {
                 row.AddElement("version", objectVersion.Value);
             }
         }
     }
 }
コード例 #27
0
ファイル: PaymentScript.cs プロジェクト: MakoLab/fractus
        public override void SetPreviousVersion(DBXml dbXml, Dictionary <string, string> previousVersions)
        {
            if (dbXml.Table(MainObjectTag).Rows.Count() == 0)
            {
                return;
            }

            if (dbXml.Table(MainObjectTag).Rows.Any(r => r.Action == DBRowState.Delete))
            {
                PackageExecutionHelper.SetPreviousVersion(dbXml, previousVersions, this.MainObjectTag);
            }
            else
            {
                base.SetPreviousVersion(dbXml, previousVersions);
            }
        }
コード例 #28
0
        /// <summary>
        /// Gets the object snapshot or null when snapshot is empty.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <returns>Snapshot if snapshot is not empty; otherwise, <c>null</c></returns>
        protected DBXml GetSnapshotOrNull(DBXml snapshot)
        {
            if (snapshot == null)
            {
                return(null);
            }

            if (snapshot != null && snapshot.Tables.Any(table => table.HasRows) == false)
            {
                return(null);
            }
            else
            {
                return(snapshot);
            }
        }
コード例 #29
0
ファイル: ItemRelationScript.cs プロジェクト: MakoLab/fractus
        /// <summary>
        /// Executes the changeset. Operation is persisting changes to database.
        /// </summary>
        /// <param name="changeset">The changeset that is persisted.</param>
        public override void ExecuteChangeset(DBXml changeset)
        {
            repository.ExecuteOperations(changeset);

            List <string> indexedItems = new List <string>();
            XDocument     xml          = XDocument.Parse("<root businessObjectId=\"\" mode=\"\" />");
            var           mainItem     = this.CurrentPackage.Xml.Root.Descendants("itemId").FirstOrDefault();

            if (mainItem != null)
            {
                xml.Root.Attribute("businessObjectId").Value = mainItem.Value;
                xml.Root.Attribute("mode").Value             = DBRowState.Update.ToStateName();
                this.repository.IndexItem(xml);
                indexedItems.Add(xml.Root.Attribute("businessObjectId").Value);
            }

            foreach (DBRow row in changeset.Table(MainObjectTag).Rows)
            {
                if (row.Action == DBRowState.Delete)
                {
                    continue;
                }

                string id = row.Element("relatedObjectId").Value;
                if (indexedItems.Contains(id) == true)
                {
                    continue;
                }

                xml.Root.Attribute("businessObjectId").Value = id;
                xml.Root.Attribute("mode").Value             = DBRowState.Update.ToStateName();
                ItemRelationType relationType      = DictionaryMapper.Instance.GetItemRelationType(new Guid(row.Element("itemRelationTypeId").Value));
                string           relatedObjectType = relationType.Metadata.Element("relatedObjectType").Value;
                switch (relatedObjectType)
                {
                case "Item":
                    this.repository.IndexItem(xml);
                    break;

                case "Contractor":
                    this.contractorRepository.IndexContractor(xml);
                    break;
                }
                indexedItems.Add(xml.Root.Attribute("businessObjectId").Value);
            }
        }
コード例 #30
0
        public Dictionary <string, string> GetBranchList()
        {
            if (this.database.State != ConnectionState.Open)
            {
                this.database.Open();
            }

            using (SqlCommand cmd = this.helper.CreateCommand(StoredProcedure.dictionary_p_getBranches.ToProcedureName()))
            {
                XDocument branchXml = this.helper.GetXmlDocument(cmd.ExecuteXmlReader());
                DBXml     branches  = new DBXml(branchXml);
                Dictionary <string, string> branchList = new Dictionary <string, string>();
                foreach (var branch in branches.Table("branch").Rows)
                {
                    branchList.Add(branch.Element("id").Value, branch.Element("xmlLabels").Element("labels").Element("label").Value);
                }

                return(branchList);
            }
        }