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

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 2)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                string scoreSheetID, strCount;
                int    intCount;
                //0     scoreSheetID
                //1     count
                //...   object check state
                scoreSheetID = listParams[0];
                strCount     = listParams[1];
                if (!int.TryParse(strCount, out intCount))
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("ObjectCount param invalid");
                    return(optReturn);
                }
                if (listParams.Count < 2 + intCount)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Object count invalid");
                    return(optReturn);
                }
                string           rentToken = session.RentInfo.Token;
                string           strSql;
                IDbConnection    objConn;
                IDbDataAdapter   objAdapter;
                DbCommandBuilder objCmdBuilder;
                switch (session.DBType)
                {
                //MSSQL
                case 2:
                    //strSql = string.Format("SELECT * FROM T_11_201_{0} WHERE C004 = {1}  AND C003 LIKE '102%' "
                    //    , rentToken
                    //    , scoreSheetID);
                    strSql = string.Format("SELECT * FROM T_11_201_{0} WHERE C004 = {1}  AND C003 >=1030000000000000000 AND C003<1060000000000000000"
                                           , rentToken
                                           , scoreSheetID);
                    objConn       = MssqlOperation.GetConnection(session.DBConnectionString);
                    objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                    objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                    break;

                //ORCL
                case 3:
                    strSql = string.Format("SELECT * FROM T_11_201_{0} WHERE C004 = {1} AND C003 >=1030000000000000000 AND C003<1060000000000000000"
                                           , rentToken
                                           , scoreSheetID);
                    objConn       = OracleOperation.GetConnection(session.DBConnectionString);
                    objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                    objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not support");
                    return(optReturn);
                }
                if (objConn == null || objAdapter == null || objCmdBuilder == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("Db object is null");
                    return(optReturn);
                }
                objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                objCmdBuilder.SetAllValues   = false;
                try
                {
                    DataSet objDataSet = new DataSet();
                    objAdapter.Fill(objDataSet);
                    List <string> listMsg = new List <string>();
                    for (int i = 2; i < listParams.Count; i++)
                    {
                        string   objectState     = listParams[i];
                        string[] listObjectState = objectState.Split(new[] { ConstValue.SPLITER_CHAR },
                                                                     StringSplitOptions.RemoveEmptyEntries);
                        if (listObjectState.Length < 2)
                        {
                            optReturn.Result  = false;
                            optReturn.Code    = Defines.RET_PARAM_INVALID;
                            optReturn.Message = string.Format("ListObjectState invalid");
                            break;
                        }
                        string    objID     = listObjectState[0];
                        string    isChecked = listObjectState[1];
                        DataRow[] drs       = objDataSet.Tables[0].Select(string.Format("c003 = {0}", objID));
                        if (isChecked == "1")
                        {
                            //不存在,则插入
                            if (drs.Length <= 0)
                            {
                                DataRow newRow = objDataSet.Tables[0].NewRow();
                                newRow["C001"] = 0;
                                newRow["C002"] = 0;
                                newRow["C003"] = Convert.ToInt64(objID);
                                newRow["C004"] = Convert.ToInt64(scoreSheetID);
                                newRow["C005"] = DateTime.Now;
                                newRow["C006"] = DateTime.MaxValue;
                                objDataSet.Tables[0].Rows.Add(newRow.ItemArray);

                                listMsg.Add(string.Format("{0}{1}{2}", "A", ConstValue.SPLITER_CHAR, objID));
                            }
                        }
                        else
                        {
                            //存在,则移除
                            if (drs.Length > 0)
                            {
                                for (int j = drs.Length - 1; j >= 0; j--)
                                {
                                    drs[j].Delete();

                                    listMsg.Add(string.Format("{0}{1}{2}", "D", ConstValue.SPLITER_CHAR, objID));
                                }
                            }
                        }
                    }
                    objAdapter.Update(objDataSet);
                    objDataSet.AcceptChanges();
                    optReturn.Data = listMsg;
                }
                catch (Exception ex)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_DBACCESS_FAIL;
                    optReturn.Message = ex.Message;
                }
                finally
                {
                    if (objConn.State == ConnectionState.Open)
                    {
                        objConn.Close();
                    }
                    objConn.Dispose();
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 2
0
        private OperationReturn GetStatisticalInfoList(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 1)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                //ListParams
                //0        UserID
                string  rentToken = session.RentInfo.Token;
                int     dbType    = session.DBType;
                string  strCon    = session.DBConnectionString;
                string  strSql;
                DataSet objDataSet;
                switch (dbType)
                {
                case 2:
                    strSql    = string.Format("SELECT A.C001 AS AC001,A.C002 AS AC002,A.C003 AS AC003, ");
                    strSql   += string.Format("B.C001 AS BC001,B.C002 AS BC002,B.C003 AS BC003, ");
                    strSql   += string.Format("C.C001 AS CC001,C.C002 AS CC002 ");
                    strSql   += string.Format("FROM T_31_052_00000 A,T_31_050_00000 B,T_11_006_00000 C ");
                    strSql   += string.Format("WHERE A.C002 = B.C001 AND A.C003=C.C001 ");
                    optReturn = MssqlOperation.GetDataSet(strCon, strSql);
                    if (!optReturn.Result)
                    {
                        optReturn.Message += string.Format("\r\n{0}", strSql);
                        return(optReturn);
                    }
                    break;

                case 3:
                    strSql    = string.Format("SELECT A.C001 AS AC001,A.C002 AS AC002,A.C003 AS AC003, ");
                    strSql   += string.Format("B.C001 AS BC001,B.C002 AS BC002,B.C003 AS BC003, ");
                    strSql   += string.Format("C.C001 AS CC001,C.C002 AS CC002 ");
                    strSql   += string.Format("FROM T_31_052_00000 A,T_31_050_00000 B,T_11_006_00000 C ");
                    strSql   += string.Format("WHERE A.C002 = B.C001 AND A.C003=C.C001 ");
                    optReturn = OracleOperation.GetDataSet(strCon, strSql);
                    if (!optReturn.Result)
                    {
                        optReturn.Message += string.Format("\r\n{0}", strSql);
                        return(optReturn);
                    }
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid.\t{0}", dbType);
                    return(optReturn);
                }
                objDataSet = optReturn.Data as DataSet;
                if (objDataSet == null ||
                    objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or table not exist.");
                    return(optReturn);
                }
                List <string> listReturn = new List <string>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = objDataSet.Tables[0].Rows[i];

                    StatisticalInfo item = new StatisticalInfo();
                    item.ID      = Convert.ToInt64(dr["AC001"]);
                    item.ParamID = Convert.ToInt64(dr["AC002"]);
                    item.OwnerID = Convert.ToInt64(dr["AC003"]);

                    string paramName = dr["BC002"].ToString();
                    string orgName   = dr["CC002"].ToString();
                    orgName        = DecryptFromDB(orgName);
                    item.OwnerName = orgName;
                    item.Name      = string.Format("{0}[{1}]", paramName, orgName);

                    optReturn = XMLHelper.SeriallizeObject(item);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    listReturn.Add(optReturn.Data.ToString());
                }
                optReturn.Data = listReturn;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 3
