示例#1
0
 public Task SendAll(BroadcastMessage message, Identification identification)
 {
     // Call the addMessage method on all clients
     message.UserName = identification.Username;
     message.When = DateTime.Now;
     return Clients.All.Broadcast(message);
 }
示例#2
0
 public IAsyncResult BeginGetUser(int id, Identification identification, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     if (AppLib.VerifyToken(identification.Token) <= 0) {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<User>.Factory.StartNew(process => DoGetUser(id), state);
     return task.ContinueWith(res => callback(task));
 }
示例#3
0
 public IAsyncResult BeginGetBusinessClosedDays(Identification identification, DateTime startDate, DateTime endDate, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     if (AppLib.VerifyToken(identification.Token) <= 0) {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<SmartCollection<BusinessClosedDay>>.Factory.StartNew(process => DoGetBusinessClosedDays(identification, startDate, endDate), state);
     return task.ContinueWith(res => callback(task));
 }
示例#4
0
 public IAsyncResult BeginGetAnalytes(bool addAny, bool includeInActive, Identification identification, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     if (AppLib.VerifyToken(identification.Token) <= 0) {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<SmartCollection<Analyte>>.Factory.StartNew(process => DoGetAnalytes(addAny, includeInActive, identification), state);
     return task.ContinueWith(res => callback(task));
 }
示例#5
0
        public IAsyncResult BeginGetInventoryItem(int id, Identification identification, AsyncCallback callback, object state)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
            if (AppLib.VerifyToken(identification.Token) <= 0)
                throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));

            if (!AppLib.IsAuthorized(identification, ModuleNames.Inventory.ToString()))
                throw new FaultException<ServiceFault>(new ServiceFault("User account is not Authorized.", "Authorization"), new FaultReason("Restricted"));

            var task = Task<InventoryItem>.Factory.StartNew(process => DoGetInventoryItem(id, identification.Token), state);
            return task.ContinueWith(res => callback(task));
        }
示例#6
0
        public IAsyncResult BeginGetChangeHistory(string moduleName, int rootModelKey, Identification identification, AsyncCallback callback, object state)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
            if (AppLib.VerifyToken(identification.Token) <= 0) throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));

            //if (!AppLib.IsAuthorized(identification, SysLib.GetOptionName(ModuleNames.Orders, ModelNamesEnum.SampleTest, ModuleAction.Create, ModuleAction.Report)))
            //    throw new FaultException<ServiceFault>(new ServiceFault("User account is not Authorized.", "Authorization"), new FaultReason("Restricted"));

            // TODO: if isauthorized

            var task = Task<SmartCollection<AuditedModelValue>>.Factory.StartNew(process => DoGetChangeHistory(moduleName, rootModelKey, identification), state);
            return task.ContinueWith(res => callback(task));
        }
示例#7
0
        public IAsyncResult BeginGetUsers(string searchString, Identification identification, AsyncCallback callback, object state)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
            // JSON POST Sample = {"searchString":"Test","searchFields":["FirstName"]}

            if (AppLib.VerifyToken(identification.Token) <= 0)
            {
                throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
            }

            var task = Task<SmartCollection<User>>.Factory.StartNew(process => DoGetUsers(searchString), state);
            return task.ContinueWith(res => callback(task));
        }
示例#8
0
        public IAsyncResult BeginCancelSample(int arlNumber, SampleNote note, Identification identification, AsyncCallback callback, object state)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
            identification.UserId = AppLib.VerifyToken(identification.Token);
            if (identification.UserId <= 0) {
                throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
            }

            if (!AppLib.IsAuthorized(identification, SysLib.GetOptionName(ModuleNames.Samples, ModelNamesEnum.Sample, ModuleAction.Cancel)))
                throw new FaultException<ServiceFault>(new ServiceFault("User account is not Authorized.", "Authorization"), new FaultReason("Restricted"));

            var task = Task<int>.Factory.StartNew(process => DoCancelSample(arlNumber, note, identification), state);
            return task.ContinueWith(res => callback(task));
        }
示例#9
0
        private string GetClientComplaintsOpenCount(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, Identification identification)
        {
            try
            {
                bool canApproveComplaints = AppLib.IsAuthorized(identification, SysLib.GetOptionName(ModuleNames.Clients, ModelNamesEnum.Complaint, ModuleAction.Approve));

                int returnValue = 0;

                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.CommandText = "uspGetClientComplaintsOpenCount";
                dbCommand.Parameters.Clear();
                dbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = identification.UserId;
                returnValue = (int)dbConnection.ExecuteScalar(dbCommand);
                return returnValue <= 0 ? string.Empty : returnValue.ToString();
            }
            catch
            {
                throw;
            }
        }
示例#10
0
        public int SaveClientComplaint(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, ClientComplaint complaint, Identification identification)
        {
            try
            {
                int returnValue = 0;
                if (complaint.IsDirty)
                {
                    SystemDAO.SaveChangeAudit<ClientComplaint>(ref dbConnection, ref dbCommand,
                        GetClientComplaint(ref dbConnection, ref dbCommand, complaint.Pk),
                        complaint,
                        ModuleNames.Clients,
                        complaint.ClientId,
                        identification.UserId);

                    dbCommand.Parameters.Clear();
                    dbCommand.CommandType = CommandType.StoredProcedure;
                    dbCommand.CommandText = "uspUpdateClientComplaint";

                    dbCommand.Parameters.Add("@ClientComplaintId", System.Data.SqlDbType.Int).Value = complaint.ClientComplaintId;
                    dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = complaint.ClientId;
                    dbCommand.Parameters.Add("@ClassificationId", System.Data.SqlDbType.Int).Value = complaint.ClassificationId;
                    dbCommand.Parameters.Add("@StatusYN", System.Data.SqlDbType.Int).Value = (bool)complaint.StatusYN;
                    dbCommand.Parameters.Add("@Description", System.Data.SqlDbType.NVarChar, 100).Value = complaint.Description;
                    dbCommand.Parameters.Add("@ARLNumber", System.Data.SqlDbType.NVarChar, 100).Value = complaint.ARLNumber;
                    dbCommand.Parameters.Add("@RootCause", System.Data.SqlDbType.NVarChar, 100).Value = complaint.RootCause;
                    dbCommand.Parameters.Add("@NotifyUserId", System.Data.SqlDbType.Int).Value = complaint.NotifyUserId;
                    dbCommand.Parameters.Add("@CorrectiveAction", System.Data.SqlDbType.NVarChar, 100).Value = complaint.CorrectiveAction;
                    dbCommand.Parameters.Add("@CorrectiveActionDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now;
                    dbCommand.Parameters.Add("@CorrectiveActionUserId", System.Data.SqlDbType.Int).Value = complaint.CorrectiveActionUserId;
                    dbCommand.Parameters.Add("@ModifiedDate", System.Data.SqlDbType.DateTime).Value = complaint.CorrectiveActionDate != null ? (SqlDateTime)complaint.CorrectiveActionDate : SqlDateTime.Null;
                    dbCommand.Parameters.Add("@ModifiedBy", System.Data.SqlDbType.Int).Value = identification.UserId;
                    returnValue += dbConnection.ExecuteCommand(dbCommand);
                }
                return returnValue;
            }
            catch
            {
                throw;
            }
        }
示例#11
0
 public int SaveClientComplaint(ClientComplaint complaint, Identification identification)
 {
     int result = 0;
     try
     {
         using (DbConnection = new MsSqlPersistence(DbConnectionSettings))
         {
             if (DbConnection.IsConnected())
             {
                 using (DbCommand)
                 {
                     result = this.SaveClientComplaint(ref dbConnection, ref dbCommand, complaint, identification);
                 }
             }
             else
             {
                 throw new Exception("Unable to Connect");
             }
         }
         return result;
     }
     catch
     {
         throw;
     }
 }
示例#12
0
        public string DoCreateMultiSampleInvoice(string arlNumbers, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO())
            {
                return dao.CreateMultiSampleInvoice(arlNumbers, identification);
            }
        }
