///<summary></summary>
		public static void Update(ReplicationServer serv) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),serv);
				return;
			}
			Crud.ReplicationServerCrud.Update(serv);
		}
		///<summary></summary>
		public static long Insert(ReplicationServer serv) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				serv.ReplicationServerNum=Meth.GetLong(MethodBase.GetCurrentMethod(),serv);
				return serv.ReplicationServerNum;
			}
			return Crud.ReplicationServerCrud.Insert(serv);
		}
        ///<summary>Checks if the current database connected to is the replication report server.  Allows users to run dangerous custom queries that could potentially break replication.  We will allow these queries to be run on exactly one replication server (the report server), because our custom queries contain CREATE TABLE statements for static temporary table names which can cause replication failure if multiple users run the same query at the same time.</summary>
        public static bool IsConnectedReportServer()
        {
            //No need to check RemotingRole; no call to db.
            if (PrefC.GetLong(PrefName.ReplicationUserQueryServer) == 0)           //Report server not set up.
            {
                return(false);
            }
            ReplicationServer repServer = GetForLocalComputer();

            if (repServer == null || repServer.ReplicationServerNum != PrefC.GetLong(PrefName.ReplicationUserQueryServer))
            {
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        ///<summary>Generates a random primary key.  Tests to see if that key already exists before returning it for use.  The range of returned values is greater than 0, and less than or equal to 9223372036854775807.</summary>
        public static long GetKey(string tablename, string field)
        {
            //No need to check RemotingRole; no call to db.
            //establish the range for this server
            long rangeStart = 10000;
            long rangeEnd   = long.MaxValue;

            //the following line triggers a separate call to db if server_id=-1.  Must be cap.
            if (Server_id != 0)           //if it IS 0, then there is no server_id set.
            {
                ReplicationServer thisServer = null;
                for (int i = 0; i < Listt.Count; i++)
                {
                    if (Listt[i].ServerId == Server_id)
                    {
                        thisServer = Listt[i];
                        break;
                    }
                }
                if (thisServer != null)                                        //a ReplicationServer row was found for this server_id
                {
                    if (thisServer.RangeEnd - thisServer.RangeStart >= 999999) //and a valid range was entered that was at least 1,000,000
                    {
                        rangeStart = thisServer.RangeStart;
                        rangeEnd   = thisServer.RangeEnd;
                    }
                }
            }
            Random random = new Random();
            long   rndLong;
            long   span = rangeEnd - rangeStart;

            do
            {
                rndLong = (long)(random.NextDouble() * span) + rangeStart;
                //rnd=random.Next(myPartitionStart,myPartitionEnd);
            }while(rndLong == 0 ||
                   rndLong < rangeStart ||
                   rndLong > rangeEnd ||
                   KeyInUse(tablename, field, rndLong));
            return(rndLong);
        }