示例#1
0
        public ApiResponse Login([FromBody] LoginReq model)
        {
            int loginType = 0;

            if (HttpContext.Current.Request.UserAgent.Contains("IPHONE"))
            {
                loginType = (int)SourceType.Ios;;   // ios 登录
            }
            else if (HttpContext.Current.Request.UserAgent.Contains("ANDROID"))
            {
                loginType = (int)SourceType.Android;  // android 登录
            }
            else if (HttpContext.Current.Request.UserAgent.Contains("PC_Ver"))
            {
                loginType = (int)SourceType.Pc;  // Pc客户端 登录
            }

            #region Token登录
            if (!string.IsNullOrEmpty(model.Token))
            {
                var userByToken = userBll.PostLoginByToken(model.Token);
                var result      = new
                {
                    userByToken.UserID,
                    userByToken.Name,
                    userByToken.Phone,
                    userByToken.Token,
                    userByToken.Icon,
                    ExpirationDate = DateTimeUtility.ToUnixTime(userByToken.ExpirationDate),
                    userByToken.CityId,
                    userByToken.Email,
                    GainPoints    = 0,
                    GainPointsMsg = ""
                };
                return(new ApiResponse(Metas.SUCCESS, result));
            }
            #endregion
            int loginStatus;
            var user = userBll.PostLogin(model.UserName, model.Password, loginType, out loginStatus);

            if (user != null)
            {
                int    gainPoints    = 0;
                string gainPointsMsg = "";


                #region APP登录加分

                switch (loginType)
                {
                case (int)SourceType.Ios:
                case (int)SourceType.Android:
                    DoTask(user.UserID, PointsEnum.First_Login_App, out gainPoints);
                    gainPointsMsg = "完成“APP客户端登录”任务"; break;

                case (int)SourceType.Pc:
                    DoTask(user.UserID, PointsEnum.First_Login_PC, out gainPoints);
                    gainPointsMsg = "完成“Pc客户端登录”任务"; break;
                }


                #endregion

                var result = new
                {
                    user.UserID,
                    user.Name,
                    user.Phone,
                    user.Token,
                    user.Icon,
                    ExpirationDate = DateTimeUtility.ToUnixTime(user.ExpirationDate),
                    user.CityId,
                    user.Email,
                    GainPoints    = gainPoints,
                    GainPointsMsg = gainPointsMsg
                };
                return(new ApiResponse(Metas.SUCCESS, result));
            }

            switch (loginStatus)
            {
            case 1: return(new ApiResponse(Metas.ACCOUNT_OR_PASSWORD_WRONG));
            }

            return(new ApiResponse(Metas.UNKNOWN_ERROR));
        }
示例#2
0
        public JsonResult GetCurrentErrorRateStatus()
        {
            Dictionary <string, string> dict = BlobStorageService.GetDictFromBlob("ErrorRate" + string.Format("{0:MMdd}", DateTimeUtility.GetPacificTimeNow()) + ".json");

            if (dict != null && dict.Count > 0)
            {
                return(Json(dict.Values.ElementAt(dict.Count - 1), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("N/A"));
            }
        }
示例#3
0
        public ActionResult LatencyToday()
        {
            List <Tuple <string, long, long, long> > scenarios = GetLatencyData(String.Format("{0:yyyy-MM-dd}", DateTimeUtility.GetPacificTimeNow()));

            ViewBag.catalog  = GetCatalogLag();
            ViewBag.resolver = GetResolverLag();
            return(PartialView("~/Views/V2GalleryFrontEnd/V2GalleryFrontEnd_LatencyDetails.cshtml", scenarios));
        }
示例#4
0
        public ActionResult CpuUsage()
        {
            string[] blobNames = new string[1];
            blobNames[0] = "nuget-prod-0-v2gallery" + @"\Processor(_Total)\% Processor Time" + string.Format("{0:MMdd}", DateTimeUtility.GetPacificTimeNow());

            return(PartialView("~/Views/Shared/PartialChart.cshtml", ChartingUtilities.GetLineChartFromBlobName(blobNames, "CpuUsagetoday", 24 * 4, 800)));
        }
示例#5
0
 public ActionResult ErrorRate()
 {
     return(PartialView("~/Views/Shared/PartialChart.cshtml", ChartingUtilities.GetLineChartFromBlobName("ErrorRate" + string.Format("{0:MMdd}", DateTimeUtility.GetPacificTimeNow()), "ErrorsPerHour")));
 }
 public void TryParseIso8601MissingTimezone()
 {
     Assert.IsFalse(DateTimeUtility.TryParseIso8601("2006-01-02T03:04:05", out var dtParsed));
     Assert.IsFalse(DateTimeUtility.TryParseIso8601("2006-01-02T03:04:05").HasValue);
 }
        public ALSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, AuditLogVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter)
        {
            try
            {
                //Restore Server Session
                RetrieveServerSideSession(entity_WCFAuthInfoVM);

                bool ret = false;

                List <string> strList_Error = new List <string>();

                ALSerListResult returnResult = new ALSerListResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                AuditLogRespository entityRepos_AL = new AuditLogRespository(dbContext, entity_BaseSession.ID);

                #region [ Check Privilege ]
                ret = CheckAccPrivilege(entity_BaseSession.ID, entity_WCFAuthInfoVM.RequestFunKey, entity_WCFAuthInfoVM.RequestFunTypeKey, ref strList_Error);
                #endregion

                returnResult.StrList_Error         = strList_Error;
                returnResult.Int_TotalRecordCount  = 0;
                returnResult.EntityList_AuditLogVM = new List <AuditLogVM>();

                LoginUserRespository LoginUserRespo = new LoginUserRespository(dbContext, entity_BaseSession.ID);

                List <LoginUserVM> entityList_LUVM = LoginUserRespo.GetLoginUser_All();

                IDictionary <string, Guid> dic_LoginUser          = new Dictionary <string, Guid>();
                IDictionary <Guid, string> dic_LoginUser_Reversal = new Dictionary <Guid, string>();

                foreach (var item in entityList_LUVM)
                {
                    dic_LoginUser[item.LoginName]   = item.ID;
                    dic_LoginUser_Reversal[item.ID] = item.LoginName;
                }

                if (ret)
                {
                    int recordCount = 0;

                    Func <List <AuditLog>, List <AuditLog> > func_OtherFilter = (entityList_AuditLog) =>
                    {
                        List <AuditLog> temp = entityList_AuditLog;
                        if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.Operator))
                        {
                            List <string> strList_Key  = dic_LoginUser.Keys.Where(current => current.ToUpper().StartsWith(entity_SearchCriteria.Operator.ToUpper())).ToList();
                            List <Guid>   guidList_Key = new List <Guid>();
                            foreach (var item in strList_Key)
                            {
                                guidList_Key.Add(dic_LoginUser[item]);
                            }

                            if (guidList_Key.Count > 0)
                            {
                                temp = temp.Where(current => guidList_Key.Contains(current.AL_UserID)).ToList();
                            }
                            else
                            {
                                temp.Clear();
                            }
                        }

                        if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.AL_EventType))
                        {
                            if ("Create".ToUpper().StartsWith(entity_SearchCriteria.AL_EventType.ToUpper()))
                            {
                                temp = temp.Where(current => current.AL_EventType == OperationType.A.ToString()).ToList();
                            }
                            else if ("Edit".ToUpper().StartsWith(entity_SearchCriteria.AL_EventType.ToUpper()))
                            {
                                temp = temp.Where(current => current.AL_EventType == OperationType.M.ToString()).ToList();
                            }
                            else if ("Delete".ToUpper().StartsWith(entity_SearchCriteria.AL_EventType.ToUpper()))
                            {
                                temp = temp.Where(current => current.AL_EventType == OperationType.D.ToString()).ToList();
                            }
                            else
                            {
                                temp.Clear();
                            }
                        }

                        temp = temp.Where(current => DateTimeUtility.ValidateInputDatetime(current.AL_CreateDate, entity_SearchCriteria.DateFrom, entity_SearchCriteria.DateTo)).ToList();
                        return(temp);
                    };

                    List <AuditLogVM> vmList = entityRepos_AL.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter, func_OtherFilter, (entityList_VM) =>
                    {
                        foreach (var item in entityList_VM)
                        {
                            if (dic_LoginUser_Reversal.ContainsKey(item.AL_UserID))
                            {
                                item.Operator = dic_LoginUser_Reversal[item.AL_UserID];
                            }
                            if (item.AL_EventType == OperationType.A.ToString())
                            {
                                item.AL_EventType = "Create";
                            }
                            else if (item.AL_EventType == OperationType.M.ToString())
                            {
                                item.AL_EventType = "Edit";
                            }
                            else if (item.AL_EventType == OperationType.D.ToString())
                            {
                                item.AL_EventType = "Delete";
                            }
                        }
                        return(entityList_VM);
                    });

                    returnResult.EntityList_AuditLogVM = vmList;
                    returnResult.Int_TotalRecordCount  = recordCount;
                }

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }
示例#8
0
        private static YearlySales GetYearSales_bySalesDate(IEnumerable <Sales> sales, int lastyear, string HCOId, string productGroupId)
        {
            YearlySales sale = new YearlySales();

            sale.LastYear       = lastyear;
            sale.HCOId          = HCOId;
            sale.ProductGroupId = productGroupId;

            sale.LastYearTotalCredit = 0;

            //Get last year's data
            for (int i = 1; i <= 12; i++)
            {
                DateTime month = new DateTime(lastyear, i, 1);

                MonthlySales monthlySales = new MonthlySales()
                {
                    Month = month, MonthInt = Int32.Parse(month.ToString("yyyyMM"))
                };

                var filteredList = from Sales s in sales
                                   where s.HCOId == HCOId
                                   //&& s.ProductGroupId == productGroupId && s.Month == monthlySales.MonthInt  //用bonus_in来计算起销月
                                   && s.ProductGroupId == productGroupId && DateTimeUtility.GetMonthInt(s.SalesDate) == monthlySales.MonthInt && //用sales date来计算起销月
                                   s.Year == lastyear
                                   select s.Credit;
                double credit = filteredList.Sum();
                //double credit = sales.Where(s => s.ProductGroupId == productGroupId && s.HCOId == HCOId &&
                //               s.Month == monthlySales.MonthString &&  s.TerritoryId == territoryId && s.Year == year).
                //                Select(x => x.Credit).Sum();
                monthlySales.Credit = credit;
                if (filteredList.Count() > 0)
                {
                    sale.lastYearMonthlySales.Add(monthlySales);
                }


                sale.LastYearTotalCredit += credit;
            }

            int startSalesMonth = GetStartSalesMonth(sale.lastYearMonthlySales);

            if (startSalesMonth > 0)
            {
                sale.LastYearStartSalesMonth      = lastyear.ToString() + startSalesMonth.ToString("0#");
                sale.LastYearSalesMonthNumber     = 12 - startSalesMonth + 1;
                sale.LastYearMonthlyAverageCredit = sale.LastYearTotalCredit / sale.LastYearSalesMonthNumber;

                sale.iLastYearStartSalesMonth = startSalesMonth;
            }

            int thisYear = lastyear + 1;

            //Get this year's data
            for (int i = 1; i <= 12; i++)
            {
                DateTime month = new DateTime(thisYear, i, 1);

                MonthlySales monthlySales = new MonthlySales()
                {
                    Month = month, MonthInt = Int32.Parse(month.ToString("yyyyMM"))
                };

                var filteredList = from Sales s in sales
                                   where s.HCOId == HCOId &&
                                   s.ProductGroupId == productGroupId && DateTimeUtility.GetMonthInt(s.SalesDate) == monthlySales.MonthInt &&
                                   s.Year == thisYear
                                   select s.Credit;
                double credit = filteredList.Sum();
                monthlySales.Credit = credit;
                //double credit = sales.Where(s => s.ProductGroupId == productGroupId && s.HCOId == HCOId &&
                //               s.Month == monthlySales.MonthString &&  s.TerritoryId == territoryId && s.Year == year).
                //                Select(x => x.Credit).Sum();
                if (filteredList.Count() > 0)
                {
                    sale.thisYearMonthlySales.Add(monthlySales);
                }

                sale.ThisYearYTDCredit += credit;
            }

            startSalesMonth = GetStartSalesMonth(sale.thisYearMonthlySales);

            if (startSalesMonth > 0)
            {
                sale.ThisYearStartSalesMonth  = lastyear.ToString() + startSalesMonth.ToString("0#");
                sale.iThisYearStartSalesMonth = startSalesMonth;
            }

            return(sale);
        }
