コード例 #1
0
        public void updateUnits()
        {
            using (var context = new CompanyDbContext())
            {
                Console.WriteLine("Update Business Units:");
                Console.Write("Enter UnitName:");
                string name = Console.ReadLine();

                try
                {
                    var b = context.BusinessUnits.Single(t => t.UnitName == name);
                    unit.BusinessUnitId = b.BusinessUnitId;
                    unit.UnitName       = b.UnitName;
                    unit.CompanyId      = b.CompanyId;
                    Console.Write("Enter NumberOfProjects:");
                    unit.NumberOfProjects = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter NumberOfEmployees:");
                    unit.NumberOfEmployees = Convert.ToInt32(Console.ReadLine());
                    BusinessUnits.Update(unit);
                    SaveChanges();
                }
                catch
                {
                    Console.WriteLine("BusinessUnit Doen't exist");
                    throw new ArgumentException("BusinessUnit Doen't exist");
                }
            }
        }
コード例 #2
0
        public IRestResponse GetBusinessUnits(out List <BusinessUnit> businessUnits)
        {
            Log.Info($"Querying Business Units for AccountID '{options.ForgeBimAccountId}'");
            businessUnits = new List <BusinessUnit>();
            try
            {
                var request = new RestRequest(Method.GET);
                //request.Resource = "hq/v1/accounts/{AccountId}/business_units_structure";
                request.Resource = Urls["businessUnitsStructure"];
                request.AddParameter("AccountId", options.ForgeBimAccountId, ParameterType.UrlSegment);
                request.AddHeader("authorization", $"Bearer {Token}");

                IRestResponse response = ExecuteRequest(request);
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    JsonSerializerSettings settings = new JsonSerializerSettings();
                    settings.NullValueHandling = NullValueHandling.Ignore;
                    BusinessUnits units = JsonConvert.DeserializeObject <BusinessUnits>(response.Content, settings);
                    if (units != null && units.business_units != null)
                    {
                        businessUnits.AddRange(units.business_units);
                    }
                }
                return(response);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw ex;
            }
        }
        void IBusinessUnitService.FindAllTask(Action <BusinessUnits> resultCallback, Action <Exception> exceptionCallBack)
        {
            Task <ResultSet <BusinessUnits> > task =
                Task.Factory.StartNew(() =>
            {
                try
                {
                    BusinessUnits businessUnits = FindAll();
                    return(new ResultSet <BusinessUnits>(businessUnits, null));
                }
                catch (Exception ex)
                {
                    return(new ResultSet <BusinessUnits>(null, ex));
                }
            });

            task.ContinueWith(r =>
            {
                if (r.Result.Exception != null)
                {
                    //An error occured
                    exceptionCallBack(r.Result.Exception);
                }
                else
                {
                    //Return the results
                    resultCallback(r.Result.Data);
                }
            }, CancellationToken.None, TaskContinuationOptions.None,
                              TaskScheduler.FromCurrentSynchronizationContext());
        }
コード例 #4
0
        public async Task <ActionResult <BusinessUnits> > PostBusinessUnits(BusinessUnits businessUnits)
        {
            _context.BusinessUnits.Add(businessUnits);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBusinessUnits", new { id = businessUnits.Id }, businessUnits));
        }
コード例 #5
0
        public async Task <IActionResult> PutBusinessUnits(long id, BusinessUnits businessUnits)
        {
            if (id != businessUnits.Id)
            {
                return(BadRequest());
            }

            _context.Entry(businessUnits).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessUnitsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #6
0
        public string InsertBusinessUnits(BusinessUnits businessUnits)
        {
            string            result;
            OracleDataAdapter obj_ORCL = new OracleDataAdapter("CROL_DML_BussUnit_ST", this.GetConnection().ConnectionString);

            obj_ORCL.SelectCommand.CommandType = CommandType.StoredProcedure;
            obj_ORCL.SelectCommand.BindByName  = true;
            obj_ORCL.SelectCommand.Parameters.Add("p_busunit", businessUnits.busUnit);
            obj_ORCL.SelectCommand.Parameters.Add("p_butitle", businessUnits.busTitle);
            obj_ORCL.SelectCommand.Parameters.Add("p_buname", businessUnits.busName);
            obj_ORCL.SelectCommand.Parameters.Add("p_user_cd", businessUnits.user_Cd);
            //obj_ORCL.SelectCommand.Parameters.Add("p_insdate", "");
            obj_ORCL.SelectCommand.Parameters.Add("p_rowid", "");
            obj_ORCL.SelectCommand.Parameters.Add("p_upduser_cd", "");
            obj_ORCL.SelectCommand.Parameters.Add("p_action", "I");
            obj_ORCL.SelectCommand.Parameters.Add("p_dataset", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            DataTable ins_Dt = new DataTable();

            try
            {
                obj_ORCL.Fill(ins_Dt);
                result = Newtonsoft.Json.JsonConvert.SerializeObject(ins_Dt);
            }
            catch (Exception ex)
            {
                result = Newtonsoft.Json.JsonConvert.SerializeObject(ex.Message);
            }
            finally
            {
                obj_ORCL.Dispose();
                ins_Dt.Dispose();
            }

            return(result);
        }
コード例 #7
0
        public virtual string GetNextNumber(DateTime date, int leadDocumentId, IOfficialDocument document, string leadingDocumentNumber,
                                            int departmentId, int businessUnitId, string caseFileIndex, string docKindCode, string indexLeadingSymbol)
        {
            var index = Functions.DocumentRegister.GetNextIndex(_obj, date, leadDocumentId, departmentId, businessUnitId, document).ToString();

            var departmentCode = string.Empty;

            if (departmentId != 0)
            {
                var department = Departments.Get(departmentId);
                if (department != null)
                {
                    departmentCode = department.Code ?? string.Empty;
                }
            }

            var businessUnitCode = string.Empty;

            if (businessUnitId != 0)
            {
                var businessUnit = BusinessUnits.Get(businessUnitId);
                if (businessUnit != null)
                {
                    businessUnitCode = businessUnit.Code ?? string.Empty;
                }
            }

            var counterpartyCode = Functions.OfficialDocument.GetCounterpartyCode(document);

            var number = Functions.DocumentRegister.GenerateRegistrationNumber(_obj, date, index, leadingDocumentNumber,
                                                                               departmentCode, businessUnitCode, caseFileIndex, docKindCode, counterpartyCode, indexLeadingSymbol);

            return(number);
        }
コード例 #8
0
 public static List <Audit> GetAuditsByType(List <ActionType> actionTypes, BusinessUnits businessUnit)
 {
     using (var ctx = new EvolutionRepository.Models.EvolutionDBContext())
     {
         ctx.Configuration.ProxyCreationEnabled = false;
         return(ctx.Audits.ToList());
     }
 }
コード例 #9
0
        public List <IBusinessUnit> GetDuplicateBusinessUnit()
        {
            var duplicateBusinessUnits = new List <IBusinessUnit>();

            if (!string.IsNullOrWhiteSpace(_obj.TIN))
            {
                duplicateBusinessUnits = BusinessUnits.GetAll(b => !Equals(b, _obj) && b.Status == CoreEntities.DatabookEntry.Status.Active &&
                                                              _obj.TIN == b.TIN && _obj.TRRC == b.TRRC).ToList();
            }
            return(duplicateBusinessUnits);
        }
コード例 #10
0
        public ActionResult deleteUnit(int id)
        {
            BusinessUnits unit     = BusinessRepo.GetBusinessUnitById(id);
            var           unitName = unit.unitname;

            if (unit == null)
            {
                return(HttpNotFound());
            }
            TempData["unitName"] = string.Format($"{unitName} has been deleted");
            BusinessRepo.RemoveBusinessunit(id);
            return(RedirectToAction("AllBusinessUnits"));
        }
コード例 #11
0
        public ActionResult GetBusinessById([FromBody] BusinessUnits busUnits)
        {
            var result = businessUnits.GetBusinessUnitById(busUnits);

            if (result == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(result));
            }
        }
コード例 #12
0
        public ActionResult UpdateBusinessUnits([FromBody] BusinessUnits busUnits)
        {
            var result = businessUnits.UpdateBusinessUnits(busUnits);

            if (result == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(result));
            }
        }
