Esempio n. 1
0
 private void BindValues()
 {
     if (FolderId > 0)
     {
         DirectoryInfo diCur = fs.GetDirectory(FolderId);
         txtTitle.Text = diCur.Name;
     }
 }
Esempio n. 2
0
        private void ProcessFolder(int iFolder)
        {
            string name   = "";
            string folder = "";

            for (int i = 0; i < _Level; i++)
            {
                name += "&nbsp;&nbsp;&nbsp;";
            }
            _Level++;
            bool fl = false;

            if (fs.CanUserWrite(iFolder))
            {
                if (iFolder == fs.Root.Id)
                {
                    name += LocRM.GetString("tRoot");
                }
                else
                {
                    name += fs.GetDirectory(iFolder).Name;
                }
                folder = iFolder.ToString();
                fl     = true;
            }
            else
            {
                if (iFolder == fs.Root.Id)
                {
                    name += LocRM.GetString("tRoot");
                }
                else
                {
                    name += fs.GetDirectory(iFolder).Name;
                }
                folder = "*" + iFolder.ToString();
            }
            System.IO.StringWriter writer = new System.IO.StringWriter();
            Server.HtmlDecode(name, writer);
            string decoded = writer.ToString();

            ListItem item = new ListItem(decoded, folder);

            if (!fl)
            {
                item.Attributes.Add("style", "COLOR: gray;");
            }

            ddFolder.Items.Add(item);

            DirectoryInfo[] _di = fs.GetDirectories(iFolder);
            foreach (DirectoryInfo di in _di)
            {
                ProcessFolder(di.Id);
                _Level--;
            }
        }
        private void BindJsTree()
        {
            string containerName = Request["ContainerName"];
            string containerKey  = Request["ContainerKey"];
            string folderId      = Request["FolderId"];

            Mediachase.IBN.Business.ControlSystem.FileStorage fs = Mediachase.IBN.Business.ControlSystem.FileStorage.Create(containerName, containerKey);

            ArrayList parentList = new ArrayList();

            if (!String.IsNullOrEmpty(folderId))
            {
                int iFolder = int.Parse(folderId);
                while (true)
                {
                    DirectoryInfo diEx = fs.GetDirectory(iFolder);
                    parentList.Add(diEx.Id);
                    if (iFolder == fs.Root.Id)
                    {
                        break;
                    }
                    iFolder = diEx.ParentDirectoryId;
                }
            }

            BindNode(fs.Root.Id.ToString(), parentList);
        }
Esempio n. 4
0
        private string BuildPath(int FolderId)
        {
            string sPath = "";

            int iFolder = FolderId;

            while (true)
            {
                DirectoryInfo di = fs.GetDirectory(iFolder);
                string        sFullFolderName = di.Name;
                if (iFolder == fs.Root.Id)
                {
                    sFullFolderName = LocRM.GetString("tRoot");
                }
                string sFolderName = sFullFolderName;
                if (sFolderName.Length > 13)
                {
                    sFolderName = sFolderName.Substring(0, 10) + "...";
                }
                if (sPath == "")
                {
                    sPath = sFolderName;
                }
                else
                {
                    sPath = String.Format("{0} \\ {1}", sFolderName, sPath);
                }
                if (iFolder == fs.Root.Id)
                {
                    break;
                }
                iFolder = di.ParentDirectoryId;
            }
            return(sPath);
        }
Esempio n. 5
0
 private void GetCurrentFolder()
 {
     _fs = Mediachase.IBN.Business.ControlSystem.FileStorage.Create(_containerName, _containerKey);
     if (!IsPostBack && Request["FolderId"] != null && Request["FolderId"] != String.Empty)
     {
         _folderId = int.Parse(Request["FolderId"]);
     }
     else if (_folderId < 0 && _pc["fs_FolderId_" + _containerKey] != null)
     {
         int           iFolder = int.Parse(_pc["fs_FolderId_" + _containerKey]);
         DirectoryInfo di      = _fs.GetDirectory(iFolder);
         if (di != null)
         {
             _folderId = iFolder;
         }
         else
         {
             _folderId = _fs.Root.Id;
         }
     }
     else
     {
         _folderId = _fs.Root.Id;
     }
     _rootId = _fs.Root.Id;
     _pc["fs_FolderId_" + _containerKey] = _folderId.ToString();
 }
Esempio n. 6
0
        private void GetCurrentFolderAndMoveObjects()
        {
            bic = BaseIbnContainer.Create(ContainerName, ContainerKey);
            fs  = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

            string sFolders = Request["Folders"].ToString();
            string sFiles   = Request["Files"].ToString();

            while (sFolders.Length > 0)
            {
                alFolders.Add(sFolders.Substring(0, sFolders.IndexOf(",")));
                sFolders = sFolders.Remove(0, sFolders.IndexOf(",") + 1);
            }
            while (sFiles.Length > 0)
            {
                alFiles.Add(sFiles.Substring(0, sFiles.IndexOf(",")));
                sFiles = sFiles.Remove(0, sFiles.IndexOf(",") + 1);
            }
            if (alFolders.Count > 0)
            {
                ParentFolderId = fs.GetDirectory(int.Parse(alFolders[0].ToString())).ParentDirectoryId;
            }
            else if (alFiles.Count > 0)
            {
                int      i  = int.Parse(alFiles[0].ToString());
                FileInfo fi = fs.GetFile(i);
                ParentFolderId = fi.ParentDirectoryId;
            }
            ctrlDirTree.DisFolderId = ParentFolderId;
        }
Esempio n. 7
0
 void grdMain_ItemCommand(object source, DataGridCommandEventArgs e)
 {
     if (e.CommandName == "Select")
     {
         int    selId             = int.Parse(e.Item.Cells[0].Text);
         string containerKey      = "EMailAttach";
         CS.BaseIbnContainer bic2 = CS.BaseIbnContainer.Create(ContainerName, containerKey);
         CS.FileStorage      fs2  = (CS.FileStorage)bic2.LoadControl("FileStorage");
         CS.DirectoryInfo    di   = fs2.GetDirectory(fs2.Root.Id, guid, true);
         try
         {
             fs.CopyFile(selId, di.Id);
         }
         catch { }
         string        sFiles = "";
         CS.FileInfo[] _fi    = fs2.GetFiles(di);
         foreach (CS.FileInfo fi in _fi)
         {
             sFiles += String.Format("<div style='padding-bottom:1px;'><img align='absmiddle' src='{0}' width='16' height='16'/>&nbsp;{1}&nbsp;&nbsp;<img src='{2}' align='absmiddle' width='16' height='16' style='cursor:pointer;' onclick='_deleteFile({3})' title='{4}' /></div>",
                                     ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId),
                                     Util.CommonHelper.GetShortFileName(fi.Name, 40),
                                     ResolveUrl("~/Layouts/Images/delete.gif"),
                                     fi.Id, LocRM.GetString("tDelete"));
         }
         Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), String.Format("CloseAll(\"{0}\");", sFiles), true);
     }
 }