0
        private OperationReturn GetCtrolReExtension(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //ListParam
                //0      用户编号
                //1      所属机构编号
                if (listParams == null || listParams.Count < 2)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string strUserID   = listParams[0];
                string strParentID = listParams[1];
                string path1       = string.Empty;
                string path2       = string.Empty;
                if (listParams[2] == "E")//虚拟分机
                {
                    path1 = string.Format("1040000000000000000");
                    path2 = string.Format("1050000000000000000");
                }
                else if (listParams[2] == "R")//真实分机
                {
                    path1 = string.Format("1050000000000000000");
                    path2 = string.Format("1060000000000000000");
                }
                string  rentToken = session.RentInfo.Token;
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_11_101_{0} WHERE C011 = '{1}' AND C001 IN (SELECT C004 FROM T_11_201_{0} WHERE C003 = {2}) AND C001 >= {3} AND C001 < {4}"
                            , rentToken, strParentID, strUserID, path1, path2);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_11_101_{0} WHERE C011 = '{1}' AND C001 IN (SELECT C004 FROM T_11_201_{0} WHERE C003 = {2}) AND C001 >= {3} AND C001 < {4}"
                            , rentToken, strParentID, strUserID, path1, path2);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not surpport.\t{0}", session.DBType);
                    return(optReturn);
                }
                if (objDataSet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null");
                    return(optReturn);
                }
                List <string> listReturn = new List <string>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow dr          = objDataSet.Tables[0].Rows[i];
                    string  strID       = dr["C001"].ToString();
                    string  strName     = dr["C017"].ToString();
                    string  strFullName = dr["C018"].ToString();
                    strName     = DecryptFromDB(strName);
                    strFullName = DecryptFromDB(strFullName);
                    string strInfo = string.Format("{0}{1}{2}{1}{3}", strID, ConstValue.SPLITER_CHAR, strName, strFullName);
                    listReturn.Add(strInfo);
                }
                optReturn.Data = listReturn;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
                return(optReturn);
            }
            return(optReturn);
        }