コード例 #13
0
 public ActionResult EditUnit(BusinessUnits units)
 {
     if (ModelState.IsValid)
     {
         TempData["Success"] = string.Format($"{units.unitname} has been modified");
         BusinessRepo.UpdateBusinessunit(units);
         return(RedirectToAction("AllBusinessUnits"));
     }
     else
     {
         TempData["Error"] = "Something went wrong. please make sure you fill all the appropriate details";
         return(View(units));
     }
 }
コード例 #14
0
        public void AddBusinessUnit()
        {
            using (var businessapp = new CompanyBusinessAppDbContext())
            {
                Console.WriteLine("Enter Business Unit Name");
                string BusinessUnitName = Console.ReadLine();

                var businessunit = new BusinessUnits
                {
                    BusinessUnitName = BusinessUnitName
                };
                businessapp.BusinessUnits.Add(businessunit);
                businessapp.SaveChanges();
                Console.WriteLine("Successfully Added");
            }
        }
コード例 #15
0
 public void addUnits()
 {
     using (var context = new CompanyDbContext())
     {
         Console.WriteLine("Add Business Units:");
         Console.Write("Enter UnitName:");
         unit.UnitName = Console.ReadLine();
         Console.Write("Enter CompanyId");
         unit.CompanyId = Convert.ToInt32(Console.ReadLine());
         Console.Write("Enter NumberOfProjects:");
         unit.NumberOfProjects = Convert.ToInt32(Console.ReadLine());
         Console.Write("Enter NumberOfEmployees:");
         unit.NumberOfEmployees = Convert.ToInt32(Console.ReadLine());
         BusinessUnits.Add(unit);
         SaveChanges();
     }
 }
コード例 #16
0
        private static string GetBusinessUnitId(object bu)
        {
            ///TODO: this catches the first ID always, although the same name can be used multiple times in the structure
            /// need to find a delimier character "/" and "\" can be part of BU names...
            string buName = Convert.ToString(bu);
            string result = null;

            if (bu != null && BusinessUnits != null && BusinessUnits.Count > 0)
            {
                BusinessUnit unit = BusinessUnits.FirstOrDefault(b => b.name.Equals(buName, StringComparison.InvariantCultureIgnoreCase));
                if (unit != null)
                {
                    result = unit.id;
                }
            }
            return(result);
        }
コード例 #17
0
        protected void Initialise()
        {
            string groupID = settings.VariableKey1;

            TalentAccessDetailList = new List <TalentDataAccess>();
            try
            {
                TalentAccessDetailList = objAudit.GetCommandsByGroupId(int.Parse(groupID));
                DESQLParameter currBusinessUnit = null;
                foreach (TalentDataAccess sqlAccess in TalentAccessDetailList)
                {
                    currBusinessUnit = sqlAccess.CommandElements.CommandParameter.Find(x => x.ParamName.Contains(BUSINESS_UNIT));
                    if (!(currBusinessUnit == null))
                    {
                        HasBusinessUnit = true;
                    }
                }
                if (HasBusinessUnit)
                {
                    string[] items = TalentSystemDefaults.Utilities.GetBusinessUnits(settings);
                    foreach (string item in items)
                    {
                        bool selected = string.Compare(currBusinessUnit.ParamValue.ToString(), item, true) == 0;
                        BusinessUnits.Add(new SelectListItem {
                            Text = item, Value = item, Selected = selected
                        });
                    }
                }
                ConnectionStrings.Add(new SelectListItem {
                    Text = "TALENTEBUSINESS", Value = "SQL2005", Selected = true
                });
                ConnectionStrings.Add(new SelectListItem {
                    Text = "TALENT CONFIGURATION", Value = "TALENT_CONFIG", Selected = false
                });
                if (!string.IsNullOrEmpty(settings.SearchText))
                {
                    BackURL += "&searchText={1}";
                }
                BackURL        = string.Format(BackURL, settings.Module_Name, settings.SearchText);
                AuditGroupInfo = objAudit.RetrieveAuditGroupInfo(int.Parse(groupID));
            }
            catch (Exception)
            {
            }
        }
