Ejemplo n.º 1
0
        public void updateCompany(int id, Update company)
        {
            DBHelper._Company dbhelp          = new DBHelper._Company();
            Company           existingCompany = dbhelp.GetByid(id);

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

            existingCompany.Name                    = company.Name;
            existingCompany.ShortName               = company.ShortName;
            existingCompany.Address                 = company.Address;
            existingCompany.CompanyWebSite          = company.CompanyWebSite;
            existingCompany.ContactName             = company.ContactName;
            existingCompany.ContactEmail            = company.ContactEmail;
            existingCompany.ContactPhone            = company.ContactPhone;
            existingCompany.Latitude                = company.Latitude;
            existingCompany.Longitude               = company.Longitude;
            existingCompany.CultureInfo             = company.CultureInfoId;
            existingCompany.AllowDomain             = company.AllowDomain;
            existingCompany.ExtAppAuthenticationKey = company.ExtAppAuthenticationKey;
            if (company.DeletedFlag.HasValue)
            {
                existingCompany.DeletedFlag = (bool)company.DeletedFlag;
            }

            dbhelp.Update(existingCompany);
        }
Ejemplo n.º 2
0
        public Detail getCompanyById(int id)
        {
            DBHelper._Company dbhelp  = new DBHelper._Company();
            Company           company = dbhelp.GetByid(id);

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

            return(new Detail()
            {
                Id = company.Id,
                Name = company.Name,
                ShortName = company.ShortName,
                Address = company.Address,
                CompanyWebSite = company.CompanyWebSite,
                ContactName = company.ContactName,
                ContactPhone = company.ContactPhone,
                ContactEmail = company.ContactEmail,
                Latitude = (float)company.Latitude,
                Longitude = (float)company.Longitude,
                LogoURL = company.LogoURL,
                CultureInfoId = company.CultureInfo,
                CultureInfoName = (company.RefCultureInfo == null ? "" : company.RefCultureInfo.Name),
                AllowDomain = company.AllowDomain,
                ExtAppAuthenticationKey = company.ExtAppAuthenticationKey,
                DeletedFlag = company.DeletedFlag
            });
        }
Ejemplo n.º 3
0
        public Detail_readonly getCompanyByIdReadonly(int id)
        {
            DBHelper._Company dbhelp  = new DBHelper._Company();
            Company           company = dbhelp.GetByid(id);

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

            return(new Detail_readonly()
            {
                Name = company.Name,
                ShortName = company.ShortName,
                Address = company.Address,
                CompanyWebSite = company.CompanyWebSite,
                ContactName = company.ContactName,
                ContactPhone = company.ContactPhone,
                ContactEmail = company.ContactEmail,
                Latitude = (float)company.Latitude,
                Longitude = (float)company.Longitude,
                LogoURL = company.LogoURL,
                CultureInfoName = (company.RefCultureInfo == null ? "" : company.RefCultureInfo.Name)
            });
        }
Ejemplo n.º 4
0
        public void deleteCompany(int id)
        {
            DBHelper._Company dbhelp          = new DBHelper._Company();
            Company           existingCompany = dbhelp.GetByid(id);

            dbhelp.Delete(existingCompany);
        }
Ejemplo n.º 5
0
        public List <Detail> GetAllOperationTaskByCompanyId(int companyId)
        {
            DBHelper._OperationTask dbhelp                     = new DBHelper._OperationTask();
            DBHelper._Company       dbhelp_company             = new DBHelper._Company();
            List <OperationTask>    operationTaskList          = new List <OperationTask>();
            List <Detail>           returnOperationtTaskDetail = new List <Detail>();

            DateTime invaildDatetime = new DateTime(1, 1, 1);

            operationTaskList = dbhelp.GetAllByCompanyId(companyId);

            foreach (OperationTask operationTask in operationTaskList)
            {
                Company company = dbhelp_company.GetByid((int)operationTask.CompanyId);

                returnOperationtTaskDetail.Add(new Detail()
                {
                    Id           = operationTask.Id,
                    Name         = operationTask.Name,
                    TaskStatus   = operationTask.TaskStatus,
                    CompanyId    = (int)operationTask.CompanyId,
                    CompanyName  = company == null ? "" : company.Name,
                    CompletedAt  = operationTask.CompletedAt,
                    RetryCounter = (operationTask.RetryCounter == null) ? "" : operationTask.RetryCounter.ToString(),
                    Entity       = operationTask.Entity,
                    EntityId     = operationTask.EntityId,
                    TaskContent  = (operationTask.TaskContent == null) ? null : JObject.Parse(operationTask.TaskContent),
                    TaskLog      = operationTask.TaskLog
                });
            }
            return(returnOperationtTaskDetail);
        }
Ejemplo n.º 6
0
        public void updateCompanyLogoURL(int id, string url)
        {
            DBHelper._Company dbhelp          = new DBHelper._Company();
            Company           existingCompany = dbhelp.GetByid(id);

            existingCompany.LogoURL = url;
            dbhelp.Update(existingCompany);
        }
Ejemplo n.º 7
0
        public void deleteCompany(int id)
        {
            DBHelper._Company dbhelp          = new DBHelper._Company();
            Company           existingCompany = dbhelp.GetByid(id);

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

            dbhelp.Delete(existingCompany);
        }
Ejemplo n.º 8
0
        public void updateCompanyLogoURL(int id, string url)
        {
            DBHelper._Company dbhelp          = new DBHelper._Company();
            Company           existingCompany = dbhelp.GetByid(id);

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

            existingCompany.LogoURL = url;
            dbhelp.Update(existingCompany);
        }
Ejemplo n.º 9
0
        public Detail getOperationTaskById(int id)
        {
            DBHelper._OperationTask dbhelp         = new DBHelper._OperationTask();
            DBHelper._Company       dbhelp_company = new DBHelper._Company();
            OperationTask           operationTask  = dbhelp.GetByid(id);
            Company company = dbhelp_company.GetByid((int)operationTask.CompanyId);

            return(new Detail()
            {
                Id = operationTask.Id,
                Name = operationTask.Name,
                TaskStatus = operationTask.TaskStatus,
                CompanyId = (int)operationTask.CompanyId,
                CompanyName = company == null ? "" : company.Name,
                CompletedAt = operationTask.CompletedAt,
                RetryCounter = (operationTask.RetryCounter == null) ? "" : operationTask.RetryCounter.ToString(),
                Entity = operationTask.Entity,
                EntityId = operationTask.EntityId,
                TaskContent = (operationTask.TaskContent == null) ? null : JObject.Parse(operationTask.TaskContent),
                TaskLog = operationTask.TaskLog
            });
        }
Ejemplo n.º 10
0
        public List <Detail> searchInPastSevenDaysOperations(SearchCondition condition, int companyId = 0)
        {
            int    hours;
            string taskStatus;

            if (condition == null)
            {
                hours      = -168;
                taskStatus = null;
            }
            else
            {
                hours      = (condition.hours == 0 || condition.hours > 168) ? -168 : -(condition.hours);
                taskStatus = condition.taskStatus;
            }

            DBHelper._OperationTask dbhelp                     = new DBHelper._OperationTask();
            DBHelper._Company       dbhelp_company             = new DBHelper._Company();
            List <OperationTask>    operationTaskList          = new List <OperationTask>();
            List <Detail>           returnOperationtTaskDetail = new List <Detail>();

            if (companyId > 0)
            {
                operationTaskList = dbhelp.Search(taskStatus, hours, companyId);
                Company company = dbhelp_company.GetByid(companyId);

                foreach (OperationTask operationTask in operationTaskList)
                {
                    try
                    {
                        returnOperationtTaskDetail.Add(new Detail()
                        {
                            Id           = operationTask.Id,
                            Name         = operationTask.Name,
                            TaskStatus   = operationTask.TaskStatus,
                            CompanyId    = (int)operationTask.CompanyId,
                            CompanyName  = company == null ? "" : company.Name,
                            CompletedAt  = operationTask.CompletedAt,
                            RetryCounter = (operationTask.RetryCounter == null) ? "" : operationTask.RetryCounter.ToString(),
                            Entity       = operationTask.Entity,
                            EntityId     = operationTask.EntityId,
                            TaskContent  = (operationTask.TaskContent == null) ? null : JObject.Parse(operationTask.TaskContent),
                            TaskLog      = operationTask.TaskLog
                        });
                    }
                    catch { }
                }
            }
            else
            {
                operationTaskList = dbhelp.Search(taskStatus, hours);

                List <int>       companyIdList = operationTaskList.Select(s => (int)s.CompanyId).Distinct().ToList <int>();
                CDStudioEntities dbEntity      = new CDStudioEntities();
                var L2Enty = from c in dbEntity.Company
                             where companyIdList.Contains(c.Id)
                             select new { Id = c.Id, Name = c.Name };
                Dictionary <int, string> companyTable = new Dictionary <int, string>();
                foreach (var company in L2Enty)
                {
                    companyTable.Add(company.Id, company.Name);
                }

                foreach (OperationTask operationTask in operationTaskList)
                {
                    try
                    {
                        returnOperationtTaskDetail.Add(new Detail()
                        {
                            Id           = operationTask.Id,
                            Name         = operationTask.Name,
                            TaskStatus   = operationTask.TaskStatus,
                            CompanyId    = (int)operationTask.CompanyId,
                            CompanyName  = companyTable.ContainsKey((int)operationTask.CompanyId) ? companyTable[(int)operationTask.CompanyId] : "",
                            CompletedAt  = operationTask.CompletedAt,
                            RetryCounter = (operationTask.RetryCounter == null) ? "" : operationTask.RetryCounter.ToString(),
                            Entity       = operationTask.Entity,
                            EntityId     = operationTask.EntityId,
                            TaskContent  = (operationTask.TaskContent == null) ? null : JObject.Parse(operationTask.TaskContent),
                            TaskLog      = operationTask.TaskLog
                        });
                    }
                    catch { }
                }
            }

            return(returnOperationtTaskDetail);
        }