Example #1
0
        ClientData SwitchDo(GSSModel.Request.ClientData clientData)
        {//在创建工单的同时将逻辑数据提交到服务端处理
            TaskContainerLogicData tl = clientData.Data as TaskContainerLogicData;
            Tasks task = tl.WorkOrder;
            int   id   = dbhandle.AddTask(task);

            clientData.TaskID = id;
            string.Format("Sync create task and run :{0}", clientData.Data.GetType().Name);
            if (tl.LogicData.GetType().Name != typeof(RunTask).Name)
            {
                Unlock un   = tl.LogicData as Unlock;//bug 此处不能直接将object转换为json
                string json = un.MapObject <Unlock, UnlockLogic>().ConvertJson();
                // if(clientData.Data.GetType().Name==typeof())
                int code = dbhandle.InsertLogicJsonAfterTask(id, json);

                clientData.Data = null;
                if (code != StatueCode.Ok)
                {//未创建成功
                    clientData.Data    = code;
                    clientData.Message = "Error";
                }
                else
                {
                    string ret = WebServiceLib.URNolock((un.RoleId > 0 ? "2" : "1"), id.ToString());
                    clientData.Success = ret == "true";
                    string.Format("taskId=[{0}]->Unlock result:[{1}]", id, ret).Logger();
                    clientData.Message = ret;
                }
                return(clientData);
            }
            msgCommand cmd;
            RunTask    rt = tl.LogicData as RunTask;

            clientData.Data = null;
            string.Format("create work order and run-> {0}", rt.Command).Logger();
            string msg = string.Empty;

            cmd = (msgCommand)Enum.Parse(typeof(msgCommand), rt.Command);
            switch (cmd)
            {
            case msgCommand.GameNoticeStart:    //运行公告
                msg = WebServiceLib.GameNoticeStart(id.ToString());
                break;

            default:
                break;
            }
            clientData.Message = msg;
            if (!string.IsNullOrEmpty(msg))
            {
                clientData.Success = true;
            }
            return(clientData);
        }