Beispiel #1
0
        private void btnRender_Click(object sender, EventArgs e)
        {
            //Create a new list of ADXP(Address Parts)
            List<ADXP> adxpList = new List<ADXP>();

            //Populate the adxpList
            if (!String.IsNullOrEmpty(txtBuildingNumber.Text))
                adxpList.Add(new ADXP(txtBuildingNumber.Text, AddressPartType.BuildingNumber));
            if (!String.IsNullOrEmpty(txtStreetNameBase.Text))
                adxpList.Add(new ADXP(txtStreetNameBase.Text, AddressPartType.StreetNameBase));
            if (!String.IsNullOrEmpty(txtStreetType.Text))
                adxpList.Add(new ADXP(txtStreetType.Text, AddressPartType.StreetType));
            if (!String.IsNullOrEmpty(txtDirection.Text))
                adxpList.Add(new ADXP(txtDirection.Text, AddressPartType.Direction));
            if (!String.IsNullOrEmpty(txtCity.Text))
                adxpList.Add(new ADXP(txtCity.Text, AddressPartType.City));
            if (!String.IsNullOrEmpty(txtState.Text))
                adxpList.Add(new ADXP(txtState.Text, AddressPartType.State));
            if (!String.IsNullOrEmpty(txtCountry.Text))
                adxpList.Add(new ADXP(txtCountry.Text, AddressPartType.Country));
            if (!String.IsNullOrEmpty(txtPostalCode.Text))
                adxpList.Add(new ADXP(txtPostalCode.Text, AddressPartType.PostalCode));
            
            //Create a address out of the Address Parts.
            //NOTE: The PostalAddressUse can be changed to format the address in a variety of ways.
            AD ad = new AD(PostalAddressUse.HomeAddress, adxpList);

            // Get the AD in XML format using the FormatterHelper class.
            string adXmlStr = FormatterHelper.FormatDataType(ad, "AD");

            // Display the generated xml.
            txtXml.Text = adXmlStr;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a patient structure
        /// </summary>
        /// <param name="id">The unique identifier</param>
        /// <param name="name">The name of the patient</param>
        /// <param name="addr">The primary address</param>
        /// <param name="telecom">A primary telecom</param>
        /// <returns>A constructed patient structure</returns>
        public static Patient CreatePatient(
                II id,
                EN name,
                AD addr,
                TEL telecom
            )
        {
            // Instantiate the object
            var retVal = new Patient();

            // Populate address
            retVal.Addr = BAG<AD>.CreateBAG(addr);

            // Confidentiality Code
            retVal.ConfidentialityCode = "N";

            // Effective Time of the types
            // High is populated as "Not Applicable"
            retVal.EffectiveTime = new IVL<TS>(
                (TS)DateTime.Now,
                new TS() { NullFlavor = NullFlavor.NotApplicable }
                );

            // Telecom address
            retVal.Telecom = BAG<TEL>.CreateBAG(telecom);

            // Populate the ID
            retVal.Id = SET<II>.CreateSET(id);

            // Status Code
            retVal.StatusCode = RoleStatus.Active;

            // Return result
            return retVal;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     bool validated = false;
     AD ad = new AD("LDAP://utl.co.ug", "utl\\utl030530", "resetpassword");
     Dictionary<string,object> userDetails = ad.getUserDetails(Page.User.Identity.Name.Split(new char[]{'\\'})[1]);
     string[] Dls = (string [])userDetails["dls"];
     List<string> allowedProfiles = new List<string>() { "DL-Callcen-Back office", "DL-CUSTOMER SERVICE ADVISORS", "DL-CallCen Msente", "DL-CallCen The Royals", "DL-IT VAS&TI", "DL-Service Centre Team Leaders" };
     foreach (string dl in Dls)
     {
         if (allowedProfiles.Contains(dl))
         {
             validated = true;
             break;
         }
     }
     if (!validated)
     {
         Response.StatusCode = 403;
         Response.Write("Access Denied");
         Response.End();
     }
 }
Beispiel #4
0
 public void ADExampleTest04()
 {
     AD vacationHome = new AD(PostalAddressUse.VacationHome,
         new ADXP[] {}
         );
     vacationHome.NullFlavor = NullFlavor.Other;
     Console.WriteLine(vacationHome.ToString("{ZIP} - {CTY}, {STA} {CNT}"));
     // output: N2N2N4 - Thunder Bay, Ontario Canada
     Assert.IsTrue(vacationHome.Validate());
 }
Beispiel #5
0
 public void R2ADUnknownAddressSerializationTest()
 {
     String expectedXml = @"<test xmlns=""urn:hl7-org:v3"" use=""WP"" nullFlavor=""UNK""/>";
     var adi = new AD(PostalAddressUse.WorkPlace) { NullFlavor = NullFlavor.Unknown };
     String actualXml = R2SerializationHelper.SerializeAsString(adi);
     R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml);
 }
Beispiel #6
0
 internal void AddStructuredAddress(AD address)
 {
     if (this.addr == null)
     {
         this.addr = new List<AD>();
     }
     this.addr.Add(address);
 }
Beispiel #7
0
 public void ADTypeMismatchEqualityTest()
 {
     AD a = new AD(
         new ADXP[] { 
             new ADXP("123 Main Street West Hamilton ON")
         }
     );
     Assert.IsFalse(a.Equals("123 Main Street West Hamilton ON"));
 }
Beispiel #8
0
        public void ADNullFlavorTest()
        {
            AD ad = new AD();
            ad.NullFlavor = NullFlavor.NotAsked;
            Assert.IsTrue(ad.Validate());

        }
Beispiel #9
0
 public void ADPartTest()
 {
     AD ad = new AD();
     ad.Part.AddRange(GenerateAddress());
     ad.NullFlavor = null;
     Assert.IsTrue(ad.Validate());
 }
Beispiel #10
0
 public void ADContentDifferentEqualityTest()
 {
     AD a = new AD(
         new ADXP[] { 
             new ADXP("123 Main Street West Hamilton ON")
         }
     ), b = new AD(new ADXP[] { 
             new ADXP("123 Main Street West Hamilton")
         }
     );
     Assert.IsFalse(a.Equals(b));
 }
Beispiel #11
0
 public void ADToStringTest()
 {
     AD a = new AD(
         new ADXP[] { 
             new ADXP("123", AddressPartType.BuildingNumber),
             new ADXP("Main", AddressPartType.StreetName),
             new ADXP("Street", AddressPartType.StreetType),
             new ADXP("West", AddressPartType.Direction)
         });
     Assert.AreEqual(a.ToString(), "123MainStreetWest");
 }
Beispiel #12
0
 public void ADExampleTest01()
 {
     AD vacationHome = new AD(PostalAddressUse.VacationHome,
         new ADXP[]{
             new ADXP("321 Cedar Rd. North", AddressPartType.StreetAddressLine),
             new ADXP("Thunder Bay", AddressPartType.City),
             new ADXP("Ontario", AddressPartType.State),
             new ADXP("Canada", AddressPartType.Country),
             new ADXP("N2N2N4", AddressPartType.PostalCode)
         }
         );
     vacationHome.NullFlavor = null;
     Console.WriteLine(vacationHome.ToString("{ZIP} - {CTY}, {STA} {CNT}"));
     // output: N2N2N4 - Thunder Bay, Ontario Canada
     Assert.IsTrue(vacationHome.Validate());
 }
Beispiel #13
0
 public void ADExampleTest08()
 {
     AD vacationHome = new AD(PostalAddressUse.VacationHome,
         new ADXP[] {
             new ADXP("Canada", AddressPartType.Country)
         }
         );
     vacationHome.NullFlavor = null;
     Console.WriteLine(vacationHome.ToString("{ZIP} - {CTY}, {STA} {CNT}"));
     // output: Canada
     Assert.IsFalse(AD.IsValidBasicFlavor(vacationHome));
 }
Beispiel #14
0
 public void ADExampleTest07()
 {
     AD vacationHome = new AD(PostalAddressUse.VacationHome,
         new ADXP[] {
             new ADXP("Ontario", AddressPartType.State)
         }
         );
     vacationHome.NullFlavor = null;
     Console.WriteLine(vacationHome.ToString("{ZIP} - {CTY}, {STA} {CNT}"));
     // output: Ontario
     Assert.IsTrue(AD.IsValidBasicFlavor(vacationHome));
 }
Beispiel #15
0
        public void ADToStringCorrectTest()
        {
            AD toStringValid = new AD(
                new ADXP[]
                {
                    new ADXP("Hamilton",AddressPartType.City),
                    new ADXP("Ontario", AddressPartType.State),
                    new ADXP("CA",AddressPartType.Country)
                }
            );

            Assert.AreEqual("Hamilton Ontario CA", toStringValid.ToString("{CTY}{STA}{CNT}"));
        }
Beispiel #16
0
 public void ADNullTest()
 {
     AD ad = new AD();
     ad.NullFlavor = null;
     Assert.IsFalse(ad.Validate());
 }
Beispiel #17
0
        public void ANYIsNullTest()
        {
            AD isNull = new AD();
            isNull.NullFlavor = NullFlavor.AskedUnknown;

            Assert.AreEqual(true, isNull.IsNull);
        }
Beispiel #18
0
 public void ADPartNullFlavorTest()
 {
     AD ad = new AD();
     ad.Part.AddRange(GenerateAddress());
     ad.NullFlavor = NullFlavor.NotApplicable;
     Assert.IsFalse(ad.Validate());
 }
Beispiel #19
0
 public void ADContentSameEqualityTest()
 {
     AD a = new AD(
         new ADXP[] { 
             new ADXP("123 Main Street West Hamilton ON")
         }
     ), b = new AD(new ADXP[] { 
             new ADXP("123 Main Street West Hamilton ON")
         }
     );
     Assert.IsTrue(a.Equals(b));
     Assert.IsTrue(a.Equals((object)b));
 }
Beispiel #20
0
 public void ADNullFlavorValidationTest()
 {
     AD ad = new AD(new ADXP[] {new ADXP("123", AddressPartType.BuildingNumber)});
     ad.NullFlavor = NullFlavor.Invalid;
     Assert.IsFalse(ad.Validate());
 }
Beispiel #21
0
 internal void SetStructuredAddress(AD address)
 {
     // redefine so as to clear - we only want one address
     this.addr = new List<AD>();
     this.AddStructuredAddress(address);
 }
Beispiel #22
0
 public void ADPartNullFlavorValidationTest()
 {
     AD ad = new AD();
     ad.NullFlavor = NullFlavor.Invalid;
     ad.Part.Add(new ADXP("hello"));
     Assert.IsFalse(ad.Validate());
 }
Beispiel #23
0
        public ActionResult Login(LoginInfo model)
        {
            //初始化系統參數
            Configer.Init();

            AD AD = new AD();
            VA VA = new VA();
            LoginProcessor LP = new LoginProcessor();
            bool UseCertLogin = false;
            string LDAPName = Configer.LDAPName;
            //string VAVerifyURL = WebConfigurationManager.AppSettings["VAVerifyURL"];
            //string ConnStr = Configer.C_DBConnstring;
            Boolean ContinueLogin = true;

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();
            SL.UId = model.UserID;
            SL.Controller = "Account";
            SL.Action = "Login";
            SL.StartDateTime = DateTime.Now;
            SL.TotalCount = 1;

            string MailServer = Configer.MailServer;
            int MailServerPort = Configer.MailServerPort;
            string MailSender = Configer.MailSender;
            List<string> MailReceiver = Configer.MailReceiver;
            //string SendResult = string.Empty;

            if (ModelState.IsValid)
            {
                if (LDAPName == "")
                {
                    //缺少系統參數,需記錄錯誤
                    SL.EndDateTime = DateTime.Now;
                    SL.SuccessCount = 0;
                    SL.FailCount = 1;
                    SL.Msg = "登入作業失敗,錯誤訊息:[缺少系統參數LDAPName]";
                    SL.Result = false;
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    ContinueLogin = false;
                }
                if (ContinueLogin)
                {
                    AD.UserName = model.UserID;
                    AD.Pwd = model.Pwd;
                    AD.validType = AD.ValidType.Domain;
                    AD.LDAPName = LDAPName;

                    //VA.SignData = model.SignData;
                    //VA.Plaintext = model.Plaintext;
                    //VA.txnCode = "TxnCode";
                    //VA.VAVerifyURL = VAVerifyURL;
                    //VA.Tolerate = 120;

                    DateTime LoginStartTime = DateTime.Now;
                    SF.logandshowInfo("登入開始@" + LoginStartTime.ToString(Configer.SystemDateTimeFormat), log_Info);
                    bool LoginResult = LP.DoLogin(UseCertLogin, AD, VA);
                    DateTime LoginEndTime = DateTime.Now;
                    SF.logandshowInfo("登入結束@" + LoginEndTime.ToString(Configer.SystemDateTimeFormat), log_Info);
                    string LoginSpanTime = OtherProcesser.TimeDiff(LoginStartTime, LoginEndTime, "Milliseconds");
                    SF.logandshowInfo("本次登入共花費@" + LoginSpanTime + "毫秒", log_Info);

                    if (LoginResult == true)
                    {
                        //登入成功,需紀錄
                        SL.EndDateTime = DateTime.Now;
                        SL.SuccessCount = 1;
                        SL.FailCount = 0;
                        SL.Msg = "登入成功";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                        Session["UseCertLogin"] = UseCertLogin;
                        //Session["UseCertLogin"] = true;
                        Session["UserID"] = model.UserID;
                        //Session["UserID"] = "TAS191";
                        int UserRole= SF.getUserRole(model.UserID);
                        Session["UserRole"] = UserRole;

                        //主管導向覆核頁面
                        if (UserRole > 3)
                        {
                            return RedirectToAction("Index", "Review");
                        }
                        else
                        {
                            //導向檢查頁面
                            return RedirectToAction("Index", "Process");
                        }
                    }
                    else
                    {
                        //string a=VA.ResultStr;

                        //登入失敗,需記錄錯誤
                        SL.EndDateTime = DateTime.Now;
                        SL.FailCount = 1;
                        if (UseCertLogin)
                        {
                            SL.Msg = "登入失敗,錯誤訊息:[AD或VA驗證失敗]";
                        }
                        else
                        {
                            SL.Msg = "登入失敗,錯誤訊息:[AD驗證失敗]";
                        }
                        SL.Result = false;
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                        TempData["LoginMsg"] = SL.Msg;

                        return RedirectToAction("Login", "Account");
                    }
                }
                else
                {
                    TempData["LoginMsg"] = "登入失敗,錯誤訊息:[系統登入參數遺失]";
                    return RedirectToAction("Login", "Account");
                }
            }
            else
            {
                return RedirectToAction("Login", "Account");
            }
        }
Beispiel #24
0
 public void ADPostalAddressUseIEnumerableADXP_CTORTest()
 {
     AD ctorPostalAddressUseAndADXPArray =
       new AD(
         PostalAddressUse.Direct,
       new ADXP[]
       {
             new ADXP("Street",AddressPartType.StreetType),
             new ADXP("Main",AddressPartType.StreetName),
             new ADXP("122",AddressPartType.BuildingNumber),
             new ADXP("Hamilton",AddressPartType.City)      
       }
    );
     // True if the the AD object has 4 address parts and 1 postal address use.
     Assert.IsTrue(ctorPostalAddressUseAndADXPArray.Part.Count == 4 && ctorPostalAddressUseAndADXPArray.Use.Count == 1);
 }
Beispiel #25
0
 internal void SetStructuredAddress(AD address)
 {
     this.addr = new List<AD>();
     this.addr.Add(address);
 }
Beispiel #26
0
        public void ADSETPostalAddressUseIEnumerableADXP_CTORTest()
        {
            AD ctorPostalAddressUseAndADXPArray =
                new AD(
                    new SET<CS<PostalAddressUse>>(
                        new CS<PostalAddressUse>[]
                        {
                            PostalAddressUse.HomeAddress,
                            PostalAddressUse.Direct
                        },CS<PostalAddressUse>.Comparator
                        ),

                    new ADXP[]
                    {
                        new ADXP("Street",AddressPartType.StreetType),
                        new ADXP("Main",AddressPartType.StreetName),
                        new ADXP("122",AddressPartType.BuildingNumber),
                        new ADXP("Hamilton",AddressPartType.City)      
                    }
                );
            Assert.AreEqual(ctorPostalAddressUseAndADXPArray.Part.Count ,4);
            Assert.AreEqual(ctorPostalAddressUseAndADXPArray.Use.Count ,2);
        }
Beispiel #27
0
 public void R2ADUnknownAddressParseTest()
 {
     var adi = new AD(PostalAddressUse.WorkPlace) { NullFlavor = NullFlavor.NoInformation };
     String actualXml = R2SerializationHelper.SerializeAsString(adi);
     var ad2 = R2SerializationHelper.ParseString<AD>(actualXml);
     Assert.AreEqual(adi, ad2);
 }
Beispiel #28
0
        public void ADValidADBasicFlavorTest()
        {
            AD invalidBasicFlavorTest = new AD();

            invalidBasicFlavorTest.Part.Add(new ADXP("Hamilton", AddressPartType.City));
            invalidBasicFlavorTest.Part.Add(new ADXP("Ontario", AddressPartType.State));

            Assert.IsTrue(AD.IsValidBasicFlavor(invalidBasicFlavorTest));
        }
Beispiel #29
0
        /// <summary>
        /// Example 69
        /// Creates a patient structure
        /// </summary>
        /// <param name="id">The unique identifier</param>
        /// <param name="name">The name of the patient</param>
        /// <param name="addr">The primary address</param>
        /// <param name="telecom">A primary telecom</param>
        /// <returns>A constructed patient structure</returns>
        public Patient CreatePatient(
                II id,
                EN name,
                AD addr,
                TEL telecom
            )
        {
            try
            {
                // Instantiate the object
                var retVal = new Patient();

                // Populate address
                retVal.Addr = BAG<AD>.CreateBAG(addr);

                // Confidentiality Code
                retVal.ConfidentialityCode = "N";

                // Effective Time of the types
                // High is populated as "Not Applicable"
                retVal.EffectiveTime = new IVL<TS>(
                    (TS)DateTime.Now,
                    new TS() { NullFlavor = NullFlavor.NotApplicable }
                    );

                // Telecom address
                retVal.Telecom = BAG<TEL>.CreateBAG(telecom);

                // Populate the ID
                retVal.Id = SET<II>.CreateSET(id);

                // Status Code
                retVal.StatusCode = RoleStatus.Active;

                // Set entity choice
                retVal.SetPatientEntityChoiceSubject(
                    new Person()
                    {
                        AdministrativeGenderCode = AdministrativeGender.Male,
                        Name = BAG<EN>.CreateBAG(name),
                        BirthTime = DateTime.Now
                    }
                    );

                // cannot return result for unit test purposes
                return retVal;
            }
            catch
            {
                Console.WriteLine("Unit tests must not return a value, but Patient must be returned..");
                return new Patient();
            }
        }
Beispiel #30
0
        public void ADUPTest01()
        {
            AD vacationHome = new AD(PostalAddressUse.VacationHome,
                new ADXP[]{
                    new ADXP("321 Cedar Rd. North", AddressPartType.StreetAddressLine),
                    new ADXP("Thunder Bay", AddressPartType.City),
                    new ADXP("Ontario", AddressPartType.State),
                    new ADXP("Canada", AddressPartType.Country),
                    new ADXP("N2N2N4", AddressPartType.PostalCode)
                }
                );

            // Assign a usable period interval to the address
            vacationHome.UseablePeriod = new GTS(
                new PIVL<TS>(
                    new TS(DateTime.Parse("01-May-2011"),
                        DatePrecision.Month).ToIVL(),
                        new PQ (1, "a")
                    )
                );

            vacationHome.NullFlavor = null;
            Assert.IsTrue(vacationHome.Validate());
        }