示例#9
0
 public void UnixTimestampNow()
 {
     DateTimeUtility.GetNowUnixTimestamp();
 }
示例#10
0
        /// <summary>
        /// 邀请成员加入项目
        /// </summary>
        /// <param name="ProjectID"></param>
        /// <param name="Email"></param>
        /// <returns></returns>
        public ResponseMessage InviteJoin(long ProjectID, string Email)
        {
            // 判断是否有权限
            var userproject = _UserManage.GetUserProject(_TenantManage.user.ID, ProjectID);

            if (userproject == null)
            {
                return(new ResponseMessage(MessageResult.Error, "项目不存在"));
            }
            // 只有创建者和管理员能进行邀请
            if (userproject.Role == 0)
            {
                return(new ResponseMessage(MessageResult.Error, "只有创建者和管理员能进行邀请"));
            }
            // 获取项目信息
            var project = _ProjectManage.GetModel(ProjectID);

            if (project == null)
            {
                return(new ResponseMessage(MessageResult.Error, "项目不存在"));
            }
            // 生成邀请码
            var model  = _UserInvitationManage.GetModel(_TenantManage.user.ID, Email, ProjectID);
            var result = false;

            if (model == null)
            {
                model = new Dao.Models.UserInvitation()
                {
                    UserID         = _TenantManage.user.ID,
                    Email          = Email,
                    ProjectID      = ProjectID,
                    Code           = Guid.NewGuid().ToString("N"),
                    CreateTime     = DateTimeUtility.GetTimeMilliseconds(DateTime.Now),
                    ExpirationTime = DateTimeUtility.GetTimeMilliseconds(DateTime.Now.AddDays(2)),
                };
                result = _UserInvitationManage.Create(model);
            }
            else
            {
                model.CreateTime     = DateTimeUtility.GetTimeMilliseconds(DateTime.Now);
                model.ExpirationTime = DateTimeUtility.GetTimeMilliseconds(DateTime.Now.AddDays(2));
                result = _UserInvitationManage.Update(model);
            }
            if (result)
            {
                var acitveurl = string.Format(@"http://admin.htmlid.cn/#/invite?code={0}&email={1}&t={2}", model.Code, model.Email, model.CreateTime); // Url.Action("invite", "Access", new { code = "", email = Email, t = DateTimeUtility.GetTimeMilliseconds(DateTime.Now) });
                var title     = string.Format("{0}邀请您加入{1}项目", _TenantManage.user.Nickname, project.Name);
                var content   = string.Format(@"<div class=""easyadmin-email"" style=""background: #F2F2F2; font-family: Helvetica Neue, Microsoft Yahei, Hiragino Sans GB, WenQuanYi Micro Hei, sans-serif; font-size: 14px; font-weight: normal; margin: 0; padding: 40px 0; text-align: center"">
    <div style=""font-size: 36px; font-weight: bold;margin: 30px auto; "">Easy Admin</div>
    <div class=""content-wrap"">
        <div class=""content"" lang=""zh"" style=""background: white; border: 1px solid #D9D9D9; border-radius: 3px; box-sizing: border-box; margin: 0 auto; max-width: 690px; overflow: hidden; padding: 40px 30px; text-align: center"">
            <div class=""main"">
                <div class=""user"">
                    <h2 class=""user-info"" style=""color: #383838; font-size: 20px; font-weight: normal; margin: 20px auto; margin-top: 20px; word-break: normal"">{0}
                        <span class=""user-email"" style=""color: inherit; display: inline; text-decoration: none; word-break: normal"">(<a href=""mailto:{1}"" target=""_blank"">{1}</a>)</span>
                    </h2>
                </div>
                <h2 class=""message"" style=""color: #808080; display: inline; font-size: 20px; font-weight: normal; margin: 0; word-break: normal"">邀请您加入项目
                    <q class=""organization-name"" style=""display: inline"">{2}</q>
                </h2><a class=""btn"" href=""{3}"" style=""-moz-transition: all 218ms; -o-transition: all 218ms; -webkit-transition: all 218ms; background: #03A9F4; border-radius: 2px; color: white; display: block; font-size: 20px; height: 54px; line-height: 54px; margin: 30px auto; text-decoration: none; transition: all 218ms; width: 200px; color: white!important; border: 0!important; cursor: pointer !important;"" target=""_blank"">进入项目</a>
                <p class=""hint center"" style=""color: #A6A6A6; display: block; font-weight: normal; line-height: 24px; margin: 0 auto; max-width: 600px; word-break: normal"">如果按钮无法点击,请直接访问以下链接:
                    <br><a href=""{3}"" style=""-moz-transition: all 218ms; -o-transition: all 218ms; -webkit-transition: all 218ms; color: #03A9F4; text-decoration: underline; transition: all 218ms; word-break: break-all;"" target=""_blank"">{3}</a> 此链接自发送之时起两天后过期 </p>
            </div>
        </div>
    </div>
    <p class=""small"" style=""color: #BDBDBD; display: block; font-size: 12px; font-weight: normal; line-height: 22px; margin: 0 auto; margin-top: 20px; max-width: 540px; padding: 0 5px; text-align: center; word-break: normal"">邮件来自{4} 的自动提醒,无需回复。
        <br>如果您在使用中有任何的疑问或者建议, 欢迎反馈我们意见至邮件:<a style=""-moz-transition: all 218ms; -o-transition: all 218ms; -webkit-transition: all 218ms; color: #BDBDBD; text-decoration: underline; transition: all 218ms"">[email protected]</a></p>
</div>", _TenantManage.user.Nickname, _TenantManage.user.Email, project.Name, acitveurl, "Easy Admin - 快速后台构建工具");
                if (EmailHelper.SendEmail(Email, title, content))
                {
                    return(new ResponseMessage(MessageResult.Success, "邀请邮件发送成功"));
                }
                else
                {
                    return(new ResponseMessage(MessageResult.Error, "邀请邮件发送失败"));
                }
            }
            return(new ResponseMessage(MessageResult.Error, "邀请失败"));
        }
示例#11
0
 /// <summary>
 /// Constructs and returns a random number generator seeded with the given date.
 /// </summary>
 /// <param name="d">typically <see cref="System.DateTime.Now"/></param>
 public DRand(DateTime d) : this((int)DateTimeUtility.GetTime(d))
 {
 }
示例#12
0
 public DateTime GetUtcNow() => DateTimeUtility.FromUnixTimestamp(m_timestamp);
示例#13
0
        protected void Payment_Btn_Click(object sender, EventArgs e)
        {
            string[] code       = Request.Params["code"].Split('U');
            string   leasing_id = code[1];
            string   idcard     = code[2];

            cls = cls_mng.getCarLeasingById(leasing_id);

            double real_payment       = string.IsNullOrEmpty(Real_Payment_TBx.Text) ? 0 : Convert.ToDouble(Real_Payment_TBx.Text);
            double cal_payment        = string.IsNullOrEmpty(Cal_Period_Payment_TBx.Text) ? 0 : Convert.ToDouble(Cal_Period_Payment_TBx.Text);
            double total_payment_left = string.IsNullOrEmpty(Total_payment_left_TBx.Text) ? 0 : Convert.ToDouble(Total_payment_left_TBx.Text);
            double period_fine        = string.IsNullOrEmpty(Total_payment_fine_TBx.Text) ? 0 : Convert.ToDouble(Total_payment_fine_TBx.Text);
            double real_payment_fine  = string.IsNullOrEmpty(Real_Payment_Fine_TBx.Text) ? 0 : Convert.ToDouble(Real_Payment_Fine_TBx.Text);
            double discount           = string.IsNullOrEmpty(Discount_TBx.Text) ? 0 : Convert.ToDouble(Discount_TBx.Text);
            double real_discount      = string.IsNullOrEmpty(Real_Discount_TBx.Text) ? 0 : Convert.ToDouble(Real_Discount_TBx.Text);
            double sum_payment_left   = total_payment_left;

            cls_pay.Leasing_id         = leasing_id;
            cls_pay.Period_fee         = string.IsNullOrEmpty(Period_free_TBx.Text) ? 0.00 : Convert.ToDouble(Period_free_TBx.Text);
            cls_pay.Period_track       = string.IsNullOrEmpty(Period_track_TBx.Text) ? 0.00 : Convert.ToDouble(Period_track_TBx.Text);
            cls_pay.Total_payment_fine = Convert.ToDouble(Real_Payment_Fine_TBx.Text);
            cls_pay.Discount           = Convert.ToDouble(Real_Discount_TBx.Text);
            cls_pay.Real_payment       = Convert.ToDouble(Real_Payment_TBx.Text);
            cls_pay.Real_payment_date  = string.IsNullOrEmpty(Payment_Date_TBx.Text) ? DateTimeUtility._dateNOWForServer() : DateTimeUtility.convertDateToMYSQL(Payment_Date_TBx.Text);
            cls_pay.Bill_no_manual_ref = string.IsNullOrEmpty(Bill_No_Manual_Ref_TBx.Text) ? "" : Bill_No_Manual_Ref_TBx.Text;

            Base_Companys package_login = new Base_Companys();
            Account_Login acc_lgn       = new Account_Login();

            package_login = (Base_Companys)Session["Package"];
            acc_lgn       = (Account_Login)Session["Login"];

            cls_pay.acc_lgn            = new Account_Login();
            cls_pay.acc_lgn.Account_id = acc_lgn.Account_id;

            cls_pay.bs_cpn            = new Base_Companys();
            cls_pay.bs_cpn.Company_id = package_login.Company_id;

            bool past_page = false;

            if (Cal_Status_Lbl.Visible == false) /* กรณีจ่าค่างวดแบบธรรมดา */
            {
                if (real_payment >= sum_payment_left)
                {
                    if (real_payment <= 0)
                    {
                        Note_Lbl.Text = "*** ระบุยอดชำระมากกว่า : 0.00 บาท ***";

                        Real_Payment_TBx.Focus();
                    }

                    /*else if (period_fine > 0 && real_payment_fine != period_fine)
                     * {
                     *  Note_Lbl.Text = "*** มียอดค่าปรับค้างชำระจำนวน :  " + period_fine.ToString("#,###.00") + " บาท ***";
                     *
                     *  Real_Payment_Fine_TBx.Focus();
                     * }
                     * else if (period_fine == 0 && real_payment_fine != period_fine)
                     * {
                     *  Note_Lbl.Text = "*** ไม่มียอดค่าปรับค้างชำระกรุณาใส่ 0 ในช่องชำระค่าปรับ ***";
                     *
                     *  Real_Payment_Fine_TBx.Focus();
                     * }*/
                    else if (discount == 0 && real_discount != 0)
                    {
                        Note_Lbl.Text = "*** ไม่มียอดส่วนลดกรุณาใส่ 0 ในช่องส่วนลด ***";

                        Real_Payment_Fine_TBx.Focus();
                    }
                    else if (real_payment > sum_payment_left)
                    {
                        Note_Lbl.Text = "*** ยอดปิดบัญชีจำนวน : " + sum_payment_left.ToString("#,###.00") + " บาท ***";
                    }
                    else
                    {
                        Note_Lbl.Text = "";

                        if (!string.IsNullOrEmpty(Bill_No_Manual_Ref_TBx.Text))
                        {
                            past_page = cls_pay_mng.addPayment_Mod_III(cls_pay, 1);
                        }
                        else
                        {
                            past_page = cls_pay_mng.addPayment(cls_pay, 1);
                        }

                        if (past_page)
                        {
                            /// Acticity Logs System
                            ///

                            string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " บันทึกข้อมูลการจ่ายเงิน ในสัญญา : " + cls.Leasing_no + " เลขที่ฝาก : " + cls.Deps_no + " จำนวนเงิน [ค่างวด] [ค่าปรับ] [ส่วนลด] : [" + real_payment + "] [" + period_fine + "] [" + real_discount + "] ", acc_lgn.resu, package_login.Company_N_name);

                            new Activity_Log_Manager().addActivityLogs(message, acc_lgn.Account_id, package_login.Company_id);

                            /// Acticity Logs System

                            _clearRealPayment();
                        }
                        else
                        {
                            Alert_Danger_Panel.Visible   = true;
                            alert_header_danger_Lbl.Text = "แจ้งเตือน!!";
                            alert_danger_Lbl.Text        = "กรุณาตรวจสอบ ข้อมูลอีกครั้ง";

                            Alert_Danger_Panel.Focus();
                        }
                    }
                }
                else
                {
                    if (real_payment <= 0)
                    {
                        Note_Lbl.Text = "*** ระบุยอดชำระมากกว่า : 0.00 บาท ***";

                        Real_Payment_TBx.Focus();
                    }

                    /*else if (period_fine > 0 && real_payment_fine > period_fine)
                     * {
                     *  Note_Lbl.Text = "*** มียอดค่าปรับค้างชำระจำนวน :  " + period_fine.ToString("#,###.00") + " บาท ***";
                     *
                     *  Real_Payment_Fine_TBx.Focus();
                     * }
                     * else if (period_fine == 0 && real_payment_fine != period_fine)
                     * {
                     *  Note_Lbl.Text = "*** ไม่มียอดค่าปรับค้างชำระกรุณาใส่ 0 ในช่องชำระค่าปรับ ***";
                     *
                     *  Real_Payment_Fine_TBx.Focus();
                     * }*/
                    else if (discount == 0 && real_discount != 0)
                    {
                        Note_Lbl.Text = "*** ไม่มียอดส่วนลดกรุณาใส่ 0 ในช่องส่วนลด ***";

                        Real_Payment_Fine_TBx.Focus();
                    }
                    else
                    {
                        Note_Lbl.Text = "";

                        if (!string.IsNullOrEmpty(Bill_No_Manual_Ref_TBx.Text))
                        {
                            past_page = cls_pay_mng.addPayment_Mod_III(cls_pay, 1);
                        }
                        else
                        {
                            past_page = cls_pay_mng.addPayment(cls_pay, 1);
                        }

                        if (past_page)
                        {
                            /// Acticity Logs System
                            ///

                            string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " บันทึกข้อมูลการจ่ายเงิน ในสัญญา : " + cls.Leasing_no + " เลขที่ฝาก : " + cls.Deps_no + " จำนวนเงิน [ค่างวด] [ค่าปรับ] [ส่วนลด] : [" + real_payment + "] [" + period_fine + "] [" + real_discount + "] ", acc_lgn.resu, package_login.Company_N_name);

                            new Activity_Log_Manager().addActivityLogs(message, acc_lgn.Account_id, package_login.Company_id);

                            /// Acticity Logs System

                            _clearRealPayment();
                        }
                        else
                        {
                            Alert_Danger_Panel.Visible   = true;
                            alert_header_danger_Lbl.Text = "แจ้งเตือน!!";
                            alert_danger_Lbl.Text        = "กรุณาตรวจสอบ ข้อมูลอีกครั้ง";

                            Alert_Danger_Panel.Focus();
                        }
                    }
                }

                _loadLeasingDetails(leasing_id, idcard);
            }
            else /* กรณีปิดบัญชี และมีส่วนลด */
            {
                if (real_payment != cal_payment)
                {
                    Note_Lbl.Text = "*** ไม่สามารถปิดบัญชีได้ เนื่องจาก ยอดชำระไม่ตรงกับที่ระบบคำนวนได้  " + cal_payment.ToString("#,###.00") + " บาท ***";
                }

                /*else if (period_fine > 0 && real_payment_fine != period_fine)
                 * {
                 *  Note_Lbl.Text = "*** มียอดค่าปรับค้างชำระจำนวน :  " + period_fine.ToString("#,###.00") + " บาท ***";
                 *
                 *  Real_Payment_Fine_TBx.Focus();
                 * }
                 * else if (period_fine == 0 && real_payment_fine != period_fine)
                 * {
                 *  Note_Lbl.Text = "*** ไม่มียอดค่าปรับค้างชำระกรุณาใส่ 0 ในช่องชำระค่าปรับ ***";
                 *
                 *  Real_Payment_Fine_TBx.Focus();
                 * }
                 * else if (discount == 0 && real_discount != discount)
                 * {
                 *  Note_Lbl.Text = "*** ไม่มียอดส่วนลดกรุณาใส่ 0 ในช่องส่วนลด ***";
                 *
                 *  Real_Payment_Fine_TBx.Focus();
                 * }
                 * else if (discount > 0 && real_discount != discount)
                 * {
                 *  Note_Lbl.Text = "*** กรุณมระบุยอดส่วนลดจำนวน :  " + discount.ToString("#,###.00") + " บาท ***";
                 *
                 *  Real_Discount_TBx.Focus();
                 * }*/
                else
                {
                    Note_Lbl.Text = "";

                    if (!string.IsNullOrEmpty(Bill_No_Manual_Ref_TBx.Text))
                    {
                        past_page = cls_pay_mng.addPayment_Mod_III(cls_pay, 2);
                    }
                    else
                    {
                        past_page = cls_pay_mng.addPayment(cls_pay, 2);
                    }

                    if (past_page)
                    {
                        /// Acticity Logs System
                        ///

                        string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " บันทึกข้อมูลการจ่ายเงินแบบคำนวนการปิดบัญชี ในสัญญา : " + cls.Leasing_no + " เลขที่ฝาก : " + cls.Deps_no + " จำนวนเงิน [ค่างวด] [ค่าปรับ] [ส่วนลด] : [" + real_payment + "] [" + period_fine + "] [" + real_discount + "] ", acc_lgn.resu, package_login.Company_N_name);

                        new Activity_Log_Manager().addActivityLogs(message, acc_lgn.Account_id, package_login.Company_id);

                        /// Acticity Logs System

                        _clearRealPayment();

                        _loadLeasingDetails(leasing_id, idcard);
                    }
                    else
                    {
                        Alert_Danger_Panel.Visible   = true;
                        alert_header_danger_Lbl.Text = "แจ้งเตือน!!";
                        alert_danger_Lbl.Text        = "กรุณาตรวจสอบ ข้อมูลอีกครั้ง";

                        Alert_Danger_Panel.Focus();
                    }
                }
            }
        }
示例#14
0
        private void _loadLeasingDetails(string leasing_id, string idcard)
        {
            cls = cls_mng.getCarLeasingById(leasing_id);

            Leasing_Comments_Lbl.Text = cls.Leasing_Comment;

            if (cls.Total_payment_left == 0)
            {
                Close_Leasing_Lbl.Visible = true;
                Cal_Status_Lbl.Visible    = false;

                Payment_Btn.Visible = false;
                Calculate_Close_Leasing_Btn.Visible = false;
                Back_Before_Page_Btn.Visible        = false;

                Leasing_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.Leasing_date);

                Deps_No_TBx.Text    = cls.Deps_no;
                Leasing_No_TBx.Text = cls.Leasing_no;

                bs_cpn = bs_cpn_mng.getCompanysById(cls.bs_cpn.Company_id.ToString());

                Company_N_Name_TBx.Text = bs_cpn.Company_N_name;
                Company_F_Name_TBx.Text = bs_cpn.Company_F_name;

                bs_zn = bs_zn_mng.getZoneById(cls.bs_zn.Zone_id);

                Zone_Name_TBx.Text = bs_zn.Zone_code + " " + bs_zn.Zone_name;

                ctm = cls_ctm_mng.getCustomersLeasing(leasing_id, idcard);

                if (ctm != null)
                {
                    Customer_Name_TBx.Text   = ctm.Cust_Fname + " " + ctm.Cust_LName;
                    Customer_Idcard_TBx.Text = ctm.Cust_Idcard.Length == 13 ? ctm.Cust_Idcard.Substring(0, 1) + "-" + ctm.Cust_Idcard.Substring(1, 4) + "-" + ctm.Cust_Idcard.Substring(5, 5) + "-" + ctm.Cust_Idcard.Substring(10, 2) + "-" + ctm.Cust_Idcard.Substring(12) : ctm.Cust_Idcard;
                    //Customer_B_Date_TBx.Text = DateTimeUtility.convertDateToPage(ctm.Cust_B_date);
                    //Customer_Age_TBx.Text = ctm.Cust_Age.ToString();

                    Customer_H_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Home_address_no) ? "" : ctm.Cust_Home_address_no;
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage_no) ? "" : ctm.Cust_Home_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage_no : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage) ? "" : ctm.Cust_Home_vilage.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_alley) ? "" : ctm.Cust_Home_alley.IndexOf('.') >= 1 ? ctm.Cust_Home_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_alley : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_road) ? "" : ctm.Cust_Home_road.IndexOf('.') >= 1 ? ctm.Cust_Home_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_road : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_subdistrict) ? "" : ctm.Cust_Home_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Home_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_subdistrict : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_district) ? "" : ctm.Cust_Home_district.IndexOf('.') >= 1 ? ctm.Cust_Home_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_district : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_province) ? "" : ctm.Cust_Home_province.IndexOf('.') >= 1 ? ctm.Cust_Home_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_province : "";

                    Customer_C_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Current_address_no) ? "" : ctm.Cust_Current_address_no;
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage_no) ? "" : ctm.Cust_Current_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage_no : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage) ? "" : ctm.Cust_Current_vilage.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_alley) ? "" : ctm.Cust_Current_alley.IndexOf('.') >= 1 ? ctm.Cust_Current_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_alley : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_road) ? "" : ctm.Cust_Current_road.IndexOf('.') >= 1 ? ctm.Cust_Current_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_road : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_subdistrict) ? "" : ctm.Cust_Current_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Current_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_subdistrict : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_district) ? "" : ctm.Cust_Current_district.IndexOf('.') >= 1 ? ctm.Cust_Current_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_district : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_province) ? "" : ctm.Cust_Current_province.IndexOf('.') >= 1 ? ctm.Cust_Current_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_province : "";
                }

                Car_Type_TBx.Text = cls.Car_type;

                bs_cbrn = cbrn_mng.getCarBrandById(cls.bs_cbrn.car_brand_id);

                if (bs_cbrn != null)
                {
                    Car_Brand_TBx.Text = bs_cbrn.car_brand_name_th + " ( " + bs_cbrn.car_brand_name_eng + " )";
                }

                Car_Plate_TBx.Text = cls.Car_license_plate + " " + cls.Car_license_plate_province;

                Car_Chassis_No_TBx.Text = cls.Car_chassis_no;
                Car_Engine_No_TBx.Text  = cls.Car_engine_no;

                cag_com = cag_mng.getAgentCommission("", leasing_id);

                Agent_Commission_TBx.Text = cag_com.Agent_commission.ToString("#,###.00");

                Finance_Cost_TBx.Text       = cls.Total_require.ToString("#,###.00");
                Finance_Value_TBx.Text      = cls.Total_sum.ToString("#,###.00");
                Leasing_Cost_TBx.Text       = cls.Total_Net_leasing.ToString("#,###.00");
                Period_Amount_TBx.Text      = cls.Total_period.ToString();
                Period_Payment_TBx.Text     = cls.Period_payment.ToString("#,###.00");
                Payment_Schedule_TBx.Text   = cls.Payment_schedule.ToString();
                Frist_Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.First_payment_date);

                Payment_Date_TBx.Enabled = false;

                List <Car_Leasings_Payment> list_cls_pay = cls_pay_mng.getRealPaymentInfo(leasing_id);

                Session["list_cls_pay"] = list_cls_pay;

                Period_free_TBx.Enabled  = false;
                Period_track_TBx.Enabled = false;

                Real_Payment_TBx.Enabled      = false;
                Real_Payment_Fine_TBx.Enabled = false;
                Real_Discount_TBx.Enabled     = false;

                Payment_Date_TBx.Text = "";

                Period_No_TBx.Text            = "";
                Total_Payment_Period_TBx.Text = "";
                Total_payment_left_TBx.Text   = "";
                Period_free_TBx.Text          = "";
                Period_track_TBx.Text         = "";
                Discount_TBx.Text             = "";

                Total_payment_fine_TBx.Text = "";

                Total_period_left_TBx.Text  = "";
                Period_fine_TBx.Text        = "";
                Cal_Period_Payment_TBx.Text = "";
            }
            else
            {
                Leasing_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.Leasing_date);
                Deps_No_TBx.Text      = cls.Deps_no;
                Leasing_No_TBx.Text   = cls.Leasing_no;

                bs_cpn = bs_cpn_mng.getCompanysById(cls.bs_cpn.Company_id.ToString());

                Company_N_Name_TBx.Text = bs_cpn.Company_N_name;
                Company_F_Name_TBx.Text = bs_cpn.Company_F_name;

                bs_zn = bs_zn_mng.getZoneById(cls.bs_zn.Zone_id);

                Zone_Name_TBx.Text = bs_zn.Zone_code + " " + bs_zn.Zone_name;

                ctm = cls_ctm_mng.getCustomersLeasing(leasing_id, idcard);

                if (ctm != null)
                {
                    Customer_Name_TBx.Text   = ctm.Cust_Fname + " " + ctm.Cust_LName;
                    Customer_Idcard_TBx.Text = ctm.Cust_Idcard.Length == 13 ? ctm.Cust_Idcard.Substring(0, 1) + "-" + ctm.Cust_Idcard.Substring(1, 4) + "-" + ctm.Cust_Idcard.Substring(5, 5) + "-" + ctm.Cust_Idcard.Substring(10, 2) + "-" + ctm.Cust_Idcard.Substring(12) : ctm.Cust_Idcard;
                    //Customer_B_Date_TBx.Text = DateTimeUtility.convertDateToPage(ctm.Cust_B_date);
                    //Customer_Age_TBx.Text = ctm.Cust_Age.ToString();

                    Customer_H_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Home_address_no) ? "" : ctm.Cust_Home_address_no;
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage_no) ? "" : ctm.Cust_Home_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage_no : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage) ? "" : ctm.Cust_Home_vilage.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_alley) ? "" : ctm.Cust_Home_alley.IndexOf('.') >= 1 ? ctm.Cust_Home_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_alley : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_road) ? "" : ctm.Cust_Home_road.IndexOf('.') >= 1 ? ctm.Cust_Home_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_road : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_subdistrict) ? "" : ctm.Cust_Home_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Home_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_subdistrict : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_district) ? "" : ctm.Cust_Home_district.IndexOf('.') >= 1 ? ctm.Cust_Home_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_district : "";
                    Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_province) ? "" : ctm.Cust_Home_province.IndexOf('.') >= 1 ? ctm.Cust_Home_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_province : "";

                    Customer_C_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Current_address_no) ? "" : ctm.Cust_Current_address_no;
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage_no) ? "" : ctm.Cust_Current_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage_no : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage) ? "" : ctm.Cust_Current_vilage.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_alley) ? "" : ctm.Cust_Current_alley.IndexOf('.') >= 1 ? ctm.Cust_Current_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_alley : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_road) ? "" : ctm.Cust_Current_road.IndexOf('.') >= 1 ? ctm.Cust_Current_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_road : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_subdistrict) ? "" : ctm.Cust_Current_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Current_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_subdistrict : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_district) ? "" : ctm.Cust_Current_district.IndexOf('.') >= 1 ? ctm.Cust_Current_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_district : "";
                    Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_province) ? "" : ctm.Cust_Current_province.IndexOf('.') >= 1 ? ctm.Cust_Current_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_province : "";
                }

                Car_Type_TBx.Text = cls.Car_type;

                bs_cbrn = cbrn_mng.getCarBrandById(cls.bs_cbrn.car_brand_id);

                if (bs_cbrn != null)
                {
                    Car_Brand_TBx.Text = bs_cbrn.car_brand_name_th + " ( " + bs_cbrn.car_brand_name_eng + " )";
                }

                Car_Plate_TBx.Text = cls.Car_license_plate + " " + cls.Car_license_plate_province;

                Car_Chassis_No_TBx.Text = cls.Car_chassis_no;
                Car_Engine_No_TBx.Text  = cls.Car_engine_no;

                cag_com = cag_mng.getAgentCommission("", leasing_id);

                Agent_Commission_TBx.Text = cag_com.Agent_commission.ToString("#,###.00");

                Finance_Cost_TBx.Text       = cls.Total_require.ToString("#,###.00");
                Finance_Value_TBx.Text      = cls.Total_sum.ToString("#,###.00");
                Leasing_Cost_TBx.Text       = cls.Total_Net_leasing.ToString("#,###.00");
                Period_Amount_TBx.Text      = cls.Total_period.ToString();
                Period_Payment_TBx.Text     = cls.Period_payment.ToString("#,###.00");
                Payment_Schedule_TBx.Text   = cls.Payment_schedule.ToString();
                Frist_Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.First_payment_date);

                Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(DateTime.Now.ToString());

                Period_No_TBx.Text            = cls.Total_period_length;
                Total_Payment_Period_TBx.Text = cls.Total_period_lose == 0 ? "1" : cls.Total_period_lose.ToString();
                Total_payment_left_TBx.Text   = cls.Total_payment_left.ToString("#,###.00");
                Period_free_TBx.Text          = "0.00";
                Period_track_TBx.Text         = "0.00";
                Discount_TBx.Text             = "0.00";

                List <Car_Leasings_Payment> list_cls_pay = cls_pay_mng.getRealPaymentInfo(leasing_id);

                double total_lost         = 0.00;
                double total_payment_fine = 0.00;
                double payment_fine       = 0.00;
                double real_payment_fine  = 0.00;
                double real_payment       = 0.00;
                double next_period_no     = 1;
                double duplicate_period   = 0;

                for (int i = 0; i < list_cls_pay.Count; i++)
                {
                    Car_Leasings_Payment cls_pay = list_cls_pay[i];

                    if (string.IsNullOrEmpty(cls.Total_period_length))
                    {
                        total_lost         = cls_pay.Period_current;
                        Period_No_TBx.Text = next_period_no.ToString();
                    }
                    else
                    {
                        int period_str = Convert.ToInt32(cls.Total_period_length.Split('-')[0].Trim());
                        int period_end = Convert.ToInt32(cls.Total_period_length.Split('-')[1].Trim());

                        if (cls_pay.Period_no >= period_str && cls_pay.Period_no <= period_end && cls_pay.Period_no != duplicate_period)
                        {
                            total_lost += cls_pay.Period_current;
                        }
                    }

                    if (cls_pay.Period_fine > 0 && cls_pay.Period_no != duplicate_period)
                    {
                        payment_fine += cls_pay.Period_fine;
                    }

                    if (cls_pay.Real_payment_fine > 0)
                    {
                        real_payment_fine += cls_pay.Real_payment_fine;
                    }

                    if (cls_pay.Real_payment > 0 && cls_pay.Period_payment_status != 9)
                    {
                        real_payment += cls_pay.Real_payment;
                    }

                    if (cls_pay.Period_payment_status == 9 && cls_pay.Period_no != duplicate_period)
                    {
                        next_period_no += 1;
                    }

                    duplicate_period = cls_pay.Period_no;
                }

                total_payment_fine = payment_fine - real_payment_fine;

                Total_payment_fine_TBx.Text = total_payment_fine > 0 ? total_payment_fine.ToString("#,###.00") : "0.00";

                Total_period_left_TBx.Text = string.IsNullOrEmpty(cls.Total_period_length) ? "0.00" : (total_lost - real_payment).ToString("#,###.00");

                Period_fine_TBx.Text = total_payment_fine < 0 ? "0.00" : total_payment_fine.ToString("#,###.00");

                Cal_Period_Payment_TBx.Text = (total_lost - real_payment).ToString("#,###.00");

                Session["list_cls_pay"] = list_cls_pay;

                Real_Payment_TBx.Focus();
            }
        }
 public void ParseIso8601BadMinute()
 {
     Assert.Throws <FormatException>(() => DateTimeUtility.ParseIso8601("2006-01-02T03:61:05"));
 }
