コード例 #1
0
        /// <summary>
        /// Closes the assignment.
        /// </summary>
        /// <param name="context">The context.</param>
        protected virtual void CloseAssignment(BusinessContext context)
        {
            CloseAssignmentRequest request = (CloseAssignmentRequest)context.Request;

            // Load Assignment
            MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Active)
            {
                throw new InvalidOperationException();
            }

            DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);

            // Update Meta Object Fields
            metaObject[AssignmentEntity.FieldClosedBy]         = (int)DataContext.Current.CurrentUserId;
            metaObject[AssignmentEntity.FieldState]            = (int)AssignmentState.Closed;
            metaObject[AssignmentEntity.FieldExecutionResult]  = request.ExecutionResult;
            metaObject[AssignmentEntity.FieldComment]          = request.Comment;
            metaObject[AssignmentEntity.FieldActualFinishDate] = dateTimeNow;

            // Save Meta Object
            metaObject.Save();

            if (metaObject[AssignmentEntity.FieldWorkflowInstanceId] != null)
            {
                // Run Workflow
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
                RunWorkflow(entity);
            }

            context.SetResponse(new Response());
        }
コード例 #2
0
        /// <summary>
        /// Activates the assignment.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ActivateAssignment(BusinessContext context)
        {
            // Load Assignment
            MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Pending)
            {
                throw new InvalidOperationException();
            }

            // Load Meta Object
            DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);

            metaObject[AssignmentEntity.FieldState]           = (int)AssignmentState.Active;
            metaObject[AssignmentEntity.FieldActualStartDate] = dateTimeNow;

            // Save Meta Object
            metaObject.Save();

            //if (entity.WorkflowInstanceId.HasValue)
            //{
            //    // Run Workflow
            //    RunWorkflow(entity);
            //}

            context.SetResponse(new Response());
        }
コード例 #3
0
        /// <summary>
        /// Suspends the assignment.
        /// </summary>
        /// <param name="context">The context.</param>
        private void SuspendAssignment(BusinessContext context)
        {
            // Load Assignment
            MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Active)
            {
                throw new InvalidOperationException();
            }

            // Load Meta Object

            metaObject[AssignmentEntity.FieldState] = (int)AssignmentState.Suspended;

            // Save Meta Object
            metaObject.Save();

            if (metaObject[AssignmentEntity.FieldWorkflowInstanceId] != null)
            {
                // Run Workflow
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
                RunWorkflow(entity);
            }


            context.SetResponse(new Response());
        }
コード例 #4
0
        protected string GetPostedTime(object obj, object objectType, int timeTrackingEntryId)
        {
            string retval = "";

            if (obj != null && obj != DBNull.Value && objectType != null && objectType != DBNull.Value)
            {
                int objectId     = (int)obj;
                int objectTypeId = (int)objectType;

                if (objectTypeId == (int)ObjectTypes.CalendarEntry ||
                    objectTypeId == (int)ObjectTypes.Document ||
                    objectTypeId == (int)ObjectTypes.Issue ||
                    objectTypeId == (int)ObjectTypes.Task ||
                    objectTypeId == (int)ObjectTypes.ToDo)
                {
                    int minutes = TimeTrackingManager.GetPostedTimeByObject((int)objectId, (int)objectTypeId);
                    retval = Mediachase.UI.Web.Util.CommonHelper.GetHours(minutes);
                }
            }
            else if ((bool)block.Properties["AreFinancesRegistered"].Value)
            {
                TimeTrackingEntry entry = MetaObjectActivator.CreateInstance <TimeTrackingEntry>(TimeTrackingEntry.GetAssignedMetaClass(), timeTrackingEntryId);
                int minutes             = 0;
                if (entry.Properties["TotalApproved"].Value != null && entry.Properties["TotalApproved"].Value != DBNull.Value)
                {
                    minutes = Convert.ToInt32(entry.Properties["TotalApproved"].Value);
                }
                retval = Mediachase.UI.Web.Util.CommonHelper.GetHours(minutes);
            }

            return(retval);
        }
コード例 #5
0
        private void Reactivate(BusinessContext context)
        {
            // Load Assignment
            MetaObject metaObject = MetaObjectActivator.CreateInstance(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            if (((int)metaObject[AssignmentEntity.FieldState]) != (int)AssignmentState.Closed)
            {
                throw new InvalidOperationException();
            }

            // Load Meta Object
            metaObject[AssignmentEntity.FieldState]            = (int)AssignmentState.Active;
            metaObject[AssignmentEntity.FieldActualFinishDate] = null;
            metaObject[AssignmentEntity.FieldActualWork]       = null;

            // Save Meta Object
            metaObject.Save();

            //if (entity.WorkflowInstanceId.HasValue)
            //{
            //    // Run Workflow
            //    RunWorkflow(entity);
            //}

            context.SetResponse(new Response());
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CHelper.AddToContext("ClassName", ClassName);
            CHelper.AddToContext("ObjectId", ObjectId);
            //CHelper.AddToContext(NavigationBlock.KeyContextMenu, "class_" + ClassName);
            //CHelper.AddToContext(NavigationBlock.KeyContextMenuTitle, CommonHelper.GetResFileString(mc.FriendlyName));

            this.Page.PreRenderComplete += new EventHandler(Page_PreRenderComplete);
            xmlStruct.InnerDataBind     += new XmlFormBuilder.InnerDataBindEventHandler(xmlStruct_InnerDataBind);

            if (!Page.IsPostBack)
            {
                xmlStruct.ClassName  = ClassName;
                xmlStruct.LayoutType = LayoutType.ObjectView;
                if (!String.IsNullOrEmpty(PlaceName))
                {
                    xmlStruct.PlaceName = PlaceName;
                }
                xmlStruct.LayoutMode = LayoutMode.WithTabs;

                if (_bindObject == null)
                {
                    _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName), ObjectId);
                }

                xmlStruct.CheckVisibleTab = _bindObject;

                xmlStruct.DataBind();
            }
        }
コード例 #7
0
ファイル: TimeTrackingEntry.cs プロジェクト: alex765022/IBN
        protected override void OnSaving()
        {
            int blockId = this.ParentBlockId;

            // O.R. [2008-07-29]
            if (!SkipSecurityCheckScope.IsActive)
            {
                // Check rights
                if (!TimeTrackingBlock.CheckUserRight(blockId, Security.RightWrite))
                {
                    throw new AccessDeniedException();
                }
            }

            // O.R. [2008-08-04]: If finances are registered, set TotalApproved for new entries to zero.
            // So we can see the differences in the "Accounts" tab of info popup
            TimeTrackingBlock block = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), blockId);

            if ((bool)block.Properties["AreFinancesRegistered"].Value && this.Properties["TotalApproved"].Value == null)
            {
                this.Properties["TotalApproved"].Value = 0;
            }

            base.OnSaving();
        }
コード例 #8
0
        public bool IsEnable(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;

                if (!cp.CommandArguments.ContainsKey("parentBlockId"))
                {
                    return(false);
                }

                MetaObject          ttb         = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName("TimeTrackingBlock"), Convert.ToInt32(cp.CommandArguments["parentBlockId"]));
                StateMachineService sms         = ((BusinessObject)ttb).GetService <StateMachineService>();
                StateTransition[]   transitions = sms.GetNextAvailableTransitions(true);

                bool retval = true;
                if (transitions.Length == 0)
                {
                    transitions = sms.GetPrevAvailableTransitions(true);
                    retval      = transitions.Length > 0;
                }
                return(retval);
            }

            return(false);
        }
コード例 #9
0
        void ctrlUpdate_ValueChanged(object sender, EventArgs e)
        {
            xmlStruct.Controls.Clear();
            string[] mas = ctrlUpdate.Value.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);
            if (mas.Length > 0)
            {
                ClassName = mas[0].Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1];

                if (ClassName == MetaViewGroupUtil.keyValueNotDefined)
                {
                    CHelper.UpdateParentPanel(this);
                    return;
                }
                ObjectId = Convert.ToInt32(mas[0].Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0]);

                _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName), ObjectId);

                if (_bindObject != null && _bindObject.GetCardMetaType() != null)
                {
                    ClassName = _bindObject.GetCardMetaType().Name;
                }

                xmlStruct.ClassName           = ClassName;
                xmlStruct.LayoutType          = LayoutType.ObjectView;
                xmlStruct.PlaceName           = "TTGridDetails";
                xmlStruct.LayoutMode          = LayoutMode.WithTabs;
                xmlStruct.TabBlockCssClass    = "ibn-stylebox-light";
                xmlStruct.TabLeftGap          = false;
                xmlStruct.SelectTabByPostback = true;
                xmlStruct.CheckVisibleTab     = _bindObject;

                xmlStruct.DataBind();
            }
            CHelper.UpdateParentPanel(this);
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (BlockId <= 0)
            {
                throw new ArgumentException("BlockId is wrong or not specified");
            }

            block = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), BlockId);
//			block = new TimeTrackingBlock(BlockId);

            SecurityService ss = block.GetService <SecurityService>();

            if (ss == null || !ss.CheckUserRight(TimeTrackingManager.Right_RegFinances))
            {
                throw new AccessDeniedException();
            }

            btnApprove.Text = LocRM.GetString("tApprove");
            btnCancel.Text  = LocRM.GetString("tCancel");
            if (!Page.IsPostBack)
            {
                BindAccounts();
                dtcDate.SelectedDate = Mediachase.IBN.Business.User.GetLocalDate(DateTime.UtcNow).Date;
            }

            btnApprove.CustomImage = CHelper.GetAbsolutePath("/layouts/images/accept.gif");
            btnCancel.CustomImage  = CHelper.GetAbsolutePath("/layouts/images/cancel.gif");
        }
コード例 #11
0
        public static void RecalculateObject()
        {
            if (TriggerContext.Current == null)
            {
                throw new ArgumentException("TriggerContext.Current == null");
            }

            TimeTrackingEntry entry = TriggerContext.Current.Parameter.MetaObject as TimeTrackingEntry;

            if (entry == null)
            {
                return;
            }

            TimeTrackingBlock block = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), entry.ParentBlockId);

            int projectId = GetProjectIdByTimeTrackingBlock(block);

            //TimeTracking.RecalculateObject(int? objectId, int? objectTypeId, int projectId)
            //надо вызывать при создании TimeTrackingEntry (с хотя бы одним ненулевым Day1, Day2..., Day7)
            //при изменении TimeTrackingEntry (когда изменился хотя бы один Day1, Day2..., Day7) и
            // при удалении TimeTrackingEntry (с хотя бы одним ненулевым Day1, Day2..., Day7)

            // Comment conition because can n't detects that all DayX set to zero
            if (TriggerContext.Current.Parameter.State == MetaObjectState.Created && (entry.Day1 != 0 || entry.Day2 != 0 || entry.Day3 != 0 ||
                                                                                      entry.Day4 != 0 || entry.Day5 != 0 || entry.Day6 != 0 || entry.Day7 != 0) ||
                TriggerContext.Current.Parameter.State != MetaObjectState.Created)
            {
                RecalculateObjectAndProject(entry.Properties["ObjectId"].GetValue <int?>(),
                                            entry.Properties["ObjectTypeId"].GetValue <int?>(),
                                            projectId);
            }
        }
コード例 #12
0
        /// <summary>
        /// Resets the delivery attempts.
        /// </summary>
        /// <param name="context">The context.</param>
        protected virtual void ResetDeliveryAttempts(BusinessContext context)
        {
            MetaObject metaObject = MetaObjectActivator.CreateInstance(context.GetTargetMetaClassName(), context.GetTargetPrimaryKeyId().Value);

            metaObject[OutgoingMessageQueueEntity.FieldDeliveryAttempts] = 0;

            metaObject.Save();
        }
コード例 #13
0
ファイル: ListHandler.asmx.cs プロジェクト: alex765022/IBN
        /// {"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();
            }
        }
コード例 #14
0
ファイル: NewFolderTab.ascx.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Binds the data. Get the folder business object and add the folder name to the textbox
        /// </summary>
        private void BindData()
        {
            BusinessObject _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>("Folder", FolderId);

            if (_bindObject != null)
            {
                FolderName.Text = _bindObject["Name"].ToString();
            }
        }
