Exemplo n.º 1
0
        /// <summary>
        /// Saves changes of current <see cref="BusinessObject"/> to the operations list.
        /// </summary>
        /// <param name="document">Xml document containing operation list to execute.</param>
        public override void SaveChanges(XDocument document)
        {
            if (this.Id == null)
            {
                this.GenerateId();
            }

            if (this.Status != BusinessObjectStatus.Unchanged && this.Status != BusinessObjectStatus.Unknown)
            {
                if (this.Parent != null)
                {
                    if (this.Parent.BOType == BusinessObjectType.CommercialDocument)
                    {
                        this.CommercialDocumentHeaderId = this.Parent.Id.Value;
                        this.FinancialDocumentHeaderId  = null;
                    }
                    else if (this.Parent.BOType == BusinessObjectType.FinancialDocument)
                    {
                        this.CommercialDocumentHeaderId = null;
                        this.FinancialDocumentHeaderId  = this.Parent.Id.Value;
                    }
                    else
                    {
                        throw new InvalidOperationException("Type of Parent is not supported");
                    }
                }

                BusinessObjectHelper.SaveBusinessObjectChanges(this, document, null, null);
            }

            if (this.Settlements != null)
            {
                this.Settlements.SaveChanges(document);
            }
        }
Exemplo n.º 2
0
        public static bool BenifitCalculationOfPeriod(GLBenifitCalcsInfo benifitInfo)
        {
            if (benifitInfo.FK_GEPeriodID.HasValue == false || benifitInfo.GLBenifitCalcID == Guid.Empty)
            {
                return(false);
            }

            GEPeriodsInfo period = new GEPeriodsController().GetObjectByID(benifitInfo.FK_GEPeriodID.Value) as GEPeriodsInfo;

            if (period == null)
            {
                return(false);
            }

            DateTime startDate = new DateTime(period.Year.Value, period.Month.Value, 1);
            DateTime endDate   = startDate.AddMonths(1).AddSeconds(-10);

            BenifitCalculationOfRange(benifitInfo, startDate, endDate);

            if (BusinessObjectHelper.IsModifiedObject(benifitInfo))
            {
                new GLBenifitCalcsController().UpdateObject(benifitInfo);
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Saves changes of current <see cref="BusinessObject"/> to the operations list.
        /// </summary>
        /// <param name="document">Xml document containing operation list to execute.</param>
        public override void SaveChanges(XDocument document)
        {
            if (this.Id == null)
            {
                this.GenerateId();
            }

            if (this.Status != BusinessObjectStatus.Unchanged && this.Status != BusinessObjectStatus.Unknown)
            {
                Dictionary <string, object> forcedToSave = new Dictionary <string, object>();

                string parentColumnName          = null;
                string relatedDocumentColumnName = null;

                if (this.Direction == WarehouseDirection.Outcome)
                {
                    parentColumnName          = "outcomeWarehouseDocumentLineId";
                    relatedDocumentColumnName = "incomeWarehouseDocumentLineId";
                }
                else
                {
                    parentColumnName          = "incomeWarehouseDocumentLineId";
                    relatedDocumentColumnName = "outcomeWarehouseDocumentLineId";
                }

                forcedToSave.Add(relatedDocumentColumnName, this.RelatedLine.Id.ToUpperString());

                forcedToSave.Add(parentColumnName, this.Parent.Id.ToUpperString());

                BusinessObjectHelper.SaveBusinessObjectChanges(this, document, forcedToSave, null);
            }
        }
Exemplo n.º 4
0
        internal static XElement ConvertAttributeFromDbToBoXmlFormat(XElement attrElement, string dataType)
        {
            XElement result = new XElement(XmlName.Attribute);

            foreach (XElement memberElement in attrElement.Elements())
            {
                if (!VariableColumnName.IsVariableColumnName(memberElement.Name.LocalName))
                {
                    result.Add(memberElement);                     //auto-cloning
                }
                else
                {
                    if (dataType != DataType.Xml)
                    {
                        result.Add(new XElement(XmlName.Value, BusinessObjectHelper.ConvertAttributeValueForSpecifiedDataType(memberElement.Value, dataType)));
                    }
                    else
                    {
                        result.Add(new XElement(XmlName.Value, memberElement.Elements()));
                    }
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Saves changes of current <see cref="BusinessObject"/> to the operations list.
        /// </summary>
        /// <param name="document">Xml document containing operation list to execute.</param>
        public override void SaveChanges(XDocument document)
        {
            if (this.Id == null)
            {
                this.GenerateId();
            }

            if (this.Status != BusinessObjectStatus.Unchanged && this.Status != BusinessObjectStatus.Unknown)
            {
                Dictionary <string, object> forcedToSave = new Dictionary <string, object>();

                Payment parent = (Payment)this.Parent;

                if (parent.Direction * parent.Amount > 0)
                {
                    forcedToSave.Add("incomePaymentId", this.Parent.Id.ToUpperString());
                    forcedToSave.Add("outcomePaymentId", this.RelatedPayment.Id.ToUpperString());
                }
                else
                {
                    forcedToSave.Add("outcomePaymentId", this.Parent.Id.ToUpperString());
                    forcedToSave.Add("incomePaymentId", this.RelatedPayment.Id.ToUpperString());
                }

                BusinessObjectHelper.SaveBusinessObjectChanges(this, document, forcedToSave, null);
            }
        }
Exemplo n.º 6
0
        public override void SaveChanges(XDocument document)
        {
            if (this.Id == null)
            {
                this.GenerateId();
            }

            if ((this.Status != BusinessObjectStatus.Unchanged && this.Status != BusinessObjectStatus.Unknown) ||
                this.ForceSave)
            {
                if (this.AlternateVersion == null || ((this.AlternateVersion.Status == BusinessObjectStatus.Unchanged ||
                                                       this.AlternateVersion.Status == BusinessObjectStatus.Unknown) && ((IVersionedBusinessObject)this.AlternateVersion).ForceSave == false))
                {
                    if (this.Status == BusinessObjectStatus.New)
                    {
                        this.CreationDate = SessionManager.VolatileElements.CurrentDateTime;
                    }
                    else if (this.Status == BusinessObjectStatus.Modified)
                    {
                        this.ModificationDate = SessionManager.VolatileElements.CurrentDateTime;
                    }

                    BusinessObjectHelper.SaveBusinessObjectChanges(this, document, null, null);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Saves changes of current <see cref="BusinessObject"/> to the operations list.
        /// </summary>
        /// <param name="document">Xml document containing operation list to execute.</param>
        public override void SaveChanges(XDocument document)
        {
            if (this.Id == null)
            {
                this.GenerateId();
            }

            //save changes of child elements first

            if (this.Accounts != null)
            {
                this.Accounts.SaveChanges(document);
            }

            if (this.Addresses != null)
            {
                this.Addresses.SaveChanges(document);
            }

            if (this.Attributes != null)
            {
                this.Attributes.SaveChanges(document);
            }

            //if the contractor has been changed or some of his children have been changed
            if ((this.Status != BusinessObjectStatus.Unchanged && this.Status != BusinessObjectStatus.Unknown) ||
                this.ForceSave)
            {
                if (this.AlternateVersion == null || ((this.AlternateVersion.Status == BusinessObjectStatus.Unchanged ||
                                                       this.AlternateVersion.Status == BusinessObjectStatus.Unknown) && ((IVersionedBusinessObject)this.AlternateVersion).ForceSave == false))
                {
                    //BusinessObjectHelper.SaveMainObjectChanges(this, document, "contractor", new string[] { "id",
                    //"code", "isSupplier", "isReceiver", "isBusinessEntity", "isBank", "isEmployee",
                    //"isTemplate", "isOwnCompany", "fullName", "shortName", "nip", "nipPrefixCountryId", "version" }, null);

                    BusinessObjectHelper.SaveBusinessObjectChanges(this, document, null, null);
                }
            }

            //relations have to be saved at the end
            if (this.GroupMemberships != null)
            {
                this.GroupMemberships.SaveChanges(document);
            }

            if (this.Relations != null)
            {
                this.Relations.SaveChanges(document);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Recursively creates new children (BusinessObjects) and attaches them to proper xml elements.
        /// </summary>
        /// <param name="element">Xml element to attach.</param>
        public override void Deserialize(XElement element)
        {
            base.Deserialize(element);

            ItemRelationType relType           = DictionaryMapper.Instance.GetItemRelationType(this.ItemRelationTypeId);
            string           relatedObjectType = relType.Metadata.Element("relatedObjectType").Value;

            //update the relation type name
            this.itemRelationTypeName = relType.TypeName;

            IBusinessObject obj = BusinessObjectHelper.CreateRelatedBusinessObjectFromXmlElement((XElement)element.Element("relatedObject").FirstNode,
                                                                                                 relatedObjectType);

            this.RelatedObject = obj;
        }
Exemplo n.º 9
0
        public override XDocument LoadBusinessObjectForPrinting(XDocument requestXml, string customLabelsLanguage)
        {
            if (requestXml.Root.Element("storedProcedure") != null)
            {
                DictionaryMapper.Instance.CheckForChanges();
                XDocument retXml = DependencyContainerManager.Container.Get <DocumentMapper>().LoadBusinessObjectForPrinting(requestXml.Root.Element("storedProcedure").Value, requestXml.Root.Element("id").Value);

                BusinessObjectHelper.GetPrintXml(retXml, customLabelsLanguage);
                return(retXml);
            }
            else
            {
                return(base.LoadBusinessObjectForPrinting(requestXml, customLabelsLanguage));
            }
        }
Exemplo n.º 10
0
        public XDocument GetPermissionProfiles()
        {
            XDocument xml = XDocument.Parse("<root></root>");

            ICollection <Configuration> profiles = ConfigurationMapper.Instance.GetConfiguration(SessionManager.User, "permissions.profiles.*");

            foreach (Configuration conf in profiles)
            {
                XElement profile = new XElement("permissionProfile");
                profile.Add(new XAttribute("id", conf.Key.Substring(21)));
                profile.Add(new XAttribute("label", BusinessObjectHelper.GetXmlLabelInUserLanguage(conf.Value.Element("labels")).Value));
                xml.Root.Add(profile);
            }

            return(xml);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Saves changes of current <see cref="BusinessObject"/> to the operations list.
        /// </summary>
        /// <param name="document">Xml document containing operation list to execute.</param>
        public override void SaveChanges(XDocument document)
        {
            if (this.Id == null)
            {
                this.GenerateId();
            }

            if (this.Attributes != null)
            {
                this.Attributes.SaveChanges(document);
            }

            if (this.Status != BusinessObjectStatus.Unchanged && this.Status != BusinessObjectStatus.Unknown)
            {
                BusinessObjectHelper.SaveRelationChanges(this, document);
            }
        }
Exemplo n.º 12
0
        public static GLJournalEntrysInfo GenerateJournalEntry(BusinessObject objItem, Guid iDebitID, Guid iCreditID, double dbAmt, String strDesc)
        {
            GLJournalEntrysInfo entry = new GLJournalEntrysInfo();

            BusinessObjectHelper.CopyObject(objItem, entry, false);
            InvalidateJournalEntry(entry, null);
            entry.Remark = strDesc;

            entry.FK_GLAccountID_Debit      = iDebitID;
            entry.FK_GLAccountID_RaiseDebit = entry.FK_GLAccountID_Debit;

            entry.FK_GLAccountID_Credit      = iCreditID;
            entry.FK_GLAccountID_RaiseCredit = entry.FK_GLAccountID_Credit;

            entry.AmtTot = dbAmt;
            return(entry);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Converts ItemAttrValue table from database xml format to <see cref="BusinessObject"/>'s xml format.
        /// </summary>
        /// <param name="xml">Full xml with all tables in database format.</param>
        /// <param name="id">Id of the currently processed <see cref="Item"/>.</param>
        /// <param name="outXml">Output xml in <see cref="BusinessObject"/>'s xml format.</param>
        private void ConvertItemAttributesFromDbToBoXmlFormat(XDocument xml, Guid id, XDocument outXml)
        {
            if (xml.Root.Element("itemAttrValue") != null)
            {
                XElement attributes = new XElement("attributes");
                outXml.Root.Element("item").Add(attributes);

                var elements = from node in xml.Root.Element("itemAttrValue").Elements()
                               where node.Element("itemId").Value == id.ToUpperString()
                               orderby Convert.ToInt32(node.Element("order").Value, CultureInfo.InvariantCulture) ascending
                               select node;

                foreach (XElement element in elements)
                {
                    XElement attribute = new XElement("attribute");
                    attributes.Add(attribute);

                    foreach (XElement attrElement in element.Elements())
                    {
                        if (attrElement.Name.LocalName != "itemId")
                        {
                            if (!VariableColumnName.IsVariableColumnName(attrElement.Name.LocalName))
                            {
                                attribute.Add(attrElement);
                            }
                            else
                            {
                                ItemField cf = DictionaryMapper.Instance.GetItemField(new Guid(element.Element("itemFieldId").Value));

                                string dataType = cf.Metadata.Element("dataType").Value;

                                if (dataType != "xml")
                                {
                                    attribute.Add(new XElement(XmlName.Value, BusinessObjectHelper.ConvertAttributeValueForSpecifiedDataType(attrElement.Value, dataType)));
                                }
                                else
                                {
                                    attribute.Add(new XElement(XmlName.Value, attrElement.Elements()));
                                }
                            }
                        }
                    }
                }
            }
        }