Exemplo n.º 1
0
        private OperationReturn RemoveResourceObjectData(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //ListParam
                //0     资源总数
                //1...     资源编码
                if (listParams == null || listParams.Count < 1)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string strCount = listParams[0];
                int    intCount;
                if (!int.TryParse(strCount, out intCount))
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Resource id count param invalid");
                    return(optReturn);
                }
                if (listParams.Count < intCount + 1)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Resource id count invalid");
                    return(optReturn);
                }
                if (intCount > 0)
                {
                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = session;
                    webRequest.Code    = (int)RequestCode.WSInsertTempData;
                    webRequest.ListData.Add(string.Empty);
                    webRequest.ListData.Add(intCount.ToString());
                    for (int i = 0; i < intCount; i++)
                    {
                        webRequest.ListData.Add(listParams[i + 1]);
                    }
                    Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(session),
                                                                       WebHelper.CreateEndpointAddress(session.AppServerInfo, "Service11012"));
                    WebReturn webReturn = client.DoOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = webReturn.Code;
                        optReturn.Message = webReturn.Message;
                        return(optReturn);
                    }
                    string strID     = webReturn.Data;
                    string rentToken = session.RentInfo.Token;
                    string strSql;
                    switch (session.DBType)
                    {
                    case 2:
                        strSql =
                            string.Format(
                                "DELETE FROM T_11_101_{0} WHERE C001 IN (SELECT C011 FROM T_00_901 WHERE C001 = {1})",
                                rentToken,
                                strID);
                        optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        break;

                    case 3:
                        strSql =
                            string.Format(
                                "DELETE FROM T_11_101_{0} WHERE C001 IN (SELECT C011 FROM T_00_901 WHERE C001 = {1})",
                                rentToken,
                                strID);
                        optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        break;

                    default:
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                        optReturn.Message = string.Format("Database type not support");
                        return(optReturn);
                    }
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }