示例#1
0
        public override RecordLockedData CreateLockInfo(RecordLockedData lockedData)
        {
            RecordLockedData result = null;

            if (lockedData != null)
            {
                result = (RecordLockedData)lockedData.Clone();
                if (result.ID == Guid.Empty)
                {
                    result.ID = CombineGuid.NewComboGuid();
                }

                if (result.LockTime == DateTime.MinValue)
                {
                    result.LockTime = DateTime.UtcNow;
                }

                DbCommand dbCmd = this.InsertCommand;
                Utils.PrepareParameter(dbCmd);
                this.Adapter.SetParametersValue(dbCmd.Parameters, result, false);
                Utils.ResetParameter(dbCmd);

                this.Database.ExecuteNonQuery(dbCmd);
            }
            return(result);
        }
示例#2
0
        public virtual RecordLockedData Lock(RecordLockedData lockedData)
        {
            RecordLockedData           result     = null;
            RecordLockedFetchParameter fetchParam = CreateFetchParameter(lockedData);
            RecordLockedData           data       = this.GetLockedInfoData(fetchParam);

            if (data != null)
            {
                //if (lockedData.FormID != Guid.Empty
                //    && lockedData.FormUniqueID != Guid.Empty
                //    && data.FormID != Guid.Empty
                //    && data.FormUniqueID != Guid.Empty
                //    && data.FormID != lockedData.FormID
                //    && data.FormUniqueID != lockedData.FormUniqueID)
                //{
                //    __Error.RecordHasLocked(data.FormID, data.FormUniqueID);
                //}
                if (lockedData.FormID != Guid.Empty &&
                    lockedData.FormUniqueID != Guid.Empty &&
                    data.FormID != Guid.Empty &&
                    data.FormUniqueID != Guid.Empty
                    )
                {
                    if ((data.FormID != lockedData.FormID ||
                         data.FormUniqueID != lockedData.FormUniqueID) &&
                        data.ExpireTime > DateTime.UtcNow
                        )
                    {
                        __Error.RecordHasLocked(data.FormID, data.FormUniqueID);
                    }
                    else if (data.FormID == lockedData.FormID &&
                             data.FormUniqueID == lockedData.FormUniqueID &&
                             data.ID != lockedData.ID &&
                             data.ExpireTime > DateTime.UtcNow)
                    {
                        __Error.RecordHasLocked(data.FormID, data.FormUniqueID);
                    }
                }
            }
            else
            {
                data = (RecordLockedData)lockedData.Clone();
            }
            this.PrepareLockData(data);
            result = this.DataProvider.CreateLockInfo(data);
            return(result);
        }