public DiaryController(yfjbContext dbContext, TicketsBusiness ticketsBusiness) { ReptilesApp = new ReptilesApp(dbContext); TicketsBusiness = ticketsBusiness; }
//-- Validate User Input and Values private bool VerifyAddLine(TicketsBusiness.Action action) { // verify data was entered properly bool canSave = true; Alert alert = new Alert(AddLineBrokenRules); if (action.Identification == 1 || action.Identification == 2) { // activate / modify rules // speed is required if (ddlSpeed.SelectedIndex == 0) { canSave = false; alert.AddError("No Speed", "Speed is a required field."); } // at least one vlan is required if (ddlVLAN.SelectedIndex == 0) { canSave = false; alert.AddError("No VLAN", "VLAN is a required field."); } if (pnlTrunk.Visible) { bool dupeVlan = false; foreach (ListItem vlan in lstVLAN.Items) { if (vlan.Selected) { if (ddlVLAN.SelectedIndex > 0 && vlan.Value == ddlVLAN.SelectedValue) { dupeVlan = true; break; } } } if (dupeVlan) { canSave = false; alert.AddError("Duplicate VLAN", "The Native VLAN selected cannot also be selected as a Tagged VLAN. Please ensure all VLAN selections are unique."); } } // valid account info is required if (ddlAccountType.SelectedIndex == 0) { canSave = false; alert.AddError("No AccountType", "Account Type is a required field."); } else { if (AcctValidation(alert) == false) { canSave = false; } } } if (!canSave) alert.ShowBrokenRules(); return canSave; }
private void AddPhoneOnly_csv(string[] values, DataRow line, Interface pic, TicketsBusiness.Action action) { line["LocationID"] = pic.Device.Room.LocationID; line["ActionID"] = action.Identification; line["ActionName"] = action.Name; line["LocationID"] = pic.Device.Room.LocationID; line["SpeedName"] = "VoIP Phone Speed Settings"; line["NativeVLANName"] = "VoIP Phone VLAN Settings"; line["ServiceNames"] = "VoIP Phone Settings"; line["IsVoIP"] = true; line["IsOnlyAccountChange"] = false; // Set Account Info for Phone Only string fund = values[7]; string cost = values[8]; string order = values[9]; string wbs = values[10]; string sio = values[11]; string bpn = values[12]; if (!string.IsNullOrEmpty(fund) && !string.IsNullOrEmpty(cost)) { // cost center AccountType at = AccountType.GetByIdentification(1); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = fund; line["AccountNumber2"] = cost; line["AccountNumber3"] = sio; } else if (!string.IsNullOrEmpty(fund) && !string.IsNullOrEmpty(order)) { // real order AccountType at = AccountType.GetByIdentification(2); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = fund; line["AccountNumber2"] = order; string fundCenter = LineItem.GetFundCenter(order); if (!string.IsNullOrEmpty(fundCenter)) line["AccountNumber3"] = fundCenter; } else if (!string.IsNullOrEmpty(wbs)) { // wbs element AccountType at = AccountType.GetByIdentification(3); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = wbs; line["AccountNumber2"] = sio; } else if (!string.IsNullOrEmpty(bpn)) { // business partner number AccountType at = AccountType.GetByIdentification(4); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = bpn; } }
/// <summary> /// Add current .csv upload line item. /// </summary> /// <param name="values"></param> /// <param name="line">Current Line Item</param> /// <param name="pic">Line Item PIC</param> /// <param name="action"></param> private void AddLineActivateModify_csv(string[] values, DataRow line, Interface pic, TicketsBusiness.Action action) { // logic to fill activate/modify line data from csv row /* 0 = Line * 1 = Action * 2 = PIC * 3 = Speed * 4 = VLAN * 5 = Tagged VLANs * 6 = Services * 7 = Fund * 8 = Cost Center * 9 = Real Order * 10 = WBS * 11 = SIO * 12 = BPN * 13 = Repair Notes * 14 = Phone Only Connection */ // Check if the Line is a Phone Only Connection -- if So add different values if (values[14] == "Y".ToUpperInvariant()) AddPhoneOnly_csv(values, line, pic, action); else { line["LocationID"] = pic.Device.Room.LocationID; line["IsVoIP"] = false; if (values[3] != string.Empty) // Speed { InterfaceSpeed speed = InterfaceSpeedList.GetByCriteria(new InterfaceSpeedCriteria { Name = values[3] })[0]; line["InterfaceSpeedID"] = speed.Identification; line["SpeedName"] = speed.Name; } if (values[4] != string.Empty) // VLAN { Vlan vlan = VlanList.FetchByFriendlyName(values[4])[0]; line["NativeVLAN"] = vlan.Identification; line["NativeVLANName"] = vlan.FriendlyName + "<br />"; } // Tagged VLAN(s) string[] linevlans = values[5].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray(); List<int> vlans = new List<int>(); string vlansConcat = ""; foreach (string linevlan in linevlans) { Vlan vlanObj = VlanList.FetchByFriendlyName(linevlan)[0]; vlans.Add(vlanObj.Identification); vlansConcat += vlanObj.FriendlyName + "<br />"; } if (vlansConcat.Length > 2) vlansConcat = vlansConcat.Substring(0, vlansConcat.Length - 6); line["InterfaceVLANs"] = vlans; line["TaggedVlanNames"] = vlansConcat; // services string[] lineservices = values[6].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray(); List<int> services = new List<int>(); string servicesConcat = ""; foreach (string lineservice in lineservices) { Service serviceObj = ServiceList.GetByCriteria(new ServiceCriteria { Name = lineservice })[0]; services.Add(serviceObj.Identification); servicesConcat += serviceObj.Name + "<br />"; } if (servicesConcat.Length > 2) servicesConcat = servicesConcat.Substring(0, servicesConcat.Length - 6); line["InterfaceServiceAssignments"] = services; line["ServiceNames"] = servicesConcat; if (pic.BillingPlanID != null) line["prevBillingPlanID"] = pic.BillingPlanID; // Account string fund = values[7]; string cost = values[8]; string order = values[9]; string wbs = values[10]; string sio = values[11]; string bpn = values[12]; if (!string.IsNullOrEmpty(fund) && !string.IsNullOrEmpty(cost)) { // cost center AccountType at = AccountType.GetByIdentification(1); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = fund; line["AccountNumber2"] = cost; line["AccountNumber3"] = sio; } else if (!string.IsNullOrEmpty(fund) && !string.IsNullOrEmpty(order)) { // real order AccountType at = AccountType.GetByIdentification(2); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = fund; line["AccountNumber2"] = order; string fundCenter = LineItem.GetFundCenter(order); if (!string.IsNullOrEmpty(fundCenter)) line["AccountNumber3"] = fundCenter; } else if (!string.IsNullOrEmpty(wbs)) { // wbs element AccountType at = AccountType.GetByIdentification(3); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = wbs; line["AccountNumber2"] = sio; } else if (!string.IsNullOrEmpty(bpn)) { // business partner number AccountType at = AccountType.GetByIdentification(4); line["AccountTypeID"] = at.Identification; line["AccountTypeName"] = at.Name; line["AccountNumber1"] = bpn; } // check if only account changed bool isOnlyAccountChange = true; if (pic.InterfaceSpeedID != (int)line["InterfaceSpeedID"]) isOnlyAccountChange = false; if (vlans.Count + 1 != pic.InterfaceVLANs.Count) isOnlyAccountChange = false; else { foreach (int vlan in vlans) { if (!pic.InterfaceVLANs.Contains(pic.Identification, vlan)) { isOnlyAccountChange = false; break; } } } if (!pic.InterfaceVLANs.Contains(pic.Identification, (int) line["NativeVLAN"])) isOnlyAccountChange = false; else if (!pic.InterfaceVLANs.GetInterfaceVLAN(pic.Identification, (int) line["NativeVLAN"]).IsNative) isOnlyAccountChange = false; if (services.Count != pic.InterfaceServiceAssignments.Count) isOnlyAccountChange = false; else { foreach (int service in services) { if (!pic.InterfaceServiceAssignments.Contains(pic.Identification, service)) { isOnlyAccountChange = false; break; } } } if (action.Name != TicketsBusiness.Action.Modify) isOnlyAccountChange = false; line["IsOnlyAccountChange"] = isOnlyAccountChange; } // run special cases AddLineActivateModifySpecialCases(line); }
//--- Add Line Item for Active and/or Modify Line items private void AddLineActivateModify(DataRow drLine, Interface lineItemPic, TicketsBusiness.Action action) { AddLineGeneral(drLine, lineItemPic, action); drLine["LocationID"] = lineItemPic.Device.Room.LocationID; drLine["IsVoIP"] = false; // Set Speed if (ddlSpeed.SelectedIndex > 0) { InterfaceSpeed speed = InterfaceSpeed.GetByIdentification(int.Parse(ddlSpeed.SelectedValue)); drLine["InterfaceSpeedID"] = speed.Identification; drLine["SpeedName"] = speed.Name; } // Set selected native vlan. LineItemVLAN.SetNewNativeVlan(drLine, ddlVLAN); // Set selected tagged vlans. LineItemVLAN.SetNewTaggedVlans(drLine, lstVLAN); // Set if the native VLAN is trunk. drLine["isTrunk"] = chkTrunk.Checked; //--Services, check if PIC is in a VoIP Building--// List<int> services = new List<int>(); string servicesConcat = string.Empty; foreach (ListItem service in lstAdvanced.Items) { if (service.Selected) { services.Add(int.Parse(service.Value)); servicesConcat += service.Text + "<br />"; } } if (servicesConcat.Length > 2) servicesConcat = servicesConcat.Substring(0, servicesConcat.Length - 6); drLine["InterfaceServiceAssignments"] = services; drLine["ServiceNames"] = servicesConcat; if (ddlAccountType.SelectedIndex > 0) // Billing Account Information { AccountType at = AccountType.GetByIdentification(int.Parse(ddlAccountType.SelectedValue)); drLine["AccountTypeID"] = at.Identification; drLine["AccountTypeName"] = at.Name; // If Modify or Deactivate, Store Original Billing plan; otherwise ignore it if (string.IsNullOrEmpty(lineItemPic.BillingPlanID.ToString()) == false) { if (action.Identification == 2 || action.Identification == 3) { drLine["prevBillingPlanID"] = lineItemPic.BillingPlanID; } } switch (at.Identification) // Add Account Numbers Based on Type { case 1: // Cost Center { drLine["AccountNumber1"] = txtFund.Text.Trim(); drLine["AccountNumber2"] = txtCostCenter.Text.Trim(); drLine["AccountNumber3"] = txtSIO.Text.Trim(); break; } case 2: // Real order { drLine["AccountNumber1"] = txtFund.Text.Trim(); drLine["AccountNumber2"] = txtRealOrder.Text.Trim(); string fundCenter = LineItem.GetFundCenter(txtRealOrder.Text.Trim()); if (!string.IsNullOrEmpty(fundCenter)) drLine["AccountNumber3"] = fundCenter; break; } case 3: //. WBS Element { drLine["AccountNumber1"] = txtWBS.Text.Trim(); drLine["AccountNumber2"] = txtSIO.Text.Trim(); break; } case 4: //. Business Partner Number { drLine["AccountNumber1"] = txtBPN.Text.Trim(); break; } } } // Keep track of changes other than the account. bool isAccountChangeOnly = lineItemPic.InterfaceSpeedID == (int)drLine["InterfaceSpeedID"]; if (!lineItemPic.InterfaceVLANs.Contains(lineItemPic.Identification, (int)drLine["NativeVLAN"])) isAccountChangeOnly = false; else if (!lineItemPic.InterfaceVLANs.GetInterfaceVLAN(lineItemPic.Identification, (int) drLine["NativeVLAN"]).IsNative) isAccountChangeOnly = false; if (services.Count != lineItemPic.InterfaceServiceAssignments.Count) isAccountChangeOnly = false; else isAccountChangeOnly = services.Any(srvc => !lineItemPic.InterfaceServiceAssignments.Contains(lineItemPic.Identification, srvc)); if (action.Name != TicketsBusiness.Action.Modify) isAccountChangeOnly = false; drLine["IsOnlyAccountChange"] = isAccountChangeOnly; // run special cases AddLineActivateModifySpecialCases(drLine); }
// General Line Item Information that All Line Items Use private static void AddLineGeneral(DataRow drLine, Interface lineItemPic, TicketsBusiness.Action action) { // Deactivate == Special if (action.Identification == 3) { /*Set Basic Lines known not to be null*/ drLine["ActionID"] = action.Identification; drLine["ActionName"] = action.Name; drLine["InterfaceID"] = lineItemPic.Identification; drLine["PICID"] = lineItemPic.FriendlyLongName; // Check that Speed Exists to avoid thrown exceptions if (lineItemPic.InterfaceSpeed != null) { drLine["SpeedName"] = lineItemPic.InterfaceSpeed.Name; drLine["InterfaceSpeedID"] = lineItemPic.InterfaceSpeedID; } //Set Services (Advanced Column) if (lineItemPic.InterfaceServiceAssignments.Count > 0) { string servicesConcat = String.Empty; var services = new List<int>(); foreach (InterfaceServiceAssignment isa in lineItemPic.InterfaceServiceAssignments) { services.Add(isa.ServiceID); servicesConcat += isa.Service.Name + "<br />"; } if (servicesConcat.Length > 2) { servicesConcat = servicesConcat.Substring(0, servicesConcat.Length - 6); } drLine["InterfaceServiceAssignments"] = services; drLine["ServiceNames"] = servicesConcat; } // Find and Set Account Information int accountInfo = 0; // Cost Center if (!string.IsNullOrEmpty(lineItemPic.AccountFund) && !string.IsNullOrEmpty(lineItemPic.AccountCost)) accountInfo = 1; // Real Order. else if (!string.IsNullOrEmpty(lineItemPic.AccountFund) && !string.IsNullOrEmpty(lineItemPic.AccountOrder)) accountInfo = 2; // WBS Element else if (!string.IsNullOrEmpty(lineItemPic.AccountWBS)) accountInfo = 3; // Business Partner Number (BPN) else if (!string.IsNullOrEmpty(lineItemPic.AccountBusinessPartner)) accountInfo = 4; //Check account numbers. Store in the amdLineItems table for the save event. if (accountInfo != 0) { var at = AccountType.GetByIdentification(accountInfo); drLine["AccountTypeID"] = at.Identification; drLine["AccountTypeName"] = at.Name; switch (accountInfo) { case 1: // Cost Center { drLine["AccountNumber1"] = lineItemPic.AccountFund; drLine["AccountNumber2"] = lineItemPic.AccountCost; drLine["AccountNumber3"] = lineItemPic.AccountSIO; break; } case 2: // Real Order { drLine["AccountNumber1"] = lineItemPic.AccountFund; drLine["AccountNumber2"] = lineItemPic.AccountOrder; string fundCenter = LineItem.GetFundCenter(lineItemPic.AccountOrder); if (!string.IsNullOrEmpty(fundCenter)) drLine["AccountNumber3"] = fundCenter; break; } case 3: // WBS Element { drLine["AccountNumber1"] = lineItemPic.AccountWBS; drLine["AccountNumber2"] = lineItemPic.AccountSIO; break; } case 4: // Business Partner Number { drLine["AccountNumber1"] = lineItemPic.AccountBusinessPartner; break; } default: break; } } // Find Current VLANs and Set Trunk and Native VLAN(s) for deactivate line items. if (lineItemPic.InterfaceVLANs.Any()) { // Set native. LineItemVLAN.SetCurrentNativeVlan(lineItemPic, drLine); // Set tagged. LineItemVLAN.SetCurrentTaggedVlans(lineItemPic, drLine); } } else { // Used in all other create ticket events (Activate / Modify / Repair) drLine["ActionID"] = action.Identification; drLine["ActionName"] = action.Name; drLine["InterfaceID"] = lineItemPic.Identification; drLine["PICID"] = lineItemPic.FriendlyLongName; } }