Beispiel #1
0
        public static ObservableCollection<ProjInfoData> GetProjInfoDatas(string dbName)
        {
            var list = new ObservableCollection<ProjInfoData>();
            if (File.Exists(dbName))
            {
                using (var deLinker = new DbOperator(dbName, DbCategory.Accdb))
                {
                    DataSet ds = deLinker.ExecuteDataSet("select * from ItemToData");
                    if (ds.Tables.Count == 0)
                        return list;

                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        var data = new ProjInfoData
                        {
                            NumIndex = Convert.ToInt32(row["NumIndex"]),
                            ProjInfo = row["ProjInfo"].ToString(),
                            Unit = row["Unit"].ToString(),
                        };
                        list.Add(data);
                    }
                }
            }
            return list;
        }
Beispiel #2
0
        public static ObservableCollection<ItemTreeNode> GetTreeData(string dbName)
        {
            var list = new ObservableCollection<ItemTreeNode>();
            if (File.Exists(dbName))
            {
                using (var deLinker = new DbOperator(dbName, DbCategory.Accdb))
                {
                    DataSet ds = deLinker.ExecuteDataSet("select * from Demo");
                    if (ds.Tables.Count == 0)
                        return list;

                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        var data = new ItemTreeNode
                            {
                                Id = Convert.ToInt32(row["Id"]),
                                Name = row["ItemInfo"].ToString(),
                                Pid = Convert.ToInt32(row["Pid"]),
                                ProjInfoIndexList = ExplainListInfo(row["ProjIndexList"].ToString()),
                            };
                        list.Add(data);
                    }
                }
            }
            return list;
        }
Beispiel #3
0
        public List <WX_OtherConfig> QueryAll(string companyId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from WX_OtherConfig where CompanyID=@CompanyID");
            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("CompanyID", companyId);
                List <WX_OtherConfig> models = new List <WX_OtherConfig>();
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <WX_OtherConfig> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Beispiel #4
0
        public WX_OtherConfig QueryByConfigType(string companyId, ConfigType type)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from WX_OtherConfig where ConfigType=@ConfigType and CompanyID=@CompanyID");
            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("ConfigType", (int)type);
                dbOperator.AddParameter("CompanyID", companyId);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    if (reader.Read())
                    {
                        return(DataReaderToModel <WX_OtherConfig> .ToModel(reader));
                    }
                    return(null);
                }
            }
        }
Beispiel #5
0
        public IEnumerable <KeyValuePair <UpperString, Airline> > Query()
        {
            string sql    = "SELECT [CODE],[NAME],[SHORTNAME],[SETTLECODE],[VALID] FROM [T_Airline] ORDER BY CODE";
            var    result = new List <KeyValuePair <UpperString, Airline> >();

            using (var dbOperator = new DbOperator(Provider, ConnectionString)) {
                using (var reader = dbOperator.ExecuteReader(sql)) {
                    while (reader.Read())
                    {
                        Airline item = new Airline(reader.GetString(0));
                        item.Name       = reader.GetString(1);
                        item.ShortName  = reader.GetString(2);
                        item.SettleCode = reader.GetString(3);
                        item.Valid      = (bool)reader.GetValue(4);
                        result.Add(new KeyValuePair <UpperString, Airline>(item.Code, item));
                    }
                }
            }
            return(result);
        }
Beispiel #6
0
        public BaseParkinfo QueryParkingByParkingNo(string parkingNo)
        {
            BaseParkinfo baseparkinfo = null;
            string       strSql       = "select * from BaseParkinfo where PKNo=@PKNo and  DataStatus!=@DataStatus";

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("PKNo", parkingNo);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql))
                {
                    if (reader.Read())
                    {
                        baseparkinfo = DataReaderToModel <BaseParkinfo> .ToModel(reader);
                    }
                }
            }
            return(baseparkinfo);
        }
Beispiel #7
0
        public List <BaseParkinfo> QueryAllParking()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from BaseParkinfo where DataStatus!=@DataStatus");
            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    List <BaseParkinfo> models = new List <BaseParkinfo>();
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <BaseParkinfo> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Beispiel #8
0
 public bool QueryGrant(string recordId)
 {
     using (DbOperator dbOperator = ConnectionManager.CreateConnection())
     {
         string str = "select * from ParkGrant where CarTypeID=@CarTypeID and DataStatus!=2";
         dbOperator.ClearParameters();
         dbOperator.AddParameter("CarTypeID", recordId);
         using (DbDataReader reader = dbOperator.ExecuteReader(str.ToString()))
         {
             if (reader.Read())
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
 }
Beispiel #9
0
        public ParkDerateConfig QueryByRecordId(string recordId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from ParkDerateConfig where RecordID=@RecordID and DataStatus!=@DataStatus");
            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("RecordID", recordId);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    if (reader.Read())
                    {
                        return(DataReaderToModel <ParkDerateConfig> .ToModel(reader));
                    }
                }
            }
            return(null);
        }
Beispiel #10
0
        public List <BaseVillage> QueryVillageByCompanyIds(List <string> companyIds)
        {
            string sql = string.Format("select ID,VID,VNo,VName,CPID,LinkMan,Mobile,Address,Coordinate,ProxyNo,LastUpdateTime,HaveUpdate,DataStatus,IsOnLine from BaseVillage where CPID in('{0}') and DataStatus!=@DataStatus;", string.Join("','", companyIds));

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);

                List <BaseVillage> models = new List <BaseVillage>();
                using (DbDataReader reader = dbOperator.ExecuteReader(sql.ToString()))
                {
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <BaseVillage> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Beispiel #11
0
        public List <BaseVillage> QueryPage(string companyId, int pageIndex, int pageSize, out int totalRecord)
        {
            string sql = "select ID,VID,VNo,VName,CPID,LinkMan,Mobile,Address,Coordinate,ProxyNo,LastUpdateTime,HaveUpdate,DataStatus,IsOnLine from BaseVillage where CPID=@CPID and DataStatus!=@DataStatus;";

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("CPID", companyId);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                List <BaseVillage> models = new List <BaseVillage>();
                using (DbDataReader reader = dbOperator.Paging(sql, " ID DESC", pageIndex, pageSize, out totalRecord))
                {
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <BaseVillage> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Beispiel #12
0
        public List <BaseCompany> QueryTopCompany()
        {
            List <BaseCompany> company = null;
            string             sql     = string.Format("select ID,CPID,CPName,CityID,Address,LinkMan,Mobile,MasterID,LastUpdateTime,HaveUpdate,DataStatus from BaseCompany where (masterid is null or masterid='' or masterid='0') and DataStatus!=@DataStatus");

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(sql.ToString()))
                {
                    company = new List <BaseCompany>();
                    if (reader.Read())
                    {
                        company.Add(DataReaderToModel <BaseCompany> .ToModel(reader));
                    }
                }
            }
            return(company);
        }
Beispiel #13
0
        public BWYGateMapping QueryByGateID(string gateId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from BWYGateMapping where GateID=@GateID and DataStatus!=@DataStatus");
            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("GateID", gateId);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    if (reader.Read())
                    {
                        return(DataReaderToModel <BWYGateMapping> .ToModel(reader));
                    }
                    return(null);
                }
            }
        }
Beispiel #14
0
        public List <BaseVillage> QueryPage(List <string> villageIds, string companyId, int pageIndex, int pageSize, out int totalRecord)
        {
            string sql = string.Format("select * from BaseVillage where VID in('{0}') and DataStatus!=@DataStatus and  CPID=@CPID;", string.Join("','", villageIds));

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                dbOperator.AddParameter("CPID", companyId);
                List <BaseVillage> models = new List <BaseVillage>();
                using (DbDataReader reader = dbOperator.Paging(sql, " ID DESC", pageIndex, pageSize, out totalRecord))
                {
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <BaseVillage> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Beispiel #15
0
        public WX_Article QueryById(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from WX_Article where ID=@ID and DataStatus!=@DataStatus order by ID desc");
            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("ID", id);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    if (reader.Read())
                    {
                        return(DataReaderToModel <WX_Article> .ToModel(reader));
                    }
                    return(null);
                }
            }
        }