Ejemplo n.º 4
0
        private OperationReturn GetScoreSheetUserList(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 1)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                string rentToken = session.RentInfo.Token;
                //ListParam
                //0     scoreSheetID
                string  scoreSheetID = listParams[0];
                string  strSql       = string.Empty;
                DataSet objDataSet   = null;
                switch (session.DBType)
                {
                //MSSQL--("SELECT * FROM T_11_201_{0} WHERE C004 = {1} AND C003 LIKE '103%' ",
                case 2:
                    strSql = string.Format("SELECT * FROM T_11_201_{0} WHERE C004 = {1} AND C003 >=1030000000000000000 AND C003<1060000000000000000",
                                           rentToken,
                                           scoreSheetID);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                //ORCL
                case 3:
                    strSql = string.Format("SELECT * FROM T_11_201_{0} WHERE C004 = {1} AND C003 >=1030000000000000000 AND C003<1060000000000000000",
                                           rentToken,
                                           scoreSheetID);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;
                }
                if (objDataSet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null");
                    return(optReturn);
                }
                List <string> listUsers = new List <string>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = objDataSet.Tables[0].Rows[i];
                    string  strID;
                    strID = dr["C003"].ToString();
                    listUsers.Add(strID);
                }
                optReturn.Data    = listUsers;
                optReturn.Message = strSql;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 5
0
        private OperationReturn LoadCommentItem(SessionInfo session, ItemComment itemComment)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string     rentToken  = session.RentInfo.Token;
                ScoreSheet scoreSheet = itemComment.ScoreSheet;
                if (scoreSheet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("ScoreSheet is null");
                    return(optReturn);
                }
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_005_{0} WHERE C002 = {1}",
                            rentToken,
                            itemComment.ID);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_005_{0} WHERE C002 = {1}",
                            rentToken,
                            itemComment.ID);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (objDataSet == null || objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or DataTables empty");
                    return(optReturn);
                }
                List <CommentItem> listCommentItems = new List <CommentItem>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow     dr          = objDataSet.Tables[0].Rows[i];
                    CommentItem commentItem = new CommentItem();
                    commentItem.Type    = ScoreObjectType.CommentItem;
                    commentItem.ID      = Convert.ToInt64(dr["C001"]);
                    commentItem.Comment = itemComment;
                    commentItem.OrderID = Convert.ToInt32(dr["C003"]);
                    commentItem.Text    = dr["C005"].ToString();

                    listCommentItems.Add(commentItem);
                }
                optReturn.Data = listCommentItems;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 6
0
        private OperationReturn GetScoreSheetList(SessionInfo session, List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 1)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                //ListParams
                //0        UserID
                string  userID    = listParams[0];
                string  rentToken = session.RentInfo.Token;
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    //strSql =
                    //   string.Format(
                    //       "SELECT A.* FROM T_31_001_{0} A, T_11_201_{0} B WHERE A.C001 = B.C004 AND B.C003 = {1}",
                    //       rentToken,userID);
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_001_{0} ORDER BY C001 ",
                            rentToken);

                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_001_{0}  ORDER BY C001  ",
                            rentToken);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (objDataSet == null || objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or DataTables empty");
                    return(optReturn);
                }
                List <string> listReturn = new List <string>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow             dr             = objDataSet.Tables[0].Rows[i];
                    BasicScoreSheetInfo scoreSheetInfo = new BasicScoreSheetInfo();
                    scoreSheetInfo.ID          = Convert.ToInt64(dr["C001"]);
                    scoreSheetInfo.Name        = dr["C002"].ToString();
                    scoreSheetInfo.State       = dr["C018"].ToString() == "Y" ? 0 : 1;
                    scoreSheetInfo.TotalScore  = Convert.ToDouble(dr["C004"]);
                    scoreSheetInfo.ViewClassic = dr["C003"].ToString() == "C" ? 1 : 0;
                    scoreSheetInfo.ScoreType   = dr["C014"].ToString() == "F" ? 2 : dr["C014"].ToString() == "P" ? 1 : 0;
                    scoreSheetInfo.UseFlag     = Convert.ToInt32(dr["C017"]);
                    scoreSheetInfo.ItemCount   = Convert.ToInt32(dr["C012"]);
                    scoreSheetInfo.Description = dr["C019"].ToString();
                    optReturn = XMLHelper.SeriallizeObject(scoreSheetInfo);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    listReturn.Add(optReturn.Data.ToString());
                }
                optReturn.Data    = listReturn;
                optReturn.Message = strSql;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 7
