Ejemplo n.º 1
0
        public List <Detail> getAllCompanies()
        {
            DBHelper._Company dbhelp = new DBHelper._Company();

            return(dbhelp.GetAll().Select(s => new Detail()
            {
                Id = s.Id,
                Name = s.Name,
                ShortName = s.ShortName,
                Address = s.Address,
                CompanyWebSite = s.CompanyWebSite,
                ContactName = s.ContactName,
                ContactPhone = s.ContactPhone,
                ContactEmail = s.ContactEmail,
                Latitude = (float)s.Latitude,
                Longitude = (float)s.Longitude,
                LogoURL = s.LogoURL,
                CultureInfoId = s.CultureInfo,
                CultureInfoName = (s.RefCultureInfo == null ? "" : s.RefCultureInfo.Name),
                DocDBConnectionString = s.DocDBConnectionString,
                AllowDomain = s.AllowDomain,
                ExtAppAuthenticationKey = s.ExtAppAuthenticationKey,
                DeletedFlag = s.DeletedFlag
            }).ToList <Detail>());
        }
Ejemplo n.º 2
0
        public List <Detail> getAllCompaniesBySuperAdmin()
        {
            DBHelper._Company dbhelp = new DBHelper._Company();
            var companyList          = dbhelp.GetAll();

            if (companyList == null)
            {
                throw new CDSException(10301);
            }

            return(companyList.Select(s => new Detail()
            {
                Id = s.Id,
                Name = s.Name,
                ShortName = s.ShortName,
                Address = s.Address,
                CompanyWebSite = s.CompanyWebSite,
                ContactName = s.ContactName,
                ContactPhone = s.ContactPhone,
                ContactEmail = s.ContactEmail,
                Latitude = (float)s.Latitude,
                Longitude = (float)s.Longitude,
                LogoURL = s.LogoURL,
                CultureInfoId = s.CultureInfo,
                CultureInfoName = (s.RefCultureInfo == null ? "" : s.RefCultureInfo.Name),
                AllowDomain = s.AllowDomain,
                ExtAppAuthenticationKey = s.ExtAppAuthenticationKey,
                DeletedFlag = s.DeletedFlag,
            }).ToList <Detail>());
        }
Ejemplo n.º 3
0
        public override void Exec()
        {
            RecordStartLog();
            DBHelper._Company   dbhelp_Company   = new DBHelper._Company();
            DBHelper._Factory   dbhelp_Facotry   = new DBHelper._Factory();
            DBHelper._Equipment dbhelp_Equipment = new DBHelper._Equipment();
            DBHelper._UsageLog  dbhelp_UsageLog  = new DBHelper._UsageLog();
            List <UsageLog>     usageLogList     = new List <UsageLog>();

            foreach (var company in dbhelp_Company.GetAll())
            {
                int  companyId       = company.Id;
                int  factoryQty      = 0;
                int  equipmentQty    = 0;
                long deviceMsgQty    = 0;
                long alarmMsgQty     = 0;
                int  DocDbSizeInGB   = 0;
                int  DocDBPercentage = 0;

                try
                {
                    foreach (var factory in dbhelp_Facotry.GetAllByCompanyId(companyId))
                    {
                        factoryQty++;
                        equipmentQty += dbhelp_Equipment.GetAllByFactoryId(factory.Id).Count;
                    }

                    DocumentDBHelper docDBHelpler = new DocumentDBHelper(companyId, company.DocDBConnectionString);
                    docDBHelpler.Init();
                    deviceMsgQty = docDBHelpler.GetCompanyDeviceMsgQty();
                    alarmMsgQty  = docDBHelpler.GetCompanyAlarmMessageQty();

                    DocDbSizeInGB   = Convert.ToInt32(docDBHelpler._SizeQuotaInKB / (1024 * 1024));
                    DocDBPercentage = Convert.ToInt32(docDBHelpler._SizeUsageInKB * 100 / docDBHelpler._SizeQuotaInKB);
                }
                catch (Exception ex)
                {
                    StringBuilder logMessage = new StringBuilder();
                    logMessage.AppendLine("Routine TaskActor : " + _TaskName);
                    logMessage.AppendLine("\tCompayId " + companyId + " is failed");
                    logMessage.AppendLine("\tException: " + ex.Message);
                    if (ex.InnerException != null)
                    {
                        logMessage.AppendLine("\tInnerException: " + ex.InnerException.Message);
                    }
                    _sfAppLogger.Error(logMessage);
                }

                usageLogList.Add(new UsageLog()
                {
                    CompanyId       = companyId,
                    FactoryQty      = factoryQty,
                    EquipmentQty    = equipmentQty,
                    DeviceMessage   = deviceMsgQty,
                    AlarmMessage    = alarmMsgQty,
                    DocSizeInGB     = DocDbSizeInGB,
                    DocDBPercentage = DocDBPercentage,
                    UpdatedAt       = DateTime.Now
                });
            }
            try
            {
                dbhelp_UsageLog.Add(usageLogList);
            }
            catch (Exception ex)
            {
                StringBuilder logMessage = new StringBuilder();
                logMessage.AppendLine("Routine TaskActor : " + _TaskName);
                logMessage.AppendLine("\tException: " + ex.Message);
                logMessage.AppendLine("\tInnerException: " + ex.InnerException.Message);
                _sfAppLogger.Error(logMessage);
            }

            RecordEndLog();
        }