示例#1
0
        }//end static method

        public static Context CreateInstanceFromCache(this Context ctx, string dataCenterId, long userId)
        {
            Context contextByDataCenterId = DataCenterService.GetDataCenterContextFromCache(dataCenterId);

            //处理用户登录名
            {
                FormMetadata metadata     = FormMetaDataCache.GetCachedFormMetaData(contextByDataCenterId, FormIdConst.SEC_User);
                BusinessInfo businessInfo = metadata.BusinessInfo.GetSubBusinessInfo(new List <string> {
                    "FNumber", "FUserAccount", "FName"
                });
                DynamicObject dataObject = BusinessDataServiceHelper.LoadFromCache(contextByDataCenterId, new object[] { userId }, businessInfo.GetDynamicObjectType()).FirstOrDefault();
                contextByDataCenterId.UserId = dataObject.PkId <long>();
                if (businessInfo.GetField("FNumber") != null)
                {
                    contextByDataCenterId.LoginName = dataObject.FieldProperty <string>(businessInfo.GetField("FNumber"));
                }
                if (businessInfo.GetField("FUserAccount") != null)
                {
                    contextByDataCenterId.LoginName = dataObject.FieldProperty <string>(businessInfo.GetField("FUserAccount"));
                }
                contextByDataCenterId.UserName = dataObject.FieldProperty <string>(businessInfo.GetField("FName"));
            }

            return(contextByDataCenterId);
        }//end static method
示例#2
0
        }//end static method

        public static Context CreateAdministratorFromCache(this Context ctx, string dataCenterId)
        {
            Context contextByDataCenterId = DataCenterService.GetDataCenterContextFromCache(dataCenterId);

            contextByDataCenterId.UserId   = FormConst.AdministratorID;
            contextByDataCenterId.UserName = "******";
            return(contextByDataCenterId);
        }//end static method