0
        private OperationReturn LoadVisualStyle(SessionInfo session, ScoreObject scoreObject, string type)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string rentToken = session.RentInfo.Token;
                if (scoreObject == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("ScoreObject is null");
                    return(optReturn);
                }
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_012_{0} WHERE C003 = {1} AND C005 = '{2}'",
                            rentToken,
                            scoreObject.ID,
                            type);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_012_{0} WHERE C003 = {1} AND C005 = '{2}'",
                            rentToken,
                            scoreObject.ID,
                            type);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (objDataSet == null || objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or DataTables empty");
                    return(optReturn);
                }
                if (objDataSet.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_NOT_EXIST;
                    optReturn.Message = string.Format("VisualStyle not exist");
                    return(optReturn);
                }
                DataRow     dr    = objDataSet.Tables[0].Rows[0];
                VisualStyle style = new VisualStyle();
                style.ScoreObject   = scoreObject;
                style.Type          = ScoreObjectType.VisualStyle;
                style.ID            = Convert.ToInt64(dr["C001"]);
                style.FontSize      = Convert.ToInt32(dr["C006"]);
                style.StrFontWeight = dr["C007"].ToString();
                style.StrFontFamily = dr["C008"].ToString();
                style.StrForeColor  = dr["C009"].ToString();
                style.StrBackColor  = dr["C010"].ToString();
                style.Width         = Convert.ToInt32(dr["C011"]);
                style.Height        = Convert.ToInt32(dr["C012"]);

                optReturn.Data = style;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 8
0
        private OperationReturn LoadComment(SessionInfo session, ScoreItem scoreItem)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string     rentToken  = session.RentInfo.Token;
                ScoreSheet scoreSheet = scoreItem.ScoreSheet;
                if (scoreSheet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("ScoreSheet is null");
                    return(optReturn);
                }
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_004_{0} WHERE C002 = {1} AND C003 = {2}",
                            rentToken,
                            scoreItem.ID,
                            scoreSheet.ID);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_004_{0} WHERE C002 = {1} AND C003 = {2}",
                            rentToken,
                            scoreItem.ID,
                            scoreSheet.ID);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (objDataSet == null || objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or DataTables empty");
                    return(optReturn);
                }
                List <Comment> listComments = new List <Comment>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = objDataSet.Tables[0].Rows[i];
                    Comment comment;
                    int     intCommentStyle = Convert.ToInt32(dr["C008"]);
                    switch (intCommentStyle)
                    {
                    case (int)CommentStyle.Text:
                        TextComment textComment = new TextComment();
                        textComment.Type        = ScoreObjectType.TextComment;
                        textComment.DefaultText = dr["C005"].ToString();
                        comment = textComment;
                        break;

                    case (int)CommentStyle.Item:
                        ItemComment itemComment = new ItemComment();
                        itemComment.Type = ScoreObjectType.ItemComment;
                        comment          = itemComment;
                        break;

                    default:
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_NOT_EXIST;
                        optReturn.Message = string.Format("CommentStyle not exist");
                        return(optReturn);
                    }
                    comment.Style      = (CommentStyle)intCommentStyle;
                    comment.ID         = Convert.ToInt64(dr["C001"]);
                    comment.ScoreItem  = scoreItem;
                    comment.ScoreSheet = scoreSheet;
                    comment.OrderID    = Convert.ToInt32(dr["C004"]);
                    comment.Title      = dr["C009"].ToString();

                    #region 样式

                    OperationReturn styleReturn;
                    styleReturn = LoadVisualStyle(session, comment, "T");
                    if (!styleReturn.Result)
                    {
                        if (styleReturn.Code != Defines.RET_NOT_EXIST)
                        {
                            return(styleReturn);
                        }
                        comment.TitleStyle = null;
                    }
                    else
                    {
                        VisualStyle style = styleReturn.Data as VisualStyle;
                        if (style != null)
                        {
                            style.ScoreSheet   = scoreSheet;
                            comment.TitleStyle = style;
                        }
                    }

                    styleReturn = LoadVisualStyle(session, comment, "P");
                    if (!styleReturn.Result)
                    {
                        if (styleReturn.Code != Defines.RET_NOT_EXIST)
                        {
                            return(styleReturn);
                        }
                        comment.PanelStyle = null;
                    }
                    else
                    {
                        VisualStyle style = styleReturn.Data as VisualStyle;
                        if (style != null)
                        {
                            style.ScoreSheet   = scoreSheet;
                            comment.PanelStyle = style;
                        }
                    }

                    #endregion


                    #region 子项

                    var temp = comment as ItemComment;
                    if (temp != null)
                    {
                        OperationReturn commentItemReturn;
                        commentItemReturn = LoadCommentItem(session, temp);
                        if (!commentItemReturn.Result)
                        {
                            return(commentItemReturn);
                        }
                        List <CommentItem> listItems = commentItemReturn.Data as List <CommentItem>;
                        if (listItems == null)
                        {
                            commentItemReturn.Result  = false;
                            commentItemReturn.Code    = Defines.RET_OBJECT_NULL;
                            commentItemReturn.Message = string.Format("ListCommentItems is null");
                            return(commentItemReturn);
                        }
                        for (int j = 0; j < listItems.Count; j++)
                        {
                            temp.ValueItems.Add(listItems[j]);
                        }
                        temp.ValueItems = temp.ValueItems.OrderBy(j => j.OrderID).ToList();
                    }


                    #endregion

                    listComments.Add(comment);
                }
                optReturn.Data = listComments;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 9
