private SysLog DefaultValues(SysLog row)
 {
     return row;
 }
Beispiel #2
0
 public void setException(Exception ex, SysLog Log)
 {
     Message = ex.Message;
     Log.Exception(ex);
 }
Beispiel #3
0
        /// <summary>
        /// Implements the background thread responsible for persisting buffered <see cref="GeoFix "/>es .
        /// </summary>
        private void FlushThread()
        {
            bool             stopCompleted = false;
            List <FixRecord> writeFixes;

            while (true)
            {
                writeFixes = null;

                try
                {
                    lock (syncLock)
                    {
                        if (!isRunning)
                        {
                            return;
                        }

                        if (stopPending || bufferedFixes.Count >= bufferSize || flushTimer.HasFired)
                        {
                            writeFixes    = bufferedFixes;
                            bufferedFixes = new List <FixRecord>(writeFixes.Count);
                        }
                    }

                    if (writeFixes != null && writeFixes.Count > 0)
                    {
                        // Build SQL batch command that to add all of the buffered fixes using
                        // the SQL script template to generate the T-SQL statements for each fix.

                        var processor = new MacroProcessor();
                        var sqlBatch  = new StringBuilder(8192);

                        foreach (var record in writeFixes)
                        {
                            if (record.EntityID == null)
                            {
                                SysLog.LogWarning("SqlGeoFixArchiver: GeoFix has a [EntityID=NULL] field and will be ignored.");
                            }

                            if (!record.Fix.TimeUtc.HasValue)
                            {
                                SysLog.LogWarning("SqlGeoFixArchiver: GeoFix has a [TimeUtc=NULL] field and will be ignored.");
                            }

                            if (double.IsNaN(record.Fix.Latitude))
                            {
                                SysLog.LogWarning("SqlGeoFixArchiver: GeoFix has a [Latitude=NaN] field and will be ignored.");
                            }

                            if (double.IsNaN(record.Fix.Longitude))
                            {
                                SysLog.LogWarning("SqlGeoFixArchiver: GeoFix has a [Longitude=NaN] field and will be ignored.");
                            }

                            processor["EntityID"]           = ToSqlLiteral(record.EntityID);
                            processor["GroupID"]            = ToSqlLiteral(record.GroupID);
                            processor["TimeUtc"]            = ToSqlLiteral(record.Fix.TimeUtc);
                            processor["Technology"]         = ToSqlLiteral(record.Fix.Technology);
                            processor["Latitude"]           = ToSqlLiteral(record.Fix.Latitude);
                            processor["Longitude"]          = ToSqlLiteral(record.Fix.Longitude);
                            processor["Altitude"]           = ToSqlLiteral(record.Fix.Altitude);
                            processor["Course"]             = ToSqlLiteral(record.Fix.Course);
                            processor["Speed"]              = ToSqlLiteral(record.Fix.Speed);
                            processor["HorizontalAccuracy"] = ToSqlLiteral(record.Fix.HorizontalAccuracy);
                            processor["VerticalAccurancy"]  = ToSqlLiteral(record.Fix.VerticalAccurancy);
                            processor["NetworkStatus"]      = ToSqlLiteral(record.Fix.NetworkStatus);

                            sqlBatch.AppendLine(processor.Expand(addScript));
                        }

                        // Submit the T-SQL batch to the server.

                        var sqlCtx = new SqlContext(conString);

                        sqlCtx.Open();
                        try
                        {
                            sqlCtx.Execute(sqlBatch.ToString());
                            node.IncrementFixesReceivedBy(writeFixes.Count);
                        }
                        catch (SqlException e)
                        {
                            const string msgTemplate =
                                @"SQL Error [Line {1}]: {0}

{2}
";
                            SysLog.LogException(e);
                            SysLog.LogError(msgTemplate, e.Message, e.LineNumber, sqlBatch);
                        }
                        finally
                        {
                            sqlCtx.Close();
                        }
                    }
                }
                catch (Exception e)
                {
                    SysLog.LogException(e);
                }
                finally
                {
                    if (writeFixes != null)
                    {
                        writeFixes = null;
                        flushTimer.Reset();
                    }
                }

                if (stopCompleted)
                {
                    return;
                }

                if (stopPending)
                {
                    // Loop one more time to archive any fixes cached while we were
                    // persisting to the database.

                    stopCompleted = true;
                    continue;
                }

                Thread.Sleep(settings.BkInterval);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Gets the order information.
        /// </summary>
        void GetOrderInfo()
        {
            try
            {
                using (var conn = DB.dbConn())
                {
                    conn.Open();
                    using (var cmd = new SqlCommand("aspdnsf_GetOrderDetail", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@ORDERNUMBER", OrderNumber);

                        reader = cmd.ExecuteReader();
                        if (reader.Read())
                        {
                            lblOrderNumber.Text         = reader["OrderNumber"].ToString();
                            hplPrintReceipt.NavigateUrl = "OrderReceipt.aspx?ordernumber=" + lblOrderNumber.Text.Trim();
                            lblOrderDate.Text           = Localization.ConvertLocaleDate(reader["OrderDate"].ToString(), Localization.GetDefaultLocale(), ThisCustomer.LocaleSetting);
                            //Billing Address
                            lblBAFullName.Text = reader["BillingFirstName"].ToString() + ' ' +
                                                 reader["BillingLastName"].ToString();
                            lblBACompany.Text      = reader["BillingCompany"].ToString();
                            lblBAAddress1.Text     = reader["BillingAddress1"].ToString();
                            lblBAAddress2.Text     = reader["BillingAddress2"].ToString();
                            lblBASuite.Text        = reader["BillingSuite"].ToString();
                            lblBACityStateZip.Text = reader["BillingCity"] + ", " + reader["BillingState"] + ' ' +
                                                     reader["BillingZip"];
                            lblBACountry.Text = reader["BillingCountry"].ToString();
                            lblBAPhone.Text   = reader["BillingPhone"].ToString();
                            //Shipping Address
                            lblSAFullName.Text = reader["ShippingFirstName"].ToString() + ' ' +
                                                 reader["ShippingLastName"].ToString();
                            lblSACompany.Text      = reader["ShippingCompany"].ToString();
                            lblSAAddress1.Text     = reader["ShippingAddress1"].ToString();
                            lblSAAddress2.Text     = reader["ShippingAddress2"].ToString();
                            lblSASuite.Text        = reader["ShippingSuite"].ToString();
                            lblSACityStateZip.Text = reader["ShippingCity"] + ", " + reader["ShippingState"] + ' ' +
                                                     reader["ShippingZip"];
                            lblSACountry.Text = reader["ShippingCountry"].ToString();
                            lblSAPhone.Text   = reader["ShippingPhone"].ToString();
                            //Payment Methods
                            if (reader["PaymentMethod"].ToString().Equals(AppLogic.ro_PMCreditCard))
                            {
                                decimal NetTotal = Convert.ToDecimal(reader["OrderTotal"]);
                                if (NetTotal == System.Decimal.Zero && AppLogic.AppConfigBool("SkipPaymentEntryOnZeroDollarCheckout"))
                                {
                                    lblPMCardInfo.Text      = AppLogic.GetString("checkoutpayment.aspx.28", SkinID, ThisCustomer.LocaleSetting);
                                    lblPMExpireDate.Visible = false;
                                    lblPMCountry.Visible    = false;
                                }
                                else
                                {
                                    lblPMCardInfo.Text = reader["CardType"].ToString() + ' ' +
                                                         (string.Concat("*********", reader["CardNumber"].ToString()));
                                    lblPMExpireDate.Text = "order.aspx.2".StringResource() + " " + reader["CardExpirationMonth"] + '/' +
                                                           reader["CardExpirationYear"];
                                    lblPMCountry.Text = reader["BillingCountry"].ToString();
                                }
                            }
                            else
                            {
                                lblPMCardInfo.Text      = "order.aspx.1".StringResource() + " " + reader["PONumber"].ToString();
                                lblPMExpireDate.Visible = false;
                                lblPMCountry.Visible    = false;
                                lblPurchasefee.Visible  = true;
                                lblPurchasefee.Text     = "PurchaseOrder.aspx.1".StringResource() + ": " + string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), Convert.ToDecimal(reader["InvoiceFee"]));
                            }
                            //Billing Amounts
                            lblSubTotal.Text     = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), Convert.ToDecimal(reader["OrderSubtotal"]));
                            lblTax.Text          = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), Convert.ToDecimal(reader["OrderTax"]));
                            lblShippingCost.Text = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), Convert.ToDecimal(reader["OrderShippingCosts"]));
                            lblTotalAmount.Text  = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), Convert.ToDecimal(reader["OrderTotal"]));
                            shipmentChargesPaid  = Convert.ToDecimal(reader["ShipmentChargesPaid"].ToString());

                            SetPageHeading(int.Parse(reader["CustomerID"].ToString()), reader["FirstName"].ToString(), reader["LastName"].ToString());

                            for (var i = 2; i < 7; i++)
                            {
                                if (Convert.ToDecimal(reader[i.ToString()].ToString()) != 0)
                                {
                                    lstFund[i] =
                                        lstFund[i] + Convert.ToDecimal(reader[i.ToString()].ToString());

                                    if (lstFund[i] != 0 && i == (int)FundType.SOFFunds)
                                    {
                                        lblSOFFundsTotal.Text           = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), lstFund[i]);
                                        lblSOFFundsTotalCaption.Visible = true;
                                        if (shipmentChargesPaid > 0)
                                        {
                                            lblSOFFundsTotal.Text        = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), lstFund[i] + shipmentChargesPaid);
                                            lblSOFFundsTotalCaption.Text = AppLogic.GetString("SOFFundsCaptionWithShipmentCharges", ThisCustomer.LocaleSetting);;
                                        }
                                    }
                                    else if (lstFund[i] != 0 && i == (int)FundType.DirectMailFunds)
                                    {
                                        lblDirectMailFundsTotal.Text           = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), lstFund[i]);
                                        lblDirectMailFundsTotalCaption.Visible = true;
                                    }
                                    else if (lstFund[i] != 0 && i == (int)FundType.DisplayFunds)
                                    {
                                        lblDisplayFundsTotal.Text           = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), lstFund[i]);
                                        lblDisplayFundsTotalCaption.Visible = true;
                                    }
                                    else if (lstFund[i] != 0 && i == (int)FundType.LiteratureFunds)
                                    {
                                        lblLiteratureFundsTotal.Text           = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), lstFund[i]);
                                        lblLiteratureFundsTotalCaption.Visible = true;
                                    }
                                    else if (lstFund[i] != 0 && i == (int)FundType.POPFunds)
                                    {
                                        lblPOPFundsTotal.Text           = string.Format(CultureInfo.GetCultureInfo(ThisCustomer.LocaleSetting), AppLogic.AppConfig("CurrencyFormat"), lstFund[i]);
                                        lblPOPFundsTotalCaption.Visible = true;
                                    }
                                }
                            }
                            if (lstFund.Sum(x => Convert.ToDecimal(x)) <= 0)
                            {
                                lblCreditsUsedCaption.Visible = false;
                            }
                        }
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.LogMessage(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " :: " + System.Reflection.MethodBase.GetCurrentMethod().Name,
                                  ex.Message + ((ex.InnerException != null && string.IsNullOrEmpty(ex.InnerException.Message)) ? " :: " + ex.InnerException.Message : ""),
                                  MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);
            }
        }
        public async void CmdPayment()
        {
            try
            {
                //if (!PayPrc.Equals("0"))
                //{
                IsBusy = true;

                using (RequestArbitrageServiceReqModel req = new RequestArbitrageServiceReqModel())
                {
                    req.userEmail = MainViewModel.LoginDataModel.userEmail;
                    req.cnKndCd   = SelectedCoinCode;

                    using (ResponseArbitrageServiceReqModel res = await WebApiLib.AsyncCallEncrypt <ResponseArbitrageServiceReqModel, RequestArbitrageServiceReqModel>(req))
                    {
                        if (res.resultStrCode == "000")
                        {
                            string resultCd = res.data.failCd;
                            if (resultCd.Equals(""))
                            {
                                Messenger.Default.Send("AssetsRefresh");
                                WindowService.Close();
                            }
                            else if (resultCd.Equals("998"))
                            {
                                Alert alert = new Alert(Localization.Resource.ArbitrageRequestPop_Alert_1, 300);
                                alert.ShowDialog();
                            }
                            else if (resultCd.Equals("997"))
                            {
                                Alert alert = new Alert(Localization.Resource.ArbitrageRequestPop_Alert_2, 300);
                                alert.ShowDialog();
                            }
                            else if (resultCd.Equals("786"))
                            {
                                Alert alert = new Alert(Localization.Resource.ArbitrageRequestPop_Alert_3, 300);
                                alert.ShowDialog();
                            }
                            else if (resultCd.Equals("785"))
                            {
                                Alert alert = new Alert(Localization.Resource.ArbitrageRequestPop_Alert_4, 300);
                                alert.ShowDialog();
                            }
                        }
                        else
                        {
                            Alert alert = new Alert(Localization.Resource.AutoTradingAdditionalPop_6, 300);
                            alert.ShowDialog();
                        }
                    }
                }
                //}
                //else
                //{
                //    Alert alert = new Alert(Localization.Resource.AutoTradingAdditionalPop_5, 350);
                //    alert.ShowDialog();
                //}
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
            finally
            {
                IsBusy = false;
            }
        }
        //玩家登陆
        private void Login(bool isfig = true)
        {
            var isLock = this.mLockIpInfoService.IsLockIp(Utils.GetIp());

            if (isLock)
            {
                //获取跳转地址
                AppGlobal.RenderResult(ApiCode.DisabledIp, this.GetRefDns());
                return;
            }

            //登陆名
            string loginCode = Request.Params["M_LOGINCODE"];
            //登陆密码
            string pwd = Request.Params["M_LOGINPWD"];
            //验证码
            string code = Request.Params["M_LOGINVIDACODE"];

            if (string.IsNullOrEmpty(loginCode) || string.IsNullOrEmpty(pwd))
            {
                AppGlobal.RenderResult(ApiCode.ParamEmpty);
                return;
            }
            if (string.IsNullOrEmpty(code) && isfig)
            {
                AppGlobal.RenderResult(ApiCode.ParamEmpty);
                return;
            }


            var item = this.mSysUserService.Get(loginCode, pwd);

            if (null == item)
            {
                AppGlobal.RenderResult(ApiCode.ValidationFails);
                return;
            }
            if (item.IsDelete)
            {
                AppGlobal.RenderResult(ApiCode.DisabledCode, this.GetRefDns());
                return;
            }


            string       sessionid = Guid.NewGuid().ToString();
            CookUserInfo info      = new CookUserInfo();

            info.Id         = item.Id;
            info.Code       = item.Code;
            info.NikeName   = item.NikeName;
            info.Sex        = sessionid;
            info.Head       = item.Head;
            info.Rebate     = item.Rebate;
            info.UserType   = item.UserType;
            info.IsRecharge = item.IsRecharge;
            info.PlayType   = item.PlayType;
            info.ProxyLevel = item.ProxyLevel;

            FormsPrincipal <CookUserInfo> .SignIn(loginCode, info, FormsAuthentication.Timeout.Minutes);

            //Ytg.ServerWeb.BootStrapper.SessionManager.AddOrUpdateSession(item.Id,new YtgSession()
            //{
            //    UserId = item.Id,
            //    SessionId = sessionid,
            //    OccDate = DateTime.Now,
            //    Code = item.Code
            //});


            string loginIpAddress = Ytg.Comm.Utils.GetIp();
            int    state          = this.mSysUserSessionService.UpdateInsertUserSession(new UserSession()
            {
                UserId      = item.Id,
                SessionId   = sessionid,
                LoginIp     = loginIpAddress,
                LoginClient = Ytg.Comm.Utils.GetLoginClientType(),
            });
            string loginCityName = "";//Utils.GetCityByIp(item.LastLoginIp);//获取所在城市
            string useSource     = System.Web.HttpContext.Current.Request.Params["usesource"];
            //判断是否为移动设备访问
            bool isMobile = Utils.IsMobile();

            if (isMobile)
            {
                useSource = "移动设备";
            }

            /**记录日志*/
            SysLog log = new SysLog()
            {
                Descript      = loginCityName,
                Ip            = loginIpAddress,
                OccDate       = DateTime.Now,
                ReferenceCode = info.Code,
                ServerSystem  = Ytg.Comm.Utils.GetUserSystem(),
                Type          = 0,
                UserId        = info.Id,
                UseSource     = useSource
            };

            /**记录日志 end*/

            //修改用户登录时间
            item.LastLoginTime = DateTime.Now;
            item.LastLoginIp   = loginIpAddress;
            item.IsLogin       = true;
            item.IsLineLogin   = true;
            item.LastCityName  = log.Descript;
            item.ServerSystem  = log.ServerSystem;
            item.UseSource     = log.UseSource;
            item.LoginCount++;//登录次数增加
            this.mSysUserService.Save();
            //单点登录
            // DanDianLogin(info.Id.ToString());

            //输出结果
            AppGlobal.RenderResult <CookUserInfo>(ApiCode.Success, info);
            //添加登录日志
            Ytg.Service.Logic.LogHelper.AddLog(log);
        }
Beispiel #7
0
        /// <summary>
        /// Handles the Click event of the btnResendInfotoFulfillmentAPI control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnResendInfotoFulfillmentAPI_Click(object sender, EventArgs e)
        {
            string message = AppLogic.GetString("SentFulfillmentAPI.Success", SkinID, ThisCustomer.LocaleSetting.ToString());

            try
            {
                using (var conn = DB.dbConn())
                {
                    conn.Open();
                    using (var cmd = new SqlCommand("aspdnsf_GetOrderItemsDetail", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@ORDERNUMBER", OrderNumber);
                        reader2 = cmd.ExecuteReader();
                        int totalRRDRow = 0;
                        while (reader2.Read())
                        {
                            if ((reader2["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor RRD", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader2["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor CDS Publications", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader2["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor Wetzel Brothers", SkinID, ThisCustomer.LocaleSetting)))
                            {
                                totalRRDRow++;
                            }
                        }
                        reader2.Close();
                        reader = cmd.ExecuteReader();
                        orderService.brandstore.ws.orderService    os = new orderService.brandstore.ws.orderService();
                        orderService.brandstore.ws.Credentials     c  = new orderService.brandstore.ws.Credentials();
                        orderService.brandstore.ws.BillingAddress  Ba = new orderService.brandstore.ws.BillingAddress();
                        orderService.brandstore.ws.ShippingAddress Sa = new orderService.brandstore.ws.ShippingAddress();
                        orderService.brandstore.ws.Product         p;
                        orderService.brandstore.ws.Product[]       pa = new orderService.brandstore.ws.Product[totalRRDRow];

                        // Set the authentication
                        c.Username = AppLogic.AppConfig("fullfillmentapi_username");
                        c.Token    = AppLogic.AppConfig("fullfillmentapi_password");
                        SetBillingAndShippingAddresses(ref Ba, ref Sa, OrderNumber);
                        int    index              = 0;
                        bool   hasproducts        = false;
                        string shippingMethodCode = string.Empty;
                        string shippingMethod     = string.Empty;

                        while (reader.Read())
                        {
                            if ((reader["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor RRD", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor CDS Publications", SkinID, ThisCustomer.LocaleSetting)) ||
                                (reader["DistributorName"].ToString() == AppLogic.GetString("Fullfilment Vendor Wetzel Brothers", SkinID, ThisCustomer.LocaleSetting)))
                            {
                                p = new orderService.brandstore.ws.Product();
                                // set the product
                                p.ID          = reader["ProductID"].ToString();
                                p.Quantity    = reader["Quantity"].ToString();
                                p.SKU         = reader["SKU"].ToString();
                                p.Description = reader["OrderedProductName"].ToString();
                                pa[index]     = p;
                                index++;
                                hasproducts        = true;
                                shippingMethodCode = reader["ShippingMethodCode"].ToString();
                                shippingMethod     = reader["ShippingMethod"].ToString();
                            }
                        }
                        // call the service after verification if the shopping cart has RRD Product
                        if (hasproducts)
                        {
                            orderService.brandstore.ws.ReturnStatus rs = os.processOrder(c, OrderNumber.ToString(), OrderNumber.ToString(), Ba, Sa, DateTime.Now, pa, AppLogic.GetString("Fullfilment Vendor RRDParam", SkinID, ThisCustomer.LocaleSetting), shippingMethodCode, shippingMethod);
                            bool isok = rs.status.Equals(0) ? false : true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                message = AppLogic.GetString("SentFulfillmentAPI.Error", SkinID, ThisCustomer.LocaleSetting.ToString());
                SysLog.LogMessage(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " :: " + System.Reflection.MethodBase.GetCurrentMethod().Name,
                                  ex.Message + ((ex.InnerException != null && string.IsNullOrEmpty(ex.InnerException.Message)) ? " :: " + ex.InnerException.Message : ""),
                                  MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);
            }
            finally
            {
                string script = "alert('" + message + "')";
                System.Web.UI.ClientScriptManager cs = this.ClientScript;
                cs.RegisterClientScriptBlock(this.GetType(), "alertMessage", script, true);
            }
        }
Beispiel #8
0
        protected void Save_Click(object sender, EventArgs e)
        {
            var customerAnonymizeSuccesses = new StringBuilder();
            var cannotBeAnonymized         = new StringBuilder();
            var customerAnonymizeErrors    = new StringBuilder();

            var customerDeleteSuccesses = new StringBuilder();
            var cannotBeDeleted         = new StringBuilder();
            var customerDeleteErrors    = new StringBuilder();

            var orderAnonymizeSuccesses = new StringBuilder();
            var orderAnonymizeErrors    = new StringBuilder();

            foreach (GridViewRow row in Grid.Rows)
            {
                if (row.RowType != DataControlRowType.DataRow)
                {
                    continue;
                }

                // We're getting the customer id through a hidden field because the grid data keys are cleared in the GridLoad() sorting above.
                var customerId   = Convert.ToInt32(((HiddenField)row.FindControl("hidCustomerId")).Value);
                var chkAnonymize = (CheckBox)row.FindControl("chkAnonymizeCustomer");
                var chkRemove    = (CheckBox)row.FindControl("chkRemoveCustomer");
                var customerInfo = ((HiddenField)row.FindControl("hidCustomerInfo")).Value;

                if (chkAnonymize.Checked)
                {
                    if (!DataRetentionService.CustomerCanBeAnonymized(customerId))
                    {
                        cannotBeAnonymized
                        .Append(customerInfo)
                        .Append("<br />");

                        continue;
                    }

                    var result = DataRetentionService.AnonymizeCustomer(customerId);

                    if (!result.Success)
                    {
                        customerAnonymizeErrors
                        .Append(customerInfo)
                        .Append("<br />");

                        SysLog.LogException(result.Error, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);

                        continue;
                    }

                    if (!result.Value)
                    {
                        customerAnonymizeErrors
                        .Append(customerInfo)
                        .Append("<br />");

                        continue;
                    }

                    customerAnonymizeSuccesses
                    .Append(customerInfo)
                    .Append("<br />");

                    foreach (var orderResult in DataRetentionService.AnonymizeOrders(customerId))
                    {
                        if (!orderResult.Success)
                        {
                            orderAnonymizeErrors
                            .Append(customerInfo)
                            .Append("<br />");

                            SysLog.LogException(result.Error, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error);

                            continue;
                        }

                        if (!orderResult.Value)
                        {
                            orderAnonymizeErrors
                            .Append(customerInfo)
                            .Append("<br />");

                            continue;
                        }

                        orderAnonymizeSuccesses
                        .Append(customerInfo)
                        .Append("<br />");
                    }
                }
            }

            if (customerAnonymizeSuccesses.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) have been anonymized:<br />", customerAnonymizeSuccesses.ToString()),
                    AlertMessage.AlertType.Success);
            }

            if (cannotBeAnonymized.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) and their orders could not be anonymized:<br />", cannotBeAnonymized.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (customerAnonymizeErrors.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) could not be anonymized:<br />", customerAnonymizeErrors.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (customerDeleteSuccesses.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) have been removed:<br />", customerDeleteSuccesses.ToString()),
                    AlertMessage.AlertType.Success);
            }

            if (cannotBeDeleted.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) and their orders could not be removed:<br />", cannotBeDeleted.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (customerDeleteErrors.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) could not be removed:<br />", customerDeleteErrors.ToString()),
                    AlertMessage.AlertType.Error);
            }

            if (orderAnonymizeSuccesses.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer(s) orders have been anonymized:<br />", orderAnonymizeSuccesses.ToString()),
                    AlertMessage.AlertType.Success);
            }

            if (orderAnonymizeErrors.Length > 0)
            {
                AlertMessageDisplay.PushAlertMessage(
                    string.Concat("The following customer's orders could not be anonymized:<br />", orderAnonymizeErrors.ToString()),
                    AlertMessage.AlertType.Error);
            }

            FilteredListing.Rebind();
        }
Beispiel #9
0
        /// <summary>
        /// Returns a named instance of a performance counter.  Note that the
        /// lookup is case insensitive and that the method will create the
        /// underlying Windows performance counter if it doesn't already exist.
        /// </summary>
        /// <param name="name">The performance counter name.</param>
        /// <param name="instance">The instance name (or <c>null</c>).</param>
        /// <remarks>
        /// <note>
        /// Passing <paramref name="instance" /> as <c>null</c> or the empty string is
        /// equivalent to passing no instance parameter.
        /// </note>
        /// </remarks>
        public PerfCounter this[string name, string instance]
        {
            get
            {
                if (!multiInstance)
                {
                    throw new InvalidOperationException("Counter set is configured as single-instance so an instance name cannot be specified.");
                }

                if (instance == null || instance == string.Empty)
                {
                    throw new ArgumentException("Invalid instance name.");
                }

                PerfCounter counter;
                PerfCounter template;
                string      key = string.Format("{0}[{1}]", name, instance);

                if (!counters.TryGetValue(name, out template))
                {
                    throw new ArgumentException("Counter does not exist.", "name");
                }

                if (counters.TryGetValue(key, out counter))
                {
                    return(counter);
                }

                try
                {
                    // Instantiate the performance counter and add it
                    // to the set.

                    counter = new PerfCounter(template.Name, template.Help, instance, template.Type);
                    counters.Add(key, counter);

                    if (!enabled)
                    {
                        return(counter);
                    }

                    counter.Counter = new PerformanceCounter(categoryName, template.Name, instance, false);

                    // Associate any related counters

                    if (template.RelatedCounters != null && counter.Related == null)
                    {
                        var           list = new List <PerfCounter>();
                        PerfCounter   related;
                        PerfCounter[] relatedList;

                        for (int i = 0; i < template.RelatedCounters.Length; i++)
                        {
                            related = this[template.RelatedCounters[i], instance];
                            if (related != null)
                            {
                                list.Add(related);
                            }
                        }

                        relatedList = new PerfCounter[list.Count];
                        for (int i = 0; i < list.Count; i++)
                        {
                            relatedList[i] = list[i];
                        }

                        counter.Related = relatedList;
                    }
                }
                catch (Exception e)
                {
                    // I'm going to fail gracefully if the performance counter could not
                    // be created.  The PerfCounter class handles null counters by implementing
                    // a process local simulation.

                    counter.Counter = null;
                    SysLog.LogException(e);
                }

                return(counter);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Returns a single instance performance counter with the
        /// name passed.  Note that the lookup is case insensitive and that
        /// the method will create the underlying Windows performance counter
        /// if it doesn't already exist.
        /// </summary>
        /// <param name="name">The performance counter name.</param>
        /// <remarks>
        /// <note>
        /// This method verifies that the performance counters
        /// are installed on the system and goes ahead and installs them
        /// if necessary.
        /// </note>
        /// </remarks>
        public PerfCounter this[string name]
        {
            get
            {
                PerfCounter counter;

                if (!installed)
                {
                    Install();
                }

                if (multiInstance)
                {
                    throw new InvalidOperationException("Counter set is configured as multi-instance so an instance name must be specified.");
                }

                if (!counters.TryGetValue(name, out counter))
                {
                    throw new ArgumentException("Counter does not exist.", "name");
                }

                if (!enabled)
                {
                    return(counter);
                }

                try
                {
                    // Instantiate the performance counter if necessary.

                    if (counter.Counter == null && !installFailed && !PerfCounter.ProcessLocalOnly)
                    {
                        counter.Counter = new PerformanceCounter(categoryName, counter.Name, false);
                    }

                    // Associate any related counters

                    if (counter.RelatedCounters != null && counter.Related == null)
                    {
                        var           list = new List <PerfCounter>();
                        PerfCounter   related;
                        PerfCounter[] relatedList;

                        for (int i = 0; i < counter.RelatedCounters.Length; i++)
                        {
                            related = this[counter.RelatedCounters[i]];

                            if (related != null)
                            {
                                list.Add(related);
                            }
                        }

                        relatedList = new PerfCounter[list.Count];
                        for (int i = 0; i < list.Count; i++)
                        {
                            relatedList[i] = list[i];
                        }

                        counter.Related = relatedList;
                    }
                }
                catch (Exception e)
                {
                    // I'm going to fail gracefully if the performance counter could not
                    // be created.  The PerfCounter class handles null counters by simply
                    // ignoring calls to the counter modification members.

                    counter.Counter = null;
                    SysLog.LogException(e);
                }

                return(counter);
            }
        }
Beispiel #11
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="category"></param>
        /// <param name="searchType">1=工号、2=姓名</param>
        /// <param name="keyWord"></param>
        /// <returns></returns>
        public DataTable GetList(int logUserId, string logUserName, EOrgaCategory category, int orgaId, int searchType, string keyWord, int pageIndex, int pageSize, out int count)
        {
            count = 0;
            try
            {
                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "Employee";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion

                Expression <Func <Employee, bool> > condition = t => true;
                if (category == EOrgaCategory.集团)
                {
                    condition.And(t => t.SubCompanyId == orgaId);
                }
                else if (category == EOrgaCategory.公司)
                {
                    condition.And(t => t.CompanyId == orgaId);
                }
                else if (category == EOrgaCategory.部门)
                {
                    condition.And(t => t.DepartmentId == orgaId);
                }
                else if (category == EOrgaCategory.工作组)
                {
                    condition.And(t => t.WorkgroupId == orgaId);
                }

                if (searchType == 1)
                {
                    condition.And(t => t.Code == keyWord);
                }
                if (searchType == 2)
                {
                    condition.And(t => t.Name == keyWord);
                }


                List <Employee> list  = dal.GetList(pageIndex, pageSize, out count, condition, t => t.Code, true).Cast <Employee>().ToList();
                DataTable       rltDt = ConvertHelper.ToDataTable(list);
                rltDt.Columns.AddRange(new DataColumn[]
                {
                    new DataColumn("DutyName"),
                    new DataColumn("EducationName"),
                    new DataColumn("DegreeName"),
                    new DataColumn("TitleName"),
                    new DataColumn("TitleLevelName"),
                    new DataColumn("PartyName"),
                    new DataColumn("NationName"),
                    new DataColumn("NationalityName"),
                    new DataColumn("WorkingPropertyName"),
                    new DataColumn("CompetencyName"),
                });

                var dict = this.BLLProvider.DataDictionaryBLL.AllDictionary;
                foreach (DataRow item in rltDt.Rows)
                {
                    item["DutyName"]            = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["EducationName"]       = dict.Find(t => t.ID == int.Parse(item["Education"].ToString())).Name;
                    item["DegreeName"]          = dict.Find(t => t.ID == int.Parse(item["Degree"].ToString())).Name;
                    item["TitleName"]           = dict.Find(t => t.ID == int.Parse(item["TitleId"].ToString())).Name;
                    item["TitleLevelName"]      = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["PartyName"]           = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["NationName"]          = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["NationalityName"]     = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["WorkingPropertyName"] = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["CompetencyName"]      = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                }



                return(rltDt);
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Beispiel #12
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 13编码重复</returns>
        public int Edit(Employee model)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var oldModel = dal.GetModel(ctx, t => t.ID == model.ID);
                    if (rlt == 1 && IsRepeatCode(model.Code, model.ID))
                    {
                        rlt = 13;
                    }
                    if (rlt == 1)
                    {
                        #region RegionName
                        oldModel.Name              = model.Name;
                        oldModel.Code              = model.Code;
                        oldModel.Spell             = model.Spell;
                        oldModel.Alias             = model.Alias;
                        oldModel.Age               = model.Age;
                        oldModel.Birthday          = model.Birthday;
                        oldModel.Gender            = model.Gender;
                        oldModel.SubCompanyId      = model.SubCompanyId;
                        oldModel.CompanyId         = model.CompanyId;
                        oldModel.DepartmentId      = model.DepartmentId;
                        oldModel.WorkgroupId       = model.WorkgroupId;
                        oldModel.DutyId            = model.DutyId;
                        oldModel.IDCard            = model.IDCard;
                        oldModel.BankCode          = model.BankCode;
                        oldModel.Email             = model.Email;
                        oldModel.Mobile            = model.Mobile;
                        oldModel.ShortNumber       = model.ShortNumber;
                        oldModel.Telephone         = model.Telephone;
                        oldModel.OICQ              = model.OICQ;
                        oldModel.OfficePhone       = model.OfficePhone;
                        oldModel.OfficeZipCode     = model.OfficeZipCode;
                        oldModel.OfficeAddress     = model.OfficeAddress;
                        oldModel.OfficeFax         = model.OfficeFax;
                        oldModel.EducationId       = model.EducationId;
                        oldModel.School            = model.School;
                        oldModel.GraduationDate    = model.GraduationDate;
                        oldModel.Major             = model.Major;
                        oldModel.DegreeId          = model.DegreeId;
                        oldModel.TitleId           = model.TitleId;
                        oldModel.TitleDate         = model.TitleDate;
                        oldModel.TitleLevelId      = model.TitleLevelId;
                        oldModel.WorkingDate       = model.WorkingDate;
                        oldModel.JoinInDate        = model.JoinInDate;
                        oldModel.HomeZipCode       = model.HomeZipCode;
                        oldModel.HomeAddress       = model.HomeAddress;
                        oldModel.HomePhone         = model.HomePhone;
                        oldModel.HomeFax           = model.HomeFax;
                        oldModel.Province          = model.Province;
                        oldModel.City              = model.City;
                        oldModel.Area              = model.Area;
                        oldModel.NativePlace       = model.NativePlace;
                        oldModel.PartyId           = model.PartyId;
                        oldModel.NationId          = model.NationId;
                        oldModel.NationalityId     = model.NationalityId;
                        oldModel.WorkingPropertyId = model.WorkingPropertyId;
                        oldModel.Competency        = model.Competency;
                        oldModel.EmergencyContact  = model.EmergencyContact;
                        oldModel.IsDimission       = model.IsDimission;
                        oldModel.DimissionDate     = model.DimissionDate;
                        oldModel.DimissionCause    = model.DimissionCause;
                        oldModel.DimissionWhither  = model.DimissionWhither;

                        oldModel.Remark         = model.Remark;
                        oldModel.SortIndex      = model.SortIndex;
                        oldModel.ModifyDate     = DateTime.Now;
                        oldModel.ModifyUserId   = model.ModifyUserId;
                        oldModel.ModifyUserName = model.ModifyUserName;
                        #endregion

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "DataDictionary";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = model.ModifyUserId;
                        sysLogModel.CreateUserName = model.ModifyUserName;
                        sysLogModel.ObjectId       = model.ID;
                        sysLogModel.OperationType  = EOperationType.修改.GetHashCode();

                        var entry = ctx.Entry(oldModel);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion

                        if (rlt == 1 && !dal.Insert(ctx, oldModel))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }