/// <summary>
        /// Add AccountDataRecordAdditionals to database
        /// </summary>
        /// <param name="instances">AccountDataRecordAdditional instance array</param>
        /// <param name="accountDataRecord">AccountDataRecord instance for instances</param>
        /// <param name="saveAfterInsert">Save database after insertion</param>
        /// <param name="waitUntilSaving">Wait until saving</param>
        public void AccountDataRecordAdditionalAdd(IEnumerable<AccountDataRecordAdditional> instances, AccountDataRecord accountDataRecord, bool saveAfterInsert = true, bool waitUntilSaving = true)
        {
            try
            {
                if (instances == null)
                    throw new ArgumentNullException("instances");
                if (accountDataRecord == null)
                    throw new ArgumentNullException("accountDataRecord");
                instances = instances.Where(i => i != null).ToArray();
                try
                {
                    foreach (var i in instances)
                        if (i.AccountDataRecord != accountDataRecord)
                            i.AccountDataRecord = accountDataRecord;

                    this.Context.AccountDataRecordAdditionals.AddRange(instances);
                    if (saveAfterInsert)
                        this.SaveChanges(waitUntilSaving);
                }
                catch (Exception ex)
                {
                    var e = new Exception(ex.Message, ex);
                    for (int i = 0; i < instances.Count();i++)
                        e.Data.Add(string.Format("instance_{0}", i), instances.ElementAt(i).ToString());
                    throw e;
                }
            }
            catch (Exception ex)
            {
                Helpers.Log.Add(ex, string.Format("Repository.AccountDataRecordAdditionalAdd(instances=[{0}],saveAfterInsert={1},waitUntilSaving={2})", instances == null ? "NULL" : instances.Count().ToString(), saveAfterInsert, waitUntilSaving));
                throw;
            }
        }
示例#2
0
 /// <summary>
 /// Create/Get new AccountDataRecordExport instance without any link to database
 /// </summary>
 /// <returns>AccountDataRecordExport instance</returns>
 public AccountDataRecordExport AccountDataRecordExportNew(AccountDataRecord accountDataRecord = null, File file = null, Host host = null)
 {
     try
     {
         var dt = DateTime.UtcNow;
         var res = new AccountDataRecordExport()
         {
             ExportDate = DateTime.UtcNow,
             AccountDataRecord = accountDataRecord,
             File = file,
             Host = host
         };
         if (accountDataRecord != null)
             accountDataRecord.ExportInfo.Add(res);
         return res;
     }
     catch(Exception ex)
     {
         Helpers.Log.Add(ex, string.Format("Repository.AccountDataRecordExportNew()"));
         throw;
     }
 }
        /// <summary>
        /// Create/Get new ImportQueueRecordFileAccountDataRecord instance without any link to database
        /// </summary>
        /// <returns>ImportQueueRecordFileAccountDataRecord instance</returns>
        public ImportQueueRecordFileAccountDataRecord ImportQueueRecordFileAccountDataRecordNew(ImportQueueRecordFileInfo importQueueRecordFile = null, AccountDataRecord accountDataRecord = null)
        {
            try
            {
                var dt = DateTime.UtcNow;
                var res = new ImportQueueRecordFileAccountDataRecord()
                { 
                    ImportQueueRecordFile = importQueueRecordFile,
                    AccountDataRecord = accountDataRecord,
                    LoadDate = dt,
                };

                if (importQueueRecordFile != null)
                    importQueueRecordFile.LoadedRecords.Add(res);

                if (accountDataRecord != null)
                    accountDataRecord.LoadedByQueueFiles.Add(res);

                return res;
            }
            catch(Exception ex)
            {
                Helpers.Log.Add(ex, string.Format("Repository.ImportQueueRecordFileAccountDataRecordNew()"));
                throw;
            }
        }
示例#4
0
 public static object GetAccountDataForColumnType(this ColumnTypes type, AccountDataRecord data)
 {
     switch(type)
     {
         case ColumnTypes.Address:
             return data.Street.Name + (string.IsNullOrWhiteSpace(data.HouseNumber) ? string.Empty : ", " + data.HouseNumber);
         case ColumnTypes.Area:
             return data.Street.Area.Name;
         case ColumnTypes.Changed:
             return data.Changed;
         case ColumnTypes.City:
             return data.Street.Area.City.Name;
         case ColumnTypes.Created:
             return data.Created;
         case ColumnTypes.Exported:
             return data.Exported;
         case ColumnTypes.Host:
             return data.Host.Name;
         case ColumnTypes.Mark:
             return data.Account.PhoneMarks.FirstOrDefault(pm => pm.PhoneID == data.PhoneID)?.Mark?.Name;
         case ColumnTypes.Phone:
             return data.Phone.PhoneNumber;
     }
     return null;
 }
示例#5
0
		/// <summary>
        /// Loads account based data, creates base data if no data is found.
        /// </summary>
        void LoadAccountData()
        {
            var adr = AccountDataRecord.GetAccountData(AccountId) ?? AccountDataRecord.InitializeNewAccount(AccountId);

            AccountData = adr;
        }
示例#6
0
        /// <summary>
        /// Loads account based data, creates base data if no data is found.
        /// </summary>
        void LoadAccountData()
        {
            var adr = AccountDataRecord.GetAccountData(AccountId) ?? AccountDataRecord.InitializeNewAccount(AccountId);

            AccountData = adr;
        }
示例#7
0
 /// <summary>
 /// Loads account based data, creates base data if no data is found.
 /// </summary>
 private void LoadAccountData()
 {
     this.AccountData = AccountDataRecord.GetAccountData((long)this.AccountId) ??
                        AccountDataRecord.InitializeNewAccount((long)this.AccountId);
 }
 /// <summary>
 /// Add AccountDataRecordAdditional to database
 /// </summary>
 /// <param name="instance">AccountDataRecordAdditional instance</param>
 /// <param name="accountDataRecord">AccountDataRecord instance for instance</param>
 /// <param name="saveAfterInsert">Save database after insertion</param>
 /// <param name="waitUntilSaving">Wait until saving</param>
 public void AccountDataRecordAdditionalAdd(AccountDataRecordAdditional instance, AccountDataRecord accountDataRecord, bool saveAfterInsert = true, bool waitUntilSaving = true)
 {
     AccountDataRecordAdditionalAdd(new AccountDataRecordAdditional[] { instance }, accountDataRecord, saveAfterInsert, waitUntilSaving);
 }
 /// <summary>
 /// Create/Get new AccountDataRecordAdditional instance without any link to database
 /// </summary>
 /// <returns>AccountDataRecordAdditional instance</returns>
 public AccountDataRecordAdditional AccountDataRecordAdditionalNew(AccountDataRecord accountDataRecord = null)
 {
     try
     {
         var res = new AccountDataRecordAdditional();
         if (accountDataRecord != null)
             accountDataRecord.DataAdditional = res;
         return res;
     }
     catch(Exception ex)
     {
         Helpers.Log.Add(ex, string.Format("Repository.AccountDataRecordAdditionalNew()"));
         throw;
     }
 }
示例#10
0
 /// <summary>
 /// Loads account based data, creates base data if no data is found.
 /// </summary>
 private void LoadAccountData()
 {
     AccountData = AccountDataRecord.GetAccountData(AccountId) ??
                   AccountDataRecord.InitializeNewAccount(AccountId);
 }