예제 #1
0
        /// <summary>
        /// 创建系统日志
        /// </summary>
        /// <param name="level">级别</param>
        /// <param name="type">类名,可自定义</param>
        /// <param name="parasHashtable">自定义参数,目前固定三个{UserId;IP;FunName}</param>
        /// <param name="message">内容</param>
        public void Log(MsgLevel level, System.String type, Hashtable parasHashtable, object message)
        {
            switch (level)
            {
            case MsgLevel.DEBUG:
                MyLog.Debug(type, parasHashtable, message);
                break;

            case MsgLevel.INFO:
                MyLog.Info(type, parasHashtable, message);
                break;

            case MsgLevel.WARN:
                MyLog.Warn(type, parasHashtable, message);
                break;

            case MsgLevel.ERROR:
                MyLog.Error(type, parasHashtable, message);
                break;

            case MsgLevel.FATAL:
                MyLog.Fatal(type, parasHashtable, message);
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// 创建系统日志
        /// </summary>
        /// <param name="level">级别</param>
        /// <param name="type">类名,可自定义</param>
        /// <param name="parasHashtable">自定义参数,目前固定三个{UserId;IP;FunName}</param>
        /// <param name="message">内容</param>
        public void Log(MsgLevel level, System.String type, Hashtable parasHashtable, object message)
        {
            switch (level)
            {
            case MsgLevel.Debug:
                MyLog.Debug(type, parasHashtable, message);
                break;

            case MsgLevel.Info:
                MyLog.Info(type, parasHashtable, message);
                break;

            case MsgLevel.Warn:
                MyLog.Warn(type, parasHashtable, message);
                break;

            case MsgLevel.Error:
                MyLog.Error(type, parasHashtable, message);
                break;

            case MsgLevel.Fatal:
                MyLog.Fatal(type, parasHashtable, message);
                break;
            }
        }
예제 #3
0
 public Student Update(Student student)
 {
     logger.Debug("Editing student");
     using (var context = this.studentContext)
     {
         var studentToUpdate = context.Students
                               .Find(student.ID);
         studentToUpdate.Apellidos         = student.Apellidos;
         studentToUpdate.Nombre            = student.Nombre;
         studentToUpdate.FechaDeNacimiento = student.FechaDeNacimiento;
         studentToUpdate.FechaHoraRegistro = student.FechaHoraRegistro;
         studentToUpdate.DNI  = student.DNI;
         studentToUpdate.Edad = student.Edad;
         context.SaveChanges();
         return(GetById(student.ID));
     }
 }
예제 #4
0
 public Student Update(Student student)
 {
     logger.Debug("Editing student");
     using (var context = this.studentContext)
     {
         var studentToUpdate = context.Students
                               .Find(student.IdAlumno);
         studentToUpdate.Apellido        = student.Apellido;
         studentToUpdate.Nombre          = student.Nombre;
         studentToUpdate.FechaNacimiento = student.FechaNacimiento;
         studentToUpdate.HoraRegistro    = student.HoraRegistro;
         studentToUpdate.Dni             = student.Dni;
         studentToUpdate.Edad            = student.Edad;
         context.SaveChanges();
         return(student);
     }
 }
예제 #5
0
 private void processScreenShotResult(Data_Net__03ScreenshotResult _03)
 {
     trayLog.Debug("ScreenshotResult " + _03.GetFileName());
     // 1) Delete the request file
     DSSwitch.msgFile02().Delete(niceSystem, _03.FileName, trayLog);
     // 2) Update the loopback file
     this.onScreenshot(_03.B64ScreenshotData, niceSystem);
 }
예제 #6
0
    protected void Commit_Click(object sender, EventArgs e)
    {
        IMyLog logUpgrade = MyLog.GetLogger("Upgrade");

        try
        {
            UpdateInfo priceInfo = getHardcodedPriceInfoOrGoBackToPricePage();

            int howManyNumbers = 0;
            int.TryParse(HowManyNumbers.SelectedItem.Value, out howManyNumbers);

            int howManyMessages = 0;
            int.TryParse(HowManyMessages.SelectedItem.Value, out howManyMessages);

            int howManyTopups = 0;
            int.TryParse(HowManyTopups.SelectedItem.Value, out howManyTopups);

            int fullpayment = 0;
            int.TryParse(FullPayment.SelectedItem.Value, out fullpayment);

            logUpgrade.Info("Commit");

            Data_AppUserWallet wal = Data_AppUserWallet.Create(
                sd.LoggedOnUserEmail,
                TitleId.Text,
                priceInfo.Info,
                priceInfo.Type,
                new AmountAndPrice(howManyNumbers, GetPrice(priceInfo.Number)),
                new AmountAndPrice(howManyMessages, GetPrice(priceInfo.Message)),
                new AmountAndPrice(howManyTopups, GetPrice(priceInfo.Month)),
                new AmountAndPrice(1, GetPrice(priceInfo.OneTimeSetup)),
                new AmountAndPrice(fullpayment, GetPrice(priceInfo.FullPayment)));

            string emailBody = wal.GetEmailBody(sd.LoggedOnUserName, sd.LoggedOnUserEmail);

            bool alreadyThere;
            DSSwitch.appWallet().StoreNew(wal, out alreadyThere, logUpgrade);

            EMail.SendGeneralEmail(sd.LoggedOnUserEmail, true, wal.Title, emailBody, new LogForEmailSend(MyLog.GetLogger("Email")));

            showStoredData(wal);
        }
        catch (DataUnavailableException)
        {
            DSSwitch.OnDataUnavailableException(this);
        }
        catch (Exception ex)
        {
            logUpgrade.Debug(ex.Message);
        }
    }
예제 #7
0
    protected void Calculate_Click(object sender, EventArgs e)
    {
        IMyLog logUpgrade = MyLog.GetLogger("Upgrade");

        try
        {
            UpdateInfo priceInfo = getHardcodedPriceInfoOrGoBackToPricePage();

            int howManyNumbers = 0;
            int.TryParse(HowManyNumbers.SelectedItem.Value, out howManyNumbers);

            int howManyMessages = 0;
            int.TryParse(HowManyMessages.SelectedItem.Value, out howManyMessages);

            int howManyTopups = 0;
            int.TryParse(HowManyTopups.SelectedItem.Value, out howManyTopups);

            int fullpayment = 0;
            int.TryParse(FullPayment.SelectedItem.Value, out fullpayment);

            Data_AppUserWallet wal = new Data_AppUserWallet(
                priceInfo.Type,
                new AmountAndPrice(howManyNumbers, GetPrice(priceInfo.Number)),
                new AmountAndPrice(howManyMessages, GetPrice(priceInfo.Message)),
                new AmountAndPrice(howManyTopups, GetPrice(priceInfo.Month)),
                new AmountAndPrice(1, GetPrice(priceInfo.OneTimeSetup)),
                new AmountAndPrice(fullpayment, GetPrice(priceInfo.FullPayment)));
            CalcInfo.Text = wal.CalucateCost().Explained;
            alterStep1DivVisibility(false, priceInfo,
                                    HowManyNumbers.SelectedIndex,
                                    HowManyMessages.SelectedIndex,
                                    HowManyTopups.SelectedIndex,
                                    FullPayment.SelectedIndex
                                    );
            CalcInfoDiv.Visible = true;
            CommitDiv.Visible   = true;
            CommitButton.Focus();
        }
        catch (Exception Ex)
        {
            logUpgrade.Debug(Ex.Message);
        }
    }
예제 #8
0
    protected void checkEmail_ServerValidate(ref bool bOk)
    {
        IMyLog log = MyLog.GetLogger("Register");

        resetError(errorEmail);
        string error = Data_AppUserFile.Check_Email(Email.Text);

        if (error != null)
        {
            setError(errorEmail, error, ref bOk);
        }
        else if (DSSwitch.appUser().HasAccount(Email.Text, log))
        {
            setError(errorEmail, "Email is already registred.", ref bOk);
        }
        else if (isOnBlacklist(Email.Text))
        {
            log.Debug("Blacklisted " + Email.Text + " refused");
            setError(errorEmail, "Email is invalid", ref bOk);
        }
    }
예제 #9
0
    protected void CancelCommit_Click(object sender, EventArgs e)
    {
        IMyLog logUpgrade = MyLog.GetLogger("Upgrade");

        try
        {
            logUpgrade.Info("CancelCommit_Click");

            sd.QuickMessage     = "You have just cancelled your upgrade request";
            sd.QuickMessageGood = true;

            DSSwitch.appWallet().DeleteOne(sd.LoggedOnUserEmail, logUpgrade);

            Response.Redirect("~/Price");
        }
        catch (DataUnavailableException)
        {
            DSSwitch.OnDataUnavailableException(this);
        }
        catch (Exception ex)
        {
            logUpgrade.Debug(ex.Message);
        }
    }
예제 #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This comes from the TrayApp

        IMyLog          trayLog   = MyLog.GetLogger("TrayApp");
        LogForEmailSend log4Email = new LogForEmailSend(MyLog.GetLogger("Email"));

        try
        {
            // 1) read in incoming object
            //log.Info("incoming msg");
            Data_Net_Tray2ASP fromTray  = new Data_Net_Tray2ASP();
            Stream            streamB64 = Request.InputStream;

            if (streamB64.Length == 0)
            {
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    ld.GetEntry_CreateIfNotThere(NiceSystemInfo.DEFAULT_STR).debugStr = "Zero is nice at " + DateTime.UtcNow.Ticks.ToUkTime(false);
                }
                Response.ContentType = "text/plain";
                Response.Write("Zero is nice!");
                return;
            }

            BinBase64StreamHelper.Tray2ASP_FromB64Stream(ref fromTray, streamB64);
            ASPTray_ObjectList.Counters fromTrayCounter = fromTray.GetCounters();
            if (fromTrayCounter.Total_Results() != 0)
            {
                trayLog.Debug("X " + fromTrayCounter.Total_ResultsString());
            }

            //trayLog.Debug("TrayApp request from " + fromTray.TrayType);
            NiceSystemInfo subSystem = fromTray.TrayType.GetSystemInfoFromTrayType();
            if (subSystem == null)
            {
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    ld.LastError = string.Format("incomming subSystem '{0}' not recognised. {1}",
                                                 fromTray.TrayType,
                                                 DateTime.UtcNow.Ticks.ToUkTime(false));
                }
                throw new SystemException("Unknown System: " + fromTray.TrayType);
            }
            //trayLog.Debug("TrayApp loaded " + subSystem.Name);

            // Update loopback file (with the data from the incoming object)
            using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
            {
                DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                sub.lastTrayConnection = DateTime.UtcNow;
                sub.lastTrayId         = fromTrayCounter.Total_ResultsString();
                sub.trayTypeAndIp      = fromTray.TrayType + " - " + Request.UserHostAddress + " - " + (Request.IsSecureConnection ? "https" : "httpONLY");
            }

            // 3) Process each file from the incoming object
            MessageProcessing_TrayFrom proc = new MessageProcessing_TrayFrom(subSystem, onScreenshot, trayLog, log4Email);
            proc.Process_TrayFrom(fromTray, true);

            // 5) prepare the object to be sent
            Data_Net_ASP2Tray toTray = new Data_Net_ASP2Tray();
            DateTime          dtGo   = DateTime.UtcNow.AddSeconds(3);
            while ((toTray.ObjectList.Count == 0) && (dtGo > DateTime.UtcNow))
            {
                // no data yet to send and no timeout
                toTray.ObjectList = MessageProcessing_TrayTo.GetFilesToSendToTray_ConsiderPriority(subSystem, 5, trayLog);
                if (toTray.ObjectList.Count == 0)
                {
                    Thread.Sleep(500);
                }
            }

            // 6) update the loopback file with the sent date
            ASPTray_ObjectList.Counters toTrayCounter = toTray.GetCounters();
            using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
            {
                DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                sub.lastToTray     = DateTime.UtcNow;
                sub.lastToTrayData = "FilesToProcess: " + toTrayCounter.Total_RequestsString();
            }

            // 7) send the object to be sent
            //            Response.ContentType = "application/octet-stream";
            Response.ContentType = "text/plain";
            BinBase64StreamHelper.ASP2Tray_ToB64Stream(ref toTray, Response.OutputStream);
        }
        catch (ThreadAbortException)
        {
            trayLog.Debug("ThreadAbortException");
        }
        catch (Exception se)
        {
            trayLog.Error("TrayApp " + se.Message + " " + se.ToString());
            Response.ContentType = "text/plain";
            Response.Write("Exception");
            Response.Write(se.Message);
            Response.Write(se.ToString());
        }
    }