Esempio n. 8
0
 private void GetCurrentFolder()
 {
     ContainerKey = ViewState["ContainerKey"].ToString();
     bic          = CS.BaseIbnContainer.Create(ContainerName, ContainerKey);
     fs           = (CS.FileStorage)bic.LoadControl("FileStorage");
     if (!Page.IsPostBack && Request["FolderId"] != null && Request["FolderId"] != String.Empty)
     {
         FolderId = int.Parse(Request["FolderId"]);
     }
     else if (FolderId < 0 && pc["fs_FolderId_" + ContainerKey] != null)
     {
         int iFolder         = int.Parse(pc["fs_FolderId_" + ContainerKey]);
         CS.DirectoryInfo di = fs.GetDirectory(iFolder);
         if (di != null)
         {
             FolderId = iFolder;
         }
         else
         {
             FolderId = fs.Root.Id;
         }
     }
     else
     {
         FolderId = fs.Root.Id;
     }
     RootId = fs.Root.Id;
     pc["fs_FolderId_" + ContainerKey] = FolderId.ToString();
 }
Esempio n. 9
0
        public ArrayList DeleteAttachment(string _guid, string _id)
        {
            string    sFiles         = "";
            ArrayList values         = new ArrayList();
            string    _containerName = "FileLibrary";
            string    _containerKey  = "EMailAttach";

            CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
            CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");
            fs.DeleteFile(int.Parse(_id));
            CS.DirectoryInfo di = fs.GetDirectory(fs.Root.Id, _guid, false);
            if (di != null)
            {
                CS.FileInfo[] _fi = fs.GetFiles(di);
                foreach (CS.FileInfo fi in _fi)
                {
                    sFiles += String.Format(CultureInfo.InvariantCulture,
                                            "<div style='padding-bottom:1px;'><img align='absmiddle' src='{0}' width='16' height='16'>&nbsp;{1}&nbsp;&nbsp;<img src='{2}' align='absmiddle' width='16' height='16' style='cursor:pointer;' onclick='_deleteFile({3})' title='{4}' /></div>",
                                            CHelper.GetAbsolutePath("/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId),
                                            Util.CommonHelper.GetShortFileName(fi.Name, 40),
                                            CHelper.GetAbsolutePath("/Layouts/Images/delete.gif"),
                                            fi.Id,
                                            LocRM.GetString("Delete"));
                }
            }
            values.Add(sFiles);
            return(values);
        }
Esempio n. 10
0
        protected void grdMain_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                int selId = int.Parse(e.Item.Cells[0].Text);

                string sText  = "";
                string sTitle = "";
                using (IDataReader reader = Mediachase.IBN.Business.Common.GetArticle(selId))
                {
                    if (reader.Read())
                    {
                        sTitle = reader["Question"].ToString();
                        sText  = String.Format("<div style='border-top: solid 1px #95B7F3; padding:0px;background-color:ffffe1;'>" +
                                               "<div style='padding:5px; cursor:default;background-color:#FFD275;'><b>{0}</b></div>" +
                                               "<div style='padding:5px;'>{1}</div>" +
                                               "</div>", reader["Question"].ToString(), reader["AnswerHTML"].ToString());
                    }
                }

                Common.AddHistory(ObjectTypes.KnowledgeBase, selId, sTitle);
                Common.IncreaseArticleCounter(selId);

                string sFiles           = "";
                string containerName    = "FileLibrary";
                string containerKey     = UserRoleHelper.CreateArticleContainerKey(selId);
                CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(containerName, containerKey);
                CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");
                CS.FileInfo[]       _fi = fs.Root.GetFiles();
                if (_fi.Length > 0)
                {
                    string _containerName    = "FileLibrary";
                    string _containerKey     = "EMailAttach";
                    CS.BaseIbnContainer _bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
                    CS.FileStorage      _fs  = (CS.FileStorage)_bic.LoadControl("FileStorage");
                    CS.DirectoryInfo    di   = _fs.GetDirectory(_fs.Root.Id, guid, true);
                    foreach (CS.FileInfo fi in _fi)
                    {
                        fs.CopyFile(fi.Id, di.Id, true);
                    }

                    _fi = _fs.GetFiles(di);
                    foreach (CS.FileInfo fi in _fi)
                    {
                        sFiles += String.Format("<div style='padding-bottom:1px;'><img align='absmiddle' src='{0}' width='16' height='16'>&nbsp;{1}&nbsp;&nbsp;<img src='{2}' align='absmiddle' width='16' height='16' style='cursor:pointer;' onclick='_deleteFile({3})' title='{4}' /></div>",
                                                ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId),
                                                Util.CommonHelper.GetShortFileName(fi.Name, 40),
                                                ResolveUrl("~/Layouts/Images/delete.gif"),
                                                fi.Id,
                                                LocRM2.GetString("tDelete"));
                    }
                }
                sText = sText.Replace("\r\n", "");
                sText = sText.Replace("\t", "");
                sText = sText.Replace("\\", "\\\\");
                sText = sText.Replace("\"", "\\\"");
                Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), String.Format("CloseAll(\"{0}\", \"{1}\");", sFiles, sText), true);
            }
        }
Esempio n. 11
0
        private void btnPublish_ServerClick(object sender, EventArgs e)
        {
            int iDestFolder = -1;

            try
            {
                iDestFolder = ctrlDirTree.FolderId;
            }
            catch { }
            if (iDestFolder == -1)
            {
                lblNotValid.Visible = true;
                return;
            }

            BaseIbnContainer sourceBic = BaseIbnContainer.Create(ContainerName, ContainerKey);

            Mediachase.IBN.Business.ControlSystem.FileStorage sourceFS = (Mediachase.IBN.Business.ControlSystem.FileStorage)sourceBic.LoadControl("FileStorage");
            FileInfo sourceFi = sourceFS.GetFile(FileId);

            string cKey = DirectoryInfo.GetContainerKey(iDestFolder);

            if (String.IsNullOrEmpty(cKey))
            {
                cKey = "Workspace";
            }
            BaseIbnContainer destBic = BaseIbnContainer.Create("FileLibrary", cKey);

            Mediachase.IBN.Business.ControlSystem.FileStorage destFS = (Mediachase.IBN.Business.ControlSystem.FileStorage)destBic.LoadControl("FileStorage");
            DirectoryInfo destDi = destFS.GetDirectory(iDestFolder);

            try
            {
                destFS.CopyFile(sourceFi, destDi);
            }
            catch (SqlException exception)
            {
                if (exception.Number == 2627 || exception.Number == 50000)
                {
                    lblErrorMessage.Text = LocRM.GetString("tDuplicateName");
                    trError.Visible      = true;
                    return;
                }
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                    "try {window.opener.location.href=window.opener.location.href;window.close();}" +
                                                    "catch (e){}", true);
        }
Esempio n. 12
0
        private void BindToolbar()
        {
            DirectoryInfo di    = fs.GetDirectory(FolderId);
            string        sName = di.Name;

            if (fs.Root.Id == FolderId)
            {
                sName = LocRM.GetString("tRoot");
            }
            if (sName.Length > 33)
            {
                sName = sName.Substring(0, 30) + "...";
            }
            secHeader.Title = LocRM.GetString("tEditSec") + " \"" + sName + "\"";
            secHeader.AddLink("<img alt='' src='../Layouts/Images/saveitem.gif'/> " + LocRM.GetString("Save"), "javascript:FuncSave();");
            secHeader.AddSeparator();
            secHeader.AddLink("<img alt='' src='../Layouts/Images/cancel.gif'/> " + LocRM.GetString("Cancel"), "javascript:window.close();");
        }
Esempio n. 13
0
 private void grdMain_ItemDataBound(object sender, DataGridItemEventArgs e)
 {
     if (Top > 0)
     {
         return;
     }
     else
     {
         DataGridItem item = e.Item;
         if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.EditItem)
         {
             string           containerKey1 = item.Cells[1].Text;
             BaseIbnContainer bic           = BaseIbnContainer.Create("FileLibrary", containerKey1);
             Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");
             DirectoryInfo di         = fs.GetDirectory(int.Parse(item.Cells[2].Text));
             string        parentName = "";
             string        parentLink = "";
             Util.CommonHelper.GetParentContainer(containerKey1, di, out parentName, out parentLink);
             item.Cells[5].Text = parentLink;
         }
     }
 }
        private void Process()
        {
            string _containerName = "FileLibrary";
            string _containerKey  = "EMailAttach";

            CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
            CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");
            CS.DirectoryInfo    di  = fs.GetDirectory(fs.Root.Id, guid, true);

            for (int Index = 0; Index < Request.Files.Count; Index++)
            {
                if (!String.IsNullOrEmpty(Request.Files[Index].FileName))
                {
                    using (McHttpPostedFile PostedFile = new McHttpPostedFile(Request.Files[Index]))
                    {
                        if (PostedFile.InputStream != null)
                        {
                            fs.SaveFile(di.Id, PostedFile.FileName, PostedFile.InputStream);
                        }
                    }
                }
            }
        }
Esempio n. 15
0
        void lbSelectChecked_Click(object sender, EventArgs e)
        {
            string    sIds  = hidForSelect.Value;
            ArrayList alIds = new ArrayList();

            while (sIds.Length > 0)
            {
                alIds.Add(sIds.Substring(0, sIds.IndexOf(",")));
                sIds = sIds.Remove(0, sIds.IndexOf(",") + 1);
            }
            string _containerKey = "EMailAttach";

            CS.BaseIbnContainer bic2 = CS.BaseIbnContainer.Create(ContainerName, _containerKey);
            CS.FileStorage      fs2  = (CS.FileStorage)bic2.LoadControl("FileStorage");
            CS.DirectoryInfo    di   = fs2.GetDirectory(fs2.Root.Id, guid, true);
            foreach (string scId in alIds)
            {
                int assetID = int.Parse(scId);
                try
                {
                    fs.CopyFile(assetID, di.Id);
                }
                catch { }
            }
            string sFiles = "";

            CS.FileInfo[] _fi = fs2.GetFiles(di);
            foreach (CS.FileInfo fi in _fi)
            {
                sFiles += String.Format("<div style='padding-bottom:1px;'><img align='absmiddle' src='{0}' width='16' height='16'/>&nbsp;{1}&nbsp;&nbsp;<img src='{2}' align='absmiddle' width='16' height='16' style='cursor:pointer;' onclick='_deleteFile({3})' title='{4}' /></div>",
                                        ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId),
                                        Util.CommonHelper.GetShortFileName(fi.Name, 40),
                                        ResolveUrl("~/Layouts/Images/delete.gif"),
                                        fi.Id, LocRM.GetString("tDelete"));
            }
            Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), String.Format("CloseAll(\"{0}\");", sFiles), true);
        }
