Exemplo n.º 1
0
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public string GetMaxId(Eva.Library.Data.AccessDataTrans.IAccessDataTrans t)
        {
            string sqlString = "update tbl_num set f_tablesys_id = ";

            sqlString += " (select to_number(f_tablesys_id)+1 from tbl_num where f_tablename  = 'tbl_ld_cben')";
            sqlString += " where f_tablename  = 'tbl_ld_cben'";

            if (t == null)
            {
                _iAccessData.ExecuteSql(sqlString);
            }
            else
            {
                t.ExecuteSql(sqlString);
            }

            sqlString = "select f_tablesys_id from tbl_num where f_tablename  = 'tbl_ld_cben'";


            if (t == null)
            {
                return(_iAccessData.GetSingle(sqlString).ToString());
            }
            else
            {
                return(t.GetSingle(sqlString).ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取新的FILEID
        /// </summary>
        /// <returns></returns>
        public static string GetNewFileId(Eva.Library.Data.AccessDataTrans.IAccessDataTrans t)
        {
            string sql = "select max(id) from tbl_file_menu ";
            object o;
            string fileid = "";

            if (t == null)
            {
                fileid = ((o = _iAccessData.GetSingle(sql)) == null ? "0" : o.ToString());
            }
            else
            {
                fileid = ((o = t.GetSingle(sql)) == null ? "0" : o.ToString());
            }
            if (fileid == "")
            {
                fileid = "0";
            }
            fileid = (int.Parse(fileid) + 1).ToString();
            sql    = "insert into tbl_file_menu(id,hascontent) values('" + fileid + "','1')";
            if (t == null)
            {
                _iAccessData.ExecuteSql(sql);
            }
            else
            {
                t.ExecuteSql(sql);
            }

            return(fileid);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public string GetMaxId(Eva.Library.Data.AccessDataTrans.IAccessDataTrans t)
        {
            string sqlString = "select SEQ_TBL_LD_YCBGLZB.Nextval from DUAL";


            if (t == null)
            {
                return(_iAccessData.GetSingle(sqlString).ToString());
            }
            else
            {
                return(t.GetSingle(sqlString).ToString());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 重写获取count
        /// </summary>
        /// <param name="whereString"></param>
        /// <param name="clientInf"></param>
        /// <returns></returns>
        public string GetCount(string whereString, Eva.Library.Data.AccessDataTrans.IAccessDataTrans t)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(*) from tbl_ld_cben");
            if (whereString.Trim() != "")
            {
                strSql.Append(" where " + whereString);
            }
            string count = "0";

            if (t == null)
            {
                count = int.Parse(_iAccessData.GetSingle(strSql.ToString()).ToString()).ToString();
            }
            else
            {
                count = int.Parse(t.GetSingle(strSql.ToString()).ToString()).ToString();
            }
            return(count);
        }
Exemplo n.º 5
0
        /*
         *                   CREATE OR REPLACE FUNCTION f_checktoken(arg_token    in varchar2, --token
         *                              arg_service  in varchar2, --定义参数变量
         *                              arg_function in varchar2)
         * return varchar2 as
         * v_result varchar2(200);
         * v_count  number;
         *
         * BEGIN
         * --定义返回值
         * v_result := 'true';
         * --私有变量
         * v_count := 0;
         * --0、验证有效性
         * select count(*)
         * into v_count
         * from t_token_list t, t_token_function f, t_token_relation r
         * where t.sys_id = r.fk_t_token_list_sys_id
         * and f.sys_id = r.fk_t_token_function_sys_id
         * and t.f_token = arg_token
         * and t.sys_delflag = '0'
         * and t.f_enable = 'true'
         * and sysdate between t.f_startdate and t.f_enddate
         * and f.f_service = arg_service
         * and f.f_function = arg_function
         * and f.sys_delflag = '0';
         *
         * if v_count > 0 then
         * v_result := 'true';
         *
         * else
         * --v_result := 'false';
         * --1、验证token是否存在
         * select count(*)
         * into v_count
         * from t_token_list
         * where f_token = arg_token;
         * if v_count <= 0 then
         * v_result := '传入的token不存在于Token列表中';
         * else
         * --2、验证token是否已停用
         * select count(*)
         * into v_count
         * from t_token_list
         * where f_token = arg_token
         * and sys_delflag = '0';
         * if v_count <= 0 then
         * v_result := '传入的token已经停用';
         * else
         * --3、验证token是否超时
         * select count(*)
         * into v_count
         * from t_token_list
         * where f_token = arg_token
         * and sys_delflag = '0'
         * and sysdate between f_startdate and f_enddate;
         * if v_count <= 0 then
         * v_result := '传入的token已超时';
         * else
         * --4、验证function和service是否存在
         * select count(*)
         *  into v_count
         *  from t_token_function
         * where f_service = arg_service
         *   and f_function = arg_function;
         *
         * if v_count <= 0 then
         *  v_result := 'function或者service不存在于服务列表中';
         * else
         *  --5、验证function和service是否已停用
         *  select count(*)
         *    into v_count
         *    from t_token_function
         *   where f_service = arg_service
         *     and f_function = arg_function
         *     and sys_delflag = '0';
         *
         *  if v_count <= 0 then
         *    v_result := 'function或者service已停用';
         *  else
         *     v_result := '当前token不具备对此服务或方法的操作权限';
         *  end if;
         *
         * end if;
         *
         * end if;
         * end if;
         * end if;
         * end if;
         *
         * RETURN(v_result);
         *
         * END f_checktoken;
         *
         *
         */

        #endregion

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            try
            {
                //请求服务的路径
                string path = this.Request.Path;
                //请求的方法
                string function = this.Request.PathInfo.Replace("/", "");
                //请求的service
                string service = path.Replace(function, "");
                //执行消息
                string message = "";



                //webservice采集器
                if (ConfigWebServiceCollect == "true")
                {
                    #region  输通道加密算法-采集
                    Eva.Library.Data.AccessDataTrans.IAccessDataTrans t = null;
                    try
                    {
                        if (function != "")
                        {
                            if (service != "")
                            {
                                t = commonclass.commonclass.CreateIAccessDataTrans();

                                t.getTrans().begin();

                                string sql = "select count(*) from t_token_function  where f_function = '" + function + "' and f_service = '" + service + "' and  f_appname = '" + ConfigAppName + "'";

                                if (t.GetSingle(sql).ToString() == "0")
                                {
                                    sara.platform.operation.token.model.t_token_function m = new sara.platform.operation.token.model.t_token_function();
                                    m.sys_creatdate    = DateTime.Now;
                                    m.sys_lasteditdate = DateTime.Now;
                                    m.sys_deldate      = DateTime.Parse("1900-01-01");
                                    m.sys_delflag      = "0";
                                    m.f_appcode        = ConfigAppCode;
                                    m.f_appname        = ConfigAppName;
                                    m.f_appnameen      = ConfigAppName;
                                    m.f_function       = function;
                                    m.f_service        = service;
                                    m.f_isencrypt      = "true";
                                    m.f_istoken        = "true";

                                    sara.platform.operation.token.idal.It_token_function d = sara.platform.operation.commonclass.platformdalfactory.Create <sara.platform.operation.token.idal.It_token_function>();
                                    string id = d.Add(m, t);

                                    sara.platform.operation.token.model.t_token_relation rm = new sara.platform.operation.token.model.t_token_relation();
                                    rm.fk_t_token_function_sys_id = id;
                                    rm.fk_t_token_list_sys_id     = ConfigDefaultTokenId;

                                    sara.platform.operation.token.idal.It_token_relation rd = sara.platform.operation.commonclass.platformdalfactory.Create <sara.platform.operation.token.idal.It_token_relation>();
                                    rd.Add(rm, t);
                                }
                                t.getTrans().commit();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (t != null)
                        {
                            t.getTrans().rollback();
                        }
                    }
                    finally
                    {
                    }
                    #endregion
                }

                //是否开启token
                if (ConfigWebServiceToken == "true")
                {
                    #region  输通道令牌管理
                    //是否为webservice调用
                    //if (this.Request.CurrentExecutionFilePathExtension != ".asmx")
                    //{
                    //    return;
                    //}


                    //如果是直接打开webSerivce页面,function参数会为空
                    if (function != "")
                    {
                        //检查是否例外
                        DataRow[] drs = _dt_token_function_istoken.Select(" f_function='" + function + "' and f_service='" + service + "'");
                        if (drs.Length == 0)
                        {
                            //获取token
                            object token = this.Request.QueryString["token"];
                            if (token != null)
                            {
                                object result = _iAccessData.GetSingle("select f_checktoken('" + token + "','" + service + "','" + function + "') from dual");
                                if (result != null)
                                {
                                    if (result.ToString() == "true")
                                    {
                                    }
                                    else
                                    {
                                        message = result.ToString();//token的验证信息
                                    }
                                }
                                else
                                {
                                    message = "其他未知错误";
                                }
                            }
                            else
                            {
                                message += "必须传入token";
                            }
                        }
                    }
                    #endregion
                }

                //如果不满足令牌,则直接退出,不进行后边的验证
                if (message != "")
                {
                    Response.Write(message);
                    Response.End();
                }

                //是否开启悲观锁
                if (ConfigWebServiceLock == "true")
                {
                    #region 防并发悲观锁

                    DataRow[] drs_lock = _dt_token_function_islock.Select(" f_function='" + function + "' and f_service='" + service + "'");
                    if (drs_lock.Length != 0)
                    {
                        string functionName = drs_lock[0]["f_value10"].ToString();
                        string lockResult   = lockFunction(functionName);
                        switch (lockResult)
                        {
                        case "true":

                            break;

                        case "false":
                            message = "访问超时,请稍后再试";
                            break;

                        case "error":
                            message = "访问异常";
                            break;
                        }
                    }


                    #endregion
                }


                //如果不满足令牌,则直接退出,不进行后边的验证
                if (message != "")
                {
                    Response.Write(message);
                    Response.End();
                }
            }
            catch
            {
            }
        }
Exemplo n.º 6
0
        public string UpdateFileData(string fileId, string fileContent, string businessKey, string businessTableName, string clientInf)
        {
            Eva.Library.Data.AccessDataTrans.IAccessDataTrans t = null;
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                IDictionary <String, String> userInfDic = commonclass.commonclass.CheckClientInf(clientInf);
                if (userInfDic == null)
                {
                    resultDic["result"]  = "false";
                    resultDic["message"] = "客户端信息错误";
                }
                else
                {
                    string fileIdKey   = fileId.Split('|')[0];
                    string fileIdValue = fileId.Split('|')[1];

                    string fileContentKey   = fileContent.Split('|')[0];
                    string fileContentValue = fileContent.Split('|')[1];

                    string businessKeyName = businessKey.Split('|')[0];
                    string businessValue   = businessKey.Split('|')[1];

                    string str = "";
                    t = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans();
                    t.getTrans().begin();

                    //验证,如果fileIdValue为空,则自动创建一个fileid的value
                    if (fileIdValue == "")
                    {
                        str = "select tbl_file_menu_sequence.nextval from dual";
                        object o      = t.GetSingle(str);
                        string fileid = (o == null || o.ToString() == "" ? "0" : o.ToString());

                        fileid = (int.Parse(fileid) + 1).ToString();
                        str    = "insert into tbl_file_menu(id,hascontent) values('" + fileid + "','1')";
                        t.ExecuteSql(str);

                        fileIdValue = fileid;
                    }

                    //分析传入数据
                    List <String> fileNameList = new List <string>();
                    List <String> fileSizeList = new List <string>();

                    string[] fileContentArray = fileContentValue.Split(';');
                    for (int i = 0; i < fileContentArray.Length; i++)
                    {
                        string[] a = fileContentArray[i].Split('^');
                        fileNameList.Add(a[0]);
                        fileSizeList.Add(a[1] + "^" + a[2]);
                    }
                    string fileNameString = "," + string.Join(",", fileNameList) + ",";


                    str = "select * from tbl_file_content where menuid = '" + fileIdValue + "'";
                    DataSet       ds = t.Query(str);
                    List <String> oldfileNameList = new List <string>();

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        oldfileNameList.Add(ds.Tables[0].Rows[i]["fileuploadname"].ToString());
                    }
                    string oldFileNameString = "," + string.Join(",", oldfileNameList) + ",";


                    //==================找到需要删除的文件-====================
                    List <String> needDelFileNameList = new List <string>();
                    for (int i = 0; i < oldfileNameList.Count; i++)
                    {
                        if (fileNameString.IndexOf("," + oldfileNameList[i] + ",") > -1)
                        {
                        }
                        else
                        {
                            needDelFileNameList.Add(oldfileNameList[i]);
                        }
                    }

                    for (int i = 0; i < needDelFileNameList.Count; i++)
                    {
                        //删除记录
                        DataRow[] dr_del = ds.Tables[0].Select(" fileuploadname = '" + needDelFileNameList[i] + "'");
                        if (dr_del.Length > 0)
                        {
                            str = "delete from tbl_file_content where id = '" + dr_del[0]["id"].ToString() + "'";
                            t.ExecuteSql(str);
                        }
                    }


                    //==================找到需要新建的文件-====================
                    List <String> needAddFileNameList = new List <string>();
                    for (int i = 0; i < fileNameList.Count; i++)
                    {
                        if (oldFileNameString.IndexOf("," + fileNameList[i] + ",") > -1)
                        {
                        }
                        else
                        {
                            needAddFileNameList.Add(fileNameList[i]);
                        }
                    }
                    for (int i = 0; i < needAddFileNameList.Count; i++)
                    {
                        str  = " insert into tbl_file_content ";
                        str += " (id, menuid, fileuploadname, filerealname, filesize, filetype, creatdate, deldate, delflag) ";
                        str += " values ";
                        str += " (tbl_file_content_sequence.nextval, '" + fileIdValue + "', '" + needAddFileNameList[i] + "', '" + needAddFileNameList[i] + "', '0', '" + needAddFileNameList[i].Substring(needAddFileNameList[i].LastIndexOf('.')) + "', to_date('" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'), to_date('1900-01-01 00:00:00','yyyy-MM-dd hh24:mi:ss'), '0')";

                        t.ExecuteSql(str);
                    }



                    //更新业务数据
                    str  = " update " + businessTableName + " set ";
                    str += fileContentKey + " = '" + fileContentValue + "'";
                    str += "," + fileIdKey + " = '" + fileIdValue + "'";
                    str += " where " + businessKeyName + " = '" + businessValue + "'";
                    t.ExecuteSql(str);

                    t.getTrans().commit();
                    resultDic["result"]  = "true";
                    resultDic["message"] = "";
                }
            }
            catch (Exception ex)
            {
                if (t != null)
                {
                    t.getTrans().rollback();
                }
                resultDic["result"]  = "error";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }