Exemplo n.º 1
0
            /// <summary>
            /// Process the request.
            /// </summary>
            /// <param name="request">The request object.</param>
            /// <returns>The response object.</returns>
            protected override NullResponse Process(PickAndPackOrderRequest request)
            {
                ThrowIf.Null(request, "request");

                if (string.IsNullOrEmpty(request.SalesId))
                {
                    throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_RequiredValueNotFound, "Order identifier is required.");
                }

                // Get current channel
                OrgUnit currentStore = PickAndPackOrderRequestHandler.GetStoreFromContext(this.Context);

                string shippingWarehouseId = string.IsNullOrWhiteSpace(currentStore.ShippingInventLocationId)
                    ? currentStore.InventoryLocationId
                    : currentStore.ShippingInventLocationId;

                // Execute request
                this.Context.Execute <Response>(
                    new PickAndPackOrderRealtimeRequest(
                        request.SalesId,
                        request.CreatePickingList,
                        request.CreatePackingSlip,
                        shippingWarehouseId));

                // Retrive customer order
                return(new NullResponse());
            }
Exemplo n.º 2
0
 public OrgUnit(string shortName, string name, OrgUnitType type, OrgUnit parent = null)
 {
     ShortName = shortName;
     Name      = name;
     Type      = type;
     Parent    = parent;
 }
            /// <summary>
            /// Gets the store by identifier and sets it on the context.
            /// </summary>
            /// <param name="context">The context.</param>
            private static void PopulateContextWithOrgUnit(RequestContext context)
            {
                SearchOrgUnitDataRequest request = new SearchOrgUnitDataRequest(context.GetPrincipal().ChannelId);
                OrgUnit orgUnit = context.Runtime.Execute <EntityDataServiceResponse <OrgUnit> >(request, context, skipRequestTriggers: true).PagedEntityCollection.SingleOrDefault();

                context.SetOrgUnit(orgUnit);
            }
Exemplo n.º 4
0
        public async Task <IActionResult> PutOrgUnit(long id, OrgUnit orgUnit)
        {
            if (id != orgUnit.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                DropHeadOfOrgUnit(orgUnit);

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

            return(NoContent());
        }
 public override void Initialize()
 {
     base.Initialize();
     this._CoOrgan      = new OrgUnit();
     this._CoGovSession = new GovSession();
     this._Attachments  = new AnnouncementAttachs();
 }
 public override void Initialize()
 {
     base.Initialize();
     this._CoLetter    = new Letter();
     this._CouncilType = new BasicInfoDetail();
     this._CoOrgUnit   = new OrgUnit();
 }
        /// <summary>
        /// Add Organization Unit
        /// Documentation https://developers.google.com/directory/directory_v1/reference/orgunits/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Directory service.</param>
        /// <param name="customerId">Immutable ID of the G Suite account</param>
        /// <param name="body">A valid Directory directory_v1 body.</param>
        /// <returns>OrgUnitResponse</returns>
        public static OrgUnit Insert(DirectoryService service, string customerId, OrgUnit body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (customerId == null)
                {
                    throw new ArgumentNullException(customerId);
                }

                // Make the request.
                return(service.Orgunits.Insert(body, customerId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Orgunits.Insert failed.", ex);
            }
        }
            /// <summary>
            /// Initializes a new instance of the <see cref="SqliteDatabaseContext"/> class.
            /// </summary>
            /// <param name="requestContext">The request context.</param>
            public SqliteDatabaseContext(RequestContext requestContext)
                : base(requestContext)
            {
                ChannelConfiguration channelConfiguration = requestContext.GetChannelConfiguration();

                if (channelConfiguration != null)
                {
                    this.ChannelId  = channelConfiguration.RecordId;
                    this.DataAreaId = channelConfiguration.InventLocationDataAreaId;
                }

                OrgUnit orgUnit = requestContext.GetOrgUnit();

                if (orgUnit != null)
                {
                    this.StoreNumber = orgUnit.OrgUnitNumber;
                }

                this.connectionElementUniqueIdentifier = 0;
                this.ShiftId         = requestContext.GetPrincipal().ShiftId;
                this.ShiftTerminalId = requestContext.GetPrincipal().ShiftTerminalId;

                GetCurrentTerminalIdDataRequest dataRequest = new GetCurrentTerminalIdDataRequest();

                this.TerminalId = requestContext.Runtime.Execute <SingleEntityDataServiceResponse <string> >(dataRequest, requestContext, skipRequestTriggers: true).Entity;
            }
Exemplo n.º 9
0
        public static Cat_OrgStructure GetNearestParent(Guid?orgId
                                                        , OrgUnit unit
                                                        , List <Cat_OrgStructure> lstAllStructure, List <Cat_OrgStructureType> lstAllOrgType)
        {
            Cat_OrgStructure     structure = lstAllStructure.Where(m => m.ID == orgId).FirstOrDefault();
            Cat_OrgStructureType orgType   = lstAllOrgType.Where(m => m.OrgStructureTypeCode == unit.ToString()).FirstOrDefault();

            if (structure == null)
            {
                return(null);
            }
            if (structure.OrgStructureTypeID == null)
            {
                return(null);
            }
            if (orgType == null)
            {
                return(null);
            }
            if (structure.OrgStructureTypeID.Value == orgType.ID || structure.ParentID == null)
            {
                return(structure);
            }
            return(GetNearestParent(structure.ParentID, unit, lstAllStructure, lstAllOrgType));
        }
Exemplo n.º 10
0
        public List <OrgUnit> GetOrgUnitsForLeader(Person currentUser)
        {
            var orgUnitsDupes = new List <OrgUnit>();

            if (currentUser.Employments.Where(e => e.IsLeader).Any())
            {
                foreach (Employment e in currentUser.Employments.Where(e => e.IsLeader))
                {
                    OrgUnit org = e.OrgUnit;
                    orgUnitsDupes.Add(org);
                    orgUnitsDupes.AddRange(getChildrenOrgUnits(org.Id));
                }
            }

            if (currentUser.SubstituteLeaders != null && currentUser.SubstituteLeaders.Count > 0)
            {
                foreach (Substitute subFor in currentUser.SubstituteLeaders)
                {
                    Person leader = subFor.Leader;
                    foreach (Employment e in leader.Employments.Where(e => e.IsLeader))
                    {
                        OrgUnit org = e.OrgUnit;
                        orgUnitsDupes.Add(org);
                        orgUnitsDupes.AddRange(getChildrenOrgUnits(org.Id));
                    }
                }
            }

            return(orgUnitsDupes.Distinct().ToList());
        }
 public override void Initialize()
 {
     base.Initialize();
     this._RelationType     = GEPRellationToOfferType.OutOfValue;
     this._CorrelateOrgUnit = new OrgUnit();
     this._CorrelateOffer   = new Offer();
 }
Exemplo n.º 12
0
 protected void txtSearch_TextChanged(object sender, EventArgs e)
 {
     if (txtSearch.Text.Trim().Length > 0)
     {
         try {
             lbxOrgUnits.Items.Clear();
             DataSet  ds = OrgUnit.ItemsLBX(txtSearch.Text.Trim());
             DataView dv = new DataView(ds.Tables[0]);
             dv.Sort = "Name";
             if (dv.Table.Rows.Count > 0)
             {
                 foreach (DataRowView drv in dv)
                 {
                     drv["DistinguishedName"] = drv["DistinguishedName"].ToString().Replace(",OU=", ",");
                     drv["DistinguishedName"] = drv["DistinguishedName"].ToString().Replace("OU=", "");
                 }
             }
             lbxOrgUnits.DataSource     = dv;
             lbxOrgUnits.DataTextField  = "DistinguishedName";
             lbxOrgUnits.DataValueField = "ID";
             lbxOrgUnits.DataBind();
             if (dv.Table.Rows.Count > 0)
             {
                 SetListItemColors();
             }
         } catch (Exception ex) {
             SPA.Error.WriteError(ex);
             if (ShowDebug)
             {
                 lblErrorMessage.Text = ex.ToString();
             }
         }
     }
 }
Exemplo n.º 13
0
            private static void SaveTransaction(RequestContext context, TransactionType transactionType, string transactionId)
            {
                string terminalId;
                string storeId;

                if (context.GetPrincipal() != null && context.GetTerminal() != null)
                {
                    terminalId = context.GetTerminal().TerminalId;
                    var     getStoreDataServiceRequest = new SearchOrgUnitDataRequest(context.GetPrincipal().ChannelId);
                    OrgUnit store = context.Runtime.Execute <EntityDataServiceResponse <OrgUnit> >(getStoreDataServiceRequest, context).PagedEntityCollection.SingleOrDefault();

                    storeId = store.OrgUnitNumber;
                }
                else
                {
                    return;
                }

                TransactionLog transaction = new TransactionLog()
                {
                    TransactionType = transactionType,
                    Id         = transactionId,
                    StaffId    = context.GetPrincipal().UserId,
                    TerminalId = terminalId,
                    StoreId    = storeId
                };

                TransactionLogService.LogTransaction(context, transaction);
            }
Exemplo n.º 14
0
 private void FillOrgUnits()
 {
     try {
         lbxOrgUnits.Items.Clear();
         DataSet  ds = OrgUnit.ItemsLBX();
         DataView dv = new DataView(ds.Tables[0]);
         dv.Sort = "Name";
         foreach (DataRowView drv in dv)
         {
             drv["DistinguishedName"] = drv["DistinguishedName"].ToString().Replace(",OU=", ",");
             drv["DistinguishedName"] = drv["DistinguishedName"].ToString().Replace("OU=", "");
         }
         lbxOrgUnits.DataSource     = dv;
         lbxOrgUnits.DataTextField  = "DistinguishedName";
         lbxOrgUnits.DataValueField = "ID";
         lbxOrgUnits.DataBind();
         SetListItemColors();
     } catch (Exception ex) {
         SPA.Error.WriteError(ex);
         if (ShowDebug)
         {
             lblErrorMessage.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 15
0
        public JsonResult Get(long id)
        {
            DepartmentViewModel department = null;

            try
            {
                OrgUnit orgUnit = OrgUnit.Find(SessionContext, id);

                if (orgUnit == null)
                {
                    SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Get, MessageException.Null("The static method Find return null, ID : " + id));
                }

                department = new DepartmentViewModel
                {
                    ID       = orgUnit.ID,
                    Code     = orgUnit.Code,
                    Name     = orgUnit.CurrentName.Name.GetValue("th-TH"),
                    Ministry = new MinistryViewModel
                    {
                        ID   = orgUnit.OrganizationParent.ID,
                        Code = orgUnit.OrganizationParent.Code,
                        Name = orgUnit.OrganizationParent.CurrentName.Name.GetValue(SessionContext.CurrentLanguage.Code)
                    }
                };
            }
            catch (Exception ex)
            {
                SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Get, MessageException.Fail(ex.Message));
            }

            return(Json(department, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> AddOrgUnit(OrgUnit item, long?parentId)
        {
            //calculate ou code
            if (!parentId.HasValue) //new company
            {
                item.Code = "01";
            }
            else
            {
                string parentCode = _context.OrgUnits.SingleOrDefault(b => b.Id == parentId).Code;
                int    seq        = _context.OrgUnits.Where(b => b.Code.StartsWith(parentCode) && b.Code.Length == parentCode.Length + 3).Count() + 1;
                if (seq < 10)
                {
                    item.Code = parentCode + "." + "0" + seq.ToString();
                }
                else
                {
                    item.Code = parentCode + "." + seq.ToString();
                }
            }

            item.IsVacant    = true;
            item.CreatedDate = DateTime.Now.Date;
            item.LastUpdated = DateTime.Now.Date;
            item.UpdatedBy   = "user";

            _context.OrgUnits.Add(item);
            await _context.SaveChangesAsync();

            return(RedirectToAction("OrgChart", new { id = parentId }));
        }
Exemplo n.º 17
0
 public IActionResult EditWithAddLegalEntity(OrgUnit orgUnit, LegalEntityInformation legalEntity)
 {
     _organizationUnitProvider.AddLegalEntity(legalEntity);
     orgUnit.LegalEntityInformation = legalEntity;
     _organizationUnitProvider.Edit(orgUnit);
     return(Ok());
 }
 public OrgUnitModel(OrgUnit orgUnit)
 {
     _orgUnit  = orgUnit;
     _location = new LocationModel {
         Lat = _orgUnit.Lat, Lng = _orgUnit.Lng, Address = _orgUnit.Address
     };
 }
Exemplo n.º 19
0
        public IActionResult AddWithLegalEntity([FromBody] CreateEditViewModel model)
        {
            var orgUnit = new OrgUnit();

            _mapper.Map(model, orgUnit);
            var legalEntity = new LegalEntityInformation();

            model.SuperiorID = EncryptionHelper.DecryptUrlParam(model.SuperiorID);
            var legalEntityMapper = _mapper.Map(model, legalEntity);

            legalEntity.ManagingDirectorId = Convert.ToInt32(EncryptionHelper.DecryptUrlParam(model.ManagingDirectorID));
            _organizationUnitProvider.AddLegalEntity(legalEntityMapper);

            orgUnit.LegalEntityInformation = legalEntity;
            //if (model.AttachmentFile != null)
            //{
            //    var theObject = new OrgUnit();
            //    var tableName = GetTableName(theObject);

            //    var attachment = new Attachment
            //    {
            //        TableOriginID = orgUnit.ID,
            //        TableOriginName = tableName,
            //        AttachmentFile = model.AttachmentFile
            //    };

            //model.SuperiorID = !string.IsNullOrEmpty(model.SuperiorID) ? EncryptionHelper.DecryptUrlParam(model.SuperiorID) : null;

            var orgUnitMapper = _mapper.Map(model, orgUnit);

            _organizationUnitProvider.Add(orgUnitMapper);

            return(Ok(orgUnitMapper));
        }
            /// <summary>
            /// Gets the list of stores accessible by this employee from address book.
            /// </summary>
            /// <param name="staffId">The staff identifier.</param>
            /// <param name="settings">The query result settings.</param>
            /// <returns>The paged results of stores accessible by this employee.</returns>
            public PagedResult <OrgUnit> GetEmployeeStoresFromAddressBook(string staffId, QueryResultSettings settings)
            {
                ThrowIf.Null(settings, "settings");
                ThrowIf.Null(settings.Paging, "settings.Paging");

                var orgUnits = new List <OrgUnit>();
                var data     = this.InvokeMethodAllowNullResponse(
                    GetEmployeeStoresFromAddressBookMethodName,
                    new object[] { staffId, settings.Paging.NumberOfRecordsToFetch, settings.Paging.Skip });

                if (data != null)
                {
                    // Parse response data
                    foreach (var orgUnitDataRow in data)
                    {
                        var orgUnitData = (object[])orgUnitDataRow;
                        var orgUnit     = new OrgUnit()
                        {
                            OrgUnitNumber         = (string)orgUnitData[0],
                            OrgUnitName           = (string)orgUnitData[1],
                            OrgUnitFullAddress    = (string)orgUnitData[2],
                            OMOperatingUnitNumber = (string)orgUnitData[3]
                        };

                        orgUnits.Add(orgUnit);
                    }
                }

                return(new PagedResult <OrgUnit>(orgUnits.AsReadOnly(), settings.Paging));
            }
Exemplo n.º 21
0
 public override void Initialize()
 {
     base.Initialize();
     this._OrgUnit    = new OrgUnit();
     this._Interdicts = new PersonnelInterdicts();
     this._CoOrgUnit  = new MFOrgUnit();
 }
        private RuleSet MapDTOtoModel(RuleSetDTO ruleSetDto)
        {
            List <OrgUnit> orgUnitList = new List <OrgUnit>();
            RuleSet        modle       = new RuleSet();

            modle.IsActive                   = ruleSetDto.IsActive;
            modle.SendBeforeInDays           = ruleSetDto.SendSMSBeforeDays;
            modle.ExpireInDays               = ruleSetDto.DaysForRetryExpiry;
            modle.SendingTimeIntervalFrom    = ruleSetDto.SendingTimeWindowFrom;
            modle.SendingTimeIntervalTo      = ruleSetDto.SendingTimeWindowTo;
            modle.IgnoreSMStoAdmittedPatient = ruleSetDto.IgnoreSMStoAdmittedPatient;
            modle.AppointmentTo              = ruleSetDto.AptValidate_To;
            modle.AppointmentFrom            = ruleSetDto.AptValidate_From;
            modle.DepartmentId               = ruleSetDto.DepartmentID;
            modle.HospitalId                 = ruleSetDto.HospitalID;
            modle.RulesetName                = ruleSetDto.Name;
            modle.RulesetId                  = ruleSetDto.RuleSetGUID.Value;
            modle.ScheduleValidityPeriodFrom = ruleSetDto.ValidFrom;
            modle.ScheduleValidityPeriodTo   = ruleSetDto.ValidTo;
            modle.MinimumTimeFromMinutes     = ruleSetDto.SendSMSBeforeInMins;
            modle.IsAppointmentTimeValidate  = ruleSetDto.isValidateAptTime;
            foreach (var id in ruleSetDto.ExcludingOrgUnitIDs)
            {
                OrgUnit orgUnit = new OrgUnit();
                orgUnit.UnitID = id;
                orgUnitList.Add(orgUnit);
            }
            modle.ExcludeOrgUnits = orgUnitList;
            return(modle);
        }
Exemplo n.º 23
0
        public JsonResult UpdateResponsibleOrgUnits(long[] agencies)
        {
            try
            {
                if (agencies.Length <= 0)
                {
                    return(Json(new { Success = true, Message = "กรุณาตรวจสอบข้อมูล" }, JsonRequestBehavior.AllowGet));
                }

                SelfAuthenticatedUser user = SessionContext.User;

                //Expire all
                foreach (var item in user.ResponsibleOrgUnits)
                {
                    item.EffectivePeriod = new TimeInterval(TimeInterval.MaxDate, TimeInterval.MinDate);
                }

                //update
                for (int i = 0; i < agencies.Length; i++)
                {
                    if (user.ResponsibleOrgUnits.Any(x => x.OrgUnit.ID == agencies[i]))
                    {
                        user.ResponsibleOrgUnits.Where(x => x.OrgUnit.ID == agencies[i]).SingleOrDefault().EffectivePeriod = TimeInterval.EffectiveNow;
                    }
                    else
                    {
                        UserOrgUnit userOrgUnitNew = new UserOrgUnit(user, OrgUnit.Find(SessionContext, agencies[i]));
                        user.ResponsibleOrgUnits.Add(userOrgUnitNew);
                    }
                }

                using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction())
                {
                    try
                    {
                        SessionContext.Persist(user);
                        tx.Commit();

                        SessionContext.Log(0, pageID, 0, MessageException.ProjectMessage.EditProfile, MessageException.Success(user.LoginName));
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();

                        SessionContext.LogButNotFlush(0, pageID, 0, MessageException.ProjectMessage.EditProfile, MessageException.Fail(ex.Message));
                        return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet));
                    }
                }

                return(Json(new { Success = true, Message = "บันทึกเรียบร้อย" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                SessionContext.LogButNotFlush(0, pageID, 0, MessageException.ProjectMessage.EditProfile, MessageException.Fail(ex.Message));
                return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Determines whether a user has write access to this instance.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>
        ///   <c>true</c> if user has write access, otherwise <c>false</c>.
        /// </returns>
        public override bool HasUserWriteAccess(User user)
        {
            if (OrgUnit != null && OrgUnit.HasUserWriteAccess(user))
            {
                return(true);
            }

            return(base.HasUserWriteAccess(user));
        }
Exemplo n.º 25
0
        private static void AddExcludedReshId(RuleSet ruleset, string reshid)
        {
            var orgUnit = new OrgUnit
            {
                UnitID = reshid
            };

            ruleset.ExcludeOrgUnits.Add(orgUnit);
        }
Exemplo n.º 26
0
            /// <summary>
            /// Constructs the SalesTaxGroupPicker for store.
            /// </summary>
            /// <param name="store">The organization unit.</param>
            /// <param name="customer">The customer object.</param>
            /// <param name="context">The request context.</param>
            /// <param name="deliveryAddress">The delivery address.</param>
            /// <param name="deliveryMode">The delivery mode used.</param>
            /// <param name="fulfillmentStoreId">The store that fulfills the purchase (pick up from).</param>
            /// <param name="shippingFromInventLocation">The invent location that item shipped from.</param>
            /// <returns>
            /// The SalesTaxGroupPicker object.
            /// </returns>
            private static SalesTaxGroupPicker CreatePickerForStore(
                OrgUnit store,
                Customer customer,
                RequestContext context,
                Address deliveryAddress,
                string deliveryMode,
                string fulfillmentStoreId,
                string shippingFromInventLocation)
            {
                var policies = new Collection <ITaxGroupPolicy>();

                bool pickUpFromStore = false;

                if (!string.IsNullOrWhiteSpace(deliveryMode))
                {
                    pickUpFromStore = deliveryMode.Equals(context.GetChannelConfiguration().PickupDeliveryModeCode, StringComparison.OrdinalIgnoreCase);

                    if (!string.IsNullOrWhiteSpace(fulfillmentStoreId))
                    {
                        // same store pickup or not?
                        if (!fulfillmentStoreId.Equals(store.OrgUnitNumber, StringComparison.CurrentCultureIgnoreCase))
                        {
                            var getStoresByStoreNumbersDataRequest = new SearchOrgUnitDataRequest(new string[] { fulfillmentStoreId }, QueryResultSettings.SingleRecord);
                            store = context.Runtime.Execute <EntityDataServiceResponse <OrgUnit> >(getStoresByStoreNumbersDataRequest, context).PagedEntityCollection.Results.SingleOrDefault();
                        }
                    }
                }

                // Constructs the policy checking chain in the priority of : Shipping address -> Customer -> Store.
                // There should be no tax fallback calculations between types of store taxes.
                // For example, if the store is using Customer based tax and no tax group found,
                // should return 0 tax instead of trying to calculate using Store based tax.
                if (store.UseDestinationBasedTax && !pickUpFromStore && deliveryAddress != null)
                {
                    switch (context.GetChannelConfiguration().CountryRegionISOCode)
                    {
                    case CountryRegionISOCode.IN:
                        policies.Add(new AddressTaxGroupPolicyIndia(context, deliveryAddress, shippingFromInventLocation));
                        break;

                    default:
                        policies.Add(new AddressTaxGroupPolicy(context, deliveryAddress));
                        break;
                    }
                }
                else if (store.UseCustomerBasedTax && customer != null)
                {
                    policies.Add(new CustomerTaxGroupPolicy(customer));
                }
                else
                {
                    policies.Add(new StoreTaxGroupPolicy(store));
                }

                return(new SalesTaxGroupPicker(policies));
            }
Exemplo n.º 27
0
        public async Task <ActionResult <OrgUnit> > PostOrgUnit(OrgUnit orgUnit)
        {
            _context.OrgUnits.Add(orgUnit);

            DropHeadOfOrgUnit(orgUnit);

            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrgUnit", new { id = orgUnit.Id }, orgUnit));
        }
Exemplo n.º 28
0
 public override void Initialize()
 {
     base.Initialize();
     this._ReceiptDate        = "";
     this._ReceiptDescription = "";
     this._CorrelateLetter    = new Letter();
     this._ReceiptType        = new BasicInfoDetail();
     this._CorrelateOrgan     = new OrgUnit();
     this._CorrelatePersonnel = new PersonnelInterdict();
 }
Exemplo n.º 29
0
 private void BouwTVVerder(TreeViewItem parent_tv_itm, OrgUnit parent_ou)
 {
     foreach (OrgUnit ou in parent_ou.Childeren)
     {
         TreeViewItem itm = new TreeViewItem();
         itm.Tag    = ou.Tag;
         itm.Header = ou.Name;
         BouwTVVerder(itm, ou);
         parent_tv_itm.Items.Add(itm);
     }
 }
Exemplo n.º 30
0
        public JsonResult Save(long ministryId, string code, string name)
        {
            try
            {
                if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(name))
                {
                    SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Save, MessageException.Fail("The code or name is emptry."));
                    return(Json(new { Success = false, Message = MessageException.PleaseFillOut }, JsonRequestBehavior.AllowGet));
                }

                Organization org = Organization.Find(SessionContext, ministryId);

                if (org == null)
                {
                    SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Save, MessageException.Null("The static method Find return null, ID : " + ministryId));
                    return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet));
                }

                using (ITransaction tx = SessionContext.PersistenceSession.BeginTransaction())
                {
                    try
                    {
                        OrgUnit orgUnit = new OrgUnit
                        {
                            Code        = code.Trim(),
                            CurrentName = new OrgName {
                                Name = new MultilingualString("th-TH", name.Trim(), "en-US", name.Trim())
                            },
                            OrganizationParent = org
                        };

                        orgUnit.Persist(SessionContext);

                        tx.Commit();

                        SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Save, MessageException.Success());
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();

                        SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Save, MessageException.Fail(ex.Message));
                        return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                SessionContext.Log(0, this.pageID, 0, MessageException.DepartmentMessage.Save, MessageException.Fail(ex.Message));
                return(Json(new { Success = false, Message = MessageException.Error }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { Success = true, Message = "เพิ่มหน่วยงาน เรียบร้อย" }, JsonRequestBehavior.AllowGet));
        }
        private void ProcessRequest(Instance request)
        {
            try
            {
                var orgUnit = new OrgUnit
                    {
                        BlockInheritance = BlockInheritance,
                        Description = String.IsNullOrEmpty(Description) ? null : Description,
                        OrgUnitPath = String.IsNullOrEmpty(OrgUnitPath) ? null : OrgUnitPath,
                        ParentOrgUnitPath = String.IsNullOrEmpty(ParentOrgUnitPath) ? null : ParentOrgUnitPath,
                        Name = String.IsNullOrEmpty(Name) ? null : Name
                    };

                var service = request.DirectoryService.Orgunits.Update(orgUnit, "my_customer", OrgUnitId);

                service.Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to Update OrgUnit!");
                Console.WriteLine("Error: " + e);
            }
        }
Exemplo n.º 32
0
 public static Cat_OrgStructure GetNearestParent(Guid? orgId
                                      , OrgUnit unit
                                      , List<Cat_OrgStructure> lstAllStructure, List<Cat_OrgStructureType> lstAllOrgType)
 {
     Cat_OrgStructure structure = lstAllStructure.Where(m => m.ID == orgId).FirstOrDefault();
     Cat_OrgStructureType orgType = lstAllOrgType.Where(m => m.OrgStructureTypeCode == unit.ToString()).FirstOrDefault();
     if (structure == null)
         return null;
     if (structure.OrgStructureTypeID == null)
         return null;
     if (orgType == null)
         return null;
     if (structure.OrgStructureTypeID.Value == orgType.ID || structure.ParentID == null)
         return structure;
     return GetNearestParent(structure.ParentID, unit, lstAllStructure, lstAllOrgType);
 }