Esempio n. 16
0
        private DataTable BindStorage()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("PrimaryKeyId", typeof(string)));
            dt.Columns.Add(new DataColumn("Id", typeof(int)));
            dt.Columns.Add(new DataColumn("Weight", typeof(int)));              //0- Root, 1- Folder, 2-File
            dt.Columns.Add(new DataColumn("Icon", typeof(string)));
            dt.Columns.Add(new DataColumn("BigIcon", typeof(string)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("sortName", typeof(string)));
            dt.Columns.Add(new DataColumn("Description", typeof(string)));
            dt.Columns.Add(new DataColumn("ModifiedDate", typeof(string)));
            dt.Columns.Add(new DataColumn("sortModified", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("Modifier", typeof(string)));
            dt.Columns.Add(new DataColumn("sortModifier", typeof(string)));
            dt.Columns.Add(new DataColumn("Size", typeof(string)));
            dt.Columns.Add(new DataColumn("sortSize", typeof(int)));
            DataRow       dr;
            DirectoryInfo diCur = _fs.GetDirectory(_folderId);

            if (diCur.ParentDirectoryId > 0)
            {
                #region Parent Directory
                dr                 = dt.NewRow();
                dr["Id"]           = diCur.Id;
                dr["Weight"]       = 0;
                dr["PrimaryKeyId"] = GetUniqueKey(dr["Weight"].ToString(), dr["Id"].ToString());
                dr["Icon"]         = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/layouts/images/blank.gif"));
                dr["BigIcon"]      = "";
                if (_pc["fs_ViewStyle"] == "Thumbnails")
                {
                    dr["BigIcon"] = String.Format("<a href=\"{0}\"><img src='{1}' align='absmiddle' border='0' /></a>",
                                                  GetCurrentLink(diCur.ParentDirectoryId),
                                                  ResolveClientUrl("/layouts/images/back-up.gif"));
                }
                dr["Name"]     = String.Format("<a href=\"{0}\">{1}</a>", GetCurrentLink(diCur.ParentDirectoryId), "[..]");
                dr["sortName"] = "";
                dr["sortSize"] = 0;
                dt.Rows.Add(dr);
                #endregion
            }
            bool isExternal = Mediachase.IBN.Business.Security.CurrentUser.IsExternal;
            if (_fs.CanUserRead(diCur.Id))
            {
                DirectoryInfo[] dMas     = _fs.GetDirectories(_folderId);
                bool            canWrite = _fs.CanUserWrite(diCur.Id);
                foreach (DirectoryInfo di in dMas)
                {
                    #region Children Directories
                    if (!_fs.CanUserRead(di.Id))
                    {
                        continue;
                    }
                    dr                 = dt.NewRow();
                    dr["Id"]           = di.Id;
                    dr["Weight"]       = 1;
                    dr["PrimaryKeyId"] = GetUniqueKey(dr["Weight"].ToString(), dr["Id"].ToString());
                    if (Mediachase.IBN.Business.Common.IsPop3Folder(di.Id))
                    {
                        dr["Icon"] = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/layouts/images/folder_mailbox.gif"));
                    }
                    else
                    {
                        dr["Icon"] = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/layouts/images/FileTypes/Folder.gif"));
                    }
                    dr["BigIcon"] = "";
                    if (_pc["fs_ViewStyle"] == "Thumbnails")
                    {
                        dr["BigIcon"] = String.Format("<a href=\"{0}\"><img src='{1}' align='absmiddle' border='0' /></a>",
                                                      GetCurrentLink(di.Id),
                                                      (Mediachase.IBN.Business.Common.IsPop3Folder(di.Id)) ?
                                                      ResolveClientUrl("~/layouts/images/mailfolder.gif") :
                                                      ResolveClientUrl("~/layouts/images/folder1.gif"));
                        dr["Name"] = String.Format("<a href=\"{0}\" title='{2}'>{1}</a>",
                                                   GetCurrentLink(di.Id),
                                                   (di.Name.Length > 27) ? di.Name.Substring(0, 24) + "..." : di.Name,
                                                   di.Name
                                                   );
                    }
                    else
                    {
                        dr["Name"] = String.Format("<a href=\"{0}\" title='{2}'>{1}</a>", GetCurrentLink(di.Id),
                                                   (di.Name.Length > 40) ? di.Name.Substring(0, 37) + "..." : di.Name, di.Name);
                    }
                    dr["sortName"]     = di.Name;
                    dr["ModifiedDate"] = di.Modified.ToShortDateString();
                    dr["sortModified"] = di.Modified;
                    dr["Modifier"]     = CommonHelper.GetUserStatus(di.ModifierId);
                    dr["sortModifier"] = CommonHelper.GetUserStatusPureName(di.ModifierId);
                    dr["sortSize"]     = 0;
                    dt.Rows.Add(dr);
                    #endregion
                }

                FileInfo[] fMas = _fs.GetFiles(_folderId);
                foreach (FileInfo fi in fMas)
                {
                    #region Children Files
                    dr                 = dt.NewRow();
                    dr["Id"]           = fi.Id;
                    dr["Weight"]       = 2;
                    dr["PrimaryKeyId"] = GetUniqueKey(dr["Weight"].ToString(), dr["Id"].ToString());
                    dr["Icon"]         = String.Format("<img alt='' src='{0}' width='16' height='16' />", ResolveClientUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId));
                    dr["BigIcon"]      = "";
                    string sLink = "";
                    if (fi.FileBinaryContentType.ToLower().IndexOf("url") >= 0)
                    {
                        sLink = CommonHelper.GetLinkText(_fs, fi);
                    }
                    if (sLink == "")
                    {
                        sLink = CommonHelper.GetAbsoluteDownloadFilePath(fi.Id, fi.Name, _containerName, _containerKey);
                    }

                    string sNameLocked = CommonHelper.GetLockerText(sLink);

                    if (_pc["fs_ViewStyle"] == "Thumbnails")
                    {
                        dr["BigIcon"] = String.Format("<a href=\"{0}\"{2}>{1}</a>",
                                                      sLink,
                                                      String.Format("<img src='{0}' align='absmiddle' border='0' />",
                                                                    String.Format(ResolveClientUrl("~/Common/ContentIcon.aspx?Big=1&IconID={0}&ContainerKey={1}&FileId={2}"), fi.FileBinaryContentTypeId, _containerKey, fi.Id)),
                                                      Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : ""
                                                      );
                        dr["Name"] = String.Format("<a href=\"{0}\" title='{3}'{2}>{1}</a> {4}",
                                                   sLink,
                                                   CommonHelper.GetShortFileName(fi.Name, 27),
                                                   Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : "",
                                                   fi.Name,
                                                   sNameLocked
                                                   );
                    }
                    else
                    {
                        dr["Name"] = String.Format("<a href='{0}' title='{3}'{2}>{1}</a> {4}",
                                                   sLink,
                                                   CommonHelper.GetShortFileName(fi.Name, 40),
                                                   Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : "",
                                                   fi.Name,
                                                   sNameLocked
                                                   );
                    }
                    dr["sortName"]     = fi.Name;
                    dr["Description"]  = fi.Description;
                    dr["ModifiedDate"] = fi.Modified.ToShortDateString();
                    dr["sortModified"] = fi.Modified;
                    dr["Modifier"]     = CommonHelper.GetUserStatus(fi.ModifierId);
                    dr["sortModifier"] = CommonHelper.GetUserStatusPureName(fi.ModifierId);
                    dr["Size"]         = FormatBytes((long)fi.Length);
                    dr["sortSize"]     = fi.Length;
                    dt.Rows.Add(dr);
                    #endregion
                }
            }

            return(dt);
        }