コード例 #15
0
ファイル: MultipleAdd.ascx.cs プロジェクト: alex765022/IBN
        private void BindSingleBlockTypeInstance(int blockTypeInstanceId)
        {
            TimeTrackingBlockTypeInstance blockTypeInstance = MetaObjectActivator.CreateInstance <TimeTrackingBlockTypeInstance>(TimeTrackingBlockTypeInstance.GetAssignedMetaClass(), blockTypeInstanceId);

            BlockInstanceList.Items.Add(new ListItem(blockTypeInstance.Properties[titledFieldName].Value.ToString(), blockTypeInstanceId.ToString()));

            BlockInstanceList.Enabled = false;                  // lock
            ProjectRow.Visible        = false;
        }
コード例 #16
0
        private void BindProjects()
        {
            ProjectList.Items.Clear();

            if (startDate == DateTime.MinValue)
            {
                return;
            }

            string titledFieldName = TimeTrackingManager.GetBlockTypeInstanceMetaClass().TitleFieldName;

            int blockTypeInstanceFromFilter = GetProjectFromFilter();

            if (blockTypeInstanceFromFilter > 0)
            {
                TimeTrackingBlockTypeInstance inst = MetaObjectActivator.CreateInstance <TimeTrackingBlockTypeInstance>(TimeTrackingBlockTypeInstance.GetAssignedMetaClass(), blockTypeInstanceFromFilter);
                if (inst != null)
                {
                    ProjectList.Items.Add(new ListItem(inst.Properties[titledFieldName].Value.ToString(), blockTypeInstanceFromFilter.ToString()));
                }
            }
            else                // all instances
            {
                // Non-project
                bool isHeaderAdded = false;
                foreach (TimeTrackingBlockTypeInstance bo in TimeTrackingManager.GetNonProjectBlockTypeInstances())
                {
                    if (!isHeaderAdded)
                    {
                        ProjectList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "ByActivity").ToString(), "-1"));
                        isHeaderAdded = true;
                    }

                    ListItem li = new ListItem("   " + bo.Properties[titledFieldName].Value.ToString(), bo.PrimaryKeyId.ToString());
                    ProjectList.Items.Add(li);
                }

                // Projects
                isHeaderAdded = false;
                foreach (TimeTrackingBlockTypeInstance bo in TimeTrackingManager.GetProjectBlockTypeInstances())
                {
                    if (!isHeaderAdded)
                    {
                        ProjectList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "ByProject").ToString(), "-2"));
                        isHeaderAdded = true;
                    }

                    ListItem li = new ListItem("   " + bo.Properties[titledFieldName].Value.ToString(), bo.PrimaryKeyId.ToString());
                    ProjectList.Items.Add(li);
                }
            }

            EnsureSelectInstance();

            BindUsers();
        }
コード例 #17
0
ファイル: FileAddTab.ascx.cs プロジェクト: hdgardner/ECF
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            BusinessObject _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>("FolderElement", ObjectId);

            if (_bindObject != null)
            {
                ucView.DataItem = _bindObject;
                ucView.DataBind();
            }
        }
コード例 #18
0
ファイル: Info.ascx.cs プロジェクト: alex765022/IBN
        public void MakeDataBind(Control _ctrl)
        {
            if (ClassName == string.Empty && _bindObject == null)
            {
                return;
            }

            _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName), ObjectId);

            MakeDataBindColl(_ctrl.Controls, _bindObject);
        }
コード例 #19
0
ファイル: FileAddTab.ascx.cs プロジェクト: hdgardner/ECF
        //protected void tProgress_Tick(object sender, EventArgs e)
        //{
        //    // Get ref to the progress and try to display bytes so far.
        //    Guid _progressUid =
        //        new Guid(Request.Form["__MEDIACHASE_FORM_UNIQUEID"]);
        //    UploadProgressInfo _upi =
        //        UploadProgress.Provider.GetInfo(_progressUid);

        //    if (_upi != null)
        //    {
        //        this.lProgress.Text = _upi.BytesReceived.ToString();

        //        // Always update the time display every interval.
        //        this.lTime.Text = DateTime.Now.ToLongTimeString();

        //    }
        //    //else
        //    //{
        //    //    // Just display the form param to make sure it's even there.
        //    //    this.lProgress.Text = _progressUid.ToString();
        //    //}
        //}

        #region IAdminTabControl Members
        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <param name="context">The context.</param>
        public void SaveChanges(IDictionary context)
        {
            if (ObjectId > 0)
            {
                BusinessObject _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>("FolderElement", ObjectId);
                if (_bindObject != null)
                {
                    ProcessCollection(this.Page.Controls, (BusinessObject)_bindObject);
                    ((BusinessObject)_bindObject).Save();
                }
            }
        }
コード例 #20
0
ファイル: NewFolderTab.ascx.cs プロジェクト: hdgardner/ECF
 /// <summary>
 /// Saves the changes made to the folder name
 /// </summary>
 /// <param name="context">The context.</param>
 public void SaveChanges(IDictionary context)
 {
     if (FolderId > 0)
     {
         BusinessObject _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>("Folder", FolderId);
         if (_bindObject != null)
         {
             _bindObject["Name"] = FolderName.Text;
             //ProcessCollection(this.Page.Controls, (BusinessObject)_bindObject);
             ((BusinessObject)_bindObject).Save();
         }
     }
 }
コード例 #21
0
        public void MakeDataBind(Control _ctrl)
        {
            if (_bindObject == null)
            {
                _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName), ObjectId);
            }
            MakeDataBindColl(_ctrl.Controls, _bindObject);

            if (BindSectionHeader)
            {
                BindToolbar();
            }
        }
コード例 #22
0
ファイル: QuickAdd.ascx.cs プロジェクト: alex765022/IBN
        private void ApplyStartValues()
        {
            if (BlockId > 0)
            {
                TimeTrackingBlock block = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), BlockId);
                if (block != null)
                {
                    blockInstanceId = block.BlockTypeInstanceId;
                }
            }

            BindNullValues();
        }
コード例 #23
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            if (this.ClassName == TimeTrackingEntry.GetAssignedMetaClass().Name)
            {
                TimeTrackingEntry tte = MetaObjectActivator.CreateInstance <TimeTrackingEntry>(TimeTrackingEntry.GetAssignedMetaClass(), this.ObjectId);

                BindDayHeaders(tte.StartDate);
                BindTTEntry(tte);
                frmView.DataItem = tte;
                frmView.DataBind();

                if (TimeTrackingBlock.CheckUserRight(tte.ParentBlockId, Security.RightWrite))
                {
                    TTBlock.Visible       = false;
                    TTEntry.Visible       = true;
                    ReadOnlyBlock.Visible = false;
                }
                else
                {
                    TTBlock.Visible       = false;
                    TTEntry.Visible       = false;
                    ReadOnlyBlock.Visible = true;
                }
            }
            else if (this.ClassName == TimeTrackingBlock.GetAssignedMetaClass().Name)
            {
                TimeTrackingBlock ttb = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), this.ObjectId);

                frmViewBlock.DataItem = ttb;
                frmViewBlock.DataBind();

                if (TimeTrackingBlock.CheckUserRight(ttb.PrimaryKeyId.Value, Security.RightWrite))
                {
                    TTBlock.Visible       = true;
                    TTEntry.Visible       = false;
                    ReadOnlyBlock.Visible = false;
                }
                else
                {
                    TTBlock.Visible       = false;
                    TTEntry.Visible       = false;
                    ReadOnlyBlock.Visible = true;
                }
            }
            else
            {
                TTBlock.Visible       = false;
                TTEntry.Visible       = false;
                ReadOnlyBlock.Visible = true;
            }
        }
コード例 #24
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (CHelper.NeedToDataBind())
            {
                if (_bindObject == null)
                {
                    _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName), ObjectId);
                }

                xmlStruct.CheckVisibleTab = _bindObject;

                xmlStruct.DataBind();
            }
        }
コード例 #25
0
        private void BindData()
        {
            if (BlockId > 0)
            {
                TimeTrackingBlock   ttb             = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), BlockId);
                StateMachineService sms             = ttb.GetService <StateMachineService>();
                StateTransition[]   nextTransitions = sms.GetNextAvailableTransitions();
                StateTransition[]   prevTransitions = sms.GetPrevAvailableTransitions();

                ttbTitle.Text        = ttb.Title;
                TTBlockComment.Value = string.Empty;

                BindTransitions(nextTransitions, prevTransitions);
            }
        }
コード例 #26
0
        protected override void Create(BusinessContext context)
        {
            base.Create(context);

            // Append to tree
            DirectoryOrganizationalUnitEntity target = ((DirectoryOrganizationalUnitEntity)context.Request.Target);

            BusinessObject newElement = (BusinessObject)context.Items[MetaObjectRequestHandler.SourceMetaObjectKey];
            BusinessObject parent     = (BusinessObject)MetaObjectActivator.CreateInstance(DirectoryOrganizationalUnitEntity.ClassName,
                                                                                           target.ParentId.Value);

            TreeNode node = parent.GetService <TreeService>().AppendChild(newElement);

            parent.Save();
        }
コード例 #27
0
        private void SaveObject()
        {
            if (ObjectId > 0)
            {
                _bindObject = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName), ObjectId);

                if (_bindObject != null)
                {
                    ProcessCollection(this.Page.Controls, _bindObject);
                    _bindObject.Save();

                    CHelper.UpdateParentPanel(this);
                }
            }
        }
コード例 #28
0
 private void BindObject()
 {
     if (!String.IsNullOrEmpty(_className) && ObjectId > 0)
     {
         BusinessObject bo = MetaObjectActivator.CreateInstance <BusinessObject>(MetaDataWrapper.ResolveMetaClassByNameOrCardName(_className), ObjectId);
         txtName.InnerHtml = String.Format("<div style='padding:2px;'><span style='float:left;'>{0}</span><span style='float:right;cursor:pointer;padding-right:4px;' onclick=\"{2}\"><img alt='' align='absmiddle' src='{1}' style='cursor:pointer;' /></span></div>",
                                           bo.Properties[bo.GetMetaType().TitleFieldName].Value.ToString(),
                                           CHelper.GetAbsolutePath("/images/IbnFramework/delete.gif"),
                                           String.Format("CancelBubble_SelectPopups(event);__doPostBack('{0}', '')", hfClear.ClientID));
     }
     else
     {
         txtName.InnerHtml = String.Format("<div style='padding:2px;'>{0}</div>", "Not Set");
     }
 }
コード例 #29
0
        /// <summary>
        /// Customs the method.
        /// </summary>
        /// <param name="context">The context.</param>
        protected virtual void SetDefaultAddress(BusinessContext context)
        {
            // Load Address
            MetaObject newDefaultAddress = MetaObjectActivator.CreateInstance(AddressEntity.GetAssignedMetaClassName(),
                                                                              context.GetTargetPrimaryKeyId().Value);


            if (newDefaultAddress["ContactId"] != null)
            {
                // Find default addresses
                MetaObject[] defaultAddressList = MetaObject.List(DataContext.Current.GetMetaClass(AddressEntity.GetAssignedMetaClassName()),
                                                                  FilterElement.EqualElement("ContactId", newDefaultAddress["ContactId"]),
                                                                  FilterElement.EqualElement("IsDefaultContactElement", true));

                // Reset default addresses
                foreach (MetaObject defaultAddress in defaultAddressList)
                {
                    defaultAddress["IsDefaultContactElement"] = false;
                    defaultAddress.Save();
                }

                // Set default address
                newDefaultAddress["IsDefaultContactElement"] = true;
                newDefaultAddress.Save();
            }
            else if (newDefaultAddress["OrganizationId"] != null)
            {
                // Find default addresses
                MetaObject[] defaultAddressList = MetaObject.List(DataContext.Current.GetMetaClass(AddressEntity.GetAssignedMetaClassName()),
                                                                  FilterElement.EqualElement("OrganizationId", newDefaultAddress["OrganizationId"]),
                                                                  FilterElement.EqualElement("IsDefaultOrganizationElement", true));

                // Reset default addresses
                foreach (MetaObject defaultAddress in defaultAddressList)
                {
                    defaultAddress["IsDefaultOrganizationElement"] = false;
                    defaultAddress.Save();
                }

                // Set default address
                newDefaultAddress["IsDefaultOrganizationElement"] = true;
                newDefaultAddress.Save();
            }

            context.SetResponse(new Response());
        }
コード例 #30
0
        /// <summary>
        /// Handles the Click event of the btnSaveBlock 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 btnSaveBlock_Click(object sender, EventArgs e)
        {
            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                TimeTrackingBlock ttb = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), this.ObjectId);

                ProcessCollection(this.frmViewBlock.Controls, ttb);

                ttb.Save();

                tran.Commit();
            }

            CommandParameters cp = new CommandParameters("MC_TimeTracking_EditGridFrame");

            Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString());
        }