示例#13
0
        public int DoSaveUser(User user, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            //Validate Object
            if (!user.ValidateModel())
                throw new FaultException<ServiceFault>(new ServiceFault(user.CurrentErrors), new FaultReason(SysVars.InvalidFormat));

            if (user.UserId == null) {
                using (UserDAO dao = new UserDAO()) {
                    if (dao.IsDuplicateUserName(user.Username))
                        throw new FaultException<ServiceFault>(new ServiceFault("Duplicate User Name", "Rejected"), new FaultReason("Duplicate User Name Found."));
                }
            }
            using (UserDAO dao = new UserDAO()) {
                return dao.SaveUser(user, identification.Token, identification.UserId);
            }
        }
示例#14
0
 public int DoRemoveInventoryItemNote(int id, Identification identification)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     using (InventoryDAO dao = new InventoryDAO())
     {
         return dao.RemoveInventoryNote(id, identification.UserId);
     }
 }
示例#15
0
 public int DoRemoveUser(int id, Identification identification)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     using (UserDAO dao = new UserDAO()) {
         return dao.RemoveUser(id, identification.UserId);
     }
 }
示例#16
0
 public IAsyncResult BeginSearchInventory(string searchString, Collection<SearchItem> searchItems, Identification identification, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     if (AppLib.VerifyToken(identification.Token) <= 0)
     {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<SmartCollection<InventoryItem>>.Factory.StartNew(process => DoSearchInventory(searchString, searchItems, identification), state);
     return task.ContinueWith(res => callback(task));
 }
示例#17
0
        public InventoryModuleObject DoGetInventoryNotifiers(int id, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (InventoryDAO dao = new InventoryDAO())
            {
                return dao.GetInventoryNotifiers(id);
            }
        }
示例#18
0
        public SmartCollection<Sample> DoGetClientSamples(int clientId, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO())
            {
                return dao.GetClientSamples(clientId, identification);
            }
        }
示例#19
0
        public int DoFinalizeSampleTestSubmission(int id, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO()) {
                return dao.FinalizeSampleTestSubmission(id, identification);
            }
        }
示例#20
0
        public int DoDeleteOos(int oosId, string reason, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            // Delete Oos
            using (SampleDAO dao = new SampleDAO())
            {
                return dao.DeleteOOS(oosId, reason, identification);
            }
        }
示例#21
0
        public SmartCollection<ClientComplaint> GetClientComplaintsOpen(Identification identification)
        {
            try
            {
                SmartCollection<ClientComplaint> resultList = new SmartCollection<ClientComplaint>();
                using (DbConnection = new MsSqlPersistence(DbConnectionSettings))
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspGetClientComplaintsOpen";
                            DbCommand.Parameters.Clear();

                            DataTable returnDT = DbConnection.ExecuteQuery(DbCommand);
                            foreach (DataRow row in returnDT.Rows)
                            {
                                ClientComplaint complaint = new ClientComplaint();
                                complaint.ClientComplaintId = Convert.ToInt32(row["ClientComplaintID"]);
                                complaint.ClientId = Convert.ToInt32(row["ClientID"]);
                                complaint.ClientName = row["ClientName"].ToString();
                                complaint.ClassificationId = row["ClassificationID"] != DBNull.Value ? Convert.ToInt32(row["ClassificationID"]) : -1;
                                if (complaint.ClassificationId.HasValue && complaint.ClassificationId != -1)
                                    complaint.Classification = new Complaint { ComplaintId = complaint.ClassificationId, ComplaintName = row["ComplaintName"].ToString(), Active = true };
                                complaint.Description = row["Description"].ToString();
                                complaint.ARLNumber = row["ARLNumber"].ToString();
                                complaint.StatusYN = (bool)(row["StatusYN"] ?? false);
                                complaint.RootCause = row["RootCause"].ToString();
                                complaint.CorrectiveAction = row["CorrectiveAction"].ToString();
                                if (row["CorrectiveActionDate"] != DBNull.Value)
                                    complaint.CorrectiveActionDate = (DateTime)row["CorrectiveActionDate"];
                                else
                                    complaint.CorrectiveActionDate = null;
                                complaint.CorrectiveActionUserId = row["CorrectiveActionUserID"] != DBNull.Value ? Convert.ToInt32(row["CorrectiveActionUserID"]) : -1;
                                complaint.CorrectiveActionUser = row["CorrectiveUser"].ToString();
                                complaint.NotifyUserId = row["NotifyUserID"] != DBNull.Value ? Convert.ToInt32(row["NotifyUserID"]) : -1;
                                complaint.NotifyUser = row["NotifyUser"].ToString();
                                complaint.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : -1;
                                complaint.CreatedUser = row["CreatedUser"].ToString();
                                complaint.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                                complaint.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : -1;
                                complaint.ModifiedUser = row["ModifiedUser"].ToString();
                                complaint.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;
                                resultList.Add(complaint);
                            }
                            returnDT = null;
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }
                }
                return resultList;
            }
            catch
            {
                throw;
            }
        }
示例#22
0
        public int DoCreateCoaReport(Sample sample, Identification identification)
        {
            ReportRecord reportRecord = null;

            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO()) {
                reportRecord = dao.CreateCoaReport(sample, identification);
            }
            if (reportRecord.Id.IsNotNull() && reportRecord.Id > 0) {
                using (ClientDAO customerDao = new ClientDAO()) {
                    reportRecord.ParentId = customerDao.GetClientId(reportRecord.ParentId.Value);
                }
                using (ReportDAO reportDao = new ReportDAO()) {
                    ReportNotification reportNotification = new ReportNotification();
                    reportNotification.ReportId = reportRecord.Id.Value;
                    reportNotification.CustomerId = reportRecord.ParentId.Value;
                    reportNotification.DepartmentId = reportRecord.DepartmentId.Value;
                    reportNotification.SubjectLine = reportRecord.SubjectLine;
                    reportDao.SaveNotificationReports(reportDao.GetNotificationRecords(reportNotification));
                }
            }

            return reportRecord.Id.Value;
        }
示例#23
0
 public string GetClientComplaintsOpenCount(Identification identification)
 {
     try
     {
         using (DbConnection = new MsSqlPersistence(DbConnectionSettings))
         {
             if (DbConnection.IsConnected())
             {
                 using (DbCommand)
                 {
                     return this.GetClientComplaintsOpenCount(ref dbConnection, ref dbCommand, identification);
                 }
             }
             else
             {
                 throw new Exception("Unable to Connect");
             }
         }
     }
     catch
     {
         throw;
     }
 }
示例#24
0
        public SmartCollection<InventoryItem> DoSearchInventory(string searchString, Collection<SearchItem> searchItems, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (InventoryDAO dao = new InventoryDAO())
            {
                return dao.SearchInventory(searchString, searchItems, identification);
            }
        }
示例#25
0
        public void DoSaveNewPin(string newPin, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (UserDAO dao = new UserDAO())
            {
                dao.SaveNewPin(newPin, identification.UserId);
            }
        }
示例#26
0
        public int DoCancelSampleTest(int id, SampleNote note, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO()) {
                return dao.CancelSampleTest(id, note, identification);
            }
        }
示例#27
0
        public bool DoValidatePin(string pin, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (UserDAO dao = new UserDAO())
            {
                return dao.ValidatePin(pin, identification.UserId);
            }
        }
示例#28
0
 public IAsyncResult BeginRemoveInventoryItem(int id, Identification identification, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     identification.UserId = AppLib.VerifyToken(identification.Token);
     if (identification.UserId <= 0)
     {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<int>.Factory.StartNew(func => DoRemoveInventoryItem(id, identification), state);
     return task.ContinueWith(cb => callback(task));
 }
示例#29
0
        public int DoSaveInventoryItem(InventoryItem inventoryItem, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            //Validate Inventory Object
            if (!inventoryItem.ValidateModel())
                throw new FaultException<ServiceFault>(new ServiceFault(inventoryItem.CurrentErrors), new FaultReason(SysVars.InvalidFormat));

            using (InventoryDAO dao = new InventoryDAO())
            {
                return dao.SaveInventoryRecord(inventoryItem, identification.Token, identification.UserId);
            }
        }
示例#30
0
        public string DoCreateInvoice(Invoice invoice, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO()) {
                return dao.CreateInvoice(invoice, identification);
            }
        }