Esempio n. 17
0
        private void BindStorage()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Id", typeof(int)));
            dt.Columns.Add(new DataColumn("Weight", typeof(int)));              //0- Root, 1- Folder, 2-File
            dt.Columns.Add(new DataColumn("Icon", typeof(string)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("sortName", typeof(string)));
            DataRow dr;

            CS.DirectoryInfo diCur = fs.GetDirectory(FolderId);
            if (diCur.ParentDirectoryId > 0)
            {
                dr             = dt.NewRow();
                dr["Id"]       = diCur.Id;
                dr["Weight"]   = 0;
                dr["Icon"]     = ResolveUrl("~/layouts/images/blank.gif");
                dr["Name"]     = String.Format("<a href='{0}'>{1}</a>", GetCurrentLink(diCur.ParentDirectoryId), "[..]");
                dr["sortName"] = "";
                dt.Rows.Add(dr);
            }
            if (fs.CanUserRead(diCur.Id))
            {
                CS.DirectoryInfo[] _di = fs.GetDirectories(FolderId);
                bool CanWrite          = fs.CanUserWrite(diCur.Id);
                foreach (CS.DirectoryInfo di in _di)
                {
                    if (!fs.CanUserRead(di.Id))
                    {
                        continue;
                    }
                    dr           = dt.NewRow();
                    dr["Id"]     = di.Id;
                    dr["Weight"] = 1;
                    if (Mediachase.IBN.Business.Common.IsPop3Folder(di.Id))
                    {
                        dr["Icon"] = ResolveUrl("~/layouts/images/folder_mailbox.gif");
                    }
                    else
                    {
                        dr["Icon"] = ResolveUrl("~/layouts/images/FileTypes/Folder.gif");
                    }
                    dr["Name"] = String.Format("<a href='{0}' title='{2}'>{1}</a>", GetCurrentLink(di.Id),
                                               (di.Name.Length > 40) ? di.Name.Substring(0, 37) + "..." : di.Name, di.Name);
                    dr["sortName"] = di.Name;
                    dt.Rows.Add(dr);
                }

                CS.FileInfo[] _fi = fs.GetFiles(FolderId);
                foreach (CS.FileInfo fi in _fi)
                {
                    dr             = dt.NewRow();
                    dr["Id"]       = fi.Id;
                    dr["Weight"]   = 2;
                    dr["Icon"]     = ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId);
                    dr["Name"]     = Util.CommonHelper.GetShortFileName(fi.Name, 40);
                    dr["sortName"] = fi.Name;
                    dt.Rows.Add(dr);
                }
            }
            DataView dv = dt.DefaultView;

            dv.Sort = "Weight, " + pc["fs_Sort1_" + ContainerKey].ToString();

            int i = 4;

            grdMain.Columns[i++].HeaderText = LocRM.GetString("DocTitle");

            if (pc["fs_PageSize1_" + ContainerKey] == null)
            {
                pc["fs_PageSize1_" + ContainerKey] = "10";
            }

            grdMain.PageSize = int.Parse(pc["fs_PageSize1_" + ContainerKey].ToString());

            if (pc["fs_Page1_" + ContainerKey] == null)
            {
                pc["fs_Page1_" + ContainerKey] = "0";
            }
            int PageIndex = int.Parse(pc["fs_Page1_" + ContainerKey].ToString());
            int ppi       = dv.Count / grdMain.PageSize;

            if (dv.Count % grdMain.PageSize == 0)
            {
                ppi = ppi - 1;
            }
            if (PageIndex <= ppi)
            {
                grdMain.CurrentPageIndex = PageIndex;
            }
            else
            {
                grdMain.CurrentPageIndex       = 0;
                pc["fs_Page1_" + ContainerKey] = "0";
            }

            grdMain.DataSource = dv;
            grdMain.DataBind();

            /*foreach (DataGridItem dgi in grdMain.Items)
             * {
             * }*/
        }
Esempio n. 18
0
        private void GetCurrentFolderAndMoveObjects()
        {
            bic = BaseIbnContainer.Create(ContainerName, ContainerKey);
            fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

            string sFolders = Request["Folders"].ToString();
            string sFiles = Request["Files"].ToString();
            while (sFolders.Length > 0)
            {
                alFolders.Add(sFolders.Substring(0, sFolders.IndexOf(",")));
                sFolders = sFolders.Remove(0, sFolders.IndexOf(",") + 1);
            }
            while (sFiles.Length > 0)
            {
                alFiles.Add(sFiles.Substring(0, sFiles.IndexOf(",")));
                sFiles = sFiles.Remove(0, sFiles.IndexOf(",") + 1);
            }
            if (alFolders.Count > 0)
                ParentFolderId = fs.GetDirectory(int.Parse(alFolders[0].ToString())).ParentDirectoryId;
            else if (alFiles.Count > 0)
            {
                int i = int.Parse(alFiles[0].ToString());
                FileInfo fi = fs.GetFile(i);
                ParentFolderId = fi.ParentDirectoryId;
            }
            ctrlDirTree.DisFolderId = ParentFolderId;
        }
Esempio n. 19
0
        protected void lbSend_Click(object sender, System.EventArgs e)
        {
            string sTo = txtTo.Text.Trim();

            // all recipients string
            string allRecipients = String.Empty;

            if (sTo != String.Empty)
            {
                allRecipients = sTo;
            }
            if (allRecipients != String.Empty)
            {
                allRecipients += "; ";
            }
            allRecipients += lblCC.Text;
            CommonHelper.AddToContext(ForumThreadNodeSetting.AllRecipients, allRecipients);

            string regex = "([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\\w]*[0-9a-zA-Z])*\\.)+[a-zA-Z]" +
                           "{2,9})";
            List <string> dic = new List <string>();

            System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline)
                                                                   | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options);


            foreach (Match item in reg.Matches(sTo))
            {
                if (!dic.Contains(item.Value))
                {
                    dic.Add(item.Value);
                }
            }
            string[] masTo = dic.ToArray();

            if (masTo.Length == 0 && lblCC.Text == String.Empty)
            {
                lblException.Text  = LocRM.GetString("NoRecipients");
                divMessage.Visible = true;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "_getFiles",
                                                        "window.setTimeout('updateAttachments()', 500);", true);
                return;
            }


            string _containerName = "FileLibrary";
            string _containerKey  = "EMailAttach";

            CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
            CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");
            CS.DirectoryInfo    di  = fs.GetDirectory(fs.Root.Id, _guid, true);

            try
            {
                if (IncidentId > 0)
                {
                    NameValueCollection _params = new NameValueCollection();
                    _params["IssueId"] = IncidentId.ToString();
                    EMailClient.SendMessage(masTo, txtSubject.Text, fckEditor.Text, di, EMailClient.IssueMode, _params);
                    string sUrl = "../Incidents/IncidentView.aspx?IncidentId=" + IncidentId;
                    if (Request["back"] != null)
                    {
                        sUrl = HttpUtility.UrlDecode(Request["back"]);
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "_close", "try{window.opener.location.href='" + sUrl + "';}catch(ex){}window.close();", true);
                }
                else
                {
                    EMailClient.SendMessage(masTo, txtSubject.Text, fckEditor.Text, di);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "_close", "window.close();", true);
                }
            }
            catch (Exception ex)
            {
                string sException = "";
                switch (ex.GetType().ToString())
                {
                case "System.Net.Sockets.SocketException":
                    sException = ex.Message;
                    break;

                case "Mediachase.IBN.Business.EMail.SmtpClientException":
                    sException = LocRM2.GetString("tServerSMTPError") + ":&nbsp;<span style='color:#444;font-style:italic;'>" + ex.Message + "</span>";
                    break;

                default:
                    // TODO: Save Exception to IBN Log And Show Friendly Link to Log
                    sException = ex.Message;
                    CHelper.GenerateErrorReport(ex);
                    break;
                }
                lblException.Text = LocRM2.GetString("SMTPSettingsIncorrect") + "&nbsp;" +
                                    LocRM2.GetString("tWereErrorsSMTP") + "<br/>" + sException;
                if (Security.IsUserInGroup(InternalSecureGroups.Administrator))
                {
                    lblSMTP.Text = "<a href='javascript:ToSMTPSettings();'><font style='color:Red;'><b><u>" + LocRM2.GetString("tSetupSMTPServer") + "</u></b></font></a>";
                }
                else
                {
                    lblSMTP.Text = LocRM2.GetString("tContactSMTPError");
                }
                divMessage.Visible = true;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "_getFiles",
                                                        "window.setTimeout('updateAttachments()', 500);", true);
            }
        }
Esempio n. 20
0
        private void ProcessFolderNode(TreeViewNode CurTreeNode, string ContainerKey, int iFolder, string RootName, bool RenderRoot)
        {
            string name   = "";
            string folder = "";

            bool isRoot = false;

            if (iFolder == fs.Root.Id)
            {
                name  += RootName;
                isRoot = true;
            }
            else
            {
                name += fs.GetDirectory(iFolder).Name;
            }

            folder = iFolder.ToString();

            bool fl = fs.CanUserWrite(iFolder);

            DirectoryInfo[] _di = fs.GetDirectories(iFolder);

            System.IO.StringWriter writer = new System.IO.StringWriter();
            Server.HtmlDecode(name, writer);
            string decoded = writer.ToString();

            TreeViewNode childNode;

            if (isRoot && !RenderRoot)
            {
                childNode = CurTreeNode;
            }
            else
            {
                childNode      = new TreeViewNode();
                childNode.Text = decoded;
            }
            if (iFolder == DisFolderId)
            {
                childNode.Selectable    = false;
                childNode.CssClass      = "TreeNodeGray";
                childNode.HoverCssClass = "TreeNodeGray";
            }
            if (fl)
            {
                childNode.ClientSideCommand = "_dtSV('" + decoded + "','" + ContainerKey + "','" + folder + "');";
            }
            else
            {
                childNode.Selectable    = false;
                childNode.CssClass      = "TreeNodeGray";
                childNode.HoverCssClass = "TreeNodeGray";
            }

            if (Mediachase.IBN.Business.Common.IsPop3Folder(iFolder))
            {
                //childNode.ImageUrl="../layouts/images/folder2.gif";
                childNode.ImageUrl = "../layouts/images/folder_mailbox.gif";
            }


            if (ContainerKey == txtContainerKey.Value && iFolder.ToString() == txtFolderId.Value)
            {
                TreeView1.SelectedNode = childNode;
            }

            foreach (DirectoryInfo di in _di)
            {
                ProcessFolderNode(childNode, ContainerKey, di.Id, RootName, true);
            }

            if (!(isRoot && !RenderRoot))
            {
                CurTreeNode.Nodes.Add(childNode);
            }
        }
Esempio n. 21
0
        protected void grdDetails_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                foreach (Control c in e.Item.Controls[4].Controls)
                {
                    if (c is LinkButton)
                    {
                        LinkButton lb = (LinkButton)c;
                        switch (lb.CommandArgument)
                        {
                        case "sortName":
                            lb.Text = LocRM.GetString("tName");
                            break;

                        case "ContainerKey":
                            lb.Text = LocRM.GetString("tLocation");
                            break;

                        case "sortModifier":
                            lb.Text = LocRM.GetString("UpdatedBy");
                            break;

                        case "sortModified":
                            lb.Text = LocRM.GetString("UpdatedDate");
                            break;

                        case "sortSize":
                            lb.Text = LocRM.GetString("Size");
                            break;

                        default:
                            break;
                        }
                        if (lb.CommandArgument == _pc["fl_Sort_" + _containerKey].ToString())
                        {
                            lb.Text += String.Format("&nbsp;<img border='0' align='absmiddle' width='9px' height='5px' src='{0}'/>",
                                                     ResolveUrl("~/layouts/images/upbtnF.jpg"));
                        }
                        else if (lb.CommandArgument + " DESC" == _pc["fl_Sort_" + _containerKey].ToString())
                        {
                            lb.Text += String.Format("&nbsp;<img border='0' align='absmiddle' width='9px' height='5px' src='{0}'/>",
                                                     ResolveUrl("~/layouts/images/downbtnF.jpg"));
                        }
                    }
                }
            }


            if (Top > 0)
            {
                return;
            }
            else
            {
                DataGridItem item = e.Item;
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.EditItem)
                {
                    string           containerKey1 = item.Cells[1].Text;
                    BaseIbnContainer bic           = BaseIbnContainer.Create("FileLibrary", containerKey1);
                    Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");
                    DirectoryInfo di         = fs.GetDirectory(int.Parse(item.Cells[2].Text));
                    string        parentName = "";
                    string        parentLink = "";
                    Util.CommonHelper.GetParentContainer(containerKey1, di, out parentName, out parentLink);
                    Label lbl = (Label)item.Cells[4].FindControl("lblLocation");
                    if (lbl != null)
                    {
                        lbl.Text = parentLink;
                    }
                }
            }
        }
Esempio n. 22
0
 private void GetCurrentFolder()
 {
     _bic = BaseIbnContainer.Create(_containerName, _containerKey);
     _fs = (FileStorage)_bic.LoadControl("FileStorage");
     if (Request["FolderId"] != null && Request["FolderId"] != String.Empty)
         _folderId = int.Parse(Request["FolderId"]);
     else if (_folderId < 0 && _pc["fs_FolderId_" + _containerKey] != null)
     {
         int iFolder = int.Parse(_pc["fs_FolderId_" + _containerKey]);
         DirectoryInfo di = _fs.GetDirectory(iFolder);
         if (di != null)
             _folderId = iFolder;
         else
             _folderId = _fs.Root.Id;
     }
     else
         _folderId = _fs.Root.Id;
     _rootId = _fs.Root.Id;
     _pc["fs_FolderId_" + _containerKey] = _folderId.ToString();
 }