예제 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This comes from the Android direct

        IMyLog trayLog = MyLog.GetLogger("TrayApp");

        trayLog.Info("Incoming 17:00");
        string inBody = "notSet";

        try
        {
            LogForEmailSend log4Email = new LogForEmailSend(MyLog.GetLogger("Email"));
            Stream          inStream  = Request.InputStream;

            if (inStream.Length == 0)
            {
                Response.ContentType = "text/plain";
                Response.Write("DirectTel: Zero!");
                return;
            }

            DirectTel_InJson inJson = null;
            using (var sr = new StreamReader(inStream))
            {
                inBody = sr.ReadToEnd();
                inJson = JsonConvert.DeserializeObject <DirectTel_InJson>(inBody);
            }
            trayLog.Debug("In Json: ");
            trayLog.Debug(JsonConvert.SerializeObject(inJson));

            DirectTel_OutJson outJson = DirectTel_Processing.ProcessDirectTel(inJson, trayLog, log4Email,
                                                                              delegate(NiceSystemInfo subSystem)
            {
                //OnGet
                // Update loopback file (with the data from the incoming object)
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                    sub.lastDirectTelGet        = DateTime.UtcNow;
                }
            },
                                                                              delegate(NiceSystemInfo subSystem)
            {
                //OnAck
                // Update loopback file (with the data from the incoming object)
                using (DataFile_Loopback ld = new DataFile_Loopback(DataFile_Base.OpenType.ForUpdate_CreateIfNotThere))
                {
                    DataFile_Loopback_Entry sub = ld.GetEntry_CreateIfNotThere(subSystem.Name);
                    sub.lastDirectTelAck        = DateTime.UtcNow;
                }
            });

            trayLog.Debug("Out Json: ");
            trayLog.Debug(JsonConvert.SerializeObject(outJson));
            Tx(outJson);
        }
        catch (ThreadAbortException)
        {
            trayLog.Debug("ThreadAbortException");
        }
        catch (Exception se)
        {
            trayLog.Error("DirectTel " + se.Message + " " + se.ToString());
            trayLog.Error("DirectTel " + inBody);
            Response.ContentType = "text/plain";
            Response.Write("Exception");
            Response.Write(se.Message);
            Response.Write(se.ToString());
        }
    }
