Пример #1
0
        //private OrgAccess[] _orgAccess = null;
        public static Role GetRole(MRole role)
        {
            Role r = new Role();

            r.IsAccessAllOrgs     = role.IsAccessAllOrgs();
            r.IsAdministrator     = role.IsAdministrator();
            r.AD_Client_ID        = role.GetAD_Client_ID();
            r.AD_User_ID          = role.GetAD_User_ID();
            r.UserLevel           = role.GetUserLevel();
            r.IsCanExport         = role.IsCanExport();
            r.IsCanReport         = role.IsCanReport();
            r.IsUseBPRestrictions = role.IsUseBPRestrictions();
            r.IsPersonalAccess    = role.IsPersonalAccess();
            r.Name             = role.GetName();
            r.IsShowPreference = role.IsShowPreference();
            r.PreferenceType   = role.GetPreferenceType();

            r.IsDisplayClient        = role.IsDisplayClient();
            r.IsDisplayOrg           = role.IsDisplayOrg();
            r.IsPersonalLock         = role.IsPersonalLock();
            r.IsOverwritePriceLimit  = role.IsOverwritePriceLimit();
            r.IsOverrideReturnPolicy = role.IsOverrideReturnPolicy();

            r.tableAccessLevel = role.GetTableAccessLevel();
            r.tableName        = role.GetTableNames();
            r.orgAccess        = role.GetOrgAccess();
            r.windowAccess     = role.GetWindowAccess();
            r.formAccess       = role.GetFormAccess();
            r.processAccess    = role.GetProcessAccess();

            r.tableAccess           = TableAccess.Get(role.GetTableAccess());
            r.columnAccess          = ColumnAccess.Get(role.GetColumnAccess());
            r.recordAccess          = RecordAccess.Get(role.GetRecordAccess());
            r.recordDependentAccess = RecordAccess.Get(role.GetRecordDependentAccess());

            r.MaxQueryRecords = role.GetMaxQueryRecords();
            r.IsShowAcct      = role.IsShowAcct();
            r.IsDisableMenu   = role.IsDisableMenu();
            r.HomePage        = role.GetHomePage_ID();

            /* Prepare Pre Setting of Table*/

            r.tableData = TableData.Get();


            return(r);
        }
