コード例 #1
0
ファイル: MESProfileProvider.cs プロジェクト: Eric-Guo/uo-mes
 /// <summary>
 /// Set/store the property values for the user profile.
 /// </summary>
 /// <param name="context">Application context.</param>
 /// <param name="settingsPropertyValues">Profile property value settings.</param>
 public override void SetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyValueCollection settingsPropertyValues)
 {
     if (true == (bool)context["IsAuthenticated"])
     {
         IObjectScope objScope = ORM.GetNewObjectScope();
         string userName = GetUserName((string)context["UserName"]);
         objScope.Transaction.Begin();
         EmployeeProfile ep = ResolveEmployeeProfileByName(objScope, userName);
         if (null == ep)
         {
             ep = new EmployeeProfile();
             ep.Employee = ResolveEmployeeByName(objScope, userName);
             objScope.Add(ep);
         }
         foreach (SettingsPropertyValue settingsPropertyValue in settingsPropertyValues)
         {
             switch (settingsPropertyValue.Property.Name)
             {
                 case "Language":
                     ep.Language = settingsPropertyValue.PropertyValue as String;
                     ep.LastUpdatedDate = DateTime.Now;
                     break;
                 case "StyleTheme":
                     ep.StyleTheme = settingsPropertyValue.PropertyValue as String;
                     ep.LastUpdatedDate = DateTime.Now;
                     break;
                 case "Factory_Name":
                     ep.Factory_Name = settingsPropertyValue.PropertyValue as String;
                     ep.LastUpdatedDate = DateTime.Now;
                     break;
                 case "Operation_Name":
                     ep.Operation_Name = settingsPropertyValue.PropertyValue as String;
                     ep.LastUpdatedDate = DateTime.Now;
                     break;
                 case "WorkCenter_Name":
                     ep.WorkCenter_Name = settingsPropertyValue.PropertyValue as String;
                     ep.LastUpdatedDate = DateTime.Now;
                     break;
                 default:
                     throw new ProviderException("Unsupported property.");
             }
         }
         objScope.Transaction.Commit();
     }
 }
コード例 #2
0
ファイル: MESProfileProvider.cs プロジェクト: Eric-Guo/uo-mes
 /// <summary>
 /// Get the property values for the user profile.
 /// </summary>
 /// <param name="context">Application context.</param>
 /// <param name="settingsProperties">Profile property settings.</param>
 /// <returns>Property setting values.</returns>
 public override System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection settingsProperties)
 {
     IObjectScope objScope = ORM.GetNewObjectScope();
     SettingsPropertyValueCollection settingsValues = new SettingsPropertyValueCollection();
     string userName = GetUserName((string)context["UserName"]);
     EmployeeProfile ep = ResolveEmployeeProfileByName(objScope, userName);
     if (null == ep) ep = new EmployeeProfile();
     foreach (SettingsProperty property in settingsProperties)
     {
         SettingsPropertyValue settingsPropertyValue = new SettingsPropertyValue(property);
         switch (property.Name)
         {
             case "Language":
                 settingsPropertyValue.PropertyValue = ep.Language;
                 break;
             case "StyleTheme":
                 settingsPropertyValue.PropertyValue = ep.StyleTheme;
                 break;
             case "Factory_Name":
                 settingsPropertyValue.PropertyValue = ep.Factory_Name;
                 break;
             case "Operation_Name":
                 settingsPropertyValue.PropertyValue = ep.Operation_Name;
                 break;
             case "WorkCenter_Name":
                 settingsPropertyValue.PropertyValue = ep.WorkCenter_Name;
                 break;
             default:
                 throw new ProviderException("Unsupported property.");
         }
         settingsValues.Add(settingsPropertyValue);
     }
     return settingsValues;
 }