Exemple #1
0
        /// <summary>
        /// 缓存登录信息
        /// </summary>
        public static void CacheUserLoginData(SysUser user)
        {
            HttpContext.Current.Session["SmartSystem_SystemLoginUser"] = user;

            List <BaseVillage> villages = VillageServices.QueryVillageByUserId(user.RecordID);

            HttpContext.Current.Session["SmartSystem_LoginUser_ValidVillage"] = villages;

            HttpContext.Current.Session["SmartSystem_LoginUser_ValidCompany"] = CompanyServices.GetCurrLoginUserRoleCompany(user.CPID, user.RecordID);

            List <SysRoles> sysRoles = SysRolesServies.QuerySysRolesByUserId(user.RecordID);

            if (sysRoles != null)
            {
                HttpContext.Current.Session["SmartSystem_SystemLoginUser_Role"] = sysRoles;
                if (sysRoles.Count > 0)
                {
                    List <SysRoleAuthorize> roleAuthorizes = SysRoleAuthorizeServices.QuerySysRoleAuthorizeByRoleIds(sysRoles.Select(p => p.RecordID).ToList());
                    if (roleAuthorizes != null)
                    {
                        HttpContext.Current.Session["SmartSystem_LoginUser_SysRoleAuthorize"] = roleAuthorizes;
                    }
                }
            }
        }
        public void RemoveCompany()
        {
            var options = new DbContextOptionsBuilder <CompanyRegisterDbContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database")
                          .Options;

            var companyServices = new CompanyServices(new CompanyRegisterDbContext(options));
            var company         = new Company()
            {
                Id         = 1,
                Name       = "Apple",
                PictureUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/160px-Apple_logo_black.svg.png"
            };
            var secondCompany = new Company()
            {
                Id         = 2,
                Name       = "Nike",
                PictureUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/160px-Apple_logo_black.svg.png"
            };

            companyServices.AddToDatabase(company);
            companyServices.AddToDatabase(secondCompany);
            companyServices.RemoveCompany(secondCompany);

            var result = companyServices.GetAllCompanies();

            if (result.Count != 1)
            {
                Assert.Fail();
            }
        }
        public IActionResult Edit(EditCompanyBindingModel bm, int id)
        {
            var company = CompanyServices.GetCompanyById(id);

            if (bm.Name != null)
            {
                var isTaken = CompanyServices.NameIsTaken(bm.Name);
                if (isTaken)
                {
                    ModelState.AddModelError("Name", "This name is already taken");
                    return(this.View(company));
                }

                company.Name = bm.Name;
            }

            if (bm.FoundationDate != null)
            {
                company.FoundationDate = bm.FoundationDate.Value;
            }

            if (bm.PictureUrl != null)
            {
                company.PictureUrl = bm.PictureUrl;
            }

            this.CompanyServices.UpdateCompany(company);
            this.ViewData["edit"] = "You have successfully edited this company!";
            return(this.View(company));
        }
Exemple #4
0
        public JsonResult Delete(string companyId)
        {
            try
            {
                List <BaseCompany> companys = CompanyServices.QueryCompanysByMasterID(companyId);
                if (companys.Count > 0)
                {
                    throw new MyException("请先删除下属单位");
                }

                bool result = CompanyServices.Delete(companyId);
                if (!result)
                {
                    throw new MyException("删除下属单位失败");
                }

                return(Json(MyResult.Success()));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "删除单位失败");
                return(Json(MyResult.Error("删除失败")));
            }
        }
Exemple #5
0
 public JsonResult EditCompany(BaseCompany model)
 {
     try
     {
         bool result = false;
         if (string.IsNullOrWhiteSpace(model.CPID))
         {
             result = CompanyServices.Add(model);
         }
         else
         {
             BaseCompany company = CompanyServices.QueryCompanyByRecordId(model.CPID);
             if (string.IsNullOrWhiteSpace(company.MasterID) && !string.IsNullOrWhiteSpace(model.MasterID))
             {
                 throw new MyException("当前修改单位为顶级单位,不能属于任何单位");
             }
             result = CompanyServices.Update(model);
         }
         if (!result)
         {
             throw new MyException("保存单位信息失败");
         }
         UpdateCompanyCacheData(model);
         return(Json(MyResult.Success()));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "单位管理保存单位信息失败");
         return(Json(MyResult.Error("保存单位信息失败")));
     }
 }