Beispiel #16
0
        public ParkDeviceParam QueryParkDeviceParamByDevID(int DevID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from ParkDeviceParam where DevID=@DevID and DataStatus!=@DataStatus");
            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("DevID", DevID);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                {
                    if (reader.Read())
                    {
                        return(DataReaderToModel <ParkDeviceParam> .ToModel(reader));
                    }
                    return(null);
                }
            }
        }
Beispiel #17
0
        public BaseVillage QueryVillageByVillageNo(string villageNo, string companyId)
        {
            string sql = "select * from BaseVillage where VNo=@VNo and CPID=@CPID and DataStatus!=@DataStatus;";

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("VNo", villageNo);
                dbOperator.AddParameter("CPID", companyId);
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                using (DbDataReader reader = dbOperator.ExecuteReader(sql.ToString()))
                {
                    if (reader.Read())
                    {
                        return(DataReaderToModel <BaseVillage> .ToModel(reader));
                    }
                    return(null);
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// 停车时长统计是否存在
        /// </summary>
        /// <param name="parkingid">车场编号</param>
        /// <param name="gathertime">统计时间</param>
        /// <returns></returns>
        public bool IsExists(string parkingid, DateTime gathertime)
        {
            bool   _isexists = false;
            string strSql    = "select count(0) Count from Statistics_GatherLongTime where parkingid=@parkingid and gathertime=@gathertime";

            using (DbOperator dboperator = ConnectionManager.CreateReadConnection())
            {
                dboperator.ClearParameters();
                dboperator.AddParameter("parkingid", parkingid);
                dboperator.AddParameter("gathertime", gathertime);
                using (DbDataReader dr = dboperator.ExecuteReader(strSql))
                {
                    if (dr.Read())
                    {
                        _isexists = (int.Parse(dr["Count"].ToString()) > 0 ? true : false);
                    }
                }
            }
            return(_isexists);
        }
Beispiel #19
0
        public List <BaseVillage> QueryVillageByEmployeeMobilePhone(string mobilePhone)
        {
            string sql = "select v.* from BaseVillage v left join BaseEmployee e on e.VID=v.VID where e.MobilePhone=@MobilePhone and e.DataStatus!=@DataStatus and v.DataStatus!=@DataStatus;";

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                dbOperator.AddParameter("MobilePhone", mobilePhone);
                List <BaseVillage> models = new List <BaseVillage>();
                using (DbDataReader reader = dbOperator.ExecuteReader(sql.ToString()))
                {
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <BaseVillage> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Beispiel #20
0
        public List <BaseVillage> QueryVillageByCompanyIds(List <string> companyIds)
        {
            string sql = string.Format("select * from BaseVillage where CPID in('{0}') and DataStatus!=@DataStatus;", string.Join("','", companyIds));

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);

                List <BaseVillage> models = new List <BaseVillage>();
                using (DbDataReader reader = dbOperator.ExecuteReader(sql.ToString()))
                {
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <BaseVillage> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Beispiel #21
0
        public bool Create(WX_Article model, DbOperator dbOperator)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into WX_Article(Title,ImagePath,Description,Url,[Text],ArticleType,Sort,GroupID,DataStatus,CreateTime,CompanyID)");
            strSql.Append(" values(@Title,@ImagePath,@Description,@Url,@Text,@ArticleType,@Sort,@GroupID,@DataStatus,@CreateTime,@CompanyID)");
            dbOperator.ClearParameters();
            dbOperator.AddParameter("Title", model.Title);
            dbOperator.AddParameter("ImagePath", model.ImagePath);
            dbOperator.AddParameter("Description", model.Description);
            dbOperator.AddParameter("Url", model.Url);
            dbOperator.AddParameter("Text", model.Text);
            dbOperator.AddParameter("ArticleType", (int)model.ArticleType);
            dbOperator.AddParameter("Sort", model.Sort);
            dbOperator.AddParameter("GroupID", model.GroupID);
            dbOperator.AddParameter("DataStatus", (int)model.DataStatus);
            dbOperator.AddParameter("CreateTime", DateTime.Now);
            dbOperator.AddParameter("CompanyID", model.CompanyID);
            return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
        }
Beispiel #22
0
        public TimeSeg GetTimeSeg(string btime, string etime, string nodeid, string planno)//显示一段时间内某一任务号某一批次数据对应时间段
        {
            TimeSeg seg;

            seg.starttime = btime;
            seg.endtime   = etime;
            seg.nodecode  = nodeid;
            seg.planno    = planno;
            DbOperator opt   = new DbOperator();
            string     query = "select starttime as rstime, 'b' as tag,PLANNO from ht_prod_report t where t.section_code = '" + nodeid.Substring(0, 5) + "' and planno = '" + planno + "' and STARTTIME between '" + btime + "' and '" + etime + "' union select endtime as rstime,'e' as tag,PLANNO  from ht_prod_report t where t.section_code = '" + nodeid.Substring(0, 5) + "' and planno = '" + planno + "' and  endtime between '" + btime + "' and '" + etime + "' order by rstime";
            DataSet    data  = opt.CreateDataSetOra(query);

            if (data != null && data.Tables[0].Rows.Count > 0)
            {
                if (data.Tables[0].Rows.Count == 1)
                {
                    if (data.Tables[0].Rows[0]["tag"].ToString() == "e")
                    {
                        seg.endtime = data.Tables[0].Rows[0]["rstime"].ToString();
                        seg.type    = TimeSegType.END;
                    }
                    else
                    {
                        seg.starttime = data.Tables[0].Rows[0]["rstime"].ToString();
                        seg.type      = TimeSegType.BEGIN;
                    }
                }
                else
                {
                    seg.starttime = data.Tables[0].Rows[0]["rstime"].ToString();
                    seg.endtime   = data.Tables[0].Rows[1]["rstime"].ToString();
                    seg.type      = TimeSegType.BOTH;
                }
            }
            else
            {
                seg.type = TimeSegType.ALL;
            }

            return(seg);
        }
Beispiel #23
0
        public static bool AddOrUpdateCarBitGroup(ParkCarBitGroup model, out bool isAdd)
        {
            isAdd = false;
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IParkGrant      factory  = ParkGrantFactory.GetFactory();
            ParkCarBitGroup oldGroup = factory.GetParkCarBitGroup(model.PKID, model.CarBitName);

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                if (oldGroup == null)
                {
                    model.RecordID = GuidGenerator.GetGuidString();
                    isAdd          = true;
                    return(factory.AddParkCarBitGroup(model, dbOperator));
                }
                else
                {
                    try
                    {
                        dbOperator.BeginTransaction();
                        //factory.UpdateParkGrantPKLot(model.CarBitName,oldGroup.CarBitName, oldGroup.PKID, dbOperator);
                        model.RecordID = oldGroup.RecordID;
                        bool result = factory.UpdateParkCarBitGroup(oldGroup.RecordID, model.CarBitName, model.CarBitNum, dbOperator);
                        if (!result)
                        {
                            throw new MyException("修改车位组信息失败");
                        }
                        dbOperator.CommitTransaction();
                        return(result);
                    }
                    catch {
                        dbOperator.RollbackTransaction();
                        throw;
                    }
                }
            }
        }
Beispiel #24
0
        public int UpdateCarBit(string PKID)
        {
            try
            {
                using (DbOperator dbOperator = ConnectionManager.CreateConnection())
                {
                    int           CarBit = 0;
                    StringBuilder strSql = new StringBuilder();
                    strSql.Append("select * from ParkArea where PKID=@PKID and DataStatus!=2");
                    dbOperator.ClearParameters();
                    dbOperator.AddParameter("PKID", PKID);
                    using (DbDataReader reader = dbOperator.ExecuteReader(strSql.ToString()))
                    {
                        while (reader.Read())
                        {
                            ParkArea model = DataReaderToModel <ParkArea> .ToModel(reader);

                            CarBit += model.CarbitNum;
                        }
                    }

                    strSql = new StringBuilder();
                    strSql.Append("update BaseParkinfo set CarBitNum=@CarBitNum,LastUpdateTime=getdate(),HaveUpdate=3  where PKID=@PKID");
                    dbOperator.ClearParameters();
                    dbOperator.AddParameter("PKID", PKID);
                    dbOperator.AddParameter("CarBitNum", CarBit);
                    if (dbOperator.ExecuteNonQuery(strSql.ToString()) > 0)
                    {
                        return(CarBit);
                    }
                    else
                    {
                        return(-1);
                    }
                }
            }
            catch
            {
                return(-1);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Persits the updates of a step execution. It must have already been persisted.
        /// </summary>
        /// <param name="stepExecution">a persisted step execution</param>
        public void UpdateStepExecution(StepExecution stepExecution)
        {
            Assert.NotNull(stepExecution, "the step execution must not be null");
            Assert.NotNull(stepExecution.StepName, "the step execution name must not be null");
            Assert.NotNull(stepExecution.Id, "the step execution must have already been saved and have an id");

            using (var scope = new TransactionScope(TransactionScopeOption.Required, TransactionOptions))
            {
                var exitDescription = TruncateExitDescription(stepExecution.ExitStatus.ExitDescription);

                lock (stepExecution)
                {
                    var version    = stepExecution.Version + 1;
                    var parameters = new Dictionary <string, object>
                    {
                        { "startTime", stepExecution.StartTime }, { "endTime", (object)stepExecution.EndTime ?? DBNull.Value },
                        { "status", stepExecution.BatchStatus.ToString() }, { "commitCount", stepExecution.CommitCount },
                        { "readCount", stepExecution.ReadCount }, { "filterCount", stepExecution.FilterCount }, { "writeCount", stepExecution.WriteCount },
                        { "exitCode", stepExecution.ExitStatus.ExitCode }, { "exitMessage", exitDescription }, { "newVersion", version },
                        { "readSkipCount", stepExecution.ReadSkipCount }, { "processSkipCount", stepExecution.ProcessSkipCount },
                        { "writeSkipCount", stepExecution.WriteSkipCount }, { "rollbackCount", stepExecution.RollbackCount },
                        { "lastUpdated", (object)stepExecution.LastUpdated ?? DBNull.Value }, { "id", stepExecution.Id }, { "version", stepExecution.Version }
                    };
                    var count = DbOperator.Update(InsertTablePrefix(UpdateStepExecutionQuery), parameters);

                    if (count == 0)
                    {
                        var currentVersion = DbOperator.Query <int>(InsertTablePrefix(CurrentVersionStepExecutionQuery),
                                                                    new Dictionary <string, object> {
                            { "id", stepExecution.Id }
                        });
                        throw new ArgumentException(string.Format("Attempt to update step id={0} with version {1} but current version is {2}",
                                                                  stepExecution.Id, stepExecution.Version, currentVersion));
                    }

                    stepExecution.IncrementVersion();
                }

                scope.Complete();
            }
        }
        public void TestAddItemCategory_正确添加()
        {
            string id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";

            #region 验证前置条件

            MSSql2005Query query    = new MSSql2005Query();
            string         sqlQuery = query.GenerateSelectViewSql(typeof(ItemCategoryInfo));
            sqlQuery += string.Format("WHERE [Id] = N'{0}'", id);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(0, dt.Rows.Count);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            string             idNew  = facade.AddItemCategory(id, "50011665", "0", "网游装备/游戏币/帐号/代练", false, "normal", 0);

            #region 验证后置条件

            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", idNew, true);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(1, dt.Rows.Count);
                Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", dt.Rows[0]["Id"].ToString(), true);
                Assert.AreEqual("50011665", dt.Rows[0]["CategoryId"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["ParentId"].ToString(), true);
                Assert.AreEqual("网游装备/游戏币/帐号/代练", dt.Rows[0]["Name"].ToString(), true);
                Assert.AreEqual("false", dt.Rows[0]["IsParent"].ToString(), true);
                Assert.AreEqual("normal", dt.Rows[0]["Status"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["SortOrder"].ToString(), true);
            }

            #endregion
        }
Beispiel #27
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            IParkDevice          factory          = ParkDeviceFactory.GetFactory();
            IParkDeviceDetection factoryDetection = ParkDeviceDetectionFactory.GetFactory();
            bool result = false;

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();

                    result = factory.Delete(recordId, dbOperator);
                    if (!result)
                    {
                        throw new MyException("删除设备失败");
                    }

                    factoryDetection.Delete(recordId, dbOperator);

                    factory.DeleParam(recordId, dbOperator);

                    dbOperator.CommitTransaction();
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Beispiel #28
0
        public ParkOrder GetIORecordOrderChareFeeCount(string userID, OrderType orderType, DateTime dt, int releaseType, out string ErrorMessage)
        {
            ErrorMessage = "";
            try
            {
                string tableName = "ParkIORecord";
                string tarID     = "RecordID";
                if (orderType == OrderType.AreaTempCardPayment ||
                    orderType == OrderType.AreaValueCardPayment)
                {
                    tableName = "ParkTimeseries";
                    tarID     = "TimeseriesID";
                }
                string strSql = string.Format(@"SELECT ISNULL(sum(O.Amount),0) as Amount,ISNULL(sum(O.PayAmount),0) as PayAmount,ISNULL(sum(O.DiscountAmount),0) as DiscountAmount  FROM  ParkOrder  O  
                                        left  outer JOIN {0} I on O.TagID=I.{1}
                                        WHERE O.OrderTime>@OrderTime and O.UserID=@UserID and O.OrderType=@OrderType and O.DataStatus!=@DataStatus and I.ReleaseType=@ReleaseType  and Status=1 ", tableName, tarID);


                using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
                {
                    dbOperator.ClearParameters();
                    dbOperator.AddParameter("UserID", userID);
                    dbOperator.AddParameter("OrderType", (int)orderType);
                    dbOperator.AddParameter("DataStatus", (int)DataStatus.Delete);
                    dbOperator.AddParameter("OrderTime", dt);
                    dbOperator.AddParameter("ReleaseType", releaseType);
                    using (DbDataReader reader = dbOperator.ExecuteReader(strSql))
                    {
                        if (reader.Read())
                        {
                            return(DataReaderToModel <ParkOrder> .ToModel(reader));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
            }
            return(null);
        }
Beispiel #29
0
        /// <summary>
        /// 根据条件获取派车信息
        /// </summary>
        /// <param name="paras"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <returns></returns>
        public List <ParkLpPlan> Search_ParkLpPlans(InParams paras, int PageSize, int PageIndex)
        {
            List <ParkLpPlan> iorecordlist = new List <ParkLpPlan>();
            string            strSql       = string.Format(@"SELECT * FROM (SELECT top {0} ROW_NUMBER() OVER ( ORDER BY i.ZB_Time desc ) AS rownum,i.*,u.UserName,                                          
                                          from ParkLpPlan i 
                                          left join SysUser u on u.recordid=i.ZB_User 
                                          where i.DataStatus<2", PageSize * PageIndex);

            if (!string.IsNullOrEmpty(paras.ParkingID))
            {
                strSql += " and i.PKID =@PKID";
            }
            if (!string.IsNullOrEmpty(paras.Owner))
            {
                strSql += " and i.EmpName like @EmpName";
            }
            if (paras.OutOperator != "-1")
            {
                strSql += " and i.ZB_User=@ZB_User";
            }
            strSql += " and ZB_Time>=@StartTime and ZB_Time<=@EndTime";
            strSql += string.Format(" order by i.ZB_Time desc) AS temp WHERE temp.rownum BETWEEN {0} AND {1} order by ZB_Time desc", PageSize * (PageIndex - 1) + 1, PageSize * PageIndex);

            using (DbOperator dboperator = ConnectionManager.CreateReadConnection())
            {
                dboperator.ClearParameters();
                dboperator.AddParameter("PKID", paras.ParkingID);
                dboperator.AddParameter("EmpName", "%" + paras.Owner + "%");
                dboperator.AddParameter("StartTime", paras.StartTime);
                dboperator.AddParameter("EndTime", paras.EndTime);
                dboperator.AddParameter("ZB_User", paras.OutOperator);
                using (DbDataReader dr = dboperator.ExecuteReader(strSql))
                {
                    while (dr.Read())
                    {
                        iorecordlist.Add(DataReaderToModel <ParkLpPlan> .ToModel(dr));
                    }
                }
            }
            return(iorecordlist);
        }
Beispiel #30
0
        public static bool UpdateForDefault(string companyId, int id)
        {
            if (id < 1)
            {
                throw new ArgumentNullException("id");
            }

            IWXKeyword factory = WXKeywordFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    List <WX_Keyword> keywords = factory.QueryByReplyType(companyId, ReplyType.Default).Where(p => p.ID != id).ToList();
                    foreach (var item in keywords)
                    {
                        bool result = factory.UpdateReplyType(item.ID, ReplyType.AutoReplay);
                        if (!result)
                        {
                            throw new MyException("修改原始默认回复失败");
                        }
                    }
                    bool r = factory.UpdateReplyType(id, ReplyType.Default);
                    if (!r)
                    {
                        throw new MyException("修改为默认回复失败");
                    }
                    dbOperator.CommitTransaction();
                    if (r)
                    {
                        OperateLogServices.AddOperateLog(string.Format("编号:{0},修改为:{1}", id, ReplyType.AutoReplay.GetDescription()), OperateType.Update);
                    }
                    return(r);
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
Beispiel #31
0
        public int Update(Resource resource)
        {
            string sql = @"UPDATE Resources set Name=@Name, Password=@Password, OfficeNo=@OfficeNo, CertificationType=@CertificationType, CertificationAddress=@CertificationAddress,   ServerAddress=@ServerAddress, ServerPort=@ServerPort, ServerLoginString=@ServerLoginString, ConfigurationType=@ConfigurationType, Status=@Status,   AgentId=@AgentId  WHERE id=@id";

            using (var dbOperator = new DbOperator(Provider, ConnectionString))
            {
                dbOperator.AddParameter("Name", resource.Name);
                dbOperator.AddParameter("Password", resource.OfficeNo);
                dbOperator.AddParameter("OfficeNo", resource.OfficeNo);
                dbOperator.AddParameter("CertificationType", resource.CertificationType);
                dbOperator.AddParameter("CertificationAddress", resource.CertificationAddress);
                dbOperator.AddParameter("ServerAddress", resource.ServerAddress.Address);
                dbOperator.AddParameter("ServerPort", resource.ServerAddress.Port);
                dbOperator.AddParameter("ServerLoginString", resource.ServerLoginString);
                dbOperator.AddParameter("ConfigurationType", resource.ConfigurationType);
                dbOperator.AddParameter("Status", resource.Status);
                dbOperator.AddParameter("AgentId", resource.AgentId);
                dbOperator.AddParameter("id", resource.Id);
                return(dbOperator.ExecuteNonQuery(sql));
            }
        }
Beispiel #32
0
        public bool Update(PGArea model)
        {
            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                model.Datastatus     = DataStatus.Normal;
                model.LastUpdateTime = DateTime.Now;
                model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;

                StringBuilder strSql = new StringBuilder();
                strSql.Append("update PGArea set AreaName=@AreaName,PKID=@PKID,AreaImgPath=@AreaImgPath,LastUpdateTime=@LastUpdateTime,HaveUpdate=@HaveUpdate");
                strSql.Append("  where AreaID=@AreaID");
                dbOperator.ClearParameters();
                dbOperator.AddParameter("AreaID", model.AreaID);
                dbOperator.AddParameter("AreaName", model.AreaName);
                dbOperator.AddParameter("PKID", model.PKID);
                dbOperator.AddParameter("AreaImgPath", model.AreaImgPath);
                dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime);
                dbOperator.AddParameter("HaveUpdate", model.HaveUpdate);
                return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
            }
        }
 public MainForm()
 {
     dbOperator = new DbOperator();
     InitializeComponent();
 }
        /// <summary>
        /// Post-initialization operation.
        /// </summary>
        public void AfterPropertiesSet()
        {
            Assert.NotNull(ConnectionStringSettings, "Connection String Settings must be supplied");

            if (DbOperator == null)
            {
                DbOperator = new DbOperator
                {
                    ConnectionProvider = new ConnectionProvider { ConnectionStringSettings = ConnectionStringSettings }
                };
            }
        }
 public DebugForm()
 {
     dbOperator = new DbOperator();
     InitializeComponent();
 }