Exemplo n.º 1
0
        public static string AddActiveFallConfig(GSSModel.Request.ActiveFallGoodsData fall)
        {//LKSV_7_gspara_db_0_1
            //首先将数据写入到GSSDB中
            List <string> scenes = new List <string>();

            foreach (int item in fall.SceneIds)
            {
                scenes.Add(item.ToString());
            }

            GSSModel.Request.ActiveFallGoodLogicData goods = fall.MapObject <GSSModel.Request.ActiveFallGoodsData, GSSModel.Request.ActiveFallGoodLogicData>(true);
            string json = goods.ConvertJson();

            GSSModel.SampleWorkOrder sample = new GSSModel.SampleWorkOrder()
            {
                Title       = goods.ActiveName,
                Note        = goods.ActiveName,
                BigZoneName = fall.BigZoneName,
                ZoneName    = fall.ZoneName,
                TypeId      = fall.TaskTypeID,
                AppId       = fall.AppId,
                CreateBy    = fall.CreateBy,
                LogicData   = json
            };
            DBHandle gss    = new DBHandle();
            int      taskId = gss.AddSampleTaskWithLogicData(sample);

            if (!fall.SyncConfig)
            {//是否同时将配置写入到MySQL?
                return(string.Empty);
            }
            string linkName = string.Format("LKSV_GSS_7_gspara_db_{0}_{1}", fall.BigZoneID, fall.ZoneID);
            string conn, error = string.Empty;

            conn = QueryMysqlLinkConnString(linkName, ref error);
            if (!string.IsNullOrEmpty(error))
            {
                return(error);
            }

            //此处需要确认MySQL中新增了列【最低等级,最高等级,掉落类型】
            string cmd = @"insert into hugeaward_cfg(szName,NGSID,tBeginDate,tEndDate,tBeginTime,tEndTime,nDropItemID,nDropMax,nDropProbability,szDropScene,minLevel,maxLevel,fallType,TaskId ) 
            values('{0}',-1,'{1}','{2}','{3}','{4}',{5},{6},{7},'{8}',{9},{10},{11},{12})";

            //nDropProbability 存储的是概率分母
            cmd = string.Format(cmd, fall.ActiveName, fall.StartTime.ToString(AppConfig.DateFormat), fall.EndTime.ToString(AppConfig.DateFormat),
                                fall.StartTime.ToString(AppConfig.TimeFormat), fall.EndTime.ToString(AppConfig.TimeFormat),
                                fall.EquipNo, fall.FallGoodNum, fall.GoodsFallPRDenominator, string.Join(",", scenes.ToArray()), fall.MinRoleLevel, fall.MaxRoleLevel, fall.FallType, taskId);
            string filter = FilterDBConnString(conn);

            //查询目前数据库中最大的ID
            DbHelperMySQL.connectionString = filter;
            try
            {
                int result = DbHelperMySQL.ExecuteSql(cmd);
                if (result > 0)
                {
                    gss.FinshSyncLogicData(taskId);
                }
            }
            catch (Exception ex)
            {
                string msg = ex.ToString();
                msg.Logger();
                return(msg);
            }
            return(string.Empty);
        }