Ejemplo n.º 1
0
 /// <summary>
 /// Metoda přidá novou zakázku.
 /// </summary>
 /// <param name="name">Jméno zakázky</param>
 /// <param name="submitter">Jméno zákazníka</param>
 /// <param name="pieces">Počet kusů</param>
 /// <param name="reward">Odměna za provedenou práci</param>
 /// <param name="material">Typ materiálu</param>
 public void AddContract(string name, string submitter, int pieces, int reward, Contract.KindMaterial material)
 {
     ContractCollection.Add(new Contract(name, submitter, pieces, reward, material));
     // Aktualizace OverviewFactory
     RefreshOverviewFactory();
     Save();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <ContractInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <ContractInfo>);
            }
            else
            {
                List <ContractInfo> list       = new List <ContractInfo>();
                ContractCollection  collection = new  ContractCollection();
                Query qry = new Query(Contract.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (Contract contract in collection)
                {
                    ContractInfo contractInfo = new ContractInfo();
                    LoadFromDAL(contractInfo, contract);
                    list.Add(contractInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <ContractInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <ContractInfo> list = new List <ContractInfo>();

            Query q = Contract.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            ContractCollection collection = new  ContractCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Contract contract  in collection)
            {
                ContractInfo contractInfo = new ContractInfo();
                LoadFromDAL(contractInfo, contract);
                list.Add(contractInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Ejemplo n.º 4
0
        public void ContractCollectionGarbageCollects()
        {
            var contractCollection = new ContractCollection();

            var s1 = (Contract)contractCollection.GetOrAddReadContract(typeof(Person));
            var s2 = (Contract)contractCollection.GetOrAddReadContract(typeof(Wrapper <Person>));

            Assert.Equal(4, contractCollection.Contracts.Count);
            Assert.True(contractCollection.Contracts.Contains(s1));
            Assert.True(contractCollection.Contracts.Contains(s2));

            contractCollection.GarbageCollect(new[] { s2 });

            Assert.Equal(4, contractCollection.Contracts.Count);
            Assert.True(contractCollection.Contracts.Contains(s1));
            Assert.True(contractCollection.Contracts.Contains(s2));

            contractCollection.GarbageCollect(new[] { s1 });

            Assert.Equal(3, contractCollection.Contracts.Count);
            Assert.True(contractCollection.Contracts.Contains(s1));
            Assert.False(contractCollection.Contracts.Contains(s2));

            contractCollection.GarbageCollect(new Contract[0]);

            Assert.Equal(0, contractCollection.Contracts.Count);
            Assert.False(contractCollection.Contracts.Contains(s1));
            Assert.False(contractCollection.Contracts.Contains(s2));
        }
Ejemplo n.º 5
0
 public Layout()
 {
     Name        = string.Empty;
     ActionItems = new ActionItemCollection();
     Contracts   = new ContractCollection();
     ViewModels  = new ViewModelCollection();
 }
        public static ContractCollection Search(SearchFilter value)
        {
            ContractCollection items = new ContractCollection();
            string             key   = string.Format(SETTINGS_Search_KEY, value.Keyword, value.Page, value.PageSize, value.OrderBy, value.OrderDirection);

            if (SystemConfig.AllowSearchCache)
            {
                object obj2 = HttpCache.Get(key);

                if ((obj2 != null))
                {
                    return((ContractCollection)obj2);
                }
            }

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PostAsJsonAsync(Resource + "?method=search", value).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <ContractCollection>().GetAwaiter().GetResult();
                }
            }

            if (SystemConfig.AllowSearchCache)
            {
                HttpCache.Max(key, items);
            }
            return(items);
        }
Ejemplo n.º 7
0
 internal ListReadContract(Type type, ContractCollection contractCollection)
 {
     if (!CanProcess(type))
     {
         throw new ArgumentException($"Type {type} must be {nameof(IReadOnlyList<int>)}<>.", nameof(type));
     }
     ItemContract = contractCollection.GetOrAddReadContract(type.GetGenericArguments().Single());
 }
Ejemplo n.º 8
0
 internal NullableReadContract(Type type, ContractCollection contractCollection)
 {
     if (!CanProcess(type))
     {
         throw new ArgumentException($"Type {type} must be nullable.", nameof(type));
     }
     Inner = contractCollection.GetOrAddReadContract(Nullable.GetUnderlyingType(type));
 }
Ejemplo n.º 9
0
 internal DictionaryWriteContract(Type type, ContractCollection contractCollection)
 {
     if (!CanProcess(type))
     {
         throw new ArgumentException($"Type {type} must be {nameof(IReadOnlyDictionary<int, int>)}<,>.", nameof(type));
     }
     KeyContract   = contractCollection.GetOrAddWriteContract(type.GetGenericArguments()[0]);
     ValueContract = contractCollection.GetOrAddWriteContract(type.GetGenericArguments()[1]);
 }
Ejemplo n.º 10
0
        internal TupleReadContract(Type type, ContractCollection contractCollection)
        {
            if (!TupleWriteContract.CanProcess(type))
            {
                throw new ArgumentException($"Type {type} is not a supported tuple type.", nameof(type));
            }

            Items = type.GetGenericArguments().Select(contractCollection.GetOrAddReadContract).ToList();
        }
Ejemplo n.º 11
0
    private void FillddlContract()
    {
        ContractCollection contracts = Contract.Utils.GetContractsByCaseID(caseID);

        foreach (var item in contracts)
        {
            ddlActivityContract.Items.Add(new ListItem(item.Title, item.ID.ToString()));
        }
    }
Ejemplo n.º 12
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <ContractInfo> pList, ContractCollection pCollection)
 {
     foreach (Contract contract in pCollection)
     {
         ContractInfo contractInfo = new ContractInfo();
         LoadFromDAL(contractInfo, contract);
         pList.Add(contractInfo);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Metoda uloží kolekce v modelu do XAML souborů (MaterialCollection, EmployeeCollection, ContractCollection, OverviewModel, TransactionCollection, DeletedMaterialCollection, DeletedEmployeeCollection, DeletedContractCollection).
        /// </summary>
        public void Save()
        {
            // K ukládání je využit serializér
            XmlSerializer materialSerializer = new XmlSerializer(MaterialCollection.GetType());

            using (StreamWriter sw = new StreamWriter(materialTrack))
            {
                materialSerializer.Serialize(sw, MaterialCollection);
            }
            XmlSerializer employeeSerializer = new XmlSerializer(EmployeeCollection.GetType());

            using (StreamWriter sw = new StreamWriter(employeeTrack))
            {
                employeeSerializer.Serialize(sw, EmployeeCollection);
            }
            XmlSerializer contractSerializer = new XmlSerializer(ContractCollection.GetType());

            using (StreamWriter sw = new StreamWriter(contractTrack))
            {
                contractSerializer.Serialize(sw, ContractCollection);
            }

            XmlSerializer overviwSerializer = new XmlSerializer(OverviewModel.GetType());

            using (StreamWriter sw = new StreamWriter(overviewTrack))
            {
                overviwSerializer.Serialize(sw, OverviewModel);
            }
            XmlSerializer accountSerializer = new XmlSerializer(TransactionCollection.GetType());

            using (StreamWriter sw = new StreamWriter(transactionTrack))
            {
                accountSerializer.Serialize(sw, TransactionCollection);
            }

            XmlSerializer deletedMaterialSerializer = new XmlSerializer(DeletedMaterialCollection.GetType());

            using (StreamWriter sw = new StreamWriter(deletedMaterialTrack))
            {
                deletedMaterialSerializer.Serialize(sw, DeletedMaterialCollection);
            }
            XmlSerializer deletedEmployeeSerializer = new XmlSerializer(DeletedEmployeeCollection.GetType());

            using (StreamWriter sw = new StreamWriter(deletedEmployeeTrack))
            {
                deletedEmployeeSerializer.Serialize(sw, DeletedEmployeeCollection);
            }
            XmlSerializer deletedContractSerializer = new XmlSerializer(DeletedContractCollection.GetType());

            using (StreamWriter sw = new StreamWriter(deletedContractTrack))
            {
                deletedContractSerializer.Serialize(sw, DeletedContractCollection);
            }
            FillingAllCollections();
        }
Ejemplo n.º 14
0
 internal UnionWriteContract(Type type, ContractCollection contractCollection)
 {
     if (!CanProcess(type))
     {
         throw new ArgumentException($"Type {type} must be a union.", nameof(type));
     }
     Members = Union.GetTypes(type)
               .Select(t => new Member(UnionEncoding.GetTypeName(t), contractCollection.GetOrAddWriteContract(t)))
               .OrderBy(m => m.Id, StringComparer.OrdinalIgnoreCase)
               .ToArray();
 }
Ejemplo n.º 15
0
        public VMcode(CodeWindow parent, ContractCollection collection) : base()
        {
            this.parent   = parent;
            this.selected = collection.Contracts[0].Name;
            this.code     = new Dictionary <string, Dictionary <string, string> >();
            foreach (ContractModel cm in collection.Contracts)
            {
                this.code.Add(cm.Name, cm.Functions.ToDictionary(f => f.Name, f => FunctionConverter.Convert(f)));
            }

            this.CommandSelectionChanged = new DelegateCommand <object>(this.Select);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Metoda odstraní zakázku a pokud byla standartně provedena, vytvoří i novou transakci.
 /// </summary>
 /// <param name="selectedContract">Vybraná zakázka</param>
 /// <param name="workPrice">Cena za provedení zakázky</param>
 /// <param name="changeAccountCollection">Potvrzení, jesti má být vytvořena nová transakce</param>
 public void DeleteContract(Contract selectedContract, double?workPrice, bool changeAccountCollection)
 {
     if (changeAccountCollection)
     {
         TransactionCollection.Add(new Transaction(selectedContract.ContractName.ToString(), Transaction.TransactionType.ContractAdd, (selectedContract.Reward - (double)workPrice)));
     }
     // Smazání zakáky
     ContractCollection.Remove(selectedContract);
     DeletedContractCollection.Add(new Contract(selectedContract.ContractName, selectedContract.SubmitterName, selectedContract.Pieces, selectedContract.Reward, selectedContract.KindMaterials));
     RefreshOverviewFactory();
     Save();
 }
Ejemplo n.º 17
0
        public void ContractCollection_ConsolidatesContracts()
        {
            var contractCollection = new ContractCollection();

            var s1 = contractCollection.GetOrAddReadContract(typeof(Person));
            var s2 = contractCollection.GetOrAddReadContract(typeof(Person));

            Assert.Same(s1, s2);

            var s3 = contractCollection.GetOrAddReadContract(typeof(Wrapper <Person>));

            Assert.Same(s2, ((Contract)s3).Children.Single());
        }
Ejemplo n.º 18
0
        public VMcontractCollection(ContractCollection root, VMmasterModel parent)
        {
            this.root   = root;
            this.parent = parent;
            this.WrapContracts();

            this.CommandDelete           = new DelegateCommand <object>(this.Remove, this.CanRemove);
            this.CommandAddGroup         = new DelegateCommand(this.AddGroup);
            this.CommandAddContract      = new DelegateCommand <object>(this.AddContract, this.CanAddContract);
            this.CommandSelectionChanged = new DelegateCommand <object>(this.SelectionChanged);

            this.Root.Contracts.CollectionChanged += new NotifyCollectionChangedEventHandler(CollectionChanged);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Base constructor.
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="guid"></param>
        private CCPCharacter(CharacterIdentity identity, Guid guid)
            : base(identity, guid)
        {
            QueryMonitors           = new QueryMonitorCollection();
            SkillQueue              = new SkillQueue(this);
            Standings               = new StandingCollection(this);
            Assets                  = new AssetCollection(this);
            WalletJournal           = new WalletJournalCollection(this);
            WalletTransactions      = new WalletTransactionsCollection(this);
            CharacterMarketOrders   = new MarketOrderCollection(this);
            CorporationMarketOrders = new MarketOrderCollection(this);
            CharacterContracts      = new ContractCollection(this);
            CorporationContracts    = new ContractCollection(this);
            CharacterIndustryJobs   = new IndustryJobCollection(this);
            CorporationIndustryJobs = new IndustryJobCollection(this);
            ResearchPoints          = new ResearchPointCollection(this);
            EVEMailMessages         = new EveMailMessageCollection(this);
            EVEMailingLists         = new EveMailingListCollection(this);
            EVENotifications        = new EveNotificationCollection(this);
            Contacts                = new ContactCollection(this);
            CharacterMedals         = new MedalCollection(this);
            CorporationMedals       = new MedalCollection(this);
            UpcomingCalendarEvents  = new UpcomingCalendarEventCollection(this);
            KillLog                 = new KillLogCollection(this);
            PlanetaryColonies       = new PlanetaryColonyCollection(this);
            LoyaltyPoints           = new LoyaltyCollection(this);

            m_endedOrdersForCharacter   = new List <MarketOrder>();
            m_endedOrdersForCorporation = new List <MarketOrder>();

            m_endedContractsForCharacter   = new List <Contract>();
            m_endedContractsForCorporation = new List <Contract>();

            m_jobsCompletedForCharacter = new List <IndustryJob>();
            m_allianceName    = EveIDToName.GetIDToName(AllianceID);
            m_corporationName = EveIDToName.GetIDToName(CorporationID);

            EveMonClient.CharacterAssetsUpdated           += EveMonClient_CharacterAssetsUpdated;
            EveMonClient.CharacterMarketOrdersUpdated     += EveMonClient_CharacterMarketOrdersUpdated;
            EveMonClient.CorporationMarketOrdersUpdated   += EveMonClient_CorporationMarketOrdersUpdated;
            EveMonClient.CharacterContractsUpdated        += EveMonClient_CharacterContractsUpdated;
            EveMonClient.CorporationContractsUpdated      += EveMonClient_CorporationContractsUpdated;
            EveMonClient.CharacterIndustryJobsUpdated     += EveMonClient_CharacterIndustryJobsUpdated;
            EveMonClient.CorporationIndustryJobsUpdated   += EveMonClient_CorporationIndustryJobsUpdated;
            EveMonClient.CharacterIndustryJobsCompleted   += EveMonClient_CharacterIndustryJobsCompleted;
            EveMonClient.CorporationIndustryJobsCompleted += EveMonClient_CorporationIndustryJobsCompleted;
            EveMonClient.CharacterPlaneteryPinsCompleted  += EveMonClient_CharacterPlaneteryPinsCompleted;
            EveMonClient.ESIKeyInfoUpdated  += EveMonClient_ESIKeyInfoUpdated;
            EveMonClient.EveIDToNameUpdated += EveMonClient_EveIDToNameUpdated;
            EveMonClient.TimerTick          += EveMonClient_TimerTick;
        }
Ejemplo n.º 20
0
    private void FillDdlWaiveContracts(long caseID)
    {
        ContractCollection contracts = Contract.Utils.GetContractsByCaseID(caseID);

        long filterContractID = Convert.ToInt64(Request.QueryString[FilterQueries.filterContract]);

        ddlContracts.Items.Add(new ListItem(Resources.Global.FilterAll, "0"));
        foreach (var item in contracts)
        {
            ddlContracts.Items.Add(new ListItem(item.Title, item.ID.ToString()));
        }

        ddlContracts.SelectedValue = filterContractID.ToString();
    }
Ejemplo n.º 21
0
        internal ComplexWriteContract(Type type, ContractCollection contractCollection)
        {
            var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase);

            Fields = properties.Select(p => new Field(p.Name,
                                                      p.PropertyType == type
                    ? this
                    : contractCollection.GetOrAddWriteContract(p.PropertyType))).ToArray();
            if (!Fields.Any())
            {
                throw new ArgumentException($"Type {type} must have at least one public instance property.", nameof(type));
            }
        }
Ejemplo n.º 22
0
            public static ContractCollection GetContractsByCaseID(Int64 CaseID)
            {
                ContractCollection c = new ContractCollection();

                DataTable dt = Execute.FillDataTable(StoredProcedures.GetContractsByCaseID, new System.Data.SqlClient.SqlParameter("CaseID", CaseID));

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        Contract o = new Contract();
                        LoadContractByReader(row, o);
                        c.Add(o);
                    }
                }

                return(c);
            }
Ejemplo n.º 23
0
        private void Export(string FileType, string FileName)
        {
            //设置回应状态
            Response.Charset         = "GB2312";
            Response.ContentEncoding = Encoding.GetEncoding("GB2312");
            Response.AppendHeader("Content-Disposition",
                                  "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8));
            Response.ContentType = FileType;
            EnableViewState      = false;

            List <Contract>    theContractSearch = SearchContract();
            ContractCollection theContracts      = new ContractCollection();

            theContracts.TheContracts = theContractSearch;
            StringWriter theExcel = theContracts.ExportContractSearchToExcel();

            Response.Write(theExcel.ToString());
            Response.End();
            theExcel.Close();
        }
        public static ContractCollection GetAll()
        {
            ContractCollection items = new ContractCollection();
            string             key   = SETTINGS_ALL_KEY;
            object             obj2  = HttpCache.Get(key);

            if ((obj2 != null))
            {
                return((ContractCollection)obj2);
            }
            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.GetAsync(Resource).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <ContractCollection>().GetAwaiter().GetResult();
                }
            }
            HttpCache.Max(key, items);
            return(items);
        }
Ejemplo n.º 25
0
        private static IReadOnlyList <TRead> Test <TWrite, TRead>(TWrite write, TRead read, bool matchIfRelaxed, bool matchIfStrict)
        {
            var contractCollection = new ContractCollection();

            var w = contractCollection.GetOrAddWriteContract(typeof(TWrite));
            var r = contractCollection.GetOrAddReadContract(typeof(TRead));

            var actualMatchIfRelaxed = r.CanReadFrom(w, strict: false);
            var actualMatchIfStrict  = r.CanReadFrom(w, strict: true);

            Assert.Equal(matchIfRelaxed, actualMatchIfRelaxed);
            Assert.Equal(matchIfStrict, actualMatchIfStrict);

            if (!actualMatchIfRelaxed && !actualMatchIfStrict)
            {
                return(new TRead[0]);
            }

            var stream = new MemoryStream();

            new Serialiser <Wrapper <TWrite> >().Serialise(stream, new Wrapper <TWrite>(write));

            var values = new List <TRead>();

            if (actualMatchIfRelaxed)
            {
                stream.Position = 0;
                values.Add(new Deserialiser <Wrapper <TRead> >(UnexpectedFieldBehaviour.Ignore).Deserialise(stream).Value);
            }

            if (actualMatchIfStrict)
            {
                stream.Position = 0;
                values.Add(new Deserialiser <Wrapper <TRead> >(UnexpectedFieldBehaviour.Throw).Deserialise(stream).Value);
            }

            return(values);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Base constructor.
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="guid"></param>
        private CCPCharacter(CharacterIdentity identity, Guid guid)
            : base(identity, guid)
        {
            QueryMonitors = new QueryMonitorCollection();
            SkillQueue = new SkillQueue(this);
            Standings = new StandingCollection(this);
            Assets = new AssetCollection(this);
            WalletJournal = new WalletJournalCollection(this);
            WalletTransactions = new WalletTransactionsCollection(this);
            CharacterMarketOrders = new MarketOrderCollection(this);
            CorporationMarketOrders = new MarketOrderCollection(this);
            CharacterContracts = new ContractCollection(this);
            CorporationContracts = new ContractCollection(this);
            CharacterContractBids = new ContractBidCollection(this);
            CorporationContractBids = new ContractBidCollection(this);
            CharacterIndustryJobs = new IndustryJobCollection(this);
            CorporationIndustryJobs = new IndustryJobCollection(this);
            ResearchPoints = new ResearchPointCollection(this);
            EVEMailMessages = new EveMailMessageCollection(this);
            EVEMailingLists = new EveMailingListCollection(this);
            EVENotifications = new EveNotificationCollection(this);
            Contacts = new ContactCollection(this);
            CharacterMedals = new MedalCollection(this);
            CorporationMedals = new MedalCollection(this);
            UpcomingCalendarEvents = new UpcomingCalendarEventCollection(this);
            KillLog = new KillLogCollection(this);
            PlanetaryColonies = new PlanetaryColonyCollection(this);

            m_endedOrdersForCharacter = new List<MarketOrder>();
            m_endedOrdersForCorporation = new List<MarketOrder>();

            m_endedContractsForCharacter = new List<Contract>();
            m_endedContractsForCorporation = new List<Contract>();

            m_jobsCompletedForCharacter = new List<IndustryJob>();

            EveMonClient.CharacterAssetsUpdated += EveMonClient_CharacterAssetsUpdated;
            EveMonClient.CharacterMarketOrdersUpdated += EveMonClient_CharacterMarketOrdersUpdated;
            EveMonClient.CorporationMarketOrdersUpdated += EveMonClient_CorporationMarketOrdersUpdated;
            EveMonClient.CharacterContractsUpdated += EveMonClient_CharacterContractsUpdated;
            EveMonClient.CorporationContractsUpdated += EveMonClient_CorporationContractsUpdated;
            EveMonClient.CharacterIndustryJobsUpdated += EveMonClient_CharacterIndustryJobsUpdated;
            EveMonClient.CorporationIndustryJobsUpdated += EveMonClient_CorporationIndustryJobsUpdated;
            EveMonClient.CharacterIndustryJobsCompleted += EveMonClient_CharacterIndustryJobsCompleted;
            EveMonClient.CorporationIndustryJobsCompleted += EveMonClient_CorporationIndustryJobsCompleted;
            EveMonClient.CharacterPlaneteryPinsCompleted += EveMonClient_CharacterPlaneteryPinsCompleted;
            EveMonClient.APIKeyInfoUpdated += EveMonClient_APIKeyInfoUpdated;
            EveMonClient.TimerTick += EveMonClient_TimerTick;
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<ContractInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< ContractInfo>;
     }
     else
     {
         List< ContractInfo>  list =new List< ContractInfo>();
         ContractCollection  collection=new  ContractCollection();
         Query qry = new Query(Contract.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Contract contract in collection)
         {
             ContractInfo contractInfo= new ContractInfo();
             LoadFromDAL(contractInfo,contract);
             list.Add(contractInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(ContractInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<ContractInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< ContractInfo> list = new List< ContractInfo>();

            Query q = Contract .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            ContractCollection  collection=new  ContractCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Contract  contract  in collection)
            {
                ContractInfo contractInfo = new ContractInfo();
                LoadFromDAL(contractInfo,   contract);
                list.Add(contractInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Ejemplo n.º 29
0
 public void SetupDemo()
 {
     this.contracts     = ContractCollectionDemo.KoopmanContract();
     this.model         = DataModelDemo.Example3();
     this.authorization = null;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< ContractInfo> pList, ContractCollection pCollection)
 {
     foreach (Contract contract in pCollection)
     {
         ContractInfo contractInfo = new ContractInfo();
         LoadFromDAL(contractInfo, contract );
         pList.Add(contractInfo);
     }
 }
Ejemplo n.º 31
0
 IWriteContract IWriteContract.CopyTo(ContractCollection collection) => collection.Intern(this);
Ejemplo n.º 32
0
 IReadContract IReadContract.CopyTo(ContractCollection collection) => collection.Intern(this);
Ejemplo n.º 33
0
    private void CreateMainMenu()
    {
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter writer = new HtmlTextWriter(sw))
            {
                ContractCollection contracts = Contract.Utils.GetContractsByCaseID(caseID);


                writer.AddAttribute("class", "main-menu");
                writer.RenderBeginTag(HtmlTextWriterTag.Ul);

                if (pageType == "overview")
                {
                    writer.AddAttribute("class", "selected");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.AddAttribute("href", Urls.OverviewUrl + "?caseid=" + caseID + "&pagetype=overview#tabindex-0");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute("class", "fa fa-home");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag(); // I
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(Resources.CaseTexts.Overview);
                writer.RenderEndTag(); // Span
                writer.RenderEndTag(); // A
                writer.RenderEndTag(); // Li


                if (pageType == "material")
                {
                    writer.AddAttribute("class", "selected");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.AddAttribute("href", Urls.MaterialsUrl + "?caseid=" + caseID + "&pagetype=material");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute("class", "fa fa-cubes");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag(); // I
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(Resources.MaterialTexts.Materials);
                writer.RenderEndTag(); // Span
                writer.RenderEndTag(); // A
                writer.RenderEndTag(); // Li


                if (pageType == "part")
                {
                    writer.AddAttribute("class", "selected");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.AddAttribute("href", Urls.PartsUrl + "?caseid=" + caseID + "&pagetype=part");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute("class", "fa fa-puzzle-piece");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag(); // I
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(Resources.PartTexts.Parts);
                writer.RenderEndTag(); // Span
                writer.RenderEndTag(); // A
                writer.RenderEndTag(); // Li


                if (pageType == "package")
                {
                    writer.AddAttribute("class", "selected");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.AddAttribute("href", Urls.PackagesUrl + "?caseid=" + caseID + "&pagetype=package");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute("class", "fa fa-cube");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag(); // I
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(Resources.PackageTexts.Packages);
                writer.RenderEndTag(); // Span
                writer.RenderEndTag(); // A
                writer.RenderEndTag(); // Li


                if (pageType == "waive")
                {
                    writer.AddAttribute("class", "selected");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.AddAttribute("href", Urls.WaivesUrl + "?caseid=" + caseID + "&pagetype=waive#tabindex-0");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute("class", "fa fa-truck");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag(); // I
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(Resources.WaiveTexts.Waives);
                writer.RenderEndTag(); // Span
                writer.RenderEndTag(); // A
                writer.RenderEndTag(); // Li


                if (pageType == "stock")
                {
                    writer.AddAttribute("class", "selected");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.AddAttribute("href", Urls.StockUrl + "?caseid=" + caseID + "&pagetype=stock");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute("class", "fa fa-th");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag(); // I
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(Resources.StockTexts.Stock);
                writer.RenderEndTag(); // Span
                writer.RenderEndTag(); // A
                writer.RenderEndTag(); // Li


                if (pageType == "report")
                {
                    writer.AddAttribute("class", "selected");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.AddAttribute("href", Urls.ReportUrl + "?caseid=" + caseID + "&pagetype=report#tabindex-0");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute("class", "fa fa-bar-chart");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag(); // I
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(Resources.ReportTexts.Report);
                writer.RenderEndTag(); // Span
                writer.RenderEndTag(); // A
                writer.RenderEndTag(); // Li



                writer.RenderEndTag(); // Ul
            }

            litCaseMenu.Text = sw.ToString();
        }
    }
Ejemplo n.º 34
0
 protected PageViewModel()
 {
     Items = new ObservableCollection <ViewModel>();
     Items.CollectionChanged += OnCollectionChanged;
     Contracts = new ContractCollection();
 }