Ejemplo n.º 1
0
		///<summary>Called after file is downloaded.  Throws exceptions.</summary>
	//public static void ImportAdministrativeSex(string tempFileName) ... not necessary.

		///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
		public static void ImportCdcrec(string tempFileName,ProgressArgs progress,ref bool quit) {
			if(tempFileName==null) {
				return;
			}
			HashSet<string> codeHash=new HashSet<string>(Cdcrecs.GetAllCodes());
			string[] lines=File.ReadAllLines(tempFileName);
			string[] arrayCDCREC;
			Cdcrec cdcrec=new Cdcrec();
			for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code
				if(quit) {
					return;
				}
				if(i%100==0) {
					progress(i+1,lines.Length);
				}
				arrayCDCREC=lines[i].Split('\t');
				if(codeHash.Contains(arrayCDCREC[0])) {//code already existed
					continue;
				}
				cdcrec.CdcrecCode				=arrayCDCREC[0];
				cdcrec.HeirarchicalCode	=arrayCDCREC[1];
				cdcrec.Description			=arrayCDCREC[2];
				Cdcrecs.Insert(cdcrec);
			}
		}
Ejemplo n.º 2
0
		///<summary></summary>
		public static void Update(Cdcrec cdcrec){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				Meth.GetVoid(MethodBase.GetCurrentMethod(),cdcrec);
				return;
			}
			Crud.CdcrecCrud.Update(cdcrec);
		}
Ejemplo n.º 3
0
		//If this table type will exist as cached data, uncomment the CachePattern region below.
		/*
		#region CachePattern
		//This region can be eliminated if this is not a table type with cached data.
		//If leaving this region in place, be sure to add RefreshCache and FillCache 
		//to the Cache.cs file with all the other Cache types.

		///<summary>A list of all Cdcrecs.</summary>
		private static List<Cdcrec> listt;

		///<summary>A list of all Cdcrecs.</summary>
		public static List<Cdcrec> Listt{
			get {
				if(listt==null) {
					RefreshCache();
				}
				return listt;
			}
			set {
				listt=value;
			}
		}

		///<summary></summary>
		public static DataTable RefreshCache(){
			//No need to check RemotingRole; Calls GetTableRemotelyIfNeeded().
			string command="SELECT * FROM cdcrec ORDER BY ItemOrder";//stub query probably needs to be changed
			DataTable table=Cache.GetTableRemotelyIfNeeded(MethodBase.GetCurrentMethod(),command);
			table.TableName="Cdcrec";
			FillCache(table);
			return table;
		}

		///<summary></summary>
		public static void FillCache(DataTable table){
			//No need to check RemotingRole; no call to db.
			listt=Crud.CdcrecCrud.TableToList(table);
		}
		#endregion
		*/

		///<summary></summary>
		public static long Insert(Cdcrec cdcrec){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				cdcrec.CdcrecNum=Meth.GetLong(MethodBase.GetCurrentMethod(),cdcrec);
				return cdcrec.CdcrecNum;
			}
			return Crud.CdcrecCrud.Insert(cdcrec);
		}
Ejemplo n.º 4
0
        ///<summary>Called after file is downloaded.  Throws exceptions.</summary>
        //public static void ImportAdministrativeSex(string tempFileName) ... not necessary.

        ///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
        public static void ImportCdcrec(string tempFileName, ProgressArgs progress, ref bool quit)
        {
            if (tempFileName == null)
            {
                return;
            }
            HashSet <string> codeHash = new HashSet <string>(Cdcrecs.GetAllCodes());

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayCDCREC;
            Cdcrec   cdcrec = new Cdcrec();

            for (int i = 0; i < lines.Length; i++)       //each loop should read exactly one line of code. and each line of code should be a unique code
            {
                if (quit)
                {
                    return;
                }
                if (i % 100 == 0)
                {
                    progress(i + 1, lines.Length);
                }
                arrayCDCREC = lines[i].Split('\t');
                if (codeHash.Contains(arrayCDCREC[0]))                 //code already existed
                {
                    continue;
                }
                cdcrec.CdcrecCode       = arrayCDCREC[0];
                cdcrec.HeirarchicalCode = arrayCDCREC[1];
                cdcrec.Description      = arrayCDCREC[2];
                Cdcrecs.Insert(cdcrec);
            }
        }
Ejemplo n.º 5
0
 ///<summary></summary>
 public static void Update(Cdcrec cdcrec)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), cdcrec);
         return;
     }
     Crud.CdcrecCrud.Update(cdcrec);
 }
Ejemplo n.º 6
0
        //If this table type will exist as cached data, uncomment the CachePattern region below.

        /*
         #region CachePattern
         *
         * private class CdcrecCache : CacheListAbs<Cdcrec> {
         *      protected override List<Cdcrec> GetCacheFromDb() {
         *              string command="SELECT * FROM Cdcrec ORDER BY ItemOrder";
         *              return Crud.CdcrecCrud.SelectMany(command);
         *      }
         *      protected override List<Cdcrec> TableToList(DataTable table) {
         *              return Crud.CdcrecCrud.TableToList(table);
         *      }
         *      protected override Cdcrec Copy(Cdcrec Cdcrec) {
         *              return Cdcrec.Clone();
         *      }
         *      protected override DataTable ListToTable(List<Cdcrec> listCdcrecs) {
         *              return Crud.CdcrecCrud.ListToTable(listCdcrecs,"Cdcrec");
         *      }
         *      protected override void FillCacheIfNeeded() {
         *              Cdcrecs.GetTableFromCache(false);
         *      }
         *      protected override bool IsInListShort(Cdcrec Cdcrec) {
         *              return !Cdcrec.IsHidden;
         *      }
         * }
         *
         * ///<summary>The object that accesses the cache in a thread-safe manner.</summary>
         * private static CdcrecCache _CdcrecCache=new CdcrecCache();
         *
         * ///<summary>A list of all Cdcrecs. Returns a deep copy.</summary>
         * public static List<Cdcrec> ListDeep {
         *      get {
         *              return _CdcrecCache.ListDeep;
         *      }
         * }
         *
         * ///<summary>A list of all visible Cdcrecs. Returns a deep copy.</summary>
         * public static List<Cdcrec> ListShortDeep {
         *      get {
         *              return _CdcrecCache.ListShortDeep;
         *      }
         * }
         *
         * ///<summary>A list of all Cdcrecs. Returns a shallow copy.</summary>
         * public static List<Cdcrec> ListShallow {
         *      get {
         *              return _CdcrecCache.ListShallow;
         *      }
         * }
         *
         * ///<summary>A list of all visible Cdcrecs. Returns a shallow copy.</summary>
         * public static List<Cdcrec> ListShort {
         *      get {
         *              return _CdcrecCache.ListShallowShort;
         *      }
         * }
         *
         * ///<summary>Refreshes the cache and returns it as a DataTable. This will refresh the ClientWeb's cache and the ServerWeb's cache.</summary>
         * public static DataTable RefreshCache() {
         *      return GetTableFromCache(true);
         * }
         *
         * ///<summary>Fills the local cache with the passed in DataTable.</summary>
         * public static void FillCacheFromTable(DataTable table) {
         *      _CdcrecCache.FillCacheFromTable(table);
         * }
         *
         * ///<summary>Always refreshes the ClientWeb's cache.</summary>
         * public static DataTable GetTableFromCache(bool doRefreshCache) {
         *      if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         *              DataTable table=Meth.GetTable(MethodBase.GetCurrentMethod(),doRefreshCache);
         *              _CdcrecCache.FillCacheFromTable(table);
         *              return table;
         *      }
         *      return _CdcrecCache.GetTableFromCache(doRefreshCache);
         * }
         *
         #endregion
         */
        #region Get Methods
        #endregion

        #region Modification Methods

        #region Insert
        #endregion

        #region Update
        #endregion

        #region Delete
        #endregion

        #endregion

        #region Misc Methods
        #endregion


        ///<summary></summary>
        public static long Insert(Cdcrec cdcrec)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                cdcrec.CdcrecNum = Meth.GetLong(MethodBase.GetCurrentMethod(), cdcrec);
                return(cdcrec.CdcrecNum);
            }
            return(Crud.CdcrecCrud.Insert(cdcrec));
        }
Ejemplo n.º 7
0
        /////<summary>Called after file is downloaded.  Throws exceptions.</summary>
        //public static void ImportAdministrativeSex(string tempFileName) ... not necessary.

        ///<summary>Called after file is downloaded.  Throws exceptions.  It is assumed that this is called from a worker thread.  Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary>
        public static void ImportCdcrec(string tempFileName, ProgressArgs progress, ref bool quit, ref int numCodesImported, ref int numCodesUpdated,
                                        bool updateExisting)
        {
            if (tempFileName == null)
            {
                return;
            }
            Dictionary <string, Cdcrec> dictCdcrecs = Cdcrecs.GetAll().ToDictionary(x => x.CdcrecCode, x => x);

            string[] lines = File.ReadAllLines(tempFileName);
            string[] arrayCDCREC;
            Cdcrec   cdcrec = new Cdcrec();

            for (int i = 0; i < lines.Length; i++)       //each loop should read exactly one line of code. and each line of code should be a unique code
            {
                if (quit)
                {
                    return;
                }
                if (i % 100 == 0)
                {
                    progress(i + 1, lines.Length);
                }
                arrayCDCREC = lines[i].Split('\t');
                if (dictCdcrecs.ContainsKey(arrayCDCREC[0]))                 //code already exists
                {
                    cdcrec = dictCdcrecs[arrayCDCREC[0]];
                    if (updateExisting &&
                        (cdcrec.HeirarchicalCode != arrayCDCREC[1] ||
                         cdcrec.Description != arrayCDCREC[2]))
                    {
                        cdcrec.HeirarchicalCode = arrayCDCREC[1];
                        cdcrec.Description      = arrayCDCREC[2];
                        Cdcrecs.Update(cdcrec);
                        numCodesUpdated++;
                    }
                    continue;
                }
                cdcrec.CdcrecCode       = arrayCDCREC[0];
                cdcrec.HeirarchicalCode = arrayCDCREC[1];
                cdcrec.Description      = arrayCDCREC[2];
                Cdcrecs.Insert(cdcrec);
                numCodesImported++;
            }
        }