Exemplo n.º 1
0
    protected void lvDataList_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        //取得Key值
        string Get_DataID = ((HiddenField)e.Item.FindControl("hf_DataID")).Value;

        //----- 宣告:資料參數 -----
        SignDataRepository _data = new SignDataRepository();

        try
        {
            //----- 方法:刪除資料 -----
            if (false == _data.Delete(Get_DataID, out ErrMsg))
            {
                CustomExtension.AlertMsg("刪除失敗", thisPage);
                return;
            }
            else
            {
                //導向本頁
                Response.Redirect(thisPage);
            }
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            _data = null;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 資料新增
    /// </summary>
    private void Add_Data()
    {
        //----- 宣告:資料參數 -----
        SignDataRepository _data = new SignDataRepository();

        try
        {
            //----- 設定:資料欄位 -----
            //產生Guid
            string guid        = CustomExtension.GetGuid();
            string _traceID    = NewTraceID();
            string _subject    = tb_Subject.Text;
            string _disp       = rbl_Display.SelectedValue;
            Int32  _sort       = Convert.ToInt32(tb_Sort.Text);
            string _startTime  = tb_StartTime.Text;
            string _endTime    = tb_EndTime.Text;
            Int32  _place      = Convert.ToInt32(ddl_Place.SelectedValue);
            string _otherPlace = tb_OtherPlace.Text;


            //instance
            var data = new BaseData
            {
                Data_ID    = new Guid(guid),
                TraceID    = _traceID,
                Subject    = _subject,
                Display    = _disp,
                Sort       = _sort,
                StartTime  = _startTime,
                EndTime    = _endTime,
                Place      = _place,
                OtherPlace = _otherPlace
            };


            //----- 方法:新增資料 -----
            if (!_data.Create(data, out ErrMsg))
            {
                ph_ErrMessage.Visible = true;
                lt_ShowMsg.Text       = ErrMsg;
                CustomExtension.AlertMsg("新增失敗", "");
                return;
            }
            else
            {
                //導向本頁
                string url = FuncPath() + "/Edit/" + guid + "#section1";
                Response.Redirect(url);
            }
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            _data = null;
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 資料修改
    /// </summary>
    private void Edit_Data()
    {
        //----- 宣告:資料參數 -----
        SignDataRepository _data = new SignDataRepository();

        try
        {
            //----- 設定:資料欄位 -----
            string _dataID = hf_DataID.Value;

            string _subject    = tb_Subject.Text;
            string _disp       = rbl_Display.SelectedValue;
            Int32  _sort       = Convert.ToInt32(tb_Sort.Text);
            string _startTime  = tb_StartTime.Text;
            string _endTime    = tb_EndTime.Text;
            Int32  _place      = Convert.ToInt32(ddl_Place.SelectedValue);
            string _otherPlace = tb_OtherPlace.Text;

            //instance
            var data = new BaseData
            {
                Subject    = _subject,
                Display    = _disp,
                Sort       = _sort,
                StartTime  = _startTime,
                EndTime    = _endTime,
                Place      = _place,
                OtherPlace = _otherPlace
            };

            //----- 方法:更新資料 -----
            if (!_data.Update(_dataID, data, out ErrMsg))
            {
                ph_ErrMessage.Visible = true;
                lt_ShowMsg.Text       = ErrMsg;
                CustomExtension.AlertMsg("更新失敗", "");
                return;
            }
            else
            {
                //導向本頁
                Response.Redirect(thisPage);
            }
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            _data = null;
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 名單設定
    /// </summary>
    protected void btn_Setting_Click(object sender, EventArgs e)
    {
        //----- 判斷 -----
        //[欄位檢查] - 權限編號
        string inputValue = tree_Values.Text;

        if (string.IsNullOrEmpty(inputValue))
        {
            CustomExtension.AlertMsg("名單未勾選任何人,請確認!", "");
            return;
        }


        //[取得參數值] - 編號組合
        string[] strAry = Regex.Split(inputValue, @"\,{1}");
        var      query  = from el in strAry
                          select new
        {
            Val = el.ToString().Trim()
        };

        //----- 宣告 -----
        List <NameList> dataList = new List <NameList>();

        foreach (var item in query)
        {
            //加入項目
            var data = new NameList
            {
                Who = item.Val
            };

            //將項目加入至集合
            dataList.Add(data);
        }


        //----- 宣告:資料參數 -----
        SignDataRepository _data = new SignDataRepository();

        //----- 方法:更新資料 -----
        if (false == _data.CreateDetail(Req_DataID, dataList, out ErrMsg))
        {
            CustomExtension.AlertMsg("名單設定失敗", "");
            return;
        }
        else
        {
            //導向本頁
            Response.Redirect(thisPage + "#section1");
        }
    }
Exemplo n.º 5
0
    protected void lvList_NameList_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            /*
             * (看實際情況)下一版本改為ajax處理, 不然跳頁會不好用
             */
            //取得Key值
            string _SignWho = ((HiddenField)e.Item.FindControl("hf_NameID")).Value;

            //----- 宣告:資料參數 -----
            SignDataRepository _data = new SignDataRepository();

            try
            {
                //instance
                var data = new CheckIn
                {
                    SignWho  = _SignWho,
                    SignTime = DateTime.Now.ToString().ToDateString("yyyy/MM/dd HH:mm:ss"),
                    FromIP   = "",
                    IsAgent  = "Y"
                };

                //do Check
                if (_data.CheckSign(Req_DataID, data, out ErrMsg))
                {
                    CustomExtension.AlertMsg("重複簽到", thisPage);
                    return;
                }

                //do Create
                if (false == _data.CreateSign(Req_DataID, data, out ErrMsg))
                {
                    CustomExtension.AlertMsg("代簽失敗", "");
                    return;
                }

                //導向本頁
                Response.Redirect(thisPage + "#section2");
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                //Release
                _data = null;
            }
        }
    }
Exemplo n.º 6
0
    protected void lvList_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            //取得Key值
            string _SignWho = fn_Param.MemberID;
            string _GetIP   = CustomExtension.GetIP();

            //----- 宣告:資料參數 -----
            SignDataRepository _data = new SignDataRepository();

            try
            {
                //instance
                var data = new CheckIn
                {
                    SignWho  = _SignWho,
                    SignTime = DateTime.Now.ToString().ToDateString("yyyy/MM/dd HH:mm:ss"),
                    FromIP   = _GetIP,
                    IsAgent  = "N"
                };

                //do Check
                if (_data.CheckSign(Req_DataID, data, out ErrMsg))
                {
                    CustomExtension.AlertMsg("重複簽到", FuncPath());
                    return;
                }

                //do Create
                if (false == _data.CreateSign(Req_DataID, data, out ErrMsg))
                {
                    CustomExtension.AlertMsg("簽到失敗", thisPage);
                    return;
                }

                //導向首頁
                Response.Redirect(FuncPath());
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                //Release
                _data = null;
            }
        }
    }
Exemplo n.º 7
0
 private void buttonX2_Click(object sender, EventArgs e)
 {
     try
     {
         CustomExtension cext = new CustomExtension(textBoxX1.Text);
         cext.Elements = Elements;
         if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             cext.SaveXml(saveFileDialog1.FileName);
         }
     }
     catch (Exception ex)
     {
         Log.ShowInfo(ex.Message, "SAVE EXTENSION");
     }
 }
