Exemple #1
0
        public void SaveWithViewSettings(SavingJournalSettings.SaveArgument argument, string conext)
        {
            if (!argument.saveFilters)
            {
                PageUrl = null;
            }
            using (var db = new DB_RvsSettingsDataContext(SpecificInstances.DbFactory.CreateConnection()))
            {
                db.Connection.Open();
                DbTransaction transaction = null;
                try
                {
                    transaction    = db.Connection.BeginTransaction();
                    db.Transaction = transaction;
                    var row = SaveProperties(db);
                    db.SubmitChanges();

                    RVS_SavedProperty viewRow = null;
                    if (argument.id != null)
                    {
                        var data = db.RVS_SavedProperties.
                                   Where(r => r.id == argument.id);
                        if (UserRoles.IsInRole(UserRoles.AllowChangeOrDeleteJournalSettingsAsShared))
                        {
                            data = data.Where(r => r.isSharedView || r.UserSID == User.GetSID());
                        }
                        else
                        {
                            data = data.Where(r => r.UserSID == User.GetSID());
                        }
                        viewRow = data.FirstOrDefault();
                    }
                    if (viewRow == null)
                    {
                        viewRow = new RVS_SavedProperty();
                        db.RVS_SavedProperties.InsertOnSubmit(viewRow);
                    }

                    viewRow.context         = conext;
                    viewRow.dateTime        = DateTime.Now;
                    viewRow.isDefaultView   = false;
                    viewRow.isSharedView    = argument.saveAsShared && UserRoles.IsInRole(UserRoles.AllowSaveJournalSettingsAsShared);
                    viewRow.JournalTypeName = JournalTypeName;
                    viewRow.nameRu          = argument.nameRu;
                    viewRow.nameKz          = argument.nameKz;
                    viewRow.UserSID         = User.GetSID();
                    viewRow.refProperties   = row.id;

                    db.SubmitChanges();
                    db.Transaction.Commit();
                }
                catch
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Dispose();
                    }
                    db.Connection.Close();
                }
            }
        }
Exemple #2
0
 partial void DeleteRVS_SavedProperty(RVS_SavedProperty instance);
Exemple #3
0
 partial void InsertRVS_SavedProperty(RVS_SavedProperty instance);
Exemple #4
0
 partial void UpdateRVS_SavedProperty(RVS_SavedProperty instance);
Exemple #5
0
 private void detach_RVS_SavedProperties(RVS_SavedProperty entity)
 {
     this.SendPropertyChanging();
     entity.RVS_Property = null;
 }