Exemple #1
0
        public FunctionOpenResult <bool> RecordAppService(List <AppService> data, int appInstanceId)
        {
            FunctionOpenResult <bool> r = new FunctionOpenResult <bool>();

            r.Data = Rel_AppInstance_AppServiceDal.UpdateAppInstanceId(new Rel_AppInstance_AppService()
            {
                AppInstanceId = appInstanceId,
                AppService    = JsonHelper.Serlaize <List <AppService> >(data),
                IsCompare     = r.Data
            }) > 0;
            if (!r.Data)
            {
                r.Data = Rel_AppInstance_AppServiceDal.Add(new Rel_AppInstance_AppService()
                {
                    AppInstanceId = appInstanceId,
                    AppService    = JsonHelper.Serlaize <List <AppService> >(data),
                    IsCompare     = r.Data
                }) > 0;
            }
            return(r);
        }
Exemple #2
0
        public FunctionOpenResult <bool> Update(int appInstanceId, int appId)
        {
            Rel_AppInstance_AppService raas = Rel_AppInstance_AppServiceDal.GetByAppInstanceId(appInstanceId);
            List <AppService>          data = (raas != null)?JsonHelper.Deserialize <List <AppService> >(raas.AppService):null;
            var r = new FunctionOpenResult <bool>();

            r.Data = false;
            if (data != null)
            {
                Rel_AppInstance_AppServiceDal.UpdateAppInstanceId(new Rel_AppInstance_AppService()
                {
                    AppInstanceId = appInstanceId,
                    AppService    = JsonHelper.Serlaize <List <AppService> >(data)
                });
                List <AppService> source = GetAppServiceByAppId(appId);
                data.ForEach(ap => {
                    var sap = source.Find(t => t.Name == ap.Name);
                    if (sap != null)
                    {
                        if (ap.AppFunctions != null)
                        {
                            ap.AppFunctions.ForEach(af => {
                                if (!(sap.AppFunctions.RemoveAll(t => t.FunctionName == af.FunctionName) > 0))//将已经保存的数据消除,如果消除数量为0表示此数据需要保存
                                {
                                    AppFunctionDal.Add(af);
                                }
                            });
                            if (sap.AppFunctions.Count > 0)//表示有实例未拥有的数据存在,需要打上无匹配的标识
                            {
                                sap.AppFunctions.ForEach(af => {
                                    AppFunctionDal.SigningNoMatching(af.AppFuntionId);
                                });
                                sap.AppFunctions.Clear();
                            }
                        }
                    }
                    else
                    {//数据中未找到的的AppService进行插入
                        int appServiceId = AppServiceDal.Add(ap);
                        if (appServiceId > 0)
                        {
                            if (ap.AppFunctions != null)
                            {
                                ap.AppFunctions.ForEach(af => {
                                    AppFunctionDal.Add(af);
                                });
                            }
                        }
                    }
                });
                var sapList = source.FindAll(ap => ap.AppFunctions.Count > 0);//找出无匹配的AppService,并且打上无匹配标识
                if (sapList != null)
                {
                    sapList.ForEach(ap => {
                        AppServiceDal.SigningNoMatching(ap.AppServiceId);
                        AppFunctionDal.SigningNoMatchingByAppServiceId(ap.AppServiceId);
                    });
                }
                r.Data = true;
            }
            return(r);
        }