Ejemplo n.º 1
0
        public bool IsEnable(object Sender, object Element)
        {
            if (Mediachase.IBN.Business.Security.CurrentUser.IsExternal)
            {
                return(false);
            }

            if (Element is CommandParameters)
            {
                CommandParameters cp  = (CommandParameters)Element;
                string            sid = cp.CommandArguments["primaryKeyId"];

                string[] elem = sid.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                //type, id, _containerName, _containerKey
                if (elem.Length != 4)
                {
                    return(false);
                }

                int id = -1;
                int.TryParse(elem[0], out id);
                if (id == 1)
                {
                    FileStorage   fs = FileStorage.Create(elem[2], elem[3]);
                    DirectoryInfo di = fs.GetDirectory(int.Parse(elem[1]));
                    if (fs.CanUserWrite(di.Parent))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;

                int destFolderId = int.Parse(cp.CommandArguments["DestFolderId"]);

                if (cp.CommandArguments.ContainsKey("GridId"))
                {
                    string[] checkedElems = MCGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                    foreach (string elem in checkedElems)
                    {
                        string[]    elemMas = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                        int         id      = Convert.ToInt32(elemMas[1], CultureInfo.InvariantCulture);
                        FileStorage fs      = FileStorage.Create(elemMas[2], elemMas[3]);
                        if (elemMas[0] == "1")
                        {
                            if (id != destFolderId)
                            {
                                fs.MoveDirectory(id, destFolderId);
                            }
                        }
                        else if (elemMas[0] == "2")
                        {
                            fs.MoveFile(id, destFolderId);
                        }
                    }
                }

                CHelper.RequireBindGrid();
            }
        }
Ejemplo n.º 3
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp  = (CommandParameters)Element;
                string            sid = cp.CommandArguments["primaryKeyId"];

                string[] elem = sid.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                //type, id, _containerName, _containerKey
                if (elem.Length != 4)
                {
                    return;
                }

                int id = -1;
                int.TryParse(elem[0], out id);

                FileStorage fs = FileStorage.Create(elem[2], elem[3]);
                if (id == 1)
                {
                    DirectoryInfo di = fs.GetDirectory(int.Parse(elem[1]));
                    fs.DeleteFolder(di);
                }
                if (id == 2)
                {
                    FileInfo fi = fs.GetFile(int.Parse(elem[1]));
                    fs.DeleteFile(fi);
                }

                CHelper.RequireBindGrid();
            }
        }
Ejemplo n.º 4
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;

                string[] checkedElems = MCGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                foreach (string elem in checkedElems)
                {
                    string[] elemMas = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                    //type, id, _containerName, _containerKey
                    if (elemMas.Length != 4)
                    {
                        continue;
                    }

                    int         id = Convert.ToInt32(elemMas[1], CultureInfo.InvariantCulture);
                    FileStorage fs = FileStorage.Create(elemMas[2], elemMas[3]);
                    if (elemMas[0] == "1")
                    {
                        fs.DeleteFolder(id);
                    }
                    else if (elemMas[0] == "2")
                    {
                        fs.DeleteFile(id);
                    }
                }

                CHelper.RequireBindGrid();
            }
        }
Ejemplo n.º 5
0
        private void BindData()
        {
            string containerKey = string.Empty;

            // WF Name
            WorkFlowLabel.Text = info.Name;

            // WF State
            if (info.State == BusinessProcessState.Active)
            {
                StateLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "WFStateActive").ToString();
            }
            else if (info.State == BusinessProcessState.Pending)
            {
                StateLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "WFStatePending").ToString();
            }
            else if (info.State == BusinessProcessState.Suspended)
            {
                StateLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "WFStateSuspended").ToString();
            }
            else
            {
                StateLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "WFStateCompleted").ToString();
            }

            // Owner Type
            if (String.Compare(OwnerName, WorkflowInstanceEntity.FieldOwnerDocumentId, true) == 0)
            {
                OwnerLiteral.Text = GetGlobalResourceObject("IbnFramework.Admin", "ObjectType_Document").ToString();
                OwnerLink.Text    = CommonHelper.GetObjectTitle((int)Mediachase.IBN.Business.ObjectTypes.Document, OwnerId);

                containerKey = String.Concat("DocumentId_", OwnerId.ToString());
            }
            OwnerLink.NavigateUrl = CHelper.GetLinkObjectViewByOwnerName(OwnerName, OwnerId.ToString());

            // Current Date
            CurrentDateLiteral.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "CurrentDate").ToString();
            DateTime userDate = Mediachase.IBN.Business.User.GetLocalDate(DateTime.UtcNow);

            CurrentDateLabel.Text = String.Concat(userDate.ToLongDateString(), " ", userDate.ToShortTimeString());

            // Files
            string      containerName = "FileLibrary";
            string      filesText     = string.Empty;
            FileStorage fs            = FileStorage.Create(containerName, containerKey);

            FileInfo[] files = fs.GetFiles();
            if (files != null && files.Length > 0)
            {
                foreach (FileInfo file in files)
                {
                    if (!String.IsNullOrEmpty(filesText))
                    {
                        filesText += ", ";
                    }
                    filesText += file.Name;
                }
            }
            FilesLabel.Text = filesText;
        }
Ejemplo n.º 6
0
        protected void ApproveButton_ServerClick(object sender, EventArgs e)
        {
            AssignmentEntity assignment = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, AssignmentId.Value);

            assignment.ExecutionResult = (int)AssignmentExecutionResult.Accepted;

            // files
            string      filesText = string.Empty;
            FileStorage fs        = FileStorage.Create(ContainerName, ContainerKey);

            FileInfo[] files = fs.GetFiles();
            if (files != null && files.Length > 0)
            {
                foreach (FileInfo file in files)
                {
                    if (!String.IsNullOrEmpty(filesText))
                    {
                        filesText += ", ";
                    }
                    filesText += file.Name;
                }

                filesText = String.Concat("<i>Файлы: ", filesText, "</i>");
            }

            if (!String.IsNullOrEmpty(filesText))
            {
                assignment.Comment = String.Format(CultureInfo.InvariantCulture,
                                                   "{0}\r\n{1}",
                                                   filesText, CommentText.Text);
            }
            else
            {
                assignment.Comment = CommentText.Text;
            }

            BusinessManager.Execute(new CloseAssignmentRequest(assignment));

            // Notify parent control
            ItemCommand(sender, e);
        }
Ejemplo n.º 7
0
        public bool IsEnable(object Sender, object Element)
        {
            if (Mediachase.IBN.Business.Security.CurrentUser.IsExternal)
            {
                return(false);
            }

            if (Element is CommandParameters)
            {
                CommandParameters cp            = (CommandParameters)Element;
                string            containerKey  = CHelper.GetFromContext(Mediachase.Ibn.Web.UI.FileLibrary.Modules.FileStorage._containerKeyKey).ToString();
                string            containerName = CHelper.GetFromContext(Mediachase.Ibn.Web.UI.FileLibrary.Modules.FileStorage._containerNameKey).ToString();

                UserLightPropertyCollection _pc = Mediachase.IBN.Business.Security.CurrentUser.Properties;
                int         folderId            = int.Parse(_pc["fs_FolderId_" + containerKey]);
                FileStorage fs = FileStorage.Create(containerName, containerKey);
                if (fs.CanUserWrite(folderId))
                {
                    return(true);
                }
            }
            return(false);
        }