예제 #1
0
        /// {"primaryKeyId":6, "column":1, "value":"11:21"}
        public void UpdateGrid(string ContextKey, object[] ChangesArray)
        {
            //List<string> fieldName = new List<string>();
            MetaGridContextKey gridContextKey = UtilHelper.JsonDeserialize <MetaGridContextKey>(ContextKey);
            List <MetaObject>  changed        = new List <MetaObject>();

            CHelper.AddToContext("GridUpdated", 1);

            LoadMetaViewPreference(gridContextKey.ViewName);
            MetaView CurrentView = GetViewByName(gridContextKey.ViewName);

            MetaObject[] list = CurrentView.List(mvPref);

            if (CurrentView.PrimaryGroupBy != null || CurrentView.SecondaryGroupBy == null)
            {
                if (CurrentView.SecondaryGroupBy != null)
                {
                    list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Secondary, CurrentView.SecondaryGroupBy, CurrentView.PrimaryGroupBy, mvPref, list);
                }

                list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Primary, CurrentView.PrimaryGroupBy, null, mvPref, list);
            }


            foreach (Dictionary <string, object> obj in ChangesArray)
            {
                int    primaryKeyId = Convert.ToInt32(obj["primaryKeyId"]);
                int    columnId     = Convert.ToInt32(obj["column"]);
                string value        = Convert.ToString(obj["value"]);

                MetaObject tmp       = GetMetaObjectById(list, primaryKeyId);
                MetaObject curObject = null;
                if (tmp != null)
                {
                    curObject = MetaObjectActivator.CreateInstance(tmp.GetMetaType(), primaryKeyId);
                }
                else
                {
                    continue;
                }

                curObject.Properties[GetFieldNameByIndex(columnId)].Value = GetMinutesFromString(value);

                changed.Add(curObject);
            }


            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                foreach (MetaObject changeObj in changed)
                {
                    changeObj.Save();
                }

                tran.Commit();
            }
        }
예제 #2
0
        /// <summary>
        /// Binds a data source to the invoked server control and all its child controls.
        /// </summary>
        public override void  DataBind()
        {
            string className = "";

            if (DataItem != null)
            {
                MetaObject mo = null;

                if (DataItem is MetaObject)
                {
                    mo = (MetaObject)DataItem;
                }
                else if (DataItem is BusinessObjectRequest)
                {
                    mo = ((BusinessObjectRequest)DataItem).MetaObject;
                }

                className = mo.GetMetaType().Name;
                if (mo.GetCardMetaType() != null)
                {
                    className = mo.GetCardMetaType().Name;
                }
                ViewState["ClassName"] = className;

                if (String.IsNullOrEmpty(FormName))
                {
                    if (DataItem is MetaObject)
                    {
                        FormName = FormController.BaseFormType;
                    }
                    else if (DataItem is BusinessObjectRequest)
                    {
                        FormName = FormController.CreateFormType;
                    }
                }
            }
            else if (ViewState["ClassName"] != null)
            {
                className = ViewState["ClassName"].ToString();
            }

            FormDocument doc = FormController.LoadFormDocument(className, FormName);

            if (doc != null)
            {
                _formExists = true;
                fRenderer.FormDocumentData = doc;
                fRenderer.FormType         = FormType;
                fRenderer.PlaceName        = PlaceName;
                if (DataItem != null)
                {
                    fRenderer.DataItem = DataItem;
                }
                fRenderer.DataBind();
            }
        }
예제 #3
0
        private void ProcessControl(Control c, MetaObject mo)
        {
            IEditControl fc = c as IEditControl;

            if (fc != null && !fc.ReadOnly)
            {
                string fieldName = fc.FieldName;
                if (fieldName.ToLower() == "title" && mo.Properties[fieldName] == null)
                {
                    fieldName = mo.GetMetaType().TitleFieldName;
                }
                mo.Properties[fieldName].Value = fc.Value;
            }
        }
예제 #4
0
        internal static void UpdateAddressName(MetaObject address)
        {
            if (address == null)
                return;

            if (address.GetMetaType().Name != AddressEntity.GetAssignedMetaClassName())
                throw new ArgumentOutOfRangeException("The address object has wrong meta object type. Should be 'Address'.");

            address["Name"] = string.Join(";",
                new string[] {
                    address.Properties["Line2"].GetValue<string>(string.Empty),
                    address.Properties["Line1"].GetValue<string>(string.Empty),
                    address.Properties["City"].GetValue<string>(string.Empty),
                    address.Properties["Region"].GetValue<string>(string.Empty),
                    address.Properties["PostalCode"].GetValue<string>(string.Empty),
                    address.Properties["Country"].GetValue<string>(string.Empty)
                });
        }
예제 #5
0
        internal static void UpdateAddressName(MetaObject address)
        {
            if (address == null)
            {
                return;
            }

            if (address.GetMetaType().Name != AddressEntity.GetAssignedMetaClassName())
            {
                throw new ArgumentOutOfRangeException("The address object has wrong meta object type. Should be 'Address'.");
            }

            address["Name"] = string.Join(";",
                                          new string[] {
                address.Properties["Line2"].GetValue <string>(string.Empty),
                address.Properties["Line1"].GetValue <string>(string.Empty),
                address.Properties["City"].GetValue <string>(string.Empty),
                address.Properties["Region"].GetValue <string>(string.Empty),
                address.Properties["PostalCode"].GetValue <string>(string.Empty),
                address.Properties["Country"].GetValue <string>(string.Empty)
            });
        }
예제 #6
0
 private void ProcessControl(Control c, MetaObject mo)
 {
     IEditControl fc = c as IEditControl;
     if (fc != null && !fc.ReadOnly)
     {
         string fieldName = fc.FieldName;
         if (fieldName.ToLower() == "title" && mo.Properties[fieldName] == null)
         {
             fieldName = mo.GetMetaType().TitleFieldName;
         }
         mo.Properties[fieldName].Value = fc.Value;
     }
 }