Пример #1
0
        void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
        {
            this.Id             = source.GetI(MD.MobStations.Fields.Id);
            this.Agl            = source.GetD(MD.MobStations.Fields.Agl);
            this.Azimut         = source.GetD(MD.MobStations.Fields.Azimut);
            this.BW             = source.GetD(MD.MobStations.Fields.BW);
            this.DesignEmission = source.GetS(MD.MobStations.Fields.DesignEmission);
            this.Name           = source.GetS(MD.MobStations.Fields.Name);
            this.CustTxt13      = source.GetS(MD.MobStations.Fields.CustTxt13);
            this.Power          = source.GetD(MD.MobStations.Fields.Power);
            this.Standart       = source.GetS(MD.MobStations.Fields.Standart);

            this.OwnerRef = new Owner
            {
                Id        = source.GetI(MD.MobStations.Fields.Owner.Id),
                Address   = source.GetS(MD.MobStations.Fields.Owner.Address),
                Code      = source.GetS(MD.MobStations.Fields.Owner.Code),
                Name      = source.GetS(MD.MobStations.Fields.Owner.Name),
                PostCode  = source.GetS(MD.MobStations.Fields.Owner.PostCode),
                RegistNum = source.GetS(MD.MobStations.Fields.Owner.RegistNum),
            };

            this.PositionRef = new Position
            {
                Address     = source.GetS(MD.MobStations.Fields.Position.Address),
                Latitude    = source.GetD(MD.MobStations.Fields.Position.Latitude),
                Longitude   = source.GetD(MD.MobStations.Fields.Position.Longitude),
                SubProvince = source.GetS(MD.MobStations.Fields.Position.SubProvince),
            };
        }
Пример #2
0
 void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
 {
     this.Id               = source.GetI(MD.Inspection.Fields.Id);
     this.Status           = source.GetS(MD.Inspection.Fields.Status);
     this.StationTableId   = source.GetI(MD.Inspection.Fields.StationTableId);
     this.StationTableName = source.GetS(MD.Inspection.Fields.StationTableName);
     this.TourId           = source.GetI(MD.Inspection.Fields.TourId);
 }
