/// <summary>
 /// 初始化一个标准ViewModel
 /// </summary>
 /// <param name="path"></param>
 /// <param name="type"></param>
 public FileSystemObjectViewModel(string path, string displayName, FileSystemObjectType type)
 {
     Path        = path;
     DisplayName = displayName;
     Type        = type;
     isSpecial   = false;
     Initialize();
 }
Beispiel #2
0
 /// <summary>
 /// 初始化一个标准ViewModel
 /// </summary>
 /// <param name="path"></param>
 /// <param name="type"></param>
 public FileSystemObjectViewModel(string path, string displayName, FileSystemObjectType type, string ppath)
 {
     Path        = path;
     DisplayName = displayName; //显示出来的名字,加到整个的(包括类型扩展)的最后面
     Type        = type;
     ParentPath  = ppath;
     isSpecial   = false;
     Initialize();
 }
Beispiel #3
0
 public SPItemInfo(string siteUrl, FileSystemObjectType fsoType, int id, string path, string name)
 {
     Id      = id;
     Path    = path;
     FsoType = fsoType;
     Name    = name;
     Url     = fsoType == FileSystemObjectType.Folder ?
               new Uri(siteUrl).GetLeftPart(UriPartial.Authority) + path :
               $"{siteUrl}_layouts/15/download.aspx?SourceUrl=" + // 需依SharePoint版本調整
               Microsoft.SharePoint.Client.Utilities.HttpUtility.UrlPathEncode(path, true, true);
 }
