Beispiel #1
0
        public static LineItem GetPICInActiveLineItem(string picid)
        {
            List<LineItem> data = new List<LineItem>();

            foreach (dynamic item in Risque.Utility.SqlHelper.getSqlData(@"
                        SELECT TOP 1 li.*
                        FROM Tickets.dbo.LineItems AS li
                        INNER JOIN Tickets.dbo.Tickets AS t
                            ON li.TicketID = t.ID
                        WHERE t.StatusID IN (1, 2, 3, 4, 5)
                            AND li.PICID = '" + picid + "'"))
                                              {
                LineItem ticket = new LineItem();
                Risque.Utility.SqlHelper.Map<LineItem>(item, ticket);
                data.Add(ticket);
            }
            return data.Count == 0 ? null : data[0];
        }
Beispiel #2
0
        private void updateLiteral_Account(LineItem line, Literal literal)
        {
            switch (line.AccountTypeID)
            {
                case 1: // Cost Center
                    literal.Text = "<strong>Fund:</strong> " + line.AccountNumber1 +
                                   "<br /><strong>Cost Center:</strong> " + line.AccountNumber2;

                    if (!string.IsNullOrEmpty(line.AccountNumber3))
                        literal.Text += "<br /><strong>SIO:</strong> " + line.AccountNumber3;
                    break;

                case 2: // Real Order
                    literal.Text = "<strong>Fund:</strong> " + line.AccountNumber1 +
                                   "<br /><strong>Real Order:</strong> " + line.AccountNumber2;

                    if (!string.IsNullOrEmpty(line.AccountNumber3))
                        literal.Text += "<br /><strong>Fund Center:</strong> " + line.AccountNumber3;
                    break;

                case 3: // WBS
                    literal.Text = "<strong>WBS Element:</strong> " + line.AccountNumber1;

                    if (!string.IsNullOrEmpty(line.AccountNumber2))
                        literal.Text += "<br /><strong>SIO:</strong> " + line.AccountNumber2;
                    break;

                case 4: // Business Partner Number
                    literal.Text = "<strong>Business Partner:</strong> " + line.AccountNumber1;
                    break;
            }
        }
Beispiel #3
0
 private void updateLabel_TaggedVLANs(LineItem line, Label lbl)
 {
     var tagged = new List<string>();
     var taggedConcat = string.Empty;
     foreach (var vlan in line.LineItemVLANs)
     {
         if (!vlan.IsNative && !vlan.IsOld)
         {
             tagged.Add(vlan.VLANName);
         }
     }
     foreach (var vlan in tagged)
     {
         taggedConcat += "<br /> &nbsp;&nbsp;" + vlan;
     }
     taggedConcat = taggedConcat == string.Empty ? "None" : taggedConcat;
     lbl.Text = taggedConcat;
 }
Beispiel #4
0
 private void updateLabel_Services(LineItem line, Label lbl)
 {
     var services = new List<string>();
     var servicesConcat = "";
     foreach (var service in line.LineItemServices)
     {
         if (!service.IsOld)
             services.Add(service.ServiceName);
     }
     foreach (var service in services)
     {
         servicesConcat += @"<br />&nbsp;&nbsp;" + service;
     }
     servicesConcat = servicesConcat == string.Empty ? "None" : servicesConcat;
     lbl.Text = servicesConcat;
 }
Beispiel #5
0
 private void updateLabel_NewVLAN(LineItem line, Label label)
 {
     foreach (var vlan in line.LineItemVLANs)
     {
         if (vlan.IsNative && !vlan.IsOld)
         {
             label.Text = "<br />&nbsp;&nbsp;" + vlan.VLANName;
             break;
         }
     }
 }
Beispiel #6
0
 private void updateLabel_NewSpeed(LineItem line, Label label)
 {
     label.Text = "<br />&nbsp;&nbsp;" + line.SpeedName;
 }
Beispiel #7
0
        /// <summary>
        ///     syncLine Validates and Saves the current Data Ticket values to the Records Database.
        /// </summary>
        /// <param name="ticket">Current Overall Ticket</param>
        /// <param name="pic">Current Line Item PIC</param>
        /// <param name="row">The spefici row pertaining to the line item (List is a repeater)</param>
        private void syncLineToRecords(Ticket ticket, LineItem pic, GridViewRow row)
        {
            var lstItemServices = (ListBox)row.FindControl("lstItemServices");
            // Save Changes To Records!
            try
            {
                Link patchLink = null;
                Link providerLink = null;

                // Current Patch Port
                var patchLinkID =
                    SqlHelper.GetSingleSqlValue(
                        "declare @intid int;declare @port1 int;select distinct @intid = I.ID from Records.dbo.Interfaces as I join Records.dbo.Devices as D on I.DeviceID = D.ID join Records.dbo.Rooms as R on D.RoomID = R.ID join Records.dbo.Locations as L on R.LocationID = L.ID where L.ShortName = '" +
                        pic.Picid.Split('-')[0] + "' and InterfaceName = '" + pic.Picid.Split('-')[2] +
                        "' and I.FriendlyLongName = '" + pic.Picid +
                        "';Select top 1 @port1 = P.ID from Records.dbo.Interfaces as I join Records.dbo.Ports as P on I.ID = P.InterfaceID where I.ID = @intid order by P.ID desc;Select distinct L.ID as LinkID from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.SourcePortID where L.SourcePortID = @port1 union Select distinct L.ID as LinkID from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.DestinationPortID where L.DestinationPortID = @port1",
                        SqlHelper.GetConnectionString("Records"));

                if (!string.IsNullOrEmpty(patchLinkID))
                {
                    patchLink = Link.GetByIdentification(int.Parse(patchLinkID));

                    if (pic.PatchPortID != null && patchLink.SourcePortID != pic.PatchPortID &&
                        patchLink.DestinationPortID != pic.PatchPortID)
                    {
                        // patch port is different! let's have them load from records so that they can confirm the proper ports through Manage Links.
                        Alert.ShowError(
                            "Because port information changed, please verify and/or update the patch and provider information for " +
                            pic.Picid + " from Manage Links, then press 'Load Records'.", BrokenRulesDisplay);
                        scrollTop();
                        return;
                    }

                    if ((patchLink.DestinationPortPort.Interface.Ports.Count > 1 &&
                         patchLink.SourcePortPort.Interface.FriendlyLongName == pic.Picid) ||
                        (patchLink.SourcePortPort.Interface.Ports.Count > 1 &&
                         patchLink.DestinationPortPort.Interface.FriendlyLongName == pic.Picid))
                    {
                        var providerLinkID = SqlHelper.GetSingleSqlValue(
                            @"declare @port1 int;Select @port1 = P.ID from Records.dbo.Interfaces as I join Records.dbo.Ports as P on I.ID = P.InterfaceID where I.ID = (select InterfaceID from Records.dbo.Ports where ID = " +
                            (int)pic.PatchPortID + ") and P.ID != " + (int)pic.PatchPortID +
                            ";Select distinct L.ID as LinkID from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.SourcePortID where L.SourcePortID = @port1 union Select distinct L.ID as LinkID from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.DestinationPortID where L.DestinationPortID = @port1",
                            SqlHelper.GetConnectionString("Records"));

                        if (!string.IsNullOrEmpty(providerLinkID))
                        {
                            providerLink = Link.GetByIdentification(int.Parse(providerLinkID));
                        }
                    }
                    else // This is actually a provider
                        providerLink = patchLink;
                }

                // Grab Ports
                Port provider = null;
                Port patch = null;

                if (pic.PatchPortID != null)
                    patch = Port.GetByIdentification((int)pic.PatchPortID);

                // Don't bother grabbing provider for deactivates, we dont need it
                if (pic.ActionID < 3)
                    provider = Port.GetByIdentification((int)pic.ProviderPortID);

                var currentInterface = Interface.GetByIdentification(pic.InterfaceID);

                // Activate or Modify PIC
                if (pic.ActionID < 3)
                {
                    // Lists to save Data
                    List<int> setTaggedVlans = new List<int>();
                    List<int> removeVLANs = new List<int>();
                    List<int> setServices = new List<int>();
                    List<int> currentServices = new List<int>();
                    List<int> removeServices = new List<int>();

                    // Set provider link, set and replicate speed, vlans, services
                    int? native = null;
                    foreach (var vlan in pic.LineItemVLANs)
                    {
                        // If the VLAN is listed is Native but is not old (current) add it as the new native vlan
                        if (vlan.IsNative && vlan.IsOld == false)
                        {
                            native = vlan.Vlanid;
                            break;
                        }
                    }

                    // Set Tagged VLANs
                    foreach (var vlan in pic.LineItemVLANs)
                    {
                        if (vlan.Vlanid != native && vlan.IsOld == false)
                            setTaggedVlans.Add(vlan.Vlanid);
                    }

                    // Remove the rest of the vlans.
                    foreach (var vlan in pic.LineItemVLANs)
                    {
                        if (vlan.Vlanid != native && !setTaggedVlans.Contains(vlan.Vlanid) && vlan.IsOld)
                            removeVLANs.Add(vlan.Vlanid);
                    }

                    // Finalize native vlan by keeping it a the existing one.
                    // This applies only to Modify ticket - activate must have a native vlan.
                    if (pic.ActionID == 2 || pic.ActionID == 1)
                    {
                        foreach (var vlan in currentInterface.InterfaceVLANs)
                        {
                            if (native == null && vlan.IsNative)
                                native = vlan.Vlanid;
                        }
                    }

                    if (pic.ActionID == 1 && native == null)
                    {
                        Alert.ShowWarning("A <b>native vlan</b> is required.", BrokenRulesDisplay);
                        return;
                    }

                    if (native == null)
                        native = 17277;

                    // Set Services.
                    foreach (var srv in pic.LineItemServices)
                    {
                        if (!srv.IsOld)
                            setServices.Add(srv.ServiceID);
                        else
                            currentServices.Add(srv.ServiceID);
                    }
                    // Remove old services.
                    foreach (var service in currentServices)
                    {
                        if (!setServices.Contains(service))
                            removeServices.Add(service);
                    }

                    if (providerLink != null)
                    {
                        // Destination Port is the provider.
                        if (patch != null && providerLink.SourcePortPort.InterfaceID == patch.InterfaceID)
                            providerLink.DestinationPortID = provider.Identification;

                        // Source port is the provider.
                        else if (patch != null && providerLink.DestinationPortPort.InterfaceID == patch.InterfaceID)
                            providerLink.SourcePortID = provider.Identification;

                        // Destiintaion Port is the provider.
                        else if (providerLink.SourcePortPort.InterfaceID == pic.InterfaceID)
                            providerLink.DestinationPortID = provider.Identification;

                        // Source port is the provider.
                        else if (providerLink.DestinationPortPort.InterfaceID == pic.InterfaceID)
                            providerLink.SourcePortID = provider.Identification;

                        providerLink = providerLink.Save();

                        // Set Billing for Activate & Modify
                        LineItem.SetBilling(pic, currentInterface);

                        // Replicate Links
                        var rep = new LinkReplicator();

                        // Set Speed
                        rep.ReplicateSpeed(providerLink.SourcePortPort.InterfaceID, providerLink.Identification,
                            pic.SpeedID);
                        rep.ReplicateSpeed(providerLink.DestinationPortPort.InterfaceID, providerLink.Identification,
                            pic.SpeedID);

                        // Set Services
                        rep.ReplicateService(providerLink.SourcePortPort.InterfaceID, providerLink.Identification,
                            setServices, removeServices);
                        rep.ReplicateService(providerLink.DestinationPortPort.InterfaceID, providerLink.Identification,
                            setServices, removeServices);

                        // Set VLAN(s)
                        rep.ReplicateVLAN(providerLink.SourcePortPort.InterfaceID, providerLink.Identification,
                            currentInterface.IsTrunk, native, setTaggedVlans, removeVLANs);
                        rep.ReplicateVLAN(providerLink.DestinationPortPort.InterfaceID, providerLink.Identification,
                            currentInterface.IsTrunk, native, setTaggedVlans, removeVLANs);
                    }
                    else // Create a provider link.
                    {
                        // Set Billing for Activate & Modify
                        LineItem.SetBilling(pic, currentInterface);

                        createLink(pic, patch, provider, currentInterface, native, setTaggedVlans, setServices);
                    }
                }
                else if (pic.ActionID == 3 && providerLink != null)
                {
                    // deactivate
                    // if link removed, remove provider link and set and replicate speed and vlan to none. otherwise, set and replicate speed to none and vlan to 1
                    if (pic.IsLinkRemoved == true)
                    {
                        // Set billing for deactivate.
                        LineItem.SetBilling(pic, currentInterface);
                        Link.RemoveLink(providerLink.Identification, false);
                    }
                    else
                    {
                        // Set billing for deactivate.
                        LineItem.SetBilling(pic, currentInterface);

                        // Instiate Link Replicator
                        var rep = new LinkReplicator();

                        // set speeds
                        rep.ReplicateSpeed(providerLink.SourcePortPort.InterfaceID, providerLink.Identification, null);
                        rep.ReplicateSpeed(providerLink.DestinationPortPort.InterfaceID, providerLink.Identification,
                            null);

                        // current services
                        List<int> currentServices = new List<int>();
                        foreach (var cursrv in currentInterface.InterfaceServiceAssignments)
                            currentServices.Add(cursrv.ServiceID);

                        // Set services
                        rep.ReplicateService(providerLink.SourcePortPort.InterfaceID, providerLink.Identification, null,
                            currentServices);
                        rep.ReplicateService(providerLink.DestinationPortPort.InterfaceID, providerLink.Identification,
                            null, currentServices);

                        // Set VLAN(s) to null. If Link is not removed.  Set native VLAN too Cisco Defualt VLAN (1)  ID: 17277
                        rep.ReplicateVLAN(providerLink.SourcePortPort.InterfaceID, providerLink.Identification, false,
                            17277, null, null);
                        rep.ReplicateVLAN(providerLink.DestinationPortPort.InterfaceID, providerLink.Identification,
                            false, 17277, null, null);
                    }
                }
                // Mark as Synced and Save.
                pic.IsSynced = true;
                ticket.Save();

                // Remove provider Drop Downs.
                var pnlItemProviderSelection = row.FindControl("pnlItemProviderSelection") as Panel;
                pnlItemProviderSelection.Visible = false;

                SetDone(row, true);
            }
            catch // Catch with error to load from records again
            {
                Alert.ShowError(
                    "Because port information changed, please verify and/or update the patch and provider information for " +
                    pic.Picid + " from Manage Links, then press 'Load Records'.", BrokenRulesDisplay);
                scrollTop();
            }
        }
Beispiel #8
0
        private bool RunCompatibilityCheck(LineItem pic)
        {
            var success = true;
            try
            {
                // Get All VLAN(s)
                var vlanIDs = new List<int>();
                foreach (var vlan in pic.LineItemVLANs)
                {
                    if (!vlan.IsOld)
                        vlanIDs.Add(vlan.Vlanid);
                }

                // check compatibility of values with selected patch
                if (pic.PatchPortID != null)
                    if (!CheckCompatibilityWithPort((int)pic.PatchPortID, pic.SpeedID, vlanIDs))
                        success = false;

                // check compatibility of values with selected provider
                if (pic.ProviderPortID != null)
                {
                    if (!CheckCompatibilityWithPort((int)pic.ProviderPortID, pic.SpeedID, vlanIDs))
                        success = false;
                }
                return success;
            }
            catch
            {
                // Catch with error to load from records again
                Alert.ShowError(
                    "Because port information changed, please verify and/or update the patch and provider information for <b>" +
                    pic.Picid + "</b> from Manage Links, then press 'Load Records'.", BrokenRulesDisplay);
                scrollTop();

                // Fail.
                return false;
            }
        }
Beispiel #9
0
        // << Method does not mutate object state >>
        private void createLink(LineItem pic, Port patch, Port provider, Interface pici, int? native, List<int> vlans,
            List<int> services)
        {
            Port patchFront = null; // Create Provider Link.
            if (patch != null)
            {
                foreach (var port in patch.Interface.Ports)
                {
                    if (port.Identification != patch.Identification)
                    {
                        patchFront = port;
                        break;
                    }
                }
            }
            else
            {
                // no patch, use pic
                foreach (var port in pici.Ports)
                {
                    if (port.Name == "2" && port.SourcePortLinks.Count < 1 && port.DestinationPortLinks.Count < 1)
                    {
                        patchFront = port;
                        break;
                    }
                }

                if (patchFront == null)
                {
                    // pic must be HW
                    foreach (var port in pici.Ports)
                    {
                        if (port.Name == "1" && port.SourcePortLinks.Count < 1 && port.DestinationPortLinks.Count < 1)
                        {
                            patchFront = port;
                            break;
                        }
                    }
                }
            }
            Link.AddLink(patchFront.Identification, provider.Identification, pici.IsTrunk, (int)pic.SpeedID, native,
                vlans, services);
        }
Beispiel #10
0
        /// <summary>
        /// Set the billing plan for the current line item to tickets. Create Ticket Process
        /// </summary>
        /// <param name="lineItemPic">Current Line Item PIC </param>
        public static void SetBilling(LineItem lineItemPic)
        {
            /* - Activate -
             *      Lineitem has no previous billing plan - set as null and update BillingPlanID
             * - Modify --
             *      Line Item has a previous billing plan -> set PreviousBillingPlanID based off what is assigned to the interface
             *      within records(authoritative source).  Set BillingPlanID from the data input that happens in the CreateTicket Process.
             *      !From this point forward we will not modify the PreviousBillingPlanID
             *  - Deactivate -
             *      Line item has a previous billing plan -> set BillingPlanID only. (Plan will soon be removed).
             *  - Repair -
             *      Line item has a previous bililng plan - > set PreviousBillingPlanID as the BillingPlanID because
             *      the BillingPlanID cannot be changed in the create ticket process. However, under Admin permision the BillingPlanID
             *      can be changed within the TicketDetail.aspx process. Therefore we need to keep track of the PreviousBillingPlanID
             *      to compare changes between that and the BillingPlanID
             */
            InterfaceSpeed speed = InterfaceSpeed.GetByIdentification((int)lineItemPic.SpeedID);
            Interface curInterface = Interface.GetByIdentification((int)lineItemPic.InterfaceID);
            switch (lineItemPic.ActionID)
            {
                case 1: // Activate
                {
                    lineItemPic.PreviousBillingPlanID = null;
                    lineItemPic.BillingPlanID = speed.DefaultBillingPlanID;
                    break;
                }
                case 2: // Modify
                {
                    if (curInterface.BillingPlanID != null)
                        lineItemPic.PreviousBillingPlanID = (byte)curInterface.BillingPlanID;

                    lineItemPic.BillingPlanID = speed.DefaultBillingPlanID;
                    break;
                }
                case 3: // Deactivate
                {
                    lineItemPic.BillingPlanID = speed.DefaultBillingPlanID;
                    break;
                }
                case 4: // Repair
                {
                    if (curInterface.BillingPlanID != null)
                        lineItemPic.PreviousBillingPlanID = (byte) curInterface.BillingPlanID;

                    lineItemPic.BillingPlanID = speed.DefaultBillingPlanID;
                    break;
                }
            }
            /*
             * Check for Account Type of 'Business Partner Number' ID=4 -- Set as a BPN Plan
             */
            if (lineItemPic.AccountTypeID == 4)
            {
                BillingPlan billingPlan = BillingPlan.GetByIdentification((int)lineItemPic.BillingPlanID);
                switch (billingPlan.Name) {
                    case "DTCSTANDARD":
                        lineItemPic.BillingPlanID = 18; // BP DTCSTANDARD
                        break;
                    case "DTC10G":
                        lineItemPic.BillingPlanID = 19; // BP DTC10G
                        break;
                    case "DTCFIBERLIT":
                        lineItemPic.BillingPlanID = 20; // BP DTCFIBERLIT
                        break;
                    case "DTCFIBERSM":
                        lineItemPic.BillingPlanID = 21; // BP DTCFIBERSM
                        break;
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Set default values based on business rules for a line item type that is a 'Phone Only Connection'
        /// </summary>
        /// <param name="lineItemPIC">Current Line Item PIC</param>
        /// <param name="isAccountChangeOnly">Current Line Item that has only had account values changed.</param>
        public static void SetPhoneOnlyLineItem(LineItem lineItemPIC, bool isAccountChangeOnly)
        {
            bool accountChange = isAccountChangeOnly;
            // Set Default Values for a phone only connection line item
            if (lineItemPIC.ActionID == 1) {
                // Set Native VLAN for VoIP.
                LineItemVLAN vlan = lineItemPIC.LineItemVLANs.AddNew();
                vlan.Vlanid       = 17277;
                vlan.VLANName     = "Cisco Default VLAN (1)";
                vlan.IsNative     = true;
                vlan.IsOld        = false;
                vlan.IsVoIP       = false;
            }
            else if (lineItemPIC.ActionID == 2 && accountChange == false) {
                LineItemVLAN vlan = lineItemPIC.LineItemVLANs.AddNew();
                vlan.Vlanid       = 17277;
                vlan.VLANName     = "Cisco Default VLAN (1)";
                vlan.IsNative     = true;
                vlan.IsOld        = false;
                vlan.IsVoIP       = false;
            }

            // Set Default Speed for VoIP.
            lineItemPIC.SpeedName = "10/100/1000T-SW-A";
            lineItemPIC.SpeedID   = 19;
        }
Beispiel #12
0
        /// <summary>
        /// Save the billing plan for the current line item to records. TicketDetail Process
        /// </summary>
        /// <param name="lineItemPic">Current line item associated with interface</param>
        /// <param name="currentInterface">Interface being updated.</param>
        public static void SetBilling(LineItem lineItemPic, Interface currentInterface)
        {
            if (lineItemPic.ActionID == 3) // Deactivate
            {
                currentInterface.BillingPlanID = null;
                currentInterface.AccountFund = null;
                currentInterface.AccountCost = null;
                currentInterface.AccountOrder = null;
                currentInterface.AccountWBS = null;
                currentInterface.AccountSIO = null;
                currentInterface.AccountFundCenter = null;
                currentInterface.AccountBusinessPartner = null;
                currentInterface.InterfaceSpeedID = null;

            }
            else // Run switch case.  Repair Line Items have no account changes
                switch (lineItemPic.AccountTypeID) // Handle each account differently (based on business rules).
                {
                    case 1: // Cost Center
                    {
                        currentInterface.AccountOrder = null;
                        currentInterface.AccountWBS = null;
                        currentInterface.AccountBusinessPartner = null;
                        currentInterface.AccountFundCenter = null;
                        //-- UPDATE --//
                        currentInterface.BillingPlanID = lineItemPic.BillingPlanID;
                        currentInterface.AccountFund   = lineItemPic.AccountNumber1;
                        currentInterface.AccountCost   = lineItemPic.AccountNumber2;
                        currentInterface.AccountSIO    = lineItemPic.AccountNumber3;
                        break;
                    }
                    case 2: // Real Order
                    {
                        currentInterface.AccountCost = null;
                        currentInterface.AccountWBS = null;
                        currentInterface.AccountSIO = null;
                        currentInterface.AccountBusinessPartner = null;
                        //-- UPDATE --//
                        currentInterface.BillingPlanID = lineItemPic.BillingPlanID;
                        currentInterface.AccountFund = lineItemPic.AccountNumber1;
                        currentInterface.AccountOrder = lineItemPic.AccountNumber2;
                        break;
                    }
                    case 3: // WBS Element
                    {
                        currentInterface.AccountFund = null;
                        currentInterface.AccountCost = null;
                        currentInterface.AccountOrder = null;
                        currentInterface.AccountBusinessPartner = null;
                        currentInterface.AccountFund = null;
                        //-- UPDATE --//
                        currentInterface.BillingPlanID = lineItemPic.BillingPlanID;
                        currentInterface.AccountWBS = lineItemPic.AccountNumber1;
                        currentInterface.AccountSIO = lineItemPic.AccountNumber2;
                        break;
                    }
                    case 4: // Business Part Number
                    {
                        currentInterface.AccountFund = null;
                        currentInterface.AccountCost = null;
                        currentInterface.AccountOrder = null;
                        currentInterface.AccountWBS = null;
                        currentInterface.AccountSIO = null;
                        // -- UPDATE -- //
                        currentInterface.BillingPlanID = lineItemPic.BillingPlanID;
                        currentInterface.AccountBusinessPartner = lineItemPic.AccountNumber1;
                        break;
                    }
                }
                currentInterface.Save();
        }
Beispiel #13
0
        //--Save and Submit all Line Items to be created for Tickets
        protected void btnSave_Click(object sender, EventArgs e)
        {
            // Validate that all required data is present for the current line items state
            List<int> createdTickets = new List<int>();
            Alert alert = new Alert(BrokenRulesDisplay);
            bool needsPriorityConfirmed = false;
            bool canSave = true;

            if (txtContactName.Text.Trim() == string.Empty)
            {
                rfvName.IsValid = false;
                txtContactName.Focus();
                canSave = false;
            }

            if (txtContactPhone.Text.Trim() == string.Empty)
            {
                rfvPhone.IsValid = false;
                txtContactPhone.Focus();
                canSave = false;
            }

            if (txtContactEmail.Text.Trim() == string.Empty)
            {
                rfvEmail.IsValid = false;
                txtContactEmail.Focus();
                canSave = false;
            }

            Match emailMatch = Regex.Match(txtContactEmail.Text.Trim(), @"\b[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\b");

            if (txtContactEmail.Text.Trim() != "" && !emailMatch.Success)
            {
                canSave = false;
                alert.AddError("Bad email", "Contact Email must be a valid email address.");
            }

            if (AmdLineItems.Rows.Count == 0 && RepairLineItems.Rows.Count == 0)
            {
                canSave = false;
                alert.AddError("No items", "A ticket must have at least one line item before being submitted.");
            }
            // save priority and comments to datatable then check if required fields are present
            PreservePriorityAndComments();
            //
            foreach (RepeaterItem item in rptBuildings.Items)
            {
                HiddenField rowLocationId = (HiddenField)item.FindControl("rowLocationID");
                RadioButton rdoPriorityRush = (RadioButton)item.FindControl("rdoPriorityRush");
                RadioButton rdoPriorityScheduled = (RadioButton)item.FindControl("rdoPriorityScheduled");

                if (rdoPriorityRush.Checked)
                {   // Rush Priority
                    needsPriorityConfirmed = true;

                    TextBox txtRushRationale = (TextBox)item.FindControl("txtRushRationale");
                    string validateLength = txtRushRationale.Text.Trim();
                    validateLength = validateLength.Replace("\r\n", " ");

                    Match match = Regex.Match(validateLength, @"^((\b[a-zA-Z.]{1,40}\b).*){3,}$");

                    if (!match.Success)
                    {
                        canSave = false;
                        alert.AddError("Needs rush rationale", "Rush Priority Rationale for building " + Location.GetByIdentification(int.Parse(rowLocationId.Value)).ShortName + " must contain at least 3 words.");
                    }
                }
                else if (rdoPriorityScheduled.Checked)
                {    // Scheduled Priority
                    needsPriorityConfirmed = true;
                    TextBox txtScheduledDate = (TextBox)item.FindControl("txtScheduledDate");
                    TextBox txtScheduledTime = (TextBox)item.FindControl("txtScheduledTime");
                    DateTime scheduled;

                    if (txtScheduledDate.Text == "" || txtScheduledTime.Text == "")
                    {
                        canSave = false;
                        alert.AddError("Needs date", "Scheduled Date and Time for building " + Location.GetByIdentification(int.Parse(rowLocationId.Value)).ShortName + " must be a valid date and time.");
                    }
                    else if (DateTime.TryParse(txtScheduledDate.Text.Trim() + " " + txtScheduledTime.Text.Trim(), out scheduled))
                    {
                        if (DateTime.Now.AddDays(Ticket.GetNumberBusinessDaysFromDate(DateTime.Now, 3)) > scheduled)
                        {
                            canSave = false;
                            alert.AddError("Needs date", "Scheduled Date and Time for building " + Location.GetByIdentification(int.Parse(rowLocationId.Value)).ShortName + " must be at least 3 business days from now.");
                        }
                    }
                }
            }
            if (needsPriorityConfirmed)
            {
                if (!chkPriorityConfirm.Checked)
                {
                    canSave = false;
                    alert.AddError("Needs priority confirmed", "You must acknowledge the 3-day business rule before submitting this ticket.");
                }
            }

            if (canSave)
            {
                foreach (RepeaterItem building in rptBuildings.Items)
                {
                    HiddenField rowLocationId = (HiddenField)building.FindControl("rowLocationID");
                    DataRow[] lineItemRow = AmdBuildings.Select("LocationID = " + rowLocationId.Value);

                    // Create Ticket and set values in the database, is populated from <amdLineItems>
                    foreach (DataRow row in lineItemRow)
                    {
                        // Create a new ticket for each building
                        Ticket ticket = Ticket.NewTicket();

                        // Populate Contact Data and Status
                        PopulateTicketGeneralData(ticket);

                        // Set ticket priority <amdLineItem>
                        if (row["PriorityID"] != DBNull.Value)
                            ticket.PriorityID = (int)row["PriorityID"];
                        else
                            ticket.PriorityID = 1;

                        // Rush rationale as comment, also set due date <amdLineItem>
                        if (ticket.PriorityID == 2)
                        {
                            Comment rush = ticket.Comments.AddNew();
                            rush.ClientName = RisqueContext.CurrentUser.FullName;
                            rush.IsInternal = false;
                            rush.Text = "Rationale for Rush priority: " + row["RushRationale"];
                            ticket.DueDate = DateTime.Now.AddDays(Ticket.GetNumberBusinessDaysFromDate(DateTime.Now, 1));
                        }
                        else
                        {
                            ticket.DueDate = DateTime.Now.AddDays(Ticket.GetNumberBusinessDaysFromDate(DateTime.Now, 3));
                        }

                        // Set Schedule Date <amdLineItem>
                        if (ticket.PriorityID == 3)
                            ticket.ScheduledDate = (DateTime?) row["ScheduledDate"];

                        // Comments amdLineItem>
                        if (row["Comment"].ToString() != string.Empty)
                        {
                            Comment comment = ticket.Comments.AddNew();
                            comment.ClientName = RisqueContext.CurrentUser.FullName;
                            comment.IsInternal = false;
                            comment.Text = row["Comment"].ToString();
                        }
                        bool isAccountChangeOnly = true;
                        bool isStandard          = true;
                        bool changeToStandard    = false;
                        bool addEngineerNote     = false;
                        bool addVoiceVlanNote    = false;

                        // Line Items (Activate / Modify / Deactivate)
                        foreach (DataRow drLineItem in AmdLineItems.Select("LocationID = " + rowLocationId.Value))
                        {
                            // Create a New Line Item for the Ticket.
                            LineItem lineItemPic = ticket.LineItems.AddNew();
                            // Check if anything has changed outside of billing. If so -- it is no long an account change only line item.
                            if ((int)drLineItem["ActionID"] == 3 || !(bool)drLineItem["IsOnlyAccountChange"])
                                isAccountChangeOnly = false;

                            // Populate from DataTable.
                            lineItemPic.ActionID = (int) drLineItem["ActionID"];
                            lineItemPic.Picid = drLineItem["PICID"].ToString();
                            lineItemPic.InterfaceID = (int) drLineItem["InterfaceID"];
                            lineItemPic.IsDone = isAccountChangeOnly;

                            // If the LineItem is not a Phone Only Connection -- Do a Normal Data Ticket -- Else add Phone Only Values
                            if ((bool?) drLineItem["IsVoIP"] == false)
                            {
                                // Set new native vlan(s) for the line item.
                                if (drLineItem["NativeVLAN"] != DBNull.Value)
                                    LineItemVLAN.SaveNewNativeVlan(lineItemPic, drLineItem);

                                // Set new tagged VLAN(s) for the the line item.
                                if (drLineItem["InterfaceVLANs"] != DBNull.Value)
                                    LineItemVLAN.SaveNewTaggedVlans(lineItemPic, drLineItem);

                                // If an Activate there are no current tagged vlan(s) to set.
                                if (!lineItemPic.ActionID.Equals(1))
                                {
                                    Interface currentInterface = Interface.GetByIdentification(lineItemPic.InterfaceID);

                                    // Save current native vlan to the ticket line item.
                                    LineItemVLAN.SaveCurrentNativeVlan(currentInterface, lineItemPic);

                                    // Save current tagged vlan to the ticket line item.
                                    LineItemVLAN.SaveCurrentTaggedVlans(currentInterface, lineItemPic);

                                    // Save current voip vlan(if any) to the ticket line item.
                                    LineItemVLAN.SaveCurrentVoipVlan(currentInterface, lineItemPic);
                                }

                                // Set Data Service Assignments
                                if (drLineItem["InterfaceServiceAssignments"] != DBNull.Value)
                                {
                                    string[] serviceNames =
                                        drLineItem["ServiceNames"].ToString()
                                            .Split(new[] {"<br />"}, StringSplitOptions.None);
                                    List<int> serviceIDs = (List<int>) drLineItem["InterfaceServiceAssignments"];

                                    for (var i = 0; i < serviceIDs.Count; i++)
                                    {
                                        LineItemService service = lineItemPic.LineItemServices.AddNew();
                                        service.ServiceID = serviceIDs[i];
                                        service.ServiceName = serviceNames[i];
                                        service.IsOld = false;

                                        // Add Engineer Note
                                        if (service.ServiceName == "Port Channel" ||
                                            service.ServiceName == "BPDU Guard Disable")
                                            addEngineerNote = true;

                                        if (service.ServiceName == "Voice VLAN") // Add voice VLAN Note
                                            addVoiceVlanNote = true;
                                    }
                                }
                                // Set Data Ticket Billing Data,
                                if (drLineItem["AccountTypeID"] != DBNull.Value)
                                    lineItemPic.AccountTypeID = drLineItem["AccountTypeID"] as int?;

                                if (drLineItem["AccountNumber1"] != DBNull.Value)
                                    lineItemPic.AccountNumber1 = drLineItem["AccountNumber1"].ToString();

                                if (drLineItem["AccountNumber2"] != DBNull.Value)
                                    lineItemPic.AccountNumber2 = drLineItem["AccountNumber2"].ToString();

                                if (drLineItem["AccountNumber3"] != DBNull.Value)
                                    lineItemPic.AccountNumber3 = drLineItem["AccountNumber3"].ToString();

                                if (drLineItem["InterfaceSpeedID"] != DBNull.Value)
                                {
                                    lineItemPic.SpeedID = (int) drLineItem["InterfaceSpeedID"];
                                    lineItemPic.SpeedName = drLineItem["SpeedName"].ToString();

                                    // Set Billing Plan if Interface speed exists
                                    LineItem.SetBilling(lineItemPic);
                                }
                            }
                            // Set IsVOIP Data -> 'Phone Only Connection'
                            else
                            {
                                // If the line item was voip and cisco and it is still a phone only connection then its an account change only.
                                if (_containsVoIp && _containsCisco)
                                    isAccountChangeOnly = true;
                                else
                                    isAccountChangeOnly = false;
                                        // Changed to phone only. Won't be an account change only

                                lineItemPic.IsDone = false;

                                // Set Default values for a Phone Only Connection.
                                LineItem.SetPhoneOnlyLineItem(lineItemPic, isAccountChangeOnly);

                                // If PIC is not an activate. Set current VLAN(s) for the line item.
                                if (!lineItemPic.ActionID.Equals(1))
                                {
                                    Interface currentInterface = Interface.GetByIdentification(lineItemPic.InterfaceID);
                                    LineItemVLAN.SaveCurrentNativeVlan(currentInterface, lineItemPic);
                                    LineItemVLAN.SaveCurrentTaggedVlans(currentInterface, lineItemPic);
                                }

                                // Set VoIP Billing Data
                                if (drLineItem["AccountTypeID"] != DBNull.Value)
                                    lineItemPic.AccountTypeID = (int?) drLineItem["AccountTypeID"];

                                if (drLineItem["AccountNumber1"] != DBNull.Value)
                                    lineItemPic.AccountNumber1 = drLineItem["AccountNumber1"].ToString();

                                if (drLineItem["AccountNumber2"] != DBNull.Value)
                                    lineItemPic.AccountNumber2 = drLineItem["AccountNumber2"].ToString();

                                if (drLineItem["AccountNumber3"] != DBNull.Value)
                                    lineItemPic.AccountNumber3 = drLineItem["AccountNumber3"].ToString();

                                // Set current billg plan.
                                LineItem.SetBilling(lineItemPic);

                                // Populate the Switch VOIP Vlan Value if it exists
                                if ((int) drLineItem["ActionID"] == 2 || (int) drLineItem["ActionID"] == 1)
                                    PopSwitchVoIp(lineItemPic);
                            }

                            // If previous BillingPlan was saved -- Check if it has changed from Premium to Standard Account
                            if (drLineItem["prevBillingPlanID"] != DBNull.Value)
                            {
                                // Check if billing plan has changed from Premium to a Standard.  If so update changeToStandard to get sent to billing
                                if ((int) lineItemPic.BillingPlanID != (int) drLineItem["prevBillingPlanID"] && lineItemPic.BillingPlanID == 16)
                                    changeToStandard = true;
                            }
                            //Check Billing Plan 16 = 'DTCSTANDARD'
                            if (lineItemPic.BillingPlanID != 16)
                                isStandard = false;

                            if (drLineItem["isTrunk"] != DBNull.Value)
                            {
                                if ((bool) drLineItem["isTrunk"])
                                {
                                    Comment trunkNote = ticket.Comments.AddNew();
                                    trunkNote.ClientName = "Risque System";
                                    trunkNote.IsInternal = true;
                                    trunkNote.Text = lineItemPic.Picid + ": is <b>Trunk.</b>";
                                }
                            }
                            AddCurrentSettingsToLine(lineItemPic); // Populate current PIC settings
                        } // END AMD LINE ITEM FOREACH LOOP //

                        if (addEngineerNote)
                        {
                            Comment note = ticket.Comments.AddNew();
                            note.ClientName = "Risque System";
                            note.IsInternal = true;
                            note.Text = "Please assign this ticket directly to an engineer.";
                        }

                        if (addVoiceVlanNote)
                        {
                            Comment note = ticket.Comments.AddNew();
                            note.ClientName = "Risque System";
                            note.IsInternal = true;
                            note.Text = "Please verify the voice VLAN for this TR and update links accordingly.";
                        }

                        // Ticket goes to Billing if there it is an account change only.
                        if (isAccountChangeOnly)
                        {
                            //--Update Interface Account Information if the Ticket is an Account Only Change
                            Interface intrface;  // Create Objects
                            LineItem pic = new LineItem();
                            for (var i = 0; i < ticket.LineItems.Count; i++)
                            {

                                pic = ticket.LineItems[i];
                                intrface = Interface.GetByIdentification(pic.InterfaceID);
                                // --- Update Billing Plan & Account Number Interface Data Upon Data Ticket Approval --- //
                                switch (pic.ActionID)
                                {
                                    case 1: // Activate
                                    {
                                        ManageAccounts(pic, intrface);
                                        break;
                                    }
                                    case 2: // Modify
                                    {
                                        ManageAccounts(pic, intrface);
                                        break;
                                    }
                                    case 3: // Deactivate
                                    {
                                        intrface.BillingPlanID = null;
                                        intrface.AccountFund = null;
                                        intrface.AccountCost = null;
                                        intrface.AccountOrder = null;
                                        intrface.AccountWBS = null;
                                        intrface.AccountSIO = null;
                                        intrface.AccountFundCenter = null;
                                        intrface.AccountBusinessPartner = null;
                                        intrface.InterfaceSpeedID = null;
                                        intrface.Save();
                                        break;
                                    }
                                    case 4: // Repair
                                        //No Changes to Billing
                                        break;
                                    default:
                                        continue;
                                }

                            }

                            //If the Billing is Standard ticket goes straight to complete
                            if (changeToStandard)
                            {
                                ticket.StatusID = 5;
                                ticket.EffectiveDate = DateTime.Now;
                            }
                            else if (isStandard)
                            {
                                ticket.StatusID = 6;
                                ticket.EffectiveDate = DateTime.Now;
                            }
                            else
                            {
                                ticket.StatusID = 5;
                                ticket.EffectiveDate = DateTime.Now;
                            }
                        }
                        // Save
                        ticket = ticket.Save();
                        createdTickets.Add(ticket.Identification);
                        // Add to Building Outage Notification List
                        AddToLocationContacts(int.Parse(rowLocationId.Value));
                        //--- Send Email ---//
                        TicketsBusiness.Utility.TicketsMailer.SendMail_CreateTicket(ticket, RisqueContext.CurrentUser);
                    }
                }
                // Iterate through repair line items if they exist
                foreach (DataRow repair in RepairLineItems.Rows)
                {   // Ticket for Repair
                    Ticket ticket = Ticket.NewTicket();

                    // populate contact data and status
                    PopulateTicketGeneralData(ticket);

                    // set as rush priority
                    ticket.PriorityID = 2;

                    // add line item
                    LineItem lineItemPic = ticket.LineItems.AddNew();

                    // populate data from datatable
                    lineItemPic.ActionID    = (int)repair["ActionID"];
                    lineItemPic.Picid       = repair["PICID"].ToString();
                    lineItemPic.InterfaceID = (int)repair["InterfaceID"];
                    lineItemPic.RepairNotes = repair["RepairNotes"].ToString();

                    // Populate Current Settings to PIC
                    AddCurrentSettingsToLine(lineItemPic);

                    // Add Current VLANs
                    LineItemVLAN.SaveCurrentNativeVlan(Interface.GetByIdentification(lineItemPic.InterfaceID), lineItemPic);
                    LineItemVLAN.SaveCurrentTaggedVlans(Interface.GetByIdentification(lineItemPic.InterfaceID), lineItemPic);

                    // Save Repair Notes - To the comments gridview
                    Comment comment    = ticket.Comments.AddNew();
                    comment.ClientName = RisqueContext.CurrentUser.FullName;
                    comment.IsInternal = false;
                    comment.Text       = repair["RepairNotes"].ToString();

                    // Finalize Ticket
                    ticket = ticket.Save();
                    createdTickets.Add(ticket.Identification);

                    //-- add to building outage notification list
                    AddToLocationContacts(Interface.GetByIdentification(lineItemPic.InterfaceID).Device.Room.LocationID);

                    //-- send email
                    TicketsBusiness.Utility.TicketsMailer.SendMail_CreateTicket(ticket, RisqueContext.CurrentUser);
                }
                var ids = string.Empty;
                foreach (int id in createdTickets)
                    ids += id + ",";

                if (createdTickets.Count > 0)
                    ids = ids.Substring(0, ids.Length - 1);

                Response.Redirect("ViewTickets.aspx?created=" + ids, false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
            else
            {
                ScrollTop();
                alert.ShowBrokenRules();
            }
        }
Beispiel #14
0
        //Populate the switch voip vlan value << method does not mutate object state >>
        private static void PopSwitchVoIp(LineItem picInterface)
        {
            // Set SwitchVoIPVLAN Data
            Interface crrntInterface = Interface.GetByIdentification(picInterface.InterfaceID);
            bool isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;

            // Save so we don't go back to the same link. An Exclusion List.
            List<int> prevLink = new List<int>();

            // Loop through All Links until we find the first transparent device.
            // Or we have run out of links to check then break out of the loop.
            while (isTransparent)
            {
                int dstPortId = 0;
                int srcPortId = 0;
                //-- PORT 0 Destination Port Links. If there are no Destination port links, look in source port links.
                if (crrntInterface.Ports[0].DestinationPortLinks.Count() > 0)
                {   // Grab the destination port and source port to make sure we aren't looking at the same two ports.
                    dstPortId = crrntInterface.Ports[0].DestinationPortLinks[0].DestinationPortID;
                    srcPortId = crrntInterface.Ports[0].DestinationPortLinks[0].SourcePortID;

                    if (dstPortId != crrntInterface.Ports[0].Identification && !prevLink.Contains(crrntInterface.Ports[0].DestinationPortLinks[0].Identification))
                    {
                        // Save previous link id to check next time through the loop Exclusion List.
                        // To Avoid checking the same link over and over again.
                        prevLink.Add(crrntInterface.Ports[0].DestinationPortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[0].DestinationPortLinks[0].DestinationPortPort.InterfaceID);

                        //Set boolean value. If the device is transparent we have found the switch. Exit.
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }
                    // Destination Port was equal to current interface port -> Look at source port.
                    else if (srcPortId != crrntInterface.Ports[0].Identification && !prevLink.Contains(crrntInterface.Ports[0].DestinationPortLinks[0].Identification))
                    {
                        prevLink.Add(crrntInterface.Ports[0].DestinationPortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[0].DestinationPortLinks[0].SourcePortPort.InterfaceID);

                        //Set boolean value
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }
                    else
                        break;
                }

                // PORT 0 Source Port Links. If there are no source port links we have looked at all the links at Ports[0]. Move to Ports[1].
                else if (crrntInterface.Ports[0].SourcePortLinks.Count() > 0)
                {
                    dstPortId = crrntInterface.Ports[0].SourcePortLinks[0].DestinationPortID;
                    srcPortId = crrntInterface.Ports[0].SourcePortLinks[0].SourcePortID;

                    if (dstPortId != crrntInterface.Ports[0].Identification && !prevLink.Contains(crrntInterface.Ports[0].SourcePortLinks[0].Identification))
                    {
                        // Save previous link id to check next time through the loop.
                        // To Avoid checking the same link over and over again.
                        prevLink.Add(crrntInterface.Ports[0].SourcePortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[0].SourcePortLinks[0].DestinationPortPort.InterfaceID);
                        //Set boolean value
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }

                    else if (srcPortId != crrntInterface.Ports[0].Identification && !prevLink.Contains(crrntInterface.Ports[0].SourcePortLinks[0].Identification))
                    {
                        prevLink.Add(crrntInterface.Ports[0].SourcePortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[0].SourcePortLinks[0].SourcePortPort.InterfaceID);
                        //Set boolean value
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }
                    else
                        break;
                }

                //-- PORT 1 Destination Port Links
                else if (crrntInterface.Ports[1].DestinationPortLinks.Count() > 0)
                {
                    dstPortId = crrntInterface.Ports[1].DestinationPortLinks[0].DestinationPortID;
                    srcPortId = crrntInterface.Ports[1].DestinationPortLinks[0].SourcePortID;

                    if (dstPortId != crrntInterface.Ports[1].Identification && !prevLink.Contains(crrntInterface.Ports[1].DestinationPortLinks[0].Identification))
                    {
                        // Save previous link id to check next time through the loop.
                        // To Avoid checking the same link over and over again.
                        prevLink.Add(crrntInterface.Ports[1].DestinationPortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[1].DestinationPortLinks[0].SourcePortPort.InterfaceID);

                        //See if the device is transparent
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }
                    else if (srcPortId != crrntInterface.Ports[1].Identification && !prevLink.Contains(crrntInterface.Ports[1].DestinationPortLinks[0].Identification))
                    {
                        prevLink.Add(crrntInterface.Ports[1].DestinationPortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[1].DestinationPortLinks[0].SourcePortPort.InterfaceID);

                        //See if the device is transparent
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }
                    else // Break out of the loop of none of the above cases are true.
                        break;
                }

                //--  PORT 1 Source Port Links.
                else if (crrntInterface.Ports[1].SourcePortLinks.Count() > 0)
                {
                    dstPortId = crrntInterface.Ports[1].SourcePortLinks[0].DestinationPortID;
                    srcPortId = crrntInterface.Ports[1].SourcePortLinks[0].SourcePortID;

                    if (dstPortId != crrntInterface.Ports[1].Identification && !prevLink.Contains(crrntInterface.Ports[1].SourcePortLinks[0].Identification))
                    {
                        prevLink.Add(crrntInterface.Ports[1].SourcePortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[1].SourcePortLinks[0].DestinationPortPort.InterfaceID);

                        //See if the device is transparent
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }
                    else if (srcPortId != crrntInterface.Ports[1].Identification && !prevLink.Contains(crrntInterface.Ports[1].SourcePortLinks[0].Identification))
                    {
                        prevLink.Add(crrntInterface.Ports[1].SourcePortLinks[0].Identification);
                        crrntInterface = Interface.GetByIdentification(crrntInterface.Ports[1].SourcePortLinks[0].SourcePortPort.InterfaceID);

                        //Set boolean value
                        isTransparent = crrntInterface.Device.DeviceDefinition.IsTransparent;
                    }
                    else
                        break;
                }
            }
            // Found first non-transparent device -- now locate the telecom room it is in.
            int voip;
            string swtchVoip = Risque.Utility.SqlHelper.GetSingleSqlValue("SELECT TOP 1 svp.VLANID FROM SwitchVoIPVLANs AS svp INNER JOIN Devices AS dev "
                                               + "    on svp.DeviceID = dev.ID "
                                               + " WHERE dev.InstanceNumber = 1 "
                                               + "   AND dev.RoomID = " + crrntInterface.Device.RoomID,
                                                Risque.Utility.SqlHelper.GetConnectionString("Records"));
            //If we can parse the swtchVOIP value. Add it to the line item.
            if (int.TryParse(swtchVoip, out voip))
            {
                // Set first swtich voip vlan.
                Vlan vpVlan = Vlan.GetByIdentification(voip);
                LineItemVLAN addVoip = picInterface.LineItemVLANs.AddNew();
                addVoip.Vlanid = vpVlan.Identification;
                addVoip.VLANName = vpVlan.Name;
                addVoip.IsNative = false;
                addVoip.IsVoIP = true;

                // Determine if the VLAN was already on the Interface.  If so - set the LineItem VLAN IsOld to true.
                if (crrntInterface.InterfaceVLANs.Count > 0)
                {
                    if (crrntInterface.InterfaceVLANs[0].IsVoIP)
                        addVoip.IsOld = true;
                    else
                        addVoip.IsOld = false;
                }
            }
        }
Beispiel #15
0
        // Set current PIC settings for LineItem. << This method does not mutate the object state >>
        private static void AddCurrentSettingsToLine(LineItem pic)
        {
            Interface current = Interface.GetByIdentification(pic.InterfaceID);

            // current speed
            if (current.InterfaceSpeedID != null)
            {
                pic.OldSpeedID = current.InterfaceSpeedID;
                pic.OldSpeedName = current.InterfaceSpeed.Name;
            }

            // current services
            foreach (InterfaceServiceAssignment cursrv in current.InterfaceServiceAssignments)
            {
                LineItemService srv = pic.LineItemServices.AddNew();
                srv.ServiceID = cursrv.ServiceID;
                srv.ServiceName = cursrv.Service.Name;
                srv.IsOld = true;
            }

            // current patch port
            string patch = Risque.Utility.SqlHelper.GetSingleSqlValue("declare @devid int;declare @port1 int;declare @pport int;select distinct @devid = DeviceID from Records.dbo.Interfaces as I join Records.dbo.Devices as D on I.DeviceID = D.ID join Records.dbo.Rooms as R on D.RoomID = R.ID join Records.dbo.Locations as L on R.LocationID = L.ID where L.ShortName = '" + pic.Picid.Split('-')[0] + "' and InterfaceName = '" + pic.Picid.Split('-')[2] + "' and I.FriendlyLongName = '" + pic.Picid + "';Select top 1 @port1 = P.ID from Records.dbo.Devices As D join Records.dbo.Interfaces as I on D.ID = I.DeviceID join Records.dbo.Ports as P on I.ID = P.InterfaceID where DeviceID = @devid and I.FriendlyLongName = '" + pic.Picid + "' order by P.ID desc;Select distinct L.DestinationPortID as Port from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.SourcePortID where L.SourcePortID = @port1 union Select distinct L.SourcePortID as Port from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.DestinationPortID where L.DestinationPortID = @port1", Risque.Utility.SqlHelper.GetConnectionString("Records"));

            if (patch != "" && patch != null)
            {
                Port pport = Port.GetByIdentification(int.Parse(patch));

                int portCount = int.Parse(Risque.Utility.SqlHelper.GetSingleSqlValue("select count(ID) from Records.dbo.Ports where InterfaceID = " + pport.InterfaceID));

                if (portCount > 1)
                {
                    // patch panel then provider
                    pic.PatchPortID = pport.Identification;
                    pic.PatchPortName = pport.FriendlyLongName;

                    // current provider
                    string provider = Risque.Utility.SqlHelper.GetSingleSqlValue("declare @port1 int;Select @port1 = P.ID from Records.dbo.Interfaces as I join Records.dbo.Ports as P on I.ID = P.InterfaceID where I.ID = (select InterfaceID from Records.dbo.Ports where ID = " + (int)pic.PatchPortID + ") and P.ID != " + (int)pic.PatchPortID + ";Select distinct L.DestinationPortID as Port from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.SourcePortID where L.SourcePortID = @port1 union Select distinct L.SourcePortID as Port from Records.dbo.Ports As P left join Records.dbo.Links As L on P.ID = L.DestinationPortID where L.DestinationPortID = @port1", Risque.Utility.SqlHelper.GetConnectionString("Records"));

                    if (provider != "" && provider != null)
                    {
                        pic.ProviderPortID = int.Parse(provider);
                        pic.ProviderPortName = Risque.Utility.SqlHelper.GetSingleSqlValue("select FriendlyLongName from Records.dbo.Ports where ID = " + provider);
                    }
                }
                else
                {
                    // this is actually a provider
                    pic.ProviderPortID = pport.Identification;
                    pic.ProviderPortName = pport.FriendlyLongName;
                }
            }
        }
Beispiel #16
0
 //-- Manage Account Information
 protected void ManageAccounts(LineItem pic, Interface intrface)
 {
     //Each Account is Handeled Differently
     switch (pic.AccountTypeID)
     {
         case 1: // Cost Center
             {
                 intrface.AccountOrder = null;
                 intrface.AccountWBS = null;
                 intrface.AccountBusinessPartner = null;
                 intrface.AccountFundCenter = null;
                 //-- UPDATE --//
                 intrface.BillingPlanID = pic.BillingPlanID;
                 intrface.AccountFund = pic.AccountNumber1;
                 intrface.AccountCost = pic.AccountNumber2;
                 intrface.AccountSIO = pic.AccountNumber3;
                 break;
             }
         case 2: // Real Order
             {
                 intrface.AccountCost = null;
                 intrface.AccountWBS = null;
                 intrface.AccountSIO = null;
                 intrface.AccountBusinessPartner = null;
                 //-- UPDATE --//
                 intrface.BillingPlanID = pic.BillingPlanID;
                 intrface.AccountFund = pic.AccountNumber1;
                 intrface.AccountOrder = pic.AccountNumber2;
                 break;
             }
         case 3: // WBS Element
             {
                 intrface.AccountFund = null;
                 intrface.AccountCost = null;
                 intrface.AccountOrder = null;
                 intrface.AccountBusinessPartner = null;
                 intrface.AccountFund = null;
                 //-- UPDATE --//
                 intrface.BillingPlanID = pic.BillingPlanID;
                 intrface.AccountWBS = pic.AccountNumber1;
                 intrface.AccountSIO = pic.AccountNumber2;
                 break;
             }
         case 4: // Business Part Number
             {
                 intrface.AccountFund = null;
                 intrface.AccountCost = null;
                 intrface.AccountOrder = null;
                 intrface.AccountWBS = null;
                 intrface.AccountSIO = null;
                 // -- UPDATE -- //
                 intrface.BillingPlanID = pic.BillingPlanID;
                 intrface.AccountBusinessPartner = pic.AccountNumber1;
                 break;
             }
     }
     intrface.Save();
 }