コード例 #18
0
        private void GivenReportingUnits()
        {
            var brazil      = new Countries(this.session).CountryByIsoCode["br"];
            var southAfrica = new Countries(this.session).CountryByIsoCode["sa"];

            var gwg = new BusinessUnits(this.session).GWG;
            var git = new BusinessUnits(this.session).GIT;

            this.Guarulhos =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(31)
                .WithAbbreviation("GRU")
                .WithName("Guarulhos")
                .WithCountry(brazil)
                .WithBusinessUnit(gwg)
                .WithPerson(this.Person1)
                .Build();
            this.JohannesburgIT =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(64)
                .WithAbbreviation("JOH")
                .WithName("Johannesburg -IT")
                .WithCountry(southAfrica)
                .WithBusinessUnit(git)
                .WithPerson(this.Person1)
                .Build();

            //Child reporting units.
            this.GuarulhosPassCar =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(54)
                .WithAbbreviation("GRP")
                .WithName("Guarulhos Pass Car")
                .WithCountry(brazil)
                .WithParent(this.Guarulhos)
                .WithBusinessUnit(gwg)
                .WithPerson(this.Person1)
                .Build();
            this.GuarulhosTruck =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(55)
                .WithAbbreviation("GRT")
                .WithName("Guarulhos Truck")
                .WithCountry(brazil)
                .WithParent(this.Guarulhos)
                .WithBusinessUnit(gwg)
                .WithPerson(this.Person1)
                .Build();
        }
