Пример #1
0
        public static IEnumerable<LoginData> SelectLogins(Guid OrganizationId, int DepartmentId, string where)
        {
            if (where == string.Empty) where = null;
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);

            var l = dc.Sp_SelectLoginsDynamicWhere(DepartmentId, where);

            var ld = l.Select<Context.Sp_SelectLoginsDynamicWhereResult, LoginData>(r => new LoginData()
            {
                key = GetString(r.Id),
                email = r.Email,
                first_name = r.FirstName,
                last_name = r.LastName,
                title = r.Title,
                organization = r.Organization,
                phone = r.Phone,
                mobile_phone = r.MobilePhone,
                location = r.LocationFullName,
                location_id = GetString(r.Location_id),
                user_type_id = GetString(r.UserType_Id),
                user_type = r.UserTypeName,
                global_level_setting = r.TintLevel
            });

            return ld;
        }
Пример #2
0
        public static void InsertLogin(Guid OrganizationId, int DepartmentId, LoginData ld)
        {
            if (string.IsNullOrEmpty(ld.email)) return;
            ld.email=ld.email.ToLower();
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
            var l = (from ll in dc.Tbl_Logins where ll.Email.ToLower() == ld.email select ll).FirstOrNull();
            if (l == null)
            {
                l = new Context.Tbl_Logins();
                FillLogin(ld, l);
                dc.Tbl_Logins.InsertOnSubmit(l);
                dc.SubmitChanges();
            }
            else
            {
                FillLogin(ld, l);
            }
            var j = (from jj in dc.Tbl_LoginCompanyJunc where jj.Company_id==DepartmentId && jj.Login_id==l.Id select jj).FirstOrNull();
            if (j == null)
            {
                j = new Context.Tbl_LoginCompanyJunc();
                j.Company_id = DepartmentId;
                j.Login_id = l.Id;
                FillJunk(ld, j);
                dc.Tbl_LoginCompanyJunc.InsertOnSubmit(j);
            }
            else
            {
                FillJunk(ld, j);
            }

            dc.SubmitChanges();
        }
Пример #3
0
        public static string Copy(Guid OrgId, int DepartmentId, int ModelID, int MakeID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Models = from t in dc.AssetModels where t.Id == ModelID && t.DepartmentId == DepartmentId select t;
                var Model = Models.FirstOrNull();
                if (Model == null) return "Can not find specified asset model.";

                string ModelName = Model.Model;
                string ModelLinks = Model.Links;

                Models = from t in dc.AssetModels where t.DepartmentId == DepartmentId && t.MakeId == MakeID && t.Model == ModelName select t;
                Model = Models.FirstOrNull();
                if (Model != null) return "'" + ModelName + "' asset model already exists in destination asset make. Copy operation is not allowed.";

                lib.bwa.bigWebDesk.LinqBll.Context.AssetModels NewModel = new lib.bwa.bigWebDesk.LinqBll.Context.AssetModels();
                NewModel.MakeId = MakeID;
                NewModel.DepartmentId = DepartmentId;
                NewModel.Model = ModelName;
                NewModel.Links = ModelLinks;

                dc.AssetModels.InsertOnSubmit(NewModel);
                dc.SubmitChanges();
                return null;
            }
        }
Пример #4
0
        public static int AddImportLog(Guid OrgId, int DepartmentId, int ImportedBy, System.Collections.Generic.List<int> ImportedAssteId)
        {
            if(ImportedAssteId==null || ImportedAssteId.Count<1) return 0;
            DateTime DTUpdated = DateTime.UtcNow;
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);

            int? ExistId = (from i in dc.AssetImports where i.DepartmentId==DepartmentId select (int?)i.ImportId).Max();
            int ImportId = 1;
            if(ExistId!=null && (int)ExistId>0) ImportId=((int)ExistId)+1;

            foreach (int id in ImportedAssteId)
            {
                lib.bwa.bigWebDesk.LinqBll.Context.AssetImports imp = new lib.bwa.bigWebDesk.LinqBll.Context.AssetImports()
                {
                    AssetId = id,
                    DepartmentId = DepartmentId,
                    DtUpdated = DTUpdated,
                    ImportId = ImportId,
                    UpdatedBy = ImportedBy
                };
                dc.AssetImports.InsertOnSubmit(imp);
            }
            dc.SubmitChanges();
            return ImportId;
        }
Пример #5
0
        public static string Move(Guid OrgId, int DepartmentId, int ModelID, int MakeID, out bool IsMerge)
        {
            IsMerge = false;
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Models = from t in dc.AssetModels where t.Id == ModelID && t.DepartmentId == DepartmentId select t;
                var Model = Models.FirstOrNull();
                if (Model == null) return "Can not find specified asset model.";

                Models = from m in dc.AssetModels where m.DepartmentId == DepartmentId && m.MakeId == MakeID && m.Model == Model.Model select m;
                var MergeModel = Models.FirstOrNull();
                if (MergeModel == null)
                {
                    Model.MakeId = MakeID;
                    var Assets = from a in dc.Assets where a.DepartmentId == DepartmentId && a.ModelId == ModelID select a;
                    foreach (var Asset in Assets)
                    {
                        Asset.MakeId = MakeID;
                    }
                }
                else
                {
                    string ret = Merge(dc, DepartmentId, ModelID, MergeModel.Id);
                    if (ret != null) return ret;
                    IsMerge = true;
                }
                dc.SubmitChanges();
                return null;
            }
        }
Пример #6
0
 public static void InsertClass(Guid OrganizationId, int DepartmentId, ClassData cd)
 {
     lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
     Context.Tbl_class c = new Context.Tbl_class();
     FillClass(cd, c);
     dc.Tbl_class.InsertOnSubmit(c);
     dc.SubmitChanges();
 }
Пример #7
0
 public static void InsertClass(Guid OrganizationId, int DepartmentId, ClassData cd)
 {
     lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
     Context.Tbl_class c = new Context.Tbl_class();
     FillClass(cd, c);
     dc.Tbl_class.InsertOnSubmit(c);
     dc.SubmitChanges();
 }
Пример #8
0
 public static void UpdateClass(Guid OrganizationId, int DepartmentId, int ClassId, ClassData cd)
 {
     lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
     var c = dc.Tbl_class.Where(cc => cc.Id == ClassId && cc.Company_id == DepartmentId).FirstOrNull();
     if (c == null) return;
     FillClass(cd, c);
     dc.SubmitChanges();
 }
Пример #9
0
 public static string Merge(Guid OrgId, int DepartmentId, int SourceModelID, int DestModelID)
 {
     using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
     {
         Merge(dc, DepartmentId, SourceModelID, DestModelID);
         dc.SubmitChanges();
         return null;
     }
 }
Пример #10
0
 public static string Merge(Guid OrgId, int DepartmentId, int SourceModelID, int DestModelID)
 {
     using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
     {
         Merge(dc, DepartmentId, SourceModelID, DestModelID);
         dc.SubmitChanges();
         return(null);
     }
 }
Пример #11
0
        public static string Delete(Guid OrgId, int DepartmentId, int CategoryID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                int RetCode;

                var Types = from t in dc.AssetTypes where t.CategoryId == CategoryID && t.DepartmentId == DepartmentId select t;
                foreach (var Type in Types)
                {
                    var Makes = from m in dc.AssetMakes where m.TypeId == Type.Id && m.DepartmentId == DepartmentId select m;
                    foreach (var Make in Makes)
                    {
                        var Models = from m in dc.AssetModels where m.MakeId == Make.Id && m.DepartmentId == DepartmentId select m;
                        foreach (var m in Models)
                        {
                            RetCode = dc.Sp_DeleteAssetModel(DepartmentId, m.Id);
                            if (RetCode != 1)
                            {
                                return("Can not delete '" + m.Model + "' model. Assets live under this model.");
                            }
                        }
                        RetCode = dc.Sp_DeleteAssetMake(DepartmentId, Make.Id);
                        if (RetCode != 1)
                        {
                            return("Can not delete '" + Make.Make + "' make. Assets live under this make.");
                        }
                    }
                    RetCode = dc.Sp_DeleteAssetType(DepartmentId, Type.Id);
                    if (RetCode == 3)
                    {
                        return("Can not delete '" + Type.Name + "' type. Custom Fields Setup that must be removed first.");
                    }
                    if (RetCode != 1)
                    {
                        return("Can not delete '" + Type.Name + "' type. Assets live under this type.");
                    }
                }

                RetCode = dc.Sp_DeleteAssetCategory(DepartmentId, CategoryID);
                if (RetCode != 1)
                {
                    string CatName = (from c in dc.AssetCategories where c.DepartmentId == DepartmentId && c.Id == CategoryID select c.Name).FirstOrNull();
                    if (!string.IsNullOrEmpty(CatName))
                    {
                        CatName = "'" + CatName + "'";
                    }
                    else
                    {
                        CatName = "the";
                    }
                    return("Can not delete " + CatName + " category. Assets live under this category.");
                }

                dc.SubmitChanges();
                return(null);
            }
        }
Пример #12
0
 public static string Delete(Guid OrgId, int DepartmentId, int ModelID)
 {
     using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
     {
         int RetCode = dc.Sp_DeleteAssetModel(DepartmentId, ModelID);
         if (RetCode != 1) return "Can not delete this asset model. Assets are exist for this model.";
         dc.SubmitChanges();
         return null;
     }
 }
Пример #13
0
        public static lib.bwa.bigWebDesk.LinqBll.Context.Sp_SelectTypePropertyMergeConflictResult[] GetTypePropertyMergeConflict(Guid OrgId, int DepartmentId, int SourceTypeID, int DestTypeID, bool MergeTypeConflict)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);
            var ConflictInfo = dc.Sp_SelectTypePropertyMergeConflict(DepartmentId, SourceTypeID, DestTypeID, MergeTypeConflict);

            lib.bwa.bigWebDesk.LinqBll.Context.Sp_SelectTypePropertyMergeConflictResult[] ret = ConflictInfo.ToArray();
            if (ret == null || ret.Length < 1)
            {
                return(null);
            }
            return(ret);
        }
Пример #14
0
        public static void UpdateClass(Guid OrganizationId, int DepartmentId, int ClassId, ClassData cd)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
            var c = dc.Tbl_class.Where(cc => cc.Id == ClassId && cc.Company_id == DepartmentId).FirstOrNull();

            if (c == null)
            {
                return;
            }
            FillClass(cd, c);
            dc.SubmitChanges();
        }
Пример #15
0
        public static string Move(Guid OrgId, int DepartmentId, int SourceFolderId, int DestFolderId)
        {
            if (SourceFolderId == 0)
            {
                return("Can not move 'bigWebApps & Support' root folder.");
            }

            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var SourceFolders = from f in dc.Folders where f.DId == DepartmentId && f.Id == SourceFolderId select f;
                var Source        = SourceFolders.FirstOrNull();
                if (Source == null)
                {
                    return("Can not find the source folder.");
                }

                if (Source.ParentId == DestFolderId)
                {
                    return(null);
                }

                var DestFolderChild = (from f in dc.Folders where f.DId == DepartmentId && f.ParentId == DestFolderId && f.VchName == Source.VchName && f.Id != Source.Id select f).FirstOrNull();
                if (DestFolderChild == null)
                {
                    if (DestFolderId != 0)
                    {
                        var DestFolders = from f in dc.Folders where f.DId == DepartmentId && f.Id == DestFolderId select f;
                        var Dest        = DestFolders.FirstOrNull();
                        if (Dest == null)
                        {
                            return("Can not find the destination folder.");
                        }

                        if (Dest.ParentId == SourceFolderId)
                        {
                            Dest.ParentId = Source.ParentId;
                        }
                    }
                    Source.ParentId = DestFolderId;
                }
                else
                {
                    string rez = Merge(dc, DepartmentId, SourceFolderId, DestFolderChild.Id);
                    if (rez != null)
                    {
                        return(rez);
                    }
                }
                dc.SubmitChanges();
                return(null);
            }
        }
Пример #16
0
 public static string Delete(Guid OrgId, int DepartmentId, int ModelID)
 {
     using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
     {
         int RetCode = dc.Sp_DeleteAssetModel(DepartmentId, ModelID);
         if (RetCode != 1)
         {
             return("Can not delete this asset model. Assets are exist for this model.");
         }
         dc.SubmitChanges();
         return(null);
     }
 }
Пример #17
0
        public static string Delete(Guid OrgId, int DepartmentId, int TypeID)
        {
            try
            {
                using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
                {
                    int RetCode;
                    var Makes = from m in dc.AssetMakes where m.TypeId == TypeID && m.DepartmentId == DepartmentId select m;
                    foreach (var Make in Makes)
                    {
                        var Models = from m in dc.AssetModels where m.MakeId == Make.Id && m.DepartmentId == DepartmentId select m;
                        foreach (var m in Models)
                        {
                            RetCode = dc.Sp_DeleteAssetModel(DepartmentId, m.Id);
                            if (RetCode != 1)
                            {
                                return("Can not delete '" + m.Model + "' asset model. Assets live under this model.");
                            }
                        }
                        RetCode = dc.Sp_DeleteAssetMake(DepartmentId, Make.Id);
                        if (RetCode != 1)
                        {
                            return("Can not delete '" + Make.Make + "' asset make. Assets live under this make.");
                        }
                    }

                    RetCode = dc.Sp_DeleteAssetType(DepartmentId, TypeID);
                    if (RetCode == 3)
                    {
                        return("Can not delete this asset type. Custom Fields Setup that must be removed first.");
                    }
                    if (RetCode != 1)
                    {
                        return("Can not delete this asset type. Assets live under this type.");
                    }

                    dc.SubmitChanges();
                    return(null);
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                return("Can not delete this. Assets live under it.");
            }
            catch (Exception ex)
            {
                return("Can not delete this. Unexpected error. Contact system admnistrator.");
            }
            return(null);
        }
Пример #18
0
 public static IEnumerable<TicketLevelData> SelectLevels(Guid OrganizationId, int DepartmentId, string where)
 {
     //new TicketDataType();
     if (where == string.Empty) where = null;
     lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
     var lvs = dc.Sp_SelectTicketLevelsDynamicWhere(DepartmentId, where).ToList();
     var lds = lvs.Select<Context.Sp_SelectTicketLevelsDynamicWhereResult, TicketLevelData>(l => new TicketLevelData {
         level = l.TintLevel==null?0:(byte)l.TintLevel,
         name = l.LevelName,
         is_default = l.BitDefault,
         description = l.Description
     });
     return lds;
 }
Пример #19
0
        public static string Merge(Guid OrgId, int DepartmentId, int SourceCategoryID, int DestCategoryID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var MergeInfo =
                    from SourceType in dc.AssetTypes
                    join DestType in dc.AssetTypes on new
                {
                    SDID             = SourceType.DepartmentId,
                    DDID             = DepartmentId,
                    SourceCategoryID = SourceType.CategoryId,
                    DestCategoryID,
                    SourceType.Name
                } equals new
                {
                    SDID = DepartmentId,
                    DDID = DestType.DepartmentId,
                    SourceCategoryID,
                    DestCategoryID = DestType.CategoryId,
                    DestType.Name
                }

                orderby SourceType.Name, SourceType.Id, DestType.Name, DestType.Id
                    select new { SourceType, DestType };


                foreach (var mi in MergeInfo)
                {
                    AssetTypes.Merge(dc, DepartmentId, mi.SourceType.Id, mi.DestType.Id);
                }

                var Types = from t in dc.AssetTypes where t.DepartmentId == DepartmentId && t.CategoryId == SourceCategoryID select t;
                foreach (var type in Types)
                {
                    type.CategoryId = DestCategoryID;
                }

                var Assets = from a in dc.Assets where a.DepartmentId == DepartmentId && a.CategoryId == SourceCategoryID select a;
                foreach (var Asset in Assets)
                {
                    Asset.CategoryId = DestCategoryID;
                }

                var Categories = from c in dc.AssetCategories where c.DepartmentId == DepartmentId && c.Id == SourceCategoryID select c;
                dc.AssetCategories.DeleteAllOnSubmit(Categories);

                dc.SubmitChanges();
                return(null);
            }
        }
Пример #20
0
        public static string Merge(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentId, int SourceModelID, int DestModelID)
        {
            var Assets = from a in dc.Assets where a.DepartmentId == DepartmentId && a.ModelId == SourceModelID select a;

            foreach (var Asset in Assets)
            {
                Asset.ModelId = DestModelID;
            }

            var Models = from m in dc.AssetModels where m.DepartmentId == DepartmentId && m.Id == SourceModelID select m;

            dc.AssetModels.DeleteAllOnSubmit(Models);
            return(null);
        }
Пример #21
0
        public static void Rename(Guid OrgId, int DepartmentId, int CategoryID, string Name)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Categories = from c in dc.AssetCategories where c.Id == CategoryID && c.DepartmentId == DepartmentId select c;
                var Category   = Categories.FirstOrNull();
                if (Category == null)
                {
                    return;
                }

                Category.Name = Name;
                dc.SubmitChanges();
            }
        }
Пример #22
0
        static void SaveComputers(int DepartmentID, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, AssetComputerData data)
        {
            var lds = (
                from d in dc.AssetComputers
                where d.DepartmentId == DepartmentID && d.AssetId == data.AssetNumber
                select d
                ).FirstOrNull();

            if (lds == null)
            {
                lds = new lib.bwa.bigWebDesk.LinqBll.Context.AssetComputers();
                dc.AssetComputers.InsertOnSubmit(lds);
            }
            CopyComputers(data, lds, DepartmentID, data.AssetNumber);
        }
Пример #23
0
        public static string AssignTicket(Guid OrgId, int DepartmentId, int FolderId, int TicketId)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Folder = (from f in dc.Folders where f.DId == DepartmentId && f.Id == FolderId select f).FirstOrNull();
                if (Folder == null) return "Can not find the folder. Maybe other user delete this folder. ";

                var Tiket = (from t in dc.Tbl_ticket where t.Company_id == DepartmentId && t.Id == TicketId select t).FirstOrNull();
                if (Tiket == null) return "Can not find the ticket. Maybe other user delete this ticket. ";
                Tiket.Folder_id = FolderId;
                Tiket.UpdatedTime = DateTime.UtcNow;
                dc.SubmitChanges();
                return null;
            }
        }
Пример #24
0
        public static string Merge(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentId, int SourceMakeID, int DestMakeID)
        {
            var MergeInfo =
                from SourceModel in dc.AssetModels
                join DestModel in dc.AssetModels on new
            {
                SourceDID    = SourceModel.DepartmentId,
                DestDID      = DepartmentId,
                SourceMakeID = SourceModel.MakeId,
                DestMakeID,
                SourceModel.Model
            } equals new
            {
                SourceDID = DepartmentId,
                DestDID   = DestModel.DepartmentId,
                SourceMakeID,
                DestMakeID = DestModel.MakeId,
                DestModel.Model
            }
            select new { SourceModel, DestModel };


            foreach (var mi in MergeInfo)
            {
                AssetModels.Merge(dc, DepartmentId, mi.SourceModel.Id, mi.DestModel.Id);
            }

            var Models = from m in dc.AssetModels where m.DepartmentId == DepartmentId && m.MakeId == SourceMakeID select m;

            foreach (var Model in Models)
            {
                Model.MakeId = DestMakeID;
            }

            var Assets = from a in dc.Assets where a.DepartmentId == DepartmentId && a.MakeId == SourceMakeID select a;

            foreach (var a in Assets)
            {
                a.MakeId = DestMakeID;
            }

            var Makes = from m in dc.AssetMakes where m.DepartmentId == DepartmentId && m.Id == SourceMakeID select m;

            dc.AssetMakes.DeleteAllOnSubmit(Makes);

            dc.SubmitChanges();
            return(null);
        }
Пример #25
0
        public static int GetStatus(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, string Name)
        {
            if (string.IsNullOrEmpty(Name))
            {
                Name = "Active";
            }
            IQueryable <int> IDs;

            IDs = from d in dc.AssetStatus where d.VchStatus == Name select d.Id;
            foreach (int ID in IDs)
            {
                return(ID);
            }

            throw new Exception("Asset Status name must be specify");
        }
Пример #26
0
        public static int?GetAccountId(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentID, string Name)
        {
            if (string.IsNullOrEmpty(Name))
            {
                return(null);
            }
            IQueryable <int> IDs;

            IDs = from d in dc.Accounts where d.DId == DepartmentID && d.VchName == Name select d.Id;
            foreach (int ID in IDs)
            {
                return(ID);
            }

            return(null);
        }
Пример #27
0
        public static string Merge(Guid OrgId, int DepartmentId, int SourceFolderId, int DestFolderId)
        {
            if (SourceFolderId == 0)
            {
                return("Can not merge 'bigWebApps & Support' root folder.");
            }
            if (DestFolderId == 0)
            {
                return("Can not merge to 'bigWebApps & Support' root folder.");
            }

            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                return(Merge(dc, DepartmentId, SourceFolderId, DestFolderId));
            }
        }
Пример #28
0
        private static void CopyPrinters(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentId, int OldAssetId, int NewAssetId)
        {
            var OldPrinters = (from d in dc.AssetComputerPrinters where d.DepartmentId == DepartmentId && d.AssetId == OldAssetId select d).ToList();

            foreach (var d in OldPrinters)
            {
                var NewD = new lib.bwa.bigWebDesk.LinqBll.Context.AssetComputerPrinters()
                {
                    DepartmentId  = DepartmentId,
                    AssetId       = NewAssetId,
                    PrinterDriver = d.PrinterDriver,
                    PrinterName   = d.PrinterName,
                    PrinterPort   = d.PrinterPort
                };
                dc.AssetComputerPrinters.InsertOnSubmit(NewD);
            }
        }
Пример #29
0
        private static void CopySoftwares(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentId, int OldAssetId, int NewAssetId)
        {
            var OldSoftwares = (from d in dc.AssetComputerSoftwares where d.DepartmentId == DepartmentId && d.AssetId == OldAssetId select d).ToList();

            foreach (var d in OldSoftwares)
            {
                var NewD = new lib.bwa.bigWebDesk.LinqBll.Context.AssetComputerSoftwares()
                {
                    DepartmentId      = DepartmentId,
                    AssetId           = NewAssetId,
                    SoftwareName      = d.SoftwareName,
                    SoftwarePublisher = d.SoftwarePublisher,
                    SoftwareVersion   = d.SoftwareVersion
                };
                dc.AssetComputerSoftwares.InsertOnSubmit(NewD);
            }
        }
Пример #30
0
        public static IEnumerable <TicketLevelData> SelectLevels(Guid OrganizationId, int DepartmentId, string where)
        {
            //new TicketDataType();
            if (where == string.Empty)
            {
                where = null;
            }
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
            var lvs = dc.Sp_SelectTicketLevelsDynamicWhere(DepartmentId, where).ToList();
            var lds = lvs.Select <Context.Sp_SelectTicketLevelsDynamicWhereResult, TicketLevelData>(l => new TicketLevelData {
                level       = l.TintLevel == null?0:(byte)l.TintLevel,
                name        = l.LevelName,
                is_default  = l.BitDefault,
                description = l.Description
            });

            return(lds);
        }
Пример #31
0
        public static string Delete(Guid OrgId, int DepartmentId, int FolderId)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var folders = from f in dc.Folders where f.DId == DepartmentId && f.Id == FolderId select f;
                var folder = folders.FirstOrNull();
                if (folder == null) return "Can not find the folder.";

                int SubFolderCount = dc.Folders.Count(f=>f.DId == DepartmentId && f.ParentId == FolderId);
                if (SubFolderCount > 0) return "The folder has " + SubFolderCount + " subfolders. Please delete all subfolders first.";

                int TicketsCount = dc.Tbl_ticket.Count(t=>t.Company_id==DepartmentId && t.Folder_id==FolderId);
                if(TicketsCount>1) return "The folder has "+TicketsCount+" tickets. Please merge this folder with another one or delete all folder tickets first.";

                dc.Folders.DeleteOnSubmit(folder);
                dc.SubmitChanges();
                return null;
            }
        }
Пример #32
0
        public static string Delete(Guid OrgId, int DepartmentId, int MakeID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                int RetCode;
                var Models = from m in dc.AssetModels where m.MakeId == MakeID && m.DepartmentId == DepartmentId select m;
                foreach (var m in Models)
                {
                    RetCode = dc.Sp_DeleteAssetModel(DepartmentId, m.Id);
                    if (RetCode != 1) return "Can not delete '" + m.Model + "' asset model. Assets are exist for this model.";
                }

                RetCode = dc.Sp_DeleteAssetMake(DepartmentId, MakeID);
                if (RetCode != 1) return "Can not delete this asset make. Assets are exist for this make.";

                dc.SubmitChanges();
                return null;
            }
        }
Пример #33
0
        public static IQueryable<stFolderInfo> List(Guid OrgId, int DepartmentId, out string DepartmentName)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);

            DepartmentName = (from c in dc.Tbl_company where c.Company_id == DepartmentId select c.Company_name).FirstOrNull();

            IQueryable<stFolderInfo> ret =
                from f in dc.Folders
                where f.DId == DepartmentId
                orderby f.VchName
                select new stFolderInfo {
                    Id = f.Id,
                    DepartmentId = f.DId,
                    ParentId = f.ParentId ==null ? 0 : f.ParentId,
                    VchName = f.VchName,
                    TicketOpen = (dc.Tbl_ticket.Where(t => t.Company_id == DepartmentId && t.Folder_id == f.Id && t.Status != "Closed").Count()),
                };

            return ret;
        }
Пример #34
0
        public static IQueryable <stFolderInfo> List(Guid OrgId, int DepartmentId, out string DepartmentName)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);

            DepartmentName = (from c in dc.Tbl_company where c.Company_id == DepartmentId select c.Company_name).FirstOrNull();

            IQueryable <stFolderInfo> ret =
                from f in dc.Folders
                where f.DId == DepartmentId
                orderby f.VchName
                select new stFolderInfo {
                Id           = f.Id,
                DepartmentId = f.DId,
                ParentId     = f.ParentId == null ? 0 : f.ParentId,
                VchName      = f.VchName,
                TicketOpen   = (dc.Tbl_ticket.Where(t => t.Company_id == DepartmentId && t.Folder_id == f.Id && t.Status != "Closed").Count()),
            };

            return(ret);
        }
Пример #35
0
        public static CompanyInfo Get(string OrgAlias, string InstAlias, Guid OrgGuid, Guid InstGuid)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.Create(OrgAlias, InstAlias, OrgGuid, InstGuid);
            CompanyInfo ret = new CompanyInfo();

            if (dc == null || dc.OrganizationId == null || dc.OrganizationId == Guid.Empty)
            {
                return(ret);
            }
            if (dc.InstaceId != null)
            {
                ret.InstanceId = (Guid)dc.InstaceId;
            }
            ret.OrganizationId = (Guid)dc.OrganizationId;
            if (dc.DepartmentId != null)
            {
                ret.DepartmentId = (int)dc.DepartmentId;
            }
            return(ret);
        }
Пример #36
0
        public static string Merge(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentId, int SourceFolderId, int DestFolderId)
        {
            var SourceFolders = from f in dc.Folders where f.DId == DepartmentId && f.Id == SourceFolderId select f;
            var Source        = SourceFolders.FirstOrNull();

            if (Source == null)
            {
                return("Can not find the source folder.");
            }

            var DestFolders = from f in dc.Folders where f.DId == DepartmentId && f.Id == DestFolderId select f;
            var Dest        = DestFolders.FirstOrNull();

            if (Dest == null)
            {
                return("Can not find the destination folder.");
            }

            if (Dest.ParentId == SourceFolderId)
            {
                Dest.ParentId = Source.ParentId;
            }

            var SourceSubFolders = from f in dc.Folders where f.DId == DepartmentId && f.ParentId == SourceFolderId select f;

            foreach (var sub in SourceSubFolders)
            {
                sub.ParentId = DestFolderId;
            }

            var SourceTickets = from t in dc.Tbl_ticket where t.Company_id == DepartmentId && t.Folder_id == SourceFolderId select t;

            foreach (var t in SourceTickets)
            {
                t.Folder_id = DestFolderId;
            }

            dc.Folders.DeleteOnSubmit(Source);
            dc.SubmitChanges();
            return(null);
        }
Пример #37
0
        public static string AssignTicket(Guid OrgId, int DepartmentId, int FolderId, int TicketId)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Folder = (from f in dc.Folders where f.DId == DepartmentId && f.Id == FolderId select f).FirstOrNull();
                if (Folder == null)
                {
                    return("Can not find the folder. Maybe other user delete this folder. ");
                }

                var Tiket = (from t in dc.Tbl_ticket where t.Company_id == DepartmentId && t.Id == TicketId select t).FirstOrNull();
                if (Tiket == null)
                {
                    return("Can not find the ticket. Maybe other user delete this ticket. ");
                }
                Tiket.Folder_id   = FolderId;
                Tiket.UpdatedTime = DateTime.UtcNow;
                dc.SubmitChanges();
                return(null);
            }
        }
Пример #38
0
        public static void GetNames(Guid OrgId, int DepartmentId, int TypeID, out string TypeName, out string CategoryName)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);
            var r = (
                from t in dc.AssetTypes
                join c in dc.AssetCategories on new { t.DepartmentId, t.CategoryId } equals new { c.DepartmentId, CategoryId = c.Id }
                where t.DepartmentId == DepartmentId && t.Id == TypeID
                select new { TypeName = t.Name, CategoryName = c.Name }
                ).FirstOrNull();

            if (r == null)
            {
                TypeName     = null;
                CategoryName = null;
            }
            else
            {
                TypeName     = r.TypeName;
                CategoryName = r.CategoryName;
            }
        }
Пример #39
0
        public static void GetNames(Guid OrgId, int DepartmentId, int TypeID, out string TypeName, out string CategoryName)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);
            var r = (
                from t in dc.AssetTypes
                join c in dc.AssetCategories on new { t.DepartmentId, t.CategoryId } equals new { c.DepartmentId, CategoryId = c.Id }
                where t.DepartmentId == DepartmentId && t.Id == TypeID
                select new { TypeName = t.Name, CategoryName = c.Name }
                ).FirstOrNull();

            if (r == null)
            {
                TypeName = null;
                CategoryName = null;
            }
            else
            {
                TypeName = r.TypeName;
                CategoryName = r.CategoryName;
            }
        }
Пример #40
0
        public static string Delete(Guid OrgId, int DepartmentId, int CategoryID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                int RetCode;

                var Types = from t in dc.AssetTypes where t.CategoryId == CategoryID && t.DepartmentId == DepartmentId select t;
                foreach (var Type in Types)
                {
                    var Makes = from m in dc.AssetMakes where m.TypeId == Type.Id && m.DepartmentId == DepartmentId select m;
                    foreach (var Make in Makes)
                    {
                        var Models = from m in dc.AssetModels where m.MakeId == Make.Id && m.DepartmentId == DepartmentId select m;
                        foreach (var m in Models)
                        {
                            RetCode = dc.Sp_DeleteAssetModel(DepartmentId, m.Id);
                            if (RetCode != 1) return "Can not delete '" + m.Model + "' model. Assets live under this model.";
                        }
                        RetCode = dc.Sp_DeleteAssetMake(DepartmentId, Make.Id);
                        if (RetCode != 1) return "Can not delete '" + Make.Make + "' make. Assets live under this make.";
                    }
                    RetCode = dc.Sp_DeleteAssetType(DepartmentId, Type.Id);
                    if (RetCode == 3) return "Can not delete '" + Type.Name + "' type. Custom Fields Setup that must be removed first.";
                    if (RetCode != 1) return "Can not delete '" + Type.Name + "' type. Assets live under this type.";
                }

                RetCode = dc.Sp_DeleteAssetCategory(DepartmentId, CategoryID);
                if (RetCode != 1)
                {
                    string CatName = (from c in dc.AssetCategories where c.DepartmentId==DepartmentId && c.Id==CategoryID select c.Name).FirstOrNull();
                    if(!string.IsNullOrEmpty(CatName)) CatName="'"+CatName+"'";
                    else CatName="the";
                    return "Can not delete "+CatName+" category. Assets live under this category.";
                }

                dc.SubmitChanges();
                return null;
            }
        }
Пример #41
0
        public static int? AddChild(Guid OrgId, int DepartmentId, int FolderId, string ChildName)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                lib.bwa.bigWebDesk.LinqBll.Context.Folders folder;
                if (FolderId != 0)
                {
                    var folders = from f in dc.Folders where f.DId == DepartmentId && f.Id == FolderId select f;
                    folder = folders.FirstOrNull();
                    if (folder == null) return null;
                }

                folder = new lib.bwa.bigWebDesk.LinqBll.Context.Folders();
                folder.DId = DepartmentId;
                folder.ParentId = FolderId;
                folder.VchName = ChildName.Length>50 ? ChildName.Substring(0,50) : ChildName;
                dc.Folders.InsertOnSubmit(folder);

                dc.SubmitChanges();
                return folder.Id;
            }
        }
Пример #42
0
        public static string Delete(Guid OrgId, int DepartmentId, int TypeID)
        {
            try
            {
                using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
                {
                    int RetCode;
                    var Makes = from m in dc.AssetMakes where m.TypeId == TypeID && m.DepartmentId == DepartmentId select m;
                    foreach (var Make in Makes)
                    {
                        var Models = from m in dc.AssetModels where m.MakeId == Make.Id && m.DepartmentId == DepartmentId select m;
                        foreach (var m in Models)
                        {
                            RetCode = dc.Sp_DeleteAssetModel(DepartmentId, m.Id);
                            if (RetCode != 1) return "Can not delete '" + m.Model + "' asset model. Assets live under this model.";
                        }
                        RetCode = dc.Sp_DeleteAssetMake(DepartmentId, Make.Id);
                        if (RetCode != 1) return "Can not delete '" + Make.Make + "' asset make. Assets live under this make.";
                    }

                    RetCode = dc.Sp_DeleteAssetType(DepartmentId, TypeID);
                    if (RetCode == 3) return "Can not delete this asset type. Custom Fields Setup that must be removed first.";
                    if (RetCode != 1) return "Can not delete this asset type. Assets live under this type.";

                    dc.SubmitChanges();
                    return null;
                }
            }
            catch (System.Data.SqlClient.SqlException  sqlEx)
            {
                return "Can not delete this. Assets live under it.";
            }
            catch (Exception ex)
            {
                return "Can not delete this. Unexpected error. Contact system admnistrator.";
            }
            return null;
        }
Пример #43
0
        public static void InsertLogin(Guid OrganizationId, int DepartmentId, LoginData ld)
        {
            if (string.IsNullOrEmpty(ld.email))
            {
                return;
            }
            ld.email = ld.email.ToLower();
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
            var l = (from ll in dc.Tbl_Logins where ll.Email.ToLower() == ld.email select ll).FirstOrNull();

            if (l == null)
            {
                l = new Context.Tbl_Logins();
                FillLogin(ld, l);
                dc.Tbl_Logins.InsertOnSubmit(l);
                dc.SubmitChanges();
            }
            else
            {
                FillLogin(ld, l);
            }
            var j = (from jj in dc.Tbl_LoginCompanyJunc where jj.Company_id == DepartmentId && jj.Login_id == l.Id select jj).FirstOrNull();

            if (j == null)
            {
                j            = new Context.Tbl_LoginCompanyJunc();
                j.Company_id = DepartmentId;
                j.Login_id   = l.Id;
                FillJunk(ld, j);
                dc.Tbl_LoginCompanyJunc.InsertOnSubmit(j);
            }
            else
            {
                FillJunk(ld, j);
            }

            dc.SubmitChanges();
        }
Пример #44
0
        private static void CopyLogicalDrives(lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, int DepartmentId, int OldAssetId, int NewAssetId)
        {
            var OldLogicalDrives = (from d in dc.AssetComputerLogicalDrives where d.DepartmentId == DepartmentId && d.AssetId == OldAssetId select d).ToList();

            foreach (var d in OldLogicalDrives)
            {
                var NewD = new lib.bwa.bigWebDesk.LinqBll.Context.AssetComputerLogicalDrives()
                {
                    DepartmentId = DepartmentId,
                    AssetId      = NewAssetId,
                    DeviceID     = d.DeviceID,
                    FileSystem   = d.FileSystem,
                    SizeGB       = d.SizeGB,
                    FreeSpaceGB  = d.FreeSpaceGB,
                    Description  = d.Description,
                    VolumeName   = d.VolumeName,
                    VolumeSerial = d.VolumeSerial,
                    Compressed   = d.Compressed,
                    DriveType    = d.DriveType
                };
                dc.AssetComputerLogicalDrives.InsertOnSubmit(NewD);
            }
        }
Пример #45
0
        public static string Copy(Guid OrgId, int DepartmentId, int TypeID, int CategoryID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Types = from t in dc.AssetTypes where t.Id == TypeID && t.DepartmentId == DepartmentId select t;
                var Type = Types.FirstOrNull();
                if (Type == null) return "Can not find specified asset type.";

                Types = from t in dc.AssetTypes where t.DepartmentId == DepartmentId && t.CategoryId == CategoryID && t.Name == Type.Name select t;
                var ExistType = Types.FirstOrNull();
                if (ExistType != null) return "This asset type exist in destination asset category.";

                lib.bwa.bigWebDesk.LinqBll.Context.AssetTypes NewType = new lib.bwa.bigWebDesk.LinqBll.Context.AssetTypes();
                NewType.CategoryId = CategoryID;
                NewType.DepartmentId = DepartmentId;
                NewType.ConfigCustFields = Type.ConfigCustFields;
                NewType.Name = Type.Name;

                dc.AssetTypes.InsertOnSubmit(NewType);
                dc.SubmitChanges();
                return null;
            }
        }
Пример #46
0
        public static void DeleteAssetComputer(Guid OrgId, int DepartmentID, AssetComputerData data)
        {
            if (data.AssetNumber == 0) return;
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentID);

            var lds = from d in dc.AssetComputerLogicalDrives where d.DepartmentId == DepartmentID && d.AssetId == data.AssetNumber select d;
            dc.AssetComputerLogicalDrives.DeleteAllOnSubmit(lds);

            var ps = from p in dc.AssetComputerProcessors where p.DepartmentId == DepartmentID && p.AssetId == data.AssetNumber select p;
            dc.AssetComputerProcessors.DeleteAllOnSubmit(ps);

            var prs = from p in dc.AssetComputerPrinters where p.DepartmentId == DepartmentID && p.AssetId == data.AssetNumber select p;
            dc.AssetComputerPrinters.DeleteAllOnSubmit(prs);

            var ss = from p in dc.AssetComputerSoftwares where p.DepartmentId == DepartmentID && p.AssetId == data.AssetNumber select p;
            dc.AssetComputerSoftwares.DeleteAllOnSubmit(ss);

            var ac = from p in dc.AssetComputers where p.DepartmentId == DepartmentID && p.AssetId == data.AssetNumber select p;
            dc.AssetComputers.DeleteAllOnSubmit(ac);

            var a = from p in dc.Assets where p.DepartmentId == DepartmentID && p.Id == data.AssetNumber select p;
            dc.Assets.DeleteAllOnSubmit(a);
        }
Пример #47
0
        public static string Move(Guid OrgId, int DepartmentId, int MakeID, int TypeID, out bool IsMerge)
        {
            IsMerge = false;
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Makes = from m in dc.AssetMakes where m.Id == MakeID && m.DepartmentId == DepartmentId select m;
                var Make  = Makes.FirstOrNull();
                if (Make == null)
                {
                    return("Can not find specified asset make.");
                }

                Makes = from t in dc.AssetMakes where t.DepartmentId == DepartmentId && t.TypeId == TypeID && t.Make == Make.Make select t;
                var MergeMake = Makes.FirstOrNull();
                if (MergeMake == null)
                {
                    Make.TypeId = TypeID;
                    var Assets = from a in dc.Assets where a.DepartmentId == DepartmentId && a.MakeId == MakeID select a;
                    foreach (var Asset in Assets)
                    {
                        Asset.TypeId = TypeID;
                    }
                }
                else
                {
                    string ret = Merge(dc, DepartmentId, MakeID, MergeMake.Id);
                    if (ret != null)
                    {
                        return(ret);
                    }
                    IsMerge = true;
                }

                dc.SubmitChanges();
                return(null);
            }
        }
Пример #48
0
        public static IQueryable <CategoryTypeMakeModel> GetCategoryTypeMakeModel(Guid OrgId, int DepartmentId)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);

            IQueryable <CategoryTypeMakeModel> ret =

                from category in dc.AssetCategories
                join jType in dc.AssetTypes on new { DepartmentId, CategoryId = category.Id } equals new { jType.DepartmentId, jType.CategoryId } into iType

            from type in iType.DefaultIfEmpty()
            join jMake in dc.AssetMakes on new { DepartmentId = (int)DepartmentId, TypeId = (int)type.Id } equals new { DepartmentId = (int)jMake.DepartmentId, TypeId = (int)jMake.TypeId } into iMake

            from make in iMake.DefaultIfEmpty()
            join jModel in dc.AssetModels on new { DepartmentId, MakeId = make.Id } equals new { DepartmentId = jModel.DepartmentId, jModel.MakeId } into iModel

            from model in iModel.DefaultIfEmpty()

            where category.DepartmentId == DepartmentId

            orderby category.Name, category.Id, type.Name, type.Id, make.Make, make.Id, model.Model, model.Id

                                               select new CategoryTypeMakeModel
            {
                CategoryID           = category.Id,
                CategoryName         = category.Name,
                TypeID               = type.Id,
                TypeName             = type.Name,
                TypeConfigCustFields = type.ConfigCustFields,
                MakeID               = make.Id,
                MakeName             = make.Make,
                ModelID              = model.Id,
                ModelName            = model.Model,
                ModelLinks           = model.Links
            };

            return(ret);
        }
Пример #49
0
        public static IQueryable<CategoryTypeMakeModel> GetCategoryTypeMakeModel(Guid OrgId, int DepartmentId)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);

            IQueryable<CategoryTypeMakeModel> ret =

                from category in dc.AssetCategories
                join jType in dc.AssetTypes on new { DepartmentId, CategoryId = category.Id } equals new { jType.DepartmentId, jType.CategoryId } into iType

                from type in iType.DefaultIfEmpty()
                join jMake in dc.AssetMakes on new { DepartmentId = (int)DepartmentId, TypeId = (int)type.Id } equals new { DepartmentId = (int)jMake.DepartmentId, TypeId = (int)jMake.TypeId } into iMake

                from make in iMake.DefaultIfEmpty()
                join jModel in dc.AssetModels on new { DepartmentId, MakeId = make.Id } equals new { DepartmentId = jModel.DepartmentId, jModel.MakeId } into iModel

                from model in iModel.DefaultIfEmpty()

                where category.DepartmentId == DepartmentId

                orderby category.Name, category.Id, type.Name, type.Id, make.Make, make.Id, model.Model, model.Id

                select new CategoryTypeMakeModel
                {
                    CategoryID = category.Id,
                    CategoryName = category.Name,
                    TypeID = type.Id,
                    TypeName = type.Name,
                    TypeConfigCustFields = type.ConfigCustFields,
                    MakeID = make.Id,
                    MakeName = make.Make,
                    ModelID = model.Id,
                    ModelName = model.Model,
                    ModelLinks = model.Links
                };

            return ret;
        }
Пример #50
0
        static void SaveComputerSoftwares(int DepartmentID, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc, AssetComputerData data)
        {
            var lds = (
                from d in dc.AssetComputerSoftwares
                where d.DepartmentId == DepartmentID && d.AssetId == data.AssetNumber
                select d
                ).ToList();

            var ss = data.Softwares.ToList();

            foreach (var ld in lds)
            {
                bool exist = false;
                for (int i = 0; i < ss.Count; i++)
                {
                    var s = ss[i];
                    if (ld.SoftwareName == s.SoftwareName && ld.SoftwarePublisher == s.SoftwarePublisher && ld.SoftwareVersion == s.SoftwareVersion)
                    {
                        exist = true;
                        ss.Remove(s);
                        i--;
                    }
                }
                if (exist)
                {
                    continue;
                }
                dc.AssetComputerSoftwares.DeleteOnSubmit(ld);
            }

            foreach (var s in ss)
            {
                var New = new lib.bwa.bigWebDesk.LinqBll.Context.AssetComputerSoftwares();
                CopyComputerSoftware(s, New, DepartmentID, data.AssetNumber);
                dc.AssetComputerSoftwares.InsertOnSubmit(New);
            }
        }
Пример #51
0
        public static IEnumerable<ClassData> SelectClasses(Guid OrganizationId, int DepartmentId, string where)
        {
            if (where == string.Empty) where = null;
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrganizationId, DepartmentId);
            var c = dc.Sp_SelectClassesDynamicWhere(DepartmentId, where);
            var ld = c.Select<Context.Sp_SelectClassesDynamicWhereResult, ClassData>(r => new ClassData()
            {
                key = GetString(r.Id),
                parent_class_id = GetString(r.ParentId),
                name = r.Name,
                description = r.TxtDesc,
                active = r.BtInactive==null?null:(bool?)(!r.BtInactive),
                priority_id = GetString(r.IntPriorityId),
                priority = r.PriorityName,
                level = r.TintLevelOverride,
                hierarchy_level = r.HierarchyLevel == null ? 0 : (int)r.HierarchyLevel,
                last_resort_tech_userid = GetString(r.LastResortTechId),
                last_resort_tech = r.LastResortTechName,
                class_type_id = GetString(r.TintClassType),
                routing_type_id = GetString(r.ConfigDistributedRouting)
            });

            return ld;
        }
Пример #52
0
        public static string Copy(Guid OrgId, int DepartmentId, int MakeID, int TypeID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Makes = from t in dc.AssetMakes where t.Id == MakeID && t.DepartmentId == DepartmentId select t;
                var Make = Makes.FirstOrNull();
                if (Make == null) return "Can not find specified asset make.";

                string MakeName = Make.Make;

                Makes = from t in dc.AssetMakes where t.DepartmentId == DepartmentId && t.TypeId == TypeID && t.Make == Make.Make select t;
                Make = Makes.FirstOrNull();
                if (Make != null) return "'" + MakeName + "' asset make exists in destination asset category. Copy operation is not allowed.";

                lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes NewMake = new lib.bwa.bigWebDesk.LinqBll.Context.AssetMakes();
                NewMake.TypeId = TypeID;
                NewMake.DepartmentId = DepartmentId;
                NewMake.Make = MakeName;

                dc.AssetMakes.InsertOnSubmit(NewMake);
                dc.SubmitChanges();
                return null;
            }
        }
Пример #53
0
        public static bigWebApps.HelpDesk.WebApi.Soap.v1.AssetComputerData[] GetAssetComputer(Guid OrgId, int DepartmentID, string MotherboardSerialNumber, int PageIndex, out int TotalPageNumber, int AssetsPageSize)
        {
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentID);

            var DBAssets = (
                from a in dc.Assets

                join AC in dc.AssetComputers on new { a.DepartmentId, AssetId = a.Id } equals new { AC.DepartmentId, AC.AssetId }

                join _c in dc.AssetCategories on new { a.DepartmentId, a.CategoryId } equals new { _c.DepartmentId, CategoryId = _c.Id } into __c
                join _t in dc.AssetTypes on new { a.DepartmentId, a.TypeId } equals new { _t.DepartmentId, TypeId = _t.Id } into __t
                join _s in dc.AssetStatus on a.StatusId equals _s.Id into __s
                join _m in dc.AssetMakes on new { a.DepartmentId, a.MakeId } equals new { _m.DepartmentId, MakeId = (int?)_m.Id } into __m
                join _M in dc.AssetModels on new { a.DepartmentId, a.ModelId } equals new { _M.DepartmentId, ModelId = (int?)_M.Id } into __M
                join _ac in dc.Accounts on new { a.DepartmentId, a.AccountId } equals new { DepartmentId = _ac.DId, AccountId = (int?)_ac.Id } into __ac
                join _l in dc.Locations on new { a.DepartmentId, a.LocationId } equals new { DepartmentId = _l.DId, LocationId = (int?)_l.Id } into __l
                join _ju in dc.Tbl_LoginCompanyJunc on new { a.DepartmentId, UpdatedById = a.IntUpdatedBy } equals new { DepartmentId = _ju.Company_id, UpdatedById = (int?)_ju.Id } into __ju
                join _jc in dc.Tbl_LoginCompanyJunc on new { a.DepartmentId, a.CheckedOutId } equals new { DepartmentId = _jc.Company_id, CheckedOutId = (int?)_jc.Id } into __jc
                join _jo in dc.Tbl_LoginCompanyJunc on new { a.DepartmentId, a.OwnerId } equals new { DepartmentId = _jo.Company_id, OwnerId = (int?)_jo.Id } into __jo
                join _v in dc.Tbl_vendors on a.VendorId equals _v.Id into __v
                join _w in dc.Tbl_vendors on a.WarrantyVendor equals _w.Id into __w

                from c in __c.DefaultIfEmpty()
                from t in __t.DefaultIfEmpty()
                from s in __s.DefaultIfEmpty()
                from m in __m.DefaultIfEmpty()
                from M in __M.DefaultIfEmpty()
                from ac in __ac.DefaultIfEmpty()
                from l in __l.DefaultIfEmpty()
                from v in __v.DefaultIfEmpty()
                from w in __w.DefaultIfEmpty()

                from sju in __ju.DefaultIfEmpty()
                join _ulu in dc.Tbl_Logins on sju.Login_id equals _ulu.Id into __ulu
                join _utu in dc.Tbl_UserType on sju.UserType_Id equals _utu.Id into __utu
                from julu in __ulu.DefaultIfEmpty()
                from utu in __utu.DefaultIfEmpty()

                from sjc in __jc.DefaultIfEmpty()
                join _ulc in dc.Tbl_Logins on sjc.Login_id equals _ulc.Id into __ulc
                join _utc in dc.Tbl_UserType on sjc.UserType_Id equals _utc.Id into __utc
                from julc in __ulc.DefaultIfEmpty()
                from utc in __utc.DefaultIfEmpty()

                from sjo in __jo.DefaultIfEmpty()
                join _ulo in dc.Tbl_Logins on sjo.Login_id equals _ulo.Id into __ulo
                join _uto in dc.Tbl_UserType on sjo.UserType_Id equals _uto.Id into __uto
                from ulo in __ulo.DefaultIfEmpty()
                from uto in __uto.DefaultIfEmpty()

                where a.DepartmentId == DepartmentID && t.AssetProfileId == 1 && (MotherboardSerialNumber == null || AC.MotherboardSerial == MotherboardSerialNumber)

                orderby a.Name

                select new
                {
                    a,

                    Category = c.Name,
                    Type = t.Name,
                    Status = s.VchStatus,
                    Make = m.Make,
                    Model = M.Model,
                    Account = ac.VchName,
                    AccountLocation = l.Name,
                    /*UpdatedBy = julu.FirstName + " " + julu.LastName + ", " + utu.Name,
                    CheckedOut = julc.FirstName + " " + julc.LastName + ", " + utc.Name,
                    Owner = ulo.FirstName + " " + ulo.LastName + ", " + uto.Name,*/
                    PurchaseVendor = v.Name,
                    WarrantyVendor = w.Name,

                    MotherboardSerial = AC.MotherboardSerial,
                    BiosSerial = AC.BiosSerial,
                    RegisteredUser = AC.RegisteredUser,
                    OperatingSystem = AC.OperatingSystem,
                    OSSerial = AC.OSSerial,
                    RamMbytes = AC.RamMbytes,
                    VideoDescription = AC.VideoDescription,
                    VideoMemoryMbytes = AC.VideoMemoryMbytes,
                    VideoHResolution = AC.VideoHResolution,
                    VideoVResolution = AC.VideoVResolution,
                    NetworkName = AC.NetworkName,
                    NetworkDomain = AC.NetworkDomain,
                    NetworkCard1IP = AC.NetworkCard1IP,
                    NetworkCard1Mask = AC.NetworkCard1Mask,
                    NetworkCard1Gate = AC.NetworkCard1Gate,
                    NetworkCard1Address = AC.NetworkCard1Address,
                    NetworkCard1Description = AC.NetworkCard1Description
                }).Skip(PageIndex * AssetsPageSize).ToList();

            TotalPageNumber = PageIndex + (DBAssets.Count + AssetsPageSize - 1) / AssetsPageSize;
            DBAssets = DBAssets.Take(AssetsPageSize).ToList();

            //bigWebApps.HelpDesk.WebApi.Soap.v1.AssetComputerData[] ret = bigWebApps.HelpDesk.WebApi.Utils.CopyProperties<bigWebApps.HelpDesk.WebApi.Soap.v1.AssetComputerData>(DBAssets);
            List<AssetComputerData> lr = new List<AssetComputerData>();
            foreach (var a in DBAssets)
            {
                AssetComputerData r = new AssetComputerData();
                lr.Add(r);

                r.Account = a.Account;
                r.AccountLocation = a.AccountLocation;
                r.BiosSeriaNumber = a.BiosSerial;
                r.Category = a.Category;
                r.Make = a.Make;
                r.Model = a.Model;
                r.MotherboardSerialNumber = a.MotherboardSerial;
                r.NetworkCard1Address = a.NetworkCard1Address;
                r.NetworkCard1Description = a.NetworkCard1Description;
                r.NetworkCard1Gate = a.NetworkCard1Gate;
                r.NetworkCard1IP = a.NetworkCard1IP;
                r.NetworkCard1Mask = a.NetworkCard1Mask;
                r.NetworkDomain = a.NetworkDomain;
                r.NetworkName = a.NetworkName;
                r.OperatingSystem = a.OperatingSystem;
                r.OSSerial = a.OSSerial;
                r.PurchaseVendor = a.PurchaseVendor;
                r.RamMbytes = a.RamMbytes;
                r.RegisteredUser = a.RegisteredUser;
                r.Status = a.Status;
                r.Type = a.Type;
                r.VideoDescription = a.VideoDescription;
                r.VideoHResolution = a.VideoHResolution;
                r.VideoMemoryMbytes = a.VideoMemoryMbytes;
                r.VideoVResolution = a.VideoVResolution;
                r.WarrantyVendor = a.WarrantyVendor;

                r.Active = a.a.Active;
                r.AssetName = a.a.Name;
                r.AssetNumber = a.a.AssetNumber==null?0:(int)a.a.AssetNumber;
                r.AssetSort = a.a.AssetSort;
                r.DateAquired = a.a.DateAquired;
                r.DateDeployed = a.a.DateDeployed;
                r.DateDisposed = a.a.DateDisposed;
                r.DateEntered = a.a.DateEntered;
                r.DateOutOfService = a.a.DateOutOfService;
                r.DatePurchased = a.a.DatePurchased;
                r.DateReceived = a.a.DateReceived;
                r.DateUpdated = a.a.DtUpdated;
                r.Description = a.a.Description;
                r.FundingCode = a.a.FundingCode;
                r.FundingSource = a.a.FundingSource;
                r.LaborWarrantyLength = a.a.LaborWarrantyLength;
                r.Notes = a.a.Notes;
                r.PartsWarrantyLength = a.a.PartsWarrantyLength;
                r.PONumber = a.a.PONumber;
                r.Room = a.a.Room;
                r.ValueCurrent = a.a.ValueCurrent;
                r.ValueDepreciated = a.a.ValueDepreciated;
                r.ValueDisposalCost = a.a.DisposalCost;
                r.ValuePurchaseCost = a.a.Value;
                r.ValueReplacement = a.a.ValueReplacement;
                r.ValueSalvage = a.a.ValueSalvage;

                GetAssetComputerArrays(DepartmentID, dc, r);

            }
            /*for (int i = 0; i < ret.Length; i++)
            {
                bigWebApps.HelpDesk.WebApi.Soap.v1.AssetComputerData r = ret[i];
                var a = DBAssets[i];

                bigWebApps.HelpDesk.WebApi.Soap.v1.AssetComputerData d = ret[i];
                //d.MotherboardSerialNumber = DBAssets[i].MotherboardSerial;
                //d.BiosSeriaNumber = DBAssets[i].BiosSerial;
                GetAssetComputerArrays(DepartmentID, dc, d);
            }*/

            return lr.ToArray();
        }
Пример #54
0
        public static void Rename(Guid OrgId, int DepartmentId, int CategoryID, string Name)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var Categories = from c in dc.AssetCategories where c.Id == CategoryID && c.DepartmentId == DepartmentId select c;
                var Category = Categories.FirstOrNull();
                if (Category == null) return;

                Category.Name = Name;
                dc.SubmitChanges();
            }
        }
Пример #55
0
        public static int SaveAssetComputer(Guid OrgId, int DepartmentID, AssetComputerData data, bool AddNewOnly, int? AccountId, int? LocationId, ref int? CategoryId, ref int? TypeId, DateTime? DTUpdated)
        {
            LastLog = "SaveAssetComputer ";
            if(DTUpdated==null) DTUpdated = DateTime.UtcNow;
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentID);

            bool isNew = true;
            lib.bwa.bigWebDesk.LinqBll.Context.Assets A = null;

            if(data.AssetNumber>1)
            {
                A = (
                    from a in dc.Assets
                    where a.DepartmentId == DepartmentID && a.AssetNumber==data.AssetNumber
                    select a
                    ).FirstOrNull();
                isNew = A == null;
            }

            if (isNew && data.MotherboardSerialNumber != null)
            {
                A = (
                    from a in dc.Assets
                    join ac in dc.AssetComputers on new { a.DepartmentId, AssetId = a.Id } equals new { ac.DepartmentId, ac.AssetId }
                    join t in dc.AssetTypes on new { a.DepartmentId, a.TypeId } equals new { t.DepartmentId, TypeId = t.Id }
                    where a.DepartmentId == DepartmentID && t.AssetProfileId == 1 && a.Unique7 == data.MotherboardSerialNumber
                    select a
                    ).FirstOrNull();
                isNew = A == null;
            }

            if (isNew)
            {
                A = (
                    from a in dc.Assets
                    join t in dc.AssetTypes on new { a.DepartmentId, a.TypeId } equals new { t.DepartmentId, TypeId = t.Id }
                    where a.DepartmentId == DepartmentID && t.AssetProfileId == 1 && a.SerialNumber == data.PCSerialNumber
                    select a
                    ).FirstOrNull();
                isNew = A == null;
            }

            LastLog += " isNew=" + isNew;

            if (AddNewOnly && !isNew) return 0;

            if (isNew)
            {
                A = new lib.bwa.bigWebDesk.LinqBll.Context.Assets();
                A.AssetGUID = Guid.NewGuid();
                int? MaxNumber = (from a in dc.Asset where a.DId==DepartmentID select (int?)a.AssetNumber).Max();
                if (MaxNumber == null || (int)MaxNumber < 1) A.AssetNumber = 1;
                else A.AssetNumber = (int)MaxNumber + 1;
            }

            if (data.AssetSort>0) A.AssetSort = data.AssetSort;
            if (data.DateAquired != null) A.DateAquired = data.DateAquired;
            if (data.DateDeployed != null) A.DateDeployed = data.DateDeployed;
            if (data.DateDisposed != null) A.DateDisposed = data.DateDisposed;
            if (data.DateEntered != null) A.DateEntered = data.DateEntered;
            if (data.DateEntered != null) A.DateEntered = data.DateEntered;
            if (data.DateOutOfService != null) A.DateOutOfService = data.DateOutOfService;
            if (data.DatePurchased != null) A.DatePurchased = data.DatePurchased;
            if (data.DateReceived != null) A.DateReceived = data.DateReceived;
            if (data.Description != null) A.Description = data.Description;
            if (data.FundingCode != null) A.FundingCode = data.FundingCode;
            if (data.FundingSource != null) A.FundingSource = data.FundingSource;
            if (data.LaborWarrantyLength != null) A.LaborWarrantyLength = data.LaborWarrantyLength;
            if (data.Notes != null) A.Notes = data.Notes;
            if (data.PartsWarrantyLength != null) A.PartsWarrantyLength = data.PartsWarrantyLength;
            if (data.PONumber != null) A.PONumber = data.PONumber;
            if (data.Room != null) A.Room = data.Room;
            if (data.ValueCurrent != null) A.ValueCurrent = data.ValueCurrent;
            if (data.ValueDepreciated != null) A.ValueDepreciated = data.ValueDepreciated;
            if (data.ValueReplacement != null) A.ValueReplacement = data.ValueReplacement;
            if (data.ValueSalvage != null) A.ValueSalvage = data.ValueSalvage;

            A.Unique7 = data.MotherboardSerialNumber;
            A.SerialNumber = data.PCSerialNumber;
            A.DtUpdated = (DateTime)DTUpdated;

            if (CategoryId != null && TypeId != null)
            {
                A.CategoryId = (int)CategoryId;
                A.TypeId = (int)TypeId;
                LastLog += " Direct_TypeId";
            }
            else
            {

                if (string.IsNullOrEmpty(data.Type))
                {
                    if (isNew)
                    {
                        LastLog += " Name_TypeId";
                        var at = (from t in dc.AssetTypes where t.DepartmentId == DepartmentID && t.AssetProfileId == 1 select t).FirstOrDefault();
                        if (at == null || at.Id == 0) throw new Exception("Cann not find Asset Type with 'Computer profile'");
                        A.CategoryId = at.CategoryId;
                        A.TypeId = at.Id;
                    }
                }
                else
                {
                    LastLog += " First_TypeId";
                    var at = (from t in dc.AssetTypes where t.DepartmentId == DepartmentID && t.AssetProfileId == 1 && t.Name == data.Type select t).FirstOrDefault();
                    if (at == null || at.Id == 0)
                    {
                        if (isNew) throw new Exception("Cann not find '" + data.Type + "' Asset Type");
                    }
                    else
                    {
                        A.CategoryId = at.CategoryId;
                        A.TypeId = at.Id;
                    }
                }
            }

            CategoryId = A.CategoryId;
            TypeId = A.TypeId;

            A.StatusId = Assets.GetStatus(dc, data.Status);
            A.MakeId = Assets.GetMakeId(dc, DepartmentID, data.Make, A.TypeId);
            A.ModelId = Assets.GetModelId(dc, DepartmentID, data.Model, A.MakeId);

            if(AccountId!=null) A.AccountId = AccountId;
            else A.AccountId = Assets.GetAccountId(dc, DepartmentID, data.Account);
            if (LocationId!=null) A.LocationId = LocationId;
            else A.LocationId = Assets.GetLocationId(dc, DepartmentID, data.AccountLocation, A.AccountId);

            A.VendorId = Assets.GetVendorId(dc, DepartmentID, data.PurchaseVendor);
            A.WarrantyVendor = Assets.GetVendorId(dc, DepartmentID, data.WarrantyVendor);
            A.DepartmentId = DepartmentID;

            if (isNew) dc.Assets.InsertOnSubmit(A);
            dc.SubmitChanges();
            data.AssetNumber = A.Id;
            LastLog += " Id=" + A.Id;

            try { SaveComputers(DepartmentID, dc, data); } catch { }
            try { SaveComputerLogicalDrives(DepartmentID, dc, data); } catch { }
            try { SaveComputerProcessors(DepartmentID, dc, data); } catch { }
            try { SaveComputerPrinters(DepartmentID, dc, data); } catch { }
            try { SaveComputerSoftwares(DepartmentID, dc, data); } catch { }

            dc.SubmitChanges();
            return A.Id;
        }
Пример #56
0
        public static string Merge(Guid OrgId, int DepartmentId, int SourceCategoryID, int DestCategoryID)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var MergeInfo =
                        from SourceType in dc.AssetTypes
                        join DestType in dc.AssetTypes on new
                        {
                            SDID = SourceType.DepartmentId,
                            DDID = DepartmentId,
                            SourceCategoryID = SourceType.CategoryId,
                            DestCategoryID,
                            SourceType.Name
                        } equals new
                        {
                            SDID = DepartmentId,
                            DDID = DestType.DepartmentId,
                            SourceCategoryID,
                            DestCategoryID = DestType.CategoryId,
                            DestType.Name
                        }

                        orderby SourceType.Name, SourceType.Id, DestType.Name, DestType.Id
                        select new { SourceType, DestType };

                foreach (var mi in MergeInfo)
                {
                    AssetTypes.Merge(dc, DepartmentId, mi.SourceType.Id, mi.DestType.Id);
                }

                var Types = from t in dc.AssetTypes where t.DepartmentId == DepartmentId && t.CategoryId == SourceCategoryID select t;
                foreach (var type in Types) type.CategoryId = DestCategoryID;

                var Assets = from a in dc.Assets where a.DepartmentId == DepartmentId && a.CategoryId == SourceCategoryID select a;
                foreach (var Asset in Assets) Asset.CategoryId = DestCategoryID;

                var Categories = from c in dc.AssetCategories where c.DepartmentId == DepartmentId && c.Id == SourceCategoryID select c;
                dc.AssetCategories.DeleteAllOnSubmit(Categories);

                dc.SubmitChanges();
                return null;
            }
        }
Пример #57
0
        public static string Rename(Guid OrgId, int DepartmentId, int FolderId, string NewName)
        {
            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var folders = from f in dc.Folders where f.DId == DepartmentId && f.Id == FolderId select f;
                var folder = folders.FirstOrNull();
                if (folder == null) return "Can not find specified folder.";

                var PrentChild = (from f in dc.Folders where f.DId == DepartmentId && f.ParentId == folder.ParentId && f.VchName == NewName && f.Id != folder.Id select f).FirstOrNull();
                if (PrentChild == null)
                {
                    folder.VchName = NewName.Length>50 ? NewName.Substring(0, 50) : NewName;
                }
                else
                {
                    string rez = Merge(dc, DepartmentId, FolderId, PrentChild.Id);
                    if (rez != null) return rez;
                }
                dc.SubmitChanges();
                return null;
            }
        }
Пример #58
0
        public static string Move(Guid OrgId, int DepartmentId, int SourceFolderId, int DestFolderId)
        {
            if (SourceFolderId == 0) return "Can not move 'bigWebApps & Support' root folder.";

            using (lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId, lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext.TransactionMode.ImmediateOpenConnection))
            {
                var SourceFolders = from f in dc.Folders where f.DId == DepartmentId && f.Id == SourceFolderId select f;
                var Source = SourceFolders.FirstOrNull();
                if (Source == null) return "Can not find the source folder.";

                if (Source.ParentId == DestFolderId) return null;

                var DestFolderChild = (from f in dc.Folders where f.DId == DepartmentId && f.ParentId == DestFolderId && f.VchName == Source.VchName && f.Id != Source.Id select f).FirstOrNull();
                if (DestFolderChild == null)
                {

                    if (DestFolderId != 0)
                    {
                        var DestFolders = from f in dc.Folders where f.DId == DepartmentId && f.Id == DestFolderId select f;
                        var Dest = DestFolders.FirstOrNull();
                        if (Dest == null) return "Can not find the destination folder.";

                        if (Dest.ParentId == SourceFolderId)
                        {
                            Dest.ParentId = Source.ParentId;
                        }
                    }
                    Source.ParentId = DestFolderId;
                }
                else
                {
                    string rez = Merge(dc, DepartmentId, SourceFolderId, DestFolderChild.Id);
                    if (rez != null) return rez;
                }
                dc.SubmitChanges();
                return null;
            }
        }
Пример #59
0
        static public int SaveAssetComputer(Guid OrgId, int DepartmentID, AssetComputerData data, bool AddNewOnly, int?AccountId, int?LocationId, ref int?CategoryId, ref int?TypeId, DateTime?DTUpdated)
        {
            LastLog = "SaveAssetComputer ";
            if (DTUpdated == null)
            {
                DTUpdated = DateTime.UtcNow;
            }
            lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentID);

            bool isNew = true;

            lib.bwa.bigWebDesk.LinqBll.Context.Assets A = null;

            if (data.AssetNumber > 1)
            {
                A = (
                    from a in dc.Assets
                    where a.DepartmentId == DepartmentID && a.AssetNumber == data.AssetNumber
                    select a
                    ).FirstOrNull();
                isNew = A == null;
            }

            if (isNew && data.MotherboardSerialNumber != null)
            {
                A = (
                    from a in dc.Assets
                    join ac in dc.AssetComputers on new { a.DepartmentId, AssetId = a.Id } equals new { ac.DepartmentId, ac.AssetId }
                    join t in dc.AssetTypes on new { a.DepartmentId, a.TypeId } equals new { t.DepartmentId, TypeId = t.Id }
                    where a.DepartmentId == DepartmentID && t.AssetProfileId == 1 && a.Unique7 == data.MotherboardSerialNumber
                    select a
                    ).FirstOrNull();
                isNew = A == null;
            }

            if (isNew)
            {
                A = (
                    from a in dc.Assets
                    join t in dc.AssetTypes on new { a.DepartmentId, a.TypeId } equals new { t.DepartmentId, TypeId = t.Id }
                    where a.DepartmentId == DepartmentID && t.AssetProfileId == 1 && a.SerialNumber == data.PCSerialNumber
                    select a
                    ).FirstOrNull();
                isNew = A == null;
            }

            LastLog += " isNew=" + isNew;

            if (AddNewOnly && !isNew)
            {
                return(0);
            }

            if (isNew)
            {
                A           = new lib.bwa.bigWebDesk.LinqBll.Context.Assets();
                A.AssetGUID = Guid.NewGuid();
                int?MaxNumber = (from a in dc.Asset where a.DId == DepartmentID select(int?) a.AssetNumber).Max();
                if (MaxNumber == null || (int)MaxNumber < 1)
                {
                    A.AssetNumber = 1;
                }
                else
                {
                    A.AssetNumber = (int)MaxNumber + 1;
                }
            }

            if (data.AssetSort > 0)
            {
                A.AssetSort = data.AssetSort;
            }
            if (data.DateAquired != null)
            {
                A.DateAquired = data.DateAquired;
            }
            if (data.DateDeployed != null)
            {
                A.DateDeployed = data.DateDeployed;
            }
            if (data.DateDisposed != null)
            {
                A.DateDisposed = data.DateDisposed;
            }
            if (data.DateEntered != null)
            {
                A.DateEntered = data.DateEntered;
            }
            if (data.DateEntered != null)
            {
                A.DateEntered = data.DateEntered;
            }
            if (data.DateOutOfService != null)
            {
                A.DateOutOfService = data.DateOutOfService;
            }
            if (data.DatePurchased != null)
            {
                A.DatePurchased = data.DatePurchased;
            }
            if (data.DateReceived != null)
            {
                A.DateReceived = data.DateReceived;
            }
            if (data.Description != null)
            {
                A.Description = data.Description;
            }
            if (data.FundingCode != null)
            {
                A.FundingCode = data.FundingCode;
            }
            if (data.FundingSource != null)
            {
                A.FundingSource = data.FundingSource;
            }
            if (data.LaborWarrantyLength != null)
            {
                A.LaborWarrantyLength = data.LaborWarrantyLength;
            }
            if (data.Notes != null)
            {
                A.Notes = data.Notes;
            }
            if (data.PartsWarrantyLength != null)
            {
                A.PartsWarrantyLength = data.PartsWarrantyLength;
            }
            if (data.PONumber != null)
            {
                A.PONumber = data.PONumber;
            }
            if (data.Room != null)
            {
                A.Room = data.Room;
            }
            if (data.ValueCurrent != null)
            {
                A.ValueCurrent = data.ValueCurrent;
            }
            if (data.ValueDepreciated != null)
            {
                A.ValueDepreciated = data.ValueDepreciated;
            }
            if (data.ValueReplacement != null)
            {
                A.ValueReplacement = data.ValueReplacement;
            }
            if (data.ValueSalvage != null)
            {
                A.ValueSalvage = data.ValueSalvage;
            }

            A.Unique7      = data.MotherboardSerialNumber;
            A.SerialNumber = data.PCSerialNumber;
            A.DtUpdated    = (DateTime)DTUpdated;

            if (CategoryId != null && TypeId != null)
            {
                A.CategoryId = (int)CategoryId;
                A.TypeId     = (int)TypeId;
                LastLog     += " Direct_TypeId";
            }
            else
            {
                if (string.IsNullOrEmpty(data.Type))
                {
                    if (isNew)
                    {
                        LastLog += " Name_TypeId";
                        var at = (from t in dc.AssetTypes where t.DepartmentId == DepartmentID && t.AssetProfileId == 1 select t).FirstOrDefault();
                        if (at == null || at.Id == 0)
                        {
                            throw new Exception("Cann not find Asset Type with 'Computer profile'");
                        }
                        A.CategoryId = at.CategoryId;
                        A.TypeId     = at.Id;
                    }
                }
                else
                {
                    LastLog += " First_TypeId";
                    var at = (from t in dc.AssetTypes where t.DepartmentId == DepartmentID && t.AssetProfileId == 1 && t.Name == data.Type select t).FirstOrDefault();
                    if (at == null || at.Id == 0)
                    {
                        if (isNew)
                        {
                            throw new Exception("Cann not find '" + data.Type + "' Asset Type");
                        }
                    }
                    else
                    {
                        A.CategoryId = at.CategoryId;
                        A.TypeId     = at.Id;
                    }
                }
            }

            CategoryId = A.CategoryId;
            TypeId     = A.TypeId;

            A.StatusId = Assets.GetStatus(dc, data.Status);
            A.MakeId   = Assets.GetMakeId(dc, DepartmentID, data.Make, A.TypeId);
            A.ModelId  = Assets.GetModelId(dc, DepartmentID, data.Model, A.MakeId);

            if (AccountId != null)
            {
                A.AccountId = AccountId;
            }
            else
            {
                A.AccountId = Assets.GetAccountId(dc, DepartmentID, data.Account);
            }
            if (LocationId != null)
            {
                A.LocationId = LocationId;
            }
            else
            {
                A.LocationId = Assets.GetLocationId(dc, DepartmentID, data.AccountLocation, A.AccountId);
            }

            A.VendorId       = Assets.GetVendorId(dc, DepartmentID, data.PurchaseVendor);
            A.WarrantyVendor = Assets.GetVendorId(dc, DepartmentID, data.WarrantyVendor);
            A.DepartmentId   = DepartmentID;

            if (isNew)
            {
                dc.Assets.InsertOnSubmit(A);
            }
            dc.SubmitChanges();
            data.AssetNumber = A.Id;
            LastLog         += " Id=" + A.Id;

            try { SaveComputers(DepartmentID, dc, data); } catch { }
            try { SaveComputerLogicalDrives(DepartmentID, dc, data); } catch { }
            try { SaveComputerProcessors(DepartmentID, dc, data); } catch { }
            try { SaveComputerPrinters(DepartmentID, dc, data); } catch { }
            try { SaveComputerSoftwares(DepartmentID, dc, data); } catch { }

            dc.SubmitChanges();
            return(A.Id);
        }
Пример #60
0
 public static string GetName(Guid OrgId, int DepartmentId, int CategoryID)
 {
     lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext dc = new lib.bwa.bigWebDesk.LinqBll.Context.MutiBaseDataContext(OrgId, DepartmentId);
     string Name = (from c in dc.AssetCategories where c.DepartmentId == DepartmentId && c.Id == CategoryID select c.Name).FirstOrNull();
     return Name;
 }