public void AddAndAccessItems()
    {
        BaseCollection <int> collection = new BaseCollection <int>();

        collection.Add(1);
        collection.Add(2);

        Assert.AreEqual(1, collection[0]);
        Assert.AreEqual(1, collection.ElementAt(0));
        Assert.AreEqual(2, collection[1]);
        Assert.AreEqual(2, collection.ElementAt(1));
    }
Example #2
0
        public AutoLinkGenerator(HPatternInstance instance)
        {
            // Read all the instances of this type to find links.
            m_Instances = new BaseCollection<HPatternInstance>();
            m_Instances.Add(instance);

            // For performance reasons it is unfeasible to actually read the updated versions here.
            foreach (PatternInstance otherInstance in PatternInstance.GetInstances(instance.Model, HPatternPattern.Definition, PatternInstance.OpenOptions.SkipUpdate))
            {
                if (otherInstance.Id != instance.Id)
                    m_Instances.Add(HPatternInstance.FastLoad(otherInstance));
            }
        }
Example #3
0
        public BaseCollection <CmsScript> GetAllScripts()
        {
            if (_allScripts == null)
            {
                //eerst alle scripts van site
                _allScripts = Site.Scripts;

                //mocht die dannog leeg zijn, dan nieuwe lege aanmaken:
                if (_allScripts == null)
                {
                    _allScripts = new BaseCollection <CmsScript>();
                }

                //dan alle van template eraan toevoegen
                BaseCollection <CmsScript> templateScripts = this.Template.Scripts;
                foreach (CmsScript script in templateScripts)
                {
                    if (!_allScripts.Contains(script))
                    {
                        _allScripts.Add(script);
                    }
                }
                //dan alle van pagina eraan toevoegen
                BaseCollection <CmsScript> pageScripts = this.Scripts;
                foreach (CmsScript script in pageScripts)
                {
                    if (!_allScripts.Contains(script))
                    {
                        _allScripts.Add(script);
                    }
                }
                //dan nog alle module specifieke scripts toevoegen
                foreach (string scriptUrl in GetModuleDependentScripts())
                {
                    CmsScript dummy = new CmsScript();
                    if (scriptUrl.EndsWith("css"))
                    {
                        dummy.ScriptType = ScriptTypeEnum.Css;
                    }
                    else
                    {
                        dummy.ScriptType = ScriptTypeEnum.Js;
                    }
                    dummy.Url = scriptUrl;
                    //dummy.UrlLive = scriptUrl;
                    dummy.ID = Guid.NewGuid();
                    _allScripts.Add(dummy);
                }
            }
            return(_allScripts);
        }
Example #4
0
        /// <summary>
        /// 查询文件
        /// </summary>
        /// <param name="keyValuePairs">键值对</param>
        /// <returns></returns>
        public BaseCollection <DCTClientFile> QueryFile(Dictionary <string, string> keyValuePairs)
        {
            BaseCollection <DCTFileField> fileFields = new BaseCollection <DCTFileField>();

            foreach (var pair in keyValuePairs)
            {
                var curField = Fields;
                if (!curField.ContainsKey(pair.Key))
                {
                    continue;
                }
                fileFields.Add(new DCTFileField()
                {
                    Field = Fields[pair.Key], FieldValue = pair.Value
                });
            }

            BaseCollection <DCTFile>       files   = new BaseCollection <DCTFile>();
            BaseCollection <DCTClientFile> results = new BaseCollection <DCTClientFile>();

            ServiceProxy.SingleCall <IDCSFetchService>(binding, searchEndpointAddress, userBehavior, action =>
            {
                files = action.DCMQueryDocByField(fileFields);
                foreach (var file in files)
                {
                    results.Add(file.To <DCTClientFile>());
                }
            });

            return(results);
        }
        private static BaseCollection <DCTFileField> BuildFileFields(DocLibContext context, IEnumerable <Field> spfields, File file)
        {
            BaseCollection <DCTFileField> results = new BaseCollection <DCTFileField>();

            context.Load(file.ListItemAllFields);
            context.Load(context.BaseList.Fields);
            context.ExecuteQuery();

            foreach (Field field in spfields)
            {
                DCTFileField fileField = new DCTFileField();
                DCTFieldInfo fieldInfo = new DCTFieldInfo();

                DCTConverterHelper.Convert(field, fieldInfo);

                if (string.IsNullOrEmpty(fieldInfo.ID))
                {
                    continue;
                }

                fileField.Field      = fieldInfo;
                fileField.FieldValue = file.ListItemAllFields[field.InternalName] == null ? "" : file.ListItemAllFields[field.InternalName].ToString();

                results.Add(fileField);
            }

            return(results);
        }
Example #6
0
        private BaseCollection <CmsTemplateContainer> CreateContainers()
        {
            BaseCollection <CmsTemplateContainer> containers = new BaseCollection <CmsTemplateContainer>();
            string content = GetBodyContent();

            //Verborgen html verwijderen uit CreateContainer functie. Voorkomt verborgen (uitgecommentarieerde) containers. BUG FIX
            MatchCollection matches = Regex.Matches(content, "<!--(.*?)-->", RegexOptions.Singleline);

            foreach (Match match in matches)
            {
                content = content.Replace(match.ToString(), "");
            }
            int posTagStart = content.IndexOf("[");
            int posTagEnd   = content.IndexOf("]", posTagStart + 1) + 1;

            while (posTagStart >= 0 && posTagEnd >= 0)
            {
                string tag = content.Substring(posTagStart, posTagEnd - posTagStart);
                if (tag.Contains("CONTENT") || tag.Contains("TOP") || tag.Contains("LEFT") || tag.Contains("RIGHT") || tag.Contains("BOTTOM") || tag.Contains("BLOCK"))
                {
                    string containerName           = tag.Replace("[", "").Replace("]", "");
                    CmsTemplateContainer container = new CmsTemplateContainer();
                    container.Site     = this.Site;
                    container.Template = this;
                    container.Name     = containerName;
                    containers.Add(container);
                }
                posTagStart = content.IndexOf("[", posTagStart + 1);
                posTagEnd   = content.IndexOf("]", posTagStart + 1) + 1;
            }
            return(containers);
        }
Example #7
0
        public BaseCollection <DCTPermission> DCMGetRolePermissions(DCTRoleDefinition role)
        {
            (role.ID <= 0 && string.IsNullOrEmpty(role.Name)).TrueThrow <ArgumentException>("角色中必须包含名称或ID.");

            using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                RoleDefinition roleDef = null;

                if (!string.IsNullOrEmpty(role.Name))
                {
                    roleDef = context.Web.RoleDefinitions.GetByName(role.Name);
                }
                else
                {
                    roleDef = context.Web.RoleDefinitions.GetById(role.ID);
                }

                context.Load(roleDef);
                context.ExecuteQuery();

                BaseCollection <DCTPermission> permissions = new BaseCollection <DCTPermission>();

                if (roleDef.BasePermissions.Has(PermissionKind.ViewListItems))
                {
                    permissions.Add(DCTPermission.ViewFileOrFolder);
                }

                if (roleDef.BasePermissions.Has(PermissionKind.AddListItems))
                {
                    permissions.Add(DCTPermission.AddFileOrFolder);
                }

                if (roleDef.BasePermissions.Has(PermissionKind.EditListItems))
                {
                    permissions.Add(DCTPermission.UpdateFileOrFolder);
                }

                if (roleDef.BasePermissions.Has(PermissionKind.DeleteListItems))
                {
                    permissions.Add(DCTPermission.DeleteFileOrFolder);
                }


                return(permissions);
            }
        }
Example #8
0
        public BaseCollection <DCTSearchResult> DCMSearchDoc(string[] keyWords)
        {
            MCS.Library.Core.ServerInfo  serverInfo  = MossServerInfoConfigurationSettings.GetConfig().Servers["documentServer"].ToServerInfo();
            System.Net.NetworkCredential Credentials = new System.Net.NetworkCredential(serverInfo.Identity.LogOnName, serverInfo.Identity.Password, serverInfo.Identity.Domain);
            string       searchServiceUrl            = MCS.Library.Core.UriHelper.CombinePath(MossServerInfoConfigurationSettings.GetConfig().Servers["documentServer"].ServerName, MossServerInfoConfigurationSettings.GetConfig().Servers["documentServer"].MossSearchServiceUrl);
            QueryService queryService = new QueryService(searchServiceUrl, Credentials);

            BaseCollection <DCTSearchResult> result = new BaseCollection <DCTSearchResult>();
            StringBuilder queryXml = new StringBuilder();

            queryXml.Append("<QueryPacket xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000\">");
            queryXml.Append("<Query domain=\"QDomain\">");
            queryXml.Append("<SupportedFormats>");
            queryXml.Append("<Format>");
            queryXml.Append("urn:Microsoft.Search.Response.Document.Document");
            queryXml.Append("</Format>");
            queryXml.Append("</SupportedFormats>");
            queryXml.Append("<Range>");
            queryXml.Append("<Count>50</Count>");
            queryXml.Append("</Range>");
            queryXml.Append("<Context>");
            queryXml.Append("<QueryText language=\"en-US\" type=\"STRING\">");
            foreach (string item in keyWords)
            {
                queryXml.Append(string.Format("{0} ", item));
            }

            queryXml.Append("</QueryText>");
            queryXml.Append("</Context>");
            queryXml.Append("</Query>");

            queryXml.Append("</QueryPacket>");
            try
            {
                using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
                {
                    DataSet dsQueryResult = queryService.QueryEx(queryXml.ToString());
                    IEnumerable <DataRow> drQueryResult = from row in dsQueryResult.Tables[0].AsEnumerable()
                                                          where row.Field <bool>("IsDocument") == true
                                                          select row;
                    foreach (var item in drQueryResult)
                    {
                        DCTSearchResult searchResult = new DCTSearchResult();
                        searchResult.Title = item["Title"].ToString();
                        searchResult.Size  = int.Parse(item["Size"].ToString());
                        searchResult.HitHighlightedSummary = item["HitHighlightedSummary"].ToString();
                        searchResult.LastModifiedDate      = DateTime.Parse(item["Write"].ToString());
                        searchResult.Path = item["Path"].ToString().ToLower().Replace(context.Url.ToLower(), "");
                        result.Add(searchResult);
                    }
                    return(result);
                }
            }
            catch (SoapException ex)
            {
                throw ex;
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (!id.HasValue)
            {
                equipments.Add(this.StoreEquipment());
            }

            equipmentWnd.Close();
        }
		public BaseCollection<DCTFile> DCMQueryDocByField(BaseCollection<DCTFileField> fields)
		{
			BaseCollection<DCTFile> files = new BaseCollection<DCTFile>();
			using (DocLibContext clientContext = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
			{
				CamlQuery query = new CamlQuery();
				CamlExpression caml = null;
				foreach (DCTFileField item in fields)
				{
					string valueText = string.Empty;
					switch (item.Field.ValueType)
					{
						case DCTFieldType.Boolean:
							break;
						case DCTFieldType.DateTime:
							break;
						case DCTFieldType.Decimal:
							break;
						case DCTFieldType.Integer:
							valueText = "Counter";
							break;
						case DCTFieldType.Note:
							break;
						case DCTFieldType.Text:
							valueText = "Text";
							break;
						case DCTFieldType.User:
							break;
						default:
							break;
					}
					if (caml == null)
					{
						caml = Caml.Field(item.Field.InternalName).Eq(Caml.Value(valueText, item.FieldValue));
					}
					else
					{
						caml = caml.And(Caml.Field(item.Field.InternalName).Eq(Caml.Value(valueText, item.FieldValue)));
					}
				}

				query.ViewXml = Caml.SimpleView(caml, CamlBuilder.ViewType.RecursiveAll).ToCamlString();

				ListItemCollection items = clientContext.BaseList.GetItems(query);
				clientContext.Load(items);

				clientContext.ExecuteQuery();

				foreach (ListItem item in items)
				{
					DCTFile file = new DCTFile();
					DCTConverterHelper.Convert(item, file);
					files.Add(file);
				}
			}
			return files;
		}
        /// <summary>
        /// <see cref="IDictionary{TKey, TValue}.Add(TKey, TValue)" />
        /// </summary>
        public void Add(TKey key, TValue value)
        {
            BaseCollection.Add(key, value);
            RaiseCollectionEvents();

            var e = new NotifyCollectionChangedEventArgs(action: NotifyCollectionChangedAction.Add,
                                                         changedItem: new KeyValuePair <TKey, TValue>(key, value));

            RaiseCollectionChanged(e);
        }
Example #12
0
    public static BaseCollection ToBase <T>(IEnumerable <T> source) where T : Base
    {
        BaseCollection result = new BaseCollection();

        foreach (T item in source)
        {
            result.Add(item);
        }
        return(result);
    }
Example #13
0
 /// <summary>
 /// Create a new instance.
 /// </summary>
 internal EntryCollection(Document owner, params ICollection <Record>[] records)
 {
     Owner = owner;
     foreach (var entry in records)
     {
         BaseCollection.Add(new Entry(entry)
         {
             Owner = this
         });
     }
 }
Example #14
0
 /// <summary>
 /// 更新字段
 /// </summary>
 public void Update()
 {
     ServiceProxy.SingleCall<IDCSStorageService>(client.Binding, client.StorageEndpointAddress, client.UserBehavior, action =>
             {
                 BaseCollection<DCTFileField> fileFields = new BaseCollection<DCTFileField>();
                 foreach (DCTFileField filefield in effectedFileField)
                 {
                     fileFields.Add(filefield);
                 }
                 action.DCMSetFileFields(this.ID, fileFields);
             });
 }
Example #15
0
 internal void AddPasswordToHistory(DateTime time, string password)
 {
     if (Enabled && !string.IsNullOrEmpty(password))   //change only if enabled and not empty
     {
         BaseCollection.Add(new PasswordHistoryItem(this, time, password));
         while (BaseCollection.Count > MaximumCount)
         {
             BaseCollection.RemoveAt(0);
         }
         MarkAsChanged();
     }
 }
Example #16
0
        internal PasswordHistoryCollection(RecordCollection records)
        {
            Records = records;

            if (Records.Contains(RecordType.PasswordHistory))
            {
                var text = Records[RecordType.PasswordHistory].Text;
                if ((text != null) && (text.Length >= 5))
                {
                    _enabled = (text[0] != '0');
                    if (!int.TryParse(text.AsSpan(1, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out _maximumCount))
                    {
                        _maximumCount = DefaultMaximumCount;
                    }

                    if (int.TryParse(text.AsSpan(3, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var count))
                    {
                        var j = 5; //where parsing starts
                        for (var i = 0; i < count; i++)
                        {
                            if (text.Length >= j + 12)
                            {
                                if (int.TryParse(text.AsSpan(j, 8), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var time) &&
                                    int.TryParse(text.AsSpan(j + 8, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var length))
                                {
                                    j += 12; //skip time and length
                                    if (text.Length >= j + length)
                                    {
                                        var item = new PasswordHistoryItem(this, UnixEpoch.AddSeconds(time), text.Substring(j, length));
                                        BaseCollection.Add(item);
                                        j += length; //skip password
                                    }
                                    else
                                    {
                                        break; //something is wrong with parsing
                                    }
                                }
                                else
                                {
                                    break; //something is wrong with parsing
                                }
                            }
                            else
                            {
                                break; //something is wrong with parsing
                            }
                        }
                    }
                }
            }
        }
Example #17
0
        public string GetPlacesAsJsonString(string googleMapsKey, string datacollectionID, GPoint geoPoint, int zoomLevel, string navigationUrl)
        {
            //public static IEnumerable<DataItem> GetPlacesAsJsonString(string googleMapsKey, string datacollectionID, GPoint geoPoint, int zoomLevel)
            //{
            string traceInfo = "";

            try
            {
                int searchRadius = convertToRadius(zoomLevel);
                traceInfo    = "1";
                string where = GetWhere(datacollectionID);
                traceInfo    = "2";
                IEnumerable <DataItem> items = BaseCollection <DataItem> .Get(where);

                traceInfo = "3";
                //if (items.Count > 500)
                //{
                //    throw new Exception("Er zijn teveel items gevonden die voldoen aan de selectie. Maak de selectie kleiner aub.");
                //}
                BaseCollection <DataItem> locations = new BaseCollection <DataItem>();

                foreach (DataItem item in items)
                {
                    double distance = 0;
                    if (GoogleGeocoder.IsWithinDistance(item, geoPoint.Lat, geoPoint.Long, searchRadius, out distance))
                    {
                        traceInfo     = "4";
                        item.Distance = distance;
                        //RewriteUrl=DrillDownUrl van de location wordt ipv de {RewriteUrl} gezet in js.
                        item.RewriteUrl = item.GetRewriteUrl(navigationUrl, "I");
                        traceInfo       = "5";
                        locations.Add(item);
                    }
                }
                //sorteer de lijst op afstand
                locations.Sort(delegate(DataItem loc1, DataItem loc2) { return(loc1.Distance.CompareTo(loc2.Distance)); });
                //return locations;
                traceInfo = "6";

                string json = ConvertToJson(locations);
                return(json);
            }
            catch (Exception ex)
            {
                traceInfo += ex.Message;
            }
            return(traceInfo);

            //return locations.Select(locations.CreateNewStatement("Name, Title"));
        }
        public BaseCollection <BaseObject> GetAllGroupsLite(string datacollectionid)
        {
            BaseService.CheckLoginAndLicense();
            BaseCollection <DataGroup>  groups      = GetAllGroups(datacollectionid);
            BaseCollection <BaseObject> returnValue = new BaseCollection <BaseObject>();

            foreach (DataGroup group in groups)
            {
                BaseObject obj = new BaseObject();
                obj.ID   = group.ID;
                obj.Name = group.CompletePath;
                returnValue.Add(obj);
            }
            return(returnValue);
        }
    public void InitControl()
    {
        BaseCollection c = new BaseCollection(UData.ToTable2("CategoryTask", "TaskID"));
        BaseItem i = null;

        i = c.NewItem();
        c.Add(i);
        i.SetColumn(0, TaskE.SearchItem.ToString("d"));

        if (UWeb.IsAuthenticated)
        {
            bool show = true;

            if (Cxt.Service.ServiceTypeID == ServiceTypeE.Membership)
            {
                if (UWeb.UserID != 1)
                {
                    show = false;
                }
            }

            if (show)
            {
                i = c.NewItem();
                c.Add(i);
                i.SetColumn(0, TaskE.NewItem.ToString("d"));

                i = c.NewItem();
                c.Add(i);
                i.SetColumn(0, TaskE.MyItem.ToString("d"));
            }
        }

        gv1.DataSource = c.DataTable;
        gv1.DataBind();
    }
        public BaseCollection <BaseObject> GetAllItemsLite(string datacollectionid)
        {
            BaseService.CheckLoginAndLicense();
            BaseCollection <DataItem>   items       = GetAllItems(datacollectionid);
            BaseCollection <BaseObject> returnValue = new BaseCollection <BaseObject>();

            foreach (DataItem item in items)
            {
                BaseObject obj = new BaseObject();
                obj.ID   = item.ID;
                obj.Name = item.Name;
                returnValue.Add(obj);
            }
            return(returnValue);
        }
        internal NamedPasswordPolicyCollection(Document owner)
        {
            Owner = owner;

            if (owner.Headers.Contains(HeaderType.NamedPasswordPolicies))
            {
                var text = owner.Headers[HeaderType.NamedPasswordPolicies].Text;
                if (text != null)
                {
                    foreach (var item in ParseMultiple(text))
                    {
                        BaseCollection.Add(item);
                    }
                }
            }
        }
Example #22
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <returns></returns>
        public BaseCollection <DCTClientSearchResult> Search(params string[] keywords)
        {
            BaseCollection <DCTClientSearchResult> results = new BaseCollection <DCTClientSearchResult>();

            ServiceProxy.SingleCall <IDCSFetchService>(binding, searchEndpointAddress, userBehavior, action =>
            {
                var allDocs = action.DCMSearchDoc(keywords);
                foreach (var doc in allDocs)
                {
                    DCTClientSearchResult result = doc.To <DCTClientSearchResult>();
                    result.Client = this;
                    results.Add(result);
                }
            });
            return(results);
        }
Example #23
0
        public BaseCollection <BaseObject> GetAllMenuItemsLite(string menuId)
        {
            BaseService.CheckLoginAndLicense();
            string whereItems = String.Format("FK_Menu = '{0}'", menuId);
            BaseCollection <CmsMenuItem> items = BaseCollection <CmsMenuItem> .Get(whereItems, "CompletePath");

            BaseCollection <BaseObject> returnValue = new BaseCollection <BaseObject>();

            foreach (CmsMenuItem item in items)
            {
                BaseObject obj = new BaseObject();
                obj.ID   = item.ID;
                obj.Name = item.CompletePath;
                returnValue.Add(obj);
            }
            return(returnValue);
        }
        /// <summary>
        /// wordt aangeroepen vanuit Page_Load() en ReLoad() in BaseDataModuleUserControl
        /// </summary>
        /// <param name="dataId"></param>
        ///
        public override void SelectAndShowData(Guid dataId)
        {
            DataGroup group = BaseObject.GetById <DataGroup>(dataId);

            if (group == null)
            {
                DataItem item = BaseObject.GetById <DataItem>(dataId);
                if (item != null)
                {
                    group = item.ParentGroup;
                }
            }
            if (group == null)
            {
                group = new DataGroup();
            }
            if (group.DataCollection != null && group.DataCollection.ID != DataCollectionID)
            {
                //return;
            }
            ModuleNavigationActionLite navigationAction = GetNavigationActionByTagName("{DrillDownLink}");

            if (navigationAction != null)
            {
                string navigationUrl = navigationAction.NavigationUrl;
                if (navigationAction.NavigationType == NavigationTypeEnum.ShowDetailsInModules)
                {
                    //blijven op dezelfde pagina
                    navigationUrl = Request.Url.LocalPath;
                }
                group.RewriteUrl = group.GetRewriteUrl(navigationUrl);

                //maak list aan
                BaseCollection <BaseDataObject> dataObjects = new BaseCollection <BaseDataObject>();
                dataObjects.Add(group);
                while (group.ParentGroup != null)
                {
                    group            = group.ParentGroup;
                    group.RewriteUrl = group.GetRewriteUrl(navigationUrl);
                    dataObjects.Insert(0, group);
                }
                DataBind(dataObjects);
            }
        }
Example #25
0
        public BaseCollection <DCTRoleAssignment> DCMGetRoleAssignments(int storageObjID)
        {
            (storageObjID <= 0).TrueThrow <ArgumentException>("ID:{0}无效,请传入大于0的值.", storageObjID);

            using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                ListItem listItem = GetListItemById(storageObjID, context);
                if (null == listItem)
                {
                    return(new BaseCollection <DCTRoleAssignment>());
                }
                context.Load(listItem);
                context.Load(listItem.RoleAssignments);
                context.ExecuteQuery();

                RoleAssignmentCollection           roleAssignments = listItem.RoleAssignments;
                BaseCollection <DCTRoleAssignment> results         = new BaseCollection <DCTRoleAssignment>();

                foreach (RoleAssignment roleAssignment in roleAssignments)
                {
                    DCTRoleAssignment dctRoleAssignment = new DCTRoleAssignment();
                    context.Load(roleAssignment.Member);
                    context.Load(roleAssignment.RoleDefinitionBindings);
                    context.ExecuteQuery();

                    dctRoleAssignment.Member = GetPrinciple(roleAssignment.Member.PrincipalType);
                    DCTConverterHelper.Convert(roleAssignment.Member, dctRoleAssignment.Member);

                    dctRoleAssignment.RoleDefinitions = new BaseCollection <DCTRoleDefinition>();
                    RoleDefinitionBindingCollection bindingCollection = roleAssignment.RoleDefinitionBindings;
                    foreach (RoleDefinition roleDefinition in bindingCollection)
                    {
                        DCTRoleDefinition dctRoleDefinition = new DCTRoleDefinition();
                        DCTConverterHelper.Convert(roleDefinition, dctRoleDefinition);
                        dctRoleAssignment.RoleDefinitions.Add(dctRoleDefinition);
                    }

                    results.Add(dctRoleAssignment);
                }

                return(results);
            }
        }
Example #26
0
        public BaseCollection <DCTFile> DCMQueryDocByCaml(string camlText)
        {
            BaseCollection <DCTFile> files = new BaseCollection <DCTFile>();

            using (DocLibContext clientContext = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                CamlQuery query = new CamlQuery();
                query.ViewXml = camlText;
                ListItemCollection items = clientContext.BaseList.GetItems(query);
                clientContext.Load(items);
                clientContext.ExecuteQuery();
                foreach (ListItem item in items)
                {
                    DCTFile file = new DCTFile();
                    DCTConverterHelper.Convert(item, file);
                    files.Add(file);
                }
            }
            return(files);
        }
    public void CallEvents()
    {
        BaseCollection <int> collection = new BaseCollection <int>();
        var setSubscriber     = Substitute.For <IDummyEventSubscriber <IEnumerable <int> > >();
        var addedSubscriber   = Substitute.For <IDummyEventSubscriber <int> >();
        var removedSubscriber = Substitute.For <IDummyEventSubscriber <int> >();

        collection.OnSet     += setSubscriber.React;
        collection.OnAdded   += addedSubscriber.React;
        collection.OnRemoved += removedSubscriber.React;

        collection.Set(new [] { 1, 2, 3, 4 });
        collection.Add(4);
        collection.Remove(2);
        collection.RemoveAt(0);

        setSubscriber.Received().React(collection.list);
        addedSubscriber.Received().React(4);
        removedSubscriber.Received().React(2);
        removedSubscriber.Received().React(1);
    }
Example #28
0
        public BaseCollection <string> DCMGetUserRoles(int storageObjID, string userAccount)
        {
            (storageObjID > 0).FalseThrow <ArgumentException>("ID值{0}无效,请传入大于0的值.", storageObjID);
            BaseCollection <string>            results         = new BaseCollection <string>();
            BaseCollection <DCTRoleAssignment> roleAssignments = DCMGetRoleAssignments(storageObjID);

            foreach (DCTRoleAssignment assignment in roleAssignments)
            {
                if (assignment.Member is DCTUser)
                {
                    DCTUser user = assignment.Member as DCTUser;
                    if (!IsSameUser(user.LoginName, userAccount))
                    {
                        continue;
                    }
                    foreach (DCTRoleDefinition definition in assignment.RoleDefinitions)
                    {
                        results.Add(definition.Name);
                    }
                }
            }
            return(results);
        }
		public BaseCollection<DCTFileVersion> DCMGetVersions(int fileId)
		{
			using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
			{
				File file = getFileById(fileId, context);
				context.Load(file.Versions);
				context.ExecuteQuery();

				BaseCollection<DCTFileVersion> results = new BaseCollection<DCTFileVersion>();

				foreach (FileVersion version in file.Versions)
				{
					context.Load(version.CreatedBy);
					context.ExecuteQuery();
					DCTFileVersion dctFileVersion = new DCTFileVersion();
					dctFileVersion.AbsoluteUri = UriHelper.CombinePath(context.Url, version.Url);
					DCTConverterHelper.Convert(version, dctFileVersion);

					results.Add(dctFileVersion);
				}

				return results;
			}
		}
        public BaseCollection <DCTFieldInfo> DCMGetFields()
        {
            using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                context.Load(context.BaseList.Fields);
                context.ExecuteQuery();
                BaseCollection <DCTFieldInfo> result = new BaseCollection <DCTFieldInfo>();

                foreach (Field field in context.BaseList.Fields)
                {
                    DCTFieldType fieldType;
                    if (!Enum.TryParse <DCTFieldType>(field.TypeAsString, out fieldType))
                    {
                        continue;
                    }
                    DCTFieldInfo fieldInfo = new DCTFieldInfo();
                    DCTConverterHelper.Convert(field, fieldInfo);

                    result.Add(fieldInfo);
                }

                return(result);
            }
        }
Example #31
0
        public BaseCollection <DCTFileVersion> DCMGetVersions(int fileId)
        {
            using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                File file = getFileById(fileId, context);
                context.Load(file.Versions);
                context.ExecuteQuery();

                BaseCollection <DCTFileVersion> results = new BaseCollection <DCTFileVersion>();

                foreach (FileVersion version in file.Versions)
                {
                    context.Load(version.CreatedBy);
                    context.ExecuteQuery();
                    DCTFileVersion dctFileVersion = new DCTFileVersion();
                    dctFileVersion.AbsoluteUri = UriHelper.CombinePath(context.Url, version.Url);
                    DCTConverterHelper.Convert(version, dctFileVersion);

                    results.Add(dctFileVersion);
                }

                return(results);
            }
        }
		public BaseCollection<DCTSearchResult> DCMSearchDoc(string[] keyWords)
		{
			MCS.Library.Core.ServerInfo serverInfo = MossServerInfoConfigurationSettings.GetConfig().Servers["documentServer"].ToServerInfo();
			System.Net.NetworkCredential Credentials = new System.Net.NetworkCredential(serverInfo.Identity.LogOnName, serverInfo.Identity.Password, serverInfo.Identity.Domain);
			string searchServiceUrl = MCS.Library.Core.UriHelper.CombinePath(MossServerInfoConfigurationSettings.GetConfig().Servers["documentServer"].ServerName, MossServerInfoConfigurationSettings.GetConfig().Servers["documentServer"].MossSearchServiceUrl);
			QueryService queryService = new QueryService(searchServiceUrl, Credentials);

			BaseCollection<DCTSearchResult> result = new BaseCollection<DCTSearchResult>();
			StringBuilder queryXml = new StringBuilder();
			queryXml.Append("<QueryPacket xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000\">");
			queryXml.Append("<Query domain=\"QDomain\">");
			queryXml.Append("<SupportedFormats>");
			queryXml.Append("<Format>");
			queryXml.Append("urn:Microsoft.Search.Response.Document.Document");
			queryXml.Append("</Format>");
			queryXml.Append("</SupportedFormats>");
			queryXml.Append("<Range>");
			queryXml.Append("<Count>50</Count>");
			queryXml.Append("</Range>");
			queryXml.Append("<Context>");
			queryXml.Append("<QueryText language=\"en-US\" type=\"STRING\">");
			foreach (string item in keyWords)
			{
				queryXml.Append(string.Format("{0} ", item));
			}

			queryXml.Append("</QueryText>");
			queryXml.Append("</Context>");
			queryXml.Append("</Query>");

			queryXml.Append("</QueryPacket>");
			try
			{
				using (DocLibContext context = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
				{
					DataSet dsQueryResult = queryService.QueryEx(queryXml.ToString());
					IEnumerable<DataRow> drQueryResult = from row in dsQueryResult.Tables[0].AsEnumerable()
														 where row.Field<bool>("IsDocument") == true
														 select row;
					foreach (var item in drQueryResult)
					{
						DCTSearchResult searchResult = new DCTSearchResult();
						searchResult.Title = item["Title"].ToString();
						searchResult.Size = int.Parse(item["Size"].ToString());
						searchResult.HitHighlightedSummary = item["HitHighlightedSummary"].ToString();
						searchResult.LastModifiedDate = DateTime.Parse(item["Write"].ToString());
						searchResult.Path = item["Path"].ToString().ToLower().Replace(context.Url.ToLower(), "");
						result.Add(searchResult);
					}
					return result;
				}
			}
			catch (SoapException ex)
			{
				throw ex;
			}
		}
Example #33
0
        public BaseCollection <DCTFile> DCMQueryDocByField(BaseCollection <DCTFileField> fields)
        {
            BaseCollection <DCTFile> files = new BaseCollection <DCTFile>();

            using (DocLibContext clientContext = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                CamlQuery      query = new CamlQuery();
                CamlExpression caml  = null;
                foreach (DCTFileField item in fields)
                {
                    string valueText = string.Empty;
                    switch (item.Field.ValueType)
                    {
                    case DCTFieldType.Boolean:
                        break;

                    case DCTFieldType.DateTime:
                        break;

                    case DCTFieldType.Decimal:
                        break;

                    case DCTFieldType.Integer:
                        valueText = "Counter";
                        break;

                    case DCTFieldType.Note:
                        break;

                    case DCTFieldType.Text:
                        valueText = "Text";
                        break;

                    case DCTFieldType.User:
                        break;

                    default:
                        break;
                    }
                    if (caml == null)
                    {
                        caml = Caml.Field(item.Field.InternalName).Eq(Caml.Value(valueText, item.FieldValue));
                    }
                    else
                    {
                        caml = caml.And(Caml.Field(item.Field.InternalName).Eq(Caml.Value(valueText, item.FieldValue)));
                    }
                }

                query.ViewXml = Caml.SimpleView(caml, CamlBuilder.ViewType.RecursiveAll).ToCamlString();

                ListItemCollection items = clientContext.BaseList.GetItems(query);
                clientContext.Load(items);

                clientContext.ExecuteQuery();

                foreach (ListItem item in items)
                {
                    DCTFile file = new DCTFile();
                    DCTConverterHelper.Convert(item, file);
                    files.Add(file);
                }
            }
            return(files);
        }
		public BaseCollection<DCTFile> DCMQueryDocByCaml(string camlText)
		{
			BaseCollection<DCTFile> files = new BaseCollection<DCTFile>();

			using (DocLibContext clientContext = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
			{
				CamlQuery query = new CamlQuery();
				query.ViewXml = camlText;
				ListItemCollection items = clientContext.BaseList.GetItems(query);
				clientContext.Load(items);
				clientContext.ExecuteQuery();
				foreach (ListItem item in items)
				{
					DCTFile file = new DCTFile();
					DCTConverterHelper.Convert(item, file);
					files.Add(file);
				}
			}
			return files;
		}
Example #35
0
        public BaseCollection <DCTStorageObject> DCMGetChildren(DCTFolder folder, DCTContentType contentType)
        {
            BaseCollection <DCTStorageObject> childs       = new BaseCollection <DCTStorageObject>();
            BaseCollection <DCTFile>          childFiles   = new BaseCollection <DCTFile>();
            BaseCollection <DCTFolder>        childFolders = new BaseCollection <DCTFolder>();

            using (DocLibContext clientContext = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                Folder    clientOMFolder = clientContext.Web.GetFolderByServerRelativeUrl(folder.Uri);
                CamlQuery query          = new CamlQuery();
                query.FolderServerRelativeUrl = LoadUri(folder, clientContext);
                query.ViewXml = Caml.SimpleView(Caml.EmptyCaml(), CamlBuilder.ViewType.Default).ToCamlString();

                ListItemCollection items = clientContext.BaseList.GetItems(query);

                clientContext.Load(items);
                clientContext.ExecuteQuery();

                foreach (ListItem item in items)
                {
                    switch (item.FileSystemObjectType)
                    {
                    case FileSystemObjectType.File:
                        if ((contentType & DCTContentType.File) != DCTContentType.None)
                        {
                            DCTFile itemFile = new DCTFile();
                            DCTConverterHelper.Convert(item, itemFile);

                            childs.Add(itemFile);
                            //childFiles.Add(itemFile);
                        }
                        break;

                    case FileSystemObjectType.Folder:
                        if ((contentType & DCTContentType.Folder) != DCTContentType.None)
                        {
                            DCTFolder itemFolder = new DCTFolder();

                            DCTConverterHelper.Convert(item, itemFolder);

                            childs.Add(itemFolder);
                            //childFolders.Add(itemFolder);
                        }
                        break;

                    case FileSystemObjectType.Invalid:
                        break;

                    case FileSystemObjectType.Web:
                        break;

                    default:
                        break;
                    }
                }
            }

            foreach (DCTFolder item in childFolders)
            {
                childs.Add(item);
            }

            foreach (DCTFile item in childFiles)
            {
                childs.Add(item);
            }

            return(childs);
        }
Example #36
0
        /// <summary>
        /// alle modules ophalen dus ook de zichtbaar op alle pagina's in site of template
        /// </summary>
        /// <returns></returns>
        public BaseCollection <BaseModule> GetAllModules()
        {
            if (_allModules == null || _allModules.Count == 0)
            {
                List <BaseModule> modules = new List <BaseModule>();

                string where = String.Format("FK_Site='{0}' AND (CrossPagesMode=2)", this.Site.ID);
                BaseCollection <BaseModule> siteModules = BaseCollection <BaseModule> .Get(where, "OrderingNumber");

                modules.AddRange(siteModules);
                //foreach (BaseModule module in siteModules)
                //{
                //    if (!modulesHtmlByContainerName.ContainsKey(module.ContainerName))
                //    {
                //        modulesHtmlByContainerName.Add(module.ContainerName, "");
                //    }
                //    module.LanguageCode = languageCode;
                //    modulesHtmlByContainerName[module.ContainerName] += module.ConvertToType().Publish2(this);
                //}
                //dan modules zichtbaar in de template
                if (this.Template != null)
                {
                    where = String.Format("FK_Site='{0}' AND (CrossPagesMode=1 AND FK_Template = '{1}')", this.Site.ID, this.Template.ID);
                    BaseCollection <BaseModule> templateModules = BaseCollection <BaseModule> .Get(where, "OrderingNumber");

                    modules.AddRange(templateModules);
                    //foreach (BaseModule module in templateModules)
                    //{
                    //    if (!modulesHtmlByContainerName.ContainsKey(module.ContainerName))
                    //    {
                    //        modulesHtmlByContainerName.Add(module.ContainerName, "");
                    //    }
                    //    module.LanguageCode = languageCode;
                    //    modulesHtmlByContainerName[module.ContainerName] += module.ConvertToType().Publish2(this);
                    //}
                }
                //en alle page modules
                //BaseCollection<BaseModule> pageModules = BaseCollection<BaseModule>.Get("FK_Page='" + this.ID + "'", "OrderingNumber");
                modules.AddRange(this.Modules);
                modules     = modules.GroupBy(c => c.ID).Select(c => c.FirstOrDefault()).OrderBy(c => c.OrderingNumber).ToList();
                _allModules = new BaseCollection <BaseModule>();
                //DIT IS NODIG OM DE INCLUDESCRIPTS TE LADEN. DEZE STAP WORDT OVERGESLAGEN IN PUBLISH()
                foreach (BaseModule module in modules)
                {
                    _allModules.Add(module.ConvertToType());
                }

                //if (_allModules == null ||_allModules.Count == 0)
                //{
                //    _allModules = new BaseCollection<BaseModule>();
                //    //eerst site modules
                //    string where = String.Format("FK_Site='{0}' AND IsVisibleOnAllPages=true", this.Site.ID);
                //    BaseCollection<BaseModule> siteModules = BaseCollection<BaseModule>.Get(where, "OrderingNumber");
                //    foreach (BaseModule mod in siteModules)
                //    {
                //        BaseModule convertedModule = mod.ConvertToType();
                //        _allModules.Add(convertedModule);
                //    }
                //    //dan modules zichtbaar in de template
                //    if (this.Template != null)
                //    {
                //        where = String.Format("FK_Site='{0}' AND IsVisibleOnAllPagesInLayout=true AND FK_Template = '{1}'", this.Site.ID, this.Template.ID);
                //        BaseCollection<BaseModule> templateModules = BaseCollection<BaseModule>.Get(where, "OrderingNumber");
                //        foreach (BaseModule mod in templateModules)
                //        {
                //            BaseModule convertedModule = mod.ConvertToType();
                //            _allModules.Add(convertedModule);
                //        }
                //    }
                //    //en alle page modules
                //    BaseCollection<BaseModule> pageModules = BaseCollection<BaseModule>.Get("FK_Page='" + this.ID + "'", "OrderingNumber");
                //    foreach (BaseModule mod in pageModules)
                //    {
                //        BaseModule convertedModule = mod.ConvertToType();
                //        _allModules.Add(convertedModule);
                //    }

                //    //en alle page modules
                //    BaseCollection<BaseModule> newsletterModules = BaseCollection<BaseModule>.Get("FK_Newsletter='" + this.ID + "'", "OrderingNumber");
                //    foreach (BaseModule mod in newsletterModules)
                //    {
                //        BaseModule convertedModule = mod.ConvertToType();
                //        _allModules.Add(convertedModule);
                //    }
            }
            return(_allModules);
        }
        public BaseCollection<DCTStorageObject> DCMGetChildren(DCTFolder folder, DCTContentType contentType)
        {
            BaseCollection<DCTStorageObject> childs = new BaseCollection<DCTStorageObject>();
            BaseCollection<DCTFile> childFiles = new BaseCollection<DCTFile>();
            BaseCollection<DCTFolder> childFolders = new BaseCollection<DCTFolder>();

            using (DocLibContext clientContext = new DocLibContext(ServiceHelper.GetDocumentLibraryName()))
            {
                Folder clientOMFolder = clientContext.Web.GetFolderByServerRelativeUrl(folder.Uri);
                CamlQuery query = new CamlQuery();
                query.FolderServerRelativeUrl = LoadUri(folder, clientContext);
                query.ViewXml = Caml.SimpleView(Caml.EmptyCaml(), CamlBuilder.ViewType.Default).ToCamlString();

                ListItemCollection items = clientContext.BaseList.GetItems(query);

                clientContext.Load(items);
                clientContext.ExecuteQuery();

                foreach (ListItem item in items)
                {
                    switch (item.FileSystemObjectType)
                    {
                        case FileSystemObjectType.File:
                            if ((contentType & DCTContentType.File) != DCTContentType.None)
                            {
                                DCTFile itemFile = new DCTFile();
                                DCTConverterHelper.Convert(item, itemFile);

                                childs.Add(itemFile);
                                //childFiles.Add(itemFile);
                            }
                            break;
                        case FileSystemObjectType.Folder:
                            if ((contentType & DCTContentType.Folder) != DCTContentType.None)
                            {
                                DCTFolder itemFolder = new DCTFolder();

                                DCTConverterHelper.Convert(item, itemFolder);

                                childs.Add(itemFolder);
                                //childFolders.Add(itemFolder);
                            }
                            break;
                        case FileSystemObjectType.Invalid:
                            break;
                        case FileSystemObjectType.Web:
                            break;
                        default:
                            break;
                    }
                }
            }

            foreach (DCTFolder item in childFolders)
                childs.Add(item);

            foreach (DCTFile item in childFiles)
                childs.Add(item);

            return childs;
        }
Example #38
0
		/// <summary>
		/// 查询文件
		/// </summary>
		/// <param name="keyValuePairs">键值对</param>
		/// <returns></returns>
		public BaseCollection<DCTClientFile> QueryFile(Dictionary<string, string> keyValuePairs)
		{
			BaseCollection<DCTFileField> fileFields = new BaseCollection<DCTFileField>();

			foreach (var pair in keyValuePairs)
			{
				var curField = Fields;
				if (!curField.ContainsKey(pair.Key))
					continue;
				fileFields.Add(new DCTFileField() { Field = Fields[pair.Key], FieldValue = pair.Value });

			}

			BaseCollection<DCTFile> files = new BaseCollection<DCTFile>();
			BaseCollection<DCTClientFile> results = new BaseCollection<DCTClientFile>();
			ServiceProxy.SingleCall<IDCSFetchService>(binding, searchEndpointAddress, userBehavior, action =>
			{
				files = action.DCMQueryDocByField(fileFields);
				foreach (var file in files)
				{
					results.Add(file.To<DCTClientFile>());
				}
			});

			return results;
		}
Example #39
0
		/// <summary>
		/// 搜索
		/// </summary>
		/// <param name="keywords">关键字</param>
		/// <returns></returns>
		public BaseCollection<DCTClientSearchResult> Search(params string[] keywords)
		{
			BaseCollection<DCTClientSearchResult> results = new BaseCollection<DCTClientSearchResult>();
			ServiceProxy.SingleCall<IDCSFetchService>(binding, searchEndpointAddress, userBehavior, action =>
			{
				var allDocs = action.DCMSearchDoc(keywords);
				foreach (var doc in allDocs)
				{
					DCTClientSearchResult result = doc.To<DCTClientSearchResult>();
					result.Client = this;
					results.Add(result);
				}
			});
			return results;
		}