Example #1
0
        //public async Task SaveUser(SiteUser siteUser)
        //{
        //    var result = await _userManager.UpdateAsync(siteUser);
        //    if (!result.Succeeded)
        //    {
        //        //TODO: log it
        //    }
        //}

        public async Task <List <UserProperty> > FetchByUser(string siteId, string userId)
        {
            var result = new List <UserProperty>();

            var kvpList = await _kvpStorage.FetchById(
                siteId, //projectId
                "*",    // featureId
                siteId, //setId
                userId  // subSetId
                ).ConfigureAwait(false);

            foreach (var kvp in kvpList)
            {
                var prop = new UserProperty();
                prop.CreatedUtc  = kvp.CreatedUtc;
                prop.Key         = kvp.Key;
                prop.ModifiedUtc = kvp.ModifiedUtc;
                prop.SiteId      = kvp.SetId;
                prop.UserId      = kvp.SubSetId;
                prop.Value       = kvp.Value;

                result.Add(prop);
            }

            return(result);
        }
Example #2
0
        public static UserProperty GetGtdGuidFromMailItem(MailItem mailItem)
        {
            UserProperty property = null;

            property = mailItem.UserProperties.Find(GTD_GUID);
            return(property);
        }
        internal void Update(ContactItem outlookContactItem, Syncronizer sync)
        {
            this.EntryID                 = outlookContactItem.EntryID;
            this.FileAs                  = outlookContactItem.FileAs;
            this.FullName                = outlookContactItem.FullName;
            this.Email1Address           = ContactPropertiesUtils.GetOutlookEmailAddress1(outlookContactItem);
            this.MobileTelephoneNumber   = outlookContactItem.MobileTelephoneNumber;
            this.Categories              = outlookContactItem.Categories;
            this.LastModificationTime    = outlookContactItem.LastModificationTime;
            this.Company                 = outlookContactItem.CompanyName;
            this.TitleFirstLastAndSuffix = GetTitleFirstLastAndSuffix(outlookContactItem);

            UserProperties userProperties = outlookContactItem.UserProperties;
            UserProperty   prop           = userProperties[sync.OutlookPropertyNameId];

            this.UserProperties.GoogleContactId = prop != null?string.Copy((string)prop.Value) : null;

            if (prop != null)
            {
                Marshal.ReleaseComObject(prop);
            }

            prop = userProperties[sync.OutlookPropertyNameSynced];
            this.UserProperties.LastSync = prop != null ? (DateTime)prop.Value : (DateTime?)null;
            if (prop != null)
            {
                Marshal.ReleaseComObject(prop);
            }

            Marshal.ReleaseComObject(userProperties);
        }
Example #4
0
        /// <summary>
        /// Log the various User Properties.
        /// </summary>
        /// <param name="ai">The Appointment item.</param>
        /// <param name="thresholdLevel">Only log if logging configured at this level or higher.</param>
        public static void LogProperties(AppointmentItem ai, log4net.Core.Level thresholdLevel)
        {
            if (((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root.Level.Value > thresholdLevel.Value)
            {
                return;
            }

            UserProperties ups = null;
            UserProperty   up  = null;

            try {
                log.Debug(OutlookOgcs.Calendar.GetEventSummary(ai));
                ups = ai.UserProperties;
                for (int p = 1; p <= ups.Count; p++)
                {
                    try {
                        up = ups[p];
                        log.Debug(up.Name + "=" + up.Value.ToString());
                    } finally {
                        up = (UserProperty)OutlookOgcs.Calendar.ReleaseObject(up);
                    }
                }
            } catch (System.Exception ex) {
                OGCSexception.Analyse("Failed to log Appointment UserProperties", ex);
            } finally {
                ups = (UserProperties)OutlookOgcs.Calendar.ReleaseObject(ups);
            }
        }
Example #5
0
    public static async Task <string> RunAsUserAsync(string userName, string password, string[] roles)
    {
        using var scope = _scopeFactory.CreateScope();

        var userManager = scope.ServiceProvider.GetService <UserManager <UserProperty> >();

        var user = new UserProperty {
            Username = userName
        };

        var result = await userManager.CreateAsync(user, password);

        if (roles.Any())
        {
            var roleManager = scope.ServiceProvider.GetService <RoleManager <IdentityRole> >();

            foreach (var role in roles)
            {
                await roleManager.CreateAsync(new IdentityRole(role));
            }

            await userManager.AddToRolesAsync(user, roles);
        }

        /*if (result.Succeeded)
         * {
         *  _currentUserId = user.Id;
         *
         *  return _currentUserId;
         * }*/

        var errors = string.Join(Environment.NewLine, result.ToApplicationResult().Errors);

        throw new Exception($"Unable to create {userName}.{Environment.NewLine}{errors}");
    }
Example #6
0
        public static String Get(AppointmentItem ai, MetadataId key)
        {
            String retVal = null;
            String searchKey;

            if (Exists(ai, key, out searchKey))
            {
                UserProperties ups  = null;
                UserProperty   prop = null;
                try {
                    ups  = ai.UserProperties;
                    prop = ups.Find(searchKey);
                    if (prop != null)
                    {
                        if (prop.Type != OlUserPropertyType.olText)
                        {
                            log.Warn("Non-string property " + searchKey + " being retrieved as String.");
                        }
                        retVal = prop.Value.ToString();
                    }
                } finally {
                    prop = (UserProperty)OutlookOgcs.Calendar.ReleaseObject(prop);
                    ups  = (UserProperties)OutlookOgcs.Calendar.ReleaseObject(ups);
                }
            }
            return(retVal);
        }
Example #7
0
        public void PublishAdvancedBinaryDecodeTestv5()
        {
            // Arrange
            byte[] encodedCorrect = new byte[] { 109, 0, 19, 116, 104, 105, 115, 116, 111, 112, 105, 99, 47, 115, 111, 109, 101, 116, 104, 105, 110,
                                                 103, 0, 42, 79, 2, 0, 0, 48, 57, 35, 0, 33, 8, 0, 14, 114, 101, 115, 112, 111, 110, 115, 101, 32, 116, 111,
                                                 112, 105, 99, 9, 0, 6, 1, 2, 3, 4, 5, 6, 38, 0, 3, 79, 110, 101, 0, 4, 112, 114, 111, 112, 38, 0, 6, 115, 101,
                                                 99, 111, 110, 100, 0, 8, 112, 114, 111, 112, 101, 114, 116, 121, 11, 254, 255, 255, 127, 3, 0, 6, 98, 105,
                                                 110, 97, 114, 121, 6, 5, 4, 3, 2, 1 };
            MokChannel mokChannel = new(encodedCorrect);
            // Act
            MqttMsgPublish publish = MqttMsgPublish.Parse(60, MqttProtocolVersion.Version_5, mokChannel);

            // Assert
            Assert.Equal(Topic, publish.Topic);
            Assert.Equal(MessageId, publish.MessageId);
            Assert.Equal(new byte[] { 6, 5, 4, 3, 2, 1 }, publish.Message);
            Assert.Equal((byte)MqttQoSLevel.ExactlyOnce, (byte)publish.QosLevel);
            Assert.Equal(true, publish.DupFlag);
            Assert.Equal(false, publish.Retain);
            Assert.Equal(publish.ContentType, "binary");
            Assert.Equal(publish.IsPayloadUTF8, false);
            Assert.Equal(publish.SubscriptionIdentifier, 268435454);
            Assert.Equal(publish.UserProperties.Count, 2);
            var prop = new UserProperty("One", "prop");

            Assert.Equal(((UserProperty)publish.UserProperties[0]).Name, prop.Name);
            Assert.Equal(((UserProperty)publish.UserProperties[0]).Value, prop.Value);
            prop = new UserProperty("second", "property");
            Assert.Equal(((UserProperty)publish.UserProperties[1]).Name, prop.Name);
            Assert.Equal(((UserProperty)publish.UserProperties[1]).Value, prop.Value);
            Assert.Equal(publish.CorrelationData, new byte[] { 1, 2, 3, 4, 5, 6 });
            Assert.Equal(publish.ResponseTopic, "response topic");
            Assert.Equal(publish.TopicAlias, (ushort)33);
            Assert.Equal(publish.MessageExpiryInterval, 12345);
        }
Example #8
0
 /// <summary>
 /// Save the new user or update an exist user
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 private int SaveProfile(UserProperty user)
 {
     try
     {
         user.FirstName               = ValidateSecurity.ValidateString(txtFirstName.Text, false);
         user.LastName                = ValidateSecurity.ValidateString(txtLastName.Text, false);
         user.Address                 = ValidateSecurity.ValidateString(CountryStateCityEditMode.SelectedAddress, false);
         user.City                    = CountryStateCityEditMode.SelectedCity;
         user.Region                  = CountryStateCityEditMode.SelectedState;
         user.Country                 = CountryStateCityEditMode.SelectedCountry;
         user.PostalCode              = CountryStateCityEditMode.SelectedPostalCode;
         user.Longitude               = CountryStateCityEditMode.SelectedLongitude;
         user.Latitude                = CountryStateCityEditMode.SelectedLatitude;
         user.Telephone               = ValidateSecurity.ValidateString(txtPhone.Text, false);
         user.SkypeName               = ValidateSecurity.ValidateString(txtSkype.Text, false);
         user.Twitter                 = ValidateSecurity.ValidateString(txtTwitter.Text, false);
         user.FaceBook                = ValidateSecurity.ValidateString(txtFacebook.Text, false);
         user.Google                  = ValidateSecurity.ValidateString(txtGoogle.Text, false);
         user.LinkedIn                = ValidateSecurity.ValidateString(txtLinkedIn.Text, false);
         user.Agreement               = "A001";
         user.CustomerType            = Convert.ToInt32(ddlWhoareYou.SelectedValue);
         user.NexsoEnrolment          = Convert.ToInt32(ddlSource.SelectedValue);
         user.Language                = Convert.ToInt32(ddlLanguage.SelectedValue);
         user.AllowNexsoNotifications = Convert.ToInt32(chkNotifications.Checked);
     }
     catch (Exception exc)
     //Module failed to load
     {
         Exceptions.
         ProcessModuleLoadException(
             this, exc);
     }
     return(0);
 }
        public void SubscribeDecodeAvanceTestsv5()
        {
            // Arrange
            byte[] encodedCorrect = new byte[] { 249, 1, 0, 42, 223, 1, 11, 253, 255, 255, 127, 38, 0, 8, 108, 111, 110, 103, 32, 111, 110, 101, 0, 210,
                                                 111, 110, 101, 32, 118, 101, 114, 121, 32, 108, 111, 110, 103, 32, 111, 110, 101, 32, 116, 111, 32, 116,
                                                 101, 115, 116, 32, 102, 111, 114, 32, 111, 110, 99, 101, 32, 104, 111, 119, 32, 116, 104, 105, 115, 32,
                                                 119, 105, 108, 108, 32, 101, 110, 99, 111, 100, 101, 32, 97, 110, 100, 32, 109, 97, 107, 101, 32, 105,
                                                 116, 32, 114, 101, 97, 108, 108, 108, 108, 108, 108, 121, 121, 121, 121, 121, 121, 121, 32, 115, 111,
                                                 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 32, 115, 111, 111, 111, 111, 111, 111, 111, 111,
                                                 111, 111, 111, 111, 111, 111, 32, 115, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
                                                 111, 111, 111, 32, 115, 111, 111, 111, 111, 111, 111, 111, 111, 111, 32, 108, 111, 110, 103, 46, 32, 89,
                                                 101, 97, 44, 32, 116, 104, 97, 116, 32, 115, 104, 111, 117, 108, 100, 32, 98, 101, 32, 116, 101, 115, 116,
                                                 101, 100, 32, 102, 111, 114, 32, 114, 101, 97, 108, 32, 105, 110, 32, 116, 104, 101, 32, 114, 101, 97,
                                                 108, 32, 108, 105, 102, 101, 32, 97, 115, 32, 119, 101, 108, 108, 0, 5, 102, 105, 114, 115, 116, 1, 0, 6,
                                                 115, 101, 99, 111, 110, 100, 2 };
            MokChannel mokChannel = new MokChannel(encodedCorrect);
            // Act
            MqttMsgSubscribe subscribe = MqttMsgSubscribe.Parse(130, MqttProtocolVersion.Version_5, mokChannel);

            // Assert
            Assert.Equal(subscribe.MessageId, (ushort)42);
            Assert.Equal(subscribe.QoSLevels, new MqttQoSLevel[] { MqttQoSLevel.AtLeastOnce, MqttQoSLevel.ExactlyOnce });
            Assert.Equal(subscribe.Topics, new string[] { "first", "second" });
            Assert.Equal(subscribe.SubscriptionIdentifier, 268435453);
            var prop = new UserProperty("long one", "one very long one to test for once how this will encode and make it reallllllyyyyyyy soooooooooooo soooooooooooooo soooooooooooooooo sooooooooo long. Yea, that should be tested for real in the real life as well");

            Assert.Equal(((UserProperty)subscribe.UserProperties[0]).Name, prop.Name);
            Assert.Equal(((UserProperty)subscribe.UserProperties[0]).Value, prop.Value);
        }
Example #10
0
        /// <summary>
        /// 建立好友关系
        /// </summary>
        /// <param name="model">建立好友模型</param>
        private void CreateFriendRelationShip(NewFriendRelationShipModel model)
        {
            IRepository <UserFriend> friendRep = Factory.Factory <IRepository <UserFriend> > .GetConcrete <UserFriend>();

            IRepository <ShortMessage> smRep = Factory.Factory <IRepository <ShortMessage> > .GetConcrete <ShortMessage>();

            IRepository <UserProperty> propertyRep = Factory.Factory <IRepository <UserProperty> > .GetConcrete <UserProperty>();

            //新建好友关系
            UserFriend uf1 = new UserFriend(model.RequestUser.UserID, model.ReciveUser.UserID, model.ReciveUser.UserName, model.ReciveUser.UserTiny);
            UserFriend uf2 = new UserFriend(model.ReciveUser.UserID, model.RequestUser.UserID, model.RequestUser.UserName, model.RequestUser.UserTiny);

            //加入仓库
            friendRep.Add(uf1);
            friendRep.Add(uf2);

            //需要添加各自的好友数
            UserProperty requestUser = propertyRep.Find(new Specification <UserProperty>(up => up.UserID == model.RequestUser.UserID));
            UserProperty receiveUser = propertyRep.Find(new Specification <UserProperty>(up => up.UserID == model.ReciveUser.UserID));

            //添加好友数
            requestUser.AddFriendsCount();
            receiveUser.AddFriendsCount();
            //更新数据
            propertyRep.Update(requestUser);
            propertyRep.Update(receiveUser);

            //好友关系持久化
            friendRep.PersistAll();

            //好友数量持久化
            propertyRep.PersistAll();
        }
Example #11
0
        /// <summary>
        /// Completely remove all OGCS custom properties
        /// </summary>
        /// <param name="ai">The AppointmentItem to strip attributes from</param>
        /// <returns>Whether any properties were removed</returns>
        public static Boolean Extirpate(ref AppointmentItem ai)
        {
            List <String> keyNames = new List <String>()
            {
                metadataIdKeyName(MetadataId.forceSave),
                metadataIdKeyName(MetadataId.gCalendarId),
                metadataIdKeyName(MetadataId.gEventID),
                metadataIdKeyName(MetadataId.locallyCopied),
                metadataIdKeyName(MetadataId.ogcsModified)
            };
            Boolean        removedProperty = false;
            UserProperties ups             = null;

            try {
                ups = ai.UserProperties;
                for (int p = ups.Count; p > 0; p--)
                {
                    UserProperty prop = null;
                    try {
                        prop = ups[p];
                        if (keyNames.Exists(k => prop.Name.StartsWith(k)))
                        {
                            log.Fine("Removed " + prop.Name);
                            prop.Delete();
                            removedProperty = true;
                        }
                    } finally {
                        prop = (UserProperty)Calendar.ReleaseObject(prop);
                    }
                }
            } finally {
                ups = (UserProperties)Calendar.ReleaseObject(ups);
            }
            return(removedProperty);
        }
Example #12
0
 private static void TryAddProperty(UserPropertyDictionary dictionary, UserProperty property)
 {
     if (!dictionary.ContainsKey(property.Name))
     {
         dictionary.Add(property);
     }
 }
Example #13
0
        private MailItem FindMailItem(string guidToFind, Folder folder, out bool found, out string newFolderPath)
        {
            found         = false;
            newFolderPath = string.Empty;

            if (folder.DefaultItemType == OlItemType.olMailItem)
            {
                string folderName = folder.Name; // For debug
                foreach (var item in folder.Items)
                {
                    if (item is MailItem)
                    {
                        MailItem     mailItem     = item as MailItem;
                        UserProperty userProperty = Utils.GetGtdGuidFromMailItem(mailItem);
                        if (userProperty != null)
                        {
                            if (guidToFind.Equals(userProperty.Value.ToString()))
                            {
                                found         = true;
                                newFolderPath = (mailItem.Parent as Folder).FolderPath;
                                return(mailItem);
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public JsonResult AddProperty(Property propertyObj)
        {
            JsonResult result = new JsonResult();

            if (ModelState.IsValid)
            {
                using (db)
                {
                    UserAccount usrObj = db.UserAccounts.Where(u => u.UserName.Equals(User.Identity.Name.ToString())).FirstOrDefault();

                    db.Properties.Add(propertyObj);
                    UserProperty usrPropObj = new UserProperty
                    {
                        UserID     = usrObj.UserID,
                        PropertyID = propertyObj.PropertyID
                    };

                    db.UserProperties.Add(usrPropObj);
                    db.SaveChanges();
                    result.Data = new { Success = true };
                }
            }
            else
            {
                result.Data = new { Success = false, Error = "Unable to save. Please enter valid values." };
            }

            return(result);
        }
        public static void AddUserProperty(MailItem mailitem, string ticketid)
        {
            UserProperties mailUserProperties = null;
            UserProperty   mailUserProperty   = null;

            try
            {
                mailUserProperties = mailitem.UserProperties;
                mailUserProperty   = mailUserProperties.Add("KayakoTicketId", OlUserPropertyType.olText, true, 1);
                // Where 1 is OlFormatText (introduced in Outlook 2007)
                mailUserProperty.Value = ticketid;
                mailitem.Save();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (mailUserProperty != null)
                {
                    Marshal.ReleaseComObject(mailUserProperty);
                }
                if (mailUserProperties != null)
                {
                    Marshal.ReleaseComObject(mailUserProperties);
                }
            }
        }
Example #16
0
        public void ConnectUserPropDecodeTestv5()
        {
            // Arrange
            byte[] correctEncoded = new byte[] { 115, 0, 4, 77, 81, 84, 84, 5, 246, 4, 210, 34, 38, 0, 3, 79, 110, 101, 0, 8, 80, 114, 111, 112, 101, 114,
                                                 116, 121, 38, 0, 3, 84, 119, 111, 0, 10, 80, 114, 111, 112, 101, 114, 116, 105, 101, 115, 0, 8, 99, 108,
                                                 105, 101, 110, 116, 73, 68, 0, 10, 119, 105, 108, 108, 32, 116, 111, 112, 105, 99, 0, 12, 119, 105, 108,
                                                 108, 32, 109, 101, 115, 115, 97, 103, 101, 0, 9, 85, 115, 101, 114, 32, 78, 97, 109, 101, 0, 21, 65, 32,
                                                 116, 101, 120, 116, 32, 112, 97, 115, 115, 119, 111, 114, 100, 32, 36, 36, 39, 47, 37 };
            MokChannel mokChannel = new MokChannel(correctEncoded);
            // Act
            MqttMsgConnect connect = MqttMsgConnect.Parse((byte)MqttMessageType.Connect << 4, MqttProtocolVersion.Version_5, mokChannel);

            // Assert
            Assert.Equal((byte)MqttProtocolVersion.Version_5, (byte)connect.ProtocolVersion);
            Assert.Equal(ClientID, connect.ClientId);
            Assert.Equal(UserName, connect.Username);
            Assert.Equal(Password, connect.Password);
            Assert.Equal(WillTopic, connect.WillTopic);
            Assert.Equal(WillMessage, connect.WillMessage);
            Assert.Equal(KeepAlivePeriod, connect.KeepAlivePeriod);
            Assert.Equal(true, connect.CleanSession);
            Assert.Equal(2, connect.UserProperties.Count);
            var prop = new UserProperty("One", "Property");

            Assert.Equal(((UserProperty)connect.UserProperties[0]).Name, prop.Name);
            Assert.Equal(((UserProperty)connect.UserProperties[0]).Value, prop.Value);
            prop = new UserProperty("Two", "Properties");
            Assert.Equal(((UserProperty)connect.UserProperties[1]).Name, prop.Name);
            Assert.Equal(((UserProperty)connect.UserProperties[1]).Value, prop.Value);
        }
Example #17
0
        public void AddPropertyToUser(string propertyName, string propertyValue, User user)
        {
            var propertyID       = _context.Properties.Where(i => i.PropertyName == propertyName).Select(i => i.Id).FirstOrDefault();
            var hasGivenProperty = _context.UserProperties.Where(i => i.UserId == user.Id && i.PropertyId == propertyID).FirstOrDefault();

            if (hasGivenProperty == null)
            {
                UserProperty userProperty = new UserProperty
                {
                    // Depending on user role, add different properties.
                    Id           = Guid.NewGuid(),
                    IsActive     = true,
                    IsDeleted    = false,
                    DateCreated  = DateTime.Now,
                    DateModified = DateTime.Now,
                    UserId       = user.Id,
                    // Following property ID is expected to be for School No.
                    PropertyId = propertyID,
                    Value      = propertyValue
                };
                _userProperties.AddUserProperties(userProperty);
            }
            else
            {
                Console.WriteLine("User already has the given property.");
            }
        }
Example #18
0
        private Func <Task> getChangeMeAction(CommandContext ctx, string propertyStr, string value)
        {
            return(new Func <Task>(async() =>
            {
                var userId = ctx.User.Id.ToString();
                var allUsers = UserDbService.GetUsers();
                if (!allUsers.ContainsKey(userId))
                {
                    throw new Exception("You are not registered in any server");
                }
                UserProperty property = UserProperty.Unknown;
                try
                {
                    property = (UserProperty)Enum.Parse(typeof(UserProperty), propertyStr);
                } catch {
                    throw new Exception("This is not an existing or editable property");
                }
                switch (property)
                {
                case UserProperty.MahjsoulName: UserDbService.SetMahjsoulName(userId, value); break;

                case UserProperty.MahjsoulFriendId: UserDbService.SetMahjsoulFriendId(userId, value); break;

                case UserProperty.TenhouName: UserDbService.SetTenhouName(userId, value); break;

                default: throw new Exception($"You can't change your {propertyStr}");
                }
                await ctx.RespondAsync($"<@{ctx.User.Id}>'s {property} has been changed to {value}.");
            }));
        }
Example #19
0
        public static Boolean Exists(AppointmentItem ai, MetadataId searchId, out String searchKey)
        {
            searchKey = metadataIdKeyName(searchId);

            int maxSet;
            int?keySet = getKeySet(ai, out maxSet);

            if (keySet.HasValue && keySet.Value != 0)
            {
                searchKey += "-" + keySet.Value.ToString("D2");
            }

            UserProperties ups  = null;
            UserProperty   prop = null;

            try {
                ups  = ai.UserProperties;
                prop = ups.Find(searchKey);
                if (searchId == MetadataId.gCalendarId)
                {
                    return(prop != null && prop.Value.ToString() == Settings.Instance.UseGoogleCalendar.Id);
                }
                else
                {
                    return(prop != null && Get(ai, MetadataId.gCalendarId) == Settings.Instance.UseGoogleCalendar.Id);
                }
            } catch {
                return(false);
            } finally {
                prop = (UserProperty)OutlookOgcs.Calendar.ReleaseObject(prop);
                ups  = (UserProperties)OutlookOgcs.Calendar.ReleaseObject(ups);
            }
        }
Example #20
0
        /// <summary>
        /// 获取用户类型
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetUserTypeByUserID(Guid id)
        {
            IRepository <UserProperty> uRep = Factory.Factory <IRepository <UserProperty> > .GetConcrete <UserProperty>();

            UserProperty up = uRep.Find(new Specification <UserProperty>(u => u.UserID == id));

            return(up.Type);
        }
Example #21
0
 public void Awake()
 {
     singleton = this;
     if (alwaysWipe || PlayerPrefs.GetString(resourceName) == "") {
         Wipe();
     }
     Load();
 }
Example #22
0
 public void Awake()
 {
     singleton = this;
     if (alwaysWipe || PlayerPrefs.GetString(resourceName) == "")
     {
         Wipe();
     }
     Load();
 }
 private string getYourPropertySentence(UserProperty userProperty)
 {
     var verb = "is";
     if (userProperty.name.EndsWith("s")) //TODO: use more advanced naturallanguage to determine if plural, deer could be plural
     {
         verb = "are";
     }
     return string.Format(propertySentence, userProperty.name, verb, userProperty.value);
 }
Example #24
0
        public static void SyncMilestonesToOutlook(String calendarName, Release release, EntityListResult <Milestone> milestones)
        {
            //set sprint map
            Dictionary <long, Milestone> milestonesMap = new Dictionary <long, Milestone>();

            foreach (Milestone milestone in milestones.data)
            {
                milestonesMap[milestone.Id] = milestone;
            }

            //iterate outlook appointments
            Items resultItems = OutlookUtils.GetAppointmentsInRange(calendarName, new DateTime(2015, 1, 1), new DateTime(2030, 1, 1));

            foreach (AppointmentItem appointment in resultItems)
            {
                UserProperty releaseUP            = appointment.UserProperties[OutlookUtils.APPOINTMENT_RELEASE_ID_FIELD];
                int          appointmentReleaseId = (releaseUP == null ? NO_ID_VALUE : int.Parse(releaseUP.Value));

                UserProperty milestoneUP            = appointment.UserProperties[OutlookUtils.APPOINTMENT_MILESTONE_ID_FIELD];
                int          appointmentMilestoneId = (milestoneUP == null ? NO_ID_VALUE : int.Parse(milestoneUP.Value));

                if (appointmentReleaseId != NO_ID_VALUE && appointmentMilestoneId != NO_ID_VALUE) //milestone
                {
                    if (milestonesMap.ContainsKey(appointmentMilestoneId))
                    {
                        Milestone tempMilestone = milestonesMap[appointmentMilestoneId];
                        milestonesMap.Remove(appointmentMilestoneId);


                        if (tempMilestone != null)
                        {
                            SyncMilestoneToOutlook(tempMilestone, appointment);
                        }
                    }
                    else
                    {
                        //Delete a Milestone that no longer exist
                        appointment.Delete();
                    }
                }

                Marshal.ReleaseComObject(appointment);
            }

            //create milestones that were not deleted from map
            foreach (Milestone milestone in milestonesMap.Values)
            {
                Dictionary <String, Object> customFields = new Dictionary <String, Object>();
                customFields.Add(OutlookUtils.APPOINTMENT_RELEASE_ID_FIELD, ((Release)(milestone.Releases.data.ElementAt <BaseEntity>(0))).Id);
                customFields[OutlookUtils.APPOINTMENT_MILESTONE_ID_FIELD] = milestone.Id;
                String milestoneName = getMilestoneAppointmentName(milestone);
                MilestoneDataContainer msExtraData = getMilestoneData(milestone);

                OutlookUtils.AddAppointment(milestoneName, milestone.GetStartDate(), milestone.GetEndDate(), msExtraData.Category, msExtraData.ReminderMinutesBeforeStart, msExtraData.ReminderSet, customFields, true);
            }
        }
Example #25
0
        public static void AddOGCSproperty(ref AppointmentItem ai, String key, DateTime value)
        {
            UserProperty prop = ai.UserProperties.Find(key);

            if (prop == null)
            {
                ai.UserProperties.Add(key, OlUserPropertyType.olDateTime);
            }
            ai.UserProperties[key].Value = value;
        }
        public List <UserProperty> GetDerivedProperties(AnalyzedChat analyzedChat, UserProperty givenProperty, UserData userData)
        {
            var properties = new List <UserProperty>();

            properties.AddRange(getSex(analyzedChat, givenProperty, userData));
            //TODO: add more of these, address, age (note time it was retrieved and factor that into response), derive from asl, etc.
            //TODO: use machine learning to determine sex and other properties, train on conversations with known males and females or known specific property versus know doesn't have property

            return(properties);
        }
Example #27
0
        private string getYourPropertySentence(UserProperty userProperty)
        {
            var verb = "is";

            if (userProperty.name.EndsWith("s")) //TODO: use naturallanguage to determine if plural
            {
                verb = "are";
            }
            return(string.Format(yourPropertySentence, userProperty.name, verb, userProperty.value));
        }
Example #28
0
        public override void SetValue(object component, object value)
        {
            UserProperty property = null;
            var          input    = ( string )value;

            if (int.TryParse(input, out int intValue))
            {
                property = new UserIntProperty(mKey, intValue);
            }
            else if (float.TryParse(input, out float floatValue))
            {
                property = new UserFloatProperty(mKey, floatValue);
            }
            else if (bool.TryParse(input, out bool boolValue))
            {
                property = new UserBoolProperty(mKey, boolValue);
            }
            else if (input.Contains(","))
            {
                var vectorContents = input.Trim('[', ']')
                                     .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                var vectorFloats = new float[vectorContents.Length];
                for (int i = 0; i < vectorContents.Length; i++)
                {
                    if (!float.TryParse(vectorContents[i], out var vectorFloat))
                    {
                        break;
                    }

                    vectorFloats[i] = vectorFloat;
                }

                if (vectorFloats.Length == 3)
                {
                    property = new UserVector3Property(mKey, new Vector3(vectorFloats[0], vectorFloats[1], vectorFloats[2]));
                }
                else if (vectorFloats.Length == 4)
                {
                    property = new UserVector4Property(
                        mKey, new Vector4(vectorFloats[0], vectorFloats[1], vectorFloats[2], vectorFloats[3]));
                }
                else
                {
                    property = new UserByteArrayProperty(mKey, vectorFloats.Cast <byte>().ToArray());
                }
            }

            if (property == null)
            {
                property = new UserStringProperty(mKey, input);
            }

            mDictionary[mKey] = property;
        }
Example #29
0
 /// <summary>
 /// Adds information to the current user. Add the user the following roles: Registered Users and NexsoUser
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 private int SaveProfile(UserProperty user)
 {
     try
     {
         user.FirstName  = ValidateSecurity.ValidateString(txtFirstName.Text, false);
         user.LastName   = ValidateSecurity.ValidateString(txtLastName.Text, false);
         user.Address    = CountryStateCityEditMode.SelectedAddress;
         user.City       = CountryStateCityEditMode.SelectedCity;
         user.Region     = CountryStateCityEditMode.SelectedState;
         user.Country    = CountryStateCityEditMode.SelectedCountry;
         user.PostalCode = CountryStateCityEditMode.SelectedPostalCode;
         user.Longitude  = CountryStateCityEditMode.SelectedLongitude;
         user.Latitude   = CountryStateCityEditMode.SelectedLatitude;
         user.email      = ValidateSecurity.ValidateString(txtEmail.Text, false);
         //user.Telephone = txtPhone.Text;
         //user.SkypeName = txtSkype.Text;
         //user.Twitter = txtTwitter.Text;
         //user.FaceBook = txtFacebook.Text;
         //user.Google = txtGoogle.Text;
         //user.LinkedIn = txtLinkedIn.Text;
         user.Agreement = "A001";
         //user.CustomerType = Convert.ToInt32(ddWhoareYou.SelectedValue);
         //user.NexsoEnrolment = Convert.ToInt32(ddSource.SelectedValue);
         //user.Language = Convert.ToInt32(ddLanguage.SelectedValue);
         //user.AllowNexsoNotifications = Convert.ToInt32(chkNotifications.Checked);
         if (currentUser != null)
         {
             UserInfo myDnnUser = currentUser;
             if (!myDnnUser.IsInRole("Registered Users"))
             {
                 var      oDnnRoleController = new RoleController();
                 RoleInfo oCurrentRole       = oDnnRoleController.GetRoleByName(this.PortalId, "Registered Users");
                 oDnnRoleController.AddUserRole(this.PortalId, myDnnUser.UserID, oCurrentRole.RoleID,
                                                System.DateTime.Now.AddDays(-1),
                                                DotNetNuke.Common.Utilities.Null.NullDate);
             }
             if (!myDnnUser.IsInRole("NexsoUser"))
             {
                 var      oDnnRoleController = new RoleController();
                 RoleInfo oCurrentRole       = oDnnRoleController.GetRoleByName(this.PortalId, "NexsoUser");
                 oDnnRoleController.AddUserRole(this.PortalId, myDnnUser.UserID, oCurrentRole.RoleID,
                                                System.DateTime.Now.AddDays(-1),
                                                DotNetNuke.Common.Utilities.Null.NullDate);
             }
         }
     }
     catch (Exception exc)
     //Module failed to load
     {
         Exceptions.
         ProcessModuleLoadException(
             this, exc);
     }
     return(0);
 }
Example #30
0
        public static void SyncSprintsToOutlook(String calendarName, Release release, EntityListResult <Sprint> sprints)
        {
            //set sprint map
            Dictionary <long, Sprint> sprintMap = new Dictionary <long, Sprint>();

            foreach (Sprint sprint in sprints.data)
            {
                sprintMap[sprint.Id] = sprint;
            }

            //iterate outlook appointments
            Items resultItems = OutlookUtils.GetAppointmentsInRange(calendarName, new DateTime(2015, 1, 1), new DateTime(2030, 1, 1));

            foreach (AppointmentItem appointment in resultItems)
            {
                UserProperty releaseUP            = appointment.UserProperties[OutlookUtils.APPOINTMENT_RELEASE_ID_FIELD];
                int          appointmentReleaseId = (releaseUP == null ? NO_ID_VALUE : int.Parse(releaseUP.Value));

                UserProperty sprintUP            = appointment.UserProperties[OutlookUtils.APPOINTMENT_SPRINT_ID_FIELD];
                int          appointmentSprintId = (sprintUP == null ? NO_ID_VALUE : int.Parse(sprintUP.Value));

                if (appointmentReleaseId != NO_ID_VALUE && appointmentSprintId != NO_ID_VALUE) //sprint
                {
                    if (sprintMap.ContainsKey(appointmentSprintId))
                    {
                        Sprint tempSprint = sprintMap[appointmentSprintId];
                        sprintMap.Remove(appointmentSprintId);


                        if (tempSprint != null)
                        {
                            SyncSprintToOutlook(tempSprint, appointment);
                        }
                    }
                    else
                    {
                        //Delete a Sprint that no longer exist
                        appointment.Delete();
                    }
                }

                Marshal.ReleaseComObject(appointment);
            }

            //create sprints that were not deleted from map
            foreach (Sprint sprint in sprintMap.Values)
            {
                Dictionary <String, Object> customFields = new Dictionary <String, Object>();
                customFields.Add(OutlookUtils.APPOINTMENT_RELEASE_ID_FIELD, sprint.Release.Id);
                customFields[OutlookUtils.APPOINTMENT_SPRINT_ID_FIELD] = sprint.Id;
                String sprintName = getSprintAppointmentName(sprint);
                OutlookUtils.AddAppointment(sprintName, sprint.StartDate, sprint.EndDate, "", 0, false, customFields, true);
            }
        }
Example #31
0
        private void CompareUserProperty(UserProperty a, UserProperty b)
        {
            if (a == null || b == null)
            {
                Assert.IsTrue(a == null ? (b == null) : (b != null));
                return;
            }

            Assert.AreEqual(a.ValueType, b.ValueType);
            Assert.AreEqual(a.Name, b.Name);
            Assert.AreEqual(a.GetValue(), b.GetValue());
        }
Example #32
0
 public void Dispose()
 {
     if (_wsApplication != null)
     {
         _wsApplication.Dispose();
         _wsApplication = null;
     }
     if (_property != null)
     {
         Marshal.ReleaseComObject(_property);
         _property = null;
     }
 }
Example #33
0
 public override void AddUserProperty(Guid userID, Guid treeNodeID, Guid fieldPlaceHolderID, Guid propertyID, int order)
 {
     UserProperty entity = new UserProperty()
     {
         ID = Guid.NewGuid(),
         ClassificationTreeID = treeNodeID,
         PropertyID = propertyID,
         UserID = userID,
         FieldPlaceHolderID = fieldPlaceHolderID,
         Sequence = order
     };
     UserProperties.InsertOnSubmit(entity);
     this.SubmitChanges();
 }
		protected override void SetCompletedPropery(ComparisonInformation compare, MailItem mail, UserProperty prop, UserProperty prop2)
		{
			if (Convert.ToInt32(prop2.Value) < 1)
			{
				prop.Value = NamedProperties.CompareComplete;
			}
			var attachProp = mail.UserProperties.Find(NamedProperties.CompareAttachment, true) ?? mail.UserProperties.Add(NamedProperties.CompareAttachment,
																														  OlUserPropertyType.olText,
																														  true);

			string attachment = attachProp.Value.ToString();
			attachProp.Value = string.Format(CultureInfo.CurrentCulture,
											 "{0}={1}¬{2};{3}",
											 compare.Modified.FileName,
											 compare.RedLineFile,
											 compare.RedLineChangeSummary,
											 attachment);
		}
Example #35
0
 internal UserPropertyEventArgs(User user, UserProperty property, string value, bool loginEvent)
 {
     User = user;
     Property = property;
     Value = value;
     LoginEvent = LoginEvent;
 }
Example #36
0
 public WsUserProperty(UserProperty property)
 {
     _property = property;
 }
Example #37
0
 public override void Start()
 {
     singleton = this;
     StartCoroutine(startInner());
 }