private void OnNewDocumentCreating(NewDocumentCancelEventArgs e)
 {
     if (NewDocumentCreating != null)
     {
         NewDocumentCreating(this, e);
     }
 }
Пример #2
0
 void controller_NewDocumentCreating(object sender, NewDocumentCancelEventArgs e)
 {
     if (NewDocumentCreating != null)
     {
         NewDocumentCreating(this, e);
     }
 }
        private string ProcessNewDocument(FileManagerItemInfo destDir, NewDocumentTemplate template)
        {
            NewDocumentCancelEventArgs cancelArg = new NewDocumentCancelEventArgs();
            cancelArg.DestinationDirectory = destDir;
            cancelArg.Template = template;
            OnNewDocumentCreating(cancelArg);

            if (cancelArg.Cancel)
            {
                return ClientMessageEventReference(cancelArg.ClientMessage);
            }

            if (template.MasterFileUrl.Length == 0)
                return "";

            FileInfo masterFile = new FileInfo(Page.MapPath(template.MasterFileUrl));
            if (!masterFile.Exists)
                return "";

            string newFileName = template.NewFileName;
            if (newFileName.Length == 0)
                newFileName = template.Name;

            int i = 1;
            string originNewFileName = newFileName;
            while (File.Exists(Path.Combine(destDir.PhysicalPath, newFileName + masterFile.Extension)))
            {
                newFileName = originNewFileName + "(" + i + ")";
                i++;
            }
            newFileName = newFileName + masterFile.Extension;
            FileManagerItemInfo itemInfo = ResolveFileManagerItemInfo(VirtualPathUtility.AppendTrailingSlash(destDir.FileManagerPath) + newFileName);
            FileInfo newDocument = masterFile.CopyTo(itemInfo.PhysicalPath);

            NewDocumentEventArgs arg = new NewDocumentEventArgs();
            arg.Template = template;
            arg.NewDocument = itemInfo;
            OnNewDocumentCreated(arg);

            return ClientRefreshEventReference;
        }
 private void OnNewDocumentCreating(NewDocumentCancelEventArgs e)
 {
     if (NewDocumentCreating != null)
         NewDocumentCreating (this, e);
 }
 void controller_NewDocumentCreating(object sender, NewDocumentCancelEventArgs e)
 {
     if (NewDocumentCreating != null)
         NewDocumentCreating(this, e);
 }