0
        private OperationReturn LoadScoreItem(SessionInfo session, ScoreItem parent)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string     rentToken  = session.RentInfo.Token;
                ScoreSheet scoreSheet = parent.ScoreSheet;
                if (scoreSheet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("ScoreSheet is null");
                    return(optReturn);
                }
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_002_{0} WHERE C003 = {1} AND C004 = {2}",
                            rentToken,
                            scoreSheet.ID,
                            parent.ID);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_002_{0} WHERE C003 = {1} AND C004 = {2}",
                            rentToken,
                            scoreSheet.ID,
                            parent.ID);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (objDataSet == null || objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or DataTables empty");
                    return(optReturn);
                }
                List <ScoreItem> listItems = new List <ScoreItem>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow   dr = objDataSet.Tables[0].Rows[i];
                    ScoreItem scoreItem;
                    bool      isStandard = dr["C009"].ToString() == "Y";
                    if (isStandard)
                    {
                        Standard     standard     = null;
                        StandardType standardType = (StandardType)Convert.ToInt32(dr["C015"]);
                        switch (standardType)
                        {
                        case StandardType.Numeric:
                            NumericStandard numericStandard = new NumericStandard();
                            numericStandard.Type         = ScoreObjectType.NumericStandard;
                            numericStandard.MaxValue     = Convert.ToDouble(dr["C027"]);
                            numericStandard.MinValue     = Convert.ToDouble(dr["C028"]);
                            numericStandard.DefaultValue = string.IsNullOrWhiteSpace(dr["C029"].ToString()) ? 0 : Convert.ToDouble(dr["C029"]);
                            numericStandard.ScoreClassic = StandardClassic.TextBox;
                            standard = numericStandard;
                            break;

                        case StandardType.YesNo:
                            YesNoStandard yesNoStandard = new YesNoStandard();
                            yesNoStandard.Type = ScoreObjectType.YesNoStandard;
                            if (string.IsNullOrWhiteSpace(dr["C029"].ToString()))
                            {
                                yesNoStandard.DefaultValue = false;
                            }
                            else
                            {
                                if (Convert.ToDouble(dr["C029"]) == 1.0)
                                {
                                    yesNoStandard.DefaultValue = true;
                                }
                                else
                                {
                                    yesNoStandard.DefaultValue = false;
                                }
                            }
                            yesNoStandard.ReverseDisplay = dr["C104"].ToString() == "1";
                            yesNoStandard.ScoreClassic   = StandardClassic.YesNo;
                            standard = yesNoStandard;
                            break;

                        case StandardType.Slider:
                            SliderStandard sliderStandard = new SliderStandard();
                            sliderStandard.Type         = ScoreObjectType.SliderStandard;
                            sliderStandard.MinValue     = Convert.ToDouble(dr["C023"]);
                            sliderStandard.MaxValue     = Convert.ToDouble(dr["C024"]);
                            sliderStandard.Interval     = Convert.ToDouble(dr["C026"]);
                            sliderStandard.DefaultValue = string.IsNullOrWhiteSpace(dr["C029"].ToString()) ? 0 : Convert.ToDouble(dr["C029"]);
                            sliderStandard.ScoreClassic = StandardClassic.Slider;
                            standard = sliderStandard;
                            break;

                        case StandardType.Item:
                            ItemStandard itemStandard = new ItemStandard();
                            itemStandard.Type         = ScoreObjectType.ItemStandard;
                            itemStandard.DefaultIndex = string.IsNullOrWhiteSpace(dr["C029"].ToString())?0: Convert.ToInt32(dr["C029"]);
                            itemStandard.ScoreClassic = StandardClassic.DropDownList;
                            standard = itemStandard;
                            break;
                        }
                        if (standard == null)
                        {
                            optReturn.Result  = false;
                            optReturn.Code    = Defines.RET_OBJECT_NULL;
                            optReturn.Message = string.Format("Standard is null");
                            return(optReturn);
                        }
                        standard.PointSystem    = Convert.ToDouble(dr["C018"]);
                        standard.StandardType   = standardType;
                        standard.IsAutoStandard = dr["C101"].ToString() == "Y";
                        string strStaID = dr["C102"].ToString();
                        long   staID;
                        if (long.TryParse(strStaID, out staID))
                        {
                            standard.StatisticalID = staID;
                        }
                        scoreItem = standard;
                    }
                    else
                    {
                        ScoreGroup scoreGroup = new ScoreGroup();
                        scoreGroup.Type  = ScoreObjectType.ScoreGroup;
                        scoreGroup.IsAvg = dr["C016"].ToString() == "Y";
                        scoreItem        = scoreGroup;
                    }
                    scoreItem.ScoreSheet     = parent.ScoreSheet;
                    scoreItem.Parent         = parent;
                    scoreItem.ItemID         = Convert.ToInt32(dr["C001"]);
                    scoreItem.ID             = Convert.ToInt64(dr["C002"]);
                    scoreItem.OrderID        = Convert.ToInt32(dr["C005"]);
                    scoreItem.Title          = dr["C006"].ToString();
                    scoreItem.Description    = dr["C007"].ToString();
                    scoreItem.TotalScore     = Convert.ToDouble(dr["C008"]);
                    scoreItem.IsAbortScore   = dr["C010"].ToString() == "Y";
                    scoreItem.ControlFlag    = dr["C011"].ToString() == "Y" ? 1 : 0;
                    scoreItem.IsKeyItem      = dr["C012"].ToString() == "Y";
                    scoreItem.IsAllowNA      = dr["C013"].ToString() == "Y";
                    scoreItem.IsJumpItem     = dr["C014"].ToString() == "Y";
                    scoreItem.IsAddtionItem  = dr["C017"].ToString() == "Y";
                    scoreItem.UsePointSystem = dr["C019"].ToString() == "Y";
                    scoreItem.ScoreType      = dr["C020"].ToString() == "F"
                        ? ScoreType.YesNo
                        : dr["C020"].ToString() == "P" ? ScoreType.Pecentage : ScoreType.Numeric;
                    scoreItem.Tip = dr["C022"].ToString();
                    scoreItem.AllowModifyScore = dr["C103"].ToString() == "Y";

                    #region 子项

                    //如果是 ScoreGroup 加载子项
                    if (!isStandard)
                    {
                        ScoreGroup scoreGroup = scoreItem as ScoreGroup;
                        optReturn = LoadScoreItem(session, scoreGroup);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        List <ScoreItem> subItems = optReturn.Data as List <ScoreItem>;
                        if (subItems == null)
                        {
                            optReturn.Result  = false;
                            optReturn.Code    = Defines.RET_OBJECT_NULL;
                            optReturn.Message = string.Format("ListItems is null");
                            return(optReturn);
                        }
                        for (int j = 0; j < subItems.Count; j++)
                        {
                            ScoreItem subItem = subItems[j];
                            scoreGroup.Items.Add(subItem);
                        }
                        scoreGroup.Items = scoreGroup.Items.OrderBy(j => j.OrderID).ToList();
                    }

                    //如果是多值型评分标准,加载评分标准子项
                    ItemStandard temp = scoreItem as ItemStandard;
                    if (temp != null)
                    {
                        optReturn = LoadStandardItem(session, temp);
                        if (!optReturn.Result)
                        {
                            return(optReturn);
                        }
                        List <StandardItem> valueItems = optReturn.Data as List <StandardItem>;
                        if (valueItems == null)
                        {
                            optReturn.Result  = false;
                            optReturn.Code    = Defines.RET_OBJECT_NULL;
                            optReturn.Message = string.Format("ValueItems is null");
                            return(optReturn);
                        }
                        for (int j = 0; j < valueItems.Count; j++)
                        {
                            StandardItem valueItem = valueItems[j];
                            temp.ValueItems.Add(valueItem);
                        }
                        temp.ValueItems = temp.ValueItems.OrderBy(j => j.OrderID).ToList();
                    }

                    #endregion


                    #region 备注

                    OperationReturn commentReturn;
                    commentReturn = LoadComment(session, scoreItem);
                    if (!commentReturn.Result)
                    {
                        return(commentReturn);
                    }
                    List <Comment> listComments = commentReturn.Data as List <Comment>;
                    if (listComments == null)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_OBJECT_NULL;
                        optReturn.Message = string.Format("listComments is null");
                        return(optReturn);
                    }
                    for (int j = 0; j < listComments.Count; j++)
                    {
                        Comment comment = listComments[j];
                        scoreItem.Comments.Add(comment);
                    }
                    scoreItem.Comments = scoreItem.Comments.OrderBy(j => j.OrderID).ToList();

                    #endregion


                    #region 样式

                    OperationReturn styleReturn;
                    styleReturn = LoadVisualStyle(session, scoreItem, "T");
                    if (!styleReturn.Result)
                    {
                        if (styleReturn.Code != Defines.RET_NOT_EXIST)
                        {
                            return(styleReturn);
                        }
                        scoreItem.TitleStyle = null;
                    }
                    else
                    {
                        VisualStyle style = styleReturn.Data as VisualStyle;
                        if (style != null)
                        {
                            style.ScoreSheet     = scoreSheet;
                            scoreItem.TitleStyle = style;
                        }
                    }

                    styleReturn = LoadVisualStyle(session, scoreItem, "P");
                    if (!styleReturn.Result)
                    {
                        if (styleReturn.Code != Defines.RET_NOT_EXIST)
                        {
                            return(styleReturn);
                        }
                        scoreItem.PanelStyle = null;
                    }
                    else
                    {
                        VisualStyle style = styleReturn.Data as VisualStyle;
                        if (style != null)
                        {
                            style.ScoreSheet     = scoreSheet;
                            scoreItem.PanelStyle = style;
                        }
                    }

                    #endregion


                    listItems.Add(scoreItem);
                }
                optReturn.Data = listItems;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 10
