Example #1
0
        // Constructor
        /// <summary>
        /// Open a profile (create if not exist) and load it.
        /// </summary>
        /// <param name="profileDirectory">The root directory of the profile</param>
        public CraftitudeProfile(DirectoryInfo profileDirectory)
        {
            Directory = profileDirectory;

            _craftitudeDirectory = Directory.CreateSubdirectory("craftitude");
            _craftitudeDirectory.CreateSubdirectory("repositories"); // repository package lists
            _craftitudeDirectory.CreateSubdirectory("packages"); // cached package setups

            _bsonFile = _craftitudeDirectory.GetFile("profile.bson");

            if (!_bsonFile.Exists)
            {
                ProfileInfo = new ProfileInfo();
            }
            else
            {
                using (FileStream bsonStream = _bsonFile.Open(FileMode.OpenOrCreate))
                {
                    using (var bsonReader = new BsonReader(bsonStream))
                    {
                        var jsonSerializer = new JsonSerializer();
                        ProfileInfo = jsonSerializer.Deserialize<ProfileInfo>(bsonReader) ?? new ProfileInfo();
                    }
                }
            }
        }
        internal override void Update(NotificationData data)
        {
            base.Update(data);

            //新しい通知を追加し、キープされた通知を再配置する
            var newDatas = ((SocialNotificationData)data).LogItems;
            var oldItemInfo = _actionLogs;
            var updatedDatas = (from nwItm in newDatas
                                join oldItm in oldItemInfo on nwItm.RawData equals oldItm.RawData into nwOldPair
                                from kpdItm in nwOldPair.DefaultIfEmpty()
                                select new { NewItemData = nwItm, OldItemInfo = kpdItm }).ToArray();
            foreach (var item in updatedDatas.Select((obj, idx) => new { Index = idx, Result = obj }))
                if (item.Result.OldItemInfo == null)
                    _actionLogs.Insert(item.Index, new NotificationItemInfo(item.Result.NewItemData, Client));
                else
                {
                    var oldIdx = 0;
                    if ((oldIdx = _actionLogs.IndexOf(item.Result.OldItemInfo)) >= 0 && item.Index != oldIdx)
                        _actionLogs.Move(oldIdx, item.Index);
                }
            //古い通知を削除
            for (var i = updatedDatas.Length; i < _actionLogs.Count; i++)
                _actionLogs.RemoveAt(i);

            if (Actor.Id != _actionLogs.First().Actor.Id)
                Actor = Client.People.InternalGetAndUpdateProfile(((SocialNotificationData)data).Actor);
        }
        public CecilSerializerContext(AssemblyDefinition assembly)
        {
            Assembly = assembly;
            SerializableTypesProfiles = new Dictionary<string, ProfileInfo>();
            SerializableTypes = new ProfileInfo();
            SerializableTypesProfiles.Add("Default", SerializableTypes);
            ComplexTypes = new Dictionary<TypeDefinition, SerializableTypeInfo>();

            SiliconStudioCoreAssembly = assembly.Name.Name == "SiliconStudio.Core"
                ? assembly
                : assembly.MainModule.AssemblyResolver.Resolve("SiliconStudio.Core");
        }
Example #4
0
        private void Auhtenticate(object state)
        {
            Thread.Sleep(500);
            if (_userId != _password)
                ProfileInfo = null;

            ProfileInfo = new ProfileInfo
            {
                FullName = "Fakhrul Azran Nawi",
                UserId = "fan2014"
            };

            CloseForm();
        }
        public void ChangeCurrentUserProfile(ProfileInfo profile)
        {
            var da = InstanceBuilder.CreateInstance<UserMaintenanceServiceDA>();
            UserInfoEntity userInfoEntity = da.GetUser(AppContext.Current.UserName);
            userInfoEntity.Title = profile.Title;
            userInfoEntity.Email = profile.Email;
            userInfoEntity.TelephoneNo = profile.TelephoneNo;
            userInfoEntity.FaxNo = profile.FaxNo;
            userInfoEntity.MobileNo = profile.MobileNo;
            userInfoEntity.PageNo = profile.PageNo;
            userInfoEntity.Office = profile.Office;

            InstanceBuilder.CreateInstance<UserMaintenanceServiceDA>().UpdateUserInfo(userInfoEntity,
               new List<DataFilterEntity>(),
               null);
        }
Example #6
0
        public Application()
        {
            Applicant = new ProfileInfo();
            Agent = new ProfileInfo();
            RegistrationDate = DateTime.Now;
            StartDateTime = DateTime.Now;
            EndDateTime = DateTime.Now;
            EndUserTypeEnum = Data.EndUserTypeEnum.Residential;
            ProductTypeEnum = Data.ProductTypeEnum.Unifi;
            ApplicantTypeEnum = Data.ApplicantTypeEnum.Malaysian;
            ApplicationTypeEnum = Data.ApplicationTypeEnum.NewRegistration;
            Services = new List<Service>();
            ApplicationState = Data.ApplicationState.Incomplete;

            ApplicationId = DateTime.Now.ToString("yyMMddHHmmssnfmy xmnbzmz");
        }
 public bool Update(ProfileInfo o)
 {
     var success = false;
     if (o != null)
     {
         //using (var scope = new TransactionScope())
         {
             var product = _unitOfWork.ProfileInfoRepo.GetByID(o.Id);
             if (product != null)
             {
                 //product = productEntity.ProductName;
                 _unitOfWork.ProfileInfoRepo.Update(product);
                 _unitOfWork.Save();
                // scope.Complete();
                 success = true;
             }
         }
     }
     return success;
 }
        public HiiP.Infrastructure.Interface.BusinessEntities.ProfileInfo GetCurrentUserProfile()
        {
            var da = InstanceBuilder.CreateInstance<UserMaintenanceServiceDA>();
            UserInfoEntity entity = da.GetUser(AppContext.Current.UserName);
            ProfileInfo profile = new ProfileInfo(
                entity.Title,
                entity.Email,
                entity.TelephoneNo,
                entity.FaxNo,
                entity.MobileNo,
                entity.PageNo,
                entity.Office);

            //Delegations
            profile.Branch = entity.Branch;
            profile.Unit = entity.Unit;
            profile.SubUnit = entity.SubUnit;

            profile.VersionNo = entity.VersionNo;

            return profile;
        }
        /** 
            @brief Return the configuration parameters of the SDK's TouchlessController application.
            @param[out] pinfo the profile info structure of the configuration parameters.
            @return PXC_STATUS_NO_ERROR if the parameters were returned successfully; otherwise, return one of the following errors:
            PXC_STATUS_ITEM_UNAVAILABLE - Item not found/not available.\n
            PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize.\n                        
        */


        public pxcmStatus QueryProfile(out ProfileInfo pinfo)
        {
            pinfo = new ProfileInfo();
            return PXCMTouchlessController_QueryProfile(instance, pinfo);
        }
 internal static extern pxcmStatus PXCMSpeechSynthesis_SetProfile(IntPtr tts, ProfileInfo pinfo);
 internal static extern pxcmStatus PXCMTouchlessController_SetProfile(IntPtr instance, ProfileInfo pinfo);
 public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
 {
     ProfileInfoCollection profiles = new ProfileInfoCollection();
     FileInfo fi = this.GetProfileFile(usernameToMatch);
     if (fi != null && fi.Exists == true && fi.LastAccessTime < userInactiveSinceDate)
     {
         ProfileInfo profile = new ProfileInfo(usernameToMatch, false, fi.LastAccessTime, fi.LastWriteTime, GetProfileSize(fi));
         profiles.Add(profile);
     }
     totalRecords = profiles.Count;
     return profiles;
 }
	public void CopyTo(ProfileInfo[] array, int index) {}
 private static extern bool LoadUserProfile([In] System.IntPtr token, ref ProfileInfo profileInfo);
 public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
 {
     ProfileInfoCollection profiles = new ProfileInfoCollection();
     foreach (FileInfo fi in this.ProfileFiles)
     {
         if (fi != null && fi.Exists == true)
         {
             ProfileInfo profile = new ProfileInfo(this.GetUsernameFromFile(fi.Name), false, fi.LastAccessTime, fi.LastWriteTime, GetProfileSize(fi));
             profiles.Add(profile);
         }
     }
     totalRecords = profiles.Count;
     return profiles;
 }
 /**
     @brief The function sets the current working algorithm configuration parameters.
     @param[in] pinfo		The configuration parameters.
     @return PXCM_STATUS_NO_ERROR				Successful execution.
 */
 public pxcmStatus SetProfile(ProfileInfo pinfo)
 {
     return PXCMSpeechSynthesis_SetProfile(instance, pinfo);
 }
 /**
     @brief The function returns the current working algorithm configuration parameters.
     @param[out] pinfo		The configuration parameters, to be returned.
     @return PXCM_STATUS_NO_ERROR				Successful execution.
 */
 public pxcmStatus QueryProfile(out ProfileInfo pinfo)
 {
     return QueryProfile(WORKING_PROFILE, out pinfo);
 }
 private ProfileInfo GetSerializableTypes(string profile)
 {
     ProfileInfo profileInfo;
     if (!SerializableTypesProfiles.TryGetValue(profile, out profileInfo))
     {
         profileInfo = new ProfileInfo();
         SerializableTypesProfiles.Add(profile, profileInfo);
     }
     return profileInfo;
 }
	// Methods
	public void Add(ProfileInfo profileInfo) {}