示例#16
0
 public void UnixTimestampMillisecondsNow()
 {
     DateTimeUtility.GetNowUnixTimestampMilliseconds();
 }
 public void ParseIso8601BadSecond()
 {
     Assert.Throws <FormatException>(() => DateTimeUtility.ParseIso8601("2006-01-02T03:04:62"));
 }
        protected void Save_Btn_Click(object sender, EventArgs e)
        {
            string[] code       = Request.Params["code"].Split('U');
            string   leasing_id = code[1];
            string   bill_no    = code[2];
            string   idcard     = (string)Session["ctm_leasing_payment"];

            cls = cls_mng.getCarLeasingById(leasing_id);

            double total_payment_left = string.IsNullOrEmpty(Total_payment_left_TBx.Text) ? 0 : Convert.ToDouble(Total_payment_left_TBx.Text);
            double period_fine        = string.IsNullOrEmpty(Total_payment_fine_TBx.Text) ? 0 : Convert.ToDouble(Total_payment_fine_TBx.Text);

            double old_period_fee   = string.IsNullOrEmpty(Old_Period_fee_TBx.Text) ? 0.00 : Convert.ToDouble(Old_Period_fee_TBx.Text);
            double old_period_track = string.IsNullOrEmpty(Old_Period_track_TBx.Text) ? 0.00 : Convert.ToDouble(Old_Period_track_TBx.Text);
            double old_payment      = string.IsNullOrEmpty(Old_Real_Payment_TBx.Text) ? 0 : Convert.ToDouble(Old_Real_Payment_TBx.Text);
            double old_payment_fine = string.IsNullOrEmpty(Old_Real_Payment_Fine_TBx.Text) ? 0 : Convert.ToDouble(Old_Real_Payment_Fine_TBx.Text);
            double old_discount     = string.IsNullOrEmpty(Old_Real_Discount_TBx.Text) ? 0 : Convert.ToDouble(Old_Real_Discount_TBx.Text);

            double real_period_fee   = string.IsNullOrEmpty(Period_fee_TBx.Text) ? 0.00 : Convert.ToDouble(Period_fee_TBx.Text);
            double real_period_track = string.IsNullOrEmpty(Period_track_TBx.Text) ? 0.00 : Convert.ToDouble(Period_track_TBx.Text);
            double real_payment      = string.IsNullOrEmpty(Real_Payment_TBx.Text) ? 0 : Convert.ToDouble(Real_Payment_TBx.Text);
            double real_payment_fine = string.IsNullOrEmpty(Real_Payment_Fine_TBx.Text) ? 0 : Convert.ToDouble(Real_Payment_Fine_TBx.Text);
            double real_discount     = string.IsNullOrEmpty(Real_Discount_TBx.Text) ? 0 : Convert.ToDouble(Real_Discount_TBx.Text);

            cls_pay.Leasing_id         = leasing_id;
            cls_pay.Period_fee         = real_period_fee;
            cls_pay.Period_track       = real_period_track;
            cls_pay.Total_payment_fine = real_payment_fine;
            cls_pay.Discount           = real_discount;
            cls_pay.Real_payment       = real_payment;
            cls_pay.Real_payment_date  = string.IsNullOrEmpty(Payment_Date_TBx.Text) ? DateTimeUtility._dateNOWForServer() : DateTimeUtility.convertDateToMYSQL(Payment_Date_TBx.Text);
            cls_pay.Bill_no_manual_ref = string.IsNullOrEmpty(Bill_No_Manual_Ref_TBx.Text) ? "" : Bill_No_Manual_Ref_TBx.Text;

            Base_Companys package_login = new Base_Companys();
            Account_Login acc_lgn       = new Account_Login();

            package_login = (Base_Companys)Session["Package"];
            acc_lgn       = (Account_Login)Session["Login"];

            cls_pay.acc_lgn            = new Account_Login();
            cls_pay.acc_lgn.Account_id = acc_lgn.Account_id;

            cls_pay.bs_cpn            = new Base_Companys();
            cls_pay.bs_cpn.Company_id = (int)Session["old_company"];

            if (total_payment_left == 0)
            {
                if (real_payment <= 0)
                {
                    Note_Lbl.Text = "*** ระบุยอดชำระมากกว่า : 0.00 บาท ***";

                    Real_Payment_TBx.Focus();
                }
                else if (real_payment > old_payment)
                {
                    Note_Lbl.Text = "*** ยอดชำระเกินกว่ายอดเดิม :  " + old_payment.ToString("#,###.00") + " บาท ***";

                    Real_Payment_TBx.Focus();
                }

                /* else if (period_fine == 0 && old_payment_fine != 0)
                 * {
                 *   Note_Lbl.Text = "*** ระบุยอดชำระค่าปรับ :  " + old_payment_fine.ToString("#,###.00") + " บาท ***";
                 *
                 *   Real_Payment_Fine_TBx.Focus();
                 * }*/
                else if (old_discount != 0)
                {
                    Note_Lbl.Text = "*** ระบุยอดส่วนลด :  " + old_discount.ToString("#,###.00") + " บาท ***";

                    Real_Discount_TBx.Focus();
                }
                else
                {
                    Note_Lbl.Text = "";

                    if (cls_pay_mng.editPayment(cls_pay, bill_no))
                    {
                        /// Acticity Logs System
                        ///

                        string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " แก้ไขข้อมูลการจ่ายเงิน ในสัญญา : " + cls.Leasing_no + " เลขที่ฝาก : " + cls.Deps_no + " เลขที่ใบเสร็จ : " + bill_no + " จำนวนเงิน [ค่างวด] [ค่าปรับ] [ส่วนลด] : [" + real_payment + "] [" + period_fine + "] [" + real_discount + "] ", acc_lgn.resu, package_login.Company_N_name);

                        new Activity_Log_Manager().addActivityLogs(message, acc_lgn.Account_id, package_login.Company_id);

                        /// Acticity Logs System

                        string ogn_code = CryptographyCode.GenerateSHA512String(leasing_id);

                        Session.Remove("old_company");

                        Response.Redirect("/Form_Leasings/Leasing_Payment?code=" + CryptographyCode.EncodeTOAddressBar(ogn_code, leasing_id, idcard));
                    }
                    else
                    {
                        Alert_Danger_Panel.Visible   = true;
                        alert_header_danger_Lbl.Text = "แจ้งเตือน!!";
                        alert_danger_Lbl.Text        = "กรุณาตรวจสอบ ข้อมูลอีกครั้ง";

                        Alert_Danger_Panel.Focus();
                    }
                }
            }
            else
            {
                if (real_payment <= 0)
                {
                    Note_Lbl.Text = "*** ระบุยอดชำระมากกว่า : 0.00 บาท ***";

                    Real_Payment_TBx.Focus();
                }

                /*else if(real_payment > total_payment_left && real_payment > 0)
                 * {
                 *  Note_Lbl.Text = "*** ยอดชำระเกินกว่ายอดคงค้าง :  " + total_payment_left.ToString("#,###.00") + " บาท ***";
                 *
                 *  Real_Payment_TBx.Focus();
                 * }*/
                else if (old_discount == 0 && real_discount != 0)
                {
                    Note_Lbl.Text = "*** ไม่มียอดส่วนลดกรุณาใส่ 0 ในช่องส่วนลด ***";

                    Real_Discount_TBx.Focus();
                }
                else
                {
                    Note_Lbl.Text = "";

                    if (cls_pay_mng.editPayment(cls_pay, bill_no))
                    {
                        /// Acticity Logs System
                        ///

                        string message = Messages_Logs._messageLogsNormal(acc_lgn.Account_F_name, " แก้ไขข้อมูลการจ่ายเงิน ในสัญญา : " + cls.Leasing_no + " เลขที่ฝาก : " + cls.Deps_no + " เลขที่ใบเสร็จ : " + bill_no + " จำนวนเงิน [ค่างวด] [ค่าปรับ] [ส่วนลด] : [" + real_payment + "] [" + period_fine + "] [" + real_discount + "] ", acc_lgn.resu, package_login.Company_N_name);

                        new Activity_Log_Manager().addActivityLogs(message, acc_lgn.Account_id, package_login.Company_id);

                        /// Acticity Logs System

                        string ogn_code = CryptographyCode.GenerateSHA512String(leasing_id);

                        Session.Remove("old_company");

                        Response.Redirect("/Form_Leasings/Leasing_Payment?code=" + CryptographyCode.EncodeTOAddressBar(ogn_code, leasing_id, idcard));
                    }
                    else
                    {
                        Alert_Danger_Panel.Visible   = true;
                        alert_header_danger_Lbl.Text = "แจ้งเตือน!!";
                        alert_danger_Lbl.Text        = "กรุณาตรวจสอบ ข้อมูลอีกครั้ง";

                        Alert_Danger_Panel.Focus();
                    }
                }
            }
        }
示例#19
0
        public void Process(DicomDataset dicomDataset, DicomItem item, Dictionary <string, object> settings = null)
        {
            if (DateShiftScope == DateShiftScope.StudyInstance)
            {
                DateShiftFunction.DateShiftKeyPrefix = dicomDataset.GetSingleValue <string>(DicomTag.StudyInstanceUID);
            }
            else if (DateShiftScope == DateShiftScope.SeriesInstance)
            {
                DateShiftFunction.DateShiftKeyPrefix = dicomDataset.GetSingleValue <string>(DicomTag.SeriesInstanceUID);
            }
            else if (DateShiftScope == DateShiftScope.SopInstance)
            {
                DateShiftFunction.DateShiftKeyPrefix = dicomDataset.GetSingleValue <string>(DicomTag.SOPInstanceUID);
            }

            if (item.ValueRepresentation == DicomVR.DA)
            {
                var values = ((DicomDate)item).Get <string[]>().Select(x => DateShiftFunction.ShiftDateTime(Utility.ParseDicomDate(x))).Where(x => !DateTimeUtility.IndicateAgeOverThreshold(x));
                dicomDataset.AddOrUpdate(item.Tag, values.Select(x => Utility.GenerateDicomDateString(x)).ToArray());
            }
            else if (item.ValueRepresentation == DicomVR.DT)
            {
                var results = new List <string>();
                var values  = ((DicomDate)item).Get <string[]>();
                foreach (var value in values)
                {
                    var dateObject = Utility.ParseDicomDateTime(value);
                    dateObject.DateValue = DateShiftFunction.ShiftDateTime(dateObject.DateValue);
                    if (!DateTimeUtility.IndicateAgeOverThreshold(dateObject.DateValue))
                    {
                        results.Add(Utility.GenerateDicomDateTimeString(dateObject));
                    }
                }

                if (results.Count != 0)
                {
                    dicomDataset.AddOrUpdate(item.Tag, results.ToArray());
                }
            }
            else
            {
                throw new Exception($"Dateshift is not supported for {item.ValueRepresentation}");
            }
        }
        private void _loadLeasingDetails(string leasing_id, string idcard, string bill_no)
        {
            cls = cls_mng.getCarLeasingById(leasing_id);

            Leasing_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.Leasing_date);
            Deps_No_TBx.Text      = cls.Deps_no;
            Leasing_No_TBx.Text   = cls.Leasing_no;

            Leasing_Comments_Lbl.Text = cls.Leasing_Comment;

            bs_cpn = bs_cpn_mng.getCompanysById(cls.bs_cpn.Company_id.ToString());

            Company_N_Name_TBx.Text = bs_cpn.Company_N_name;
            Company_F_Name_TBx.Text = bs_cpn.Company_F_name;

            bs_zn = bs_zn_mng.getZoneById(cls.bs_zn.Zone_id);

            Zone_Name_TBx.Text = bs_zn.Zone_code + " " + bs_zn.Zone_name;

            ctm = cls_ctm_mng.getCustomersLeasing(leasing_id, idcard);

            if (ctm != null)
            {
                Customer_Name_TBx.Text   = ctm.Cust_Fname + " " + ctm.Cust_LName;
                Customer_Idcard_TBx.Text = ctm.Cust_Idcard.Length == 13 ? ctm.Cust_Idcard.Substring(0, 1) + "-" + ctm.Cust_Idcard.Substring(1, 4) + "-" + ctm.Cust_Idcard.Substring(5, 5) + "-" + ctm.Cust_Idcard.Substring(10, 2) + "-" + ctm.Cust_Idcard.Substring(12) : ctm.Cust_Idcard;
                //Customer_B_Date_TBx.Text = DateTimeUtility.convertDateToPage(ctm.Cust_B_date);
                //Customer_Age_TBx.Text = ctm.Cust_Age.ToString();

                Customer_H_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Home_address_no) ? "" : ctm.Cust_Home_address_no;
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage_no) ? "" : ctm.Cust_Home_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage_no : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_vilage) ? "" : ctm.Cust_Home_vilage.IndexOf('.') >= 1 ? ctm.Cust_Home_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_vilage : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_alley) ? "" : ctm.Cust_Home_alley.IndexOf('.') >= 1 ? ctm.Cust_Home_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_alley : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_road) ? "" : ctm.Cust_Home_road.IndexOf('.') >= 1 ? ctm.Cust_Home_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_road : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_subdistrict) ? "" : ctm.Cust_Home_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Home_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_subdistrict : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_district) ? "" : ctm.Cust_Home_district.IndexOf('.') >= 1 ? ctm.Cust_Home_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_district : "";
                Customer_H_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Home_province) ? "" : ctm.Cust_Home_province.IndexOf('.') >= 1 ? ctm.Cust_Home_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Home_province : "";

                Customer_C_Address_TBx.Text  = string.IsNullOrEmpty(ctm.Cust_Current_address_no) ? "" : ctm.Cust_Current_address_no;
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage_no) ? "" : ctm.Cust_Current_vilage_no.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage_no.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage_no : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_vilage) ? "" : ctm.Cust_Current_vilage.IndexOf('.') >= 1 ? ctm.Cust_Current_vilage.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_vilage : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_alley) ? "" : ctm.Cust_Current_alley.IndexOf('.') >= 1 ? ctm.Cust_Current_alley.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_alley : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_road) ? "" : ctm.Cust_Current_road.IndexOf('.') >= 1 ? ctm.Cust_Current_road.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_road : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_subdistrict) ? "" : ctm.Cust_Current_subdistrict.IndexOf('.') >= 1 ? ctm.Cust_Current_subdistrict.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_subdistrict : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_district) ? "" : ctm.Cust_Current_district.IndexOf('.') >= 1 ? ctm.Cust_Current_district.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_district : "";
                Customer_C_Address_TBx.Text += string.IsNullOrEmpty(ctm.Cust_Current_province) ? "" : ctm.Cust_Current_province.IndexOf('.') >= 1 ? ctm.Cust_Current_province.Split('.')[1] == "-" ? "" : " " + ctm.Cust_Current_province : "";
            }

            Car_Type_TBx.Text = cls.Car_type;

            bs_cbrn = cbrn_mng.getCarBrandById(cls.bs_cbrn.car_brand_id);

            if (bs_cbrn != null)
            {
                Car_Brand_TBx.Text = bs_cbrn.car_brand_name_th + " ( " + bs_cbrn.car_brand_name_eng + " )";
            }

            Car_Plate_TBx.Text = cls.Car_license_plate + " " + cls.Car_license_plate_province;

            Car_Chassis_No_TBx.Text = cls.Car_chassis_no;
            Car_Engine_No_TBx.Text  = cls.Car_engine_no;

            cag_com = cag_mng.getAgentCommission("", leasing_id);

            Agent_Commission_TBx.Text = cag_com.Agent_commission.ToString("#,###.00");

            Finance_Cost_TBx.Text       = cls.Total_require.ToString("#,###.00");
            Finance_Value_TBx.Text      = cls.Total_sum.ToString("#,###.00");
            Leasing_Cost_TBx.Text       = cls.Total_Net_leasing.ToString("#,###.00");
            Period_Amount_TBx.Text      = cls.Total_period.ToString();
            Period_Payment_TBx.Text     = cls.Period_payment.ToString("#,###.00");
            Payment_Schedule_TBx.Text   = cls.Payment_schedule.ToString();
            Frist_Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls.First_payment_date);

            Bill_No_TBx.Text = bill_no;

            Period_fee_TBx.Text   = "0.00";
            Period_track_TBx.Text = "0.00";

            List <Car_Leasings_Payment> list_cls_pay = cls_pay_mng.getRealPaymentInfo(leasing_id);

            double total_payment_left = 0.00;
            double total_payment_fine = 0.00;

            double total_fee              = 0.00;
            double total_track            = 0.00;
            double total_real_payment     = 0.00;
            double total_rea_payment_fine = 0.00;
            double total_discount         = 0.00;

            for (int i = 0; i < list_cls_pay.Count; i++)
            {
                Car_Leasings_Payment cls_pay = list_cls_pay[i];

                if (cls_pay.Bill_no == bill_no)
                {
                    Payment_Date_TBx.Text = DateTimeUtility.convertDateToPageRealServer(cls_pay.Real_payment_date);

                    total_fee              += cls_pay.Period_fee;
                    total_track            += cls_pay.Period_track;
                    total_real_payment     += cls_pay.Real_payment;
                    total_rea_payment_fine += cls_pay.Real_payment_fine;
                    total_discount         += cls_pay.Discount;

                    total_payment_left = cls_pay.Total_payment_left;
                    total_payment_fine = cls_pay.Total_payment_fine;

                    Bill_No_Manual_Ref_TBx.Text = cls_pay.Bill_no_manual_ref;

                    Session["old_company"] = cls_pay.bs_cpn.Company_id;
                }
            }

            Total_payment_left_TBx.Text = total_payment_left.ToString("#,###.00");
            Total_payment_fine_TBx.Text = total_payment_fine.ToString("#,###.00");

            Old_Period_fee_TBx.Text        = total_fee.ToString("#,###.00");
            Old_Period_track_TBx.Text      = total_track.ToString("#,###.00");
            Old_Real_Payment_TBx.Text      = total_real_payment.ToString("#,###.00");
            Old_Real_Payment_Fine_TBx.Text = total_rea_payment_fine.ToString("#,###.00");
            Old_Real_Discount_TBx.Text     = total_discount.ToString("#,###.00");

            Session["list_cls_pay"] = list_cls_pay;

            Real_Payment_TBx.Focus();
        }
