コード例 #1
0
ファイル: Cart.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Adds the specified order group to the existing cart.
        /// </summary>
        /// <param name="orderGroup">The order group.</param>
        /// <param name="lineItemRollup">if set to <c>true</c> [line item rollup].</param>
        public void Add(OrderGroup orderGroup, bool lineItemRollup)
        {
            if (orderGroup == null)
            {
                throw new ArgumentNullException("orderGroup");
            }

            if ((orderGroup.OrderForms != null) && (orderGroup.OrderForms.Count != 0))
            {
                OrderContext orderSystem   = OrderContext.Current;
                ClassInfo    orderFormInfo = orderSystem.OrderFormClassInfo;

                // need to set meta data context before cloning
                MetaDataContext.DefaultCurrent = OrderContext.MetaDataContext;
                foreach (OrderForm form in orderGroup.OrderForms)
                {
                    OrderForm orderForm = base.OrderForms[form.Name];
                    if (orderForm == null)
                    {
                        orderForm      = (OrderForm)orderFormInfo.CreateInstance();
                        orderForm.Name = form.Name;
                        base.OrderForms.Add(orderForm);
                    }

                    int count = form.LineItems.Count;
                    for (int i = 0; i < count; i++)
                    {
                        LineItem newLineItem = (LineItem)form.LineItems[i].Clone();
                        newLineItem.SetParent(orderForm);
                        orderForm.LineItems.Add(newLineItem, lineItemRollup);
                    }
                }
            }
        }
コード例 #2
0
ファイル: OrderForm.cs プロジェクト: hdgardner/ECF
 /// <summary>
 /// Loads the payment from the reader object and adds it to the payments collection.
 /// </summary>
 /// <param name="view">The view.</param>
 protected void LoadPayment(DataView view)
 {
     // Read until we are done, since this is a collection
     foreach (DataRowView row in view)
     {
         string    type         = row["ImplementationClass"].ToString();
         ClassInfo classInfo    = new ClassInfo(type);
         Payment   orderPayment = (Payment)classInfo.CreateInstance();
         orderPayment.Load(row);
         Payments.Add(orderPayment);
     }
 }
コード例 #3
0
ファイル: Details.cs プロジェクト: formist/LinkMe
		void IBinarySerializable.Read(BinaryReader reader)
		{
            _details = new List<IEventDetail>();
			int count = reader.ReadInt32();
			for ( int index = 0; index < count; ++index )
			{
				var classInfo = new ClassInfo(reader.ReadString());
				var serializable = classInfo.CreateInstance<IBinarySerializable>();
				serializable.Read(reader);
				_details.Add(serializable as IEventDetail);
			}
		}
コード例 #4
0
ファイル: EventParameter.cs プロジェクト: formist/LinkMe
        private void UnpackTypeXml()
        {
            // Create an instance.

            ClassInfo        info  = new ClassInfo(m_class);
            IXmlSerializable value = info.CreateInstance <IXmlSerializable>();

            // Ask the object to unserialize itself using the IXmlSerializable interface.

            XmlSerializer.Deserialize(value, (string)m_value);

            // Update.

            m_class       = null;
            m_value       = value;
            m_valueFormat = ValueFormat.Raw;
        }
コード例 #5
0
ファイル: Details.cs プロジェクト: formist/LinkMe
		private void ReadXml(XmlReadAdaptor adaptor)
		{
			const string method = "ReadXml";

			while ( adaptor.ReadElement(Constants.Xml.EventDetails.EventDetailElement, true) )
			{
				string type = adaptor.ReadAttributeString(Constants.Xml.ClassAttribute, true);

                object instance = null;
				var classInfo = new ClassInfo(type);

                try
                {
                    instance = classInfo.CreateInstance();
                }
                catch (Exception)
                {
                }
                
                IEventDetail eventDetail;
                IXmlSerializable serializable;
                if (instance != null)
                {
                    eventDetail = instance as IEventDetail;
                    if (eventDetail == null)
                        throw new TypeDoesNotImplementInterfaceException(GetType(), method, instance.GetType(), typeof(IEventDetail));

                    serializable = instance as IXmlSerializable;
                    if (serializable == null)
                        throw new TypeDoesNotImplementInterfaceException(GetType(), method, instance.GetType(), typeof(IXmlSerializable));
                }
                else
                {
                    eventDetail = new GenericDetail();
                    serializable = eventDetail as IXmlSerializable;
                }

                if (adaptor.ReadElement())
                    serializable.ReadOuterXml(adaptor.XmlReader);
				Add(eventDetail);

				adaptor.ReadEndElement();
			}
		}
コード例 #6
0
ファイル: EventParameter.cs プロジェクト: formist/LinkMe
        private void UnpackTypeBinary()
        {
            // Create an instance.

            ClassInfo           info  = new ClassInfo(m_class);
            IBinarySerializable value = info.CreateInstance <IBinarySerializable>();

            // Ask the object to unserialize itself using the IBinarySerializable interface.

            MemoryStream stream = new MemoryStream((byte[])m_value);

            using (BinaryReader reader = new BinaryReader(stream))
            {
                value.Read(reader);
            }

            m_class       = null;
            m_value       = value;
            m_valueFormat = ValueFormat.Raw;
        }
コード例 #7
0
        /// <summary>
        /// Handles the Click event of the SaveChangesButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void SaveChangesButton_Click(object sender, EventArgs e)
        {
            if (String.Compare(Request.Form["__EVENTARGUMENT"], _PostBackArgumentString) == 0)
            {
                Payment payment = null;

                if (PaymentId != 0)                 // find existing
                {
                    foreach (Payment p in _order.OrderForms[0].Payments)
                    {
                        if (p.PaymentId == PaymentId)
                        {
                            payment = p;
                            break;
                        }
                    }
                }

                // Create payment of selected type
                if (payment == null)
                {
                    // determine which payment type to create
                    // temporary solution, since the algorythm below is rather slow
                    MetaClass mc = MetaClass.Load(OrderContext.MetaDataContext, Int32.Parse(PaymentType.SelectedValue));
                    if (mc != null)
                    {
                        Type[] paymentTypes = ReflectionHelper.GetInheritedClasses(typeof(Payment));
                        Type   paymentType  = null;
                        if (paymentTypes != null)
                        {
                            foreach (Type pt in paymentTypes)
                            {
                                ClassInfo classInfo  = new ClassInfo(pt);
                                Payment   tmpPayment = (Payment)classInfo.CreateInstance();
                                if (tmpPayment.MetaClass.Id == mc.Id)
                                {
                                    paymentType = pt;
                                    break;
                                }
                            }
                        }

                        if (paymentType != null)
                        {
                            payment = _order.OrderForms[0].Payments.AddNew(paymentType);
                        }
                        //payment = _order.OrderForms[0].Payments.AddNew(typeof(CreditCardPayment));
                    }
                }

                if (payment != null)
                {
                    payment.Amount = Decimal.Parse(Amount.Text);
                    ListItem selectedPaymentStatus = PaymentStatus.Items.FindByValue(SelectedPaymentStatusField.Value);
                    if (selectedPaymentStatus != null)
                    {
                        payment.Status = selectedPaymentStatus.Value;
                    }

                    payment.PaymentMethodId   = new Guid(PaymentMethodList.SelectedValue);
                    payment.PaymentMethodName = Name.Text;
                    ListItem selectedPaymentMethod = PaymentMethodList.Items.FindByValue(SelectedPaymentMethodField.Value);
                    if (selectedPaymentMethod != null)
                    {
                        payment.PaymentMethodId = new Guid(selectedPaymentMethod.Value);
                    }

                    //ListItem selectedPaymentType = PaymentType.Items.FindByValue(SelectedPaymentTypeField.Value);
                    //if (selectedPaymentType != null)
                    //    payment.MetaClass = new Guid(selectedPaymentMethod.Value);
                }

                // Put a dictionary key that can be used by other tabs
                MetaDataTab.ObjectId = payment.PaymentId;
                IDictionary dic = new ListDictionary();
                dic.Add(MetaDataTab._MetaObjectContextKey + MetaDataTab.Languages[0], payment);
                MetaDataTab.SaveChanges(dic);
            }

            ScriptManager.RegisterStartupScript(MetaDataTab, typeof(OrderPaymentEditTab), "DialogClose", "Payment_CloseDialog();", true);
        }
コード例 #8
0
ファイル: OrderGroup.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Populates the collection.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="classInfo">The class info.</param>
        /// <param name="collection">The collection.</param>
        /// <param name="dataSet">The data set.</param>
        protected static void PopulateCollection <T>(ClassInfo classInfo, MetaStorageCollectionBase <T> collection, DataSet dataSet) where T : OrderGroup
        {
            #region ArgumentNullExceptions
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }
            #endregion

            DataTableCollection tables = dataSet.Tables;

            if (tables == null || tables.Count == 0)
            {
                return;
            }

            // Get the collection that contains ids of all items returned
            DataRowCollection dataRowCol = tables[0].Rows;

            // No ids returned
            if (dataRowCol == null || dataRowCol.Count == 0)
            {
                return;
            }

            int   numberOfRecords = dataRowCol.Count;
            int[] idArray         = new int[numberOfRecords];

            // Populate array
            for (int index = 0; index < numberOfRecords; index++)
            {
                idArray[index] = (int)dataRowCol[index]["OrderGroupId"];
            }

            // Remove id collection
            tables.RemoveAt(0);

            // Map table names
            foreach (DataTable table in dataSet.Tables)
            {
                if (table.Rows.Count > 0)
                {
                    table.TableName = table.Rows[0]["TableName"].ToString();
                }
            }

            // Cycle through id Collection
            foreach (int id in idArray)
            {
                string filter = String.Format("OrderGroupId = '{0}'", id.ToString());

                // Populate the meta object data first
                // Meta data will be always in the second table returned
                DataView view = DataHelper.CreateDataView(dataSet.Tables["OrderGroup"], filter);

                // Only read one record, since we are populating only one object
                // reader.Read();

                // Create instance of the object specified and populate it
                T obj = (T)classInfo.CreateInstance();
                obj.Load(view[0]);
                collection.Add(obj);

                // Populate collections within object
                obj.PopulateCollections(dataSet.Tables, filter);

                /*
                 * if (dataSet.Tables.Count != 0)
                 * {
                 *  throw new ArgumentOutOfRangeException("Tables", "Stored Procedure returned too many tables");
                 * }
                 * */
            }
        }