Пример #3
0
        public static void WriteToDb(Record record)
        {
            try
            {
                var logsRs = new IMRecordset(MD.SysLogs.TableName, IMRecordset.Mode.ReadWrite);
                using (var logsRsScope = logsRs.OpenForAdd(
                           MD.SysLogs.Fields.Id,
                           MD.SysLogs.Fields.Event,
                           MD.SysLogs.Fields.TableName,
                           MD.SysLogs.Fields.Count,
                           MD.SysLogs.Fields.Info,
                           MD.SysLogs.Fields.Who,
                           MD.SysLogs.Fields.When
                           ))
                {
                    var currentTime = DateTime.Now;
                    var currentUser = IM.ConnectedUser();

                    logsRs.AddNew(MD.SysLogs.TableName, MD.SysLogs.Fields.Id);
                    logsRs.Put(MD.SysLogs.Fields.Event, record.Type.ToString());
                    logsRs.Put(MD.SysLogs.Fields.TableName, MD.SysLogs.TableName);
                    logsRs.Put(MD.SysLogs.Fields.Count, 1);
                    logsRs.Put(MD.SysLogs.Fields.Info, $"{record.Process}: {record.Message}");
                    logsRs.Put(MD.SysLogs.Fields.Who, currentUser);
                    logsRs.Put(MD.SysLogs.Fields.When, currentTime);
                    logsRs.Update();

                    if (record.Duration > 0)
                    {
                        logsRs.AddNew(MD.SysLogs.TableName, MD.SysLogs.Fields.Id);
                        logsRs.Put(MD.SysLogs.Fields.Event, record.Type.ToString());
                        logsRs.Put(MD.SysLogs.Fields.TableName, MD.SysLogs.TableName);
                        logsRs.Put(MD.SysLogs.Fields.Count, 1);
                        logsRs.Put(MD.SysLogs.Fields.Info, $"{record.Process}: Duration {record.Duration}ms");
                        logsRs.Put(MD.SysLogs.Fields.Who, currentUser);
                        logsRs.Put(MD.SysLogs.Fields.When, currentTime);
                        logsRs.Update();
                    }

                    if (!string.IsNullOrEmpty(record.Data))
                    {
                        logsRs.AddNew(MD.SysLogs.TableName, MD.SysLogs.Fields.Id);
                        logsRs.Put(MD.SysLogs.Fields.Event, record.Type.ToString());
                        logsRs.Put(MD.SysLogs.Fields.TableName, MD.SysLogs.TableName);
                        logsRs.Put(MD.SysLogs.Fields.Count, 1);
                        logsRs.Put(MD.SysLogs.Fields.Info, $"{record.Process}: {record.Data}");
                        logsRs.Put(MD.SysLogs.Fields.Who, currentUser);
                        logsRs.Put(MD.SysLogs.Fields.When, currentTime);
                        logsRs.Update();
                    }
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString(), "Logger.WriteToDb", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
Пример #4
0
 void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
 {
     this.Id        = source.GetI(MD.AllStations.Fields.Id);
     this.Latitude  = source.GetD(MD.AllStations.Fields.Latitude);
     this.Longitude = source.GetD(MD.AllStations.Fields.Longitude);
     this.TableId   = source.GetI(MD.AllStations.Fields.TableId);
     this.TableName = source.GetS(MD.AllStations.Fields.TableName);
     this.Standart  = source.GetS(MD.AllStations.Fields.Standart);
 }
Пример #5
0
        public OpenedRecordsetScope(IMRecordset recordset)
        {
            this._recordset = recordset;

            if (!recordset.IsOpen())
            {
                recordset.Open();
            }
        }
Пример #6
0
 void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
 {
     this.Id            = source.GetI(MD.Tours.Fields.Id);
     this.Status        = source.GetS(MD.Tours.Fields.Status);
     this.LocationList  = source.GetS(MD.Tours.Fields.LocationList);
     this.RadioTechList = source.GetS(MD.Tours.Fields.RadioTechList);
     this.StartDate     = source.GetT(MD.Tours.Fields.StartDate);
     this.StopDate      = source.GetT(MD.Tours.Fields.StopDate);
 }
Пример #7
0
 void IRepositoryCreatedEntity.SaveToRecordset(IMRecordset source)
 {
     source.Put(MD.Inspection.Fields.Id, this.Id);
     source.Put(MD.Inspection.Fields.Type, this.Type);
     source.Put(MD.Inspection.Fields.Status, this.Status);
     source.Put(MD.Inspection.Fields.DoItAfter, this.DoItAfter);
     source.Put(MD.Inspection.Fields.DoItBefore, this.DoItBefore);
     source.Put(MD.Inspection.Fields.TourId, this.TourId);
     source.Put(MD.Inspection.Fields.StationTableName, this.StationTableName);
     source.Put(MD.Inspection.Fields.StationTableId, this.StationTableId);
 }
Пример #8
0
 void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
 {
     this.Id                = source.GetI(MD.Tours.Fields.Id);
     this.Status            = source.GetS(MD.Tours.Fields.Status);
     this.StartDate         = source.GetT(MD.Tours.Fields.StartDate);
     this.StopDate          = source.GetT(MD.Tours.Fields.StopDate);
     this.MeasTaskId        = source.GetI(MD.Tours.Fields.MeasTaskId);
     this.MeasTaskName      = source.GetS(MD.Tours.Fields.MeasTaskName);
     this.SensorName        = source.GetS(MD.Tours.Fields.SensorName);
     this.SensorEquipTechId = source.GetS(MD.Tours.Fields.SensorEquipTechId);
 }
Пример #9
0
        void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
        {
            this.Id        = source.GetI(MD.MobStationFrequencies.Fields.Id);
            this.StationId = source.GetI(MD.MobStationFrequencies.Fields.StationId);

            this.ChannelTxRef = new ChannelTx
            {
                Channel = source.GetS(MD.MobStationFrequencies.Fields.ChannelTx.Channel).TryToInt(),
                PlanId  = source.GetI(MD.MobStationFrequencies.Fields.ChannelTx.PlanId),
                Freq    = Convert.ToDecimal(source.GetD(MD.MobStationFrequencies.Fields.ChannelTx.Freq))
            };
        }
Пример #10
0
 void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
 {
     this.Id             = source.GetI(MD.NfraApplication.Fields.Id);
     this.DozvDateCancel = source.GetT(MD.NfraApplication.Fields.DozvDateCancel);
     this.DozvDateFrom   = source.GetT(MD.NfraApplication.Fields.DozvDateFrom);
     this.DozvDateTo     = source.GetT(MD.NfraApplication.Fields.DozvDateTo);
     this.ObjId1         = source.GetI(MD.NfraApplication.Fields.ObjId1);
     this.ObjId2         = source.GetI(MD.NfraApplication.Fields.ObjId2);
     this.ObjId3         = source.GetI(MD.NfraApplication.Fields.ObjId3);
     this.ObjId4         = source.GetI(MD.NfraApplication.Fields.ObjId4);
     this.ObjId5         = source.GetI(MD.NfraApplication.Fields.ObjId5);
     this.ObjId6         = source.GetI(MD.NfraApplication.Fields.ObjId6);
     this.ObjTable       = source.GetS(MD.NfraApplication.Fields.ObjTable);
 }
Пример #11
0
        public static RepositoryEntityReader <T> ReadEntities <T>(Action <IMRecordset> conditionHandler)
            where T : class, IRepositoryEntity, IRepositoryReadedEntity, new()
        {
            var entity = new T();

            var entityDbName = entity.GetTableName();
            var idFieldName  = entity.GetIdFieldName();
            var fields       = entity.GetFieldNames();

            var source = new IMRecordset(entityDbName, IMRecordset.Mode.ReadOnly);

            conditionHandler(source);
            source.Select(fields);

            var reader = new RepositoryEntityReader <T>(source);

            return(reader);
        }
Пример #12
0
        public static void CreateEntity <T>(T entity)
            where T : class, IRepositoryEntity, IRepositoryCreatedEntity, new()
        {
            var entityDbName = entity.GetTableName();
            var idFieldName  = entity.GetIdFieldName();
            var fields       = entity.GetFieldNames();

            var source = new IMRecordset(entityDbName, IMRecordset.Mode.ReadWrite);

            source.Select(fields);
            source.SetWhere(idFieldName, IMRecordset.Operation.Eq, -1);

            using (source.OpenWithScope())
            {
                source.AddNew();
                entity.SaveToRecordset(source);
                source.Update();
            }
        }
Пример #13
0
        public static int GetCurrentUserId()
        {
            var    result   = IM.NullI;
            string userName = IM.ConnectedUser();

            var employeeRs = new IMRecordset(Employee.TableName, IMRecordset.Mode.ReadOnly);

            employeeRs.Select(Employee.Fields.Id);
            employeeRs.SetWhere(Employee.Fields.AppUser, IMRecordset.Operation.Eq, userName);

            using (employeeRs.OpenWithScope())
            {
                if (!employeeRs.IsEOF())
                {
                    result = employeeRs.GetI(Employee.Fields.Id);
                }
            }

            return(result);
        }
Пример #14
0
        void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
        {
            this.Id         = source.GetI(MD.Allotments.Fields.Id);
            this.TableName  = source.GetS(MD.Allotments.Fields.TableName);
            this.Status     = source.GetS(MD.Allotments.Fields.Status);
            this.UserType   = source.GetS(MD.Allotments.Fields.UserType);
            this.CustDate1  = source.GetT(MD.Allotments.Fields.CustDate1);
            this.CustDate2  = source.GetT(MD.Allotments.Fields.CustDate2);
            this.CustNum2   = source.GetD(MD.Allotments.Fields.CustNum2);
            this.CustNum3   = source.GetD(MD.Allotments.Fields.CustNum3);
            this.CustText1  = source.GetS(MD.Allotments.Fields.CustText1);
            this.CustText2  = source.GetS(MD.Allotments.Fields.CustText2);
            this.CustText3  = source.GetS(MD.Allotments.Fields.CustText3);
            this.CustText4  = source.GetS(MD.Allotments.Fields.CustText4);
            this.MeasTaskId = source.GetI(MD.Allotments.Fields.MeasTaskId);

            this.PlanRef = new Plan
            {
                Id         = source.GetI(MD.Allotments.Fields.Plan.Id),
                ChannelSep = source.GetD(MD.Allotments.Fields.Plan.ChannelSep),
                Bandwidth  = source.GetD(MD.Allotments.Fields.Plan.Bandwidth)
            };
        }
Пример #15
0
        public static T ReadEntityById <T>(int id)
            where T : class, IRepositoryEntity, IRepositoryReadedEntity, new()
        {
            var entity = new T();

            var entityDbName = entity.GetTableName();
            var idFieldName  = entity.GetIdFieldName();
            var fields       = entity.GetFieldNames();

            var source = new IMRecordset(entityDbName, IMRecordset.Mode.ReadOnly);

            source.Select(fields);
            source.SetWhere(idFieldName, IMRecordset.Operation.Eq, id.ToString());
            using (source.OpenWithScope())
            {
                if (source.IsEOF())
                {
                    throw new InvalidOperationException($"Not found a record of {entityDbName} by Id #{id}");
                }
                entity.LoadFromRecordset(source);
            }

            return(entity);
        }
Пример #16
0
        public static void UpdateEntity <T>(T entity)
            where T : class, IRepositoryEntity, IRepositoryUpdatedEntity, new()
        {
            var entityDbName = entity.GetTableName();
            var idFieldName  = entity.GetIdFieldName();
            var fields       = entity.GetFieldNames();
            var id           = entity.GetId();

            var source = new IMRecordset(entityDbName, IMRecordset.Mode.ReadWrite);

            source.Select(fields);
            source.SetWhere(idFieldName, IMRecordset.Operation.Eq, id.ToString());
            using (source.OpenWithScope())
            {
                if (source.IsEOF())
                {
                    throw new InvalidOperationException($"Not found a record of {entityDbName} by Id #{id}");
                }

                source.Edit();
                entity.SaveToRecordset(source);
                source.Update();
            }
        }
Пример #17
0
        public static T ReadFirstEntity <T>(Action <IMRecordset> conditionHandler)
            where T : class, IRepositoryEntity, IRepositoryReadedEntity, new()
        {
            var entity = new T();

            var entityDbName = entity.GetTableName();
            var fields       = entity.GetFieldNames();

            var source = new IMRecordset(entityDbName, IMRecordset.Mode.ReadOnly);

            source.Select(fields);
            conditionHandler(source);
            using (source.OpenWithScope())
            {
                if (source.IsEOF())
                {
                    return(default(T));
                }

                entity.LoadFromRecordset(source);
            }

            return(entity);
        }
Пример #18
0
 public static OpenedRecordsetScope OpenWithScope(this IMRecordset recordset)
 {
     return(new OpenedRecordsetScope(recordset));
 }
Пример #19
0
 public static OpenedRecordsetScope OpenForAdd(this IMRecordset recordset, params string[] fields)
 {
     recordset.Select(string.Join(",", fields));
     recordset.SetWhere(fields[0], IMRecordset.Operation.Eq, -1);
     return(recordset.OpenWithScope());
 }
Пример #20
0
 public static void PutNextId(this IMRecordset recordset, string tableNmae, string fieldName)
 {
     recordset.Put(fieldName, IM.AllocID(tableNmae, 1, -1));
 }
Пример #21
0
 public static void AddNew(this IMRecordset recordset, string tableNmae, string fieldName)
 {
     recordset.AddNew();
     recordset.PutNextId(tableNmae, fieldName);
 }
Пример #22
0
 public static void Select(this IMRecordset recordset, params string[] fields)
 {
     recordset.Select(string.Join(",", fields));
 }
Пример #23
0
 void IRepositoryUpdatedEntity.SaveToRecordset(IMRecordset source)
 {
     source.Put(MD.Allotments.Fields.Status, this.Status);
     source.Put(MD.Allotments.Fields.MeasTaskId, this.MeasTaskId);
 }
Пример #24
0
 public RepositoryEntityReader(IMRecordset source)
 {
     this._source = source;
     this._scope  = new OpenedRecordsetScope(source);
 }
Пример #25
0
 void IRepositoryUpdatedEntity.SaveToRecordset(IMRecordset source)
 {
     source.Put(MD.Tours.Fields.Status, this.Status);
 }
Пример #26
0
 void IRepositoryReadedEntity.LoadFromRecordset(IMRecordset source)
 {
     this.PlanId = source.GetI(MD.FreqPlanChan.Fields.PlanId);
     this.Freq   = source.GetD(MD.FreqPlanChan.Fields.Freq);
 }