Example #20
0
                public ProfileInfo Clone()
                {
                    ProfileInfo clone = new ProfileInfo();
                    clone.Count = this.Count;
                    clone.Time = this.Time;
                    clone.TotalTime = this.TotalTime;

                    return clone;
                }
 public static extern bool LoadUserProfile(
     [In] IntPtr hToken,
     ref ProfileInfo lpProfileInfo);
        /// <summary>
        /// Does the actual impersonation.
        /// </summary>
        /// <param name="userName">The name of the user to act as.</param>
        /// <param name="domain">The domain name of the user to act as.</param>
        /// <param name="password">The password of the user to act as.</param>
        /// <param name="loadUserProfile">if set to <c>true</c> [load user profile].</param>
        private void ImpersonateValidUser(string userName, string domain, string password, bool loadUserProfile)
        {
            this.profileHandle = IntPtr.Zero;
            this.userToken = IntPtr.Zero;

            WindowsIdentity tempWindowsIdentity = null;
            IntPtr token = IntPtr.Zero;

            ProfileInfo profileInfo = new ProfileInfo();

            profileInfo.Size = Marshal.SizeOf(profileInfo.GetType());
            profileInfo.Flags = 0x1;
            profileInfo.UserName = userName;

            profileInfo.ProfilePath = null;
            profileInfo.DefaultPath = null;

            profileInfo.PolicyPath = null;
            profileInfo.ServerName = domain;

            try
            {
                if (!RevertToSelf())
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                if (LogonUser(userName, domain, password, Logon32LogonInteractive, Logon32ProviderDefault, ref token) == 0)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                if (DuplicateToken(token, 2, ref this.userToken) == 0)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                if (loadUserProfile && !LoadUserProfile(this.userToken, ref profileInfo))
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }

                // Save the handle for dispose
                this.profileHandle = profileInfo.Profile;

                using (tempWindowsIdentity = new WindowsIdentity(this.userToken))
                {
                    this.impersonationContext = tempWindowsIdentity.Impersonate();
                }
            }
            finally
            {
                if (token != IntPtr.Zero)
                {
                    CloseHandle(token);
                }
            }
        }
 /**
     @brief The function sets the working algorithm configurations. 
     @param[in] config		The algorithm configuration.
     @return PXCM_STATUS_NO_ERROR			Successful execution.
 */
 public pxcmStatus SetProfile(ProfileInfo pinfo)
 {
     return PXCMSpeechRecognition_SetProfile(instance, pinfo);
 }
Example #24
0
 private static extern bool LoadUserProfile(IntPtr hToken, ref ProfileInfo lpProfileInfo);
        private void button2_Click(object sender, EventArgs e)
        {
            btnVerify.Enabled = false;

            ProfileInfo = new ProfileInfo
            {
                FullName = "Ahmad Albab",
                IcNo = "1234556",
                Address1 = "Address 1",
                Address2 = "Asress 2",
                Address3 = "Adress 3",
                Citizenship = "MALAYSIA",
                City = "BANGI",
                Postcode = "12345",
                DateOfBirth = DateTime.Now,
                Gender = "M",
                State = "Selangor"
            };
            UpdateUI();

            btnVerify.Enabled = true;
        }
    public ProfileInfoCollection FindProfilesByPropertyValue(SettingsProperty property, SearchOperator searchOperator, object value)
    {
        // instantiate an empty ProfileInfoCollection to use it for return
        ProfileInfoCollection pic = new ProfileInfoCollection();

        // try and open the connection and get the results
        try
        {
            // get the connection we're going to use
            using (SqlConnection conn = new SqlConnection(_connectionStringName))
            {

                // instantiate a SettingsPropertyValue from the property
                // to use it to serialize the value for comparison with the database
                SettingsPropertyValue spv = new SettingsPropertyValue(property);
                spv.PropertyValue = value;

                // set common parameters of the aspnet_Profile_FindProfiles stored procedure
                SqlCommand FindProfilesCommand = new SqlCommand("aspnet_Profile_FindProfiles", conn);
                FindProfilesCommand.CommandType = CommandType.StoredProcedure;
                FindProfilesCommand.CommandTimeout = _commandTimeout;
                FindProfilesCommand.Parameters.Add("@ApplicationName", System.Data.SqlDbType.NVarChar, 256).Value = base.ApplicationName;
                FindProfilesCommand.Parameters.Add("@PropertyName", System.Data.SqlDbType.NVarChar, 256).Value = property.Name;
                FindProfilesCommand.Parameters.Add("@OperatorType", System.Data.SqlDbType.Int).Value = (Int32)searchOperator;

                // if the serialized property value is of type string
                // carry on if the size is within allowed limits
                Boolean bTooBig = false;
                if (spv.SerializedValue is String)
                {
                    // if the serialized value is bigger than the PropertyValueString column's length
                    if (((String)spv.SerializedValue).Length > Int32.MaxValue)
                    {
                        bTooBig = true;
                    }
                    else
                    {
                        if (searchOperator == SearchOperator.Contains || searchOperator == SearchOperator.FreeText)
                        {
                            // if the searchOperator is a freetext operator then pass the value unaltered
                            FindProfilesCommand.Parameters.Add("@PropertyValueString",
                                System.Data.SqlDbType.NVarChar, Int32.MaxValue).Value = spv.PropertyValue;
                            FindProfilesCommand.Parameters.Add("@PropertyValueBinary",
                                System.Data.SqlDbType.VarBinary, Int32.MaxValue).Value = DBNull.Value;
                        }
                        else
                        {
                            // otherwise serialise the value before passing it
                            FindProfilesCommand.Parameters.Add("@PropertyValueString",
                                System.Data.SqlDbType.NVarChar, Int32.MaxValue).Value = spv.SerializedValue;
                            FindProfilesCommand.Parameters.Add("@PropertyValueBinary",
                                System.Data.SqlDbType.VarBinary, Int32.MaxValue).Value = DBNull.Value;
                        }

                        // set the parameter @PropertyType to indicate the property is a string
                        FindProfilesCommand.Parameters.Add("@PropertyType", System.Data.SqlDbType.Bit).Value = 0;
                    }
                }
                else
                {
                    if (((SqlBinary)spv.SerializedValue).Length > Int32.MaxValue)
                    {
                        bTooBig = true;
                    }
                    else
                    {
                        if (searchOperator == SearchOperator.Contains || searchOperator == SearchOperator.FreeText)
                        {
                            // if the searchOperator is a freetext operator then pass the value unaltered to the
                            // @PropertyValueString because we are passing a string anyway not a binary
                            FindProfilesCommand.Parameters.Add("@PropertyValueString",
                                System.Data.SqlDbType.NVarChar, Int32.MaxValue).Value = spv.PropertyValue;
                            FindProfilesCommand.Parameters.Add("@PropertyValueBinary",
                                System.Data.SqlDbType.VarBinary, Int32.MaxValue).Value = DBNull.Value;
                        }
                        else
                        {
                            // otherwise just serialise the value and pass it to the @PropertyBinaryValue
                            FindProfilesCommand.Parameters.Add("@PropertyValueString",
                                System.Data.SqlDbType.NVarChar, Int32.MaxValue).Value = DBNull.Value;
                            FindProfilesCommand.Parameters.Add("@PropertyValueBinary",
                                System.Data.SqlDbType.VarBinary, Int32.MaxValue).Value = spv.SerializedValue;
                        }

                        // set the parameter @PropertyType to indicate the property is a binary
                        FindProfilesCommand.Parameters.Add("@PropertyType", System.Data.SqlDbType.Bit).Value = 1;
                    }
                }

                if (bTooBig)
                {
                    // if the size is out of limits throw an exception
                    throw new ProviderException("Property value length is too big.");
                }

                // Open the database
                conn.Open();

                // Get a DataReader for the results we need
                using (SqlDataReader rdr = FindProfilesCommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while (rdr.Read())
                    {
                        // create a ProfileInfo with the data you got back from the current record of the SqlDataReader
                        ProfileInfo pi = new ProfileInfo(rdr.GetString(rdr.GetOrdinal("UserName")),
                            rdr.GetBoolean(rdr.GetOrdinal("IsAnonymous")),
                            DateTime.SpecifyKind(rdr.GetDateTime(rdr.GetOrdinal("LastActivityDate")), DateTimeKind.Utc),
                            DateTime.SpecifyKind(rdr.GetDateTime(rdr.GetOrdinal("LastUpdatedDate")), DateTimeKind.Utc), 0);

                        // add the ProfileInfo you just created to the ProfileInfoCollection that we will return
                        pic.Add(pi);
                    }
                }
            }
        }
        catch (Exception e)
        {
            // if anything went wrong, throw an exception
            throw new ProviderException("An error occured while finding profiles with your search criteria!", e);
        }

        return pic;
    }
 /**
     @brief The function returns the available algorithm configuration parameters.
     @param[in]	pidx		The zero-based index to retrieve all configuration parameters.
     @param[out] pinfo		The configuration parameters, to be returned.
     @return PXCM_STATUS_NO_ERROR				Successful execution.
     @return PXCM_STATUS_ITEM_UNAVAILABLE		No more configurations.
 */
 public pxcmStatus QueryProfile(Int32 pidx, out ProfileInfo pinfo)
 {
     return QueryProfileINT(instance, pidx, out pinfo);
 }
        private Data.ProfileInfo ReadFromMyKad()
        {
            try
            {
                ProfileInfo = null;
                _photoImage = null;
                List<string> sList = new List<string>();
                byte[] fp1 = null;
                byte[] fp2 = null;
                Image img = null;
                var state = ReadMyKad(out sList, out fp1, out fp2, out img);

                if (state != FpReturn.Success)
                    throw new Exception("Failed to read MyKad");

                ProfileInfo = new ProfileInfo();
                _photoImage = img;
                foreach (string s in sList)
                {
                    if (s.StartsWith("JPN_IDNum"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.IcNo = ids[1];
                    }
                    else if (s.StartsWith("JPN_GMPCName"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.FullName = ids[1];
                    }
                    else if (s.StartsWith("JPN_Citizenship"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.Citizenship = ids[1];
                    }
                    else if (s.StartsWith("JPN_Gender"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.Gender = ids[1];
                    }
                    else if (s.StartsWith("JPN_Address1"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.Address1 = ids[1];
                    }
                    else if (s.StartsWith("JPN_Address2"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.Address2 = ids[1];
                    }
                    else if (s.StartsWith("JPN_Address3"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.Address3 = ids[1];
                    }
                    else if (s.StartsWith("JPN_Postcode"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.Postcode = ids[1];
                    }
                    else if (s.StartsWith("JPN_City"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.City = ids[1];
                    }
                    else if (s.StartsWith("JPN_State"))
                    {
                        string[] ids = s.Split('=');
                        ProfileInfo.State = ids[1];
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //ProfileInfo = new ProfileInfo
            //{
            //    FullName = "Fakhrul Azran Bin Nawi",
            //    IcNo = "99999999-99-9999",
            //    //DateOfBirth = new DateTime(1975, 01, 01),
            //    Gender = "Male"
            //};

            return ProfileInfo;
        }
 /** 
     @brief Set configuration parameters of the SDK TouchlessController application.
     @param[in] pinfo the profile info structure of the configuration parameters.
     @return PXC_STATUS_NO_ERROR if the parameters were set correctly; otherwise, return one of the following errors:
     PXC_STATUS_INIT_FAILED - Module failure during initialization.\n
     PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize.\n                        
 */
 public pxcmStatus SetProfile(ProfileInfo pinfo)
 {
     return PXCMTouchlessController_SetProfile(instance, pinfo);
 }
Example #30
0
        public static void CreateProcessAsUser(string username, string domain, string password, string commandLine)
        {
            IntPtr hToken = IntPtr.Zero;
            IntPtr hDupedToken = IntPtr.Zero;

            PROCESS_INFORMATION pi = new PROCESS_INFORMATION();

            try
            {
                bool result = LogonUser(username, domain, password, (int)LOGON32_LOGON_INTERACTIVE, (int)LOGON32_PROVIDER_DEFAULT, ref hToken);

                if (!result)
                {
                    throw new ApplicationException("LogonUser failed");
                }

                SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
                sa.Length = Marshal.SizeOf(sa);

                result = DuplicateTokenEx(
                      hToken,
                      GENERIC_ALL_ACCESS,
                      ref sa,
                      (int)SECURITY_IMPERSONATION_LEVEL.SecurityIdentification,
                      (int)TOKEN_TYPE.TokenPrimary,
                      ref hDupedToken
                   );

                if (!result)
                {
                    throw new ApplicationException("DuplicateTokenEx failed");
                }

                STARTUPINFO si = new STARTUPINFO();
                si.cb = Marshal.SizeOf(si);
                si.lpDesktop = "winsta0\\default";

                ProfileInfo info = new ProfileInfo();
                info.dwSize = Marshal.SizeOf(info);
                info.lpUserName = username;
                info.dwFlags = 1;

                result = LoadUserProfile(hDupedToken, ref info);

                if (!result)
                {
                    int error = Marshal.GetLastWin32Error();

                    throw new System.ComponentModel.Win32Exception(error);
                }

                IntPtr lpEnvironment;

                result = CreateEnvironmentBlock(out lpEnvironment, hDupedToken, false);

                if (!result)
                {
                    int error = Marshal.GetLastWin32Error();

                    throw new System.ComponentModel.Win32Exception(error);
                }

                result = CreateProcessAsUser(
                                     hDupedToken,
                                     null,
                                     commandLine,
                                     ref sa, ref sa,
                                     false, 0x00000400, lpEnvironment,
                                     null, ref si, ref pi
                               );

                if (!result)
                {
                    int error = Marshal.GetLastWin32Error();

                    throw new System.ComponentModel.Win32Exception(error);
                }
            }
            finally
            {
                if (pi.hProcess != IntPtr.Zero)
                    CloseHandle(pi.hProcess);
                if (pi.hThread != IntPtr.Zero)
                    CloseHandle(pi.hThread);
                if (hDupedToken != IntPtr.Zero)
                    CloseHandle(hDupedToken);
            }
        }