Example #1
0
        private static List <Asset> InitializeAssetList(ApiUser hdUser, AssetsConfig assetsconfig, DataTable dtAssets)
        {
            List <Asset> assets = new List <Asset>();

            /*
             * int counts = 0;
             * List<Models.Location> locations = null;
             * if (hdUser != null && dtAssets.Rows.Count > 0)
             *  locations = Models.Locations.GetAccountLocations(hdUser.OrganizationId, hdUser.DepartmentId, -1, 0, "", true);
             *
             * List<AssetCategory> statuses = null;
             * if (hdUser != null && dtAssets.Rows.Count > 0)
             *  statuses = AssetStatuses.GetAssetStatuses(hdUser.OrganizationId, hdUser.DepartmentId, null);
             */

            foreach (DataRow row_asset in dtAssets.Rows)
            {
                int id = row_asset.Get <int>("Id");
                if (id < 1)
                {
                    //counts = row_asset.Get<int>("ItemsCount");
                    continue;
                }
                var asset = GetAsset(hdUser, id);
                assets.Add(asset);
            }
            return(assets);
        }
Example #2
0
        public static List <Asset> AccountAssets(ApiUser hdUser, AssetsConfig assetsconfig, int AccountId)
        {
            var sqlquery = string.Format("SELECT Assets.Id,  Assets.CategoryId as AssetCategoryId, AssetCategories.Name as AssetCategoryName,  Assets.TypeId as AssetTypeId, AssetTypes.Name as AssetTypeName,  Assets.MakeId as AssetMakeId, AssetMakes.Make as AssetMakeName,  Assets.ModelId as AssetModelId, AssetModels.Model as AssetModelName,  Assets.AccountId as AccountId,  ISNULL(Accounts.vchName,ISNULL(tbl_company.company_name, '')) AS AccountName,  Assets.AssetGUID, Assets.SerialNumber, Assets.Unique1, Assets.Unique2, Assets.Unique3, Assets.Unique4, Assets.Unique5, Assets.Unique6, Assets.Unique7, CASE WHEN LEN(Assets.SerialNumber)>0 THEN Assets.SerialNumber END AS SerialTagNumber,  dbo.fxGetUserName(lo_checkout.FirstName, lo_checkout.LastName, lo_checkout.Email) as CheckoutName, AssetStatus.vchStatus as StatusName, Assets.dtUpdated AS UpdatedDate, dbo.fxGetUserName2(lo_updated.FirstName,lo_updated.LastName,lo_updated.Email) AS UpdatedByName FROM Assets  INNER JOIN tbl_company ON tbl_company.company_id={0}  INNER JOIN AssetCategories ON AssetCategories.DepartmentId={0} and Assets.CategoryId = AssetCategories.Id  INNER JOIN AssetTypes ON AssetTypes.DepartmentId={0} and Assets.TypeId = AssetTypes.Id  INNER JOIN AssetMakes ON AssetMakes.DepartmentId={0} and Assets.MakeId = AssetMakes.Id  INNER JOIN AssetModels ON AssetModels.DepartmentId={0} and Assets.ModelId = AssetModels.Id  INNER JOIN AssetStatus ON (AssetStatus.DId is NULL OR AssetStatus.DId={0}) and Assets.StatusId = AssetStatus.Id  LEFT OUTER JOIN Accounts ON Accounts.DId={0} and Assets.AccountId = Accounts.Id  LEFT OUTER JOIN Locations ON Locations.DId={0} and Assets.LocationId = Locations.Id  LEFT OUTER JOIN tbl_vendors Vendors ON Vendors.company_id={0} and Assets.VendorId = Vendors.Id  LEFT OUTER JOIN tbl_vendors WarrantyVendors ON WarrantyVendors.company_id={0} and Assets.WarrantyVendor = WarrantyVendors.Id  LEFT OUTER JOIN tbl_LoginCompanyJunc tlj_owner ON tlj_owner.company_id={0} and Assets.OwnerId=tlj_owner.id LEFT OUTER JOIN tbl_Logins lo_owner ON lo_owner.id=tlj_owner.login_id  LEFT OUTER JOIN tbl_LoginCompanyJunc tlj_checkout ON tlj_checkout.company_id={0} and Assets.CheckedOutId=tlj_checkout.id LEFT OUTER JOIN tbl_Logins lo_checkout ON lo_checkout.id=tlj_checkout.login_id  LEFT OUTER JOIN tbl_LoginCompanyJunc tlj_updated ON tlj_updated.company_id={0} and Assets.intUpdatedBy=tlj_updated.id LEFT OUTER JOIN tbl_Logins lo_updated ON lo_updated.id=tlj_updated.login_id  LEFT OUTER JOIN AssetStatusCompany ON AssetStatusCompany.DId={0} and AssetStatusCompany.AssetStatusID=Assets.StatusId  WHERE Assets.DepartmentId = 3 AND Assets.StatusId<>17 AND (AssetStatusCompany.NonActive=0 OR (AssetStatusCompany.NonActive IS NULL))  AND Assets.AccountId = {1} ORDER BY AssetCategoryName,AssetTypeName,AssetMakeName,AssetModelName",
                                         hdUser.DepartmentId, AccountId);

            return(InitializeAssetList(hdUser, assetsconfig, DBAccess.SelectByQuery(sqlquery, hdUser.OrganizationId)));
        }
Example #3
0
        public static List <Asset> GetAssets(ApiUser hdUser, string search, string filter, int user_id, int owner_id, int account_id, int location_id, bool?is_active, int status, int limit, int page)
        {
            Instance_Config config = new Instance_Config(hdUser);

            AssetsConfig assetsconfig = config.Assets;

            bigWebApps.bigWebDesk.Data.Assets.Filter         m_Filter   = new bigWebApps.bigWebDesk.Data.Assets.Filter(hdUser.DepartmentId, true, hdUser.OrganizationId);;
            bigWebApps.bigWebDesk.Data.Assets.ColumnsSetting ColSetting = //new bigWebApps.bigWebDesk.Data.Assets.ColumnsSetting();
                                                                          //bigWebApps.bigWebDesk.Data.Assets.ColumnsSetting ColSetting =
                                                                          new bigWebApps.bigWebDesk.Data.Assets.ColumnsSetting(hdUser.DepartmentId, hdUser.UserId, true, hdUser.OrganizationId);

            /*
             * ColSetting.Column1 = ColSetting.Column1 == bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank ? bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.AssetName : ColSetting.Column1;
             * ColSetting.Column2 = ColSetting.Column2 == bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank ? bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.AuditNote : ColSetting.Column2;
             * ColSetting.Column3 = ColSetting.Column3 == bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank ? bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.DateUpdated : ColSetting.Column3;
             * ColSetting.Column4 = ColSetting.Column4 == bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank ? bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.DateEntered : ColSetting.Column4;
             */
            ColSetting.Column1 = bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank;
            ColSetting.Column2 = bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank;
            ColSetting.Column3 = bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank;
            ColSetting.Column4 = bigWebApps.bigWebDesk.Data.Assets.BrowseColumn.Blank;

            if (!hdUser.IsTechAdmin || filter == "my")
            {
                user_id = owner_id = hdUser.UserId;
            }
            if (!string.IsNullOrEmpty(search))
            {
                m_Filter.SearchText = search;
                //m_Filter.LocationName
            }
            if (user_id > 0)
            {
                m_Filter.CheckedOutID = user_id;
            }
            if (owner_id > 0)
            {
                m_Filter.OwnerID = owner_id;
            }
            if (account_id > 0)
            {
                m_Filter.TicketAccountID = account_id;
            }
            if (location_id > 0)
            {
                m_Filter.LocationID = location_id;
            }
            if (status > 0)
            {
                m_Filter.StatusID = status;
            }
            string    custom_sort  = "";
            int       _assetsCount = 0;
            DataTable dtAssets     = bigWebApps.bigWebDesk.Data.Assets.SelectAssetsByFilter(hdUser.OrganizationId, hdUser.DepartmentId, m_Filter, ColSetting, custom_sort, out _assetsCount, null, hdUser.UserId, config, is_active, limit, page);

            return(InitializeAssetList(hdUser, assetsconfig, dtAssets));
        }
Example #4
0
 public Instance_Config(ApiUser usr) : base(usr.OrganizationId, usr.InstanceId, true)
 {
     User  = new UserConfig(usr);
     m_Org = usr.OrganizationId;
     m_Dep = usr.DepartmentId;
     if (base.CustomNames)
     {
         Names = new Names(usr.OrganizationId, usr.DepartmentId);
     }
     else
     {
         Names = new Names();
     }
     Logo                = string.IsNullOrEmpty(usr.InstanceLogoImageUrl) ? usr.OrganizationLogoImageUrl : usr.InstanceLogoImageUrl;
     Assets              = new AssetsConfig(base.Assets);
     m_TimeZoneOffset    = usr.TimeZoneOffset;
     m_TimeZoneId        = usr.TimeZoneId;
     m_BusinessDayLength = GetBusinessDayLength(base.BusHourStart, base.BusMinStart, base.BusHourStop, base.BusMinStop);
 }
Example #5
0
        public static Asset GetAsset(ApiUser hdUser, int id)
        {
            Instance_Config config = new Instance_Config(hdUser);

            AssetsConfig assetsconfig = config.Assets;

            DataRow dr = GetAssetRow(hdUser, id);

            Asset asset = new Asset(dr);
            List <KeyValuePair <string, string> > unique_fields = new List <KeyValuePair <string, string> >();

            for (int i = 1; i < 8; i++)
            {
                if (!string.IsNullOrEmpty(assetsconfig.Captions[i - 1]))
                {
                    unique_fields.Add(new KeyValuePair <string, string>(assetsconfig.Captions[i - 1] + " (Unique" + i + ")", dr.GetString("Unique" + i)));
                }
            }
            asset.UniqueFields = unique_fields.ToList();
            return(asset);
        }
Example #6
0
        public static List <Asset> TicketAssets(ApiUser hdUser, AssetsConfig assetsconfig, int TicketId)
        {
            DataTable dtAssets = bigWebApps.bigWebDesk.Data.Tickets.SelectAssets(hdUser.OrganizationId, hdUser.DepartmentId, TicketId);

            return(InitializeAssetList(hdUser, assetsconfig, dtAssets));
        }