Example #1
0
        public async Task <IActionResult> PutLookupType(int id, LookupType lookupType)
        {
            if (id != lookupType.LookUpTypeId)
            {
                return(BadRequest());
            }

            _context.Entry(lookupType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LookupTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
    static void Main(string[] args)
    {
        LookupType lookupType = LookupType.Language;

        Console.WriteLine(GetLookupsByLookupType(lookupType));
        Console.Read();
    }
Example #3
0
        private async Task <GetXblIdentityRes> GetIdentity(LookupType type, string value, bool useCache)
        {
            using (var client = _redisClientsManager.GetClient())
            {
                if (useCache)
                {
                    var ident = client.GetJson <GetXblIdentityRes>(GenerateRedisKey(type, value));
                    if (ident != null)
                    {
                        return(ident);
                    }
                }

                var(gamertag, xuid) = await GetProfileSettings(type, value);

                var identity = new GetXblIdentityRes
                {
                    CacheInfo = new CacheInfo(DateTime.UtcNow, TimeSpan.FromMinutes(30)),
                    Gamertag  = gamertag,
                    Xuid      = xuid,
                };

                var jsonStr = JsonConvert.SerializeObject(identity);
                var expiry  = (DateTime)identity.CacheInfo.ExpiresAt;

                client.Set(GenerateRedisKey(LookupType.Gamertag, gamertag.ToSlug()), jsonStr, expiry);
                client.Set(GenerateRedisKey(LookupType.Xuid, xuid), jsonStr, expiry);

                return(identity);
            }
        }
Example #4
0
        public void Update(LookupTypeModel lookupTypeModel, string user)
        {
            try
            {
                LookupType lookupType = _dbContext.LookupTypes.Find(lookupTypeModel.Id);
                if (lookupType == null)
                {
                    return;
                }

                lookupType.TypeDescription = lookupTypeModel.TypeDescription;
                lookupType.IsActive        = lookupTypeModel.IsActive;
                lookupType.LastUpdated     = DateTime.Now;
                lookupType.LastUpdatedBy   = user;
                _dbContext.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                _dbContext.Dispose();
            }
        }
Example #5
0
        public void Insert(LookupTypeModel lookupTypeModel, string user)
        {
            try
            {
                LookupType lookupType = new LookupType
                {
                    Id = 0,
                    TypeDescription = lookupTypeModel.TypeDescription,
                    IsActive        = lookupTypeModel.IsActive,
                    Created         = DateTime.Now,
                    CreatedBy       = user,
                    LastUpdated     = DateTime.Now,
                    LastUpdatedBy   = user
                };

                _dbContext.LookupTypes.Add(lookupType);
                _dbContext.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                _dbContext.Dispose();
            }
        }
Example #6
0
 public List <SelectListItem> GetLookupList(LookupType type)
 {
     if (type == LookupType.Boolean)
     {
         return(new List <SelectListItem>()
         {
             new SelectListItem {
                 Text = "Yes", Value = "True"
             },
             new SelectListItem {
                 Text = "No", Value = "False"
             }
         });
     }
     else
     {
         return(_all.Where(l => l.Type == type.ToString())
                .Select(l => new SelectListItem
         {
             Text = l.Name,
             Value = l.Name
         })
                //.OrderBy(l => l.Text)
                .ToList());
     }
 }
Example #7
0
        private async Task <string> GetAchievements(string character, string realm, LookupType type) // Returns a string to this.ArmoryLookup()
        {
            AchievementsList       list       = new AchievementsList();
            AchievementSummaryJson achievinfo = await this.Call($"https://{this.Config.Region}.api.blizzard.com/profile/wow/character/{realm}/{character}/achievements", Namespace.Profile, typeof(AchievementSummaryJson));

            switch (type)
            {
            case LookupType.PVE:
                foreach (Achievement achiev in achievinfo.Achievements)
                {
                    if (Globals.AchievementsPVE.ContainsKey(achiev.Id))
                    {
                        list.Add(achiev.Id, achiev.AchievementAchievement.Name, type);
                    }
                }
                break;

            case LookupType.PVP:
                foreach (Achievement achiev in achievinfo.Achievements)
                {
                    if (Globals.AchievementsPVP.ContainsKey(achiev.Id))
                    {
                        list.Add(achiev.Id, achiev.AchievementAchievement.Name, type);
                    }
                }
                break;
            } // End Switch
            return(list.ToString());
        }
Example #8
0
 private void Seed(LookupType lookupType)
 {
     if (_context.LookupTypes.Find(lookupType.Id) == null)
     {
         _context.LookupTypes.Add(lookupType);
     }
 }
        protected void btnSaveGifts_Click(object sender, EventArgs e)
        {
            if (Person == null)
            {
                Response.Redirect(string.Format("~/default.aspx?page={0}&redirect={1}",
                                                LoginPageIDSetting, Request.RawUrl));
            }
            else
            {
                Person.Gifts.Clear();
                LookupCollection gifts = new LookupType(SystemLookupType.SpiritualGifts).Values;
                foreach (Lookup gift in gifts)
                {
                    string[] split = gift.Value.Split(new Char[] { '/', ' ', ',', '.', ':', '\t' });

                    foreach (string s in split)
                    {
                        if (hdnSelectedVals.Value.Contains(s.Trim()))
                        {
                            Lookup Gift = new Lookup(gift.LookupID);
                            Person.Gifts.Add(Gift);
                        }
                    }
                }
                Person.SaveGifts(CurrentPortal.OrganizationID, CurrentUser.Identity.Name);

                DisplayConfirmation();
            }
        }
        public IHttpActionResult DeleteLookupType(int id)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat(Resource.LogDebugModeMessage);
            }

            try
            {
                LookupType lookupType = db.LookupTypes.Find(id);
                if (lookupType == null)
                {
                    return(NotFound());
                }

                db.LookupTypes.Remove(lookupType);
                db.SaveChanges();

                return(Ok(lookupType));
            }
            catch (Exception e)
            {
                _log.Error(string.Format(Resource.GeneralError_Pre, "PostLookupType"), e);
                return(InternalServerError(e));
            }
        }
Example #11
0
        protected IEnumerable <Lookup> GetAllTopics()
        {
            bool isPublic;
            var  topics = new LookupType(SystemLookupType.TopicArea);

            return(topics.Values.Where(t => bool.TryParse(t.Qualifier2, out isPublic) && t.Active).OrderBy(t => t.Order));
        }
        public IHttpActionResult PostLookupType(LookupType lookupType)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat(Resource.LogDebugModeMessage);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                db.LookupTypes.Add(lookupType);
                db.SaveChanges();

                return(CreatedAtRoute("DefaultApi", new { id = lookupType.Id }, lookupType));
            }
            catch (Exception e)
            {
                _log.Error(string.Format(Resource.GeneralError_Pre, "PostLookupType"), e);
                return(InternalServerError(e));
            }
        }
        /// <summary>
        /// Seed the Request Status Lookup for QuoteRequests
        /// </summary>
        private void SeedQuoteRequestStatus()
        {
            LookupType quoteRequestStatus = new LookupType
            {
                Description = EnumHelper.LookupTypes.QuoteRequestStatus.ToString()
            };

            _context.LookupTypes.Add(quoteRequestStatus);
            _context.SaveChanges();

            string[] quoteRequestStatusTypes =
            {
                EnumHelper.QuoteRequestTypes.Pending.ToString(),
                EnumHelper.QuoteRequestTypes.Processing.ToString(),
                EnumHelper.QuoteRequestTypes.Supplied.ToString(),
                EnumHelper.QuoteRequestTypes.Complete.ToString()
            };
            foreach (string quoteRequestStatusType in quoteRequestStatusTypes)
            {
                Lookup quoteRequestStatusLookup = new Lookup
                {
                    Description = quoteRequestStatusType,
                    Type        = quoteRequestStatus
                };
                _context.Lookups.Add(quoteRequestStatusLookup);
            }
            _context.SaveChanges();
        }
 public Translation(string obfName, LookupType type)
 {
     ObfName   = obfName;
     CleanName = type.Name;
     _type     = type;
     Type      = TranslationType.TypeTranslation;
 }
Example #15
0
        public async Task <ActionResult <LookupType> > PostLookupType(LookupType lookupType)
        {
            _context.lookupTypes.Add(lookupType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLookupType", new { id = lookupType.LookUpTypeId }, lookupType));
        }
Example #16
0
        public override void EditObject(LookupType type, int objectID)
        {
            SiteExplorerNodeViewModel viewModel = null;

            switch (type)
            {
            case LookupType.Material:
                viewModel = ViewModelFromObjectID(SiteExplorerNodeType.Material, objectID);
                break;

            case LookupType.Region:
                viewModel = ViewModelFromObjectID(SiteExplorerNodeType.Region, objectID);
                break;

            case LookupType.Site:
                viewModel = ViewModelFromObjectID(SiteExplorerNodeType.Site, objectID);
                break;

            case LookupType.SiteVisit:
                viewModel = ViewModelFromObjectID(SiteExplorerNodeType.SiteVisit, objectID);
                break;

            case LookupType.Trap:
                viewModel = ViewModelFromObjectID(SiteExplorerNodeType.Trap, objectID);
                break;
            }

            if (viewModel != null)
            {
                _explorer.EditNode(viewModel);
            }
        }
Example #17
0
        public static float CompareFieldTypes(LookupType t1, LookupType t2, LookupModule lookupModel)
        {
            float comparative_score = 1.0f;

            float score_penalty = comparative_score / t1.Fields.Count(f => !f.IsStatic && !f.IsLiteral);

            foreach (var f1 in t1.Fields.Select((Value, Index) => new { Value, Index }))
            {
                LookupField f2 = t2.Fields[f1.Index];
                if (f1.Value.Name == f2.Name)
                {
                    return(1.5f);
                }
                if (!Regex.Match(f1.Value.Name, lookupModel.NamingRegex).Success&& f1.Value.Name != f2.Name)
                {
                    return(0.0f);
                }

                if (f1.Value.IsStatic || f1.Value.IsLiteral)
                {
                    continue;
                }

                if (f1.Value.GetType().Namespace == "System" && f2.GetType().Namespace == "System" && f1.Value.Name == f2.Name)
                {
                    comparative_score -= score_penalty;
                }
            }

            return(comparative_score);
        }
Example #18
0
        /// <summary>
        /// Get all items for the current type
        /// </summary>
        /// <returns>A list of Lookup objects</returns>
        public IList <Lookup> List(LookupType type)
        {
            //Cache Section
            string cacheKey          = null;
            MembershipHelperUser mhu = MembershipHelper.GetUser();

            if (mhu != null)
            {
                cacheKey = string.Format("LOOKUPS_{0}_{1}_{2}", mhu.UserId, typeof(Lookup).ToString(), type.ToString());
            }

            object result = CacheManager.GetCached(typeof(Lookup), cacheKey);

            ICriteria crit = GetCriteria();

            if (result == null)
            {
                string query = "SELECT L FROM Lookup L WHERE";

                query += " LookupType = :Type";
                query += " ORDER BY UPPER(Description)";

                IQuery q = NHibernateSession.CreateQuery(query);

                q.SetEnum("Type", type);

                result = q.List <Lookup>();
                //crit.Add(Expression.Eq("LookupType", type));
                //crit.AddOrder(new Order("Description", true));

                //result = crit.List<Lookup>();
                CacheManager.AddItem(typeof(Lookup), cacheKey, result);
            }
            return(result as IList <Lookup>);
        }
Example #19
0
        public void Deactivate(int id, string user)
        {
            try
            {
                LookupType lookupType = _dbContext.LookupTypes.Find(id);

                if (lookupType == null)
                {
                    return;
                }

                lookupType.IsActive      = false;
                lookupType.LastUpdated   = DateTime.Now;
                lookupType.LastUpdatedBy = user;
                _dbContext.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                _dbContext.Dispose();
            }
        }
Example #20
0
 void _enQue(LookupType lut)
 {
     _que.Enqueue(lut);
     if (_que.Count == 1)
     {
         OnLookupEvent(new LookupEventArgs(null, lut, LookupSequence.MessageStart));
     }
 }
 public void PreSelect(int?objectID, string text, LookupType lookupType)
 {
     ObjectID       = objectID;
     Text           = text;
     SelectedObject = objectID.HasValue ? new LookupResult {
         Label = text, LookupObjectID = objectID.Value, LookupType = lookupType
     } : null;
 }
Example #22
0
        public ActionResult GetLookupsByType(LookupType lookupType)
        {
            var response = _lookupRepository.GetLookupsByType(lookupType);

            var lookups = response.DataItems.First();

            return(Content(JsonConvert.SerializeObject(lookups), "text/javascript"));
        }
Example #23
0
        public void Add(long id, string name, LookupType type)
        {
            switch (type)
            {
            case LookupType.PVE:
                if (Globals.AchievementsPVE[id].Group == -1)     // No Group (-1) - Always Add
                {
                    this.List.Add((int)id * -1, new AchievementItem(Globals.AchievementsPVE[id].Group, Globals.AchievementsPVE[id].Value, name));
                    return;
                }
                if (this.List.ContainsKey(Globals.AchievementsPVE[id].Group))                                   // Group is already in list, check if achievement value is higher
                {
                    if (Globals.AchievementsPVE[id].Value > this.List[Globals.AchievementsPVE[id].Group].Value) // Value is higher
                    {
                        this.List.Remove(Globals.AchievementsPVE[id].Group);
                        this.List.Add(Globals.AchievementsPVE[id].Group, new AchievementItem(Globals.AchievementsPVE[id].Group, Globals.AchievementsPVE[id].Value, name));
                        return;
                    }
                    else
                    {
                        return;      // Value is not higher
                    }
                }
                else     // Not in list, go ahead and add
                {
                    this.List.Add(Globals.AchievementsPVE[id].Group, new AchievementItem(Globals.AchievementsPVE[id].Group, Globals.AchievementsPVE[id].Value, name));
                    return;
                }

            case LookupType.PVP:
                if (Globals.AchievementsPVP[id].Group == -1)     // No Group (-1) - Always Add
                {
                    this.List.Add((int)id * -1, new AchievementItem(Globals.AchievementsPVP[id].Group, Globals.AchievementsPVP[id].Value, name));
                    return;
                }
                if (this.List.ContainsKey(Globals.AchievementsPVP[id].Group))                                   // Group is already in list, check if achievement value is higher
                {
                    if (Globals.AchievementsPVP[id].Value > this.List[Globals.AchievementsPVP[id].Group].Value) // Value is higher
                    {
                        this.List.Remove(Globals.AchievementsPVP[id].Group);
                        this.List.Add(Globals.AchievementsPVP[id].Group, new AchievementItem(Globals.AchievementsPVP[id].Group, Globals.AchievementsPVP[id].Value, name));
                        return;
                    }
                    else
                    {
                        return;      // Value is not higher
                    }
                }
                else     // Not in list, go ahead and add
                {
                    this.List.Add(Globals.AchievementsPVP[id].Group, new AchievementItem(Globals.AchievementsPVP[id].Group, Globals.AchievementsPVP[id].Value, name));
                    return;
                }

            default:
                throw new Exception("Invalid type specified!");
            }
        }
Example #24
0
        public void LookupSelect(string Name, string Label, Func <T, object> Value, LookupType type, int?ParantLevel = null, bool Required = false, int?panelId = null, string ChainedTo = null, int width = 6, Func <T, bool> Condition = null)
        {
            var uip = new UiParameter <T>()
            {
                Name = Name, Label = Label, Value = Value, ParantLevel = ParantLevel, Required = Required, PanelId = panelId, Condition = Condition, Width = width, UiType = ParameterTypes.LookupSelect, LookupType = type, ChainedTo = ChainedTo
            };

            Parameters.Push(Name, uip);
        }
Example #25
0
        public void Edit(int id, LookupType type, string description)
        {
            Lookup l = GetById(id);

            l.LookupType  = type;
            l.Description = description;
            Save(l);
            CacheManager.ExpireAll(typeof(Lookup));
        }
Example #26
0
        public IEnumerable <LookupValuesModel> GetMasterLookUpValues(string lookupType)
        {
            LookupType type = _lookupRepository.GetFirstOrDefaultAsync(w => w.Type == lookupType).Result;
            //IEnumerable<LookupValues> lookupValues = _masterRepository.GetLookupType(lookupType);
            IEnumerable <LookupValues>      lookupValues       = _lookupValuesRepository.Find(w => w.LookUpTypeId == type.Id);
            IEnumerable <LookupValuesModel> lookupValuesModels = _mapper.Map <IEnumerable <LookupValuesModel> > (lookupValues);

            return(lookupValuesModels);
        }
Example #27
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            pnlMessage.Visible     = false;
            lblMessage.Visible     = false;
            pnlEmailExists.Visible = false;
            if (CustomLoginSetting == true)
            {
                lblDesiredLoginID.Visible = true;
                tbLoginID.Visible         = true;
                reqLoginID.Enabled        = true;
            }
            else
            {
                lblDesiredLoginID.Visible = false;
                tbLoginID.Visible         = false;
                reqLoginID.Enabled        = false;
            }

            if (!Page.IsPostBack)
            {
                iRedirect.Value = string.Empty;
                if (Request.QueryString["requestpage"] != null)
                {
                    iRedirect.Value = string.Format("default.aspx?page={0}", Request.QueryString["requestpage"]);
                }
                if (iRedirect.Value == string.Empty && Request.QueryString["requestUrl"] != null)
                {
                    iRedirect.Value = Request.QueryString["requestUrl"];
                }
                if (iRedirect.Value == string.Empty)
                {
                    iRedirect.Value = string.Format("default.aspx?page={0}", RedirectPageIDSetting);
                }

                LookupType maritalStatus = new LookupType(SystemLookupType.MaritalStatus);
                maritalStatus.Values.LoadDropDownList(ddlMaritalStatus);

                //
                // Setup the password strength regular expression.
                //
                regexPassword.ValidationExpression = Arena.Security.Login.GetPasswordStrengthRegularExpression(CurrentPortal.OrganizationID);
                regexPassword.ErrorMessage         = Arena.Security.Login.GetPasswordStrengthDescription(CurrentPortal.OrganizationID);
            }

            StringBuilder sbScript = new StringBuilder();

            sbScript.Append("\n\n<script language=\"javascript\" FOR=\"document\" EVENT=\"onreadystatechange\">\n");
            sbScript.Append("\tif(document.readyState==\"complete\");\n");
            sbScript.Append("\t{\n");
            sbScript.AppendFormat("\t\tdocument.frmMain.{0}.value = document.frmMain.{1}.value;\n", tbPassword.ClientID, iPassword.ClientID);
            sbScript.AppendFormat("\t\tdocument.frmMain.{0}.value = document.frmMain.{1}.value;\n", tbPassword2.ClientID, iPassword.ClientID);
            sbScript.Append("\t}\n");
            sbScript.Append("</script>\n\n");
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "setPassword", sbScript.ToString());
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "setPassword", sbScript.ToString());
        }