Exemplo n.º 8
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     try
     {
         if (superValidator1.Validate())
         {
             CExtension          = new CustomExtension(textBoxX1.Text);
             CExtension.Elements = Elements;
             this.Close();
         }
     }
     catch (Exception ex)
     {
         Log.ShowInfo(ex.Message, "ADD EXTENSION");
     }
 }
Exemplo n.º 9
0
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        try
        {
            /*
             * 使用外部連AD帳戶驗證, 請確認AD相關設定是否齊全
             */

            //取得輸入參數
            string GetEmail = tb_Account.Text.Left(5);
            string GetPwd   = tb_Password.Text.Left(30);
            string errTxt   = "";

            if (string.IsNullOrWhiteSpace(GetEmail))
            {
                errTxt += "帳號空白\\n";
            }
            if (string.IsNullOrWhiteSpace(GetPwd))
            {
                errTxt += "密碼空白\\n";
            }

            //alert
            if (!string.IsNullOrEmpty(errTxt))
            {
                CustomExtension.AlertMsg(errTxt, "");
                return;
            }

            //[判斷帳號是否存在]
            if (Check_AD(GetEmail, GetPwd, out ErrMsg))
            {
                //導向指定網址
                Response.Redirect(fn_Param.WebUrl);
            }
            else
            {
                //登入失敗
                CustomExtension.AlertMsg("登入失敗,請確認帳號或密碼是否正確.", "");
                return;
            }
        }
        catch (Exception)
        {
            throw;
        }
    }
