Пример #1
0
        /// <summary>
        /// Checks the existing (listItem) item against the
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="listItem">Current (existing) list item</param>
        /// <param name="entityItem">Entity with changes/updates</param>
        /// <returns>A new KPListItem with only the changed fields</returns>
        protected KPListItem UpdateItemFields <KPE>(KPE listItem, KPE entityItem) where KPE : IKPEntity
        {
            KPListItem updateItem   = entityItem.GetProperties();
            KPListItem originalItem = listItem.GetProperties();

            return(KPUtilities.UpdateItemFields(updateItem, originalItem));
        }
Пример #2
0
        protected KPListItem UpdateLookupItemFields <KPI>(KPI listItem, KPI entityItem) where KPI : IKPItem
        {
            KPListItem updateItem   = entityItem.GetProperties();
            KPListItem originalItem = listItem.GetProperties();

            return(KPUtilities.UpdateItemFields(updateItem, originalItem));
        }
Пример #3
0
        /// <summary>
        /// Set the properties of this object.
        /// This method is used by the DataAccess layer (DAL)
        /// to create new object instances from the underlying
        /// data persistence layer (DataProvider)
        /// </summary>
        /// <param name="item"></param>
        public void SetProperties(KPListItem item, string listName)
        {
            this.ID                    = (item.ContainsKey("ID")) ?KPUtilities.ParseInt(item["ID"].Value) : -1;
            this.KPID                  = (item.ContainsKey("KPID")) ? KPUtilities.ParseInt(item["KPID"].Value) : -1;
            this.KPGUID                = (item.ContainsKey("KPGUID")) ? item["KPGUID"].Value : string.Empty;
            this.Title                 = (item.ContainsKey("Title")) ? item["Title"].Value : string.Empty;
            this.ViewOwner             = (item.ContainsKey("ViewOwner")) ? item["ViewOwner"].Value : string.Empty;
            this.KPFilters             = KPUtilities.StripHTML((item.ContainsKey("KPFilters")) ? item["KPFilters"].Value : string.Empty, false);
            this.KPDescription         = KPUtilities.StripHTML((item.ContainsKey("KPDescription")) ? item["KPDescription"].Value : string.Empty, false);
            this.GridStates            = KPUtilities.StripHTML((item.ContainsKey("GridStates")) ? item["GridStates"].Value : string.Empty, false);
            this.StrikethroughOverride = (item.ContainsKey("StrikethroughOverride")) ? item["StrikethroughOverride"].Value : string.Empty;
            this.RelatedCheckpoints    = (item.ContainsKey("RelatedCheckpoints")) ? item["RelatedCheckpoints"].Value : string.Empty;
            this.SharedWith            = (item.ContainsKey("SharedWith")) ? item["SharedWith"].Value : string.Empty;
            this.KPItemState           = item["KPItemState"].Value;
            this.EntityTypes           = (item.ContainsKey("EntityTypes")) ? item["EntityTypes"].Value : string.Empty;

            this.SPCreatedDate  = KPUtilities.ParseDateTime(item["Created"].Value);
            this.SPModifiedDate = KPUtilities.ParseDateTime(item["Modified"].Value);
            this.SPCreatedBy    = item["CreatedBy"].Value;
            this.SPModifiedBy   = item["ModifiedBy"].Value;

            this.KPTeamId = null;

            this.Type = listName;
        }
Пример #4
0
 /// <summary>
 /// Set the properties of this object.
 /// This method is used by the DataAccess layer (DAL)
 /// to create new object instances from the underlying
 /// data persistence layer (DataProvider)
 /// </summary>
 /// <param name="item"></param>
 public override void SetProperties(KPListItem item, string listName)
 {
     this.IsAccomplishment = ParseBool(item["IsAccomplishment"].Value);
     this.Theme            = CheckNullInt("Theme", item);
     this.ProjectOwner     = (item.ContainsKey("ProjectOwner")) ? item["ProjectOwner"].Value : null;
     base.SetProperties(item, listName);
 }
