public string Add()
        {
            AddUserApplicationParams actionParam = JavaScriptConvert.DeserializeObject<AddUserApplicationParams>(UnicodeToString(JsonParams));//当传递过来的参数值可能存在unicode编码的字符串时需要使用UnicodeToString方法

            UserApplicationInfo userAppInfo = new UserApplicationInfo();
            userAppInfo.AppId = actionParam.AppId;
            userAppInfo.AppName = actionParam.AppName;
            userAppInfo.Uid = actionParam.Uid;
            userAppInfo.AllowFeed = actionParam.AllowFeed == null || (bool)actionParam.AllowFeed ? 1 : 0;//可不传递型属性处理实例
            userAppInfo.AllowProfileLink = actionParam.AllowProfileLink == null || (bool)actionParam.AllowProfileLink ? 1 : 0;
            userAppInfo.AllowSideNav = actionParam.AllowSideNav == null || (bool)actionParam.AllowSideNav ? 1 : 0;
            userAppInfo.DisplayOrder = actionParam.DisplayOrder == null ? 0 : (int)actionParam.DisplayOrder;
            userAppInfo.Privacy = Utils.GetEnum<PrivacyEnum>(actionParam.Privacy, PrivacyEnum.Public);

            //不确定代码
            userAppInfo.ProfileLink = actionParam.DefaultProfileLink;
            userAppInfo.MYML = actionParam.DefaultMYML;

            //当用户添加应用的时候,会在全局应用表中也增加或者更新原有记录,保证数据同步
            ManyouApplicationInfo appInfo = new ManyouApplicationInfo();
            appInfo.AppId = actionParam.AppId;
            appInfo.AppName = actionParam.AppName;
            appInfo.DisplayMethod = Utils.GetEnum<DisplayMethod>(actionParam.DisplayMethod, DisplayMethod.IFrame);
            appInfo.DisplayOrder = actionParam.DisplayOrder ?? 0;
            appInfo.Version = TypeConverter.StrToInt(actionParam.Version);

            ManyouApplications.UpdateApplicationInfo(appInfo);

            return GetResult(ManyouApplications.AddUserApplication(userAppInfo) > -1);
        }
Exemple #2
0
        public string Update()
        {
            UpdateApplicationParams actionParams = JavaScriptConvert.DeserializeObject<UpdateApplicationParams>(UnicodeToString(JsonParams));
            ManyouApplicationInfo appInfo = new ManyouApplicationInfo();
            appInfo.AppId = actionParams.AppId;
            appInfo.AppName = actionParams.AppName;
            appInfo.DisplayMethod = Utils.GetEnum<DisplayMethod>(actionParams.DisplayMethod, DisplayMethod.IFrame);
            appInfo.DisplayOrder = actionParams.DisplayOrder;
            appInfo.Version = actionParams.Version;

            return GetResult(ManyouApplications.UpdateApplicationInfo(appInfo));
        }
        private static ManyouApplicationInfo LoadManyouApplicationInfo(IDataReader reader)
        {
            ManyouApplicationInfo appInfo = new ManyouApplicationInfo();

            appInfo.AppId = TypeConverter.ObjectToInt(reader["appid"]);
            appInfo.AppName = reader["appname"].ToString();
            appInfo.DisplayMethod = (DisplayMethod)TypeConverter.ObjectToInt(reader["displaymethod"]);
            appInfo.DisplayOrder = TypeConverter.ObjectToInt(reader["displayorder"]);
            appInfo.Flag = (ApplicationFlag)TypeConverter.ObjectToInt(reader["flag"]);
            appInfo.Narrow = TypeConverter.ObjectToInt(reader["narrow"]);
            appInfo.Version = TypeConverter.ObjectToInt(reader["version"]);

            return appInfo;
        }
        public static ManyouApplicationInfo GetApplicationInfo(int appId)
        {
            IDataReader reader = DatabaseProvider.GetInstance().GetApplicationInfo(appId);
            ManyouApplicationInfo appInfo = new ManyouApplicationInfo();

            if (reader.Read())
            {
                appInfo = LoadManyouApplicationInfo(reader);
            }
            reader.Close();
            return appInfo;
        }
 public static int UpdateApplicationInfo(ManyouApplicationInfo appInfo)
 {
     return DatabaseProvider.GetInstance().UpdateApplicationInfo(appInfo);
 }
        /// <summary>
        /// 更新应用配置信息
        /// </summary>
        /// <param name="appInfo"></param>
        /// <returns>返回影响数据行数</returns>
        public static int UpdateApplicationInfo(ManyouApplicationInfo appInfo)
        {
            if (appInfo.AppId <= 0)
                return 0;

            return Data.ManyouApplications.UpdateApplicationInfo(appInfo);
        }