コード例 #19
0
 /// <summary>
 /// This will bind business units to dropdown
 /// </summary>
 private void BindBusinessUnit()
 {
     try
     {
         if (BusinessUnits != null && BusinessUnits.Count > 0)
         {
             ddlBusinessUnits.DataSource     = BusinessUnits;
             ddlBusinessUnits.DataValueField = "BusinessUnitNumber";
             ddlBusinessUnits.DataTextField  = "BusinessUnitName";
             ddlBusinessUnits.DataBind();
             Cart.SetValue("BusinessUnitIDForDistributor", BusinessUnits.FirstOrDefault().BusinessUnitNumber);
             Cart.Update();
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("Kadena_CMSWebParts_Kadena_Cart_FailedOrdersCart", "BindBusinessUnit", ex.Message);
     }
 }
コード例 #20
0
    public static string StringBusinessUnits(BusinessUnits BU)
    {
        switch (BU)
        {
        case BusinessUnits.NEW_EQUIPMENT: return("NEW EQUIPMENT");

        case BusinessUnits.USED_EQUIPMENT: return("USED EQUIPMENT");

        case BusinessUnits.RENTAL_EQUIPMENT: return("RENTAL EQUIPMENT");

        case BusinessUnits.PARTS: return("PARTS");

        case BusinessUnits.SERVICE: return("SERVICE");

        case BusinessUnits.OPERATOR_TRAINING: return("OPERATOR TRAINING");

        default: return(String.Empty);
        }
    }
コード例 #21
0
        public ActionResult addBusinessUnits(BusinessUnits units)
        {
            BusinessUnits unit = units;

            if (ModelState.IsValid)
            {
                unit.unithead     = "";
                unit.createdby    = null;
                unit.createddate  = DateTime.Now;
                unit.modifiedby   = null;
                unit.modifieddate = DateTime.Now;
                unit.isactive     = true;
                BusinessRepo.addbusinessunit(unit);
                TempData["Success"] = string.Format($"{unit.unitname} has been created");
                return(RedirectToAction("AllBusinessUnits"));
            }
            else
            {
                TempData["Error"] = "Something went wrong. please make sure you fill all the appropriate details";
                return(View());
            }
        }
コード例 #22
0
 /// <summary>
 /// This will bind business units to dropdown
 /// </summary>
 private void BindBusinessUnit()
 {
     try
     {
         var cartBusinessUnit = DIContainer.Resolve<IShoppingCartProvider>();
         if (BusinessUnits != null && BusinessUnits.Count > 0)
         {
             ddlBusinessUnits.DataSource = BusinessUnits;
             ddlBusinessUnits.DataValueField = "BusinessUnitNumber";
             ddlBusinessUnits.DataTextField = "BusinessUnitName";
             ddlBusinessUnits.DataBind();
             if (string.IsNullOrEmpty(Cart.GetStringValue("BusinessUnitIDForDistributor", null)))
             {
                 cartBusinessUnit.UpdateBusinessUnit(Cart, BusinessUnits.FirstOrDefault().BusinessUnitNumber);
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("Kadena_CMSWebParts_Kadena_Cart_DistributorCartDetails", "BindBusinessUnit", ex.Message);
     }
 }
コード例 #23
0
        public static List <IBusinessUnit> GetBusinessUnits(string tin, string trrc)
        {
            var searchByTin  = !string.IsNullOrWhiteSpace(tin);
            var searchByTrrc = !string.IsNullOrWhiteSpace(trrc);

            if (!searchByTin && !searchByTrrc)
            {
                return(new List <IBusinessUnit>());
            }

            // Отфильтровать закрытые НОР.
            var businessUnits = BusinessUnits.GetAll().Where(x => x.Status != Sungero.CoreEntities.DatabookEntry.Status.Closed);

            // Поиск по ИНН, если ИНН передан.
            if (searchByTin)
            {
                var strongTinBusinessUnits = businessUnits.Where(x => x.TIN == tin).ToList();

                // Поиск по КПП, если КПП передан.
                if (searchByTrrc)
                {
                    var strongTrrcBusinessUnits = strongTinBusinessUnits
                                                  .Where(c => !string.IsNullOrWhiteSpace(c.TRRC) && c.TRRC == trrc)
                                                  .ToList();

                    if (strongTrrcBusinessUnits.Count > 0)
                    {
                        return(strongTrrcBusinessUnits);
                    }

                    return(strongTinBusinessUnits.Where(c => string.IsNullOrWhiteSpace(c.TRRC)).ToList());
                }
                return(strongTinBusinessUnits);
            }
            return(new List <IBusinessUnit>());
        }
        public BusinessUnits FindAll(int userId)
        {
            BusinessUnits businessUnits = new BusinessUnits();

                businessUnits.Add(new BusinessUnit
                    {
                        BuId =
                            {
                                DataValue = 1

                            },
                        BuName =
                            {
                                DataValue = "Design Business Name"
                            },
                        BuEmailAddress =
                            {
                                DataValue = "*****@*****.**"

                            },
                        BuContactNum1 =
                            {
                                DataValue = "18764431234"
                            },
                        BuContactNum2 =
                            {
                                DataValue = "18764431234"
                            },
                        BuContactNum3 =
                            {
                                DataValue = "18764431234"

                            },
                        BuAddress1 =
                            {
                                DataValue = "13 Design Address Street"
                            },
                        BuAddress2 =
                            {
                                DataValue = "Design Town"
                            },
                        BuAddress3 =
                            {
                                DataValue = ""
                            },
                        BuParish =
                            {
                                DataValue = "Design Parish"
                            },
                        BuCountry =
                            {
                                DataValue = "JamRock"
                            },
                        CreatedAt =
                            {
                                DataValue = DateTime.Now
                            },
                        CreatedBy =
                            {
                                DataValue = 1

                            },
                        UpdatedAt =
                            {
                                DataValue = DateTime.Now
                            },
                        UpdatedBy =
                            {
                                DataValue = 1
                            }
                    });

            return businessUnits;
        }
コード例 #25
0
        /// <summary>
        /// Синхронизировать руководителя в роль "Руководители наших организаций".
        /// </summary>
        public virtual void SynchronizeCEOInRole()
        {
            var originalCEO = _obj.State.Properties.CEO.OriginalValue;
            var ceo         = _obj.CEO;

            // Добавить руководителя в роль "Руководители наших организаций".
            var ceoRole = Functions.Module.GetCEORole();

            if (ceoRole == null)
            {
                return;
            }

            if (ceo != null && ceo.IncludedIn(ceoRole) && Equals(originalCEO, ceo) &&
                _obj.State.Properties.Status.OriginalValue == _obj.Status)
            {
                return;
            }

            var ceoRoleRecipients = ceoRole.RecipientLinks;

            if (_obj.Status != CoreEntities.DatabookEntry.Status.Closed && ceo != null && !ceo.IncludedIn(ceoRole))
            {
                ceoRoleRecipients.AddNew().Member = ceo;
            }

            // Удалить руководителя из роли "Руководители наших организаций"
            // при смене или закрытии, если он не руководитель других действующих организаций.
            if (_obj.Status == CoreEntities.DatabookEntry.Status.Closed ||
                (originalCEO != null && !Equals(originalCEO, ceo) &&
                 !BusinessUnits.GetAll(c => c.Status == CoreEntities.DatabookEntry.Status.Active &&
                                       Equals(originalCEO, c.CEO) &&
                                       c.Id != _obj.Id).Any()))
            {
                while (ceoRoleRecipients.Any(r => Equals(r.Member, originalCEO)))
                {
                    ceoRoleRecipients.Remove(ceoRoleRecipients.First(r => Equals(r.Member, originalCEO)));
                }
            }

            // Исключить из роли "Руководители подразделений" нового руководителя НОР, либо
            // включить в роль "Руководители подразделений" при смене или закрытии, если он остался руководителем подразделения.
            var managerRole = Roles.GetAll(r => r.Sid == Constants.Module.DepartmentManagersRole).SingleOrDefault();

            if (managerRole != null)
            {
                var managerRoleRecipients = managerRole.RecipientLinks;
                // Исключить из роли "Руководители подразделений".
                if (_obj.Status != CoreEntities.DatabookEntry.Status.Closed && ceo != null && ceo.IncludedIn(managerRole))
                {
                    while (managerRoleRecipients.Any(r => Equals(r.Member, ceo)))
                    {
                        managerRoleRecipients.Remove(managerRoleRecipients.First(r => Equals(r.Member, ceo)));
                    }
                }

                if (originalCEO == null)
                {
                    return;
                }
                if (_obj.Status == CoreEntities.DatabookEntry.Status.Closed ||
                    (Departments.GetAll().Any(d => Equals(d.Manager, originalCEO)) &&
                     !BusinessUnits.GetAll(c => c.Status == CoreEntities.DatabookEntry.Status.Active &&
                                           Equals(originalCEO, c.CEO) &&
                                           c.Id != _obj.Id).Any()))
                {
                    // Включить в роль руководителя подразделений.
                    managerRoleRecipients.AddNew().Member = originalCEO;
                }
            }
        }
コード例 #26
0
        public ActionResult unitDetail(int id)
        {
            BusinessUnits unit = BusinessRepo.GetBusinessUnitById(id);

            return(View(unit));
        }
コード例 #27
0
 public static IQueryable <IBusinessUnit> GetBusinessUnits()
 {
     return(BusinessUnits.GetAll().Where(b => b.Status == Status.Active));
 }
コード例 #28
0
 private void LoadBusinessUnits(BusinessUnits bUnits)
 {
     this.BusinessUnits = bUnits;
 }
コード例 #29
0
 private void LoadBusinessUnits(BusinessUnits bUnits)
 {
     this.BusinessUnits = bUnits;
 }
        /// <summary>
        /// Returns All Business Units in the table
        /// </summary>
        /// <param name="userId"></param>
        /// <returns>BusinessUnits</returns>
        public BusinessUnits FindAll(int userId)
        {
            MySqlCommand.CommandType = CommandType.StoredProcedure;
            MySqlCommand.CommandText = FindAllStoredProcedure;
            MySqlCommand.Parameters.AddWithValue("userid", userId);
            MySqlCommand.Parameters.Add(new MySqlParameter("@result", MySqlDbType.Int32));
            MySqlCommand.Parameters["@result"].Direction = ParameterDirection.Output;
            MySqlDataAdapter.SelectCommand = MySqlCommand;
            MySqlDataAdapter.Fill(BusinessUnitDataSet);

            //Now lets return buis
            var businessUnits = new BusinessUnits();
            DataTable dataTable = BusinessUnitDataSet.Tables[0]; // Only 1 table
            for (var i = 0; i < dataTable.Rows.Count; i++)
            {
                #region Add to list
                businessUnits.Add(new BusinessUnit
                {
                    BuId =
                    {
                        DataValue = Int32.Parse(dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuId].ToString())
                    },
                    BuName =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuName].ToString())
                    },
                    BuEmailAddress =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuEmailAddress].ToString())
                    },
                    BuContactNum1 =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuContactNum1].ToString())
                    },
                    BuContactNum2 =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuContactNum2].ToString())
                    },
                    BuContactNum3 =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuContactNum3].ToString())
                    },
                    BuAddress1 =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuAddress1].ToString())
                    },
                    BuAddress2 =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuAddress2].ToString())
                    },
                    BuAddress3 =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuAddress3].ToString())
                    },
                    BuParish =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuParish].ToString())
                    },
                    BuCountry =
                    {
                        DataValue = (dataTable.Rows[i][(int)BusinessUnitTableDefinition.BuCountry].ToString())
                    },
                    CreatedAt =
                    {
                        DataValue = DateTime.Parse(dataTable.Rows[i][(int)BusinessUnitTableDefinition.CreatedAt].ToString())
                    },
                    CreatedBy =
                    {
                        DataValue = Int32.Parse(dataTable.Rows[i][(int)BusinessUnitTableDefinition.CreatedBy].ToString())
                    },
                    UpdatedAt =
                    {
                        DataValue = DateTime.Parse(dataTable.Rows[i][(int)BusinessUnitTableDefinition.UpdatedAt].ToString())
                    },
                    UpdatedBy =
                    {
                        DataValue = Int32.Parse(dataTable.Rows[i][(int)BusinessUnitTableDefinition.UpdatedBy].ToString())
                    }
                });
                #endregion

            }
            return businessUnits;
        }
コード例 #31
0
 public static IBusinessUnit CreateBusinessUnit()
 {
     return(BusinessUnits.Create());
 }
コード例 #32
0
 public void UpdateBusinessunit(BusinessUnits businessunit)
 {
     unitOfWork.BusinessUnit.Update(businessunit);
     unitOfWork.Save();
 }
コード例 #33
0
        public virtual List <Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine> GetResponsibilitiesReportData(IEmployee employee)
        {
            var result = new List <Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine>();
            // HACK: Получаем отображаемое имя модуля.
            var moduleGuid     = new CompanyModule().Id;
            var moduleName     = Sungero.Metadata.Services.MetadataSearcher.FindModuleMetadata(moduleGuid).GetDisplayName();
            var modulePriority = Company.Constants.ResponsibilitiesReport.CompanyPriority;

            // Должность.
            result = AppendResponsibilitiesReportResult(result, employee.JobTitle, moduleName, modulePriority, Resources.Jobtitle);

            // Подразделения.
            if (Departments.AccessRights.CanRead())
            {
                var employeeDepartments = Departments.GetAll()
                                          .Where(d => d.RecipientLinks.Any(e => Equals(e.Member, employee)))
                                          .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active);
                result = AppendResponsibilitiesReportResult(result, employeeDepartments, moduleName, modulePriority, Resources.Departments, employee.Department);
            }

            // НОР.
            if (Departments.AccessRights.CanRead() &&
                BusinessUnits.AccessRights.CanRead())
            {
                var businessUnits = Departments.GetAll()
                                    .Where(d => d.RecipientLinks.Any(e => Equals(e.Member, employee)))
                                    .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active)
                                    .Select(b => b.BusinessUnit)
                                    .Where(b => b.Status == Sungero.CoreEntities.DatabookEntry.Status.Active).Distinct();
                result = AppendResponsibilitiesReportResult(result, businessUnits, moduleName, modulePriority, Resources.BusinessUnits, employee.Department.BusinessUnit);
            }

            // Руководитель подразделений.
            if (Departments.AccessRights.CanRead())
            {
                var managerOfDepartments = Departments.GetAll().Where(d => Equals(d.Manager, employee))
                                           .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active);
                result = AppendResponsibilitiesReportResult(result, managerOfDepartments, moduleName, modulePriority, Resources.ManagerOfDepartmens);
            }

            // Руководители НОР.
            if (BusinessUnits.AccessRights.CanRead())
            {
                var businessUnitsCEO = BusinessUnits.GetAll().Where(b => Equals(b.CEO, employee))
                                       .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active);
                result = AppendResponsibilitiesReportResult(result, businessUnitsCEO, moduleName, modulePriority, Resources.BusinessUnitsCEO);
            }

            // Роли.
            if (Roles.AccessRights.CanRead())
            {
                var roles = Roles.GetAll().Where(r => r.RecipientLinks.Any(e => Equals(e.Member, employee)))
                            .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active);
                result = AppendResponsibilitiesReportResult(result, roles, moduleName, modulePriority, Resources.Roles);
            }

            // Помощники руководителей.
            if (ManagersAssistants.AccessRights.CanRead())
            {
                var managersAssistants = ManagersAssistants.GetAll()
                                         .Where(m => Equals(m.Assistant, employee) || Equals(m.Manager, employee))
                                         .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active)
                                         .ToDictionary <IEntity, IEntity, string>(x => x,
                                                                                  x => string.Format("{0}: {1}{2}{3}: {4}",
                                                                                                     Resources.Manager,
                                                                                                     PublicFunctions.Employee.GetShortName(ManagersAssistants.As(x).Manager, false),
                                                                                                     Environment.NewLine,
                                                                                                     Resources.Assistant,
                                                                                                     PublicFunctions.Employee.GetShortName(ManagersAssistants.As(x).Assistant, false)));
                result = AppendResponsibilitiesReportResult(result, managersAssistants, moduleName, modulePriority + result.Count, Resources.ManagersAssistants);
            }

            // Замещения.
            if (Substitutions.AccessRights.CanRead())
            {
                var substitutions = Substitutions.GetAll()
                                    .Where(s => (Equals(s.Substitute, employee) ||
                                                 Equals(s.User, employee)) &&
                                           (!s.EndDate.HasValue || s.EndDate >= Calendar.UserToday))
                                    .Where(s => s.IsSystem != true)
                                    .ToDictionary <IEntity, IEntity, string>(x => x, x => CreateSubstitutionPresentation(Substitutions.As(x)));
                result = AppendResponsibilitiesReportResult(result, substitutions, moduleName, modulePriority + result.Count, Resources.Substitutions);
            }

            return(result);
        }