Esempio n. 23
0
        void BindDefaultValues()
        {
            txtFolder.Text = "";

            int iFolderId = -1;

            try{ iFolderId = int.Parse(txtFolderId.Value); }
            catch { return; }

            string ContainerKey = txtContainerKey.Value;

            //if(ContainerKey == "")
            //	return;

            bic = BaseIbnContainer.Create("FileLibrary", ContainerKey);
            fs  = (FileStorage)bic.LoadControl("FileStorage");

            string name = "unknown";

            if (iFolderId == fs.Root.Id)
            {
                if (ContainerKey.LastIndexOf("_") > 0)
                {
                    int ProjectId = -1;
                    try
                    {
                        ProjectId = int.Parse(ContainerKey.Substring(ContainerKey.LastIndexOf("_") + 1));
                    }
                    catch {}
                    if (ProjectId != -1)
                    {
                        using (IDataReader reader = Project.GetProject(ProjectId))
                        {
                            reader.Read();
                            if (reader["Title"] != null)
                            {
                                name = reader["Title"].ToString();
                            }
                        }
                    }
                }
                else
                {
                    name = LocRM.GetString("tRoot");
                }
            }
            else
            {
                DirectoryInfo di = fs.GetDirectory(iFolderId);
                if (di != null)
                {
                    name = di.Name;
                }
                else
                {
                    ContainerKey = "";
                    FolderId     = -1;
                    return;
                }
            }
            //	name = fs.GetDirectory(iFolderId).Name;

            System.IO.StringWriter writer = new System.IO.StringWriter();
            Server.HtmlDecode(name, writer);
            string decoded = writer.ToString();

            txtFolder.Text = decoded;
        }
Esempio n. 24
0
        private void BindDefaultValues()
        {
            string fromEmail = Security.CurrentUser.Email;

            if (IncidentId > 0)
            {
                fromEmail = EMailRouterOutputMessage.FindEMailRouterPublicEmail(IncidentId);
            }
            txtFrom.Text = String.Format(CultureInfo.InvariantCulture,
                                         "{1}&nbsp;&lt;{0}&gt;", fromEmail, Security.CurrentUser.DisplayName);
            lblCCTitle.Text = "";
            lblToTitle.Text = LocRM.GetString("tTo") + ":";
            if (IncidentId > 0)
            {
                NameValueCollection _params = new NameValueCollection();
                _params["IssueId"] = IncidentId.ToString();
                string[] erList = EMailClient.GetDefaultRecipientList(EMailClient.IssueMode, _params);
                for (int i = 0; i < erList.Length; i++)
                {
                    string sName = GetNameByEMail(erList[i]);
                    if (sName != "")
                    {
                        lblCC.Text += String.Format(CultureInfo.InvariantCulture, "{0} &lt;{1}&gt;; ", sName, erList[i]);
                    }
                    else
                    {
                        lblCC.Text += erList[i] + "; ";
                    }
                }

                string sValue = EMailMessage.GetOutgoingEmailFormatBodyPreview(IncidentId).Replace("[=Text=]", "");
                if (NodeId > 0)
                {
                    EMailMessageInfo mi = EMailMessageInfo.Load(NodeId);
                    sValue += "<br/>" + "<blockquote style='border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;' dir='ltr'>" + mi.HtmlBody + "</blockquote>";
                }
                fckEditor.Text = sValue;

                using (IDataReader reader = Incident.GetIncident(IncidentId))
                {
                    if (reader.Read())
                    {
                        txtSubject.Text = string.Format(CultureInfo.InvariantCulture
                                                        , "RE: [{0}] {1}"
                                                        , (reader["Identifier"] != DBNull.Value) ?
                                                        reader["Identifier"].ToString()
                                                                : TicketUidUtil.Create(IncidentBox.Load((int)reader["IncidentBoxId"]).IdentifierMask, IncidentId)
                                                        , HttpUtility.HtmlDecode(reader["Title"].ToString())
                                                        );
                    }
                }
            }
            if (FileIds != "")
            {
                string sFiles = FileIds.Trim();
                if (sFiles.EndsWith(","))
                {
                    sFiles = sFiles.Substring(0, sFiles.Length - 1);
                }
                string[] masFiles = sFiles.Split(',');
                if (masFiles.Length > 0)
                {
                    string _containerName   = "FileLibrary";
                    string _containerKey    = "EMailAttach";
                    CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
                    CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");

                    CS.BaseIbnContainer bic2 = CS.BaseIbnContainer.Create(FilesContainerName, FilesContainerKey);
                    CS.FileStorage      fs2  = (CS.FileStorage)bic.LoadControl("FileStorage");

                    CS.DirectoryInfo di = fs.GetDirectory(fs.Root.Id, _guid, true);
                    for (int i = 0; i < masFiles.Length; i++)
                    {
                        fs2.CopyFile(int.Parse(masFiles[i]), di.Id);
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "_getFiles",
                                                            "window.setTimeout('updateAttachments()', 500);", true);
                }
            }
            if (ErrorId != "")
            {
                string support_email = GlobalResourceManager.Strings["SupportEmail"];
                //if (Security.CurrentUser != null && Security.CurrentUser.Culture.ToLower().IndexOf("ru") >= 0)
                //    support_email = "*****@*****.**";
                txtTo.Text = support_email + "; ";

                txtSubject.Text = String.Format("{0} {1} {2} Error Report", IbnConst.CompanyName, IbnConst.ProductFamilyShort, IbnConst.VersionMajorDotMinor);

                string prefix   = Request.Url.Host.Replace(".", "_");
                string FilePath = Server.MapPath("../Admin/Log/Error/" + prefix + "_" + ErrorId + ".html");
                string sTemp    = String.Empty;
                using (StreamReader sr = File.OpenText(FilePath))
                {
                    sTemp += sr.ReadToEnd();
                }

                Match match = Regex.Match(sTemp, @"<body[^>]*>(?<HtmlBody>[\s\S]*?)</body>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);
                if (match.Success)
                {
                    string body       = match.Groups["HtmlBody"].Value;
                    Match  matchStyle = Regex.Match(sTemp, @"<style[^>]*>(?<HtmlStyle>[\s\S]*?)</style>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);
                    if (matchStyle.Success)
                    {
                        body += matchStyle.Value;
                    }
                    sTemp = body;
                }
                fckEditor.Text = sTemp;
            }
            if (lblCC.Text != "")
            {
                lblCCTitle.Text = LocRM.GetString("tTo") + ":";
                lblToTitle.Text = LocRM.GetString("tCc") + ":";
            }
        }
Esempio n. 25
0
 private void GetCurrentFolder()
 {
     _fs = Mediachase.IBN.Business.ControlSystem.FileStorage.Create(_containerName, _containerKey);
     if (!IsPostBack && Request["FolderId"] != null && Request["FolderId"] != String.Empty)
         _folderId = int.Parse(Request["FolderId"]);
     else if (_folderId < 0 && _pc["fs_FolderId_" + _containerKey] != null)
     {
         int iFolder = int.Parse(_pc["fs_FolderId_" + _containerKey]);
         DirectoryInfo di = _fs.GetDirectory(iFolder);
         if (di != null)
             _folderId = iFolder;
         else
             _folderId = _fs.Root.Id;
     }
     else
         _folderId = _fs.Root.Id;
     _rootId = _fs.Root.Id;
     _pc["fs_FolderId_" + _containerKey] = _folderId.ToString();
 }
Esempio n. 26
0
        private void BindNode(string nodeId, ArrayList parentList)
        {
            List <JsonTreeNode> nodes = new List <JsonTreeNode>();
            string containerName      = Request["ContainerName"];
            string containerKey       = Request["ContainerKey"];

            Mediachase.IBN.Business.ControlSystem.FileStorage fs = Mediachase.IBN.Business.ControlSystem.FileStorage.Create(containerName, containerKey);
            DirectoryInfo diCur = fs.GetDirectory(int.Parse(nodeId));

            if (!fs.CanUserRead(diCur))
            {
                WriteArray(String.Empty);
            }
            else
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("Id", typeof(string)));
                dt.Columns.Add(new DataColumn("Name", typeof(string)));
                dt.Columns.Add(new DataColumn("Count", typeof(int)));
                DataRow         dr;
                DirectoryInfo[] dMas = fs.GetDirectories(int.Parse(nodeId));
                foreach (DirectoryInfo di in dMas)
                {
                    if (!fs.CanUserRead(di))
                    {
                        continue;
                    }
                    dr         = dt.NewRow();
                    dr["Id"]   = di.Id.ToString();
                    dr["Name"] = di.Name;

                    int             count = 0;
                    DirectoryInfo[] check = fs.GetDirectories(di.Id);
                    foreach (DirectoryInfo dIn in check)
                    {
                        if (fs.CanUserRead(dIn))
                        {
                            count++;
                        }
                    }
                    dr["Count"] = count;

                    dt.Rows.Add(dr);
                }
                DataView dv = dt.DefaultView;
                dv.Sort = "Name";
                foreach (DataRowView drv in dv)
                {
                    JsonTreeNode node = new JsonTreeNode();
                    node.leaf    = ((int)drv["Count"] == 0);
                    node.cls     = "nodeCls";
                    node.iconCls = "iconStdCls";
                    node.icon    = ResolveClientUrl("~/layouts/images/folder.gif");
                    node.text    = drv["Name"].ToString();
                    node.id      = Guid.NewGuid().ToString("N");
                    node.itemid  = drv["Id"].ToString();

                    if (parentList.Contains(int.Parse(drv["Id"].ToString())))
                    {
                        node.expanded = true;
                        BindRecursive(node, parentList);
                    }
                    else
                    {
                        node.expanded = false;
                    }

                    Dictionary <string, string> param = new Dictionary <string, string>();
                    param.Add("ContainerKey", containerKey);
                    param.Add("FolderId", drv["Id"].ToString());
                    string cmd = CommandManager.GetCommandString("FL_ChangeFolderTree", param);
                    cmd       = cmd.Replace("\"", "&quot;");
                    node.href = String.Format("javascript:{0}", cmd);

                    //node.href = ResolveClientUrl("~/Apps/FileLibrary/Pages/FileStorage.aspx?FolderId=" + di.Id);
                    //node.hrefTarget = "right";
                    nodes.Add(node);
                }
                WriteArray(nodes);
            }
        }
Esempio n. 27
0
 private void GetCurrentFolder()
 {
     ContainerKey = ViewState["ContainerKey"].ToString();
     bic = CS.BaseIbnContainer.Create(ContainerName, ContainerKey);
     fs = (CS.FileStorage)bic.LoadControl("FileStorage");
     if (!Page.IsPostBack && Request["FolderId"] != null && Request["FolderId"] != String.Empty)
         FolderId = int.Parse(Request["FolderId"]);
     else if (FolderId < 0 && pc["fs_FolderId_" + ContainerKey] != null)
     {
         int iFolder = int.Parse(pc["fs_FolderId_" + ContainerKey]);
         CS.DirectoryInfo di = fs.GetDirectory(iFolder);
         if (di != null)
             FolderId = iFolder;
         else
             FolderId = fs.Root.Id;
     }
     else
         FolderId = fs.Root.Id;
     RootId = fs.Root.Id;
     pc["fs_FolderId_" + ContainerKey] = FolderId.ToString();
 }
Esempio n. 28
0
        void BindDefaultValues()
        {
            txtFolder.Text = "";

            int iFolderId = -1;
            try{iFolderId = int.Parse(txtFolderId.Value);}
            catch{return;}

            string ContainerKey = txtContainerKey.Value;
            //if(ContainerKey == "")
            //	return;

            bic = BaseIbnContainer.Create("FileLibrary", ContainerKey);
            fs = (FileStorage)bic.LoadControl("FileStorage");

            string name = "unknown";
            if(iFolderId==fs.Root.Id)
            {
                if(ContainerKey.LastIndexOf("_") > 0)
                {
                    int ProjectId = -1;
                    try
                    {
                        ProjectId = int.Parse(ContainerKey.Substring(ContainerKey.LastIndexOf("_")+1));
                    }
                    catch{}
                    if(ProjectId != -1)
                    {
                        using(IDataReader reader = Project.GetProject(ProjectId))
                        {
                            reader.Read();
                            if(reader["Title"] != null)
                                name = reader["Title"].ToString();
                        }
                    }
                }
                else
                    name = LocRM.GetString("tRoot");
            }
            else
            {
                DirectoryInfo di = fs.GetDirectory(iFolderId);
                if(di != null)
                    name = di.Name;
                else
                {
                    ContainerKey = "";
                    FolderId = -1;
                    return;
                }
            }
            //	name = fs.GetDirectory(iFolderId).Name;

            System.IO.StringWriter writer = new System.IO.StringWriter();
            Server.HtmlDecode(name, writer);
            string decoded = writer.ToString();
            txtFolder.Text = decoded;
        }