示例#21
0
        public ActionResult Index(string id)
        {
            if (this.Request.RequestType.ToLower() == "get")
            {
                string signature = Request.QueryString["signature"];
                string timestamp = Request.QueryString["timestamp"];
                string nonce     = Request.QueryString["nonce"];
                string echostr   = Request.QueryString["echostr"];
                return(Content(echostr));
            }
            else
            {
                string xml          = MyHttpUtility.ReadRequest(this.Request);
                int    createTime   = Convert.ToInt32(XmlUtility.GetSingleNodeInnerText(xml, "/xml/CreateTime"));
                string fromUserName = XmlUtility.GetSingleNodeInnerText(xml, "/xml/FromUserName");
                string toUserName   = XmlUtility.GetSingleNodeInnerText(xml, "/xml/ToUserName");
                string msgType      = XmlUtility.GetSingleNodeInnerText(xml, "/xml/MsgType");
                if (msgType == "event")
                {//事件
                    WX_EventQueue info = new WX_EventQueue()
                    {
                        CreateTime = DateTimeUtility.Parse(createTime),
                        Event      = XmlUtility.GetSingleNodeInnerText(xml, "/xml/Event"),
                        MsgState   = 1,
                        MsgType    = msgType,
                        XmlContent = xml,
                        OpenID     = XmlUtility.GetSingleNodeInnerText(xml, "/xml/FromUserName"),
                        AppId      = id
                    };
                    new WX_EventQueueManager().Add(info);

                    //回复消息
                    string key = XmlUtility.GetSingleNodeInnerText(xml, "/xml/EventKey");
                    WX_MenuEventManager manager = new WX_MenuEventManager();
                    var eve = manager.Where(e => e.MenuKey.Equals(key)).FirstOrDefault();
                    if (eve != null)
                    {
                        string respXml = eve.GetXML(toUserName, fromUserName);
                        return(Content(respXml));
                    }
                }
                else
                { //消息
                    WX_Queue info = new WX_Queue()
                    {
                        MsgState   = 1,
                        MsgId      = XmlUtility.GetSingleNodeInnerText(xml, "/xml/MsgId"),
                        CreateTime = DateTimeUtility.Parse(createTime),
                        XmlContent = xml,
                        OpenID     = XmlUtility.GetSingleNodeInnerText(xml, "/xml/FromUserName"),
                        MsgType    = msgType,
                        AppId      = id
                    };
                    WX_QueueManager manager = new WX_QueueManager();
                    if (manager.GetByPK(info.MsgId) == null)
                    {
                        var r = manager.Add(info);
                    }
                }


                return(Content("success"));
            }
        }
示例#22
0
        public async Task <bool> LoadVideoStreamFromRemoteServer()
        {
            if (IsLoadingVideoStream_RemoteServer)
            {
                return(true);
            }
            IsLoadingVideoStream_RemoteServer = true;

            try
            {
                // clear etc
                Stream.VideoInfo.Clear();
                Stream.VideoInfo_adaptive_fmts.Clear();

                long   nonce = DateTimeUtility.CurrentTimeMillis();
                byte[] ret   = await PrimeTubeAPIs.GetVideoList(string.Format("https://www.youtube.com/watch?v={0}", _videoId), nonce);

                if (ret != null)
                {
                    char[] encryptionKey = CustomXorEncryption.GenerateKey(nonce);

                    PacketReader reader        = new PacketReader(ret);
                    bool         haveVideoInfo = reader.ReadBool();

                    if (!haveVideoInfo)
                    {
                        return(false);
                    }
                    string videoTitle   = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);
                    int    numVideoURLs = reader.ReadInt();

                    for (int i = 0; i < numVideoURLs; i++)
                    {
                        string fullURL = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey); // full url

                        VideoType videotype = VideoType.NULL;
                        switch (CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey)) // container
                        {
                        case "FLV":
                            videotype = VideoType.video_x_flv;
                            break;

                        case "GP3":
                            videotype = VideoType.video_3gpp;
                            break;

                        case "MP4":
                            videotype = VideoType.video_mp4;
                            break;

                        case "WEBM":
                            videotype = VideoType.video_webm;
                            break;
                        }

                        int type = reader.ReadByte() & 0xFF;

                        switch (type)
                        {
                        case 1:     // Audio
                        {
                            string audio = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);
                            string aq    = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);

                            Stream.VideoInfo.Add(new VideoInformation(fullURL, VideoType.audio_mp4, "", "", "", VideoQuality.NULL));
                            break;
                        }

                        case 2:     // Video
                        {
                            string video = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);
                            string vq    = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);

                            Stream.VideoInfo.Add(new VideoInformation(fullURL, videotype, "", "", "", VideoQuality.hd720));
                            break;
                        }

                        case 3:     // Combined
                        {
                            string video = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);
                            string vq    = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);
                            string audio = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);
                            string aq    = CustomXorEncryption.EncryptContent(reader.ReadString(), encryptionKey);

                            Stream.VideoInfo.Add(new VideoInformation(fullURL, videotype, "", "", "", VideoQuality.hd720));
                            break;
                        }

                        default:
                            break;
                        }
                    }

                    return(true);
                }
            }
            catch (Exception exp)
            {
                return(false);
            }
            finally
            {
                IsLoadingVideoStream_RemoteServer = false;
            }
            return(false);
        }
示例#23
0
        public ActionResult MemUsage()
        {
            string[] blobNames = new string[1];
            blobNames[0] = "nuget-prod-0-v2gallery" + @"\Memory\Available MBytes" + string.Format("{0:MMdd}", DateTimeUtility.GetPacificTimeNow());

            return(PartialView("~/Views/Shared/PartialChart.cshtml", ChartingUtilities.GetLineChartFromBlobName(blobNames, "Memory_Usage_todayInMB", 24 * 4, 800)));
        }
 public void ParseIso8601MissingTimezone()
 {
     Assert.Throws <FormatException>(() => DateTimeUtility.ParseIso8601("2006-01-02T03:04:05"));
 }
示例#25
0
 public ActionResult Throughput()
 {
     return(PartialView("~/Views/Shared/PartialChart.cshtml", ChartingUtilities.GetLineChartFromBlobName("IISRequests" + string.Format("{0:MMdd}", DateTimeUtility.GetPacificTimeNow()), "RequestsPerHour")));
 }
 public void ParseIso8601BadDay()
 {
     Assert.Throws <FormatException>(() => DateTimeUtility.ParseIso8601("2006-02-30T03:04:05"));
 }
示例#27
0
        public ActionResult RequestsToday()
        {
            List <Tuple <string, string, string, double> > scenarios = GetRequestsData(String.Format("{0:MMdd}", DateTimeUtility.GetPacificTimeNow()));

            return(PartialView("~/Views/V2GalleryFrontEnd/V2GalleryFrontEnd_RequestDetails.cshtml", scenarios));
        }
 public void ParseIso8601BadHour()
 {
     Assert.Throws <FormatException>(() => DateTimeUtility.ParseIso8601("2006-01-02T25:04:05"));
 }
        public JsonResult GetHourlyPackagetatus()
        {
            Dictionary <string, string> dict = BlobStorageService.GetDictFromBlob("Uploads" + string.Format("{0:MMdd}", DateTimeUtility.GetPacificTimeNow()) + "HourlyReport.json");

            if (dict != null && dict.Count > 0)
            {
                //find the sum of values of each hour from today's report.
                int sum = 0;
                foreach (KeyValuePair <string, string> pair in dict)
                {
                    int count = Convert.ToInt32(pair.Value);
                    sum = sum + count;
                }
                return(Json(sum.ToString(), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("N/A"));
            }
        }
示例#30
0
        // this is the common get metric shared between network and mpstat. since both files are similar formats, we place the get metrics in the common helper class
        public List <string> GetMetrics(List <string> devices, List <string> fileContents)
        {
            // Progress progress = new Progress();
            // progress.WriteTitle("Parsing MPStat/Network metrics", progressLine);

            List <string> metrics = new List <string>();

            string emptyLinePattern = "^\\s*$";
            string splitPattern     = "\\s+";
            string datePattern      = "(\\d{2})\\/(\\d{2})\\/(\\d{4})";

            Regex rgxEmptyLine = new Regex(emptyLinePattern);
            Regex rgxSplitLine = new Regex(splitPattern);
            Regex rgxDate      = new Regex(datePattern);

            int deviceCount = devices.Count;

            int    lastTimeStampHour = -1;
            string metricDateMatch   = rgxDate.Match(fileContents[0]).ToString();

            // looping through each line in the contents of this out file
            for (int i = 1; i < fileContents.Count;)
            {
                // progress.WriteProgress(i, fileContents.Count, progressLine);

                StringBuilder thisMetricSample = new StringBuilder();

                // this file is in a block format and we use empty lines to determin when to start parsing the next metric
                if (rgxEmptyLine.IsMatch(fileContents[i]) && i < fileContents.Count - 1)
                {
                    // advances to the line of the next metric
                    i = i + 2;

                    // grabbing timestamp information for this current metric. we also provide the logic to roll over to the next day since the linux metric collection does not do this for us.
                    string[] thisLineContents = rgxSplitLine.Split(fileContents[i]);

                    DateTime timeStamp = DateTime.Parse(metricDateMatch + " " + thisLineContents[0] + " " + thisLineContents[1]);

                    MetricTimeStamp metricTimeStamp = new DateTimeUtility().FormatMetricTimeStamp(timeStamp, lastTimeStampHour);

                    if (metricTimeStamp.IncrementDay)
                    {
                        metricDateMatch = DateTime.Parse(metricTimeStamp.FormattedTimeStamp).ToString("MM/dd/yyyy");
                    }
                    lastTimeStampHour = metricTimeStamp.LastTimeStampHour;

                    thisMetricSample.Append('"' + metricTimeStamp.FormattedTimeStamp + '"' + "\t");
                }

                // this is where the metric data gets parsed and added to the collection
                for (int x = 1; x <= deviceCount; x++)
                {
                    string[] thisLineContents = rgxSplitLine.Split(fileContents[i]);

                    // read the contents of the split line, start at column 3 and read each string until the end of the array.
                    for (int j = 3; j < thisLineContents.Length; j++)
                    {
                        thisMetricSample.Append('"' + thisLineContents[j] + '"' + "\t");
                    }

                    // the logic of incrementing the for loop for the file contents file is with in the for statement since we need to do some more complicated parsing.
                    i++;
                }

                metrics.Add(thisMetricSample.ToString());
            }
            return(metrics);
        }