Пример #5
0
        /// <summary>
        /// Get the properties of this object instance.
        /// This method is used by the DataAccess layer (DAL)
        /// to serialize the object instance to persist the
        /// data to the underlying data storage (DataProvider)
        /// </summary>
        /// <returns></returns>
        public KPListItem GetProperties()
        {
            this.itemProperties = new KPListItem();

            if (this.KPID > -1)
            {
                this.ID = this.KPID;
            }
            // get instance properties
            this.itemProperties.Add("ID", new KPItem(this.ID.ToString(), EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("KPID", new KPItem(this.KPID.ToString(), EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("KPGUID", new KPItem(this.KPGUID, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("Title", new KPItem(this.Title, EntityConstants.ItemTypes.TEXT));


            this.itemProperties.Add("ViewOwner", new KPItem(this.ViewOwner, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("KPFilters", new KPItem(this.KPFilters, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("KPDescription", new KPItem(this.KPDescription, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("GridStates", new KPItem(this.GridStates, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("StrikethroughOverride", new KPItem(this.StrikethroughOverride, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("RelatedCheckpoints", new KPItem(this.RelatedCheckpoints, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("SharedWith", new KPItem(this.SharedWith, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("KPItemState", new KPItem(this.KPItemState, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("EntityTypes", new KPItem(this.EntityTypes, EntityConstants.ItemTypes.TEXT));


            this.itemProperties.Add("Created", new KPItem(this.SPCreatedDate, EntityConstants.ItemTypes.DATETIME));
            this.itemProperties.Add("Modified", new KPItem(this.SPModifiedDate, EntityConstants.ItemTypes.DATETIME));
            this.itemProperties.Add("CreatedBy", new KPItem(this.SPCreatedBy, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("ModifiedBy", new KPItem(this.SPModifiedBy, EntityConstants.ItemTypes.TEXT));

            return(this.itemProperties);
        }
Пример #6
0
        /// <summary>
        /// Get the base object properties as a KPListItem
        /// </summary>
        /// <returns>KPListItem</returns>
        protected KPListItem GetBaseProperties()
        {
            if (this.itemProperties == null)
            {
                // get base properties
                this.itemProperties = new KPListItem();
            }

            if (this.KPID > -1)
            {
                this.ID = this.KPID;
            }
            // get instance properties
            this.itemProperties.Add("ID", new KPItem(this.ID.ToString(), EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("KPID", new KPItem(this.KPID.ToString(), EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("KPGUID", new KPItem(this.KPGUID, EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("Title", new KPItem(this.Title, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("OrderIndex", new KPItem(this.OrderIndex, EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("Created", new KPItem(this.SPCreatedDate, EntityConstants.ItemTypes.DATETIME));
            this.itemProperties.Add("Modified", new KPItem(this.SPModifiedDate, EntityConstants.ItemTypes.DATETIME));
            this.itemProperties.Add("CreatedBy", new KPItem(this.SPCreatedBy, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("ModifiedBy", new KPItem(this.SPModifiedBy, EntityConstants.ItemTypes.TEXT));

            return(this.itemProperties);
        }
Пример #7
0
        /// <summary>
        /// Update a team item in the Team list
        /// </summary>
        /// <param name="kpTeam"></param>
        /// <returns></returns>
        public override T UpdateItem(T updateItem)
        {
            // don't use this but required by UpdateEntityItem
            bool isUpdated = false;
            // get the team urlstring teamUrl;
            string teamUrl;

            if (updateItem.KPTeamId == null) // Default to common
            {
                teamUrl = "/common";
            }
            else
            {
                teamUrl = dataAccess.CurrentUser.GetTeamUrl(updateItem.KPTeamId.Value);
            }

            // get the typed entity object
            T listItem = dataAccess.GetEntityObjectByKPID <T>(teamUrl, this.ListName, updateItem.KPID);

            // get the filtered updated item - only fields that have changed
            KPListItem updatedItem = this.UpdateItemFields(listItem, updateItem);

            updatedItem = dataAccess.UpdateEntityItem(teamUrl, this.ListName, updatedItem, updateItem.KPID, out isUpdated);
            updateItem.SetProperties(updatedItem, this.ListName);
            return(updateItem);
        }
Пример #8
0
        /// <summary>
        /// Get the properties of this object instance.
        /// This method is used by the DataAccess layer (DAL)
        /// to serialize the object instance to persist the
        /// data to the underlying data storage (DataProvider)
        /// </summary>
        /// <returns></returns>
        public KPListItem GetProperties()
        {
            this.itemProperties = new KPListItem();

            if (this.KPID > -1)
            {
                this.ID = this.KPID;
            }
            // get instance properties
            this.itemProperties.Add("ID", new KPItem(this.ID.ToString(), EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("KPID", new KPItem(this.KPID.ToString(), EntityConstants.ItemTypes.NUMBER));
            this.itemProperties.Add("KPGUID", new KPItem(this.KPGUID, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("Title", new KPItem(this.Title, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("KPDescription", new KPItem(this.KPDescription, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("KPComments", new KPItem(this.KPComments, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("TargetDate", new KPItem(this.TargetDate, EntityConstants.ItemTypes.DATETIME));
            this.itemProperties.Add("KPItemState", new KPItem(this.KPItemState, EntityConstants.ItemTypes.TEXT));

            this.itemProperties.Add("Created", new KPItem(this.SPCreatedDate, EntityConstants.ItemTypes.DATETIME));
            this.itemProperties.Add("Modified", new KPItem(this.SPModifiedDate, EntityConstants.ItemTypes.DATETIME));
            this.itemProperties.Add("CreatedBy", new KPItem(this.SPCreatedBy, EntityConstants.ItemTypes.TEXT));
            this.itemProperties.Add("ModifiedBy", new KPItem(this.SPModifiedBy, EntityConstants.ItemTypes.TEXT));

            return(this.itemProperties);
        }
Пример #9
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.ParentID = ParseInt(item["ParentID"].Value);
     this.ChildID  = ParseInt(item["ChildID"].Value);
     this.Deleted  = ParseBool(item["Deleted"].Value);
     base.SetBaseProperties(item, listName);
 }
Пример #10
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.KPTeam  = item["KPTeam"].Value;
     this.GoalSet = item["GoalSet"].Value;
     this.Locked  = ParseBool(item["Locked"].Value);
     base.SetBaseProperties(item, listName);
 }
Пример #11
0
        /// <summary>
        /// Update a team item in the Team list
        /// </summary>
        /// <param name="kpTeam"></param>
        /// <returns></returns>
        public override T UpdateItem(T updateItem)
        {
            T    listItem;
            int  id;
            bool isKPID = false;

            // get the typed entity object
            if (updateItem.KPID > 0)
            {
                listItem = dataAccess.GetLookupObjectByKPID <T>(this.ListName, updateItem.KPID);
                id       = updateItem.KPID;
                isKPID   = true;
            }
            else
            {
                listItem = dataAccess.GetLookupObjectByID <T>(this.ListName, updateItem.ID);
                id       = updateItem.ID;
            }

            // get the filtered updated item - only fields that have changed
            KPListItem updatedItem = this.UpdateLookupItemFields(listItem, updateItem);

            updatedItem = dataAccess.UpdateLookupItem(this.ListName, updatedItem, id, isKPID);
            updateItem.SetProperties(updatedItem, this.ListName);
            return(updateItem);
        }
Пример #12
0
        /// <summary>
        /// Add a new item to the Team list
        /// </summary>
        /// <param name="listItem"></param>
        /// <returns></returns>
        public override T AddItem(T item)
        {
            KPListItem configObject = item.GetProperties();
            KPListItem newItem      = this.dataAccess.AddNewLookupItem(this.ListName, configObject);

            item.SetProperties(newItem, this.ListName);
            return(item);
        }
Пример #13
0
        /// <summary>
        /// Checks for existing items by checking the assigned primary key values
        /// </summary>
        /// <param name="sheetItem"></param>
        /// <param name="kpListItems"></param>
        /// <param name="primaryKeyValue"></param>
        /// <returns></returns>
        private int CheckForExistingItem(KPListItem sheetItem, List <KPListItem> kpListItems, string primaryKeyValue)
        {
            bool foundMatch = false;
            int  itemKPID   = -1;

            string[] primaryKeys = primaryKeyValue.Split(';');

            // check sheet for value if it has one
            if (sheetItem.ContainsKey("KPID") && !string.IsNullOrEmpty(sheetItem["KPID"].Value))
            {
                // we have a value, but it may be bogus
                // so we set the foundMatch flag to double check
                itemKPID    = Int32.Parse(sheetItem["KPID"].Value);
                primaryKeys = new string[] { "KPID" };
            }

            if (sheetItem.ContainsKey("KPExternalID") && !string.IsNullOrEmpty(sheetItem["KPExternalID"].Value))
            {
                primaryKeys = new string[] { "KPExternalID" };
            }

            if (primaryKeys.Length > 1)
            {
                foreach (KPListItem kpListItem in kpListItems)
                {
                    if ((sheetItem[primaryKeys[0]].Value == kpListItem[primaryKeys[0]].Value) && (sheetItem[primaryKeys[1]].Value == kpListItem[primaryKeys[1]].Value))
                    {
                        itemKPID   = int.Parse(kpListItem["KPID"].Value);
                        foundMatch = true;
                    }
                }
            }
            else
            {
                // check if we have the primary key to lookup
                if (sheetItem.ContainsKey(primaryKeys[0]))
                {
                    foreach (KPListItem kpListItem in kpListItems)
                    {
                        if (sheetItem[primaryKeys[0]].Value == kpListItem[primaryKeys[0]].Value)
                        {
                            itemKPID   = int.Parse(kpListItem["KPID"].Value);
                            foundMatch = true;
                        }
                    }
                }
            }

            // check if we found a match
            if (foundMatch)
            {
                return(itemKPID);
            }
            else
            {
                return(-1);
            }
        }
Пример #14
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.Action   = item["Action"].Value;
     this.TeamPath = item["TeamPath"].Value;
     this.ListName = item["ListName"].Value;
     this.ItemKPID = item["ItemKPID"].Value;
     this.ItemGUID = item["ItemGUID"].Value;
     this.ItemData = item["ItemData"].Value;
     base.SetBaseProperties(item, listName);
 }
Пример #15
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.Action       = item["Action"].Value;
     this.ErrorMessage = item["ErrorMessage"].Value;
     this.FieldNames   = item["FieldNames"].Value;
     this.ListName     = item["ListName"].Value;
     this.KPUserName   = item["KPUserName"].Value;
     this.StackTrace   = item["StackTrace"].Value;
     this.TeamSiteName = item["TeamSiteName"].Value;
     base.SetBaseProperties(item, listName);
 }
Пример #16
0
        public static KPListItem UpdateItemFields(KPListItem updateItem, KPListItem originalItem)
        {
            KPListItem updatedItem = new KPListItem();
            string     fieldValue  = string.Empty;
            string     updateValue = string.Empty;

            foreach (KeyValuePair <string, KPItem> kvp in originalItem)
            {
                if (kvp.Value.Type == EntityConstants.ItemTypes.NOTE)
                {
                    // strip all characters
                    fieldValue = KPUtilities.StripHTML(kvp.Value.Value, false);
                }
                else if (!string.IsNullOrEmpty(kvp.Value.Value) && kvp.Value.Type == EntityConstants.ItemTypes.DATETIME)
                {
                    // convert to DateTime string in SP format
                    fieldValue = Convert.ToDateTime(kvp.Value.Value).ToString("yyyy-MM-dd");
                }
                else
                {
                    // plain old value - do nothing
                    fieldValue = kvp.Value.Value;
                }

                // check for ignored fields
                if (!IgnoredFields(kvp.Key) && updateItem.ContainsKey(kvp.Key))
                {
                    if (kvp.Value.Type == EntityConstants.ItemTypes.NOTE)
                    {
                        updateValue = KPUtilities.StripHTML(updateItem[kvp.Key].Value, false);
                    }

                    else if (kvp.Value.Type == EntityConstants.ItemTypes.DATETIME)
                    {
                        updateValue = Convert.ToDateTime(updateItem[kvp.Key].Value).ToString("yyyy-MM-dd");
                    }

                    else
                    {
                        updateValue = updateItem[kvp.Key].Value;
                    }

                    // check if fields values are the same
                    if (updateValue != fieldValue)
                    {
                        kvp.Value.Value = updateValue;
                        // if changed then add to updatedItem fields
                        updatedItem.Add(kvp.Key, kvp.Value);
                    }
                }
            }

            return(updatedItem);
        }
Пример #17
0
 /// <summary>
 /// Set the properties of this object.
 /// This method is used by the DataAccess layer (DAL)
 /// to create new object instances from the underlying
 /// data persistence layer (DataProvider)
 /// </summary>
 /// <param name="item"></param>
 public override void SetProperties(KPListItem item, string listName)
 {
     this.GoalSetId         = CheckNullInt("GoalSet", item);
     this.CategoryL1Id      = CheckNullInt("CategoryL1", item);
     this.CategoryL2Id      = CheckNullInt("CategoryL2", item);
     this.Country           = item["Country"].Value;
     this.Year              = CheckNullInt("Year", item);
     this.KPGoalContributor = item["KPGoalContributor"].Value;
     this.MetricValue       = KPUtilities.StripHTML((item.ContainsKey("MetricValue")) ? item["MetricValue"].Value : string.Empty, false);
     base.SetProperties(item, listName);
 }
Пример #18
0
        /// <summary>
        /// Setting properties
        /// The object 'rehydrated' here is an entity
        /// for consumption by external code
        /// </summary>
        /// <param name="item"></param>
        public virtual void SetProperties(KPListItem item, string listName)
        {
            try
            {
                this.KPExternalId = item.ContainsKey("KPExternalID") ? ParseInt(item["KPExternalID"].Value) : -1;

                this.KPDate = ParseDateTime(item["KPDate"].Value);

                // these values do not exist for all entity types
                this.KPCreatedDate    = item.ContainsKey("KPCreatedDate") ? ParseDateTime(item["KPCreatedDate"].Value) : null;
                this.KPOriginalDate   = item.ContainsKey("KPOriginalDate") ? ParseDateTime(item["KPOriginalDate"].Value) : null;
                this.KPCompletionDate = item.ContainsKey("KPCompletionDate") ? ParseDateTime(item["KPCompletionDate"].Value) : null;
                this.KPCustomerIDs    = item.ContainsKey("KPCustomers") ? item["KPCustomers"].Value : string.Empty;
                this.KPCustomers      = null;

                this.KPItemState = item["KPItemState"].Value;

                this.KPTeamId = item.ContainsKey("KPTeam") ? ParseInt(item["KPTeam"].Value) : -1;

                this.KPMovedFromValue = item.ContainsKey("KPMovedFrom") ? item["KPMovedFrom"].Value : string.Empty;
                this.KPMovedFrom      = null;

                this.KPMovedToValue = item.ContainsKey("KPMovedTo") ? item["KPMovedTo"].Value : string.Empty;
                this.KPMovedTo      = null;

                this.KPExecSummary = KPUtilities.StripHTML(item.ContainsKey("KPExecSummary") ? item["KPExecSummary"].Value : string.Empty, false);
                this.KPStatus      = item["KPStatus"].Value;
                this.KPComments    = KPUtilities.StripHTML(item.ContainsKey("KPComments") ? item["KPComments"].Value : string.Empty, false);
                this.KPSoWhat      = KPUtilities.StripHTML(item.ContainsKey("KPSoWhat") ? item["KPSoWhat"].Value : string.Empty, false);
                this.KPPathToGreen = KPUtilities.StripHTML(item.ContainsKey("KPPathToGreen") ? item["KPPathToGreen"].Value : string.Empty, false);

                this.KPBusinessOwner = item.ContainsKey("KPBusinessOwner") ? item["KPBusinessOwner"].Value : string.Empty;
                this.KPFinanceOwner  = item.ContainsKey("KPFinanceOwner") ? item["KPFinanceOwner"].Value : string.Empty;

                this.KPDescription = KPUtilities.StripHTML((item.ContainsKey("KPDescription")) ? item["KPDescription"].Value : string.Empty, false);

                this.KPPrimaryVPId = item.ContainsKey("KPPrimaryVP") ? ParseInt(item["KPPrimaryVP"].Value) : -1;

                this.KPSecondaryVPIDs = item.ContainsKey("KPSecondaryVPs") ? item["KPSecondaryVPs"].Value : string.Empty;

                this.KPAttachment = item.ContainsKey("KPAttachment") ? item["KPAttachment"].Value : string.Empty; // Attached Documents

                this.DraftMode = ParseBool(item["DraftMode"].Value);
            }
            catch (Exception ex)
            {
                string errMsg = string.Format("Error setting BaseEntity properties on {0}: {1}", listName, ex.Message);
                throw new Exception(errMsg);
            }

            // set additional core item properties
            base.SetBaseProperties(item, listName);
        }
Пример #19
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     // set item properties to serialize object
     this.itemProperties = item;
     this.Nick           = item["Nick"].Value;
     this.ParentId       = CheckNullInt("Parent", item);
     this.SubUrl         = item["SubUrl"].Value;
     this.TeamVision     = KPUtilities.StripHTML(item["TeamVision"].Value, false);
     this.TeamIntro      = KPUtilities.StripHTML(item["TeamIntro"].Value, false);
     this.siteUrl        = GetTeamUrl();
     base.SetBaseProperties(item, listName);
 }
Пример #20
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.CollapseSettings = item["CollapseSettings"].Value;
     this.GridStates       = item["GridStates"].Value;
     this.IsDefault        = ParseBool(item["IsDefault"].Value);
     this.IsOwner          = ParseBool(item["IsOwner"].Value);
     this.IsShared         = ParseBool(item["IsShared"].Value);
     this.KPGUIDRef        = item["KPGUIDRef"].Value;
     this.KPUserID         = CheckNullInt("KPUserID", item);
     this.KPFilters        = item["KPFilters"].Value;
     this.KPUserName       = item["KPUserName"].Value;
     this.Module           = item["Module"].Value;
     base.SetBaseProperties(item, listName);
 }
Пример #21
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.FullName          = item["FullName"].Value;
     this.KPUserName        = item["KPUserName"].Value;
     this.PrimaryTeam       = ParseInt(item["PrimaryTeam"].Value);
     this.AdditionalTeams   = ConvertListInt(item["AdditionalTeams"].Value);
     this.GoalsTab          = ParseBool(item["GoalsTab"].Value);
     this.BusinessReviewTab = ParseBool(item["BusinessReviewTab"].Value);
     this.RecentEdits       = ConvertListInt(item["RecentEdits"].Value);
     this.RecentReports     = item["RecentReports"].Value;
     this.VersionNumber     = item["VersionNumber"].Value;
     this.DefaultView       = item["DefaultView"].Value;
     base.SetBaseProperties(item, listName);
 }
Пример #22
0
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.KPUserName                = item["KPUserName"].Value;
     this.AdminTools                = ParseBool(item["AdminTools"].Value);
     this.LockdownEditor            = ParseBool(item["LockdownEditor"].Value);
     this.Lockdown                  = ParseBool(item["Lockdown"].Value);
     this.GoalReordering            = ParseBool(item["GoalReordering"].Value);
     this.GoalSanitization          = ParseBool(item["GoalSanitization"].Value);
     this.ImportGoals               = ParseBool(item["ImportGoals"].Value);
     this.EventLog                  = ParseBool(item["EventLog"].Value);
     this.DeleteGoals               = ParseBool(item["DeleteGoals"].Value);
     this.UserLog                   = ParseBool(item["UserLog"].Value);
     this.BusinessReview            = ParseBool(item["BusinessReview"].Value);
     this.GoalStrikethroughOverride = ParseBool(item["GoalStrikethroughOverride"].Value);
     this.ConfigListTool            = ParseBool(item["ConfigListTool"].Value);
     base.SetBaseProperties(item, listName);
 }
Пример #23
0
        /// <summary>
        /// Add a new item to the Team list
        /// </summary>
        /// <param name="listItem"></param>
        /// <returns></returns>
        public override T AddItem(T item)
        {
            string teamUrl;

            if (item.KPTeamId == null) // Default to common
            {
                teamUrl = "/common";
            }
            else
            {
                teamUrl = dataAccess.CurrentUser.GetTeamUrl(item.KPTeamId.Value);
            }
            KPListItem entityItem = item.GetProperties();
            KPListItem newItem    = dataAccess.AddNewEntityItem(teamUrl, this.ListName, entityItem);

            item.SetProperties(newItem, this.ListName);
            return(item);
        }
Пример #24
0
        /// <summary>
        /// Set the properties of this object.
        /// This method is used by the DataAccess layer (DAL)
        /// to create new object instances from the underlying
        /// data persistence layer (DataProvider)
        /// </summary>
        /// <param name="item"></param>
        public void SetProperties(KPListItem item, string listName)
        {
            this.ID            = (item.ContainsKey("ID")) ? KPUtilities.ParseInt(item["ID"].Value) : -1;
            this.KPID          = (item.ContainsKey("KPID")) ? KPUtilities.ParseInt(item["KPID"].Value) : -1;
            this.KPGUID        = (item.ContainsKey("KPGUID")) ? item["KPGUID"].Value : string.Empty;
            this.Title         = (item.ContainsKey("Title")) ? item["Title"].Value : string.Empty;
            this.KPDescription = KPUtilities.StripHTML((item.ContainsKey("KPDescription")) ? item["KPDescription"].Value : string.Empty, false);
            this.KPComments    = KPUtilities.StripHTML((item.ContainsKey("KPComments")) ? item["KPComments"].Value : string.Empty, false);
            this.TargetDate    = KPUtilities.ParseDateTime(item["TargetDate"].Value);
            this.KPItemState   = item["KPItemState"].Value;

            this.SPCreatedDate  = KPUtilities.ParseDateTime(item["Created"].Value);
            this.SPModifiedDate = KPUtilities.ParseDateTime(item["Modified"].Value);
            this.SPCreatedBy    = item["CreatedBy"].Value;
            this.SPModifiedBy   = item["ModifiedBy"].Value;

            this.KPTeamId = null;

            this.Type = listName;
        }
Пример #25
0
 /// <summary>
 /// Set the properties of this object.
 /// This method is used by the DataAccess layer (DAL)
 /// to create new object instances from the underlying
 /// data persistence layer (DataProvider)
 /// </summary>
 /// <param name="item"></param>
 public override void SetProperties(KPListItem item, string listName)
 {
     this.TotalEffort          = ParseInt(item["TotalEffort"].Value);
     this.AvoidableEffort      = ParseInt(item["AvoidableEffort"].Value);
     this.TimesPerYear         = ParseInt(item["TimesPerYear"].Value);
     this.InvestmentToReduceAE = ParseInt(item["InvestmentToReduceAE"].Value);
     this.KeyAssumptions       = KPUtilities.StripHTML(item["KeyAssumptions"].Value, false);
     this.WorkloadDescription  = KPUtilities.StripHTML(item["WorkloadDescription"].Value, false);
     this.WorkloadsPerYear     = ParseInt(item["WorkloadsPerYear"].Value);
     this.TaskRole             = item["TaskRole"].Value;
     this.ReductionType        = item["ReductionType"].Value;
     this.UnavoidableEffort    = ParseInt(item["UnavoidableEffort"].Value);
     this.KPType = item["KPType"].Value;
     this.ProjectedAvoidableEffortReduction = ParseInt(item["ProjectedAvoidableEffortReduction"].Value);
     this.ProjectedTimesPerYearReduction    = ParseInt(item["ProjectedTimesPerYearReduction"].Value);
     this.RelatedEffortInstances            = item["RelatedEffortInstances"].Value;
     this.RelatedProject  = item["RelatedProject"].Value;
     this.ConfidenceLevel = item["ConfidenceLevel"].Value;
     base.SetProperties(item, listName);
 }
Пример #26
0
 /// <summary>
 /// Set the base properties of the object
 /// </summary>
 /// <param name="item"></param>
 internal void SetBaseProperties(KPListItem item, string listName)
 {
     try
     {
         this.ID             = (item.ContainsKey("ID")) ? ParseInt(item["ID"].Value) : -1;
         this.KPID           = (item.ContainsKey("KPID")) ? ParseInt(item["KPID"].Value) : -1;
         this.KPGUID         = (item.ContainsKey("KPGUID")) ? item["KPGUID"].Value : string.Empty;
         this.Title          = (item.ContainsKey("Title")) ? item["Title"].Value : string.Empty;
         this.OrderIndex     = (item.ContainsKey("OrderIndex")) ? ParseDouble(item["OrderIndex"].Value) : (double?)null;
         this.SPCreatedDate  = this.ParseDateTime(item["Created"].Value);
         this.SPModifiedDate = this.ParseDateTime(item["Modified"].Value);
         this.SPCreatedBy    = (item.ContainsKey("CreatedBy")) ? item["CreatedBy"].Value : null;
         this.SPModifiedBy   = (item.ContainsKey("ModifiedBy")) ? item["ModifiedBy"].Value : null;
         this.Type           = listName;
     }
     catch (Exception ex)
     {
         string errMsg = string.Format("Error setting BaseItem properties on {0}: {1}", listName, ex.Message);
         throw new Exception(errMsg);
     }
 }
Пример #27
0
        //List<Project> Versions;

        public override void SetProperties(KPListItem item, string listName)
        {
            this.AEReduction             = CheckNullInt("AEReduction", item);
            this.AssociatedProject       = item["AssociatedProject"].Value;
            this.AvoidableEffort         = CheckNullInt("AvoidableEffort", item);
            this.EffortPerWorkload       = CheckNullInt("EffortPerWorkload", item);
            this.ParentProgramInitiative = item["ParentProgramInitiative"].Value;
            this.ProjectType             = item["ProjectType"].Value;
            this.TotalEffort             = CheckNullInt("TotalEffort", item);
            this.TTMImpact              = item["TTMImpact"].Value;
            this.Dependency             = KPUtilities.StripHTML(item["Dependency"].Value, false);
            this.Risks                  = KPUtilities.StripHTML(item["Risks"].Value, false);
            this.RelatedGoals           = item["RelatedGoals"].Value;
            this.RelatedMilestones      = item["RelatedMilestones"].Value;
            this.RelatedEffortInstances = (item.ContainsKey("RelatedEffortInstances")) ? item["RelatedEffortInstances"].Value : null;
            this.ProjectVP              = item["ProjectVP"].Value;
            this.ProjectOwner           = item["ProjectOwner"].Value;
            this.ProjectDirectorVP      = item["ProjectDirectorVP"].Value;
            this.RelatedIssues          = (item.ContainsKey("RelatedIssues")) ? item["RelatedIssues"].Value : null;
            this.Theme                  = CheckNullInt("Theme", item);
            this.Year = CheckNullInt("Year", item);
            base.SetProperties(item, listName);
        }
Пример #28
0
        /// <summary>
        /// Converts the imported SheetData into KPListItem objects for importing into SP
        /// The KPListItem is used so we don't need to use the strongly typed objects which
        /// is problematic since we want to be able to dynamically support any of the entities.
        /// TODO: consider adding a generic type T to allow strongly-typed objects to be used.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="kpListColumns"></param>
        /// <param name="mappingData"></param>
        /// <returns></returns>
        private List <KPListItem> ConvertSheetData(DataTable dt, List <string> kpListColumns, MappingData mappingData, ImportStatus importStatus)
        {
            string MAPPING_DEFAULT_DELIMITER = "#";
            // need a site url regardless to get an entity item to get its fields
            // we can use the assigned team, but for 'Export' templates we don't
            // have a team so we'll need to use any team the user has access to
            List <KPListItem> listItems = new List <KPListItem>();

            // get the list column names and data type
            Dictionary <string, string> fieldInfo = this.spDataAccess.GetEntityFields(mappingData.Team.SiteUrl, mappingData.ListName);
            int rowCount = 0;

            try
            {
                // enumerate the rows of the data table
                foreach (DataRow row in dt.Rows)
                {
                    // create a new item - which represents a row/item/entity
                    KPListItem item = new KPListItem();
                    // convert each row into a KPListItem
                    foreach (KeyValuePair <string, string> kvPair in mappingData.Mappings)
                    {
                        string value = string.Empty;
                        // mapping.Key is the list column name
                        string listColumn = kvPair.Key;
                        // mapping.Value is the sheet column name
                        string sheetColumn = kvPair.Value;
                        // get the type of field
                        string fieldType = fieldInfo[listColumn];

                        // does the mapped column contain a default value?
                        // #-prefix flags default values
                        if (kvPair.Value.Contains(MAPPING_DEFAULT_DELIMITER))
                        {
                            // use the mapped value - remove the token
                            value = sheetColumn.Remove(0, 1);
                        }
                        else
                        {
                            // check the worksheet row[column] for the mapped column
                            value = row[sheetColumn].ToString();
                        }
                        // create the field with value and data type
                        if (!string.IsNullOrEmpty(value))
                        {
                            value = KPUtilities.ConvertToSPType(value, fieldType);

                            // if value is null it's an invalid date
                            if (value == null)
                            {
                                importStatus.SkippedColumns.Add(string.Format("{0}: [Invalid Date]", sheetColumn));
                            }

                            item.Add(listColumn, new KPItem(value, fieldType));
                        }
                    }
                    // ensure we have columns - but if we have '1' then it's KPTeam which doesn't matter
                    // because KPTeam is included in all items by default - so effectively we have no row data
                    if (importStatus.SkippedColumns.Count < mappingData.Mappings.Count && item.Count != 1)
                    {
                        listItems.Add(item);
                        rowCount++;
                    }
                    else
                    {
                        // we have an empty row - ignore this row, but add to skippedRows
                        if (item.Count != 1)
                        {
                            importStatus.SkippedRowCount++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string errMsg = "Error converting sheet data (ConvertSheetData). Exception: {0}; StackTrace: {1}";
                importStatus.Messages.Add(string.Format(errMsg, ex.Message, ex.StackTrace));
            }

            return(listItems);
        }
Пример #29
0
        /// <summary>
        /// Check GoalSet value and CategoryL1 and CategoryL2 values
        /// and determine if selections are valid children of each
        /// </summary>
        /// <param name="sheetData"></param>
        public static bool ValidateGoalSetCategories(DomainManager domainManager, Dictionary <string, string> originalLookup, KPListItem item, ImportStatus importErrors)
        {
            string ERR_CATL1_MISMATCH         = "Row: {0}, CategoryL1 Mismatch: {1}";
            string ERR_CATL2_MISMATCH         = "Row: {0}, CategoryL2 Mismatch: {1}";
            string ERR_CATL1_INVALID          = "Row: {0}, CategoryL1 has an invalid value so unable to match CategoryL2: {1}";
            string ERR_MISSING_CATEGORY_VALUE = "Row {0} contains a value for Category Level 2, but not for Category Level 1.";
            string ERR_MISSING_GOALSET_VALUE  = "Row {0} does not contain a value for GoalSet, but has values for Category Level 1 or 2. Please include GoalSet.";

            bool success           = true;
            bool categoryL1Invalid = false;

            // keep item count to message user
            int itemCount = 1;

            // have CL1 or CL2 missing goal set
            if ((item.ContainsKey("CategoryL1") || item.ContainsKey("CategoryL2")) && !item.ContainsKey("GoalSet"))
            {
                importErrors.Messages.Add(string.Format(ERR_MISSING_GOALSET_VALUE, itemCount + 1));
                importErrors.SkippedRowCount++;
            }
            else
            {
                // have CL2 missing CL1
                if (item.ContainsKey("CategoryL2") && !item.ContainsKey("CategoryL1"))
                {
                    importErrors.Messages.Add(string.Format(ERR_MISSING_CATEGORY_VALUE, itemCount + 1));
                    importErrors.SkippedRowCount++;
                    success = false;
                }
                else
                {
                    // we do have a CL1
                    if (item.ContainsKey("CategoryL1"))
                    {
                        // get the mapped value
                        CategoryL1 CL1 = domainManager.CategoryL1Repository.Items.Find(cl1 => cl1.KPID.ToString() == item["CategoryL1"].Value);

                        // if we have one check if the CategoryL1 is in the GoalSet
                        if (CL1 == null || CL1.GoalSetId.ToString() != item["GoalSet"].Value)
                        {
                            importErrors.Messages.Add(string.Format(ERR_CATL1_MISMATCH, itemCount, originalLookup["CategoryL1"]));
                            importErrors.SkippedColumns.Add("Category L1: [No GoalSet]");
                            item["CategoryL1"].Value = string.Empty;
                            categoryL1Invalid        = true;
                            success = false;
                        }
                    }

                    if (item.ContainsKey("CategoryL2"))
                    {
                        if (!categoryL1Invalid)
                        {
                            CategoryL2 CL2 = domainManager.CategoryL2Repository.Items.Find(cl2 => cl2.KPID.ToString() == item["CategoryL2"].Value);
                            // check if the CategoryL2 is in the CategoryL1
                            if (CL2 == null || CL2.CategoryL1Id.ToString() != item["CategoryL1"].Value)
                            {
                                importErrors.Messages.Add(string.Format(ERR_CATL2_MISMATCH, itemCount, originalLookup["CategoryL2"]));
                                importErrors.SkippedColumns.Add("Category L2: [Invalid]");
                                item["CategoryL2"].Value = string.Empty;
                                success = false;
                            }
                        }
                        else
                        {
                            importErrors.Messages.Add(string.Format(ERR_CATL1_INVALID, itemCount, originalLookup["CategoryL2"]));
                            importErrors.SkippedColumns.Add("Category L2: [No Category L1]");
                            item["CategoryL2"].Value = string.Empty;
                            success = false;
                        }
                    }

                    itemCount++;
                }
            }
            return(success);
        }
Пример #30
0
 /// <summary>
 /// Set the properties of this object.
 /// This method is used by the DataAccess layer (DAL)
 /// to create new object instances from the underlying
 /// data persistence layer (DataProvider)
 /// </summary>
 /// <param name="item"></param>
 public override void SetProperties(KPListItem item, string listName)
 {
     this.RelatedProject = (item.ContainsKey("RelatedProject")) ? item["RelatedProject"].Value : null;
     this.MilestoneOwner = (item.ContainsKey("MilestoneOwner")) ? item["MilestoneOwner"].Value : null;
     base.SetProperties(item, listName);
 }