Example #1
0
 public static void SetRemotingInfo(string strDBName, string strDBPath, string strDBUser, int iDBType)
 {
     mstrDBName = strDBName;
     mstrDBPath = strDBPath;
     DBMSSQL.InitSettings(3000, strDBPath, strDBName);
     DBHelper.DBName = strDBName;
     DBHelper.DBUer  = strDBUser;
     DBHelper.DBType = iDBType;
 }
Example #2
0
        public void LogOutSession(long SessionID)
        {
            DBHelper.Provider = new DBMSSQL();
            SqlConnection con       = new SqlConnection(SQLServerDAL.GetConnectionString);
            string        strDBName = con.Database;

            DBMSSQL.InitSettings(5000, con.DataSource, strDBName, true, "", "");
            con.Close();
            SessionTimer.LogOutSession(SessionID);
        }
Example #3
0
        private static void MTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                FactoryArgs args = new FactoryArgs(DBHelper.DBName, "系统", 0, false, null, null);
                DBHelper.Provider = new DBMSSQL();
                SqlConnection con       = new SqlConnection(SQLServerDAL.GetConnectionString);
                string        strDBName = con.Database;
                DBMSSQL.InitSettings(5000, con.DataSource, strDBName, true, "", "");
                con.Close();
                string strSQL = @"
                    delete dbo.SysSession
                    where DATEDIFF(minute,LastCheckTime,getdate())>=10
";
                DBHelper.ExecuteNonQuery(args, CommandType.Text, strSQL, new LBDbParameterCollection(), false);
            }
            catch (Exception ex)
            {
            }
        }
Example #4
0
        public static void SaleCarInBillCancel()
        {
            //查询所有未生成出场记录的单据
            string strSQL = @"
                    declare @SysSaleReceiveOverdue int
                    declare @SysSaleReceiveOverdueStr varchar(100)
                    select @SysSaleReceiveOverdueStr = case when isnull(v.SysConfigValue,'')='' then f.SysConfigDefaultValue else isnull(v.SysConfigValue,'') end
                    from dbo.DbSysConfigField f     
                        left outer join dbo.DbSysConfigValue v on
                            f.SysConfigFieldName = v.SysConfigFieldName
                    where f.SysConfigFieldName = 'SysSaleReceiveOverdue'

                    if isnumeric(@SysSaleReceiveOverdueStr)=1
                    begin
                        set @SysSaleReceiveOverdue = cast(@SysSaleReceiveOverdueStr as int)
                    end

                    update i
                    set IsCancel = 1,
                        CancelBy='系统自动作废',
                        CancelDesc='系统(超时订单系统自动作废)',
                        CancelTime=GETDATE()
                    from dbo.SaleCarInBill i
                    where i.SaleCarInBillID not in (select SaleCarInBillID from dbo.SaleCarOutBill) and
                        isnull(IsCancel,0) = 0 and
                        DATEADD(mi, @SysSaleReceiveOverdue,isnull(CancelByDate,BillDate))<= GETDATE()";

            FactoryArgs args    = new FactoryArgs(DBHelper.DBName, "系统", 0, false, null, null);
            string      strConn = GetConnectionStr();

            DBHelper.Provider = new DBMSSQL();
            SQLServerDAL.GetConnectionString = strConn;
            SqlConnection con       = new SqlConnection(SQLServerDAL.GetConnectionString);
            string        strDBName = con.Database;

            DBMSSQL.InitSettings(5000, con.DataSource, strDBName, true, "", "");

            DBHelper.ExecuteQueryUnCommitted(args, strSQL);
        }
Example #5
0
        public string RunProcedure(int ProcedureType, long SessionID, bool IsNeedSession, string strLoginName, byte[] bSerializeValue, byte[] bSerializeDataType,
                                   out string strOut, out string ErrorMsg, out bool bolIsError)
        {
            strOut = "";
            DataTable dtOut = null;

            bolIsError = false;
            DataSet dsReturn = null;

            ErrorMsg = "";
            try
            {
                string strConn = GetConnectionStr();
                SQLServerDAL.GetConnectionString = strConn;

                DataTable dtParmValue = new DataTable("SPIN");
                List <Dictionary <object, object> > lstDictValue = DeserializeObject(bSerializeValue) as List <Dictionary <object, object> >;
                Dictionary <object, object>         dictDataType = DeserializeObject(bSerializeDataType) as Dictionary <object, object>;

                foreach (KeyValuePair <object, object> keyvalue in dictDataType)
                {
                    dtParmValue.Columns.Add(keyvalue.Key.ToString(), GetType(keyvalue.Value.ToString()));
                }

                foreach (Dictionary <object, object> dictValue in lstDictValue)
                {
                    DataRow drNew = dtParmValue.NewRow();
                    foreach (KeyValuePair <object, object> keyvalue in dictValue)
                    {
                        drNew[keyvalue.Key.ToString()] = keyvalue.Value;
                    }
                    dtParmValue.Rows.Add(drNew);
                }
                dtParmValue.AcceptChanges();

                DBHelper.Provider = new DBMSSQL();
                SqlConnection con       = new SqlConnection(SQLServerDAL.GetConnectionString);
                string        strDBName = con.Database;
                DBMSSQL.InitSettings(5000, con.DataSource, strDBName, true, "", "");
                con.Close();

                //LBFactory factory = new LBFactory();
                //IBLLFunction function = factory.GetAssemblyFunction(ProcedureType);
                IBLLFunction function = DBHelper.GetFunctionMethod(ProcedureType);
                if (function == null)
                {
                    #region -- 调用存储过程 --

                    DataTable dtView = SQLServerDAL.Query("select * from dbo.SysSPType where SysSPType=" + ProcedureType);
                    if (dtView.Rows.Count > 0)
                    {
                        DataRow drView       = dtView.Rows[0];
                        string  strSysSPName = drView["SysSPName"].ToString().TrimEnd();
                        SQLServerDAL.ExecuteProcedure(strSysSPName, dtParmValue, out dtOut, out dsReturn);
                    }
                    else
                    {
                        throw new Exception("存储过程号【" + ProcedureType + "】不存在!");
                    }

                    #endregion
                }
                else
                {
                    #region -- 调用中间层程序方法 --

                    string strMethod = function.GetFunctionName(ProcedureType);
                    string str       = function.ToString();

                    string   strLoad = str.Substring(0, str.IndexOf('.', 8));
                    Assembly s       = Assembly.Load(strLoad);
                    Type     tpe     = s.GetType(str);


                    //调用GetName方法
                    MethodInfo method = tpe.GetMethod(strMethod);

                    Dictionary <string, string> dictParmType   = new Dictionary <string, string>();
                    ParameterInfo[]             parameterInfos = method.GetParameters();
                    foreach (ParameterInfo parmInfo in parameterInfos)
                    {
                        if (parmInfo.ParameterType.Name != "FactoryArgs")
                        {
                            string strParmTypeName = parmInfo.ParameterType.Name.Replace("&", "");
                            if (!dictParmType.ContainsKey(strParmTypeName))
                            {
                                dictParmType.Add(parmInfo.Name, strParmTypeName);
                            }
                        }
                    }

                    int iRowIndex = 0;

                    if (dtParmValue == null || dtParmValue.Rows.Count == 0)
                    {
                        return(null);
                    }

                    FactoryArgs factoryArgs = new FactoryArgs(strDBName, strLoginName, SessionID, IsNeedSession, null, null);

                    #region -- 校验Session --

                    if (factoryArgs.SessionID > 0)
                    {
                        bool bolExistsSession = SessionTimer.VerifySession(factoryArgs);
                        if (IsNeedSession && !bolExistsSession)
                        {
                            bolIsError = true;
                            ErrorMsg   = "长时间未操作或者被其他人逼退,请重新登录!";
                            return("");
                        }
                    }

                    #endregion -- 校验Session --

                    foreach (DataRow drParmValue in dtParmValue.Rows)
                    {
                        //获取需要传入的参数
                        ParameterInfo[] parms = method.GetParameters();

                        Dictionary <int, string> dictOutFieldName = new Dictionary <int, string>();
                        object[] objValue   = new object[parms.Length];
                        int      iParmIndex = 0;
                        foreach (ParameterInfo ss in parms)
                        {
                            string strParmName = ss.Name;
                            if (ss.ParameterType == typeof(FactoryArgs))
                            {
                                objValue[iParmIndex] = factoryArgs;
                            }
                            else if (ss.Attributes != ParameterAttributes.Out)
                            {
                                if (dtParmValue.Columns.Contains(strParmName))
                                {
                                    DataColumn dc    = dtParmValue.Columns[strParmName];
                                    object     value = null;
                                    if (dc.DataType == typeof(long) ||
                                        dc.DataType == typeof(decimal) ||
                                        dc.DataType == typeof(float) ||
                                        dc.DataType == typeof(double) ||
                                        dc.DataType == typeof(int) ||
                                        dc.DataType == typeof(byte) ||
                                        dc.DataType == typeof(bool))
                                    {
                                        if (drParmValue[strParmName] == DBNull.Value)
                                        {
                                            if (dictParmType.ContainsKey(strParmName))
                                            {
                                                ILBDbType lbType = LBDBType.GetILBDbType(dictParmType[strParmName]);
                                                value = lbType;
                                            }
                                            else
                                            {
                                                value = new t_Decimal();
                                            }
                                        }
                                        else
                                        {
                                            if (dictParmType.ContainsKey(strParmName))
                                            {
                                                ILBDbType lbType = LBDBType.GetILBDbType(dictParmType[strParmName]);
                                                lbType.SetValueWithObject(drParmValue[strParmName]);
                                                value = lbType;
                                            }
                                            else
                                            {
                                                value = new t_Decimal(drParmValue[strParmName]);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (dictParmType.ContainsKey(strParmName))
                                        {
                                            ILBDbType lbType = LBDBType.GetILBDbType(dictParmType[strParmName]);
                                            lbType.SetValueWithObject(drParmValue[strParmName]);
                                            value = lbType;
                                        }
                                        else
                                        {
                                            value = new t_String(drParmValue[strParmName]);
                                        }
                                    }
                                    objValue[iParmIndex] = value;
                                }
                            }
                            else
                            {
                                if (dictParmType.ContainsKey(strParmName))
                                {
                                    ILBDbType lbType = LBDBType.GetILBDbType(dictParmType[strParmName]);
                                    lbType.SetValueWithObject(null);
                                    objValue[iParmIndex] = lbType;
                                }

                                if (dtOut == null)
                                {
                                    dtOut = new DataTable("Out");
                                }
                                if (!dtOut.Columns.Contains(strParmName))
                                {
                                    dtOut.Columns.Add(strParmName, typeof(object));
                                }
                                dictOutFieldName.Add(iParmIndex, strParmName);
                            }

                            iParmIndex++;
                        }

                        if (dtOut != null)
                        {
                            dtOut.Rows.Add(dtOut.NewRow());
                        }

                        //获取Car对象
                        object obj = s.CreateInstance(str);

                        //如果有返回值接收下
                        method.Invoke(obj, objValue);
                        int iobjReturnIndex = 0;
                        foreach (object objReturn in objValue)
                        {
                            if (objReturn is FactoryArgs)
                            {
                                FactoryArgs args = (FactoryArgs)objReturn;
                                if (args.SelectResult != null)
                                {
                                    if (dsReturn == null)
                                    {
                                        dsReturn = new DataSet("DSResult");
                                    }
                                    args.SelectResult.TableName = "Return" + iRowIndex.ToString();
                                    dsReturn.Tables.Add(args.SelectResult.Copy());
                                }
                            }
                            if (dictOutFieldName.ContainsKey(iobjReturnIndex))
                            {
                                if (objReturn is ILBDbType)
                                {
                                    ILBDbType lbtype = objReturn as ILBDbType;
                                    if (lbtype.Value != null)
                                    {
                                        dtOut.Rows[0][dictOutFieldName[iobjReturnIndex]] = lbtype.Value;
                                    }
                                }
                            }
                            iobjReturnIndex++;
                        }
                        iRowIndex++;
                    }

                    #endregion -- 调用中间层程序方法 --
                }

                strOut = RarDataTable(dtOut);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    ErrorMsg = ex.InnerException.Message;
                }
                else
                {
                    ErrorMsg = ex.Message;
                }
                bolIsError = true;
                return("");
            }
            return(RarDataSet(dsReturn));
        }