コード例 #1
0
        private void JQDLGeditRoleOwner
            (System.Collections.Specialized.NameValueCollection pars, HttpResponse httpResponse)
        {
            IBusRoleOwner engine = new IBusRoleOwner(CONNdedicated);

            int idBusRoleBeingEdited = int.Parse(pars["JQDLGbp_id"]);

            string EID = pars["eid"].Trim();

            string strIdCurEdit = pars["idcuredit"];
            int    idCurEdit;

            if (strIdCurEdit == "ADD")
            {
                idCurEdit = engine.NewBusRoleOwner
                                (EID, pars["geo"], pars["rank"], idBusRoleBeingEdited);
            }
            else
            {
                idCurEdit = int.Parse(strIdCurEdit);
            }

            if (pars["deleteme"] == "true")
            {
                // DELETION OF THIS ROW IS REQUESTED.
                engine.DeleteBusRoleOwner(idCurEdit);
            }
            else
            {
                engine.SetBusRoleOwner
                    (idCurEdit,
                    EID, pars["geo"], pars["rank"], idBusRoleBeingEdited);
            }


            CreateOrUpdateUserName(EID,
                                   pars["NAMEsur"], pars["NAMEfirst"], true);
        }
コード例 #2
0
        ONCLICK_BulkUploadNewBusRoles(object sender, EventArgs e)
        {
            IBusRoleOwner ENGINEbrown = new IBusRoleOwner(HELPERS.NewOdbcConn());
            IBusRole      ENGINEbr    = new IBusRole(HELPERS.NewOdbcConn());


            if (this.FileUpload_AddRoles.HasFile)
            {
                string pathTempFolder = System.IO.Path.GetTempPath();
                string pathTempFile   = System.IO.Path.GetTempFileName();
                FileUpload_AddRoles.SaveAs(pathTempFile);
                DataTable dt = HELPERS.LoadCsv(pathTempFolder,
                                               System.IO.Path.GetFileName(pathTempFile));
                if (dt != null)
                {
                    if (dt.Columns.Count < 2)
                    {
                        throw new Exception("The uploaded CSV file must have at least the name and description columns.  (It can optionally also have the two approver/owner columns.)");
                    }


                    Queue RETmsgs = new Queue();

                    IEnumerator <System.Data.DataRow> x =
                        (IEnumerator <System.Data.DataRow>)dt.Rows.GetEnumerator();

                    int recordseq = 0;
                    int okCount   = 0;
                    while (x.MoveNext())
                    {
                        recordseq++;

                        string rolename        = x.Current[0].ToString().Trim();
                        string description     = x.Current[1].ToString().Trim();
                        string roletype        = x.Current[2].ToString().Trim();
                        string primaryApprover = x.Current[3].ToString().Trim().ToUpper();
                        string primaryOwner    = x.Current[4].ToString().Trim().ToUpper();


                        int IDrole = -1;
                        try
                        {
                            IDrole = HELPERS.FindBusRoleByName(rolename);
                        }
                        catch (Exception)
                        {
                            /* The exception is what we WANT!  If this does not throw an exception, this row must be ignored! */
                        }


                        bool doRoleCreation = true;

                        if (IDrole >= 0)
                        {
                            // This role name is already in use somewhere in the system (not nec this subpr).
                            RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": Role already exists, so the only action will be updating of owner/approver info.  Role name: " + rolename);
                            doRoleCreation = false;
                        }

                        int newID = (doRoleCreation ? -1 : IDrole);
                        if (doRoleCreation)
                        {
                            switch (roletype)
                            {
                            case "A":
                                break;

                            case "F":
                                break;

                            case "E":
                                break;

                            default:
                                RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": line ignored due to unknown role-type code: " + roletype);
                                continue;
                            }

                            try
                            {
                                newID = ENGINEbr.NewBusRole(rolename, description, session.idSubprocess);
                                ENGINEbr.SetBusRole(newID, roletype);
                                okCount++;
                            }
                            catch (Exception ee)
                            {
                                RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": " + ee.Message);
                            }
                        }

                        if (newID >= 0)
                        {
                            // New code added Thanksgiving 2012: supporting approver/owner
                            if (primaryOwner.Length > 2)
                            {
                                string __eid        = primaryOwner;
                                string __rank       = "OWNprim";
                                string __rankPretty = "Primary Owner";
                                try
                                {
                                    HELPERS.FindUser(HELPERS.NewOdbcConn(), __eid, __eid, false);
                                    returnListBusRoleOwnerByBusRole[] theList = ENGINEbrown.ListBusRoleOwnerByBusRole(null, newID);
                                    if (theList.Length < 1)
                                    {
                                        ENGINEbrown.NewBusRoleOwner(__eid, "", __rank, newID);
                                    }
                                    else
                                    {
                                        foreach (returnListBusRoleOwnerByBusRole roleowner in theList)
                                        {
                                            if (roleowner.Rank == __rank)
                                            {
                                                ENGINEbrown.DeleteBusRoleOwner(roleowner.ID);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ee)
                                {
                                    RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": ignoring setting of " + __rankPretty + " due to unknown employee ID: " + __eid);
                                }
                            }


                            if (primaryApprover.Length > 2)
                            {
                                string __eid        = primaryApprover;
                                string __rank       = "appr";
                                string __rankPretty = "Primary Approver";
                                try
                                {
                                    HELPERS.FindUser(HELPERS.NewOdbcConn(), __eid, __eid, false);
                                    returnListBusRoleOwnerByBusRole[] theList = ENGINEbrown.ListBusRoleOwnerByBusRole(null, newID);
                                    if (theList.Length < 1)
                                    {
                                        ENGINEbrown.NewBusRoleOwner(__eid, "", __rank, newID);
                                    }
                                    else
                                    {
                                        foreach (returnListBusRoleOwnerByBusRole roleowner in theList)
                                        {
                                            if (roleowner.Rank == __rank)
                                            {
                                                ENGINEbrown.DeleteBusRoleOwner(roleowner.ID);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ee)
                                {
                                    RETmsgs.Enqueue("REC#" + recordseq.ToString() + ": ignoring setting of " + __rankPretty + " due to unknown employee ID: " + __eid);
                                }
                            }
                        }
                    }

                    // -----------------------------------------------

                    RETmsgs.Enqueue("------------------");
                    RETmsgs.Enqueue("Number of NEW business roles created successfully: " + okCount.ToString());
                    if (RETmsgs.Count > 0)
                    {
                        string strMsgs = "";
                        foreach (object objMsg in RETmsgs.ToArray())
                        {
                            strMsgs += "\n" + objMsg.ToString();
                        }
                        TXTimportEngineMessages.Text  = strMsgs;
                        DIVimportFeeback.Visible      = true;
                        PANELcond_AbortUpload.Visible = false;
                        PANELcond_AllowUpload.Visible = false;
                    }
                }
            }
        }