Beispiel #4
0
        /// <summary>
        /// Navigate through the items under the given list.
        /// </summary>
        /// <param name="clientContext">The client context.</param>
        /// <param name="list">The list we're looking at.</param>
        /// <param name="hostWeb">The host Web.</param>
        private void GetItemsInDocumentsList(ClientContext clientContext, List list, String hostWeb)
        {
            CamlQuery          query          = new CamlQuery();
            ListItemCollection itemCollection = list.GetItems(query);

            clientContext.Load <ListItemCollection>(itemCollection);
            clientContext.ExecuteQuery();

            if (itemCollection == null)
            {
                throw new Exception("Item collection was null. ");
            }

            foreach (ListItem item in itemCollection)
            {
                clientContext.Load <ListItem>(item);
                clientContext.ExecuteQuery();
                FileSystemObjectType objType = item.FileSystemObjectType;

                // Check to see if the item is a file.
                if (objType == FileSystemObjectType.File)
                {
                    // At the topmost level, files don't belong to a folder, so set the folder name to "Documents".
                    String folderName = documentsList;
                    File   file       = item.File;
                    clientContext.Load <File>(file);
                    clientContext.ExecuteQuery();
                    ItemAttributes itemAttrs = GetFileInfo(clientContext, hostWeb, folderName, file);
                    _ItemsList.Add(itemAttrs);
                }

                // Check to see if the item is a folder.
                else if (objType == FileSystemObjectType.Folder)
                {
                    Folder folder = item.Folder;
                    clientContext.Load <Folder>(folder);
                    clientContext.ExecuteQuery();

                    if (folder == null)
                    {
                        throw new Exception("Null folder.");
                    }
                    GetSubfolders(clientContext, folder, hostWeb);
                }

                else
                {
                    throw new Exception("Item is not a folder and not a file.");
                }
            }
        }
        private void _HandleChange(
            FileSystemChangeType changeType,
            string newPath,
            string origPath = null)
        {
            bool isDirectory = changeType == FileSystemChangeType.Delete
               ? !Path.HasExtension(newPath) // best we can do since object no longer exists
               : (File.GetAttributes(newPath) & FileAttributes.Directory) == FileAttributes.Directory;

            FileSystemObjectType fsoType = isDirectory
                ? FileSystemObjectType.Directory
                : FileSystemObjectType.File;;

            Console.WriteLine(string.Concat(
                                  changeType.ToString(),
                                  ": ",
                                  newPath,
                                  origPath == null ? "" : ", orig: ",
                                  origPath == null ? "" : origPath,
                                  ", type: ",
                                  fsoType.ToString()));

            if (this.Changed != null)
            {
                //try
                //{
                //this.FileSystemWatcher.EnableRaisingEvents = false;
                this.Changed(this, new FileSystemChangeEventArgs
                {
                    ChangeType           = changeType,
                    FileSystemObjectType = fsoType,
                    FullPath             = newPath,
                    OriginalFullPath     = origPath
                });
                //}
                //finally
                //{
                //    //this.FileSystemWatcher.EnableRaisingEvents = true;
                //}
            }
        }
        public string BuildCommandArgs(
            FileSystemChangeType changeType,
            FileSystemObjectType fsoType,
            string watchDirPath,
            string changedFilePath,
            string originalFilePath,
            string filePathToProcess,
            string[] processExeArgs)
        {
            watchDirPath      = this._getFullPath(watchDirPath ?? "");
            changedFilePath   = this._getFullPath(changedFilePath ?? "");
            originalFilePath  = this._getFullPath(originalFilePath ?? "");
            filePathToProcess = this._getFullPath(filePathToProcess ?? "");

            string argTokenStr = string.Concat(
                "\"",
                string.Join("\" \"", processExeArgs),
                "\"");

            IList <string> executableArgsList = new List <string>();

            string argsStr = argTokenStr.Replace(Token.ChangeType, changeType.ToString());

            argsStr = argsStr.Replace(Token.ObjectType, fsoType.ToString());

            argsStr = argsStr.Replace(Token.ChangedPath, changedFilePath);
            argsStr = argsStr.Replace(Token.ChangedPathNoExtension, Path.Combine(Path.GetDirectoryName(changedFilePath), Path.GetFileNameWithoutExtension(changedFilePath)));
            argsStr = argsStr.Replace(Token.ChangedPathRelative, changedFilePath.Substring(watchDirPath.Length + 1));

            argsStr = argsStr.Replace(Token.EachPath, filePathToProcess);
            argsStr = argsStr.Replace(Token.EachPathNoExtension, Path.Combine(Path.GetDirectoryName(filePathToProcess), Path.GetFileNameWithoutExtension(filePathToProcess)));
            argsStr = argsStr.Replace(Token.EachPathRelative, filePathToProcess.Substring(watchDirPath.Length + 1));

            argsStr = argsStr.Replace(Token.OriginalPath, originalFilePath);

            return(argsStr);
        }
        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);

            if (flag)
            {
                return(flag);
            }
            if (peekedName != null)
            {
                if (!(peekedName == "FolderPath"))
                {
                    if (!(peekedName == "LeafName"))
                    {
                        if (peekedName == "UnderlyingObjectType")
                        {
                            flag = true;
                            reader.ReadName();
                            this.m_underlyingObjectType = reader.ReadEnum <FileSystemObjectType>();
                        }
                    }
                    else
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_leafName = reader.Read <ResourcePath>();
                    }
                }
                else
                {
                    flag = true;
                    reader.ReadName();
                    this.m_folderPath = reader.Read <ResourcePath>();
                }
            }
            return(flag);
        }
 public IListItem Add(Dictionary <string, object> values, string folderPath = null, FileSystemObjectType fileSystemObjectType = FileSystemObjectType.File)
 {
     return(AddAsync(values, folderPath, fileSystemObjectType).GetAwaiter().GetResult());
 }
        public async Task <IListItem> AddAsync(Dictionary <string, object> values, string folderPath = null, FileSystemObjectType fileSystemObjectType = FileSystemObjectType.File)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            var newListItem = CreateNewAndAdd() as ListItem;

            // Assign field values
            newListItem.Values.SystemAddRange(values);

            return(await newListItem.AddAsync(new Dictionary <string, object> {
                { ListItem.FolderPath, folderPath }, { ListItem.UnderlyingObjectType, fileSystemObjectType }
            }).ConfigureAwait(false) as ListItem);
        }
 public async Task <IListItem> AddBatchAsync(Dictionary <string, object> values, string folderPath = null, FileSystemObjectType fileSystemObjectType = FileSystemObjectType.File)
 {
     return(await AddBatchAsync(PnPContext.CurrentBatch, values, folderPath, fileSystemObjectType).ConfigureAwait(false));
 }
Beispiel #11
0
        // Public
        #region Constructors

        public SrfsAccessRule(FileSystemObjectType type, int id, FileSystemAccessRule rule)
        {
            _type       = type;
            _id         = id;
            _accessRule = rule;
        }
Beispiel #12
0
 public SrfsAuditRule(FileSystemObjectType type, int id, FileSystemAuditRule rule)
 {
     _type      = type;
     _id        = id;
     _auditRule = rule;
 }