Example #28
0
        public void Deserialize(IntermediateFormatReader reader)
        {
            reader.RegisterDeclaration(LookupInfo.m_Declaration);
            while (reader.NextMember())
            {
                switch (reader.CurrentMember.MemberName)
                {
                case MemberName.ResultExpr:
                    this.m_resultExpr = (ExpressionInfo)reader.ReadRIFObject();
                    break;

                case MemberName.DataSetName:
                    this.m_dataSetName = reader.ReadString();
                    break;

                case MemberName.SourceExpr:
                    this.m_sourceExpr = (ExpressionInfo)reader.ReadRIFObject();
                    break;

                case MemberName.IsMultiValue:
                    if (reader.ReadBoolean())
                    {
                        this.m_lookupType = LookupType.LookupSet;
                    }
                    else
                    {
                        this.m_lookupType = LookupType.Lookup;
                    }
                    break;

                case MemberName.DestinationIndexInCollection:
                    this.m_destinationIndexInCollection = reader.ReadInt32();
                    break;

                case MemberName.Name:
                    this.m_name = reader.ReadString();
                    break;

                case MemberName.ExprHostID:
                    this.m_exprHostID = reader.ReadInt32();
                    break;

                case MemberName.DataSetIndexInCollection:
                    this.m_dataSetIndexInCollection = reader.ReadInt32();
                    break;

                case MemberName.LookupType:
                    this.m_lookupType = (LookupType)reader.ReadEnum();
                    break;

                default:
                    Global.Tracer.Assert(false);
                    break;
                }
            }
        }
Example #29
0
        public async Task <IActionResult> Get(LookupType lookupType, int?userId, int?parentId)
        {
            var result = await _mediator.Send(new Query { LookupType = lookupType, UserId = userId, ParentId = parentId });

            if (result.Success)
            {
                return(Ok(result.Data));
            }
            return(Unauthorized(result.Message));
        }
Example #30
0
 public PinnableObject(string pluginId, LookupType lookupType, int objectID, object state = null)
 {
     this.PluginID   = pluginId;
     this.ObjectID   = objectID;
     this.LookupType = lookupType;
     if (state != null)
     {
         SetState(state);
     }
 }
Example #31
0
 public static int GetCategoryIDFromLookupType(LookupType l)
 {
     switch (l) {
         case LookupType.Material:
             return TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material);
         case LookupType.Taxon:
             return TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon);
         default:
             return -1;
     }
 }
        public SelectedObjectChooser(User user, List<ViewModelBase> items, LookupType objectType)
        {
            InitializeComponent();

            GridView view = new GridView();

            var m = new RDESiteVisit();

            switch (objectType) {
                case LookupType.Site:
                    AddColumn(view, "Site Name", "SiteName", 300);
                    AddColumn(view, "Site ID", "SiteID");
                    AddColumn(view, "Longitude","Longitude");
                    AddColumn(view, "Latitude","Latitude");
                    break;
                case LookupType.SiteVisit:
                    AddColumn(view, "Site Visit Name", "VisitName", 300);
                    AddColumn(view, "Site Name", "Site.SiteName", 300);
                    AddColumn(view, "Site Visit ID", "SiteVisitID");
                    AddColumn(view, "Site ID", "Site.SiteID");
                    AddColumn(view, "Longitude","Site.Longitude");
                    AddColumn(view, "Latitude","Site.Latitude");
                    break;
                case LookupType.Material:
                    AddColumn(view, "Material Name", "MaterialName", 100);
                    AddColumn(view, "BiotaID", "BiotaID");
                    AddColumn(view, "Site Visit Name", "SiteVisit.VisitName", 300);
                    AddColumn(view, "Site Name", "SiteVisit.Site.SiteName", 300);
                    AddColumn(view, "Material ID", "MaterialID");
                    AddColumn(view, "Site Visit ID", "SiteVisit.SiteVisitID");
                    AddColumn(view, "Site ID", "SiteVisit.Site.SiteID");
                    AddColumn(view, "Longitude","SiteVisit.Site.Longitude");
                    AddColumn(view, "Latitude","SiteVisit.Site.Latitude");
                    break;

            }

            lvw.View = view;
            lvw.ItemsSource = items;

            lvw.AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler));

            lblStatus.Content = string.Format("{0} items listed.", items.Count);

            lvw.MouseRightButtonUp += new MouseButtonEventHandler(lvw_MouseRightButtonUp);

            this.Title = string.Format("Multiple {0} records found at this location", objectType.ToString());
        }
 /// <summary>
 /// Created new request ID for a given lookup type (tick, intraday bar, daily bar)
 /// </summary>
 /// <param name="lookupType">Lookup type: REQ_HST_TCK (tick), REQ_HST_DWM (daily) or REQ_HST_INT (intraday resolutions)</param>
 /// <param name="id">Sequential identifier</param>
 /// <returns></returns>
 private static string CreateRequestID(LookupType lookupType, int id)
 {
     return lookupType + id.ToString("0000000");
 }
        /// <summary>
        /// Saves the correct value from ProfileMember into the passed in PersonAttribute.
        /// If the Attribute is a YesNo attribute, then the Attribute for the ProfileMember will be marked as yes.
        /// If the Attribute is a DateTime attribute, then the value will be the DateActive value of the ProfileMember.
        /// If the Attribute is a Lookup, then the value will be the Lookup ID that has a matching Value to the MemberNotes property of the ProfileMember.
        /// If the Attribute is any other type, the value will be the MemberNotes.
        /// </summary>
        /// <param name="personAttribute"></param>
        /// <param name="member"></param>
        private bool SaveAttributeValue(PersonAttribute personAttribute, ProfileMember member, bool overwrite)
        {
            bool updated = false;
            try
            {
                switch (personAttribute.AttributeType)
                {
                    case DataType.YesNo:
                        if (overwrite || !personAttribute.HasIntValue)
                        {
                            personAttribute.IntValue = 1;
                            updated = true;
                        }
                        break;

                    case DataType.DateTime:
                        if (overwrite || !personAttribute.HasDateValue)
                        {
                            personAttribute.DateValue = member.DateActive;
                            updated = true;
                        }
                        break;

                    case DataType.Lookup:
                        if (!string.IsNullOrEmpty(member.MemberNotes.Trim()) && (overwrite || !personAttribute.HasIntValue))
                        {
                            LookupType lt = new LookupType(int.Parse(personAttribute.TypeQualifier));
                            Lookup lookup = lt.Values.SingleOrDefault(l => l.Value.ToUpper() == member.MemberNotes.Trim().ToUpper());
                            if (lookup != null)
                            {
                                personAttribute.IntValue = lookup.LookupID;
                                updated = true;
                            }
                        }
                        break;

                    default:
                        if (overwrite || !personAttribute.HasStringValue)
                        {
                            personAttribute.StringValue = member.MemberNotes.Trim();
                            updated = true;
                        }
                        break;
                }

                if (updated)
                {
                    personAttribute.Save(CurrentOrganization.OrganizationID, "TagsToAttributes");
                    // we must save the relationship between the document and the person
                    if (personAttribute.AttributeType == DataType.Document)
                    {
                        if (personAttribute.IntValue != -1)
                        {
                            PersonDocument newDocument = new PersonDocument(personAttribute.PersonID, personAttribute.IntValue);
                            newDocument.PersonID = personAttribute.PersonID;
                            newDocument.DocumentID = personAttribute.IntValue;
                            newDocument.SaveRelationship("TagsToAttributes");
                        }
                    }
                }

                return updated;
            }
            catch { throw; }
        }
Example #35
0
        public bool isObstructedByMap(LookupType lookupType, Vector2 point)
        {
            if (lookupType == LookupType.Tile)
            {
                point = TileCoordToPosition(point);
            }

            if (point.X == float.NaN ||
                point.Y == float.NaN ||
                point.X == float.NegativeInfinity ||
                point.Y == float.NegativeInfinity ||
                point.X == float.PositiveInfinity ||
                point.Y == float.PositiveInfinity
                )
                return true;
            // Block units from leaving the map!
            if ( isOutsideMapBounds(lookupType, point) )
                return true;

            if ( isWall(lookupType, point) )
                return true;

            return false;
        }
Example #36
0
 public bool isOutsideMapBounds(LookupType lookupType, Vector2 point)
 {
     // We duplicate code for granularity :)
         return
             point.X < 0 ||
             point.Y < 0 ||
             point.X + 1 > CollisionMap().GetLength(0) * TileWidth ||
             point.Y + 1 > CollisionMap().GetLength(1) * TileHeight;
 }
Example #37
0
        private void EditDetails(ViewModelBase selected, LookupType objectType)
        {
            if (selected == null || !selected.ObjectID.HasValue) {
                return;
            }

            if (HasPendingChanges) {
                if (this.Question("There are unsaved changes. Press 'Yes' to save all changes and continue, or 'No' to cancel the edit", "Edit unsaved data")) {
                    CommitPendingChanges();
                } else {
                    // abort!
                    return;
                }
            }

            PluginManager.Instance.EditLookupObject(objectType, selected.ObjectID.Value);
        }
Example #38
0
        private void addSetOperations(ContextMenuBuilder builder, LookupType type, params string[] idColAliases)
        {
            int index = -1;
            foreach (string alias in idColAliases) {
                var field = alias;
                for (int i = 0; i < Data.Columns.Count; ++i) {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias)) {
                        index = i;
                        break;
                    }
                }

                if (index >= 0) {
                    break;
                }
            }

            if (index > -1) {

                List<int> idSet = new List<int>();

                if (lvw.SelectedItems.Count > 1) {
                    foreach (object selected in lvw.SelectedItems) {
                        var row = selected as MatrixRow;
                        var selectedRow = Data.Rows.IndexOf(row);
                        idSet.Add((int)row[selectedRow]);
                    }
                } else {
                    Data.Rows.ForEach(row => {
                        var objectIndex = row[index];
                        if (objectIndex is int) {
                            idSet.Add((int)row[index]);
                        }
                    });
                }

                if (idSet.Count > 0) {
                    var commands = PluginManager.Instance.SolicitCommandsForObjectSet(idSet, type);
                    if (commands != null && commands.Count > 0) {
                        MenuItemBuilder b = new MenuItemBuilder();

                        var typeItem = b.New(type.ToString() + String.Format(" Set ({0} items)", idSet.Count)).MenuItem;

                        commands.ForEach((cmd) => {
                            if (cmd is CommandSeparator) {
                                typeItem.Items.Add(new Separator());
                            } else {
                                typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                    cmd.CommandAction(idSet);
                                }).MenuItem);
                            }
                        });
                        builder.AddMenuItem(typeItem);
                    }
                }
            }
        }
Example #39
0
 public static Formula Lookup(string n, LookupType type=LookupType.Auto)
 {
     Formula f = new Formula();
     f.formulaType = FormulaType.Lookup;
     f.lookupReference = n;
     f.lookupType = type;
     f.text = n;
     switch(type) {
         case LookupType.Auto:
             break;
         case LookupType.SkillParam:
             f.text = "skill."+f.text;
             break;
         case LookupType.ActorStat:
             f.text = "c."+f.text;
             break;
         case LookupType.ActorSkillParam:
             f.text = "c.skill."+f.text;
             break;
         case LookupType.TargetStat:
             f.text = "t."+f.text;
             break;
         case LookupType.TargetSkillParam:
             f.text = "t.skill."+f.text;
             break;
         case LookupType.NamedFormula:
             f.text = "f."+f.text;
             break;
         case LookupType.ReactedSkillParam:
             f.text = "reacted-skill."+f.text;
             break;
         //faked:...
         case LookupType.ActorEquipmentParam:
             f.text = "c.equip."+f.text;
             break;
         case LookupType.TargetEquipmentParam:
             f.text = "t.equip."+f.text;
             break;
         case LookupType.ReactedEffectType:
             f.text = "effect."+f.text;
             break;
         //TODO: AppliedEffectType?
         case LookupType.ActorStatusEffect:
             f.text = "c.status."+f.text;
             break;
         case LookupType.TargetStatusEffect:
             f.text = "t.status."+f.text;
             break;
         case LookupType.ActorMountStat:
             f.text = "c.mount."+f.text;
             break;
         case LookupType.ActorMountSkillParam:
             f.text = "c.mount.skill."+f.text;
             break;
         case LookupType.ActorMountEquipmentParam:
             f.text = "c.mount.equip."+f.text;
             break;
         case LookupType.ActorMountStatusEffect:
             f.text = "c.mount.status."+f.text;
             break;
         case LookupType.ActorMounterStat:
             f.text = "c.mounter."+f.text;
             break;
         case LookupType.ActorMounterSkillParam:
             f.text = "c.mounter.skill."+f.text;
             break;
         case LookupType.ActorMounterEquipmentParam:
             f.text = "c.mounter.equip."+f.text;
             break;
         case LookupType.ActorMounterStatusEffect:
             f.text = "c.mounter.status."+f.text;
             break;
         case LookupType.TargetMountStat:
             f.text = "t.mount."+f.text;
             break;
         case LookupType.TargetMountSkillParam:
             f.text = "t.mount.skill."+f.text;
             break;
         case LookupType.TargetMountEquipmentParam:
             f.text = "t.mount.equip."+f.text;
             break;
         case LookupType.TargetMountStatusEffect:
             f.text = "t.mount.status."+f.text;
             break;
         case LookupType.TargetMounterStat:
             f.text = "t.mounter."+f.text;
             break;
         case LookupType.TargetMounterSkillParam:
             f.text = "t.mounter.skill."+f.text;
             break;
         case LookupType.TargetMounterEquipmentParam:
             f.text = "t.mounter.equip."+f.text;
             break;
         case LookupType.TargetMounterStatusEffect:
             f.text = "t.mounter.status."+f.text;
             break;
     }
     return f;
 }
