Ejemplo n.º 1
0
        void Refresh()
        {
            this.Name  = m_Item[TemplateCT.TemplateName] as string;
            this.State = EnumConverter.ToState(m_Item[TemplateCT.TemplateState] as string);

            SPFieldUserValueCollection v = new SPFieldUserValueCollection(m_Item.Web, m_Item.GetFieldValue <object>(TemplateCT.SendDraftTo, string.Empty).ToString());

            this.SendDraftToAdresses = v.Select(p => p.User.Email).ToList();

            this.UseFileForSubject = m_Item.GetFieldValue <bool>(TemplateCT.TemplateSubjectUseFile);
            this.UseFileForBody    = m_Item.GetFieldValue <bool>(TemplateCT.TemplateBodyUseFile);
            this.UseFileForFrom    = m_Item.GetFieldValue <bool>(TemplateCT.TemplateFromUseFile);
            this.UseFileForReply   = m_Item.GetFieldValue <bool>(TemplateCT.TemplateReplayUseFile);

            this.From    = m_Item.GetValueFromTextFieldOrFile(this.UseFileForFrom, TemplateCT.TemplateFrom, TemplateCT.TemplateFromFile, out FromAttached);
            this.Replay  = m_Item.GetValueFromTextFieldOrFile(this.UseFileForReply, TemplateCT.TemplateReplay, TemplateCT.TemplateReplayFile, out ReplyAttached);
            this.Body    = m_Item.GetValueFromTextFieldOrFile(this.UseFileForBody, TemplateCT.TemplateBody, TemplateCT.TemplateBodyFile, out this.BodyAttached);
            this.Subject = m_Item.GetValueFromTextFieldOrFile(this.UseFileForSubject, TemplateCT.TemplateSubject, TemplateCT.TemplateSubjectFile, out this.SubjectAttached);

            if (m_Item[TemplateCT.TemplateType] != null)
            {
                var val = new SPFieldMultiChoiceValue(m_Item[TemplateCT.TemplateType].ToString());
                this.EventTypes = EnumConverter.ToType(val);
            }
            else
            {
                this.EventTypes = (int)TemplateTypeEnum.Unknown;
            }

            this.Associations = AssociationCollection.ParseOrDefault(m_Item[TemplateCT.Associations] as string);
        }
        List <SPListItem> GetDescedantsForMessage(SPListItem message)
        {
            var res            = new List <SPListItem>();
            var discussionItem = message.ParentList.GetItemById(message.GetFieldValue <int>(SPBuiltInFieldId.ParentFolderId));
            var threadIndex    = message.GetFieldValue <string>(SPBuiltInFieldId.ThreadIndex, "");

            if (!string.IsNullOrEmpty(threadIndex))
            {
                var d = new Dictionary <int, SPListItem>();
                foreach (SPListItem item in message.ParentList.GetItems(GetQueryForDiscussionItems(discussionItem.Folder)))//cannot query only for thread
                {
                    var index = item.GetFieldValue <string>(SPBuiltInFieldId.ThreadIndex);
                    if (threadIndex.StartsWith(index) && item.ContentTypeId.IsChildOf(SPBuiltInContentTypeId.Message))
                    {
                        d.Add(index.Length, item);
                    }
                }
                res.AddRange(d.OrderBy(p => p.Key)
                             .Where(p => p.Key <= threadIndex.Length)//to avoid new messages after this
                             .Select(p => p.Value));
            }
            else
            {
                res.Add(message);
            }
            res.Insert(0, discussionItem);
            return(res);
        }
Ejemplo n.º 3
0
        //static SPUser svcUserForEmptyResponse;
        public static string[] GetCodesFromDeptCodeField(this SPListItem item, string DeptCodeFieldName)
        {
            dynamic CodeNameValues;

            string[]      CodeNames     = new String[] { };
            List <string> CodeNamesList = new List <string>();
            string        splitPattern  = @";#\d+;#";
            string        removePattern = @"\d+;#";

            CodeNameValues = item.GetFieldValue(DeptCodeFieldName);

            if (CodeNameValues.GetType().Name == "String")
            {
                if (CodeNameValues == "")
                {
                    return(CodeNames);
                }

                CodeNames    = Regex.Split(CodeNameValues, splitPattern);
                CodeNames[0] = Regex.Replace(CodeNames[0], removePattern, "");
            }
            if (CodeNameValues.GetType().Name == "SPFieldLookupValueCollection")
            {
                foreach (SPFieldLookupValue CodeValue in CodeNameValues)
                {
                    CodeNamesList.Add(CodeValue.LookupValue);
                    CodeNames = CodeNamesList.ToArray();
                }
            }

            return(CodeNames);
        }