Ejemplo n.º 1
0
 public void Equals_string_to_rid(string rid)
 {
     var value = rid;
     var expected = new Rid(rid);
     Assert.True(value == expected);
     Assert.True(expected == value);
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Returns true if QueryResponseBody instances are equal
        /// </summary>
        /// <param name="other">Instance of QueryResponseBody to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(QueryResponseBody other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                     ) &&
                 (
                     Count == other.Count ||
                     Count != null &&
                     Count.Equals(other.Count)
                 ) &&
                 (
                     ResourceArray == other.ResourceArray ||
                     ResourceArray != null &&
                     ResourceArray.Equals(other.ResourceArray)
                 ));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Rid != null)
                {
                    hash = hash * 57 + Rid.GetHashCode();
                }

                if (Count != null)
                {
                    hash = hash * 57 + Count.GetHashCode();
                }

                if (ResourceArray != null)
                {
                    hash = hash * 57 + ResourceArray.GetHashCode();
                }

                return(hash);
            }
        }
Ejemplo n.º 4
0
    public static void Main(String[] args)
    {
        JobQueue jq = new JobQueue();
        // One user submits three jobs at time=27
        Rid rid1 = jq.Submit(new Ip("62.150.83.11"), 27);

        _ = jq.Submit(new Ip("62.150.83.11"), 27);
        // One user submits three jobs at time=27
        Rid rid3 = jq.Submit(new Ip("62.150.83.11"), 27);

        // One job is executed
        jq.ExecuteOne();
        // Another user submits two jobs at time=55
        _ = jq.Submit(new Ip("130.225.17.5"), 55);
        _ = jq.Submit(new Ip("130.225.17.5"), 55);
        // One more job is executed
        jq.ExecuteOne();
        // The first user tries to cancel his first and last job
        jq.Cancel(rid1);
        jq.Cancel(rid3);
        // The remaining jobs are executed
        while (jq.ExecuteOne() != null)
        {
        }
    }
Ejemplo n.º 5
0
        private int GetNeueNummer()
        {
            int    Rid;
            string RechnungID = (DateTime.Now.Year).ToString() + "5000";

            Int32.TryParse(RechnungID, out Rid);

            var q = this.priProRechnungTableAdapter.ScalarQueryMaxID();

            if (q != null)
            {
                int liefer;
                if (Int32.TryParse(q.ToString(), out liefer))
                {
                    Rid = liefer + 1;
                }

                // die Jahreszahlumstellung
                string LidJahrString       = Rid.ToString().Substring(0, 4);
                string aktuellesJahrString = (DateTime.Now.Year).ToString();
                if (LidJahrString.Equals(aktuellesJahrString) == false)
                {
                    string neuLid = (DateTime.Now.Year).ToString() + "0001";
                    Int32.TryParse(neuLid, out Rid);
                }
            }



            return(Rid);
        }
Ejemplo n.º 6
0
        public static byte[] UploadSalt(this IOMSConnection conn)
        {
            byte[] data      = null;
            Rid    rid       = new Rid(37U);
            Aid    aid       = new Aid(2449U);
            Value  obj       = null;
            int    requestID = -1;
            Error  error     = conn.ClientSession.GetVariableRemote(rid, aid, ref obj, ref requestID);

            if (error.Failed)
            {
                return(null);
            }
            using (obj)
            {
                Blob blob = null;
                error = obj.GetValue(ref blob);
                if (error.Succeeded)
                {
                    if (blob != null)
                    {
                        error = blob.GetData(ref data);
                        blob.Dispose();
                    }
                }
            }
            if (!error.Failed)
            {
                return(data);
            }
            return(null);
        }
Ejemplo n.º 7
0
 public static void TestStop(this ClientSession clientSession)
 {
     Rid   rid       = new Rid(52U);
     Value obj       = new Value(1);
     Aid   aid       = new Aid(2167U);
     int   requestID = 0;
     Error error     = clientSession.SetVariableRemote(rid, aid, obj, 1, ref requestID);
 }
Ejemplo n.º 8
0
 public void Cancel(Rid rid)
 {
     if (jobs.Remove(rid, out IPriorityQueueHandle <Job> h))
     {
         Job job = jobQueue.Delete(h);
         userJobs.Remove(job.ip);
         Console.WriteLine("Cancelled {0}", job);
     }
 }
Ejemplo n.º 9
0
 public void Cancel(Rid rid)
 {
     if (_jobs.Remove(rid, out IPriorityQueueHandle <Job> h))
     {
         var job = _jobQueue.Delete(h);
         _userJobs.Remove(job.Ip);
         Console.WriteLine($"Cancelled {job}");
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Rid != null)
                {
                    hash = hash * 57 + Rid.GetHashCode();
                }

                if (Count != null)
                {
                    hash = hash * 57 + Count.GetHashCode();
                }

                if (ResourceArray != null)
                {
                    hash = hash * 57 + ResourceArray.GetHashCode();
                }

                if (Date != null)
                {
                    hash = hash * 57 + Date.GetHashCode();
                }

                if (XMsItemCount != null)
                {
                    hash = hash * 57 + XMsItemCount.GetHashCode();
                }

                if (XMsContinuation != null)
                {
                    hash = hash * 57 + XMsContinuation.GetHashCode();
                }

                if (XMsRequestCharge != null)
                {
                    hash = hash * 57 + XMsRequestCharge.GetHashCode();
                }

                if (XMsActivityId != null)
                {
                    hash = hash * 57 + XMsActivityId.GetHashCode();
                }

                if (XMsSessionToken != null)
                {
                    hash = hash * 57 + XMsSessionToken.GetHashCode();
                }

                return(hash);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (ContentType != null)
                {
                    hash = hash * 57 + ContentType.GetHashCode();
                }

                if (Slug != null)
                {
                    hash = hash * 57 + Slug.GetHashCode();
                }

                if (UserAgent != null)
                {
                    hash = hash * 57 + UserAgent.GetHashCode();
                }

                if (Id != null)
                {
                    hash = hash * 57 + Id.GetHashCode();
                }

                if (Rid != null)
                {
                    hash = hash * 57 + Rid.GetHashCode();
                }

                if (Ts != null)
                {
                    hash = hash * 57 + Ts.GetHashCode();
                }

                if (Self != null)
                {
                    hash = hash * 57 + Self.GetHashCode();
                }

                if (Etag != null)
                {
                    hash = hash * 57 + Etag.GetHashCode();
                }

                if (Permissions != null)
                {
                    hash = hash * 57 + Permissions.GetHashCode();
                }

                return(hash);
            }
        }
Ejemplo n.º 12
0
		public void Deserializes_string_to_rid(string ridString)
		{
			var sut = GetSut();
			var settings = new JsonSerializerSettings();
			settings.Converters.Add(sut);
			var json = JsonConvert.SerializeObject(new Dummy { Rid = ridString }, settings);
			var rid = JsonConvert.DeserializeObject<Dummy>(json, settings);
			var expected = new Rid(12, 0);
			Assert.Equal(expected, rid.Rid);
		}
Ejemplo n.º 13
0
		public void Serializes_rid_to_string()
		{
			var sut = GetSut();
			var rid = new Rid(12, 0);
			var settings = new JsonSerializerSettings();
			settings.Converters.Add(sut);

			var json = JsonConvert.SerializeObject(rid, settings);
			Assert.Equal(@"""#12:0""", json);
		}
Ejemplo n.º 14
0
        /// <summary>
        ///     Returns true if AttachmentRaw instances are equal
        /// </summary>
        /// <param name="other">Instance of AttachmentRaw to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AttachmentRaw other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     ContentType == other.ContentType ||
                     ContentType != null &&
                     ContentType.Equals(other.ContentType)
                     ) &&
                 (
                     Slug == other.Slug ||
                     Slug != null &&
                     Slug.Equals(other.Slug)
                 ) &&
                 (
                     UserAgent == other.UserAgent ||
                     UserAgent != null &&
                     UserAgent.Equals(other.UserAgent)
                 ) &&
                 (
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                 ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ) &&
                 (
                     Permissions == other.Permissions ||
                     Permissions != null &&
                     Permissions.Equals(other.Permissions)
                 ));
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     Returns true if QueryResourceResponseBody instances are equal
        /// </summary>
        /// <param name="other">Instance of QueryResourceResponseBody to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(QueryResourceResponseBody other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                     ) &&
                 (
                     Count == other.Count ||
                     Count != null &&
                     Count.Equals(other.Count)
                 ) &&
                 (
                     ResourceArray == other.ResourceArray ||
                     ResourceArray != null &&
                     ResourceArray.Equals(other.ResourceArray)
                 ) &&
                 (
                     Date == other.Date ||
                     Date != null &&
                     Date.Equals(other.Date)
                 ) &&
                 (
                     XMsItemCount == other.XMsItemCount ||
                     XMsItemCount != null &&
                     XMsItemCount.Equals(other.XMsItemCount)
                 ) &&
                 (
                     XMsContinuation == other.XMsContinuation ||
                     XMsContinuation != null &&
                     XMsContinuation.Equals(other.XMsContinuation)
                 ) &&
                 (
                     XMsRequestCharge == other.XMsRequestCharge ||
                     XMsRequestCharge != null &&
                     XMsRequestCharge.Equals(other.XMsRequestCharge)
                 ) &&
                 (
                     XMsActivityId == other.XMsActivityId ||
                     XMsActivityId != null &&
                     XMsActivityId.Equals(other.XMsActivityId)
                 ) &&
                 (
                     XMsSessionToken == other.XMsSessionToken ||
                     XMsSessionToken != null &&
                     XMsSessionToken.Equals(other.XMsSessionToken)
                 ));
        }
Ejemplo n.º 16
0
 public void Equals_between_different_references()
 {
     var value = new Rid(0, 0);
     var expected = new Rid(0, 0);
     Assert.True(value == expected);
     Assert.True(expected == value);
     Assert.True(value.Equals(expected));
     Assert.True(expected.Equals(value));
     Assert.Equal(value, expected);
     Assert.Equal(expected, value);
 }
Ejemplo n.º 17
0
        private Context BuildContext()
        {
            var context = new Context();

            context.CurrentPlatform = Rid == null?Platform.Current() :
                                          Rid.StartsWith("win") ? Platform.Value.Windows :
                                          Rid.StartsWith("osx") ? Platform.Value.MacOs : Platform.Value.Linux;

            context.TempPublishPath = Path.Combine(ProjectFileOrFolder, "dotnetwarp_temp");

            return(context);
        }
Ejemplo n.º 18
0
    public Rid Submit(Ip ip, int time)
    {
        int jobCount = userJobs.ContainsCount(ip);
        Rid rid      = new Rid();
        Job job      = new Job(rid, ip, time + 60 * jobCount);
        IPriorityQueueHandle <Job> h = null;

        jobQueue.Add(ref h, job);
        userJobs.Add(ip);
        jobs.Add(rid, h);
        Console.WriteLine("Submitted {0}", job);
        return(rid);
    }
Ejemplo n.º 19
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Id != null)
                {
                    hash = hash * 57 + Id.GetHashCode();
                }

                if (PermissionMode != null)
                {
                    hash = hash * 57 + PermissionMode.GetHashCode();
                }

                if (Resource != null)
                {
                    hash = hash * 57 + Resource.GetHashCode();
                }

                if (Rid != null)
                {
                    hash = hash * 57 + Rid.GetHashCode();
                }

                if (Ts != null)
                {
                    hash = hash * 57 + Ts.GetHashCode();
                }

                if (Self != null)
                {
                    hash = hash * 57 + Self.GetHashCode();
                }

                if (Etag != null)
                {
                    hash = hash * 57 + Etag.GetHashCode();
                }

                if (Token != null)
                {
                    hash = hash * 57 + Token.GetHashCode();
                }

                return(hash);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Id != null)
                {
                    hash = hash * 57 + Id.GetHashCode();
                }

                if (Rid != null)
                {
                    hash = hash * 57 + Rid.GetHashCode();
                }

                if (Databases != null)
                {
                    hash = hash * 57 + Databases.GetHashCode();
                }

                if (Ts != null)
                {
                    hash = hash * 57 + Ts.GetHashCode();
                }

                if (Self != null)
                {
                    hash = hash * 57 + Self.GetHashCode();
                }

                if (Etag != null)
                {
                    hash = hash * 57 + Etag.GetHashCode();
                }

                if (Colls != null)
                {
                    hash = hash * 57 + Colls.GetHashCode();
                }

                if (Users != null)
                {
                    hash = hash * 57 + Users.GetHashCode();
                }

                return(hash);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Id != null)
                {
                    hash = hash * 57 + Id.GetHashCode();
                }

                if (Body != null)
                {
                    hash = hash * 57 + Body.GetHashCode();
                }

                if (TriggerOperation != null)
                {
                    hash = hash * 57 + TriggerOperation.GetHashCode();
                }

                if (TriggerType != null)
                {
                    hash = hash * 57 + TriggerType.GetHashCode();
                }

                if (Rid != null)
                {
                    hash = hash * 57 + Rid.GetHashCode();
                }

                if (Ts != null)
                {
                    hash = hash * 57 + Ts.GetHashCode();
                }

                if (Self != null)
                {
                    hash = hash * 57 + Self.GetHashCode();
                }

                if (Etag != null)
                {
                    hash = hash * 57 + Etag.GetHashCode();
                }

                return(hash);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Returns true if Permission instances are equal
        /// </summary>
        /// <param name="other">Instance of Permission to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Permission other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     PermissionMode == other.PermissionMode ||
                     PermissionMode != null &&
                     PermissionMode.SequenceEqual(other.PermissionMode)
                 ) &&
                 (
                     Resource == other.Resource ||
                     Resource != null &&
                     Resource.Equals(other.Resource)
                 ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ) &&
                 (
                     Token == other.Token ||
                     Token != null &&
                     Token.Equals(other.Token)
                 ));
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     Returns true if Offer instances are equal
        /// </summary>
        /// <param name="other">Instance of Offer to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Offer other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     OfferType == other.OfferType ||
                     OfferType != null &&
                     OfferType.Equals(other.OfferType)
                     ) &&
                 (
                     Resource == other.Resource ||
                     Resource != null &&
                     Resource.Equals(other.Resource)
                 ) &&
                 (
                     OfferResourceId == other.OfferResourceId ||
                     OfferResourceId != null &&
                     OfferResourceId.Equals(other.OfferResourceId)
                 ) &&
                 (
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                 ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ));
        }
Ejemplo n.º 24
0
        /// <summary>
        ///     Returns true if DatabaseCollection instances are equal
        /// </summary>
        /// <param name="other">Instance of DatabaseCollection to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(DatabaseCollection other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Databases == other.Databases ||
                     Databases != null &&
                     Databases.SequenceEqual(other.Databases)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ) &&
                 (
                     Colls == other.Colls ||
                     Colls != null &&
                     Colls.Equals(other.Colls)
                 ) &&
                 (
                     Users == other.Users ||
                     Users != null &&
                     Users.Equals(other.Users)
                 ));
        }
Ejemplo n.º 25
0
        /// <summary>
        ///     Returns true if Trigger instances are equal
        /// </summary>
        /// <param name="other">Instance of Trigger to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Trigger other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Body == other.Body ||
                     Body != null &&
                     Body.Equals(other.Body)
                 ) &&
                 (
                     TriggerOperation == other.TriggerOperation ||
                     TriggerOperation != null &&
                     TriggerOperation.Equals(other.TriggerOperation)
                 ) &&
                 (
                     TriggerType == other.TriggerType ||
                     TriggerType != null &&
                     TriggerType.Equals(other.TriggerType)
                 ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ));
        }
Ejemplo n.º 26
0
        public static uint GetProtectionLevelOnline(this ClientSession session)
        {
            uint  m_OnlineProtectionLevel = 0;
            Rid   rid       = new Rid(50U);
            Aid   aid       = new Aid(3451U);
            Value obj       = new Value();
            int   requestID = -1;

            if (session.GetVariableRemote(rid, aid, ref obj, ref requestID).Succeeded)
            {
                obj.GetValue(ref m_OnlineProtectionLevel);
            }

            return(m_OnlineProtectionLevel);
        }
Ejemplo n.º 27
0
    public Rid Submit(Ip ip, int time)
    {
        var jobCount = _userJobs.ContainsCount(ip);
        var rid      = new Rid();
        var job      = new Job(rid, ip, time + 60 * jobCount);
        IPriorityQueueHandle <Job> h = default;

        _jobQueue.Add(ref h, job);
        _userJobs.Add(ip);
        _jobs.Add(rid, h);

        Console.WriteLine($"Submitted {job}");

        return(rid);
    }
Ejemplo n.º 28
0
        public async Task RefreshItem(Dictionary <string, string> result, OrientConnection setupConnection, IRestClient setupClient)
        {
            var rid     = new Rid(Item.IsNew() ? result[Identifier.Sql] : Item.Rid);
            var select  = new Select(new From(rid));
            var batch   = new OrientQueryBatch(setupConnection, select);
            var command = new Batch <List <T> >(batch, setupClient);
            var res     = await command.Execute() switch
            {
                Result <List <T>, Exception> .OkCase o => o.Payload,
                Result <List <T>, Exception> .ErrCase e => throw e.Payload,
                      _ => throw new InvalidCastException()
            };

            DbItem = res.FirstOrDefault();
        }
    }
Ejemplo n.º 29
0
        /// <summary>
        ///     Returns true if AttachmentResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of AttachmentResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AttachmentResponse other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     ContentType == other.ContentType ||
                     ContentType != null &&
                     ContentType.Equals(other.ContentType)
                 ) &&
                 (
                     Media == other.Media ||
                     Media != null &&
                     Media.Equals(other.Media)
                 ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ));
        }
Ejemplo n.º 30
0
        private void UpdtBTN_Click(object sender, EventArgs e)
        {
            using (SqlConnection Connection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|mainDatabase.mdf;Integrated Security=True;Connect Timeout=30"))
            {
                if (Rid.Text == string.Empty)
                {
                    MessageBox.Show("Missing values");
                }

                else
                {
                    try
                    {
                        Connection.Open();
                        SqlCommand cmd = new SqlCommand(@"DELETE FROM Staff where id=Rid.text");    //SQL to delete row from DB


                        int i = cmd.ExecuteNonQuery();
                        Connection.Close();


                        if (i == 1)   //confirms success or fail
                        {
                            MessageBox.Show("Employee has been removed");
                            Rid.Clear();
                        }
                        else
                        {
                            MessageBox.Show("Employee couldn't be removed");
                        }
                    }



                    catch (Exception ex)
                    {
                        MessageBox.Show("Unexpected error:" + ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 31
0
        private void A_FineReader_Load(object sender, EventArgs e)
        {
            SqlConnection conn = SQLbase.getConn();

            try
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                conn.Open();
                string        selectStr = "select * from readers where Rstate > 0";
                SqlCommand    SelectCmd = new SqlCommand(selectStr, conn);
                SqlDataReader datareader = SelectCmd.ExecuteReader();
                string        Rid, Rname, Rgender, Runit, Rtype, Rstate;
                int           rowindex = 0;
                this.datagridview.Rows.Clear();
                while (datareader.Read())
                {
                    Rid     = datareader["RID"].ToString();
                    Rname   = datareader["Rname"].ToString();
                    Rgender = datareader["Rgender"].ToString();
                    Runit   = datareader["Runit"].ToString();
                    Rtype   = datareader["Rtype"].ToString();
                    Rstate  = datareader["Rstate"].ToString();

                    rowindex = this.datagridview.Rows.Add();
                    //trim函数同于去除字符串两头的空格
                    this.datagridview.Rows[rowindex].Cells[0].Value = Rid.Trim();
                    this.datagridview.Rows[rowindex].Cells[1].Value = Rname.Trim();
                    this.datagridview.Rows[rowindex].Cells[2].Value = Rgender.Trim();
                    this.datagridview.Rows[rowindex].Cells[3].Value = Runit.Trim();
                    this.datagridview.Rows[rowindex].Cells[4].Value = Rtype.Trim();
                    this.datagridview.Rows[rowindex].Cells[5].Value = Rstate.Trim();
                }
            }
            catch
            {
                MessageBox.Show("操作错误!");
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        ///     Returns true if StoredProcedure instances are equal
        /// </summary>
        /// <param name="other">Instance of StoredProcedure to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(StoredProcedure other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Body == other.Body ||
                     Body != null &&
                     Body.Equals(other.Body)
                 ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ));
        }
Ejemplo n.º 33
0
        /// <summary>
        ///     Returns true if Document instances are equal
        /// </summary>
        /// <param name="other">Instance of Document to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Document other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ) &&
                 (
                     Attachments == other.Attachments ||
                     Attachments != null &&
                     Attachments.Equals(other.Attachments)
                 ));
        }
Ejemplo n.º 34
0
        /// <summary>
        ///     Returns true if User instances are equal
        /// </summary>
        /// <param name="other">Instance of User to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(User other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
            {
                return(false);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Rid == other.Rid ||
                     Rid != null &&
                     Rid.Equals(other.Rid)
                 ) &&
                 (
                     Ts == other.Ts ||
                     Ts != null &&
                     Ts.Equals(other.Ts)
                 ) &&
                 (
                     Self == other.Self ||
                     Self != null &&
                     Self.Equals(other.Self)
                 ) &&
                 (
                     Etag == other.Etag ||
                     Etag != null &&
                     Etag.Equals(other.Etag)
                 ) &&
                 (
                     Permissions == other.Permissions ||
                     Permissions != null &&
                     Permissions.Equals(other.Permissions)
                 ));
        }
Ejemplo n.º 35
0
 public void Not_equals_between_different_references()
 {
     var value = new Rid(0, 0);
     var expected = new Rid(0, 1);
     Assert.True(value != expected);
     Assert.True(expected != value);
     Assert.False(value.Equals(expected));
     Assert.False(expected.Equals(value));
     Assert.NotEqual(value, expected);
     Assert.NotEqual(expected, value);
 }
Ejemplo n.º 36
0
 public void Not_equals_string_to_rid(string rid, string rid2)
 {
     var value = rid;
     var expected = new Rid(rid2);
     Assert.True(value != expected);
     Assert.True(expected != value);
 }
Ejemplo n.º 37
0
 public void New_instance_is_Indeternimate()
 {
     var result = new Rid();
     Assert.True(result.IsIndeterminated);
 }
Ejemplo n.º 38
0
 public void Indeterninatable_rid_values(short clusterId, long rowId)
 {
     var result = new Rid(clusterId, rowId);
     Assert.True(result.IsIndeterminated);
 }
Ejemplo n.º 39
0
 public void Indeterminatable_rid_string(string rid)
 {
     var result = new Rid(rid);
     Assert.True(result.IsIndeterminated);
 }