0
        private OperationReturn LoadScoreSheet(SessionInfo session, string scoreSheetID)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string  rentToken = session.RentInfo.Token;
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_001_{0} WHERE C001 = {1}",
                            rentToken,
                            scoreSheetID);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_001_{0} WHERE C001 = {1}",
                            rentToken,
                            scoreSheetID);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (objDataSet == null || objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or DataTables empty");
                    return(optReturn);
                }
                if (objDataSet.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_NOT_EXIST;
                    optReturn.Message = string.Format("ScoreSheet not exist");
                    return(optReturn);
                }
                DataRow    dr         = objDataSet.Tables[0].Rows[0];
                ScoreSheet scoreSheet = new ScoreSheet();
                scoreSheet.Type          = ScoreObjectType.ScoreSheet;
                scoreSheet.ScoreSheet    = scoreSheet;
                scoreSheet.ID            = Convert.ToInt64(dr["C001"]);
                scoreSheet.Title         = dr["C002"].ToString();
                scoreSheet.ViewClassic   = dr["C003"].ToString() == "C" ? ScoreItemClassic.Table : ScoreItemClassic.Tree;
                scoreSheet.TotalScore    = Convert.ToDouble(dr["C004"]);
                scoreSheet.Creator       = Convert.ToInt64(dr["C005"]);
                scoreSheet.CreateTime    = Convert.ToDateTime(dr["C006"]);
                scoreSheet.DateFrom      = Convert.ToDateTime(dr["C009"]);
                scoreSheet.DateTo        = Convert.ToDateTime(dr["C010"]);
                scoreSheet.QualifiedLine = Convert.ToDouble(dr["C011"]);
                scoreSheet.ScoreType     = dr["C014"].ToString() == "F"
                    ? ScoreType.YesNo
                    : dr["C014"].ToString() == "P" ? ScoreType.Pecentage : ScoreType.Numeric;
                scoreSheet.UseTag            = Convert.ToInt32(dr["C017"]);
                scoreSheet.Description       = dr["C019"].ToString();
                scoreSheet.CalAdditionalItem = dr["C020"].ToString() != "N";
                scoreSheet.UsePointSystem    = dr["C021"].ToString() != "N";
                string strScoreWidth = dr["C101"].ToString();
                string strTipWidth = dr["C102"].ToString();
                double intScoreWidth, intTipWidth;
                if (double.TryParse(strScoreWidth, out intScoreWidth))
                {
                    scoreSheet.ScoreWidth = intScoreWidth;
                }
                if (double.TryParse(strTipWidth, out intTipWidth))
                {
                    scoreSheet.TipWidth = intTipWidth;
                }
                scoreSheet.HasAutoStandard  = dr["C103"].ToString() != "N";
                scoreSheet.AllowModifyScore = dr["C104"].ToString() != "N";

                #region 子项

                //加载子项
                optReturn = LoadScoreItem(session, scoreSheet);
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                List <ScoreItem> listItems = optReturn.Data as List <ScoreItem>;
                if (listItems == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("ListItems is null");
                    return(optReturn);
                }
                for (int i = 0; i < listItems.Count; i++)
                {
                    ScoreItem scoreItem = listItems[i];
                    scoreSheet.Items.Add(scoreItem);
                }
                scoreSheet.Items = scoreSheet.Items.OrderBy(i => i.OrderID).ToList();

                #endregion


                #region 样式

                OperationReturn styleReturn;
                styleReturn = LoadVisualStyle(session, scoreSheet, "T");
                if (!styleReturn.Result)
                {
                    if (styleReturn.Code != Defines.RET_NOT_EXIST)
                    {
                        return(styleReturn);
                    }
                    scoreSheet.TitleStyle = null;
                }
                else
                {
                    VisualStyle style = styleReturn.Data as VisualStyle;
                    if (style != null)
                    {
                        style.ScoreSheet      = scoreSheet;
                        scoreSheet.TitleStyle = style;
                    }
                }

                styleReturn = LoadVisualStyle(session, scoreSheet, "P");
                if (!styleReturn.Result)
                {
                    if (styleReturn.Code != Defines.RET_NOT_EXIST)
                    {
                        return(styleReturn);
                    }
                    scoreSheet.PanelStyle = null;
                }
                else
                {
                    VisualStyle style = styleReturn.Data as VisualStyle;
                    if (style != null)
                    {
                        style.ScoreSheet      = scoreSheet;
                        scoreSheet.PanelStyle = style;
                    }
                }

                #endregion


                #region 备注

                OperationReturn commentReturn;
                commentReturn = LoadComment(session, scoreSheet);
                if (!commentReturn.Result)
                {
                    return(commentReturn);
                }
                List <Comment> listComments = commentReturn.Data as List <Comment>;
                if (listComments == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("listComments is null");
                    return(optReturn);
                }
                for (int i = 0; i < listComments.Count; i++)
                {
                    Comment comment = listComments[i];
                    scoreSheet.Comments.Add(comment);
                }
                scoreSheet.Comments = scoreSheet.Comments.OrderBy(j => j.OrderID).ToList();

                #endregion


                #region 控制项

                OperationReturn controlReturn;
                controlReturn = LoadControlItem(session, scoreSheet);
                if (!controlReturn.Result)
                {
                    return(controlReturn);
                }
                List <ControlItem> listControlItems = controlReturn.Data as List <ControlItem>;
                if (listControlItems == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("ListCotnrolItems is null");
                    return(optReturn);
                }
                for (int i = 0; i < listControlItems.Count; i++)
                {
                    ControlItem controlItem = listControlItems[i];
                    scoreSheet.ControlItems.Add(controlItem);
                }
                scoreSheet.ControlItems = scoreSheet.ControlItems.OrderBy(j => j.OrderID).ToList();

                #endregion

                optReturn.Data = scoreSheet;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 11
0
        private OperationReturn LoadControlItem(SessionInfo session, ScoreSheet scoreSheet)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string  rentToken = session.RentInfo.Token;
                string  strSql;
                DataSet objDataSet;
                switch (session.DBType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_007_{0} WHERE C002 = {1}",
                            rentToken,
                            scoreSheet.ID);
                    optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_31_007_{0} WHERE C002 = {1}",
                            rentToken,
                            scoreSheet.ID);
                    optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (objDataSet == null || objDataSet.Tables.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null or DataTables empty");
                    return(optReturn);
                }
                List <ControlItem> listControlItems = new List <ControlItem>();
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow     dr          = objDataSet.Tables[0].Rows[i];
                    ControlItem controlItem = new ControlItem();
                    controlItem.Type       = ScoreObjectType.ControlItem;
                    controlItem.ID         = Convert.ToInt64(dr["C001"]);
                    controlItem.ScoreSheet = scoreSheet;
                    controlItem.SourceID   = Convert.ToInt64(dr["C003"]);
                    controlItem.JugeType   = (JugeType)Convert.ToInt32(dr["C004"]);
                    controlItem.JugeValue1 = Convert.ToDouble(dr["C005"]);
                    controlItem.JugeValue2 = string.IsNullOrEmpty(dr["C006"].ToString())
                        ? 0
                        : Convert.ToDouble(dr["C006"]);
                    controlItem.UsePonitSystem = dr["C007"].ToString() == "2";
                    controlItem.TargetID       = Convert.ToInt64(dr["C008"]);
                    controlItem.TargetType     = Convert.ToInt32(dr["C009"]);
                    controlItem.ChangeType     = (ChangeType)Convert.ToInt32(dr["C010"]);
                    controlItem.ChangeValue    = Convert.ToDouble(dr["C011"]);
                    controlItem.OrderID        = Convert.ToInt32(dr["C012"]);
                    controlItem.Title          = dr["C013"].ToString();

                    listControlItems.Add(controlItem);
                }
                optReturn.Data = listControlItems;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }