Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
Example #1
0
        private static bool UpdateLock(Synchronization oldLock, double timeframe)
        {
            var proc = SenseNet.ContentRepository.Storage.Data.DataProvider.CreateDataProcedure(insertSql);
            proc.CommandType = System.Data.CommandType.Text;

            //lockname - nem biztos, hogy kell
            var lockNamePrm = SenseNet.ContentRepository.Storage.Data.DataProvider.CreateParameter();
            lockNamePrm.ParameterName = "@lockName";
            lockNamePrm.DbType = System.Data.DbType.String;
            lockNamePrm.Value = NOTIFICATIONLOCKNAME;
            proc.Parameters.Add(lockNamePrm);
            
            //lockedUntil
            var lockedUntilPrm = SenseNet.ContentRepository.Storage.Data.DataProvider.CreateParameter();
            lockedUntilPrm.ParameterName = "@lockedUntil";
            lockedUntilPrm.DbType = System.Data.DbType.DateTime;
            lockedUntilPrm.Value = DateTime.Now.AddMinutes(timeframe);
            proc.Parameters.Add(lockedUntilPrm);

            //computername
            var computerNamePrm = SenseNet.ContentRepository.Storage.Data.DataProvider.CreateParameter();
            computerNamePrm.ParameterName = "@computerName";
            computerNamePrm.DbType = System.Data.DbType.String;
            computerNamePrm.Value = Environment.MachineName;
            proc.Parameters.Add(computerNamePrm);

            //lockId
            var lockIdPrm = SenseNet.ContentRepository.Storage.Data.DataProvider.CreateParameter();
            lockIdPrm.ParameterName = "@lockId";
            lockIdPrm.DbType = System.Data.DbType.String;
            lockIdPrm.Value = Guid.NewGuid().ToString();
            proc.Parameters.Add(lockIdPrm);

            //oldLockedUntil
            var oldLockedUntilPrm = SenseNet.ContentRepository.Storage.Data.DataProvider.CreateParameter();
            oldLockedUntilPrm.ParameterName = "@oldLockedUntil";
            oldLockedUntilPrm.DbType = System.Data.DbType.DateTime2;
            oldLockedUntilPrm.Value = oldLock.LockedUntil;
            proc.Parameters.Add(oldLockedUntilPrm);
            
            try
            {
                var rows = proc.ExecuteNonQuery();
                return rows == 1;
            }
            catch (Exception ex)
            {
                Logger.WriteException(ex);
                return false;
            }

            
        }
Example #2
0
 partial void DeleteSynchronization(Synchronization instance);
Example #3
0
        private static bool InsertLock(double timeframe)
        {
            using (var context = new DataHandler())
            {
                var success = false;
                var notifLock = new Synchronization
                                    {
                                        LockName = NOTIFICATIONLOCKNAME,
                                        Locked = true,
                                        ComputerName = Environment.MachineName,
                                        LockedUntil =
                                            DateTime.Now.AddMinutes(timeframe),
                                        LockId = AppDomainId
                                    };
                try
                {
                    context.Synchronizations.InsertOnSubmit(notifLock);
                    context.SubmitChanges();
                    success = true;
                }
                catch (Exception ex)
                {
                    Logger.WriteException(ex);
                }

                return success;
            }
        }
Example #4
0
 partial void UpdateSynchronization(Synchronization instance);
Example #5
0
 partial void InsertSynchronization(Synchronization instance);
 partial void DeleteSynchronization(Synchronization instance);
 partial void UpdateSynchronization(Synchronization instance);
 partial void InsertSynchronization(Synchronization instance);