Example #40
0
 public void CopyFrom(Formula f)
 {
     /*		Debug.Log("copy from "+f);*/
     if(NullFormula(f)) { return; }
     name = f.name;
     text = f.text;
     formulaType = f.formulaType;
     constantValue = f.constantValue;
     lookupReference = f.lookupReference;
     lookupType = f.lookupType;
     mergeMode = f.mergeMode;
     mergeNth = f.mergeNth;
     equipmentSlots = f.equipmentSlots;
     equipmentCategories = f.equipmentCategories;
     searchReactedStatNames = f.searchReactedStatNames;
     searchReactedStatChanges = f.searchReactedStatChanges;
     searchReactedEffectCategories = f.searchReactedEffectCategories;
     arguments = f.arguments;
 }
Example #41
0
 // ----------------------------------------------------------------------------------------
 public LookupType InsertLookupType(LookupType newLookupType)
 {
     newLookupType.EnteredBy = "ElecLibUser";
     newLookupType.EntryDate = DateTime.Now;
     newLookupType.LookupTypeID = Convert.ToInt32(db.Insert(newLookupType));
     return newLookupType;
 }
Example #42
0
 // ----------------------------------------------------------------------------------------
 public void UpdateLookupType(LookupType lut)
 {
     // the incoming lut is the updated info
     lut.EntryDate = DateTime.Now;
     lut.EnteredBy = "ElecLibUser";
     db.Update(lut);
 }
Example #43
0
    public bool CanLookup(
		string fname, LookupType type,
		SkillDef scontext=null,
		Character ccontext=null,
		Character tcontext=null,
		Equipment econtext=null,
		Item icontext=null,
		Formula f=null
	)
    {
        switch(type) {
            case LookupType.Auto:
                return (icontext != null && icontext.HasParam(fname)) ||
                             (econtext != null && econtext.HasParam(fname)) ||
                             (scontext != null && scontext.HasParam(fname)) ||
                             (ccontext != null && ccontext.HasStat(fname)) ||
         							 (tcontext != null && tcontext.HasStat(fname));
            case LookupType.SkillParam:
                return scontext.HasParam(fname);
            case LookupType.ItemParam: {
                if(icontext == null && scontext != null) {
                    icontext = scontext.InvolvedItem;
                }
                if(icontext == null && econtext != null) {
                    icontext = econtext.baseItem;
                }
                return icontext != null && icontext.HasParam(fname);
            }
            case LookupType.ReactedItemParam: {
                icontext = scontext.currentReactedSkill.InvolvedItem;
                return icontext != null && icontext.HasParam(fname);
            }
            case LookupType.ActorStat:
                if(scontext != null) { return scontext.character.HasStat(fname); }
                if(econtext != null) { return econtext.wielder.HasStat(fname); }
                if(ccontext != null) { return ccontext.HasStat(fname); }
                return false;
            case LookupType.ActorMountStat: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountedCharacter; }
                if(econtext != null) { m = econtext.wielder.mountedCharacter; }
                if(tcontext != null) { m = tcontext.mountedCharacter; }
                if(m != null) { return m.HasStat(fname); }
                // Debug.Log("can lookup "+fname+" on mount "+m+" ? "+(m != null && m.HasStat(fname)));
                return false;
            }
            case LookupType.ActorMounterStat: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountingCharacter; }
                if(econtext != null) { m = econtext.wielder.mountingCharacter; }
                if(tcontext != null) { m = tcontext.mountingCharacter; }
                if(m != null) { return m.HasStat(fname); }
                return false;
            }
            case LookupType.ActorEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.character;
                } else if(ccontext == null && econtext != null) {
                    if(econtext.Matches(f.equipmentSlots, f.equipmentCategories)) {
                        return econtext.HasParam(fname);
                    } else {
                        ccontext = econtext.wielder;
                    }
                }
                return CanLookupEquipmentParamOn(fname, type, ccontext, f);
            case LookupType.ActorMountEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.character.mountedCharacter;
                } else if(ccontext == null && econtext != null) {
                    if(econtext.Matches(f.equipmentSlots, f.equipmentCategories)) {
                        return econtext.HasParam(fname);
                    } else {
                        ccontext = econtext.wielder.mountedCharacter;
                    }
                }
                return CanLookupEquipmentParamOn(fname, type, ccontext, f);
            case LookupType.ActorMounterEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.character.mountingCharacter;
                } else if(ccontext == null && econtext != null) {
                    if(econtext.Matches(f.equipmentSlots, f.equipmentCategories)) {
                        return econtext.HasParam(fname);
                    } else {
                        ccontext = econtext.wielder.mountingCharacter;
                    }
                }
                return CanLookupEquipmentParamOn(fname, type, ccontext, f);
            case LookupType.ActorSkillParam:
                if(scontext != null) { return scontext.HasParam(fname); }
                return false;
            case LookupType.ActorStatusEffect:
                if(scontext != null) { return scontext.character.HasStatusEffect(fname); }
                if(econtext != null) { return econtext.wielder.HasStatusEffect(fname); }
                if(ccontext != null) { return ccontext.HasStatusEffect(fname); }
                return false;
            case LookupType.ActorMountStatusEffect: {
                Character m = null;
                if(scontext != null) { m = scontext.character.mountedCharacter; }
                if(econtext != null) { m = econtext.wielder.mountedCharacter; }
                if(ccontext != null) { m = ccontext.mountedCharacter; }
                return m != null && m.HasStatusEffect(fname);
            }
            case LookupType.ActorMounterStatusEffect: {
                Character m = null;
                if(scontext != null) { m = scontext.character.mountingCharacter; }
                if(econtext != null) { m = econtext.wielder.mountingCharacter; }
                if(ccontext != null) { m = ccontext.mountingCharacter; }
                return m != null && m.HasStatusEffect(fname);
            }
            case LookupType.TargetStat:
                if(scontext != null) { return scontext.currentTargetCharacter.HasStat(fname); }
                if(tcontext != null) { return tcontext.HasStat(fname); }
                return false;
            case LookupType.TargetMountStat: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountedCharacter; }
                if(tcontext != null) { m = tcontext.mountedCharacter; }
                if(m != null) { return m.HasStat(fname); }
                return false;
            }
            case LookupType.TargetMounterStat: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountingCharacter; }
                if(tcontext != null) { m = tcontext.mountingCharacter; }
                if(m != null) { return m.HasStat(fname); }
                return false;
            }
            case LookupType.TargetStatusEffect:
                if(scontext != null) { return scontext.currentTargetCharacter.HasStatusEffect(fname); }
                if(tcontext != null) { return tcontext.HasStatusEffect(fname); }
                return false;
            case LookupType.TargetMountStatusEffect: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountedCharacter; }
                if(tcontext != null) { m = tcontext.mountedCharacter; }
                return m != null && m.HasStatusEffect(fname);
            }
            case LookupType.TargetMounterStatusEffect: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountingCharacter; }
                if(tcontext != null) { m = tcontext.mountingCharacter; }
                return m != null && m.HasStatusEffect(fname);
            }
            case LookupType.TargetEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.currentTargetCharacter;
                } else if(tcontext != null) {
                    ccontext = tcontext;
                } else {
                    ccontext = null;
                }
                return CanLookupEquipmentParamOn(fname, type, ccontext, f);
            case LookupType.TargetMountEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.currentTargetCharacter.mountedCharacter;
                } else if(tcontext != null) {
                    ccontext = tcontext.mountedCharacter;
                } else {
                    ccontext = null;
                }
                return CanLookupEquipmentParamOn(fname, type, ccontext, f);
            case LookupType.TargetMounterEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.currentTargetCharacter.mountingCharacter;
                } else if(tcontext != null) {
                    ccontext = tcontext.mountingCharacter;
                } else {
                    ccontext = null;
                }
                return CanLookupEquipmentParamOn(fname, type, ccontext, f);
            case LookupType.TargetSkillParam:
            case LookupType.ActorMountSkillParam:
            case LookupType.ActorMounterSkillParam:
            case LookupType.TargetMountSkillParam:
            case LookupType.TargetMounterSkillParam:
                return false;
            case LookupType.NamedFormula:
                return HasFormula(fname);
            case LookupType.ReactedSkillParam:
                if(scontext != null) {
                    return true;
                }
                return false;
            case LookupType.ReactedEffectType:
                if(scontext != null) {
                    string[] fnames = f.searchReactedStatNames;
                    return scontext.currentReactedSkill.lastEffects.
                        Where(fx => fx.Matches(fnames, f.searchReactedStatChanges, f.searchReactedEffectCategories)).
                        Count() > 0;
                }
                return false;
            case LookupType.SkillEffectType:
                if(scontext != null) {
                    string[] fnames = f.searchReactedStatNames;
                    return scontext.lastEffects.
                        Where(fx => fx.Matches(fnames, f.searchReactedStatChanges, f.searchReactedEffectCategories)).
                        Count() > 0;
                }
                return false;
        }
        return false;
    }
        protected void btnSaveGifts_Click(object sender, EventArgs e)
        {
            if (Person == null)
              {
            Response.Redirect(string.Format("~/default.aspx?page={0}&redirect={1}",
              LoginPageIDSetting, Request.RawUrl));
              }
              else
              {
            Person.Gifts.Clear();
            LookupCollection gifts = new LookupType(SystemLookupType.SpiritualGifts).Values;
            foreach (Lookup gift in gifts)
            {
              string[] split = gift.Value.Split(new Char[] { '/', ' ', ',', '.', ':', '\t' });

              foreach (string s in split)
              {
            if (hdnSelectedVals.Value.Contains(s.Trim()))
            {
              Lookup Gift = new Lookup(gift.LookupID);
              Person.Gifts.Add(Gift);
            }
              }
            }
            Person.SaveGifts(CurrentPortal.OrganizationID, CurrentUser.Identity.Name);

            DisplayConfirmation();
              }
        }
