Results 1 to 5 of 5

Thread: [RESOLVED] Confused over how to implement some IF/Then logic

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Resolved [RESOLVED] Confused over how to implement some IF/Then logic

    I'm sure this should be easy but I'm having trouble getting my head around it. I shall try to explain what I need as best I can.

    I have a string called SoftwareGroupName. If that string is empty, I need to run some code that logs a call in our Helpdesk. So far, so simple.

    I then check two other variables, AuthorityLevel and InstallType. If the AuthorityLevel is anything other than "OnRequest" then a call is logged in the Helpdesk System. Again, so far, so simple.

    The problem occurs when the AuthorityLevel is "OnRequest". At this point, the application should again log a call in the Helpdesk Call with a status of "Resolved" as well as add the user to the relevant group in Active Directory.

    What I need to be able to do is, effectively, say "If the AuthorityLevel is OnRequest and SoftwareGroupName is not empty then go ahead and create the call and update the group. However, if softwaregroupname is empty then DON'T even try and update the group and create a call with a different status (e.g. Assigned).

    Here's what I'm doing so far. But it seems wrong to have to check that SoftwareGroupName is empty twice.

    Code:
    Private Sub CreateCall
    
    Dim dic As New Dictionary(Of String, String)
    
    If Not rowSoftware Is Nothing Then
    
    dic.Add("[#STATUS#]", "New")
    dic.Add("[#DESCRIPTION#]", description)
    dic.Add("[#USERID#]", UserID)
    dic.Add("[#USERNAME#]", UserFullName)
    dic.Add("[#GROUP#]", "G-ITSD-1st")
    dic.Add("[#SOLSUMMARY#]", "")
    dic.Add("[#SOLDETAILS#]", "")
    description = UserID + " requests installation of " + _
                          rowSoftware.Description + " on " + Softwarename _
                         + ". Business Justification=" + Justification
                        description = description.Replace(Environment.NewLine, " ")
    
    Try
      softwareGroupName = rowSoftware.DistributionGroupName.ToString()
    Catch ex As Exception
    End Try
    
    If softwareGroupName = String.Empty Then
                            TraceDebug("No groupname for package : " + SoftwareID + " software->" + rowSoftware.Description)
    If rowSoftware.TYPE = TypeEnum.Package.ToString() Then
                                description = "Please create a new Package group for " + rowSoftware.Description
                            Else
                                description = "Please create a new Manual Install group for " + rowSoftware.Description
                            End If
    
                            description = description.Replace(Environment.NewLine, " ")
    
                            dic.Add("[#SUMMARY#]", "Missing distribution group for " + rowSoftware.Description)
                            dic.Add("[#DESCRIPTION#]", description)
                            dic.Add("[#USERID#]", "xxx")
                            dic.Add("[#USERNAME#]", "xxxx")
                            dic.Add("[#GROUP#]", "xxxx")
                            mail_adapter.SendMailToRemedy("incident", dic)
                        Else
                            TraceDebug("AD group Name = " + rowSoftware.DistributionGroupName)
                            TraceDebug("Authority Level =  " + rowSoftware.AuthorityLevel.ToString())
    
    Select Case rowSoftware.AuthorityLevel
                            Case AuthorizationLevelEnum.OnRequest
                            
                                If Not softwareGroupName = String.Empty Then
                                    TraceDebug("AddUserToGroup->" + PCOwner + " in " + softwareGroupName)
                                    Dim ad_adapter As New AD_Adapter
                                    ad_adapter.AddUserToGroup(PCOwner, softwareGroupName)
                                    If rowSoftware.TYPE = TypeEnum.Package.ToString() Then
                                        TraceDebug("Create email Package Request for -> " + UserID + " and software group " + softwareGroupName)
                                        dic.Add("[#SUMMARY#]", "Automated software request for " + rowSoftware.Description)
                                        dic("[#STATUS#]") = "Resolved"
                                        dic("[#SOLSUMMARY#]") = "User added to " + softwareGroupName
                                        dic("[#SOLDETAILS#]") = "User added to " + softwareGroupName
                                    Else
                                        TraceDebug("Create email Manual Request for -> " + UserID + " and software group " + softwareGroupName)
                                        dic.Add("[#SUMMARY#]", "Manual installation software request for " + rowSoftware.Description)
                                        mail_adapter.SendMailToRemedy("change", dic)
                                    End If
                                Else
                                    TraceDebug("Create 'Add user to group after creation' call for -> " + UserID + " and software group " + softwareGroupName)
                                    dic.Add("[#SUMMARY#]", "Add user to AD group for " + softwareGroupName + " when created by G-COE")
                                End If
                                mail_adapter.SendMailToRemedy("change", dic)
                                Case Else 'Need Approval
                                    'Remedy Mail
                                    TraceDebug("Create email  Manual Request for -> " + UserID + " and software group " + softwareGroupName)
                                    dic.Add("[#SUMMARY#]", "Approval required software request for " + rowSoftware.Description)
                                    mail_adapter.SendMailToRemedy("change", dic)
                            End Select
    
                        End If
                    Else
                        TraceDebug("ERROR! No row software found for package : " + SoftwareID)
                    End If
    
    End Sub
    Last edited by Ginolard; Mar 17th, 2009 at 10:37 AM.
    ManagePC - the all-in-one PC management and inventory tool

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Confused over how to implement some IF/Then logic

    so....

    Code:
    If the AuthorityLevel = "OnRequest" andalso SoftwareGroupName <> "" then 
           go ahead and create the call and update the group.
    ElseIf SofwareGroupName = "" Then
           DON'T even try and update the group and create a call with a different status
    Else
    ???? do yet another action
    End If
    does that help?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Re: Confused over how to implement some IF/Then logic

    Yes, I figured it was going to be using AndAlso. I shall try that, thanks
    Last edited by Ginolard; Mar 17th, 2009 at 11:23 AM.
    ManagePC - the all-in-one PC management and inventory tool

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2006
    Posts
    746

    Re: Confused over how to implement some IF/Then logic

    Well, that's simplified matters considerably!

    Thank you for clearing that up.
    ManagePC - the all-in-one PC management and inventory tool

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [RESOLVED] Confused over how to implement some IF/Then logic

    well, the logic was in your question... it just needed to be exrapolated... infact, that's how I built it.... I took the question and changed it into the if/then needed.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width