Ejemplo n.º 1
0
 public ActionResult SystemParametersSQLImplemention(Models.SMSSystemParameters SMSSystemParameters)
 {
     using (Models.AfiscIVREntities db = new Models.AfiscIVREntities())
     {
         var SMSSystemParametersObj = (from s in db.SMSSystemParameters where s.SN == 1 select s).FirstOrDefault();
         //判斷此obj是否有資料,若沒資料直接return錯誤
         if (SMSSystemParametersObj == default(Models.SMSSystemParameters))
         {
             logger.Debug("修改失敗,資料庫無此資料");
         }
         else
         {
             SMSSystemParametersObj.SN             = 1;
             SMSSystemParametersObj.FtpServerIP    = SMSSystemParameters.FtpServerIP;
             SMSSystemParametersObj.FtpPort        = SMSSystemParameters.FtpPort;
             SMSSystemParametersObj.FtpAccount     = SMSSystemParameters.FtpAccount;
             SMSSystemParametersObj.FtpPassword    = ase256method.AES256_Encrypt(ase256method.Key, ase256method.IV, SMSSystemParameters.FtpPassword);
             SMSSystemParametersObj.SMSAccount     = SMSSystemParameters.SMSAccount;
             SMSSystemParametersObj.SMSPassword    = ase256method.AES256_Encrypt(ase256method.Key, ase256method.IV, SMSSystemParameters.SMSPassword);
             SMSSystemParametersObj.SMSApiIp       = SMSSystemParameters.SMSApiIp;
             SMSSystemParametersObj.SumFtpIp       = SMSSystemParameters.SumFtpIp;
             SMSSystemParametersObj.SumFtpPort     = SMSSystemParameters.SumFtpPort;
             SMSSystemParametersObj.SumFtpAccount  = SMSSystemParameters.SumFtpAccount;
             SMSSystemParametersObj.SumFtpPassword = ase256method.AES256_Encrypt(ase256method.Key, ase256method.IV, SMSSystemParameters.SumFtpPassword);
             SMSSystemParametersObj.MailServer     = SMSSystemParameters.MailServer;
             SMSSystemParametersObj.MailPort       = SMSSystemParameters.MailPort;
             SMSSystemParametersObj.MailAccount    = SMSSystemParameters.MailAccount;
             SMSSystemParametersObj.MailPassword   = ase256method.AES256_Encrypt(ase256method.Key, ase256method.IV, SMSSystemParameters.MailPassword);
             SMSSystemParametersObj.MailEncryption = SMSSystemParameters.MailEncryption;
             SMSSystemParametersObj.MailContent    = SMSSystemParameters.MailContent;
             SMSSystemParametersObj.UpdateTime     = DateTime.Now;
             logger.Debug(" 更新成功!");
             try
             {
                 db.SaveChanges();
             }
             catch (Exception e)
             {
                 logger.Debug("執行SQLCMD失敗" + e.ToString());
             }
         }
         return(Json(SMSSystemParametersObj));
     }
 }
Ejemplo n.º 2
0
        public ActionResult MessageUpload(string UploadNo, List <Models.MessageContent> MessageContent)
        {
            using (Models.AfiscIVREntities db = new Models.AfiscIVREntities())
            {
                foreach (var item in MessageContent)
                {
                    //new AfiscSMS.SmsService(item.PhoneNumber, item.Content);
                    var MessageObj = new Models.SMSApiRecord();
                    MessageObj.UpdateTime = DateTime.Now;//此刻時間
                    MessageObj.FId        = Guid.NewGuid().ToString();
                    MessageObj.Type       = "自動簡訊上傳";
                    MessageObj.UploadNo   = UploadNo;
                    MessageObj.SwiftCod   = item.ID;
                    MessageObj.chanel     = "簡訊平台";
                    MessageObj.FileName   = item.Filename;
                    //MessageObj.ApiNo = "";
                    MessageObj.UploadNo = UploadNo;
                    // MessageObj.SMSNo = "";
                    // MessageObj.UserId = "";
                    MessageObj.Phone   = item.PhoneNumber;
                    MessageObj.Content = item.Content;
                    // MessageObj.Batch = "";
                    //MessageObj.BatchResult = "";
                    //MessageObj.CreateTime = "";
                    //MessageObj.SMSSendTime = "";


                    db.SMSApiRecord.Add(MessageObj);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        logger.Debug("執行SQLCMD失敗" + e.ToString());
                    }
                    logger.Debug("項號 " + MessageObj.FId + " 新增成功!");
                }
            }
            return(Json("1"));
        }
