Exemplo n.º 1
0
        protected void lbAddItems_Click(object sender, EventArgs e)
        {
            string s = Request["__EVENTARGUMENT"];

            if (!String.IsNullOrEmpty(s))
            {
                string[]     mas   = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]);
                foreach (string item in mas)
                {
                    PrimaryKeyId id        = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item));
                    string       className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item);

                    if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined)
                    {
                        EntityObject eo = BusinessManager.Load(className, id);
                        if (eo != null && !String.IsNullOrEmpty(FilterFieldName) &&
                            eo.Properties[FilterFieldName] != null)
                        {
                            eo[FilterFieldName] = objId;
                            BusinessManager.Update(eo);
                        }
                    }
                }
                CHelper.RequireDataBind();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the lbAddItems 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 lbAddItems_Click(object sender, EventArgs e)
        {
            string s = Request["__EVENTARGUMENT"];

            if (!String.IsNullOrEmpty(s))
            {
                string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string item in mas)
                {
                    PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item));
                    this.Value = MetaViewGroupUtil.GetIdFromUniqueKey(item);

                    string       className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item);
                    EntityObject obj       = BusinessManager.Load(className, id);

                    MetaClass mc = MetaDataWrapper.GetMetaClassByName(obj.MetaClassName);
                    lblValue.Text = obj.Properties[mc.TitleFieldName].Value.ToString();
                }
                this.RaiseBubbleEvent(this, e);
            }
        }
Exemplo n.º 3
0
        protected void lbAddItems_Click(object sender, EventArgs e)
        {
            string s = Request["__EVENTARGUMENT"];

            if (!String.IsNullOrEmpty(s))
            {
                string[]     mas   = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]);
                foreach (string item in mas)
                {
                    PrimaryKeyId id        = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item));
                    string       className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item);

                    if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined)
                    {
                        FilterElementCollection fec = new FilterElementCollection();
                        fec.Add(FilterElement.EqualElement(Filter1FieldName, PrimaryKeyId.Parse(Request["ObjectId"])));
                        fec.Add(FilterElement.EqualElement(Filter2FieldName, id));
                        EntityObject[] list = BusinessManager.List(BridgeClassName, fec.ToArray());
                        if (list.Length == 0)
                        {
                            EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName);
                            eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]);
                            eo[Filter2FieldName] = id;
                            BusinessManager.Create(eo);
                        }
                    }
                    else if (id != PrimaryKeyId.Empty)
                    {
                        EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName);
                        eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]);
                        eo[Filter2FieldName] = id;
                        BusinessManager.Create(eo);
                    }
                }
                CHelper.RequireDataBind();
            }
        }
Exemplo n.º 4
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;

                string[] elems = null;
                if (cp.CommandArguments.ContainsKey("GridId"))
                {
                    elems = MetaGridServer.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);
                }

                List <int> ttbIds = new List <int>();

                //fix by DV: 2008-05-14
                //Esli vyzyvaetsa s grida (iconka v otklonennih listah), to primitiv v gride ustanovit etot flag
                //i togda ID budet bratsa iz parametrov, v protivnom sluchae ID - beretsa iz checkboxes
                if (!cp.CommandArguments.ContainsKey("callFromGrid"))
                {
                    foreach (string elem in elems)
                    {
                        string type = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(elem);                        // elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1];
                        if (type == MetaViewGroupUtil.keyValueNotDefined)
                        {
                            continue;
                        }

                        int id = Convert.ToInt32(MetaViewGroupUtil.GetIdFromUniqueKey(elem), CultureInfo.InvariantCulture);                         //Convert.ToInt32(elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0], CultureInfo.InvariantCulture);


                        if (type == TimeTrackingEntry.GetAssignedMetaClass().Name)
                        {
                            //TimeTrackingEntry tte = MetaObjectActivator.CreateInstance<TimeTrackingEntry>(TimeTrackingEntry.GetAssignedMetaClass(), id);

                            //if (!ttbIds.Contains(tte.ParentBlockId))
                            //    ttbIds.Add(tte.ParentBlockId);
                        }
                        else
                        {
                            if (!ttbIds.Contains(id))
                            {
                                ttbIds.Add(id);
                            }
                        }
                    }
                }
                else
                {
                    ttbIds.Add(Convert.ToInt32(MetaViewGroupUtil.GetIdFromUniqueKey(cp.CommandArguments["primaryKeyId"]), CultureInfo.InvariantCulture));
                }

                using (TransactionScope tran = DataContext.Current.BeginTransaction())
                {
                    foreach (int ttbId in ttbIds)
                    {
                        TimeTrackingBlock ttb = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), ttbId);

                        StateMachineService sms = ((BusinessObject)ttb).GetService <StateMachineService>();

                        // process only initial state
                        if (sms.StateMachine.GetStateIndex(sms.CurrentState.Name) == 0)
                        {
                            StateTransition[] availableTransitions = sms.GetNextAvailableTransitions(true);
                            if (availableTransitions.Length > 0)
                            {
                                sms.MakeTransition(availableTransitions[0].Uid);
                                ttb.Save();
                            }
                        }
                    }
                    tran.Commit();
                }
            }
        }