예제 #12
0
        public static DirectTel_OutJson ProcessDirectTel(DirectTel_InJson inJson, IMyLog trayLog, LogForEmailSend log4Email, dOnAction onGet, dOnAction onAck)
        {
            trayLog.Debug("DirectTel: Loading " + inJson.SubSystem);
            NiceSystemInfo subSystem = inJson.SubSystem.GetSystemInfoFromTrayType();

            if (subSystem == null)
            {
                throw new Exception("subSystem == null");
            }

            switch (inJson.Inst)
            {
            case "Get":
            {
                // Update loopback file (with the data from the incoming object)
                if (onGet != null)
                {
                    onGet(subSystem);
                }

                // Prepare the object to be sent
                ASPTrayBase trayBase = MessageProcessing_TrayTo.GetFilesToSendToTray_ConsiderPriority(subSystem, 1, trayLog).FirstOrDefault();
                if (trayBase == null)
                {
                    // nothing, so just wait
                    return(new DirectTel_OutJson()
                        {
                            WaitSec = 10,
                        });
                }
                if (trayBase is Data_Net__00NormalMessage)
                {
                    Data_Net__00NormalMessage _00 = trayBase as Data_Net__00NormalMessage;
                    return(new DirectTel_OutJson()
                        {
                            Id = "00" + _00.GetFileName(),
                            Zapi = _00.DestMobile.Replace("+", ""),
                            Text = _00.Msg,
                            IsAddTelOnly = false,
                            WaitSec = 1,
                        });
                }
                if (trayBase is Data_Net__04CheckTelNumbers)
                {
                    Data_Net__04CheckTelNumbers _04 = trayBase as Data_Net__04CheckTelNumbers;
                    MobileNoHandler             h   = new MobileNoHandler(_04.TelList);
                    string firstTel = h.MobileNumberX_AsZapi(0);
                    return(new DirectTel_OutJson()
                        {
                            Id = "04" + _04.GetFileName(),
                            Zapi = firstTel,
                            Text = null,
                            IsAddTelOnly = true,
                            WaitSec = 1,
                        });
                }
            }
            break;

            case "Ack":
                // Update loopback file (with the data from the incoming object)
                if (onAck != null)
                {
                    onAck(subSystem);
                }

                MessageProcessing_TrayFrom proc   = new MessageProcessing_TrayFrom(subSystem, null, trayLog, log4Email);
                Data_Net_Tray2ASP          helper = new Data_Net_Tray2ASP();
                if (inJson.Id.StartsWith("00"))
                {
                    inJson.Id = inJson.Id.Substring(2);
                    Data_Net__01NormalMessageResult _01 = new Data_Net__01NormalMessageResult(inJson.Id, true);
                    helper.ObjectList.Add(_01);
                    proc.Process_TrayFrom(helper, true);
                    return(new DirectTel_OutJson());
                }
                else if (inJson.Id.StartsWith("04"))
                {
                    inJson.Id = inJson.Id.Substring(2);
                    Data_Net__05CheckTelNumbersResult _05 = new Data_Net__05CheckTelNumbersResult(inJson.Id, null, null, null);
                    helper.ObjectList.Add(_05);
                    proc.Process_TrayFrom(helper, true);
                    return(new DirectTel_OutJson());
                }
                else
                {
                }


                break;

            default:
                throw new Exception("Unknown inst");
            }

            return(null);
        }