private void BindAbilityLevelsToDoubleListBox(OccurrenceTypeAttribute ota) { LookupCollection allAbilityLevels = new LookupCollection(Convert.ToInt32(LookupTypeIDSetting)); LookupCollection availableAbilityLevels = new LookupCollection(); LookupCollection selectedAbilityLevels = new LookupCollection(); foreach (Lookup abilityLevel in allAbilityLevels) { if (ota.AbilityLevelLookupIDs.Contains(abilityLevel.LookupID)) { selectedAbilityLevels.Add(abilityLevel); } else { availableAbilityLevels.Add(abilityLevel); } } dlbAbilityLevels.ListBoxRight.DataSource = selectedAbilityLevels; dlbAbilityLevels.ListBoxRight.DataTextField = "Value"; dlbAbilityLevels.ListBoxRight.DataValueField = "LookupID"; dlbAbilityLevels.ListBoxRight.DataBind(); dlbAbilityLevels.ListBoxLeft.DataSource = availableAbilityLevels; dlbAbilityLevels.ListBoxLeft.DataTextField = "Value"; dlbAbilityLevels.ListBoxLeft.DataValueField = "LookupID"; dlbAbilityLevels.ListBoxLeft.DataBind(); }
private bool CheckIfEndTerminalIsWithinRackEquipment(LookupCollection <TerminalEquipmentSpecification> terminalEquipmentSpecifications, IGraphObject[] graphObjects) { if (graphObjects.Length > 0) { var upstreamTerminal = graphObjects.Last(); if (upstreamTerminal != null) { if (_utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphTerminalRef>(upstreamTerminal.Id, out var terminalRef)) { if (!terminalRef.IsDummyEnd) { var terminalEquipment = terminalRef.TerminalEquipment(_utilityNetwork); var spec = terminalEquipmentSpecifications[terminalEquipment.SpecificationId]; if (spec.IsRackEquipment) { return(true); } } } } } return(false); }
/* public static LookupCollection countRawFiles(string fileXml,out int nRawfiles) * { * * //Initialize necessary objets for XML reading * XmlTextReader reader = new XmlTextReader(fileXml); * XmlNodeType nType = reader.NodeType; * XmlDocument xmldoc = new XmlDocument(); * xmldoc.Load(reader); * * //Initialize the AminoacidList[] tAaList * XmlNodeList xmlnodeMatch = xmldoc.GetElementsByTagName("peptide_match"); * * //Need the Rawfile names * LookupCollection rawFilesColl = new LookupCollection(); * * string rawFileName; * nRawfiles = 0; * foreach (XmlNode node in xmlnodeMatch) * { * foreach (XmlNode chNode in node.ChildNodes) * { * if (chNode.Name == "RAWFileName") * { * rawFileName = chNode.InnerText.ToString().Trim(); * * if (!rawFilesColl.Contains(rawFileName)) * { * int initScansNum = 1; * rawFilesColl.Add(rawFileName, initScansNum); * } * else * { * int oneMore = (int)rawFilesColl[rawFileName] + 1; * rawFilesColl[rawFileName] = oneMore; * } * * } * } * } * nRawfiles = rawFilesColl.Count; * * return rawFilesColl; * * } */ public static LookupCollection countRawFiles(DataView _quiXMLv, out int nRawfiles) { //Need the Rawfile names LookupCollection rawFilesColl = new LookupCollection(); string rawFileName; nRawfiles = 0; for (int i = 0; i < _quiXMLv.Count; i++) { rawFileName = _quiXMLv[i]["RAWFileName"].ToString().Trim(); if (!rawFilesColl.Contains(rawFileName)) { int initScansNum = 1; rawFilesColl.Add(rawFileName, initScansNum); } else { int oneMore = (int)rawFilesColl[rawFileName] + 1; rawFilesColl[rawFileName] = oneMore; } } nRawfiles = rawFilesColl.Count; return(rawFilesColl); }
private static LookupCollection RawFilesinFrame(binFrame frame, out int nRawfiles) { //Need the Rawfile names LookupCollection rawFilesColl = new LookupCollection(); string rawFileName; nRawfiles = 0; for (int i = frame.scan.GetLowerBound(0); i <= frame.scan.GetUpperBound(0); i++) { if (frame.scan[i].rawFileName != null) { rawFileName = frame.scan[i].rawFileName.Trim(); if (!rawFilesColl.Contains(rawFileName)) { int initScansNum = 1; rawFilesColl.Add(rawFileName, initScansNum); } else { int oneMore = (int)rawFilesColl[rawFileName] + 1; rawFilesColl[rawFileName] = oneMore; } } } nRawfiles = rawFilesColl.Count; return(rawFilesColl); }
public LookupCollection FetchAll() { LookupCollection coll = new LookupCollection(); Query qry = new Query(Lookup.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public InvestorConfigurationController() { _productServiceFacade = new ProductServiceFacade(); _userAccountId = IdentityManager.GetUserAccountId(); _extensionDaysLookup = LookupServiceFacade.Lookup("investorextdays", _userAccountId); _extensionPoliciesLookup = LookupServiceFacade.Lookup("investorextpolicies", _userAccountId); }
public Result PlaceNodeContainerInRouteNetworkNode( CommandContext cmdContext, LookupCollection <NodeContainer> nodeContainers, LookupCollection <NodeContainerSpecification> nodeContainerSpecifications, Guid nodeContainerId, Guid nodeContainerSpecificationId, RouteNetworkInterest nodeOfInterest, NamingInfo?namingInfo, LifecycleInfo?lifecycleInfo, Guid?manufacturerId ) { this.Id = nodeContainerId; if (nodeContainerId == Guid.Empty) { return(Result.Fail(new PlaceNodeContainerInRouteNetworkError(PlaceNodeContainerInRouteNetworkErrorCodes.INVALID_NODE_CONTAINER_ID_CANNOT_BE_EMPTY, "Node container id cannot be empty. A unique id must be provided by client."))); } if (nodeContainers.ContainsKey(nodeContainerId)) { return(Result.Fail(new PlaceNodeContainerInRouteNetworkError(PlaceNodeContainerInRouteNetworkErrorCodes.INVALID_NODE_CONTAINER_ID_ALREADY_EXISTS, $"A node container with id: {nodeContainerId} already exists."))); } if (nodeOfInterest.Kind != RouteNetworkInterestKindEnum.NodeOfInterest) { return(Result.Fail(new PlaceNodeContainerInRouteNetworkError(PlaceNodeContainerInRouteNetworkErrorCodes.INVALID_INTEREST_KIND_MUST_BE_NODE_OF_INTEREST, "Interest kind must be NodeOfInterest. You can only put node container into route nodes!"))); } if (!nodeContainerSpecifications.ContainsKey(nodeContainerSpecificationId)) { return(Result.Fail(new PlaceNodeContainerInRouteNetworkError(PlaceNodeContainerInRouteNetworkErrorCodes.INVALID_NODE_CONTAINER_SPECIFICATION_ID_NOT_FOUND, $"Cannot find node container specification with id: {nodeContainerSpecificationId}"))); } if (nodeContainers.Any(n => n.RouteNodeId == nodeOfInterest.RouteNetworkElementRefs[0])) { return(Result.Fail(new PlaceNodeContainerInRouteNetworkError(PlaceNodeContainerInRouteNetworkErrorCodes.NODE_CONTAINER_ALREADY_EXISTS_IN_ROUTE_NODE, $"A node container already exist in the route node with id: {nodeOfInterest.RouteNetworkElementRefs[0]} Only one node container is allowed per route node."))); } var nodeContainer = new NodeContainer(nodeContainerId, nodeContainerSpecificationId, nodeOfInterest.Id, nodeOfInterest.RouteNetworkElementRefs[0]) { ManufacturerId = manufacturerId, NamingInfo = namingInfo, LifecycleInfo = lifecycleInfo }; var nodeContainerPlaceInRouteNetworkEvent = new NodeContainerPlacedInRouteNetwork(nodeContainer) { CorrelationId = cmdContext.CorrelationId, IncitingCmdId = cmdContext.CmdId, UserName = cmdContext.UserContext?.UserName, WorkTaskId = cmdContext.UserContext?.WorkTaskId }; RaiseEvent(nodeContainerPlaceInRouteNetworkEvent); return(Result.Ok()); }
public CableSpanEquipmentImporter(ILogger <ConduitSpanEquipmentImporter> logger, IEventStore eventSTore, GeoDatabaseSetting geoDatabaseSettings, ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) : base(geoDatabaseSettings) { _logger = logger; _eventStore = eventSTore; _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; _utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>(); _spanEquipmentSpecifications = _eventStore.Projections.Get <SpanEquipmentSpecificationsProjection>().Specifications; }
private void BindLists() { PersonEmailCollection emails = GetPerson().Emails; if (emails.Count > 0) { LookupCollection mailChimpLists = new LookupCollection(new Guid(MailChimpLookupGUIDSetting)); dlLists.DataSource = mailChimpLists; dlLists.DataBind(); } }
public static binStack[] genIndex(DataView _quiXMLv, string rawPath, int scansbyframe, BinStackOptions options) { int numMatches = _quiXMLv.Count; int numFrames = countFrames(_quiXMLv, scansbyframe); int numRawFiles; //LookupCollection RawFilesColl = countRawFiles(fileXml, out numRawFiles); LookupCollection RawFilesColl = countRawFiles(_quiXMLv, out numRawFiles); //create index binStack[] stackIndex = new binStack[numRawFiles]; //fill rawfilenames in the index ArrayList rawFilesKeys = (ArrayList)RawFilesColl.Keys; ArrayList rawFilesValues = (ArrayList)RawFilesColl.Values; for (int i = 0; i < numRawFiles; i++) { stackIndex[i] = new binStack((int)rawFilesValues[i]); stackIndex[i].rawFileName = rawFilesKeys[i].ToString(); } fillScans(stackIndex, _quiXMLv, options); //share out the spectra amongst the frames int currFrame = 1; int currScanofFrame = 1; for (int i = 0; i < numRawFiles; i++) { for (int j = 0; j <= stackIndex[i].scan.GetUpperBound(0); j++) { stackIndex[i].scan[j].frame = currFrame; currScanofFrame++; if (currScanofFrame > scansbyframe) { currFrame++; currScanofFrame = 1; } } } //WARNING: very dangerous change, but necessary to maintain old binstacks: in currFrame // we swap the values of scanNumber by spectrumIndex (once we have obtained the desired // spectrum, we use the unique index (spectrumIndex). return(stackIndex); }
/// <summary> /// LookupStates /// </summary> /// <param name="loanType"></param> /// <param name="userAccountId"></param> /// <returns></returns> public static LookupCollection LookupStates(LoanTransactionType loanType, Int32 userAccountId) { /// TODO: THIS IS ONLY TEMPORARY FOR CLIENT TO GET TEST DOCUMENT THIS NEEDS TO BE REFACTORED CORRECTLY /// THESE VALUES SHOULD BE STORED IN DATABASE !!!!! /// ADDED STATES WA, UT, OR String[] purchaseStateList = { "CA", "CO", "FL", "HI", "ID", "NM", "TX", "WA", "UT", "OR" }; LookupCollection purchaseStates = new LookupCollection(); purchaseStates.AddRange(LookupServiceFacade.LookupStates(userAccountId).Where(l => purchaseStateList.Contains(l.Name)).ToArray()); return(loanType == LoanTransactionType.Purchase ? purchaseStates : LookupServiceFacade.LookupStates(userAccountId)); }
/// <summary> /// Runs upon page load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { _editEnabled = CurrentModule.Permissions.Allowed(Arena.Security.OperationType.Edit, CurrentUser); _pledgeId = !string.IsNullOrEmpty(Request.QueryString["pledge"]) ? Convert.ToInt32(Request.QueryString["pledge"]) : -1; // Put a bit of space at the top of the <asp:Panel ID="DataPanel"> control DataPanel.Attributes.Add("style", "margin-top:1em;"); // Add onfocus event to tbFrequencyCount that calculates totals tbFrequencyCount.Attributes.Add("onfocus", "getTimeSpans()"); // If not postback, set up form if (!Page.IsPostBack) { // Construct a fund collection to populate the fund drop down list FundCollection funds = new FundCollection(CurrentOrganization.OrganizationID); ddlFund.DataSource = funds; ddlFund.DataTextField = "FundName"; ddlFund.DataValueField = "FundId"; ddlFund.DataBind(); ddlFund.Items.Insert(0, new ListItem("", "-1")); // Set the selected fund to the defined module setting ddlFund.SelectedValue = DefaultFundSetting; // Construct campus drop down list from Arena lookup type 102, which is campus designations LookupCollection campuses = new LookupCollection(102); // Bind campus lookup key / values pairs to dropdown datasource ddlCampus.DataSource = campuses; ddlCampus.DataValueField = "LookupID"; ddlCampus.DataTextField = "Value"; ddlCampus.DataBind(); ddlCampus.Items.Insert(0, new ListItem("", "-1")); // Bind frequency dictionary to frequency dropdown datasource. rblPledgeFrequency.DataSource = PledgeFrequency.FrequencyNames; rblPledgeFrequency.DataValueField = "Key"; rblPledgeFrequency.DataTextField = "Value"; rblPledgeFrequency.DataBind(); rblPledgeFrequency.SelectedIndex = 2; foreach (ListItem li in rblPledgeFrequency.Items) { //if( "RadioButton".Equals(ctrl.GetType().ToString() ) ) // ((RadioButton)ctrl).Attributes["onfocus"] = "getTimeSpans()"; li.Attributes["onfocus"] = "getTimeSpans()"; } // Initially set focus on name text box tbName.Focus(); } }
private int _sequence = 3; // compressed audio packets start after the headers with sequence number 3 private ProcessingState( VorbisInfo vorbisInfo, LookupCollection lookups, float[][] pcm, int[] window, int centerWindow) { _vorbisInfo = vorbisInfo; _lookups = lookups; _pcm = pcm; _window = window; _centerWindow = centerWindow; }
/// <summary> /// Utility method to fetch an Arena newsletter which corresponds to the given MailChimp List. /// </summary> /// <param name="listID">List ID of a MailChimp list</param> /// <returns>newsletterID of a corresponding Arena newsletter; otherwise returns -1.</returns> private int GetNewsletterIDFromMailChimpListID(string listID) { int newsletterID = -1; LookupCollection mailChimpLists = new LookupCollection(new Guid(MailChimpLookupGUIDSetting)); var query = (from lookup in mailChimpLists.OfType <Lookup>() where lookup.Qualifier == listID select lookup).FirstOrDefault(); if (query != null) { newsletterID = int.Parse(query.Qualifier2); } return(newsletterID); }
private LookupCollection InitializeCollection(DataTable dt) { LookupCollection retVal = null; if (dt != null && dt.Columns.Count > 0) { retVal = new LookupCollection(); foreach (DataRow row in dt.Rows) { Lookup item = InitializeObject(row); retVal.Add(item); } } return(retVal); }
/// <summary> /// Save the information about a given peer. In a VoIP PBX system a peer is a physical /// device. A person may have multiple peers associated with him/her. For example I /// have a physical desk phone (first peer), a VoIP client on my iPhone (second peer). /// This method has been written on the assumption that I only care about my primary /// (desk phone) peer. We name our SIP peers after the extension, so my extension of /// 268 has a peer defined as "268". /// </summary> /// <param name="organizationId">The organization we are currently working in.</param> /// <param name="extensionRules">A collection of Lookups to use in matching this peer to a person.</param> /// <param name="objectName">The name of this peer object.</param> /// <param name="acl">Not a clue.</param> /// <param name="dynamic">If this is a dynamic (i.e. DHCP) peer.</param> /// <param name="natSupport">Does the peer support NAT?</param> /// <param name="ip">IP address of the peer.</param> /// <param name="type">The type of peer, e.g. SIP or IAX2.</param> private void SavePeer(int organizationId, LookupCollection extensionRules, string objectName, bool acl, bool dynamic, bool natSupport, string ip, string type) { string internalNumber = objectName; // // Match this peer to a extension and build internalNumber // to be the full phone number to reach this peer. // foreach (Lookup rule in extensionRules) { if (Regex.Match(objectName, rule.Qualifier).Success) { if (rule.Qualifier3 != string.Empty) { internalNumber = rule.Qualifier3.Replace("##orig##", objectName); } } } // // Find a person who has this exact phone number. If more than one person // is found, the first match is used. // PersonCollection peerPersons = new PersonCollection(); peerPersons.LoadByPhone(internalNumber); if (peerPersons.Count > 0) { // // Save the new Phone Peer object, which associates a physical phone to a person. // Arena.Phone.Peer peer = new Arena.Phone.Peer(objectName); peer.PersonId = peerPersons[0].PersonID; peer.Acl = acl; peer.Dynamic = dynamic; peer.NatSupport = natSupport; peer.Ip = ip; peer.ObjectName = objectName; peer.Type = type; peer.OrganizationId = organizationId; peer.InternalNumber = internalNumber; peer.LastAuditId = _sessionGuid; peer.Save("voipManager"); } }
public static LookupCollection countRawFiles(string fileXml, out int nRawfiles) { //Initialize necessary objets for XML reading XmlTextReader reader = new XmlTextReader(fileXml); XmlNodeType nType = reader.NodeType; XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(reader); //Initialize the AminoacidList[] tAaList XmlNodeList xmlnodeMatch = xmldoc.GetElementsByTagName("peptide_match"); //Need the Rawfile names LookupCollection rawFilesColl = new LookupCollection(); string rawFileName; nRawfiles = 0; foreach (XmlNode node in xmlnodeMatch) { foreach (XmlNode chNode in node.ChildNodes) { if (chNode.Name == "RAWFileName") { rawFileName = chNode.InnerText.ToString().Trim(); if (!rawFilesColl.Contains(rawFileName)) { int initScansNum = 1; rawFilesColl.Add(rawFileName, initScansNum); } else { int oneMore = (int)rawFilesColl[rawFileName] + 1; rawFilesColl[rawFileName] = oneMore; } } } } nRawfiles = rawFilesColl.Count; return(rawFilesColl); }
public static binStack[] genIndex(string fileXml, string schemaFile, string rawPath, int scansbyframe, BinStackOptions options) { int numMatches = countMatches(fileXml); int numFrames = countFrames(fileXml, scansbyframe); int numRawFiles; LookupCollection RawFilesColl = countRawFiles(fileXml, out numRawFiles); //create index binStack[] stackIndex = new binStack[numRawFiles]; //fill rawfilenames in the index ArrayList rawFilesKeys = (ArrayList)RawFilesColl.Keys; ArrayList rawFilesValues = (ArrayList)RawFilesColl.Values; for (int i = 0; i < numRawFiles; i++) { stackIndex[i] = new binStack((int)rawFilesValues[i]); stackIndex[i].rawFileName = rawFilesKeys[i].ToString(); } fillScans(stackIndex, fileXml, schemaFile, options); //share out the spectra amongst the frames int currFrame = 1; int currScanofFrame = 1; for (int i = 0; i < numRawFiles; i++) { for (int j = 0; j <= stackIndex[i].scan.GetUpperBound(0); j++) { stackIndex[i].scan[j].frame = currFrame; currScanofFrame++; if (currScanofFrame > scansbyframe) { currFrame++; currScanofFrame = 1; } } } return(stackIndex); }
protected void Page_Load(object sender, System.EventArgs e) { if (CurrentPerson == null || CurrentPerson.PersonID == -1) { throw new ArenaApplicationException("SpeedDialer module requires that a user be logged in. Please configure security so that only 'registered' users have access to this page."); } if (CurrentPerson.Peers.Count > 0) { string phoneTagName = CurrentOrganization.Settings["PBXPersonalListTagName"]; if (phoneTagName != null) { ProfileCollection personalTags = new ProfileCollection(); personalTags.LoadChildProfileHierarchy(-1, CurrentOrganization.OrganizationID, ProfileType.Personal, CurrentPerson.PersonID); Arena.Core.Profile contactList = GetContactList(personalTags, phoneTagName.Trim().ToLower()); if (contactList != null) { lTagName.Text = contactList.Title; extensionRules = new LookupType(SystemLookupType.PhoneInternalExtensionRules).Values; PBXSystem = PBXHelper.DefaultPBXSystem(CurrentOrganization); manager = PBXHelper.GetPBXClass(PBXSystem); lvContacts.DataSource = contactList.Members; lvContacts.DataBind(); } else { this.Visible = false; } } else { this.Visible = false; } } else { this.Visible = false; } }
private static void CreateDropDownList(PersonAttribute attribute, string cssClass, Control parentContainer, bool setValue, bool enabled) { DynamicDropDownList ddl = new DynamicDropDownList(); parentContainer.Controls.Add(ddl); ddl.ID = GetControlID(attribute); ddl.CssClass = cssClass; ddl.Enabled = enabled; LookupCollection lookups = new LookupCollection(int.Parse(attribute.TypeQualifier)); lookups.LoadDropDownList(ddl); ddl.Items.Insert(0, DynamicDropDownList.GetDefaultSelectItem()); if (setValue) { ddl.ClearSelection(); ddl.SelectedValue = attribute.IntValue.ToString(); } }
/// <summary> /// GetZipData /// </summary> /// <param name="zipCode"></param> /// <param name="loanType"></param> /// <param name="userAccountId"></param> /// <returns></returns> public static ZipDataItem GetZipData(String zipCode, LoanTransactionType loanType, Int32 userAccountId, int?conciergeId = null, bool isForEquatorState = false, Int32 homeBuyingType = 0) { var zipData = UsaZipFacade.GetZipData(zipCode, false); var isCallCenter = IdentityManager.IsInRole(RoleName.LoanProcessor); LookupCollection licStates = null; var errorMessage = "Your zip is not supported."; if (( HomeBuyingType )homeBuyingType == HomeBuyingType.WhatCanIAfford) { licStates = LicenseHelper.GetAffordabilityLicensedStates(); errorMessage = "Zip is currently not supported."; } else { licStates = LicenseHelper.GetLicensedStates(LookupStates(loanType, userAccountId), isCallCenter, conciergeId, IdentityManager.IsAuthorizedForAction(ActionCategory.ObtainingLoanApplicationinformation), isForEquatorState); } if (zipData != null) { var contains = licStates.FirstOrDefault(l => l.Name == zipData.State); if (contains == null) { zipData.City = String.Empty; zipData.County = String.Empty; zipData.State = String.Empty; zipData.ErrorMessage = errorMessage; } } else { zipData = new ZipDataItem() { ErrorMessage = "Invalid zip code." }; } return(zipData); }
protected void Page_Load(object sender, EventArgs e) { LookupCollection validNumbers = new LookupCollection(new Guid("11B4ADEC-CB8C-4D01-B99E-7A0FFE2007B5")); StringBuilder sb = new StringBuilder(); foreach (String s in AllowedPhoneNumbersSetting.Split(',')) { Lookup lk = new Lookup(Convert.ToInt32(s)); sb.AppendLine(String.Format("ddl.append('<option value=\"{0}\">{1}</option>');", Arena.Custom.HDC.Twilio.TwilioSMS.CleanPhone(lk.Qualifier), Server.HtmlEncode(lk.Value))); } ltSelect.Text = sb.ToString(); if (!String.IsNullOrEmpty(Request.Params["MEDIUM"]) && Request.Params["MEDIUM"] == "email") { IsMediumEmail = 1; FromEmail = CurrentPerson.Emails.FirstActive; ReplyToEmail = CurrentPerson.Emails.FirstActive; } }
public void NewtonsoftJsonSerializationTest() { var foo1 = new Foo() { Id = Guid.NewGuid(), Name = "Hest" }; var foo2 = new Foo() { Id = Guid.NewGuid(), Name = "Hund" }; var lookupCollection = new LookupCollection <Foo>(new[] { foo1, foo2 }); var json = JsonConvert.SerializeObject(lookupCollection); var deserializedObject = JsonConvert.DeserializeObject <LookupCollection <Foo> >(json); deserializedObject[foo1.Id].Name.Should().Be("Hest"); deserializedObject[foo2.Id].Name.Should().Be("Hund"); deserializedObject.TryGetValue(foo1.Id, out var _).Should().BeTrue(); deserializedObject.TryGetValue(Guid.NewGuid(), out var _).Should().BeFalse(); }
public static ProcessingState Create(VorbisInfo info) { if (info == null) { throw new ArgumentNullException(nameof(info)); } var codecSetup = info.CodecSetup; // initialize the storage vectors. blocksize[1] is small for encode, but the correct size for decode var pcmStorage = codecSetup.BlockSizes[1]; var pcm = new float[info.Channels][]; for (var i = 0; i < pcm.Length; i++) { pcm[i] = new float[pcmStorage]; } // Vorbis I uses only window type 0 var window = new int[2]; window[0] = Encoding.Log(codecSetup.BlockSizes[0]) - 7; window[1] = Encoding.Log(codecSetup.BlockSizes[1]) - 7; var centerWindow = codecSetup.BlockSizes[1] / 2; var lookups = LookupCollection.Create(info); return(new ProcessingState( info, lookups, pcm, window, centerWindow)); }
private static void ValidateManufacturerReferences(SpanEquipmentSpecification spanEquipmentSpecification, LookupCollection <Manufacturer> manufacturer) { // Check that all manufacturer exists if provided if (spanEquipmentSpecification.ManufacturerRefs != null) { foreach (var manufacturerId in spanEquipmentSpecification.ManufacturerRefs) { if (!manufacturer.ContainsKey(manufacturerId)) { throw new ArgumentException($"Cannot find manufaturer with id: {manufacturerId}"); } } } }
private static void ValidateSpanStructureSpecificationReferences(SpanEquipmentSpecification spanEquipmentSpecification, LookupCollection <SpanStructureSpecification> spanStructureSpecifications) { // Checkthat all span structures references exists foreach (var spanStructureTemplate in spanEquipmentSpecification.RootTemplate.GetAllSpanStructureTemplatesRecursive()) { if (!spanStructureSpecifications.ContainsKey(spanStructureTemplate.SpanStructureSpecificationId)) { throw new ArgumentException($"Cannot find span structure specification with id: {spanStructureTemplate.SpanStructureSpecificationId}"); } } }
public void AddSpecification(CommandContext cmdContext, SpanEquipmentSpecification spanEquipmentSpecification, LookupCollection <SpanStructureSpecification> spanStructureSpecifications, LookupCollection <Manufacturer> manufacturer) { if (_spanEquipmentSpecifications.ContainsKey(spanEquipmentSpecification.Id)) { throw new ArgumentException($"A span equipment specification with id: {spanEquipmentSpecification.Id} already exists"); } ValidateSpanStructureSpecificationReferences(spanEquipmentSpecification, spanStructureSpecifications); ValidateManufacturerReferences(spanEquipmentSpecification, manufacturer); ValidateSpanStructureLevelAndPosition(spanEquipmentSpecification, spanStructureSpecifications); RaiseEvent( new SpanEquipmentSpecificationAdded(spanEquipmentSpecification) { CorrelationId = cmdContext.CorrelationId, IncitingCmdId = cmdContext.CmdId, UserName = cmdContext.UserContext?.UserName, WorkTaskId = cmdContext.UserContext?.WorkTaskId } ); }
public LookupCollection FetchByQuery(Query qry) { LookupCollection coll = new LookupCollection(); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public static binFrame genFrame(binStack[] stackIndex, int frame, int scansbyframe, string rawPath, BinStackOptions options) { binFrame currFrame = new binFrame(scansbyframe); currFrame.frame = frame; int currScanofFrame = 0; for (int j = 0; j <= stackIndex.GetUpperBound(0); j++) { for (int k = 0; k <= stackIndex[j].scan.GetUpperBound(0); k++) { if (currFrame.frame == stackIndex[j].scan[k].frame) { currFrame.scan[currScanofFrame].rawFileName = stackIndex[j].rawFileName; currFrame.scan[currScanofFrame].scanNumber = stackIndex[j].scan[k].FirstScan; currFrame.scan[currScanofFrame].parentMass = stackIndex[j].scan[k].parentMass; currFrame.scan[currScanofFrame].spectrumIndex = stackIndex[j].scan[k].spectrumIndex; currScanofFrame++; } } } int nRawsinFrame; LookupCollection rawsinFrame = RawFilesinFrame(currFrame, out nRawsinFrame); DA_raws[] tRawList = new DA_raws[nRawsinFrame]; ArrayList rawFilesKeys = (ArrayList)rawsinFrame.Keys; ArrayList rawFilesValues = (ArrayList)rawsinFrame.Values; for (int i = 0; i < nRawsinFrame; i++) { tRawList[i] = new DA_raws((int)rawFilesValues[i]); tRawList[i].rawFile = rawFilesKeys[i].ToString(); for (int j = tRawList[i].scan.GetLowerBound(0); j <= tRawList[i].scan.GetUpperBound(0); j++) { tRawList[i].scan[j].rawFileName = rawFilesKeys[i].ToString(); } } for (int i = 0; i <= currFrame.scan.GetUpperBound(0); i++) { for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++) { if (currFrame.scan[i].rawFileName != null) { if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim()) { for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++) { if (tRawList[j].scan[k].scanNumber == 0) { tRawList[j].scan[k].scanNumber = currFrame.scan[i].scanNumber; tRawList[j].scan[k].parentMass = currFrame.scan[i].parentMass; tRawList[j].scan[k].spectrumIndex = currFrame.scan[i].spectrumIndex; break; } } } } } } for (int i = 0; i < nRawsinFrame; i++) { int[] scansRawList = new int[tRawList[i].scan.GetLength(0)]; double[] parentMassList; if (options.useParentalMass) { parentMassList = new double[tRawList[i].scan.GetLength(0)]; } else { parentMassList = null; } for (int j = 0; j <= scansRawList.GetUpperBound(0); j++) { scansRawList[j] = tRawList[i].scan[j].scanNumber; //These are the MSMS identified spectra if (options.useParentalMass) { parentMassList[j] = tRawList[i].scan[j].parentMass; } } int t = tRawList[i].size(); string rawFileName = tRawList[i].rawFile; DA_raw daRaw1 = new DA_raw(); Comb.mzI[][] scansRaw = daRaw1.ReadScanRaw(rawPath, rawFileName, scansRawList, parentMassList, options); daRaw1 = null; for (int j = 0; j <= scansRawList.GetUpperBound(0); j++) { if (scansRaw[j] != null) { tRawList[i].scan[j].spectrum = (Comb.mzI[])scansRaw[j]; tRawList[i].scan[j].rawFileName = tRawList[i].rawFile; } } } for (int i = currFrame.scan.GetLowerBound(0); i <= currFrame.scan.GetUpperBound(0); i++) { for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++) { if (currFrame.scan[i].rawFileName != null) { if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim()) { for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++) { if (currFrame.scan[i].spectrumIndex == tRawList[j].scan[k].spectrumIndex) { currFrame.scan[i].spectrum = tRawList[j].scan[k].spectrum; break; } } break; } } } } //WARNING: very dangerous change, but necessary to maintain old binstacks: in currFrame // we swap the values of scanNumber by spectrumIndex (once we have obtained the desired // spectrum, we use the unique index (spectrumIndex). for (int i = currFrame.scan.GetLowerBound(0); i <= currFrame.scan.GetUpperBound(0); i++) { int scanNumber_t = currFrame.scan[i].scanNumber; currFrame.scan[i].scanNumber = currFrame.scan[i].spectrumIndex; //this is not necessary, but I want to maintain the scanNumber elsewhere... currFrame.scan[i].spectrumIndex = scanNumber_t; } return(currFrame); }
public void SendMessage(int personID, int communicationID, string toNumber, string fromNumber, string fromName, string message, string userID) { PersonCommunication pc; TwilioRestClient twilio = new TwilioRestClient(_username, _password); LookupCollection validNumbers = new LookupCollection(new Guid("11B4ADEC-CB8C-4D01-B99E-7A0FFE2007B5")); Message msg; SmsHistory history; String twilioNumber = null; String callback; // // Check if this message has already been sent. The agent seems to be broken and // will send each SMS message twice in rapid succession. If the communication is // no longer pending or queued, assume it has already been sent and silently ignore. // if (personID != -1 && communicationID != -1) { pc = new PersonCommunication(personID, communicationID); if (pc.CommunicationID != -1) { if (pc.Status != "Pending" && pc.Status != "Queued") return; } } // // Get the first enabled twilio number, use that as the default. // foreach (Lookup lk in validNumbers) { if (lk.Active) { twilioNumber = CleanPhone(lk.Qualifier); break; } } // // Check if the fromNumber is a valid Twilio number, if it isn't then use the default Twilio Number. // fromNumber = CleanPhone(fromNumber); foreach (Lookup lk in validNumbers) { string cleaned = CleanPhone(lk.Qualifier); if (lk.Active && fromNumber == cleaned) { twilioNumber = cleaned; break; } } // // Verify that we have our default twilio number defined. // if (String.IsNullOrEmpty(twilioNumber)) { if (communicationID != -1 && personID != -1) new PersonCommunicationData().SavePersonCommunication(communicationID, personID, DateTime.Now, "Failed -- Invalid from number specified", ArenaContext.Current.Organization.OrganizationID); return; } // // If we don't have a valid outgoing number, fail. // toNumber = CleanPhone(toNumber); if (String.IsNullOrEmpty(toNumber)) { if (communicationID != -1 && personID != -1) new PersonCommunicationData().SavePersonCommunication(communicationID, personID, DateTime.Now, "Failed -- No SMS number available", ArenaContext.Current.Organization.OrganizationID); return; } // // Construct the callback URL. // callback = ArenaContext.Current.AppSettings["ApplicationURLPath"]; if (!callback.EndsWith("/")) callback = callback + "/"; callback = callback + "UserControls/Custom/HDC/Twilio/SmsStatus.aspx"; // // Update the person communication history to show that we have attempted to send, since this is an // asynchronous operation we don't want to chance the callback not working and the message gets // sent over and over again. // if (communicationID != -1 && personID != -1) { new PersonCommunicationData().SavePersonCommunication(communicationID, personID, DateTime.Now, "Pushed", ArenaContext.Current.Organization.OrganizationID); } // // Verify that the twilio object exists. // if (twilio == null) { new PersonCommunicationData().SavePersonCommunication(communicationID, personID, DateTime.Now, "Failed -- Could not initialize Twilio library.", ArenaContext.Current.Organization.OrganizationID); return; } // // Send the message. // msg = twilio.SendMessage(twilioNumber, toNumber, message, callback); if (personID != -1 && communicationID != -1) { if (msg == null) { new PersonCommunicationData().SavePersonCommunication(communicationID, personID, DateTime.Now, "Failed -- Could not contact Twilio API.", ArenaContext.Current.Organization.OrganizationID); return; } if (String.IsNullOrEmpty(msg.Sid)) { if (communicationID != -1 && personID != -1) { String reason; if (msg.RestException != null && !String.IsNullOrEmpty(msg.RestException.Message)) reason = String.Format("Failed -- SMS provider did not accept message ({0}).", msg.RestException.Message); else if (!String.IsNullOrEmpty(msg.Status)) reason = String.Format("Failed -- SMS provider did not accept message ({0}).", msg.Status); else reason = String.Format("Failed -- SMS provider did not accept message (Unknown Error)."); new PersonCommunicationData().SavePersonCommunication(communicationID, personID, DateTime.Now, reason, ArenaContext.Current.Organization.OrganizationID); } } else { history = new SmsHistory(); history.CommunicationId = communicationID; history.PersonId = personID; history.SmsSid = msg.Sid; history.Save(userID); } } }
private IList<ReturnedInfo> OrderByDateReturned(IList<ReturnedInfo> returns) { LookupCollection ordered = new LookupCollection(); foreach (ReturnedInfo ret in returns) { ordered.Add(ret.ReturnId, Convert.ToDateTime(ret.ReturnDate)); } IList<ReturnedInfo> orderedList = new List<ReturnedInfo>(); Object[] o = new Object[ordered.Count]; ordered.Keys.CopyTo(o, 0); Array.Reverse(o); foreach (Object oo in o) { foreach (ReturnedInfo rt in returns) { if (rt.ReturnId == (String)oo) { orderedList.Add(rt); } } } return orderedList; }
public Arena.Services.Contracts.ModifyResult ImIn(Contracts.ImIn imIn) { ModifyResult result = new ModifyResult(); result.Successful = true.ToString(); result.Link = "/person/1234"; // First Name if (String.IsNullOrEmpty(imIn.FirstName)) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "FirstNameMissing", Message = "First Name is required." }); result.Link = null; } // Last Name if (String.IsNullOrEmpty(imIn.LastName)) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "LastNameMissing", Message = "Last Name is required." }); result.Link = null; } // DOB if (imIn.DateOfBirth == null || imIn.DateOfBirth == default(DateTime)) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "DOBMissingOrInvalid", Message = "Date of Birth required and must be valid." }); result.Link = null; } // Phone Number if (String.IsNullOrEmpty(imIn.PhoneNumber)) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "PhoneNumberMissing", Message = "Phone Number is required." }); result.Link = null; } else { // Match the phone number format if (!Regex.Match(imIn.PhoneNumber, @"^(\([2-9]\d\d\)|[2-9]\d\d) ?[-.,]? ?[2-9]\d\d ?[-.,]? ?\d{4}$").Success) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "PhoneNumberInvalid", Message = "Phone Number format is invalid: (502) 253-8000" }); result.Link = null; } } // Email if (!String.IsNullOrEmpty(imIn.Email)) { // No more required email /* result.Successful = false.ToString(); * result.ValidationResults.Add(new ModifyValidationResult() { Key = "EmailMissing", Message = "Email is required." }); * result.Link = null; * } * else * {*/ // Match the email format if (!Regex.Match(imIn.Email, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$").Success) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "EmailInvalid", Message = "Email format is invalid: [email protected]" }); result.Link = null; } } // Phone Type Lookup phoneType = new Lookup(); // Get all the phone number types LookupCollection lc = new LookupCollection(); lc.LoadByType(38); String activeTypes = lc.Where(e => e.Active).Select(e => e.Value).Aggregate((current, next) => current + ", " + next); if (String.IsNullOrEmpty(imIn.PhoneType)) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "PhoneTypeInvalid", Message = "Phone type is invalid (" + activeTypes + ")" }); result.Link = null; } else { phoneType = lc.Where(e => e.Value == imIn.PhoneType).FirstOrDefault(); if (phoneType == null) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "PhoneTypeInvalid", Message = "Phone type is invalid (" + activeTypes + ")" }); result.Link = null; } } // Validate the campus if (String.IsNullOrEmpty(imIn.Campus)) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "CampusInvalid", Message = "Campus is required." }); result.Link = null; } if (result.Successful == true.ToString()) { Arena.Custom.SECC.Common.Data.Person.ImIn imInTarget = new Arena.Custom.SECC.Common.Data.Person.ImIn(); AutoMapper.Mapper.CreateMap <Contracts.ImIn, Arena.Custom.SECC.Common.Data.Person.ImIn>(); AutoMapper.Mapper.Map <Contracts.ImIn, Arena.Custom.SECC.Common.Data.Person.ImIn>(imIn, imInTarget); Arena.Custom.SECC.Common.Util.ImIn imInUtil = new Arena.Custom.SECC.Common.Util.ImIn(); if (!imInUtil.process(imInTarget)) { result.Successful = false.ToString(); result.ValidationResults.Add(new ModifyValidationResult() { Key = "ImInGeneralError", Message = "Something went wrong processing the I'm In request." }); } } return(result); }
public static binFrame genFrame(binStack[] stackIndex, int frame, int scansbyframe, string rawPath, string spectrumType, string spectrumPosition) { binFrame currFrame = new binFrame(scansbyframe); currFrame.frame = frame; int currScanofFrame = 0; for (int j = 0; j <= stackIndex.GetUpperBound(0); j++) { for (int k = 0; k <= stackIndex[j].scan.GetUpperBound(0); k++) { if (currFrame.frame == stackIndex[j].scan[k].frame) { currFrame.scan[currScanofFrame].rawFileName = stackIndex[j].rawFileName; currFrame.scan[currScanofFrame].scanNumber = stackIndex[j].scan[k].FirstScan; currScanofFrame++; } } } int nRawsinFrame; LookupCollection rawsinFrame = RawFilesinFrame(currFrame, out nRawsinFrame); DA_raws[] tRawList = new DA_raws[nRawsinFrame]; ArrayList rawFilesKeys = (ArrayList)rawsinFrame.Keys; ArrayList rawFilesValues = (ArrayList)rawsinFrame.Values; for (int i = 0; i < nRawsinFrame; i++) { tRawList[i] = new DA_raws((int)rawFilesValues[i]); tRawList[i].rawFile = rawFilesKeys[i].ToString(); for (int j = tRawList[i].scan.GetLowerBound(0); j <= tRawList[i].scan.GetUpperBound(0); j++) { tRawList[i].scan[j].rawFileName = rawFilesKeys[i].ToString(); } } for (int i = 0; i <= currFrame.scan.GetUpperBound(0); i++) { for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++) { if (currFrame.scan[i].rawFileName != null) { if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim()) { for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++) { if (tRawList[j].scan[k].scanNumber == 0) { tRawList[j].scan[k].scanNumber = currFrame.scan[i].scanNumber; break; } } } } } } for (int i = 0; i < nRawsinFrame; i++) { int[] scansRawList = new int[tRawList[i].scan.GetLength(0)]; for (int j = 0; j <= scansRawList.GetUpperBound(0); j++) { scansRawList[j] = tRawList[i].scan[j].scanNumber; //These are the MSMS identified spectra } int t = tRawList[i].size(); string rawFileName = tRawList[i].rawFile; DA_raw daRaw1 = new DA_raw(); Comb.mzI[][] scansRaw = daRaw1.ReadScanRaw(rawPath, rawFileName, scansRawList, spectrumType, spectrumPosition); daRaw1 = null; for (int j = 0; j <= scansRawList.GetUpperBound(0); j++) { if (scansRaw[j] != null) { tRawList[i].scan[j].spectrum = (Comb.mzI[])scansRaw[j]; tRawList[i].scan[j].rawFileName = tRawList[i].rawFile; } } } for (int i = currFrame.scan.GetLowerBound(0); i <= currFrame.scan.GetUpperBound(0); i++) { for (int j = tRawList.GetLowerBound(0); j <= tRawList.GetUpperBound(0); j++) { if (currFrame.scan[i].rawFileName != null) { if (currFrame.scan[i].rawFileName.Trim() == tRawList[j].rawFile.Trim()) { for (int k = tRawList[j].scan.GetLowerBound(0); k <= tRawList[j].scan.GetUpperBound(0); k++) { if (currFrame.scan[i].scanNumber == tRawList[j].scan[k].scanNumber) { currFrame.scan[i].spectrum = tRawList[j].scan[k].spectrum; break; } } break; } } } } return(currFrame); }
private void BindLists() { PersonEmailCollection emails = GetPerson().Emails; if ( emails.Count > 0 ) { LookupCollection mailChimpLists = new LookupCollection( new Guid( MailChimpLookupGUIDSetting ) ); dlLists.DataSource = mailChimpLists; dlLists.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { _editEnabled = CurrentModule.Permissions.Allowed(Arena.Security.OperationType.Edit, CurrentUser); _pledgeId = !string.IsNullOrEmpty(Request.QueryString["pledge"]) ? Convert.ToInt32(Request.QueryString["pledge"]) : -1; if (!Page.IsPostBack) { SetDefaults(); if (_achGatewayAcct != null) { cbCreateRepeatingPayment.Visible = true; cbCreateRepeatingPayment.Checked = (CurrentPerson.Settings["PledgeQuickEntry_CreateRepeatingPayment"] ?? string.Empty) == "True"; DisplayRepeatingPaymentSection(); // Load selected frequency types Processor achProcessor = Processor.GetProcessorClass(_achGatewayAcct.PaymentProcessor); ddlFrequency.Items.Clear(); Type enumType = typeof(PaymentFrequency); System.Array values = Enum.GetValues(enumType); foreach (object enumValue in values) { if ((PaymentFrequency)enumValue == PaymentFrequency.Every_Week || (PaymentFrequency)enumValue == PaymentFrequency.Once_a_Month || (PaymentFrequency)enumValue == PaymentFrequency.Every_Three_Months || (PaymentFrequency)enumValue == PaymentFrequency.Every_Year) { bool supported = true; if (achProcessor != null && !achProcessor.FrequencySupported((PaymentFrequency)enumValue)) { supported = false; } if (supported) { string itemValue = Enum.Format(enumType, enumValue, "D"); if (itemValue != "-1") { ddlFrequency.Items.Add(new ListItem(Utilities.EnumName(enumType, enumValue), itemValue)); } } } } } } // Construct campus drop down list from Arena lookup type 102, which is campus designations LookupCollection campuses = new LookupCollection(102); // Bind campus lookup key / values pairs to dropdown datasource ddlCampus.DataSource = campuses; ddlCampus.DataValueField = "LookupID"; ddlCampus.DataTextField = "Value"; ddlCampus.DataBind(); // Bind frequency dictionary to frequency dropdown datasource. ddlPledgeFrequency.DataSource = PledgeFrequency.FrequencyNames; ddlPledgeFrequency.DataValueField = "Key"; ddlPledgeFrequency.DataTextField = "Value"; ddlPledgeFrequency.DataBind(); // Add HTML tag attribute to tbAmount textbox, which calculates total amount tbAmount.Attributes.Add("onfocus", "calculateAmt()"); }
/// <summary> /// Utility method to fetch an Arena newsletter which corresponds to the given MailChimp List. /// </summary> /// <param name="listID">List ID of a MailChimp list</param> /// <returns>newsletterID of a corresponding Arena newsletter; otherwise returns -1.</returns> private int GetNewsletterIDFromMailChimpListID( string listID ) { int newsletterID = -1; LookupCollection mailChimpLists = new LookupCollection( new Guid( MailChimpLookupGUIDSetting ) ); var query = ( from lookup in mailChimpLists.OfType<Lookup>() where lookup.Qualifier == listID select lookup ).FirstOrDefault(); if ( query != null ) { newsletterID = int.Parse( query.Qualifier2 ); } return newsletterID; }
public LookupCollection FetchByID(object Id) { LookupCollection coll = new LookupCollection().Where("ID", Id).Load(); return coll; }
private static void ValidateSpanStructureLevelAndPosition(SpanEquipmentSpecification spanEquipmentSpecification, LookupCollection <SpanStructureSpecification> spanStructureSpecifications) { // Used to check level+position uniqueness HashSet <(int, int)> levelPositionUsed = new HashSet <(int, int)>(); // Root template must have level 1 if (spanEquipmentSpecification.RootTemplate.Level != 1) { throw new ArgumentException("Root template must always have level set to 1"); } levelPositionUsed.Add((spanEquipmentSpecification.RootTemplate.Level, spanEquipmentSpecification.RootTemplate.Position)); var childsToCheck = spanEquipmentSpecification.RootTemplate.ChildTemplates; var expectedChildLevel = 2; while (childsToCheck.Length != 0) { List <SpanStructureTemplate> nextLevelChildsToCheck = new List <SpanStructureTemplate>(); foreach (var childTemplate in childsToCheck) { if (childTemplate.Level != expectedChildLevel) { throw new ArgumentException($"Expected level: {expectedChildLevel} in template referencing span structure specification: {childTemplate.SpanStructureSpecificationId}"); } if (levelPositionUsed.Contains((childTemplate.Level, childTemplate.Position))) { throw new ArgumentException($"Level {childTemplate.Level} Position {childTemplate.Position} in template referencing span structure specification: {childTemplate.SpanStructureSpecificationId} is used more than once. Must be unique."); } levelPositionUsed.Add((childTemplate.Level, childTemplate.Position)); nextLevelChildsToCheck.AddRange(childTemplate.ChildTemplates); } childsToCheck = nextLevelChildsToCheck.ToArray(); expectedChildLevel++; } }
private IList<IssueInfo> OrderByDateIssued(IList<IssueInfo> issues) { LookupCollection ordered = new LookupCollection(); foreach (IssueInfo issue in issues) { ordered.Add(issue.IssueId, Convert.ToDateTime(issue.IssueDate)); } IList<IssueInfo> orderedList = new List<IssueInfo>(); Object[] o = new Object[ordered.Count]; ordered.Keys.CopyTo(o, 0); Array.Reverse(o); foreach (Object oo in o) { foreach (IssueInfo iss in issues) { if (iss.IssueId == (String)oo) { orderedList.Add(iss); } } } return orderedList; }
protected void Page_Load(object sender, EventArgs e) { String smsSid = Request.Form["SmsSid"].ToString(); String status = Request.Form["SmsStatus"].ToString().ToLower(); SmsHistory history; // // Check if this is a received message. // if (status == "received") { OrganizationData orgData = new OrganizationData(); LookupCollection validNumbers = new LookupCollection(new Guid("11B4ADEC-CB8C-4D01-B99E-7A0FFE2007B5")); LookupCollection twilioHandlers = new LookupCollection(new Guid("FC1BA7E8-C22A-48CF-8A30-5DF640049373")); String body = Request.Form["Body"].ToString(); String from = Request.Form["From"].ToString(); String to = Request.Form["To"].ToString(); String baseUrl; StringBuilder sb = new StringBuilder(); List<String> possiblyFrom = new List<String>(); Boolean handled = false; PersonCollection col = new PersonCollection(); Lookup lkTo = null; // // Look for the twilio phone number, if not found ignore the incoming message. // to = TwilioSMS.CleanPhone(to); foreach (Lookup lk in validNumbers) { if (lk.Active && to == TwilioSMS.CleanPhone(lk.Qualifier)) { lkTo = lk; break; } } if (lkTo == null) return; // // Load all person records that match the phone number. // from = TwilioSMS.CleanPhone(from); if (from.StartsWith("1")) col.LoadByPhone(from.Substring(1)); else col.LoadByPhone(from); // // Build a list of ID numbers for the person IDs that this could be from. // foreach (Person p in col) { possiblyFrom.Add(p.PersonID.ToString()); } // // See if we can find a stored procedure that wants to handle this message. // try { foreach (Lookup handler in twilioHandlers) { ArrayList parms = new ArrayList(); SqlParameter outStatus = new SqlParameter("@OutStatus", SqlDbType.Int); SqlParameter outMessage = new SqlParameter("@OutMessage", SqlDbType.VarChar, 2000); if (handler.Active == false) continue; // // Check if this handler is for us. // if (Convert.ToInt32(handler.Qualifier) != lkTo.LookupID && lkTo.LookupID != -1) continue; // // Check if there is a match on the regular expression. // if (!Regex.IsMatch(body, handler.Qualifier2, RegexOptions.IgnoreCase)) continue; outStatus.Direction = ParameterDirection.Output; outMessage.Direction = ParameterDirection.Output; parms.Add(new SqlParameter("@FromNumber", from)); parms.Add(new SqlParameter("@PossiblyFrom", String.Join(",", possiblyFrom.ToArray()))); parms.Add(new SqlParameter("@ToNumber", to)); parms.Add(new SqlParameter("@ToNumberID", lkTo.LookupID)); parms.Add(new SqlParameter("@Message", body)); parms.Add(outStatus); parms.Add(outMessage); orgData.ExecuteNonQuery(handler.Qualifier3, parms); // // See if a response should be sent. // if ((int)outStatus.Value == 1) { if (!String.IsNullOrEmpty((String)outMessage.Value)) { int len = outMessage.Value.ToString().Length; if (len > 160) len = 160; Response.Clear(); Response.ContentType = "text/plain"; Response.Write(outMessage.Value.ToString().Substring(0, len)); // // Set the base url. // baseUrl = ArenaContext.Current.AppSettings["ApplicationURLPath"]; if (!baseUrl.EndsWith("/")) baseUrl = baseUrl + "/"; baseUrl = String.Format("{0}default.aspx?page={1}", baseUrl, personDetailPageId); // // If there is a valid e-mail address to forward the text to then build up an e-mail // message and send an e-mail. // if (!String.IsNullOrEmpty(handler.Qualifier4)) { try { sb.AppendFormat("<p>Received a text message from {0} to {1} ({2})</p>", from, to, lkTo.Value); sb.AppendFormat("<p>Message: {0}</p>", body); if (col.Count > 0) { sb.Append("<p>Possibly received from:<br /><ul>"); foreach (Person p in col) { sb.AppendFormat("<li><a href=\"{0}&guid={1}\">{2}</a></li>", baseUrl, p.PersonGUID.ToString(), Server.HtmlEncode(p.FullName)); } sb.Append("</ul></p>"); } ArenaSendMail.SendMail(String.Empty, String.Empty, handler.Qualifier4, "Received SMS message", sb.ToString()); } catch (System.Exception ex) { try { new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex, ArenaContext.Current.Organization.OrganizationID, "HDC.Twilio", ArenaContext.Current.ServerUrl); } catch { } } } Response.End(); } handled = true; break; } } } catch (System.Exception ex) { if (ex.Message != "Thread was being aborted.") { new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex, ArenaContext.Current.Organization.OrganizationID, "HDC.Twilio", ArenaContext.Current.ServerUrl); } } // // If the message has already been handled, we don't need to send any replies or // e-mail anybody. // if (!handled) { // // Set the base url. // baseUrl = ArenaContext.Current.AppSettings["ApplicationURLPath"]; if (!baseUrl.EndsWith("/")) baseUrl = baseUrl + "/"; baseUrl = String.Format("{0}default.aspx?page={1}", baseUrl, personDetailPageId); // // If there is a valid e-mail address to forward the text to then build up an e-mail // message and send an e-mail. // if (!String.IsNullOrEmpty(lkTo.Qualifier2)) { try { sb.AppendFormat("<p>Received a text message from {0} to {1} ({2})</p>", from, to, lkTo.Value); sb.AppendFormat("<p>Message: {0}</p>", body); if (col.Count > 0) { sb.Append("<p>Possibly received from:<br /><ul>"); foreach (Person p in col) { sb.AppendFormat("<li><a href=\"{0}&guid={1}\">{2}</a></li>", baseUrl, p.PersonGUID.ToString(), Server.HtmlEncode(p.FullName)); } sb.Append("</ul></p>"); } ArenaSendMail.SendMail(String.Empty, String.Empty, lkTo.Qualifier2, "Received SMS message", sb.ToString()); } catch (System.Exception ex) { try { new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex, ArenaContext.Current.Organization.OrganizationID, "HDC.Twilio", ArenaContext.Current.ServerUrl); } catch { } } } // // If there is an auto-reply message in the lookup then send back that message. // if (!String.IsNullOrEmpty(lkTo.Qualifier8)) { try { int len = lkTo.Qualifier8.Length; if (len > 160) len = 160; Response.Clear(); Response.ContentType = "text/plain"; Response.Write(lkTo.Qualifier8.Substring(0, len)); Response.End(); } catch (System.Exception ex) { try { if (ex.Message != "Thread was being aborted.") { new Arena.DataLayer.Core.ExceptionHistoryData().AddUpdate_Exception(ex, ArenaContext.Current.Organization.OrganizationID, "HDC.Twilio", ArenaContext.Current.ServerUrl); } } catch { } } } } } else { // // This (should be) a status response to an outgoing message. // history = new SmsHistory(smsSid); if (history.SmsHistoryId != -1) { try { if (status == "sent") { new PersonCommunicationData().SavePersonCommunication(history.CommunicationId, history.PersonId, DateTime.Now, "Success"); } else { new PersonCommunicationData().SavePersonCommunication(history.CommunicationId, history.PersonId, DateTime.Now, "Failed"); } } catch (System.Exception) { } history.Delete(); } } }