Ejemplo n.º 3
0
        public ActionResult ATMSearchesSQLImplement(int Operation, Models.ATMSearch atmsearches)
        {
            bool   sendMail = false;
            string tempString = null, tempMailAccount = null, tempUserNumber = null, tempUserPD = null, tempType = null;

            using (Models.AfiscIVREntities db = new Models.AfiscIVREntities())
            {
                if (Operation == 1)
                {
                    atmsearches.CreateTime = DateTime.Now;                                                                       //此刻時間
                    atmsearches.UserPD     = ase256method.AES256_Encrypt(ase256method.Key, ase256method.IV, atmsearches.UserPD); //密碼加密
                    db.ATMSearch.Add(atmsearches);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        logger.Debug("執行SQLCMD失敗" + e.ToString());
                    }
                    logger.Debug("項號 " + atmsearches.SN.ToString() + " 新增成功!");
                    //查看新增時有新增櫃員代號
                    if (atmsearches.UserNumber != null)
                    {
                        sendMail        = true;
                        tempMailAccount = atmsearches.UserMail;
                        tempUserNumber  = atmsearches.UserNumber;
                        tempUserPD      = atmsearches.UserPD;
                        tempType        = atmsearches.Type.ToString();
                    }
                }
                else if (Operation == 2)//sql update operation
                {
                    var atmsearchesObj = (from s in db.ATMSearch where s.SN == atmsearches.SN select s).FirstOrDefault();
                    //判斷此obj是否有資料,若沒資料直接return錯誤
                    if (atmsearchesObj == default(Models.ATMSearch))
                    {
                        logger.Debug("修改失敗,資料庫無此筆Id資料");
                    }
                    else
                    {
                        atmsearchesObj.Type       = atmsearches.Type;
                        atmsearchesObj.UserNumber = atmsearches.UserNumber;
                        tempString                = atmsearchesObj.UserPD;
                        atmsearchesObj.UserPD     = ase256method.AES256_Encrypt(ase256method.Key, ase256method.IV, atmsearches.UserPD);
                        atmsearchesObj.UserMail   = atmsearches.UserMail;
                        atmsearchesObj.CreateUser = atmsearches.CreateUser;
                        atmsearchesObj.CreateTime = DateTime.Now;
                        logger.Debug("項號 " + atmsearches.SN.ToString() + " 更新成功!");
                        try
                        {
                            db.SaveChanges();
                        }
                        catch (Exception e)
                        {
                            logger.Debug("執行SQLCMD失敗" + e.ToString());
                        }
                        //判斷是有更新櫃員密碼
                        if (tempString != atmsearchesObj.UserPD)
                        {
                            sendMail = true;
                        }
                        tempMailAccount = atmsearches.UserMail;
                        tempUserNumber  = atmsearches.UserNumber;
                        tempUserPD      = atmsearches.UserPD;
                        tempType        = atmsearches.Type.ToString();
                    }
                }
                else
                {
                    var atmsearchesObj = (from s in db.ATMSearch where s.SN == atmsearches.SN select s).FirstOrDefault();
                    //判斷此obj是否有資料,若沒資料直接return錯誤
                    if (atmsearchesObj == default(Models.ATMSearch))
                    {
                        logger.Debug("修改失敗,資料庫無此筆Id資料");
                    }
                    else
                    {
                        try
                        {
                            db.ATMSearch.Remove(atmsearchesObj);
                            db.SaveChanges();
                            logger.Debug("項號 " + atmsearches.SN.ToString() + " 刪除成功!");
                        }
                        catch (Exception e)
                        {
                            logger.Debug("執行SQLCMD失敗" + e.ToString());
                        }
                    }
                }
                //若有新增櫃員代號或變更櫃員密碼則寄信通知
                if (sendMail)
                {
                    Mailmethod.SendEmail(tempMailAccount, tempUserNumber, tempUserPD, tempType);
                }
                return(Json(atmsearches));
            }
        }
Ejemplo n.º 4
0
 public ActionResult SMSSendParameterSQLImplement(int Operation, Models.SMSSendParameters SMSSendParameters)
 {
     using (Models.AfiscIVREntities db = new Models.AfiscIVREntities())
     {
         if (Operation == 1)
         {
             SMSSendParameters.UpdateTime = DateTime.Now;//此刻時間
             SMSSendParameters.SN         = db.SMSSendParameters.Max(p => p.SN) + 1;
             db.SMSSendParameters.Add(SMSSendParameters);
             try
             {
                 db.SaveChanges();
             }
             catch (Exception e)
             {
                 logger.Debug("執行SQLCMD失敗" + e.ToString());
             }
             logger.Debug("項號 " + SMSSendParameters.SN + " 新增成功!");
         }
         else if (Operation == 2)//sql update operation
         {
             var Obj = (from s in db.SMSSendParameters where s.FTPFileCode == SMSSendParameters.FTPFileCode select s).FirstOrDefault();
             //判斷此obj是否有資料,若沒資料直接return錯誤
             if (Obj == default(Models.SMSSendParameters))
             {
                 logger.Debug("修改失敗,資料庫無此筆Id資料");
             }
             else
             {
                 Obj.FTPFileCode       = SMSSendParameters.FTPFileCode;
                 Obj.FTPFileName       = SMSSendParameters.FTPFileName;
                 Obj.FtpDateTime1      = SMSSendParameters.FtpDateTime1;
                 Obj.FtpDateTime2      = SMSSendParameters.FtpDateTime2;
                 Obj.FtpDateTime3      = SMSSendParameters.FtpDateTime3;
                 Obj.FtpDateTime4      = SMSSendParameters.FtpDateTime4;
                 Obj.FtpDateTime5      = SMSSendParameters.FtpDateTime5;
                 Obj.FtpDateTime6      = SMSSendParameters.FtpDateTime6;
                 Obj.FtpDateTime7      = SMSSendParameters.FtpDateTime7;
                 Obj.SMSStartTime1     = SMSSendParameters.SMSStartTime1;
                 Obj.SMSStartTime2     = SMSSendParameters.SMSStartTime2;
                 Obj.SMSStartTime3     = SMSSendParameters.SMSStartTime3;
                 Obj.SMSStartTime4     = SMSSendParameters.SMSStartTime4;
                 Obj.SMSStartTime5     = SMSSendParameters.SMSStartTime5;
                 Obj.SMSStartTime6     = SMSSendParameters.SMSStartTime6;
                 Obj.SMSStartTime7     = SMSSendParameters.SMSStartTime7;
                 Obj.UpdateLoop1       = SMSSendParameters.UpdateLoop1;
                 Obj.UpdateLoop2       = SMSSendParameters.UpdateLoop2;
                 Obj.UpdateLoop3       = SMSSendParameters.UpdateLoop3;
                 Obj.UpdateLoop4       = SMSSendParameters.UpdateLoop4;
                 Obj.UpdateLoop5       = SMSSendParameters.UpdateLoop5;
                 Obj.UpdateLoop6       = SMSSendParameters.UpdateLoop6;
                 Obj.UpdateLoop7       = SMSSendParameters.UpdateLoop7;
                 Obj.ResultUpdateTime1 = SMSSendParameters.ResultUpdateTime1;
                 Obj.ResultUpdateTime2 = SMSSendParameters.ResultUpdateTime2;
                 Obj.ResultUpdateTime3 = SMSSendParameters.ResultUpdateTime3;
                 Obj.ResultUpdateTime4 = SMSSendParameters.ResultUpdateTime4;
                 Obj.ResultUpdateTime5 = SMSSendParameters.ResultUpdateTime5;
                 Obj.ResultUpdateTime6 = SMSSendParameters.ResultUpdateTime6;
                 Obj.ResultUpdateTime7 = SMSSendParameters.ResultUpdateTime7;
                 Obj.UpdateInterval1   = SMSSendParameters.UpdateInterval1;
                 Obj.UpdateInterval2   = SMSSendParameters.UpdateInterval2;
                 Obj.UpdateInterval3   = SMSSendParameters.UpdateInterval3;
                 Obj.UpdateInterval4   = SMSSendParameters.UpdateInterval4;
                 Obj.UpdateInterval5   = SMSSendParameters.UpdateInterval5;
                 Obj.UpdateInterval6   = SMSSendParameters.UpdateInterval6;
                 Obj.UpdateInterval7   = SMSSendParameters.UpdateInterval7;
                 Obj.UpdateTime        = DateTime.Now;
                 logger.Debug("項號 " + Obj.SN.ToString() + " 更新成功!");
                 try
                 {
                     db.SaveChanges();
                 }
                 catch (Exception e)
                 {
                     logger.Debug("執行SQLCMD失敗" + e.ToString());
                 }
             }
         }
         else
         {
             var Obj = (from s in db.SMSSendParameters where s.FTPFileCode == SMSSendParameters.FTPFileCode select s).FirstOrDefault();
             //判斷此obj是否有資料,若沒資料直接return錯誤
             if (Obj == default(Models.SMSSendParameters))
             {
                 logger.Debug("修改失敗,資料庫無此筆FTPFileCode資料");
             }
             else
             {
                 try
                 {
                     db.SMSSendParameters.Remove(Obj);
                     db.SaveChanges();
                     logger.Debug("項號 " + Obj.SN.ToString() + " 刪除成功!");
                 }
                 catch (Exception e)
                 {
                     logger.Debug("執行SQLCMD失敗" + e.ToString());
                 }
             }
         }
         return(Json(SMSSendParameters));
     }
 }