Example #45
0
    protected bool CanLookupEquipmentParamOn(
		string fname, LookupType type,
		Character ccontext, Formula f
	)
    {
        if(ccontext != null) {
            var equips = ccontext.Equipment.Where(eq =>
                eq.Matches(f.equipmentSlots, f.equipmentCategories) &&
                (fname == null || eq.HasParam(fname))
            );
            return equips.Count() > 0;
        }
        return false;
    }
Example #46
0
    protected float LookupEquipmentParamOn(
		string fname, LookupType type,
		Character ccontext, Formula f,
		SkillDef scontext
	)
    {
        if(ccontext != null) {
            var equips = ccontext.Equipment.Where(eq => eq.Matches(f.equipmentSlots, f.equipmentCategories) && eq.HasParam(fname));
            if(equips.Count() == 0) {
                Debug.LogError("No equipment with param "+fname);
                return float.NaN;
            }
            var results = equips.Select(eq => eq.GetParam(fname, scontext));
            switch(f.mergeMode) {
                case FormulaMergeMode.Sum:
                    return results.Sum();
                case FormulaMergeMode.Mean:
                    return results.Average(x => x);
                case FormulaMergeMode.Min:
                    return results.Min(x => x);
                case FormulaMergeMode.Max:
                    return results.Max(x => x);
                case FormulaMergeMode.First:
                    return results.First();
                case FormulaMergeMode.Last:
                    return results.Last();
                case FormulaMergeMode.Nth:
                    return results.ElementAt(f.mergeNth);
                default:
                    Debug.LogError("Unrecognized merge mode "+f.mergeMode);
                    return float.NaN;
            }
        }
        Debug.LogError("No ccontext "+ccontext+" given scontext "+scontext+"; Cannot find matching equipment to get param "+fname);
        return float.NaN;
    }
Example #47
0
        public Func<object, object, bool> GetMatcher(LookupType lookupType)
        {
            switch (lookupType)
            {
                case LookupType.ExactMatch:
                    return ExactMatch;

                case LookupType.GreaterThan:
                    return GreaterThan;

                case LookupType.GreaterThanOrEqual:
                    return GreaterThanOrEqual;

                case LookupType.LessThan:
                    return LessThanOrEqual;

                case LookupType.LessThanOrEqual:
                    return LessThanOrEqual;

                default:
                    return ExactMatch;
            }
        }