Exemple #6
0
        public string Search_Company()
        {
            String str = Request.Params["str"];
            // List<BaseCompany> companys = CompanyServices.QueryCompanyAndSubordinateCompany(GetCurrentUserCompanyId);
            List <BaseCompany> companys    = CompanyServices.QueryAllCompanyByName(GetCurrentUserCompanyId, str);
            BaseCompany        currCompany = companys.FirstOrDefault(p => p.CPID == GetCurrentUserCompanyId);

            if (currCompany == null)
            {
                return(string.Empty);
            }

            List <BaseCity> citys = CityServices.QueryAllCitys();

            StringBuilder strTree = new StringBuilder();

            strTree.Append("{\"rows\":[{");
            strTree.AppendFormat("\"CPID\":\"{0}\"", currCompany.CPID);
            strTree.AppendFormat(",\"CPName\":\"{0}\"", currCompany.CPName);
            strTree.AppendFormat(",\"Address\":\"{0}\"", currCompany.Address);
            strTree.AppendFormat(",\"LinkMan\":\"{0}\"", currCompany.LinkMan);
            strTree.AppendFormat(",\"Mobile\":\"{0}\"", currCompany.Mobile);
            strTree.AppendFormat(",\"MasterID\":\"{0}\"", currCompany.MasterID);
            strTree.AppendFormat(",\"CityID\":\"{0}\"", currCompany.CityID);
            strTree.AppendFormat(",\"ProvinceID\":\"{0}\"", "0");
            strTree.Append(",\"iconCls\":\"my-company-icon\"}");
            GetSubordinateCompany(companys, citys, currCompany.CPID, strTree);
            strTree.Append("]}");
            return(strTree.ToString());
        }
Exemple #7
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            Company company = new Company();

            company.Name      = companynameUpdateTextBox.Text;
            company.Salary    = salaryUpdateTextBox.Text;
            company.Work_type = workTypeUpdateTextBox.Text;
            company.Vacancy   = vacancyUpdateTextBox.Text;
            company.Id        = Convert.ToInt32(id);

            CompanyServices companyservices = new CompanyServices();

            if (companyservices.Update(company) == 1)
            {
                MessageBox.Show("Successfully Updated");
            }
            else
            {
                MessageBox.Show("Update Failed");
            }

            CompanyUpdate companyupdate = new CompanyUpdate();

            this.Hide();
            companyupdate.Closed += (s, args) => this.Close();
            companyupdate.Show();
        }
Exemple #8
0
 private string GetCompanyId(string pid, string bid, string gid)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(gid))
         {
             ParkGate gate = ParkGateServices.QueryByRecordId(gid);
             if (gate != null)
             {
                 bid = gate.BoxID;
             }
         }
         if (!string.IsNullOrWhiteSpace(pid))
         {
             BaseCompany company = CompanyServices.QueryByParkingId(pid);
             if (company != null)
             {
                 return(company.CPID);
             }
         }
         if (!string.IsNullOrWhiteSpace(bid))
         {
             BaseCompany company = CompanyServices.QueryByBoxID(bid);
             if (company != null)
             {
                 return(company.CPID);
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptionToDbAndTxt("QRCodeParkPayment", "GetCompanyId方法处理异常", ex, LogFrom.WeiXin);
     }
     return(string.Empty);
 }
