public ResponseBo <PersonProductProfileBo> GetProfile(PersonProductProfileGetCriteriaBo criteriaBo) { if (criteriaBo.CaseId == 0 && (criteriaBo.PersonUrlName.IsNull() || criteriaBo.PersonUrlName.Trim().Length > 50)) { return(new ResponseBo <PersonProductProfileBo>() { IsSuccess = false, Message = Stc.GetDicValue("xNoShopFound", criteriaBo.Session.RealPerson.LanguageId) }); } else if (criteriaBo.CaseId == 1 && criteriaBo.PersonProductId.IsNull()) { return(new ResponseBo <PersonProductProfileBo>() { IsSuccess = false, Message = Stc.GetDicValue("xInvalidData", criteriaBo.Session.RealPerson.LanguageId) }); } ResponseBo <PersonProductProfileBo> responseBo = new ResponseBo <PersonProductProfileBo>(); try { using (SqlConnection conn = DbAccess.Connection.GetConn()) { var p = new DynamicParameters(); p.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 255); p.Add("@IsSuccess", dbType: DbType.Boolean, direction: ParameterDirection.Output); p.Add("@CaseId", criteriaBo.CaseId, DbType.Int32, ParameterDirection.Input); p.Add("@PersonUrlName", criteriaBo.PersonUrlName, DbType.String, ParameterDirection.Input, 50); p.Add("@ProductCode", criteriaBo.ProductCode, DbType.String, ParameterDirection.Input, 50); p.Add("@PersonProductId", criteriaBo.PersonProductId, DbType.Int64, ParameterDirection.Input); p.Add("@MyPersonId", criteriaBo.Session.MyPerson.Id, DbType.Int64, ParameterDirection.Input); p.Add("@OperatorRealId", criteriaBo.Session.RealPerson.Id, DbType.Int64, ParameterDirection.Input); p.Add("@LanguageId", criteriaBo.Session.RealPerson.LanguageId, DbType.Int32, ParameterDirection.Input); responseBo.Bo = conn.Query <PersonProductProfileBo>("spPersonProductProfileGet", p, commandType: CommandType.StoredProcedure).FirstOrDefault(); responseBo.Message = p.Get <string>("@Message"); responseBo.IsSuccess = p.Get <bool>("@IsSuccess"); if (responseBo.Bo != null) { if (responseBo.Bo.CodeListRawJson.IsNotNull()) { responseBo.Bo.CodeList = JsonConvert.DeserializeObject <List <ProductCodeBo> >(responseBo.Bo.CodeListRawJson); } } } } catch (Exception ex) { responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, null).ToResponse <PersonProductProfileBo>(); } return(responseBo); }
public ResponseBo SaveOrderArea(ShopOrderAreaBo saveBo) { if (saveBo == null || saveBo.SubList == null || saveBo.SubList.Count == 0) { return(new ResponseBo() { IsSuccess = false, Message = Stc.GetDicValue("xInvalidData", saveBo.Session.RealPerson.LanguageId) }); } ResponseBo responseBo = new ResponseBo(); try { using (SqlConnection conn = DbAccess.Connection.GetConn()) { var p = new DynamicParameters(); p.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 255); p.Add("@IsSuccess", dbType: DbType.Boolean, direction: ParameterDirection.Output); p.Add("@ReturnedId", dbType: DbType.Int64, direction: ParameterDirection.Output); p.Add("@Id", saveBo.Id, DbType.Int64, ParameterDirection.Input); p.Add("PersonId", saveBo.PersonId, DbType.Int64, ParameterDirection.Input); p.Add("@AddressBoundaryId", saveBo.AddressBoundaryId, DbType.Int32, ParameterDirection.Input); p.Add("@AddressCountryId", saveBo.AddressCountryId, DbType.Int32, ParameterDirection.Input); p.Add("@AddressStateId", saveBo.AddressStateId, DbType.Int32, ParameterDirection.Input); p.Add("@AddressCityId", saveBo.AddressCityId, DbType.Int32, ParameterDirection.Input); p.Add("@AddressDistrictId", saveBo.AddressDistrictId, DbType.Int32, ParameterDirection.Input); p.Add("@CurrencyId", saveBo.CurrencyId, DbType.Int32, ParameterDirection.Input); p.Add("@OrderDeliveryTypeId", saveBo.OrderDeliveryTypeId, DbType.Int32, ParameterDirection.Input); p.Add("@SubListRawJson", JsonConvert.SerializeObject(saveBo.SubList), DbType.String, ParameterDirection.Input, 4000); p.Add("@MyPersonId", saveBo.Session.MyPerson.Id, DbType.Int64, ParameterDirection.Input); p.Add("@OperatorRealId", saveBo.Session.RealPerson.Id, DbType.Int64, ParameterDirection.Input); p.Add("@LanguageId", saveBo.Session.RealPerson.LanguageId, DbType.Int32, ParameterDirection.Input); var user = conn.Execute("spPersonOrderAreaSave", p, commandType: CommandType.StoredProcedure); responseBo.Message = p.Get <string>("@Message"); responseBo.IsSuccess = p.Get <bool>("@IsSuccess"); responseBo.ReturnedId = p.Get <long?>("@ReturnedId"); } } catch (Exception ex) { responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, saveBo); } return(responseBo); }
public void Run() { Stc.Init(); const bool ENABLE_CAPTURE = true; string StcVersion = Stc.Get("system1", "Version"); Console.WriteLine("SpirentTestCenter system version:\t" + StcVersion); // Physical topology string szChassisIp1 = "10.29.0.49"; string szChassisIp2 = "10.29.0.45"; string txPortLoc = String.Format("//{0}/1/1", szChassisIp1); string rxPortLoc = String.Format("//{0}/1/1", szChassisIp2); // Create the root project object Console.WriteLine("Creating project ..."); string hProject = Stc.Create("project", "system1"); // Create ports Console.WriteLine("Creating ports ..."); string hPortTx = Stc.Create("port", hProject); string hPortRx = Stc.Create("port", hProject); Dictionary <string, string> sm = new Dictionary <string, string>(); sm.Clear(); sm["location"] = txPortLoc; sm["useDefaultHost"] = "False"; Stc.Config(hPortTx, sm); sm.Clear(); sm["location"] = rxPortLoc; sm["useDefaultHost"] = "False"; Stc.Config(hPortRx, sm); // Configure ethernet Fiber interface. Stc.Create("EthernetCopper", hPortTx); // Attach to ports. Console.WriteLine("Attaching to ports {0} and {1}", txPortLoc, rxPortLoc); Stc.Perform("AttachPorts"); // Apply the configuration. Console.WriteLine("Apply configuration"); Stc.Apply(); // Initialize generator/analyzer. string hGenerator = Stc.Get(hPortTx, "children-Generator"); string generatorState = Stc.Get(hGenerator, "state"); Console.WriteLine("Stopping Generator -current state " + generatorState); sm.Clear(); sm["generatorList"] = hGenerator; Stc.Perform("generatorStop", sm); string hAnalyzer = Stc.Get(hPortRx, "children-Analyzer"); string analyzerState = Stc.Get(hAnalyzer, "state"); Console.WriteLine("Stopping Analyzer -current state " + analyzerState); sm.Clear(); sm["analyzerList"] = hAnalyzer; Stc.Perform("analyzerStop", sm); // Create a stream block. FrameConfig with blank double quotes Clears the frame out. Console.WriteLine("Configuring stream block ..."); string hStreamBlock = Stc.Create("streamBlock", hPortTx); sm.Clear(); sm["insertSig"] = "true"; sm["frameConfig"] = ""; sm["frameLengthMode"] = "FIXED"; sm["maxFrameLength"] = "1200"; sm["FixedFrameLength"] = "256"; Stc.Config(hStreamBlock, sm); // Add an EthernetII Protocol Data Unit (PDU). Console.WriteLine("Adding headers"); string ethPDU = Stc.Create("ethernet:EthernetII", hStreamBlock); sm.Clear(); sm["name"] = "sb1_eth"; sm["srcMac"] = "00:00:20:00:00:00"; sm["dstMac"] = "00:00:00:00:00:00"; Stc.Config(ethPDU, sm); // Use modifier to generate multiple streams. Console.WriteLine("Creating Modifier on Stream Block ..."); string hRangeModifier = Stc.Create("RangeModifier", hStreamBlock); sm.Clear(); sm["ModifierMode"] = "INCR"; sm["Mask"] = "0000FFFFFFFF"; sm["StepValue"] = "000000000001"; sm["Data"] = "000000000000"; sm["RecycleCount"] = "4294967295"; sm["RepeatCount"] = "0"; sm["DataType"] = "BYTE"; sm["EnableStream"] = "FALSE"; sm["Offset"] = "0"; sm["OffsetReference"] = "sb1_eth.dstMac"; Stc.Config(hRangeModifier, sm); // Configure generator Console.WriteLine("Configuring Generator"); string hGeneratorConfig = Stc.Get(hGenerator, "children-GeneratorConfig"); sm.Clear(); sm["DurationMode"] = "SECONDS"; sm["BurstSize"] = "1"; sm["Duration"] = "100"; sm["LoadMode"] = "FIXED"; sm["FixedLoad"] = "25"; sm["LoadUnit"] = "PERCENT_LINE_RATE"; sm["SchedulingMode"] = "PORT_BASED"; Stc.Config(hGeneratorConfig, sm); // Analyzer Configuration Console.WriteLine("Configuring Analyzer"); string hAnalyzerConfig = Stc.Get(hAnalyzer, "children-AnalyzerConfig"); // Subscribe to realtime results Console.WriteLine("Subscribe to results"); sm.Clear(); sm["Parent"] = hProject; sm["ConfigType"] = "Analyzer"; sm["resulttype"] = "AnalyzerPortResults"; sm["filenameprefix"] = "Analyzer_Port_Results"; Stc.Subscribe(sm); sm.Clear(); sm["Parent"] = hProject; sm["ConfigType"] = "Generator"; sm["resulttype"] = "Generator"; sm["filenameprefix"] = "Generator_Port_Counter"; Stc.Subscribe(sm); // Configure Capture. string hCapture = ""; if (ENABLE_CAPTURE) { Console.WriteLine("\nStarting Capture..."); // Create a capture object. Automatically created. hCapture = Stc.Get(hPortRx, "children-capture"); sm.Clear(); sm["mode"] = "REGULAR_MODE"; sm["srcMode"] = "TX_RX_MODE"; Stc.Config(hCapture, sm); sm.Clear(); sm["captureProxyId"] = hCapture; Stc.Perform("CaptureStart", sm); } // Apply configuration. Console.WriteLine("Apply configuration"); Stc.Apply(); // Save the configuration as an XML file for later import into the GUI. Console.WriteLine("\nSave configuration as an XML file."); Stc.Perform("SaveAsXml"); // Start the analyzer and generator. Console.WriteLine("Start Analyzer"); sm.Clear(); sm["AnalyzerList"] = hAnalyzer; Stc.Perform("AnalyzerStart", sm); analyzerState = Stc.Get(hAnalyzer, "state"); Console.WriteLine("Current analyzer state " + analyzerState); Thread.Sleep(2000); Console.WriteLine("Start Generator"); sm.Clear(); sm["GeneratorList"] = hGenerator; Stc.Perform("GeneratorStart", sm); generatorState = Stc.Get(hGenerator, "state"); Console.WriteLine("Current generator state " + generatorState); Console.WriteLine("Wait 5 seconds ..."); Thread.Sleep(5000); analyzerState = Stc.Get(hAnalyzer, "state"); generatorState = Stc.Get(hGenerator, "state"); Console.WriteLine("Current analyzer state " + analyzerState); Console.WriteLine("Current generator state " + generatorState); // Stop the analyzer. Console.WriteLine("Stop Analyzer"); sm.Clear(); sm["AnalyzerList"] = hAnalyzer; Stc.Perform("AnalyzerStop", sm); Thread.Sleep(1000); // Display some statistics. Console.WriteLine("Frames Counts:"); // Example of Direct-Descendant Notation ( DDN ) syntax. ( DDN starts with an object reference ) string sigFrameCount = Stc.Get(String.Format("{0}.AnalyzerPortResults(1)", hAnalyzer), "sigFrameCount"); string totalFrameCount = Stc.Get(String.Format("{0}.AnalyzerPortResults(1)", hAnalyzer), "totalFrameCount"); Console.WriteLine("\tSignature frames: {0}", sigFrameCount); Console.WriteLine("\tTotal frames: {0}", totalFrameCount); // Example of Descendant-Attribute Notation ( DAN ) syntax. ( using explicit indeces ) string minFrameLength = Stc.Get(hPortRx, "Analyzer(1).AnalyzerPortResults(1).minFrameLength"); Console.WriteLine("\tMinFrameLength: {0}", minFrameLength); // Notice indexing is not necessary since there is only 1 child. string maxFrameLength = Stc.Get(hPortRx, "Analyzer.AnalyzerPortResults.maxFrameLength"); Console.WriteLine("\tMaxFrameLength: {0}", maxFrameLength); if (ENABLE_CAPTURE) { Console.WriteLine("Retrieving Captured frames..."); sm.Clear(); sm["captureProxyId"] = hCapture; Stc.Perform("CaptureStop", sm); // Save captured frames to a file. sm.Clear(); sm["captureProxyId"] = hCapture; sm["FileName"] = "capture.pcap"; sm["FileNameFormat"] = "PCAP"; sm["IsScap"] = "FALSE"; Stc.Perform("CaptureDataSave", sm); string capPackets = Stc.Get(hCapture, "PktCount"); Console.WriteLine("Captured frames:\t" + capPackets); } // Disconnect from chassis, release ports, and reset configuration. Console.WriteLine("Release ports and disconnect from chassis"); Stc.Perform("ChassisDisconnectAll"); Stc.Perform("ResetConfig"); // Delete configuration Console.WriteLine("Deleting project"); Stc.Delete(hProject); }