Exemplo n.º 10
0
 private void buttonX3_Click(object sender, EventArgs e)
 {
     try
     {
         CustomExtension cext = new CustomExtension("");
         if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             cext.LoadFromXml(openFileDialog1.FileName);
             Elements = cext.Elements;
             foreach (ASNElement el in cext.Elements)
             {
                 Node nd = ASNode(el);
                 node2.Nodes.Add(nd);
                 AddNodes(nd, el);
             }
         }
     }
     catch (Exception ex)
     {
         Log.ShowInfo(ex.Message, "OPEN EXTENSION");
     }
 }
Exemplo n.º 11
0
    /// <summary>
    /// SAVE
    /// </summary>
    private void doSave()
    {
        string errTxt = "";

        if (string.IsNullOrWhiteSpace(tb_Subject.Text))
        {
            errTxt += "會議主題\\n";
        }
        if (string.IsNullOrWhiteSpace(ddl_Place.SelectedValue))
        {
            errTxt += "會議室\\n";
        }

        string _sTime = tb_StartTime.Text;
        string _eTime = tb_EndTime.Text;

        if (Convert.ToDateTime(_sTime) > Convert.ToDateTime(_eTime))
        {
            errTxt += "會議簽到時間不可逆行\\n";
        }

        //alert
        if (!string.IsNullOrEmpty(errTxt))
        {
            CustomExtension.AlertMsg("=== 請檢查以下欄位 ===\\n" + errTxt, "");
            return;
        }

        /* 執行新增/更新 */
        if (string.IsNullOrEmpty(hf_DataID.Value))
        {
            Add_Data();
        }
        else
        {
            Edit_Data();
        }
    }
Exemplo n.º 12
0
        //the construction for custom extensions
        public AnonymousFunction(string value, CustomExtension parent) : this()
        {
            Name = value.Split('.')[1].Split('(')[0];

            //get top level anonymous functions before everything else
            var anonRegex        = new Regex(Compiler.ScopeRegex(@"=>"), RegexOptions.IgnorePatternWhitespace);
            var anonRegexMatches = anonRegex.Matches(value);

            foreach (var a in anonRegexMatches)
            {
                var func = new AnonymousFunction(a.ToString(), true, _base);
                func.Base = Base;
                FunctionStack.Add(func);
                value = value.Replace(a.ToString(), $"\"{func.Name}\"");
            }
            //
            Value        = value;
            ExpectedArgs = value.Split('(')[1].Split(')')[0].Split(',');
            var type = ExpectedArgs.ElementAtOrDefault(0);

            if (type != null && type == "this variable")
            {
                parent.SetProperties(Name, new string[] { }, false, false, true, new string[] { });
            }
            else if (type != null && type == "this function")
            {
                parent.SetProperties(Name, new string[] { }, false, false, false, new string[] { });
            }
            else
            {
                Compiler.ExceptionListener.Throw("[287]Custom extension must have input parameter of `this variable` or `this function`");
            }
            //replace this from the parameter, so it can be called by just `function` or `variable` at runtime
            //the `this` is only there for definition, to direct the extension parser to look for this extension
            //in the variable lot or not.
            ExpectedArgs[0] = ExpectedArgs[0].Replace("this ", "");
            ParseDirectives(value);
        }
Exemplo n.º 13
0
        // GET: api/<ExtensionController>
        //[HttpGet("extensions/")]
        public async Task <IActionResult> GetExtensions()
        {
            List <ExtensionModel> retVal = new List <ExtensionModel>();

            try
            {
                var authenticationResult = GraphClientUtility.GetAuthentication();

                if (authenticationResult == null)
                {
                    _logger.LogError("ExtensionController-GetExtensions: Unable to get the Access token and Authentication Result");
                    return(NotFound());
                }
                _logger.LogInfo("ExtensionController-GetExtensions: [Started] to fetch user attribute in Azure AD B2C");

                var accessToken             = authenticationResult.Result.AccessToken;
                var b2cExtensionAppObjectId = GraphClientUtility.b2cExtensionAppObjectId;
                var tenantId           = GraphClientUtility.TenantId;
                var aadGraphVersion    = GraphClientUtility.AADGraphVersion;
                var aadGraphResourceId = GraphClientUtility.AADGraphResourceId;

                CustomExtension customExtensions = null;

                if (!string.IsNullOrEmpty(b2cExtensionAppObjectId) &&
                    !string.IsNullOrEmpty(tenantId) &&
                    !string.IsNullOrEmpty(aadGraphVersion) &&
                    !string.IsNullOrEmpty(aadGraphResourceId))
                {
                    string url = $"{aadGraphResourceId}{tenantId}" +
                                 $"{CareStreamConst.ForwardSlash}{CareStreamConst.Applications}{CareStreamConst.ForwardSlash}" +
                                 $"{b2cExtensionAppObjectId}{CareStreamConst.ForwardSlash}{CareStreamConst.ExtensionProperties}" +
                                 $"{CareStreamConst.Question}{aadGraphVersion}";

                    HttpClient         http    = new HttpClient();
                    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);
                    request.Headers.Authorization = new AuthenticationHeaderValue(CareStreamConst.Bearer, accessToken);
                    HttpResponseMessage response = await http.SendAsync(request);

                    if (response.IsSuccessStatusCode)
                    {
                        var data = await response.Content.ReadAsStringAsync();

                        customExtensions = JsonConvert.DeserializeObject <CustomExtension>(data);
                    }
                }

                if (customExtensions != null)
                {
                    if (customExtensions.value != null)
                    {
                        _logger.LogInfo($"ExtensionController-GetExtensions:got {customExtensions.value.Count} user attribute from Azure AD B2C");
                    }

                    var b2cExtensionAppClientId = GraphClientUtility.b2cExtensionAppClientId;
                    b2cExtensionAppClientId = b2cExtensionAppClientId.Replace(CareStreamConst.Dash, "");
                    var toReplace = $"{CareStreamConst.Extension}{CareStreamConst.Underscore}{b2cExtensionAppClientId}{CareStreamConst.Underscore}";

                    foreach (var value in customExtensions.value)
                    {
                        try
                        {
                            var extensionModel = new ExtensionModel
                            {
                                ObjectId      = value.objectId,
                                DataType      = value.dataType,
                                TargetObjects = value.targetObjects,
                                AttributeType = CareStreamConst.Custom,
                                Description   = string.Empty,
                                Name          = value.name,
                                IsBuildIn     = false
                            };

                            if (!string.IsNullOrEmpty(extensionModel.Name))
                            {
                                extensionModel.Name = extensionModel.Name.Replace(toReplace, "");
                            }

                            retVal.Add(extensionModel);
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError($"ExtensionController-GetExtensions: fail to add extension [name:{value.name}] to collection ");
                            _logger.LogError(ex);
                        }
                    }
                }
                if (retVal.Any())
                {
                    retVal = retVal.OrderBy(x => x.Name).ToList();
                }

                _logger.LogInfo("ExtensionController-GetExtensions: [Completed] getting user attribute in Azure AD B2C");
            }
            catch (ServiceException ex)
            {
                _logger.LogError("ExtensionController-GetExtensions: Exception occured....");
                _logger.LogError(ex);
            }

            return(Ok(retVal));
        }
Exemplo n.º 14
0
    /// <summary>
    /// 取得資料
    /// </summary>
    private void LookupData()
    {
        //----- 宣告:資料參數 -----
        SignDataRepository          _data  = new SignDataRepository();
        Dictionary <string, string> search = new Dictionary <string, string>();

        try
        {
            //----- 原始資料:取得所有資料 -----
            search.Add("DataID", Req_DataID);

            var query = _data.GetOne(search, out ErrMsg).FirstOrDefault();

            //----- 資料整理:繫結 -----
            if (query == null)
            {
                CustomExtension.AlertMsg("無法取得資料,即將返回列表頁.", Page_SearchUrl);
                return;
            }


            #region >> 欄位填寫 <<
            hf_DataID.Value           = query.Data_ID.ToString();
            lb_TraceID.Text           = query.TraceID;
            rbl_Display.SelectedValue = query.Display;
            tb_Sort.Text            = query.Sort.ToString();
            tb_Subject.Text         = query.Subject;
            tb_StartTime.Text       = query.StartTime.ToDateString("yyyy/MM/dd HH:mm");
            tb_EndTime.Text         = query.EndTime.ToDateString("yyyy/MM/dd HH:mm");
            ddl_Place.SelectedValue = query.Place.ToString();
            tb_OtherPlace.Text      = query.OtherPlace;

            //Details
            ph_Details.Visible  = true;  //與會名單tree / list
            ph_DetailJS.Visible = true;  //tree js
            ph_tip1.Visible     = false; //提示建立資料

            #endregion


            //維護資訊
            info_Creater.Text    = query.Create_Name;
            info_CreateTime.Text = query.Create_Time;
            info_Updater.Text    = query.Update_Name;
            info_UpdateTime.Text = query.Update_Time;


            //簽到判斷, 大於0, 鎖住部份欄位
            Int32 _signCnt = query.SignCnt;
            if (_signCnt > 0)
            {
                tb_StartTime.Enabled  = false;
                tb_EndTime.Enabled    = false;
                ddl_Place.Enabled     = false;
                tb_OtherPlace.Enabled = false;

                ph_LockMessage.Visible = true;
            }

            //載入單身
            LookupData_Detail1();
            LookupData_Detail2();
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            //Release
            _data = null;
        }
    }
Exemplo n.º 15
0
        public ExtensionPublicPropertyReflectorTest()
        {
            this.extension = new CustomExtension();

            this.testee = new ReflectExtensionPublicProperties();
        }
Exemplo n.º 16
0
        private List <IBaseFunction> ParseScopes(string file, List <IBaseFunction> predefined)
        {
            var temp = new List <IBaseFunction>();
            //remove all comments
            var commRegex = new Regex(@"#([^\n]+)$", RegexOptions.Multiline);

            file = commRegex.Replace(file, "");

            //add functions first
            var _functionStack = new List <IBaseFunction>();
            var scopeRegex     = new Regex(ScopeRegex(@"\bfunction\.\b"), RegexOptions.IgnorePatternWhitespace);
            var scopes         = scopeRegex.Matches(file);

            foreach (var s in scopes)
            {
                _functionStack.Add(new AnonymousFunction(s.ToString()));
            }
            //add inherits second
            var _inheritStack     = new List <IBaseFunction>();
            var inheritRegex      = new Regex(ScopeRegex(@"\boverride\.\b"), RegexOptions.IgnorePatternWhitespace);
            var inherits          = inheritRegex.Matches(file);
            var tempfunctionstack = new List <IBaseFunction>();

            tempfunctionstack.AddRange(_functionStack);
            tempfunctionstack.AddRange(predefined);
            for (var i = inherits.Count - 1; i >= 0; i--)
            {
                var inherit = inherits[i];
                var obj     = new AnonymousFunction(inherit.ToString(), tempfunctionstack);
                _inheritStack.Add(obj);
                tempfunctionstack.Insert(0, obj);
            }
            //add custom extensions
            var _extStack = new List <EDefinition>();
            var extRegex  = new Regex(ScopeRegex(@"\bextension\.\b"), RegexOptions.IgnorePatternWhitespace);
            var exts      = extRegex.Matches(file);

            for (var i = exts.Count - 1; i >= 0; i--)
            {
                var ext  = exts[i];
                var cext = new CustomExtension();
                cext.FunctionReference = new AnonymousFunction(ext.ToString(), cext);
                _extStack.Add(cext);
            }
            ExtensionStack.AddRange(_extStack);
            //add async
            var _asyncStack = new List <IBaseFunction>();
            var asyncRegex  = new Regex(ScopeRegex(@"\basync\.\b"), RegexOptions.IgnorePatternWhitespace);
            var asyncs      = asyncRegex.Matches(file);

            foreach (var i in asyncs)
            {
                var obj = new AnonymousFunction(i.ToString());
                obj.Async = true;
                _asyncStack.Add(obj);
            }
            temp.AddRange(_inheritStack.Reverse <IBaseFunction>());
            temp.AddRange(_functionStack);
            temp.AddRange(_asyncStack);
            return(temp);
        }
Exemplo n.º 17
0
    /// <summary>
    /// 取得資料
    /// </summary>
    private void LookupDataList(int pageIndex)
    {
        //----- 宣告:網址參數 -----
        int       RecordsPerPage = 10;                               //每頁筆數
        int       StartRow       = (pageIndex - 1) * RecordsPerPage; //第n筆開始顯示
        int       TotalRow       = 0;                                //總筆數
        int       DataCnt        = 0;
        ArrayList PageParam      = new ArrayList();                  //分類暫存條件參數

        //----- 宣告:資料參數 -----
        SignDataRepository          _data  = new SignDataRepository();
        Dictionary <string, string> search = new Dictionary <string, string>();

        try
        {
            #region >> 條件篩選 <<

            //[查詢條件] - Keyword
            if (!string.IsNullOrWhiteSpace(Req_Keyword))
            {
                search.Add("Keyword", Req_Keyword);
                PageParam.Add("k=" + Server.UrlEncode(Req_Keyword));
                filter_Keyword.Text = Req_Keyword;
            }

            //[查詢條件] - Place
            if (!string.IsNullOrWhiteSpace(Req_Place))
            {
                search.Add("Place", Req_Place);
                PageParam.Add("place=" + Server.UrlEncode(Req_Place));
                filter_place.SelectedValue = Req_Place;
            }

            //[取得/檢查參數] - Date between
            string _today = DateTime.Today.ToShortDateString();
            string _sDate = Req_sDate.Equals("") ? _today : Req_sDate;
            string _eDate = Req_eDate.Equals("") ? _today : Req_eDate;

            //網址參數
            PageParam.Add("sDate=" + Server.UrlEncode(_sDate));
            filter_sDate.Text = _sDate;
            PageParam.Add("eDate=" + Server.UrlEncode(_eDate));
            filter_eDate.Text = _eDate;

            //參數,日期區間
            search.Add("sDate", Req_sDate); //代入SQL Param
            search.Add("eDate", Req_eDate); //代入SQL Param
            search.Add("dateSection", "Y");


            #endregion

            //----- 原始資料:取得所有資料 -----
            var query = _data.GetList(search, StartRow, RecordsPerPage
                                      , out DataCnt, out ErrMsg);

            //----- 資料整理:取得總筆數 -----
            TotalRow = DataCnt;

            //----- 資料整理:頁數判斷 -----
            if (pageIndex > ((TotalRow / RecordsPerPage) + ((TotalRow % RecordsPerPage) > 0 ? 1 : 0)) && TotalRow > 0)
            {
                StartRow  = 0;
                pageIndex = 1;
            }

            //----- 資料整理:繫結 -----
            lvDataList.DataSource = query;
            lvDataList.DataBind();


            //----- 資料整理:顯示分頁(放在DataBind之後) -----
            if (query.Count() == 0)
            {
                ph_EmptyData.Visible = true;
                ph_Data.Visible      = false;

                //Clear
                CustomExtension.setCookie("SignManage", "", -1);
            }
            else
            {
                ph_EmptyData.Visible = false;
                ph_Data.Visible      = true;

                //分頁設定
                string getPager = CustomExtension.Pagination(TotalRow, RecordsPerPage, pageIndex, 5
                                                             , thisPage, PageParam, false, true);

                Literal lt_Pager = (Literal)this.lvDataList.FindControl("lt_Pager");
                lt_Pager.Text = getPager;

                //重新整理頁面Url
                string reSetPage = "{0}?page={1}{2}".FormatThis(
                    thisPage
                    , pageIndex
                    , (PageParam.Count == 0 ? "" : "&") + string.Join("&", PageParam.ToArray()));

                //暫存頁面Url, 給其他頁使用
                CustomExtension.setCookie("SignManage", Server.UrlEncode(reSetPage), 1);
            }
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            _data = null;
        }
    }
Exemplo n.º 18
0
        public void XliffElement_CollapseChildrenWithScope()
        {
            IExtensible         extensible;
            CustomExtension     extension1;
            CustomExtension     extension2;
            CustomElement1      element1;
            CustomElement2      element2;
            List <XliffElement> elementList;
            List <Source>       sourceList;
            PlainText           text;
            Segment             segment;
            Source         source;
            StandaloneCode code;
            Unit           unit;
            XliffDocument  document;

            code           = new StandaloneCode();
            text           = new PlainText();
            segment        = new Segment();
            segment.Source = new Source();
            segment.Source.Text.Add(text);
            segment.Source.Text.Add(code);

            unit = new Unit();
            unit.Resources.Add(segment);

            document = new XliffDocument();
            document.Files.Add(new File());
            document.Files[0].Containers.Add(unit);

            extensible = document.Files[0];

            extension1 = new CustomExtension("namespace");
            element1   = new CustomElement1("pre1", "namespace");
            extension1.AddChild(new ElementInfo(new XmlNameInfo("localname"), element1));
            extensible.Extensions.Add(extension1);

            extension2 = new CustomExtension("namespace");
            element2   = new CustomElement2("pre1", "namespace");
            extension2.AddChild(new ElementInfo(new XmlNameInfo("localname"), element2));
            source = new Source();
            extension2.AddChild(new ElementInfo(new XmlNameInfo("localname"), source));
            extensible.Extensions.Add(extension2);

            Console.WriteLine("Test with none.");
            elementList = document.CollapseChildren <XliffElement>(CollapseScope.None);
            Assert.AreEqual(0, elementList.Count, "Element count is incorrect.");

            Console.WriteLine("Test with current element.");
            elementList = document.CollapseChildren <XliffElement>(CollapseScope.CurrentElement);
            Assert.AreEqual(1, elementList.Count, "Element count is incorrect.");
            Assert.IsTrue(elementList.Contains(document), "Document not found in list");

            Console.WriteLine("Test with default.");
            elementList = document.CollapseChildren <XliffElement>(CollapseScope.Default);
            Assert.AreEqual(6, elementList.Count, "Element count is incorrect.");
            Assert.IsTrue(elementList.Contains(code), "StandaloneCode not found in list");
            Assert.IsFalse(elementList.Contains(document), "Document not found in list");
            Assert.IsTrue(elementList.Contains(document.Files[0]), "File not found in list");
            Assert.IsTrue(elementList.Contains(segment), "Segment not found in list");
            Assert.IsTrue(elementList.Contains(segment.Source), "Source not found in list");
            Assert.IsTrue(elementList.Contains(text), "PlainText not found in list");
            Assert.IsTrue(elementList.Contains(unit), "Unit not found in list");

            Console.WriteLine("Test with default with current element.");
            elementList = document.CollapseChildren <XliffElement>(CollapseScope.Default | CollapseScope.CurrentElement);
            Assert.AreEqual(7, elementList.Count, "Element count is incorrect.");
            Assert.IsTrue(elementList.Contains(document), "Document not found in list");
            Assert.IsTrue(elementList.Contains(code), "StandaloneCode not found in list");
            Assert.IsTrue(elementList.Contains(document.Files[0]), "File not found in list");
            Assert.IsTrue(elementList.Contains(segment), "Segment not found in list");
            Assert.IsTrue(elementList.Contains(segment.Source), "Source not found in list");
            Assert.IsTrue(elementList.Contains(text), "PlainText not found in list");
            Assert.IsTrue(elementList.Contains(unit), "Unit not found in list");

            elementList = document.CollapseChildren <XliffElement>(CollapseScope.Extensions | CollapseScope.CoreElements | CollapseScope.AllDescendants);
            Assert.AreEqual(9, elementList.Count, "Element count is incorrect.");
            Assert.IsTrue(elementList.Contains(code), "StandaloneCode not found in list");
            Assert.IsTrue(elementList.Contains(document.Files[0]), "File not found in list");
            Assert.IsTrue(elementList.Contains(segment), "Segment not found in list");
            Assert.IsTrue(elementList.Contains(segment.Source), "Source not found in list");
            Assert.IsTrue(elementList.Contains(text), "PlainText not found in list");
            Assert.IsTrue(elementList.Contains(unit), "Unit not found in list");
            Assert.IsTrue(elementList.Contains(source), "Source not found in list");
            Assert.IsTrue(elementList.Contains(element1), "Element1 not found in list");
            Assert.IsTrue(elementList.Contains(element2), "Element2 not found in list");

            sourceList = document.CollapseChildren <Source>(CollapseScope.Extensions | CollapseScope.CoreElements | CollapseScope.AllDescendants);
            Assert.AreEqual(2, sourceList.Count, "Element count is incorrect.");
            Assert.IsTrue(sourceList.Contains(segment.Source), "Source not found in list");
            Assert.IsTrue(sourceList.Contains(source), "Source not found in list");

            elementList = document.CollapseChildren <XliffElement>(CollapseScope.All);
            Assert.AreEqual(10, elementList.Count, "Element count is incorrect.");
            Assert.IsTrue(elementList.Contains(document), "Document not found in list");
            Assert.IsTrue(elementList.Contains(code), "StandaloneCode not found in list");
            Assert.IsTrue(elementList.Contains(document.Files[0]), "File not found in list");
            Assert.IsTrue(elementList.Contains(segment), "Segment not found in list");
            Assert.IsTrue(elementList.Contains(segment.Source), "Source not found in list");
            Assert.IsTrue(elementList.Contains(text), "PlainText not found in list");
            Assert.IsTrue(elementList.Contains(unit), "Unit not found in list");
            Assert.IsTrue(elementList.Contains(source), "Source not found in list");
            Assert.IsTrue(elementList.Contains(element1), "Element1 not found in list");
            Assert.IsTrue(elementList.Contains(element2), "Element2 not found in list");

            sourceList = document.CollapseChildren <Source>(CollapseScope.All);
            Assert.AreEqual(2, sourceList.Count, "Element count is incorrect.");
            Assert.IsTrue(sourceList.Contains(source), "Source not found in list");
            Assert.IsTrue(sourceList.Contains(segment.Source), "Source not found in list");

            Console.WriteLine("Test with extensions with core elements for Source.");
            sourceList = document.CollapseChildren <Source>(CollapseScope.Extensions | CollapseScope.AllDescendants);
            Assert.AreEqual(1, sourceList.Count, "Element count is incorrect.");
            Assert.IsTrue(sourceList.Contains(source), "Source not found in list");

            Console.WriteLine("Test with extensions without core elements.");
            elementList = document.CollapseChildren <XliffElement>(CollapseScope.Extensions | CollapseScope.AllDescendants);
            Assert.AreEqual(3, elementList.Count, "Element count is incorrect.");
            Assert.IsTrue(elementList.Contains(element1), "Element1 not found in list");
            Assert.IsTrue(elementList.Contains(element2), "Element2 not found in list");
            Assert.IsTrue(elementList.Contains(source), "Source not found in list");

            elementList = document.CollapseChildren <XliffElement>(CollapseScope.TopLevelDescendants);
            Assert.AreEqual(0, elementList.Count, "Element count is incorrect.");

            elementList = document.CollapseChildren <XliffElement>(CollapseScope.TopLevelDescendants | CollapseScope.CoreElements);
            Assert.AreEqual(1, elementList.Count, "Element count is incorrect.");
            Assert.IsTrue(elementList.Contains(document.Files[0]), "File not found in list");
        }
        public ExtensionPublicPropertyReflectorTest()
        {
            this.extension = new CustomExtension();

            this.testee = new ReflectExtensionPublicProperties();
        }