Example #48
0
    public float Lookup(
		string fname, LookupType type,
		SkillDef scontext=null,
		Character ccontext=null,
		Character tcontext=null,
		Equipment econtext=null,
		Item icontext=null,
		Formula f=null
	)
    {
        switch(type) {
            case LookupType.Auto: {
                float ret =
                    (icontext != null ? icontext.GetParam(fname) :
                    (econtext != null ? econtext.GetParam(fname) :
                    (scontext != null ? scontext.GetParam(fname) :
                    (ccontext != null ? ccontext.GetStat(fname) :
                    (tcontext != null ? tcontext.GetStat(fname) :
                    (HasFormula(fname) ? LookupFormula(fname).GetValue(this, scontext, ccontext, tcontext, econtext, icontext) : float.NaN))))));
                if(float.IsNaN(ret)) {
                    Debug.LogError("auto lookup failed for "+fname);
                }
                return ret;
            }
            case LookupType.SkillParam:
                return scontext.GetParam(fname);
            case LookupType.ItemParam: {
                if(icontext == null && scontext != null) {
                    icontext = scontext.InvolvedItem;
                }
                if(icontext == null && econtext != null) {
                    icontext = econtext.baseItem;
                }
                return icontext.GetParam(fname, scontext);
            }
            case LookupType.ReactedItemParam: {
                icontext = scontext.currentReactedSkill.InvolvedItem;
                return icontext.GetParam(fname, scontext);
            }
            case LookupType.ActorStat:
                if(scontext != null) { return scontext.character.GetStat(fname); }
                if(econtext != null) { return econtext.wielder.GetStat(fname); }
                if(ccontext != null) { return ccontext.GetStat(fname); }
                Debug.LogError("Cannot find actor stat "+fname);
                return float.NaN;
            case LookupType.ActorMountStat: {
                Character m = null;
                if(scontext != null) { m = scontext.character.mountedCharacter; }
                if(econtext != null) { m = econtext.wielder.mountedCharacter; }
                if(ccontext != null) { m = ccontext.mountedCharacter; }
                // Debug.Log("lookup "+fname+" on mount "+m+" ? "+(m != null ? m.GetStat(fname) : 0));
                if(m != null) {
                    return m.GetStat(fname);
                }
                Debug.LogError("Cannot find actor mount stat "+fname);
                return float.NaN;
            }
            case LookupType.ActorMounterStat: {
                Character m = null;
                if(scontext != null) { m = scontext.character.mountingCharacter; }
                if(econtext != null) { m = econtext.wielder.mountingCharacter; }
                if(ccontext != null) { m = ccontext.mountingCharacter; }
                if(m != null) {
                    return m.GetStat(fname);
                }
                Debug.LogError("Cannot find actor mounter stat "+fname);
                return float.NaN;
            }
            case LookupType.ActorEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.character;
                } else if(ccontext == null && econtext != null) {
                    if(econtext.Matches(f.equipmentSlots, f.equipmentCategories)) {
                        return econtext.GetParam(fname);
                    } else {
                        ccontext = econtext.wielder;
                    }
                }
                return LookupEquipmentParamOn(fname, type, ccontext, f, scontext);
            case LookupType.ActorMountEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.character.mountedCharacter;
                } else if(ccontext == null && econtext != null) {
                    if(econtext.Matches(f.equipmentSlots, f.equipmentCategories)) {
                        return econtext.GetParam(fname);
                    } else {
                        ccontext = econtext.wielder.mountedCharacter;
                    }
                }
                return LookupEquipmentParamOn(fname, type, ccontext, f, scontext);
            case LookupType.ActorMounterEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.character.mountingCharacter;
                } else if(ccontext == null && econtext != null) {
                    if(econtext.Matches(f.equipmentSlots, f.equipmentCategories)) {
                        return econtext.GetParam(fname);
                    } else {
                        ccontext = econtext.wielder.mountingCharacter;
                    }
                }
                return LookupEquipmentParamOn(fname, type, ccontext, f, scontext);
            case LookupType.ActorStatusEffect:
            case LookupType.ActorMountStatusEffect:
            case LookupType.ActorMounterStatusEffect:
                Debug.LogError("lookup semantics not defined for own status effect "+fname);
                return float.NaN;
            case LookupType.ActorSkillParam:
                //TODO: look up skill by slot, name, type?
                if(scontext != null) { return scontext.GetParam(fname); }
                Debug.LogError("Cannot find skill param "+fname);
                return float.NaN;
            case LookupType.TargetStat:
                if(scontext != null) { return scontext.currentTargetCharacter.GetStat(fname); }
                if(tcontext != null) { return tcontext.GetStat(fname); }
                Debug.LogError("Cannot find target stat "+fname);
                return float.NaN;
            case LookupType.TargetMountStat: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountedCharacter; }
                if(tcontext != null) { m = tcontext.mountedCharacter; }
                if(m != null) { return m.GetStat(fname); }
                Debug.LogError("Cannot find target stat "+fname);
                return float.NaN;
            }
            case LookupType.TargetMounterStat: {
                Character m = null;
                if(scontext != null) { m = scontext.currentTargetCharacter.mountingCharacter; }
                if(tcontext != null) { m = tcontext.mountingCharacter; }
                if(m != null) { return m.GetStat(fname); }
                Debug.LogError("Cannot find target stat "+fname);
                return float.NaN;
            }
            case LookupType.TargetEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.currentTargetCharacter;
                } else if(tcontext != null) {
                    ccontext = tcontext;
                } else {
                    ccontext = null;
                }
                return LookupEquipmentParamOn(fname, type, ccontext, f, scontext);
            case LookupType.TargetMountEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.currentTargetCharacter.mountedCharacter;
                } else if(tcontext != null) {
                    ccontext = tcontext.mountedCharacter;
                } else {
                    ccontext = null;
                }
                return LookupEquipmentParamOn(fname, type, ccontext, f, scontext);
            case LookupType.TargetMounterEquipmentParam:
                if(scontext != null) {
                    ccontext = scontext.currentTargetCharacter.mountingCharacter;
                } else if(tcontext != null) {
                    ccontext = tcontext.mountingCharacter;
                } else {
                    ccontext = null;
                }
                return LookupEquipmentParamOn(fname, type, ccontext, f, scontext);
            case LookupType.TargetStatusEffect:
            case LookupType.TargetMountStatusEffect:
            case LookupType.TargetMounterStatusEffect:
                Debug.LogError("lookup semantics not defined for target status effect "+fname);
                return float.NaN;
            case LookupType.TargetSkillParam:
            case LookupType.ActorMountSkillParam:
            case LookupType.ActorMounterSkillParam:
            case LookupType.TargetMountSkillParam:
            case LookupType.TargetMounterSkillParam:
            //TODO: look up skill by slot, name, type?
                Debug.LogError("Cannot find "+type+" "+fname);
                return float.NaN;
            case LookupType.NamedFormula:
                if(!HasFormula(fname)) {
                    Debug.LogError("Missing formula "+fname);
                    return float.NaN;
                }
                // Debug.Log("F:"+LookupFormula(fname));
                return LookupFormula(fname).GetValue(this, scontext, ccontext, tcontext, econtext, icontext);
            case LookupType.ReactedSkillParam:
                if(scontext != null) {
                    return scontext.currentReactedSkill.GetParam(fname);
                }
                Debug.LogError("Cannot find reacted skill for "+fname);
                return float.NaN;
            case LookupType.ReactedEffectType:
                if(scontext != null) {
                    //ignore lookupRef
                    string[] fnames = f.searchReactedStatNames;
                    var results = scontext.currentReactedSkill.lastEffects.
                        Where(fx => fx.Matches(fnames, f.searchReactedStatChanges, f.searchReactedEffectCategories)).
                        Select(fx => fx.value);
                    switch(f.mergeMode) {
                        case FormulaMergeMode.Sum:
                            return results.Sum();
                        case FormulaMergeMode.Mean:
                            return results.Average(x => x);
                        case FormulaMergeMode.Min:
                            return results.Min(x => x);
                        case FormulaMergeMode.Max:
                            return results.Max(x => x);
                        case FormulaMergeMode.First:
                            return results.First();
                        case FormulaMergeMode.Last:
                            return results.Last();
                        case FormulaMergeMode.Nth:
                            return results.ElementAt(f.mergeNth);
                    }
                } else {
                    Debug.LogError("Skill effect lookups require a skill context.");
                    return float.NaN;
                }
                Debug.LogError("Cannot find reacted effects for "+f);
                return float.NaN;
            case LookupType.SkillEffectType:
                if(scontext != null) {
                    string[] fnames = f.searchReactedStatNames;
                    //ignore lookupRef
                    var results = scontext.lastEffects.
                        Where(fx => fx.Matches(fnames, f.searchReactedStatChanges, f.searchReactedEffectCategories)).
                        Select(fx => fx.value);
                    switch(f.mergeMode) {
                        case FormulaMergeMode.Sum:
                            return results.Sum();
                        case FormulaMergeMode.Mean:
                            return results.Average(x => x);
                        case FormulaMergeMode.Min:
                            return results.Min(x => x);
                        case FormulaMergeMode.Max:
                            return results.Max(x => x);
                        case FormulaMergeMode.First:
                            return results.First();
                        case FormulaMergeMode.Last:
                            return results.Last();
                        case FormulaMergeMode.Nth:
                            Debug.Log("nth "+f.mergeNth+" is "+results.ElementAt(f.mergeNth));
                            return results.ElementAt(f.mergeNth);
                    }
                } else {
                    Debug.LogError("Skill effect lookups require a skill context.");
                    return float.NaN;
                }
                Debug.LogError("Cannot find effects for "+f);
                return float.NaN;
        }
        Debug.LogError("failed to look up "+type+" "+fname+" with context s:"+scontext+", c:"+ccontext+", e:"+econtext+", i:"+icontext+" and formula "+f);
        return float.NaN;
    }
Example #49
0
        private void AddLookupItem(ContextMenuBuilder builder, LookupType lookupType, params String[] aliases)
        {
            int index = -1;
            foreach (string alias in aliases) {
                var field = alias;

                for (int i = 0; i < Data.Columns.Count; ++i) {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias)) {
                        index = i;
                        break;
                    }
                }

                if (index >= 0) {
                    break;
                }
            }

            if (index > -1) {
                var row = lvw.SelectedItem as MatrixRow;

                int objectId = 0;
                var enabled = false;
                if (row[index] != null) {
                    if (Int32.TryParse(row[index].ToString(), out objectId) && objectId > 0) {
                        enabled = true;
                    }
                }

                var pinnable = PluginManager.Instance.GetPinnableForLookupType(lookupType, objectId);

                var commands = new List<Command>();

                if (pinnable != null) {
                    var vm = PluginManager.Instance.GetViewModel(pinnable);
                    if (vm != null) {
                        var selected = new List<ViewModelBase>();
                        selected.Add(vm);
                        commands.AddRange(PluginManager.Instance.SolicitCommandsForObjects(selected));
                    }
                }

                if (commands.Count > 0) {

                    MenuItemBuilder b = new MenuItemBuilder();

                    var typeItem = b.New(lookupType.ToString()).MenuItem;

                    typeItem.Items.Add(b.New("Pin {0} to pinboard", lookupType).Handler(() => {
                        PluginManager.Instance.PinObject(pinnable);
                    }).Enabled(enabled).MenuItem);
                    typeItem.Items.Add(new Separator());

                    commands.ForEach((cmd) => {
                        if (cmd is CommandSeparator) {
                            typeItem.Items.Add(new Separator());
                        } else {
                            typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                cmd.CommandAction(pinnable);
                            }).Enabled(enabled).MenuItem);
                        }
                    });

                    builder.AddMenuItem(typeItem);
                } else {
                    builder.New("Edit " + lookupType.ToString()).Handler(() => {
                        PluginManager.Instance.EditLookupObject(lookupType, objectId);
                    }).Enabled(enabled).End();
                }
            }

            addSetOperations(builder, lookupType, aliases);
        }
Example #50
0
        public bool isWall(LookupType lookupType, Vector2 point)
        {
            // FIXME - Unsafe, can crash on exiting the map.
            int x = (int)(point.X / TileWidth);
            int y = (int)(point.Y / TileHeight);

            return CollisionMap()[x, y] == 0;
        }
Example #51
0
 public LookupEventArgs(string requestId, LookupType lookupType, LookupSequence lookupSequence)
 {
     _requestId = requestId;
     _lookupType = lookupType;
     _lookupSequence = lookupSequence;
 }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            _useGroupType = (CurrentOrganization.Settings["UseGroupType"] != null && CurrentOrganization.Settings["UseGroupType"].Trim().ToLower() == "true");

            CategoryID = Int32.Parse(CategorySetting);

            SetCaptions();
            RegisterScripts();

            if (!Page.IsPostBack)
            {
                this.CurrentPortalPage.TemplateControl.Title = "Group Locator";

                ddlGroupType.Items.Clear();
                ddlGroupTopic.Items.Clear();
                ddlGroupAge.Items.Clear();
                ddlMaritalPreference.Items.Clear();

                //GroupType
                ddlGroupType.Items.Add(new ListItem("Any", "-1"));
                ddlGroupType.Items[0].Selected = true;
                if (_useGroupType)
                {
                    LookupCollection luTypes = new LookupType(SystemLookupType.SmallGroupType).Values;
                    foreach (Lookup luType in luTypes)
                        if (luType.Value.ToLower() != "unknown")
                            ddlGroupType.Items.Add(new ListItem(luType.Value, luType.LookupID.ToString()));
                }
                else
                {
                    //SqlDataReader rdr = new GroupClusterData().GetClusterRegistrationTypes(Arena.Core.ArenaContext.Current.Organization.OrganizationID);
                    SqlDataReader rdr = new GroupClusterData().GetClusterTypes(Int16.Parse(CategorySetting), Arena.Core.ArenaContext.Current.Organization.OrganizationID); //KM-edit; took ", Arena.Core.ArenaContext.Current.Organization.OrganizationID);" out of GetClusterTypes. There were too many items.
                    while (rdr.Read())
                        if ((bool)rdr["allow_registration"])
                            ddlGroupType.Items.Add(new ListItem(rdr["type_name"].ToString(), rdr["cluster_type_id"].ToString()));
                    rdr.Close();
                }

                //GroupTopic
                LookupCollection lookupCollection = new LookupType(SystemLookupType.SmallGroupTopic).Values;
                trGroupTopic.Visible = (lookupCollection.Count > 0);
                ddlGroupTopic.Items.Add(new ListItem("Any", "-1"));
                ddlGroupTopic.Items[0].Selected = true;
                foreach (Lookup lookup in lookupCollection)
                    if (lookup.Value != "Unknown" && lookup.Value != "Any")
                        ddlGroupTopic.Items.Add(new ListItem(lookup.Value, lookup.LookupID.ToString()));

                //DayOfWeek
                lookupCollection = new LookupType(SystemLookupType.DayOfWeek).Values;
                trDayOfWeek.Visible = (lookupCollection.Count > 0);
                ddlDayOfWeek.Items.Add(new ListItem("Any", "-1"));
                ddlDayOfWeek.Items[0].Selected = true;
                ddlDayOfWeek2.Items.Add(new ListItem("Any", "-1"));
                ddlDayOfWeek2.Items[0].Selected = true;
                foreach (Lookup lookup in lookupCollection)
                    if (lookup.Value != "Unknown" && lookup.Value != "Any")
                    {
                        ddlDayOfWeek.Items.Add(new ListItem(lookup.Value, lookup.LookupID.ToString()));
                        ddlDayOfWeek2.Items.Add(new ListItem(lookup.Value, lookup.LookupID.ToString()));
                    }

                //GroupAge
                lookupCollection = new LookupType(SystemLookupType.AgeRangePreference).Values;
                trAgeRange.Visible = (lookupCollection.Count > 0);
                ddlGroupAge.Items.Add(new ListItem("Any", "-1"));
                ddlGroupAge.Items[0].Selected = true;
                foreach (Lookup lookup in lookupCollection)
                    if (lookup.Value != "Unknown" && lookup.Value != "Any")
                        ddlGroupAge.Items.Add(new ListItem(lookup.Value, lookup.LookupID.ToString()));

                //GroupMaritalPreference
                lookupCollection = new LookupType(SystemLookupType.MaritalPreference).Values;
                trMaritalPreference.Visible = (lookupCollection.Count > 0);
                ddlMaritalPreference.Items.Add(new ListItem("Any", "-1"));
                ddlMaritalPreference.Items[0].Selected = true;
                foreach (Lookup lookup in lookupCollection)
                    if (lookup.Value != "Unknown" && lookup.Value != "Any")
                        ddlMaritalPreference.Items.Add(new ListItem(lookup.Value, lookup.LookupID.ToString()));

                AreaCollection areas = new AreaCollection(CurrentOrganization.OrganizationID);
                trArea.Visible = (areas.Count > 0);
                foreach (Area area in areas)
                {
                    ddlAreas.Items.Add(new ListItem(area.Name, area.AreaID.ToString()));
                }
                if (RequireAreaSetting == "false")
                    ddlAreas.Items.Insert(0, new ListItem("", "-1"));

                if (CurrentPerson != null && CurrentPerson.PersonID != -1)
                {
                    if (CurrentPerson.PrimaryAddress != null && CurrentPerson.PrimaryAddress.AddressID != -1)
                    {
                        tbAddress.Text = CurrentPerson.PrimaryAddress.StreetLine1;
                        tbCity.Text = CurrentPerson.PrimaryAddress.City;
                        tbState.Text = CurrentPerson.PrimaryAddress.State;
                        tbZip.Text = CurrentPerson.PrimaryAddress.PostalCode;
                    }
                }

                ShowSearch();
            }
        }