Exemple #9
0
        public ActionResult EditCompany(int id)
        {
            var company = new Company();

            try
            {
                if (id < 1)
                {
                    company.Error     = "Invalid Selection!";
                    company.ErrorCode = -1;
                    return(Json(company, JsonRequestBehavior.AllowGet));
                }

                var myViewObj = new CompanyServices().GetCompany(id);

                if (myViewObj == null || myViewObj.CompanyId < 1)
                {
                    company.Error     = "Company Information could not be retrieved.";
                    company.ErrorCode = -1;
                    return(Json(company, JsonRequestBehavior.AllowGet));
                }
                Session["_company"] = myViewObj;
                myViewObj.ErrorCode = myViewObj.CompanyId;
                return(Json(myViewObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                company.Error     = "An unknown error was Company Information could not be retrieved.";
                company.ErrorCode = -1;
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(Json(company, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #10
0
        public string GetParkingData(string companyId)
        {
            List <BaseParkinfo> parkings = new List <BaseParkinfo>();
            List <BaseCompany>  companys = CompanyServices.GetCurrLoginUserRoleCompany(companyId, GetLoginUser.RecordID);

            if (companys.Count > 0)
            {
                parkings = ParkingServices.QueryParkingByCompanyIds(companys.Select(p => p.CPID).ToList());
            }

            StringBuilder strTree = new StringBuilder();

            strTree.Append("[");
            strTree.Append("{\"id\":\"-1\",");
            strTree.Append("\"text\":\"所有\",\"selected\":true");
            strTree.Append("}");
            foreach (var item in parkings)
            {
                strTree.Append(",{\"id\":\"" + item.PKID + "\",");
                strTree.Append("\"text\":\"" + item.PKName + "\"");
                strTree.Append("}");
            }
            strTree.Append("]");
            return(strTree.ToString());
        }
        public ViewResult Persons()
        {
            var companyList = new CompanyServices().GetAllOrderedCompanies() ?? new List <Company>();

            if (!companyList.Any())
            {
                ViewBag.Title = "Persons' Information Set Up";
                return(View(Tuple.Create(new List <Company>(), new List <Person>())));
            }

            var personList = new PersonServices().GetAllOrderedPersons() ?? new List <Person>();

            if (!personList.Any())
            {
                ViewBag.Title = "Persons' Information Set Up";
                return(View(Tuple.Create(companyList, new List <Person>())));
            }

            personList.ForEach(m =>
            {
                m.CompanyName = m.Company.Name;
            });

            ViewBag.Title = "Manage Persons' Information";
            return(View(Tuple.Create(companyList, personList)));
        }
        public IActionResult Edit(EditEmployeeBindingModel bm, int id)
        {
            var employee = EmployeeServices.GetEmployeeById(id);

            var expLevels = new[] { "A", "B", "C", "D" };

            if (bm.ExperinceLevel != null && !expLevels.Contains(bm.ExperinceLevel))
            {
                ModelState.AddModelError("ExperinceLevel", "Experince Level must be \"A\", \"B\", \"C\", \"D\"");
                var dtoComp = CompanyServices.GetAllCompanies();
                var dto     = new EditEmployeeDto()
                {
                    Companies = dtoComp,
                    Employee  = employee
                };
                return(this.View(dto));
            }

            EditEmployee(bm, employee);

            this.EmployeeServices.UpdateEmployee(employee);
            var companies = this.CompanyServices.GetAllCompanies();

            employee = EmployeeServices.GetEmployeeById(id);

            var employeeDto = new EditEmployeeDto()
            {
                Employee  = employee,
                Companies = companies
            };

            this.ViewData["edit"] = "You have successfully edited this employee!";

            return(this.View(employeeDto));
        }
Exemple #13
0
        public JsonResult DownloadQRCode(string gateId, int size)
        {
            try
            {
                List <int> dics = new List <int>();
                dics.Add(258);
                dics.Add(344);
                dics.Add(430);
                dics.Add(860);
                dics.Add(1280);

                List <string> imgs = new List <string>();
                ParkGate      gate = ParkGateServices.QueryByRecordId(gateId);
                if (gate == null)
                {
                    throw new MyException("获取通道信息失败");
                }
                BaseCompany company = CompanyServices.QueryByBoxID(gate.BoxID);
                if (company == null)
                {
                    throw new MyException("获取单位信息失败");
                }

                ParkBox box = ParkBoxServices.QueryByRecordId(gate.BoxID);
                if (box == null)
                {
                    throw new MyException("获取岗亭信息失败");
                }

                ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID);
                if (area == null)
                {
                    throw new MyException("获取区域信息失败");
                }

                BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(area.PKID);
                if (parking == null)
                {
                    throw new MyException("获取车场信息失败");
                }
                string content = string.Format("{0}/qrl/scio_ix_pid={1}^io={2}", SystemDefaultConfig.SystemDomain, parking.PKID, gate.GateID);
                foreach (var item in dics)
                {
                    string parkingName = string.Format("{0}_{1}_{2}_{3}_{4}", parking.PKName, area.AreaName, box.BoxName, gate.GateName, item);
                    string result      = QRCodeServices.GenerateQRCode(company.CPID, content, item, parkingName);
                    imgs.Add(item.ToString() + "|" + result);
                }

                return(Json(MyResult.Success("", imgs)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "下载二维码失败");
                return(Json(MyResult.Error("下载二维码失败")));
            }
        }
Exemple #14
0
        private List <Company> GetCompanies(int itemsPerPage, int pageNumber, out int dataCount)
        {
            try
            {
                var companyList = new CompanyServices().GetAllOrderedCompanies(itemsPerPage, pageNumber, out dataCount) ?? new List <Company>();

                if (!companyList.Any())
                {
                    return(new List <Company>());
                }

                ViewBag.DataCount = dataCount.ToString(CultureInfo.InvariantCulture);

                var totalPages = dataCount / itemsPerPage;

                // Counting the last page
                if (dataCount % itemsPerPage != 0)
                {
                    totalPages++;
                }

                ViewBag.TotalPages = totalPages;
                ViewBag.Page       = pageNumber;
                return(companyList);
            }
            catch (Exception ex)
            {
                dataCount = 0;
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(new List <Company>());
            }
        }
Exemple #15
0
        public IActionResult Edit(EditInternBindingModel bm, int id)
        {
            var intern = InternServices.GetInternById(id);

            if (!ModelState.IsValid)
            {
                var comapnies = CompanyServices.GetAllCompanies();

                var internDto = new EditInternDto()
                {
                    Intern    = intern,
                    Companies = comapnies
                };

                return(this.View(internDto));
            }

            EditIntern(bm, intern);

            this.InternServices.UpdateIntern(intern);
            var companies = this.CompanyServices.GetAllCompanies();

            intern = InternServices.GetInternById(id);

            var dto = new EditInternDto()
            {
                Intern    = intern,
                Companies = companies
            };

            this.ViewData["edit"] = "You have successfully edited this intern!";

            return(this.View(dto));
        }
Exemple #16
0
 public CompanyController(CompanyServices compSer, DriverService driverSer, UserManager <BudAkutenUsers> userMan, AdsServices adSer)
 {
     companyServices = compSer;
     userManager     = userMan;
     adService       = adSer;
     driverService   = driverSer;
 }
Exemple #17
0
 private void InitData()
 {
     try
     {
         SystemDefaultConfig.WriteConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
         SystemDefaultConfig.ReadConnectionString  = ConfigurationManager.ConnectionStrings["ReadConnectionString"].ToString();
         SystemDefaultConfig.BWPKID  = ConfigurationManager.AppSettings["BWPKID"] ?? "";
         SystemDefaultConfig.SFMPKID = ConfigurationManager.AppSettings["SFMPKID"] ?? "";
         //Session["SmartSystem_LogFrom"] = LogFrom.UnKnown;
         SystemDefaultConfig.DatabaseProvider = "Sql";
         SystemDefaultConfig.DataUpdateFlag   = 3;
         SystemDefaultConfig.SystemDomain     = ConfigurationManager.AppSettings["SystemDomain"] ?? "";
         SystemDefaultConfig.CreateImageUploadFile();
         SystemDefaultConfig.Secretkey           = ConfigurationManager.AppSettings["Secretkey"] ?? "";
         BackgroundWorkerManager.EnvironmentPath = Server.MapPath("~");
         CompanyServices.InitSystemDefaultCompany();
         string startBackground = ConfigurationManager.AppSettings["BackgroundWorkeStart"] ?? "0";
         if (startBackground == "1")
         {
             BackgroundWorkerManager.Start();
         }
     }
     catch (Exception ex)
     {
         TxtLogServices.WriteTxtLogEx("Application_Start", ex);
     }
 }
 public EmployeesController(
     EmployeeServices employeeServices,
     CompanyServices companyServices,
     IMapper mapper)
 {
     this.EmployeeServices = employeeServices;
     this.CompanyServices  = companyServices;
     this.Mapper           = mapper;
 }
Exemple #19
0
 public InternsController(
     InternServices internServices,
     CompanyServices companyServices,
     IMapper mapper)
 {
     this.InternServices  = internServices;
     this.CompanyServices = companyServices;
     this.Mapper          = mapper;
 }
        public ActionResult Delete(int id)
        {
            try
            {
                InvitationCompanyModel filters = new InvitationCompanyModel()
                {
                    CompanyId = UserCompanyId
                };
                DatatableModel dt = new DatatableModel()
                {
                    iColumns       = 5,
                    iDisplayLength = 10,
                    iDisplayStart  = 0,
                    iSortCol_0     = 3,
                    iSortingCols   = 1,
                    iTotalRecords  = 0,
                    sSearch        = null
                };
                var invitationsC = GetInvitationsCompany(dt, filters);
                if (invitationsC != null && invitationsC.Count() > 0)
                {
                    return(Json(new RequestResult <object>()
                    {
                        Status = Status.Warning, Message = localResource.txt_company_has_invitation
                    }));
                }

                CompanyServices cs = new CompanyServices();
                CompanyModel    cm = new CompanyModel()
                {
                    CompanyId = id,
                };
                if (cs.HasProjectsVesselsCompany(cm))
                {
                    return(Json(new RequestResult <object>()
                    {
                        Status = Status.Warning, Message = localResource.txt_company_has_vp
                    }));
                }

                var result = cs.RemoveCompany(cm, UserPerson);
                UserCompanyId = null;
                if (result.Status != Status.Success)
                {
                    throw new Exception(string.Format("{0}: {1}", localResource.txt_company_error_delete, result.Message));
                }
                return(Json(result));
            }
            catch (Exception ex)
            {
                Response.StatusCode        = (int)HttpStatusCode.BadRequest;
                Response.StatusDescription = ex.Message;

                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
 public CompanyController(CompanyServices companyServices
                          , BasicInfoServices basicInfoServices
                          , ILogger <CompanyController> logger
                          , PresetFunctionServices presetFunctionServices)
     : base(logger)
 {
     _companyServices        = companyServices;
     _basicInfoServices      = basicInfoServices;
     _presetFunctionServices = presetFunctionServices;
 }
Exemple #22
0
        public void RemoveEmployee()
        {
            var options = new DbContextOptionsBuilder <CompanyRegisterDbContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database")
                          .Options;

            var employeeService = new EmployeeServices(new CompanyRegisterDbContext(options));
            var companyServices = new CompanyServices(new CompanyRegisterDbContext(options));

            var company = new Company()
            {
                Id         = 1,
                Name       = "Apple",
                PictureUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/160px-Apple_logo_black.svg.png"
            };

            companyServices.AddToDatabase(company);

            var employee = new Employee()
            {
                Id             = 1,
                CompanyId      = 1,
                ExperinceLevel = "A",
                Name           = "Veselin",
                PictureUrl     =
                    "https://images-eu.ssl-images-amazon.com/images/G/31/img16/imports/AGS/MensFashion_Cat_Clothing._V279132526_.jpg",
                Salary       = 1400,
                VacationDays = 15,
                StartDate    = DateTime.Now
            };

            var secondEmployee = new Employee()
            {
                Id             = 2,
                CompanyId      = 1,
                ExperinceLevel = "A",
                Name           = "Pesho",
                PictureUrl     =
                    "https://images-eu.ssl-images-amazon.com/images/G/31/img16/imports/AGS/MensFashion_Cat_Clothing._V279132526_.jpg",
                Salary       = 1400,
                VacationDays = 15,
                StartDate    = DateTime.Now
            };

            employeeService.AddEmployee(employee);
            employeeService.AddEmployee(secondEmployee);
            employeeService.RemoveEmployee(employee);

            var result = employeeService.GetAllEmployees();

            if (result.Count != 1)
            {
                Assert.Fail();
            }
        }
        public ActionResult Create(CompanyModel data)
        {
            try
            {
                if (HasCompany())
                {
                    return(RedirectToAction("Index"));
                }

                if (ModelState.IsValid)
                {
                    PersonServices PersonServ = new PersonServices();
                    var            userId     = (int)SessionWeb.User.UserId;
                    var            person     = PersonServ.getFirstUserPerson(new UserPersonModel()
                    {
                        UserId = userId
                    }).ToPerson();
                    CompanyServices cs = new CompanyServices();
                    CompanyModel    cm = new CompanyModel()
                    {
                        CompanyName = data.CompanyName,
                        RFC         = data.RFC,
                        Address     = data.Address,
                        PhoneNumber = data.PhoneNumber,
                        Email       = data.Email
                    };
                    var result = cs.AddCompany(cm, person);
                    if (result.Status != Status.Success)
                    {
                        throw new Exception(string.Format("{0}: {1}", localResource.txt_company_error_saved, result.Message));
                    }
                    SessionWeb.User.CompanyId = ((CompanyModel)result.Data).CompanyId;
                    InvitationCompanyServices invServ = new InvitationCompanyServices();
                    foreach (var i in UserPerson.InvitationsCompanies)
                    {
                        i.Status = 2;
                        invServ.InsUpd(i);
                    }
                    return(Json(result));
                }
                return(Json(new RequestResult <object>()
                {
                    Status = Status.Error, Message = localResource.txt_company_error_saved
                }));
            }
            catch (Exception ex)
            {
                Response.StatusCode        = (int)HttpStatusCode.BadRequest;
                Response.StatusDescription = ex.Message;

                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
                //return Json(new RequestResult<object>() { Status = Status.Error, Message = ex.Message });
            }
        }
Exemple #24
0
        private WX_ApiConfig GetApiConfig(string id)
        {
            TxtLogServices.WriteTxtLogEx("RedirectHandle", "获取微信配置信息,id:{0}", id);
            var separator = new[] { '|', '_' };
            var param     = new[] { '^' };//^参数分隔符
            var ids       = id.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            var parameters = ids[2].Split(param, StringSplitOptions.RemoveEmptyEntries);

            if (parameters.Length == 0)
            {
                throw new MyException("获取单位失败");
            }
            foreach (var item in parameters)
            {
                var parame = item.Split(new[] { '=' });
                if (parame.Length == 2)
                {
                    if (parame[0].ToUpper() == "CID")
                    {
                        WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(parame[1]);
                        if (config == null)
                        {
                            throw new MyException("获取微信配置失败");
                        }
                        if (config.CompanyID != parame[1])
                        {
                            throw new MyException("该公众号暂停使用");
                        }
                        return(config);
                    }
                    if (parame[0] == "PARKINGID" || parame[0] == "PID")
                    {
                        BaseCompany company = CompanyServices.QueryByParkingId(parame[1]);
                        if (company == null)
                        {
                            throw new MyException("获取单位信息失败");
                        }

                        WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(company.CPID);
                        if (config == null)
                        {
                            throw new MyException("获取微信配置失败");
                        }
                        if (config.CompanyID != parame[1])
                        {
                            throw new MyException("该公众号暂停使用");
                        }
                        return(config);
                    }
                }
            }
            throw new MyException("获取微信配置失败,id:" + id);
        }
Exemple #25
0
        private List <Company> GetCompanies()
        {
            var companyList = new CompanyServices().GetAllOrderedCompanies() ?? new List <Company>();

            if (!companyList.Any())
            {
                return(new List <Company>());
            }

            return(companyList);
        }
        public IActionResult Delete(int id, string slug)
        {
            var company = CompanyServices.GetCompanyById(id);

            if (company == null || company.Name != slug)
            {
                return(NotFound());
            }

            return(this.View(company));
        }
Exemple #27
0
        private List <Company> GetCompanies()
        {
            var companies = new CompanyServices().GetCompaniesWithBlocks() ?? new List <Company>();

            if (!companies.Any())
            {
                return(new List <Company>());
            }

            return(companies);
        }
        public CompanyViewModel()
        {
            _companyServ      = new CompanyServices();
            _companyAddDialog = new CompanyAddDialog();

            _key           = "";
            _isFocused     = true;
            _currentWindow = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();
            companies      = _companyServ.GetCompanies();
            Load();
        }
        public void Initialize()
        {
            services = new CompanyServices();
            context  = new DataContext();
            List <Company> list = services.FindListCompanies();

            foreach (Company item in list)
            {
                services.DeleteCompany(item.Id);
            }
        }
Exemple #30
0
 public bool Save(CompanyServices entity)
 {
     try
     {
         context.Services.Add(entity);
         context.SaveChanges();
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }