Exemplo n.º 1
0
        public void BulkAddEditDel(List<FileHeader> records, Claim claimObj, bool doSubmit, CPMmodel dbcContext)
        {
            //OLD: if (claimID <= Defaults.Integer) return; //Can't move forward if its a new Claim entry
            #region NOTE
            /* Perform Bulk Add, Edit & Del based on Object properties set in VIEW
             * MEANT ONLY FOR ASYNC BULK OPERATIONS
             * Handle transaction, error and final commit in Caller */
            #endregion

            //using{dbc}, try-catch and transaction must be handled in callee function
            foreach (FileHeader item in records)
            {
                #region Perform Db operations
                item.ClaimID = claimObj.ID;
                item.LastModifiedBy = _SessionUsr.ID;
                item.LastModifiedDate = DateTime.Now;
                item.UploadedOn = DateTime.Now; // double ensure dates are not null !

                //Special case handling for IE with KO - null becomes "null"
                if (item.Comment == "null") item.Comment = "";

                if (item._Deleted)
                    Delete(item, false);
                else if (item._Edited)//Make sure Delete is LAST
                    AddEdit(item, false);
                else if (item._Added)
                    Add(item, false);
                #endregion

                #region Log Activity (finally when the uploaded file data is entered in the DB
                if (item._Added || item._Edited)
                {
                    //Special case: Call the econd overload which has "doSubmit" parameter
                    new ActivityLogService(ActivityLogService.Activity.ClaimFileUpload, dbcContext).Add(
                    new ActivityHistory() { FileName = item.FileName, ClaimID = claimObj.ID, ClaimText = claimObj.ClaimNo.ToString() },
                    doSubmit);
                }
                #endregion
            }
            if (doSubmit) dbc.SubmitChanges();//Make a FINAL submit instead of periodic updates
            //Move header files
            ProcessFiles(records, claimObj.ID, claimObj.ClaimGUID);
        }
Exemplo n.º 2
0
        public void BulkAddEditDel(List<FileDetail> records, Claim claimObj, int oldclaimDetailId, int claimDetailId, bool doSubmit, 
            CPMmodel dbcContext)
        {
            //using{dbc}, try-catch and transaction must be handled in callee function
            foreach (FileDetail item in records)
            {
                #region Perform Db operations
                item.LastModifiedBy = _SessionUsr.ID;
                item.LastModifiedDate = DateTime.Now;
                item.UploadedOn = DateTime.Now;// double ensure dates are not null !
                //HT: MUST: MAke sure this is set (i.e. the newly added Claimetail ID or it'll give FK err)
                item.ClaimDetailID = claimDetailId;
                item.ClaimID = claimObj.ID;

                //Special case handling for IE with KO - null becomes "null"
                if (item.Comment == "null") item.Comment = "";

                if (item._Deleted)
                    Delete(item, false);
                else if (item._Edited)//Make sure Delete is LAST
                    AddEdit(item, false);
                else if (item._Added)
                    Add(item, false);
                #endregion

                #region Log Activity (finally when the uploaded file data is entered in the DB
                if (item._Added || item._Edited)
                {//Special case: Call the econd overload which has "doSubmit" parameter
                    new ActivityLogService(ActivityLogService.Activity.ClaimFileUpload, dbcContext).Add(
                        new ActivityHistory() { FileName = item.FileName, ClaimID = item.ClaimID, ClaimDetailID = item.ClaimDetailID,
                                                ClaimText = claimObj.ClaimNo.ToString()
                        }, doSubmit);
                }
                #endregion
            }
            if (doSubmit) dbc.SubmitChanges(); //Make a FINAL submit instead of periodic updates
            //Move Item detail files
            ProcessFiles(records, claimObj.ID, claimObj.ClaimGUID, oldclaimDetailId, claimDetailId);
        }
Exemplo n.º 3
0
        public void BulkAddEditDel(List<ClaimDetail> records, Claim claimObj, bool doSubmit, bool isNewClaim, CPMmodel dbcContext)
        {
            //using{dbc}, try-catch and transaction must be handled in callee function
            foreach (ClaimDetail item in records)
            {
                #region Perform Db operations
                item.ClaimID = claimObj.ID; //Required when adding new Claim
                item.LastModifiedBy = _SessionUsr.ID;
                item.LastModifiedDate = DateTime.Now;
                int oldClaimDetailId = item.ID;//store old id

                //Special case handling for IE with KO - null becomes "null"
                if (item.Note == "null") item.Note = "";
                if (item.Serial == "null") item.Serial = "";
                if (item.DOT == "null") item.DOT = "";

                if (item._Deleted)
                {
                    Delete(item, false);
                    // Make sure the Existing as well as Uploaded (Async) files are deleted
                    FileIO.EmptyDirectory(FileIO.GetClaimDirPathForDelete(claimObj.ID, item.ID, claimObj.ClaimGUID, true));
                    FileIO.EmptyDirectory(FileIO.GetClaimDirPathForDelete(claimObj.ID, item.ID, null,false));
                }
                else if (item._Edited)
                    AddEdit(item, false);
                else if (item._Added)
                    Add(item, false);

                #endregion

                if (doSubmit) //Make a FINAL submit here instead of periodic updates
                    dbc.SubmitChanges();

                // Finally, If Item is NOT deleted then process its Files
                if (!item._Deleted && item.aDFiles != null && item.aDFiles.Count() > 0) // Make sure item is not deleted
                    new FileDetailService(dbc).BulkAddEditDel(item.aDFiles, claimObj, oldClaimDetailId, item.ID, doSubmit, dbcContext);
            }
        }
Exemplo n.º 4
0
		private void detach_Claims(Claim entity)
		{
			this.SendPropertyChanging();
			entity.MasterOrg = null;
		}
Exemplo n.º 5
0
 partial void DeleteClaim(Claim instance);
Exemplo n.º 6
0
		private void attach_Claims(Claim entity)
		{
			this.SendPropertyChanging();
			entity.MasterOrg = this;
		}
Exemplo n.º 7
0
 partial void InsertClaim(Claim instance);
Exemplo n.º 8
0
 partial void UpdateClaim(Claim instance);
Exemplo n.º 9
0
 public void Delete(Claim claimObj)
 {
     //HT: IMP: SP way of checking if an FK ref exists: http://stackoverflow.com/questions/5077423/sql-server-check-if-child-rows-exist
     dbc.Claims.DeleteOnSubmit(dbc.Claims.Single(c => c.ID == claimObj.ID));
     //Delete Claim Activities ???
     dbc.SubmitChanges();
 }
Exemplo n.º 10
0
        public int AddEdit(Claim claimObj, int StatusIDold, bool doSubmit)
        {
            if (claimObj.ID <= Defaults.Integer) // Insert
                return Add(claimObj);

            // Update

            //Set lastmodified fields
            claimObj.LastModifiedBy = _SessionUsr.ID;
            claimObj.LastModifiedDate = DateTime.Now;

            dbc.Claims.Attach(claimObj);//attach the object as modified
            dbc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, claimObj);//Optimistic-concurrency (simplest solution)

            #region If the Status has been changed then make entry in StatusHistory
            if (claimObj.StatusID != StatusIDold)
                new StatusHistoryService(dbc).Add(new StatusHistory()
                {
                    ClaimID = claimObj.ID,
                    NewStatusID = claimObj.StatusID,
                    OldStatusID = StatusIDold
                }, false);
            #endregion

            if (doSubmit)    dbc.SubmitChanges();
            // Set Claim #
            claimObj.ClaimNo = claimObj.ID;

            return claimObj.ID;
        }
Exemplo n.º 11
0
        public Claim AddDefault(int userID, int OrgID, bool defaultOrgSP,ref string spNameForCustomer)
        {
            DefaultClaim dDB = DefaultDBService.GetClaim(userID);
            Claim claimObj = new Claim()
            {
                AssignedTo = dDB.AssignTo,
                BrandID = dDB.BrandID,
                ClaimDate = dDB.ClaimDate,
                CustID = dDB.CustID,
                SalespersonID = dDB.SalespersonID,
                ShipToLocationID = dDB.ShipToLocID,
                StatusID = dDB.StatusID,
                ClaimGUID = System.Guid.NewGuid().ToString() // MAke sure the GUID is set at this initial level
            };

            claimObj.ID = Defaults.Integer;
            //Set lastmodified fields
            claimObj.LastModifiedBy = _SessionUsr.ID;
            claimObj.LastModifiedDate = DateTime.Now;

            #region Kept for future ref - also must be done in Add claim
            /* claimObj.StatusHistories.Add(new StatusHistory() { Claim = claimObj, //ClaimID = claimObj.ID,
                LastModifiedBy = _SessionUsr.ID, LastModifiedDate = DateTime.Now,
                OldStatusID = Defaults.Integer, NewStatusID = claimObj.StatusID });

            dbc.Claims.InsertOnSubmit(claimObj);
            dbc.SubmitChanges(); */
            #endregion

            #region Special case for customer - pre populate SP
            if (defaultOrgSP)
            {
                try
                {
                    var spData = from i in dbc.vw_CustOrg_SalesUsers where i.ID == OrgID select i;
                    claimObj.SalespersonID = spData.ToList()[0].SalespersonId.Value;
                    spNameForCustomer = spData.ToList()[0].UserName;
                }
                catch(Exception ex){}// handles emply SP
                //OrgID
            }
            #endregion

            return claimObj; // Return the 'newly configured claim'
        }
Exemplo n.º 12
0
        public int Add(Claim claimObj)
        {
            //Claim claimObj = GetClaimObjFromVW(vwObj);
            //triple ensure that the latest comment.PostedOn date is NOT null
            claimObj.ClaimDate = DateTime.Now;
            //Set lastmodified fields
            claimObj.LastModifiedBy = _SessionUsr.ID;
            claimObj.LastModifiedDate = DateTime.Now;

            claimObj.StatusHistories.Add(new StatusHistory()
            {
                Claim = claimObj, //ClaimID = claimObj.ID,
                LastModifiedBy = _SessionUsr.ID,
                LastModifiedDate = DateTime.Now,
                OldStatusID = Defaults.Integer,
                NewStatusID = claimObj.StatusID
            });

            dbc.Claims.InsertOnSubmit(claimObj);
            dbc.SubmitChanges();
            claimObj.ClaimNo = claimObj.ID;

            return claimObj.ID; // Return the 'newly inserted id'
        }
Exemplo n.º 13
0
 public static vw_Claim_Master_User_Loc GetVWFromClaimObj(Claim c, string SPNameForCustomer)
 {
     return new vw_Claim_Master_User_Loc()
     {
         ID = c.ID,
         AssignedTo = c.AssignedTo, //HT? : CAUTION: Handle default Assignee !!!
         //AssignedToVal = c.AssignedToVal,
         BrandID = c.BrandID,
         ClaimDate = c.ClaimDate,
         ClaimNo = c.ClaimNo, //HT: Needed for Comment-AssignTo email (Auto-Generated)
         CustID = c.CustID,
         CustRefNo = c.CustRefNo,
         SalespersonID = c.SalespersonID,
         SalespersonName = SPNameForCustomer, // HT: Need to default for customer
         ShipToLocationID = c.ShipToLocationID,
         StatusID = c.StatusID,
         //VendorID = c.VendorID,
         Archived = c.Archived, // HT: Make sure this is set!
         ClaimGUID = c.ClaimGUID // HT: Make sure this is set!
     };
 }