Пример #2
0
        /// <summary>
        /// Set AD_Process_ID.
        /// Check Role if process can be performed
        /// </summary>
        /// <param name="AD_Process_ID">process</param>
        public new void SetAD_Process_ID(int AD_Process_ID)
        {
            if (AD_Process_ID <= 0)
            {
                return;
            }
            Console.WriteLine(AD_Process_ID.ToString());
            int AD_Role_ID = GetCtx().GetAD_Role_ID();

            if (AD_Role_ID != 0)
            {
                MRole role   = MRole.Get(GetCtx(), AD_Role_ID);
                bool? access = role.GetProcessAccess(AD_Process_ID, AD_Role_ID);
                if (access == null)
                {
                    throw new Exception("Cannot access Process " + AD_Process_ID
                                        + " with Role: " + role.Get_Value("Name"));
                }
            }
            base.SetAD_Process_ID(AD_Process_ID);
        }
        /// <summary>
        /// Complete the Payment Record
        /// </summary>
        /// <param name="ctx">Context</param>
        /// <param name="Record_ID">C_Payment_ID</param>
        /// <param name="Process_ID">AD_Process_ID</param>
        /// <param name="DocAction">Documnet Action</param>
        /// <returns>return message</returns>
        public string CompletePayment(Ctx ctx, int Record_ID, int Process_ID, string DocAction)
        {
            string result = "";
            MRole  role   = MRole.Get(ctx, ctx.GetAD_Role_ID());

            if (Util.GetValueOfBool(role.GetProcessAccess(Process_ID)))
            {
                DB.ExecuteQuery("UPDATE C_Payment SET DocAction = '" + DocAction + "' WHERE C_Payment_ID = " + Record_ID);

                MProcess   proc = new MProcess(ctx, Process_ID, null);
                MPInstance pin  = new MPInstance(proc, Record_ID);
                if (!pin.Save())
                {
                    ValueNamePair vnp      = VLogger.RetrieveError();
                    string        errorMsg = "";
                    if (vnp != null)
                    {
                        errorMsg = vnp.GetName();
                        if (errorMsg == "")
                        {
                            errorMsg = vnp.GetValue();
                        }
                    }
                    if (errorMsg == "")
                    {
                        result = Msg.GetMsg(ctx, "DocNotCompleted");
                    }

                    return(result);
                }

                MPInstancePara para = new MPInstancePara(pin, 20);
                para.setParameter("DocAction", DocAction);
                if (!para.Save())
                {
                    //String msg = "No DocAction Parameter added"; // not translated
                }
                ProcessInfo pi = new ProcessInfo("WF", Process_ID);
                pi.SetAD_User_ID(ctx.GetAD_User_ID());
                pi.SetAD_Client_ID(ctx.GetAD_Client_ID());
                pi.SetAD_PInstance_ID(pin.GetAD_PInstance_ID());
                pi.SetRecord_ID(Record_ID);
                pi.SetTable_ID(335); //AD_Table_ID=335 for C_Payment

                ProcessCtl worker = new ProcessCtl(ctx, null, pi, null);
                worker.Run();

                if (pi.IsError())
                {
                    ValueNamePair vnp      = VLogger.RetrieveError();
                    string        errorMsg = "";
                    if (vnp != null)
                    {
                        errorMsg = vnp.GetName();
                        if (errorMsg == "")
                        {
                            errorMsg = vnp.GetValue();
                        }
                    }

                    if (errorMsg == "")
                    {
                        errorMsg = pi.GetSummary();
                    }

                    if (errorMsg == "")
                    {
                        errorMsg = Msg.GetMsg(ctx, "DocNotCompleted");
                    }
                    result = errorMsg;
                    return(result);
                }
                else
                {
                    result = "";
                }
            }
            else
            {
                result = Msg.GetMsg(ctx, "NoAccess");
                return(result);
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// set node properties
        /// </summary>
        /// <param name="Node_ID">node key id</param>
        /// <param name="Parent_ID">parent node id</param>
        /// <param name="seqNo">seq no</param>
        /// <param name="onBar">node in favorite tree</param>
        /// <returns>VTreeNode </returns>

        private VTreeNode GetNodeDetail(int Node_ID, int Parent_ID, int seqNo, bool onBar)
        {
            int AD_Window_ID    = 0;
            int AD_Process_ID   = 0;
            int AD_Form_ID      = 0;
            int AD_Workflow_ID  = 0;
            int AD_Task_ID      = 0;
            int AD_Workbench_ID = 0;

            VTreeNode retValue = null;

            string strColumnName = "";

            if (treeType == TreeType.MM)
            {
                strColumnName = "Ad_Menu_Id";
            }
            else
            {
                strColumnName = "Ad_ORG_ID";
            }

            // Serch For Node details
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int node1 = Utility.Util.GetValueOfInt(dt.Rows[i][0].ToString());
                if (Node_ID != node1)   //	search for correct one
                {
                    continue;
                }
                DataRow dr = dt.Rows[i];

                int node  = Utility.Util.GetValueOfInt(dr[0].ToString());
                int index = 1;

                string name        = dr[index++].ToString();
                string description = dr[index++].ToString();
                bool   isSummary   = "Y".Equals(dr[index++].ToString());
                string actionColor = "";
                //	Menu only
                //if (getTreeType().equals(TREETYPE_Menu) && !isSummary)
                if (!isSummary)
                {
                    bool?blnAccess = null;
                    if (treeType == TreeType.MM)
                    {
                        actionColor  = dr[index++].ToString();
                        AD_Window_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Process_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Form_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Workflow_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Task_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        AD_Workbench_ID = (dr[index].ToString().Trim() == "") ? 0 : Utility.Util.GetValueOfInt(dr[index].ToString());
                        index++;
                        MRole role = MRole.GetDefault(ctx);
                        if (VTreeNode.ACTION_WINDOW.Equals(actionColor))
                        {
                            blnAccess = role.GetWindowAccess(AD_Window_ID);
                        }
                        else if (VTreeNode.ACTION_PROCESS.Equals(actionColor) ||
                                 VTreeNode.ACTION_REPORT.Equals(actionColor))
                        {
                            blnAccess = role.GetProcessAccess(AD_Process_ID);
                        }
                        else if (VTreeNode.ACTION_FORM.Equals(actionColor))
                        {
                            blnAccess = role.GetFormAccess(AD_Form_ID);
                        }
                        else if (VTreeNode.ACTION_WORKFLOW.Equals(actionColor))
                        {
                            blnAccess = role.GetWorkflowAccess(AD_Workflow_ID);
                        }
                        else if (VTreeNode.ACTION_TASK.Equals(actionColor))
                        {
                            blnAccess = role.GetTaskAccess(AD_Task_ID);
                        }
                    }
                    if (blnAccess != null || _editable)         //	rw or ro for Role
                    {
                        retValue = new VTreeNode(Node_ID, seqNo,
                                                 name, description, Parent_ID, isSummary,
                                                 actionColor, onBar); //	menu has no color
                    }
                }
                else
                {
                    retValue = new VTreeNode(Node_ID, seqNo,
                                             name, description, Parent_ID, isSummary,
                                             actionColor, onBar);
                }
                break;
            }

            if (retValue != null && treeType == TreeType.MM)
            {
                // set VTreeNode ID's
                retValue.AD_Window_ID    = AD_Window_ID;
                retValue.AD_Process_ID   = AD_Process_ID;
                retValue.AD_Form_ID      = AD_Form_ID;
                retValue.AD_Workflow_ID  = AD_Workflow_ID;
                retValue.AD_Task_ID      = AD_Task_ID;
                retValue.AD_Workbench_ID = AD_Workbench_ID;
            }
            return(retValue);
        }