Exemplo n.º 1
0
 public ResultInfo.Result SubmitInput(Guid endPointKeyPass, string value, DateTime?execTime)
 {
     ResultInfo.Result result = Result.GenerateFailedResult();
     try
     {
         //if (!execTime.HasValue)
         //{
         //    List<Endpoint> ends = db.Endpoints.Include("Device").Where(e => e.GUID == endPointKeyPass).ToList();
         //    if (ends.Count > 0)
         //    {
         //        execTime = DateTime.UtcNow.AddHours(ends[0].Device.UTC_Diff);
         //    }
         //    else
         //    {//endPointKeyPass not Exist
         //        result = Result.GenerateFailedResult("EndPoint KeyPass not Exist");
         //    }
         //}
         db.SubmitEndPointInput(endPointKeyPass, value, execTime);
         result = Result.GenerateOKResult();
     }
     catch (Exception ex)
     {
         result.Message = ex.InnerException.ToString();
     }
     return(result);
 }
Exemplo n.º 2
0
 public ResultInfo.Result SubmitLog(Guid endPointKeyPass, string value, DateTime?execTime)
 {
     ResultInfo.Result result = Result.GenerateFailedResult();
     try
     {
         db.SubmitEndPointLog(endPointKeyPass, value, execTime);
         result = Result.GenerateOKResult();
     }
     catch { }
     return(result);
 }
Exemplo n.º 3
0
 public ResultInfo.Result SetCommandAsExecuted(long endPointCommandID, Guid endPointKeyPass, DateTime?execTime)
 {
     ResultInfo.Result result = Result.GenerateFailedResult();
     try
     {
         db.SubmitEndpointCommandExecuted(endPointCommandID, endPointKeyPass, execTime);
         result = Result.GenerateOKResult();
     }
     catch (Exception ex)
     { result.Message = ex.Message + " -- " + ex.InnerException; }
     return(result);
 }
 public ResultInfo.Result SetNotificationAsRead(long notificationID)
 {
     ResultInfo.Result res = Result.GenerateFailedResult("Error");
     try
     {
         UserNotification noti = db.UserNotifications.Find(notificationID);
         noti.IsRead = 2;
         db.SaveChanges();
         res = Result.GenerateOKResult();
     }
     catch (Exception ex)
     {
         res = Result.GenerateFailedResult(ex.Message);
     }
     return(res);
 }
Exemplo n.º 5
0
 public static ResultInfo.Result SendMail(MailsConfig mailsConfig, string to, string subject, string body)
 {
     ResultInfo.Result result = Result.GenerateFailedResult("");
     try
     {
         MailMessage mail   = new MailMessage(mailsConfig.Sender, to);
         SmtpClient  client = new SmtpClient();
         client.Port                  = mailsConfig.Port;
         client.DeliveryMethod        = SmtpDeliveryMethod.Network;
         client.UseDefaultCredentials = false;
         client.Host                  = mailsConfig.Host;
         mail.IsBodyHtml              = false;
         mail.Subject                 = subject;
         mail.Body = body;
         client.Send(mail);
         result = Result.GenerateOKResult();
     }
     catch (Exception ex)
     {
         result = Result.GenerateFailedResult("Mail send Failed", ex.Message);
     }
     return(result);
 }
Exemplo n.º 6
0
        public async Task <ResultInfo.Result> InstallDBChanges()
        {
            ResultInfo.Result result = Result.GenerateFailedResult();

            long lastCentralChangeID = 0;
            int  localDBChangesCount = db.DBChanges.Count();

            if (db.DBChanges.Count() > 0)
            {
                lastCentralChangeID = db.DBChanges.ToList()[localDBChangesCount - 1].CentralChangeID;
            }

            APIDBChangesRequestModels.GetDBChangesList requestModel = new APIDBChangesRequestModels.GetDBChangesList();
            requestModel.SearchFor      = "";
            requestModel.StartFrom      = lastCentralChangeID + 1;
            requestModel.PageNumber     = 1;
            requestModel.RecordsPerPage = 10;
            APIDBChangesResponseModels.GetDBChangesList responseModel = await client.DBChanges.GetDBChangesListAsync(requestModel);

            if (responseModel.DBChanges.Count > 0)
            {
                foreach (APIDBChange item in responseModel.DBChanges)
                {
                    db.Database.ExecuteSqlCommand(item.Script);
                    DBChanx dbChange = new DBChanx();
                    dbChange.CentralChangeID = item.ID;
                    dbChange.ChangeCode      = item.Code;
                    dbChange.TimeStamp       = DateTime.Now;
                    db.DBChanges.Add(dbChange);
                    db.SaveChanges();
                }
            }
            result = Result.GenerateOKResult();

            return(result);
        }