コード例 #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
ファイル: View.cs プロジェクト: mkpace/sharepoint-wcf
        /// <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;
        }
コード例 #3
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));
        }
コード例 #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.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);
 }
コード例 #5
0
ファイル: Team.cs プロジェクト: mkpace/sharepoint-wcf
 /// <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);
 }
コード例 #6
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);
        }
コード例 #7
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);
 }
コード例 #8
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;
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: SheetImport.cs プロジェクト: mkpace/sharepoint-wcf
        /// <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);
        }
コード例 #11
0
 /// <summary>
 /// Ctor to create a new item - used to serialize
 /// a KP object into an SPItem for save and update
 /// </summary>
 /// <param name="value"></param>
 /// <param name="type"></param>
 public KPItem(string value, string type)
 {
     value      = KPUtilities.ConvertToSPType(value, type);
     this.Value = value;
     this.Type  = type;
 }
コード例 #12
0
ファイル: Customer.cs プロジェクト: mkpace/sharepoint-wcf
 /// <summary>
 /// Implements IKPEntity interface
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public void SetProperties(KPListItem item, string listName)
 {
     this.KPDescription = KPUtilities.StripHTML((item.ContainsKey("KPDescription")) ? item["KPDescription"].Value : string.Empty, false);
     base.SetBaseProperties(item, listName);
 }