Пример #1
0
        /// <summary>
        /// Fixed:
        /// </summary>
        private static HtmlBuilder Results(
            this HtmlBuilder hb,
            Context context,
            string text,
            int offset,
            EnumerableRowCollection <DataRow> dataRows)
        {
            if (dataRows?.Any() == true)
            {
                var dataSet = ResultContents(context: context, dataRows: dataRows);
                dataRows.ForEach(result =>
                {
                    var referenceType = result.String("ReferenceType");
                    var referenceId   = result.Long("ReferenceId");
                    var dataRow       = dataSet.Tables[referenceType]
                                        .AsEnumerable()
                                        .FirstOrDefault(o => o["Id"].ToLong() == referenceId);
                    if (dataRow != null)
                    {
                        var href = string.Empty;
                        switch (referenceType)
                        {
                        case "Sites":
                            href = Locations.ItemIndex(
                                context: context,
                                id: referenceId);
                            break;

                        default:
                            href = Locations.ItemEdit(
                                context: context,
                                id: referenceId);
                            break;
                        }
                        href += "?back=1";
                        hb.Section(
                            attributes: new HtmlAttributes()
                            .Class("result")
                            .Add("data-href", href),
                            action: () => hb
                            .Breadcrumb(
                                context: context,
                                ss: new SiteSettings()
                        {
                            SiteId = dataRow.Long("SiteId")
                        })
                            .H(number: 3, action: () => hb
                               .A(
                                   href: href,
                                   text: dataRow.String("Title")))
                            .P(action: () => hb
                               .Text(text: dataRow.String("Body"))));
                    }
                });
            }
            return(hb);
        }
Пример #2
0
 private DemoCollection Set(
     Context context,
     EnumerableRowCollection <DataRow> dataRows)
 {
     if (dataRows.Any())
     {
         foreach (DataRow dataRow in dataRows)
         {
             Add(new DemoModel(
                     context: context,
                     dataRow: dataRow));
         }
         AccessStatus = Databases.AccessStatuses.Selected;
     }
     else
     {
         AccessStatus = Databases.AccessStatuses.NotFound;
     }
     return(this);
 }
Пример #3
0
 private RegistrationCollection Set(
     Context context,
     SiteSettings ss,
     EnumerableRowCollection <DataRow> dataRows)
 {
     if (dataRows.Any())
     {
         foreach (DataRow dataRow in dataRows)
         {
             Add(new RegistrationModel(
                     context: context,
                     ss: ss,
                     dataRow: dataRow));
         }
         AccessStatus = Databases.AccessStatuses.Selected;
     }
     else
     {
         AccessStatus = Databases.AccessStatuses.NotFound;
     }
     return(this);
 }
Пример #4
0
 private SiteCollection Set(
     Context context,
     EnumerableRowCollection <DataRow> dataRows,
     List <FormData> formDataSet = null)
 {
     if (dataRows.Any())
     {
         foreach (DataRow dataRow in dataRows)
         {
             Add(new SiteModel(
                     context: context,
                     dataRow: dataRow,
                     formData: formDataSet?.FirstOrDefault(o =>
                                                           o.Id == dataRow.Long("SiteId"))?.Data));
         }
         AccessStatus = Databases.AccessStatuses.Selected;
     }
     else
     {
         AccessStatus = Databases.AccessStatuses.NotFound;
     }
     return(this);
 }
Пример #5
0
        private bool checkLogin(string username, string password)
        {
            if (mailBox.Tables["users"].Rows.Count == 0)
            {
                string[] passwordFile = readS3File(bucketName, string.Format("{0}/{1}/{2}", bucketPrefix, sessionDomain, "passwd.txt")).Split("\r\n");
                foreach (var line in passwordFile)
                {
                    string[] parts = line.Trim().Split(":");
                    mailBox.Tables["users"].Rows.Add(parts[0], parts[1], 0);
                }
            }

            EnumerableRowCollection <DataRow> results = from row in mailBox.Tables["users"].AsEnumerable() where row.Field <string>("username") == username select row;

            if (!results.Any())
            {
                return(false);
            }

            DataRow dataRow = results.First <DataRow>();

            string storedPassword = dataRow.Field <string>("password");

            SHA512 shaM = new SHA512Managed();

            byte[] saltedPlainText = Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password));
            byte[] hashedBytes     = shaM.ComputeHash(saltedPlainText);
            string hash            = BitConverter.ToString(hashedBytes).Replace("-", "");

            if (storedPassword.ToLower() == hash.ToLower())
            {
                return(true);
            }

            return(false);
        }
Пример #6
0
        /// <summary>
        /// Applies the filter on the column corresponding to the pattern in the given datarow
        /// </summary>
        internal override Boolean ApplyFilter(DataRow row, Boolean applyNegation)
        {
            Boolean keepRow = false;
            EnumerableRowCollection <DataRow> patternResultsEnumerable = this.PatternResults?.AsEnumerable();

            if (patternResultsEnumerable?.Any() ?? false)
            {
                #region Disjoint Evaluation
                //In case of disjointess between the query and the filter's pattern, all solutions are compatible
                Boolean disjointSubject = this.Pattern.Subject is RDFVariable ?
                                          !row.Table.Columns.Contains(this.Pattern.Subject.ToString()) : true;
                Boolean disjointPredicate = this.Pattern.Predicate is RDFVariable ?
                                            !row.Table.Columns.Contains(this.Pattern.Predicate.ToString()) : true;
                Boolean disjointObject = this.Pattern.Object is RDFVariable ?
                                         !row.Table.Columns.Contains(this.Pattern.Object.ToString()) : true;
                if (disjointSubject && disjointPredicate && disjointObject)
                {
                    keepRow = true;
                }
                #endregion

                #region Non-Disjoint Evaluation
                else
                {
                    #region Subject
                    Boolean subjectCompared = false;
                    if (this.Pattern.Subject is RDFVariable &&
                        this.PatternResults.Columns.Contains(this.Pattern.Subject.ToString()) &&
                        row.Table.Columns.Contains(this.Pattern.Subject.ToString()))
                    {
                        //In case of emptiness the solution is compatible, otherwise proceed with comparison
                        if (!row.IsNull(this.Pattern.Subject.ToString()))
                        {
                            //Get subject filter's value for the given row
                            RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Subject.ToString()].ToString());

                            //Apply subject filter on the pattern resultset
                            patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field <String>(this.Pattern.Subject.ToString())).Equals(rowMember));
                        }
                        subjectCompared = true;
                    }
                    #endregion

                    #region Predicate
                    Boolean predicateCompared = false;
                    if (this.Pattern.Predicate is RDFVariable &&
                        this.PatternResults.Columns.Contains(this.Pattern.Predicate.ToString()) &&
                        row.Table.Columns.Contains(this.Pattern.Predicate.ToString()))
                    {
                        //In case of emptiness the solution is compatible, otherwise proceed with comparison
                        if (!row.IsNull(this.Pattern.Predicate.ToString()))
                        {
                            //Get predicate filter's value for the given row
                            RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Predicate.ToString()].ToString());

                            //Apply predicate filter on the pattern resultset
                            patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field <String>(this.Pattern.Predicate.ToString())).Equals(rowMember));
                        }
                        predicateCompared = true;
                    }
                    #endregion

                    #region Object
                    Boolean objectCompared = false;
                    if (this.Pattern.Object is RDFVariable &&
                        this.PatternResults.Columns.Contains(this.Pattern.Object.ToString()) &&
                        row.Table.Columns.Contains(this.Pattern.Object.ToString()))
                    {
                        //In case of emptiness the solution is compatible, otherwise proceed with comparison
                        if (!row.IsNull(this.Pattern.Object.ToString()))
                        {
                            //Get object filter's value for the given row
                            RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Object.ToString()].ToString());

                            //Apply object filter on the pattern resultset
                            patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field <String>(this.Pattern.Object.ToString())).Equals(rowMember));
                        }
                        objectCompared = true;
                    }
                    #endregion

                    #region Decision
                    //Verify filter's response on the pattern resultset
                    if ((subjectCompared || predicateCompared || objectCompared) && patternResultsEnumerable.ToList().Any())
                    {
                        keepRow = true;
                    }
                    #endregion
                }
                #endregion
            }

            //Apply the eventual negation
            if (applyNegation)
            {
                keepRow = !keepRow;
            }

            return(keepRow);
        }
        private static DataSet ResultContents(EnumerableRowCollection <DataRow> dataRows)
        {
            var statements = new List <SqlStatement>();

            if (dataRows.Any(o => o["ReferenceType"].ToString() == "Sites"))
            {
                statements.Add(Rds.SelectSites(
                                   dataTableName: "Sites",
                                   column: Rds.SitesColumn()
                                   .ParentId(_as: "SiteId")
                                   .SiteId(_as: "Id")
                                   .Title()
                                   .Body(),
                                   where : Rds.SitesWhere()
                                   .TenantId(Sessions.TenantId())
                                   .SiteId_In(dataRows
                                              .Where(o => o["ReferenceType"].ToString() == "Sites")
                                              .Select(o => o["ReferenceId"].ToLong()))));
            }
            if (dataRows.Any(o => o["ReferenceType"].ToString() == "Issues"))
            {
                statements.Add(Rds.SelectIssues(
                                   dataTableName: "Issues",
                                   column: Rds.IssuesColumn()
                                   .SiteId()
                                   .IssueId(_as: "Id")
                                   .Title()
                                   .Body(),
                                   where : Rds.IssuesWhere()
                                   .IssueId_In(dataRows
                                               .Where(o => o["ReferenceType"].ToString() == "Issues")
                                               .Select(o => o["ReferenceId"].ToLong()))));
            }
            if (dataRows.Any(o => o["ReferenceType"].ToString() == "Results"))
            {
                statements.Add(Rds.SelectResults(
                                   dataTableName: "Results",
                                   column: Rds.ResultsColumn()
                                   .SiteId()
                                   .ResultId(_as: "Id")
                                   .Title()
                                   .Body(),
                                   where : Rds.ResultsWhere()
                                   .ResultId_In(dataRows
                                                .Where(o => o["ReferenceType"].ToString() == "Results")
                                                .Select(o => o["ReferenceId"].ToLong()))));
            }
            if (dataRows.Any(o => o["ReferenceType"].ToString() == "Wikis"))
            {
                statements.Add(Rds.SelectWikis(
                                   dataTableName: "Wikis",
                                   column: Rds.WikisColumn()
                                   .SiteId()
                                   .WikiId(_as: "Id")
                                   .Title()
                                   .Body(),
                                   where : Rds.WikisWhere()
                                   .WikiId_In(dataRows
                                              .Where(o => o["ReferenceType"].ToString() == "Wikis")
                                              .Select(o => o["ReferenceId"].ToLong()))));
            }
            return(Rds.ExecuteDataSet(statements: statements.ToArray()));
        }
        private void frm_thongke_danhsachbenhnhanh_sieuam_Load(object sender, EventArgs e)
        {
            try
            {
                DataBinding.BindDataCombobox(cboDoituongKCB, THU_VIEN_CHUNG.LaydanhsachDoituongKcb(),
                                             DmucDoituongkcb.Columns.IdDoituongKcb,
                                             DmucDoituongkcb.Columns.TenDoituongKcb,
                                             "Chọn đối tượng KCB", true);
                DataTable m_dtKhoathucHien = THU_VIEN_CHUNG.Laydanhmuckhoa("NGOAI", 0);
                DataBinding.BindDataCombobox(cboKhoa, m_dtKhoathucHien,
                                             DmucKhoaphong.Columns.MaKhoaphong, DmucKhoaphong.Columns.TenKhoaphong,
                                             "Chọn khoa KCB", true);

                EnumerableRowCollection <DataRow> query = from khoa in m_dtKhoathucHien.AsEnumerable()
                                                          where
                                                          Utility.sDbnull(khoa[DmucKhoaphong.Columns.MaKhoaphong]) ==
                                                          globalVariables.MA_KHOA_THIEN
                                                          select khoa;
                if (query.Any())
                {
                    cboKhoa.SelectedValue = globalVariables.MA_KHOA_THIEN;
                }
                dtFromDate.Value = dtToDate.Value = dtNgayInPhieu.Value = DateTime.Now;
                string reportcode = "";
                baocaO_TIEUDE1.TIEUDE = "";
                switch (Args.Substring(0, 2))
                {
                case "SA":
                    reportcode = "baocao_thongkedanhsach_sieuam";
                    break;

                case "XQ":
                    reportcode = "baocao_thongkedanhsach_xquang";
                    break;

                case "DT":
                    reportcode = "baocao_thongkedanhsach_dientim";
                    break;

                case "NS":
                    reportcode = "baocao_thongkedanhsach_noisoi";
                    break;

                case "PTTT":
                    reportcode = "baocao_thongkedanhsach_pttt";
                    break;

                default:
                    reportcode = "baocao_thongkedanhsach_noisoi";
                    break;
                }
                Utility.GetReport(reportcode, ref tieude, ref reportname);
                baocaO_TIEUDE1.TIEUDE = tieude;
                LoaddanhmucCLS();
                // txtdichvu.dtData =
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Пример #9
0
        private void bindConfigurations()
        {
            try
            {
                using (DataTable dt = new BL_Configurations().select())
                {
                    #region Membership No
                    EnumerableRowCollection <DataRow> MembershipNoIndex = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.MembershipNoIndexStr select myRow;
                    if (MembershipNoIndex.Any())
                    {
                        rtb_mem_no_desc.Text      = MembershipNoIndex.First()["Description"].ToString();
                        txt_mem_no_value.Text     = MembershipNoIndex.First()["ConfigurationValue"].ToString();
                        txt_mem_no_conf_by.Text   = MembershipNoIndex.First()["Name"].ToString();
                        txt_mem_no_conf_date.Text = Convert.ToDateTime(MembershipNoIndex.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }
                    #endregion

                    #region Membership Date

                    EnumerableRowCollection <DataRow> MembershipDate = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.MembershipDateStr select myRow;
                    if (MembershipDate.Any())
                    {
                        txt_mem_date_desc.Text       = MembershipDate.First()["Description"].ToString();
                        txt_mem_date_value.EditValue = Convert.ToDateTime(MembershipDate.First()["ConfigurationValue"].ToString()).ToShortDateString();
                        txt_mem_date_conf_by.Text    = MembershipDate.First()["Name"].ToString();
                        txt_mem_date_conf_date.Text  = Convert.ToDateTime(MembershipDate.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }
                    #endregion

                    #region Internet Connection

                    EnumerableRowCollection <DataRow> InternetConnection = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.InternetConnectionStr select myRow;
                    if (InternetConnection.Any())
                    {
                        txt_int_con_desc.Text      = InternetConnection.First()["Description"].ToString();
                        tsw_int_con.IsOn           = Convert.ToBoolean(InternetConnection.First()["ConfigurationValue"].ToString());
                        txt_int_con_conf_by.Text   = InternetConnection.First()["Name"].ToString();
                        txt_int_con_conf_date.Text = Convert.ToDateTime(InternetConnection.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }
                    #endregion

                    #region Receipt No

                    EnumerableRowCollection <DataRow> ReceiptNo = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.ReceiptNoStr select myRow;
                    if (ReceiptNo.Any())
                    {
                        txt_rec_no_desc.Text      = ReceiptNo.First()["Description"].ToString();
                        txt_rec_no_value.Text     = ReceiptNo.First()["ConfigurationValue"].ToString();
                        txt_rec_no_conf_by.Text   = ReceiptNo.First()["Name"].ToString();
                        txt_rec_no_conf_date.Text = Convert.ToDateTime(ReceiptNo.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }
                    #endregion

                    #region Receipt Amount
                    EnumerableRowCollection <DataRow> ReceiptAmount = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.ReceiptAmountStr select myRow;
                    if (ReceiptAmount.Any())
                    {
                        txt_rec_amount_desc.Text = ReceiptAmount.First()["Description"].ToString();
                        lst_receipt_amount.Items.Clear();
                        lst_receipt_amount.Items.AddRange(ReceiptAmount.First()["ConfigurationValue"].ToString().Split(new char[] { ';' }));
                        txt_rec_amount_conf_by.Text   = ReceiptAmount.First()["Name"].ToString();
                        txt_rec_amount_conf_date.Text = Convert.ToDateTime(ReceiptAmount.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }
                    #endregion

                    #region System Timeout

                    EnumerableRowCollection <DataRow> TimeoutPeriod = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.TimeoutPeriodStr select myRow;
                    if (TimeoutPeriod.Any())
                    {
                        txt_timeout_desc.Text = TimeoutPeriod.First()["Description"].ToString();
                        string[] time = TimeoutPeriod.First()["ConfigurationValue"].ToString().Split(new char[] { ':' });
                        nud_timeout_hrs.Text       = time[0];
                        nud_timeout_minutes.Text   = time[1];
                        nud_timeout_seconds.Text   = time[2];
                        txt_timeout_conf_by.Text   = TimeoutPeriod.First()["Name"].ToString();
                        txt_timeout_conf_date.Text = Convert.ToDateTime(TimeoutPeriod.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }
                    #endregion

                    #region Logout Confirmation Timeout

                    EnumerableRowCollection <DataRow> LogoffPeriod = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.LogoffPeriodStr select myRow;
                    if (LogoffPeriod.Any())
                    {
                        mem_logout_desc.Text = LogoffPeriod.First()["Description"].ToString();
                        string[] time = LogoffPeriod.First()["ConfigurationValue"].ToString().Split(new char[] { ':' });
                        nud_msg_box_minutes.Text  = time[1];
                        nud_msg_box_seconds.Text  = time[2];
                        txt_logout_conf_by.Text   = LogoffPeriod.First()["Name"].ToString();
                        txt_logout_conf_date.Text = Convert.ToDateTime(LogoffPeriod.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }
                    #endregion

                    #region Default Values

                    EnumerableRowCollection <DataRow> DefaultSalutation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.DefaultSalutationStr select myRow;
                    if (DefaultSalutation.Any())
                    {
                        mem_def_val_desc.Text      = DefaultSalutation.First()["Description"].ToString();
                        cbo_salutation.EditValue   = DefaultSalutation.First()["ConfigurationValue"].ToString();
                        txt_def_val_conf_by.Text   = DefaultSalutation.First()["Name"].ToString();
                        txt_def_val_conf_date.Text = Convert.ToDateTime(DefaultSalutation.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }

                    EnumerableRowCollection <DataRow> DefaultCountry = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.DefaultCountryStr select myRow;
                    if (DefaultCountry.Any())
                    {
                        cbo_country.EditValue = DefaultCountry.First()["ConfigurationValue"].ToString();
                        cbo_country_EditValueChanged(this, new EventArgs());
                    }

                    EnumerableRowCollection <DataRow> DefaultCity = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.DefaultCityStr select myRow;
                    if (DefaultCity.Any())
                    {
                        cbo_city.EditValue = DefaultCity.First()["ConfigurationValue"].ToString();
                    }

                    #endregion

                    #region Control Validations

                    EnumerableRowCollection <DataRow> TelephoneValidation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.TelephoneValidationStr select myRow;
                    if (TelephoneValidation.Any())
                    {
                        mem_validations_desc.Text      = TelephoneValidation.First()["Description"].ToString();
                        chk_validations_tel.EditValue  = TelephoneValidation.First()["ConfigurationValue"].ToString().ToBool();
                        txt_validations_conf_by.Text   = TelephoneValidation.First()["Name"].ToString();
                        txt_validations_conf_date.Text = Convert.ToDateTime(TelephoneValidation.First()["UpdatedDate"].ToString()).ToShortDateString();
                    }

                    EnumerableRowCollection <DataRow> MobileValidation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.MobileValidationStr select myRow;
                    if (MobileValidation.Any())
                    {
                        chk_validations_mobile.EditValue = MobileValidation.First()["ConfigurationValue"].ToString().ToBool();
                    }

                    EnumerableRowCollection <DataRow> EmailValidation = from myRow in dt.AsEnumerable() where myRow.Field <string>("ConfigurationName") == Configurations.EmailValidationStr select myRow;
                    if (EmailValidation.Any())
                    {
                        chk_validations_email.EditValue = EmailValidation.First()["ConfigurationValue"].ToString().ToBool();
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                AuditFactory.AuditLog(ex);
                ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message);
            }
        }
Пример #10
0
        private void AdTPhieuCapphatNoitru()
        {
            try
            {
                if (p_phieuCapPhatThuoc != null)
                {
                    EnumerableRowCollection <DataRow> query = from phieu in p_phieuCapPhatThuoc.AsEnumerable()
                                                              where
                                                              Utility.Int32Dbnull(phieu[TPhieuCapphatNoitru.Columns.IdCapphat]) ==
                                                              Utility.Int32Dbnull(txtID_CAPPHAT.Text)
                                                              select phieu;
                    if (!query.Any())
                    {
                        DataRow             drv             = p_phieuCapPhatThuoc.NewRow();
                        TPhieuCapphatNoitru objPhieuCapphat = TPhieuCapphatNoitru.FetchByID(Utility.Int32Dbnull(txtID_CAPPHAT.Text));
                        Utility.FromObjectToDatarow(objPhieuCapphat, ref drv);
                        if (p_phieuCapPhatThuoc.Columns.Contains("ten_KHOA_LINH"))
                        {
                            drv["ten_KHOA_LINH"] = Utility.sDbnull(txtTen_KHOA_LINH.Text);
                        }
                        if (p_phieuCapPhatThuoc.Columns.Contains("ten_kho_xuat"))
                        {
                            drv["ten_kho_xuat"] = Utility.sDbnull(txtTenKho.Text);
                        }
                        if (p_phieuCapPhatThuoc.Columns.Contains("ten_nvien"))
                        {
                            drv["ten_nvien"] = Utility.sDbnull(globalVariables.gv_sStaffName);
                        }
                        p_phieuCapPhatThuoc.Rows.Add(drv);
                    }
                    else
                    {
                        DataRow drv = query.FirstOrDefault();
                        if (drv != null)
                        {
                            drv["ID_CAPPHAT"] = Utility.Int32Dbnull(txtID_CAPPHAT.Text);

                            drv["ID_KHO_XUAT"] = Utility.Int32Dbnull(txtId_KhoXuat.Text);
                            if (p_phieuCapPhatThuoc.Columns.Contains("ten_kho_xuat"))
                            {
                                drv["ten_kho_xuat"] = Utility.sDbnull(txtTenKho.Text);
                            }
                            drv["ID_KHOA_LINH"] = Utility.Int32Dbnull(txtID_KHOA_LINH.Text);
                            if (p_phieuCapPhatThuoc.Columns.Contains("ten_KHOA_LINH"))
                            {
                                drv["ten_KHOA_LINH"] = Utility.sDbnull(txtTen_KHOA_LINH.Text);
                            }
                            drv["ID_NVIEN"] = Utility.Int32Dbnull(txtID_NVIEN.Text);
                            if (p_phieuCapPhatThuoc.Columns.Contains("ten_nvien"))
                            {
                                drv["ten_nvien"] = Utility.sDbnull(txtTen_NVIEN.Text);
                            }
                            drv["NGAY_NHAP"]  = dtNgayCapPhat.Text;
                            drv["MOTA_THEM"]  = Utility.sDbnull(txtMOTA_THEM.Text);
                            drv["Loai_Phieu"] = radThuoc.Checked ? "THUOC" : "VT";
                            drv["Da_CapPhat"] = chkDa_CapPhat.Checked;
                        }
                        drv.AcceptChanges();
                        p_phieuCapPhatThuoc.AcceptChanges();
                    }
                }
            }
            catch (Exception exception)
            {
                if (globalVariables.IsAdmin)
                {
                    Utility.ShowMsg(exception.ToString());
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Applies the filter on the column corresponding to the pattern in the given datarow
        /// </summary>
        internal override Boolean ApplyFilter(DataRow row, Boolean applyNegation)
        {
            Boolean keepRow = false;
            EnumerableRowCollection <DataRow> patternResultsEnumerable = this.PatternResults?.AsEnumerable();

            if (patternResultsEnumerable?.Any() ?? false)
            {
                #region Evaluation

                #region Subject
                Boolean subjectCompared = false;
                if (this.Pattern.Subject is RDFVariable &&
                    this.PatternResults.Columns.Contains(this.Pattern.Subject.ToString()) &&
                    row.Table.Columns.Contains(this.Pattern.Subject.ToString()))
                {
                    //Get subject filter's value for the given row
                    RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Subject.ToString()].ToString());

                    //Apply subject filter on the pattern resultset
                    patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field <String>(this.Pattern.Subject.ToString())).Equals(rowMember));
                    subjectCompared          = true;
                }
                #endregion

                #region Predicate
                Boolean predicateCompared = false;
                if (this.Pattern.Predicate is RDFVariable &&
                    this.PatternResults.Columns.Contains(this.Pattern.Predicate.ToString()) &&
                    row.Table.Columns.Contains(this.Pattern.Predicate.ToString()))
                {
                    //Get predicate filter's value for the given row
                    RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Predicate.ToString()].ToString());

                    //Apply predicate filter on the pattern resultset
                    patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field <String>(this.Pattern.Predicate.ToString())).Equals(rowMember));
                    predicateCompared        = true;
                }
                #endregion

                #region Object
                Boolean objectCompared = false;
                if (this.Pattern.Object is RDFVariable &&
                    this.PatternResults.Columns.Contains(this.Pattern.Object.ToString()) &&
                    row.Table.Columns.Contains(this.Pattern.Object.ToString()))
                {
                    //Get object filter's value for the given row
                    RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Object.ToString()].ToString());

                    //Apply object filter on the pattern resultset
                    patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field <String>(this.Pattern.Object.ToString())).Equals(rowMember));
                    objectCompared           = true;
                }
                #endregion

                #endregion

                #region Decision
                //Verify filter's response on the pattern resultset
                if ((subjectCompared || predicateCompared || objectCompared) && patternResultsEnumerable.ToList().Any())
                {
                    keepRow = true;
                }
                #endregion
            }

            //Apply the eventual negation
            if (applyNegation)
            {
                keepRow = !keepRow;
            }

            return(keepRow);
        }
Пример #12
0
        /// <summary>
        /// Finalize burst analysis for the supplied host Id
        /// </summary>
        /// <param name="theHostId">The host Id for which burst analysis is to be finalized</param>
        private void FinaliseForHostId(byte theHostId)
        {
            //// Obtain the set of message Ids encountered for this host Id during the burst analysis in ascending order

            EnumerableRowCollection <System.Data.DataRow>
            theMessageIdRowsFound =
                from r in this.theMessageIdsTable.AsEnumerable()
                where r.Field <byte>("HostId") == theHostId
                orderby r.Field <ulong>("MessageId") ascending
                select r;

            // Finalize the burst analysis separately for reliable and non-reliable messages
            foreach (bool isReliable in new bool[] { true, false })
            {
                bool theFirstReliableRowProcessed = false;

                //// Loop across all the timestamp values using each of the message Ids in turn

                foreach (System.Data.DataRow theMessageIdRow in theMessageIdRowsFound)
                {
                    ulong theMessageId = theMessageIdRow.Field <ulong>("MessageId");

                    // Finalize the burst analysis separately for outgoing and incoming messages
                    foreach (bool isOutgoing in new bool[] { true, false })
                    {
                        EnumerableRowCollection <System.Data.DataRow>
                        theTimestampValueRowsFound =
                            from s in this.theTimestampValuesTable.AsEnumerable()
                            where s.Field <byte>("HostId") == theHostId &&
                            s.Field <ulong>("MessageId") == theMessageId &&
                            s.Field <bool>("IsReliable") == isReliable &&
                            s.Field <bool>("IsOutgoing") == isOutgoing
                            select s;

                        if (theTimestampValueRowsFound.Any())
                        {
                            if (!theFirstReliableRowProcessed)
                            {
                                theFirstReliableRowProcessed = true;

                                if (isReliable)
                                {
                                    this.theDebugInformation.WriteTextLine("Reliable Messages");
                                    this.theDebugInformation.WriteTextLine("-----------------");
                                }
                                else
                                {
                                    this.theDebugInformation.WriteTextLine("Non-Reliable Messages");
                                    this.theDebugInformation.WriteTextLine("---------------------");
                                }

                                this.theDebugInformation.WriteBlankLine();
                            }

                            this.FinaliseForMessageId(
                                theHostId,
                                isOutgoing,
                                theMessageId,
                                theTimestampValueRowsFound);
                        }
                    }
                }
            }
        }
Пример #13
0
        private static HtmlBuilder LinkTable(
            this HtmlBuilder hb,
            Context context,
            SiteSettings ss,
            View view,
            EnumerableRowCollection <DataRow> dataRows,
            string direction,
            string dataTableName,
            int tabIndex = 0)
        {
            if (dataRows != null)
            {
                ss.SetChoiceHash(
                    context: context,
                    dataRows: dataRows);
            }
            return(hb.Table(
                       id: dataTableName,
                       css: "grid" + (ss.GetNoDisplayIfReadOnly()
                    ? " not-link"
                    : string.Empty),
                       attributes: new HtmlAttributes()
                       .DataId(ss.SiteId.ToString())
                       .DataName(direction)
                       .DataValue("back")
                       .DataAction("LinkTable")
                       .DataMethod("post")
                       .Add(
                           name: "from-tab-index",
                           value: tabIndex.ToString()),
                       action: () =>
            {
                var siteMenu = SiteInfo.TenantCaches.Get(context.TenantId)?.SiteMenu;
                if (dataRows != null && dataRows.Any())
                {
                    var columns = ss.GetLinkTableColumns(
                        context: context,
                        view: view,
                        checkPermission: true);
                    switch (ss.ReferenceType)
                    {
                    case "Issues":
                        var issueCollection = new IssueCollection(
                            context: context,
                            ss: ss,
                            dataRows: dataRows);
                        issueCollection.SetLinks(context: context, ss: ss);
                        hb
                        .Caption(
                            action: () => hb
                            .Span(
                                css: "caption-direction",
                                action: () => hb
                                .Text(text: "{0} : ".Params(Caption(
                                                                context: context,
                                                                direction: direction))))
                            .Span(
                                css: "caption-title",
                                action: () => hb
                                .Text(text: "{0}".Params(siteMenu.Breadcrumb(
                                                             context: context,
                                                             siteId: ss.SiteId)
                                                         .Select(o => o.Title)
                                                         .Join(" > "))))
                            .Span(
                                css: "caption-quantity",
                                action: () => hb
                                .Text(text: " - {0} ".Params(
                                          Displays.Quantity(context: context))))
                            .Span(
                                css: "caption-count",
                                action: () => hb
                                .Text(text: "{0}".Params(dataRows.Count()))))
                        .THead(action: () => hb
                               .GridHeader(
                                   context: context,
                                   ss: ss,
                                   columns: columns,
                                   view: view,
                                   sort: true,
                                   checkRow: false,
                                   action: "LinkTable"))
                        .TBody(action: () => issueCollection
                               .ForEach(issueModel =>
                                        hb.Tr(
                                            attributes: new HtmlAttributes()
                                            .Class("grid-row")
                                            .DataId(issueModel.IssueId.ToString()),
                                            action: () => columns
                                            .ForEach(column => hb
                                                     .TdValue(
                                                         context: context,
                                                         ss: ss,
                                                         column: column,
                                                         issueModel: issueModel,
                                                         tabIndex: tabIndex)))));
                        break;

                    case "Results":
                        var resultCollection = new ResultCollection(
                            context: context,
                            ss: ss,
                            dataRows: dataRows);
                        resultCollection.SetLinks(context: context, ss: ss);
                        hb
                        .Caption(
                            action: () => hb
                            .Span(
                                css: "caption-direction",
                                action: () => hb
                                .Text(text: "{0} : ".Params(Caption(
                                                                context: context,
                                                                direction: direction))))
                            .Span(
                                css: "caption-title",
                                action: () => hb
                                .Text(text: "{0}".Params(siteMenu.Breadcrumb(
                                                             context: context,
                                                             siteId: ss.SiteId)
                                                         .Select(o => o.Title)
                                                         .Join(" > "))))
                            .Span(
                                css: "caption-quantity",
                                action: () => hb
                                .Text(text: " - {0} ".Params(
                                          Displays.Quantity(context: context))))
                            .Span(
                                css: "caption-count",
                                action: () => hb
                                .Text(text: "{0}".Params(dataRows.Count()))))
                        .THead(action: () => hb
                               .GridHeader(
                                   context: context,
                                   ss: ss,
                                   columns: columns,
                                   view: view,
                                   sort: true,
                                   checkRow: false,
                                   action: "LinkTable"))
                        .TBody(action: () => resultCollection
                               .ForEach(resultModel =>
                                        hb.Tr(
                                            attributes: new HtmlAttributes()
                                            .Class("grid-row")
                                            .DataId(resultModel.ResultId.ToString()),
                                            action: () => columns
                                            .ForEach(column => hb
                                                     .TdValue(
                                                         context: context,
                                                         ss: ss,
                                                         column: column,
                                                         resultModel: resultModel,
                                                         tabIndex: tabIndex)))));
                        break;
                    }
                }
            }));
        }
Пример #14
0
        // Public Methods (1) 

        public override bool Perform()
        {
            LogMessage("Loading Resource Pool List");

            SPList oResourcePool    = SPWeb.Lists.TryGetList("Resources");
            SPList oRoles           = SPWeb.Lists.TryGetList("Roles");
            SPList oDepartments     = SPWeb.Lists.TryGetList("Departments");
            SPList oHolidaySchedule = SPWeb.Lists.TryGetList("Holiday Schedules");
            SPList oWorkHours       = SPWeb.Lists.TryGetList("Work Hours");

            if (oResourcePool == null)
            {
                LogMessage("", "Resources list missing", 3);
            }
            else if (oRoles == null)
            {
                LogMessage("", "Roles list missing", 3);
            }
            else if (oDepartments == null)
            {
                LogMessage("", "Departments list missing", 3);
            }
            else if (oHolidaySchedule == null)
            {
                LogMessage("", "HolidaySchedules list missing", 3);
            }
            else if (oWorkHours == null)
            {
                LogMessage("", "WorkHours list missing", 3);
            }
            else
            {
                try
                {
                    DataTable dtRoles       = oRoles.Items.GetDataTable();
                    DataTable dtDepartments = oDepartments.Items.GetDataTable();

                    #region Add Temp fields

                    try
                    {
                        if (!oResourcePool.Fields.ContainsFieldWithInternalName("TempRole"))
                        {
                            LogMessage("\tAdding TempRole field");

                            oResourcePool.Fields.Add("TempRole", SPFieldType.Text, false);

                            SPField oField = oResourcePool.Fields.GetFieldByInternalName("TempRole");
                            oField.ShowInDisplayForm = false;
                            oField.ShowInEditForm    = false;
                            oField.ShowInNewForm     = false;
                            oField.Update();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogMessage("\t", "Adding TempRole field: " + ex.Message, 3);
                    }

                    try
                    {
                        if (!oResourcePool.Fields.ContainsFieldWithInternalName("TempDept"))
                        {
                            LogMessage("\tAdding TempDept field");

                            oResourcePool.Fields.Add("TempDept", SPFieldType.Text, false);

                            SPField oField = oResourcePool.Fields.GetFieldByInternalName("TempDept");
                            oField.ShowInDisplayForm = false;
                            oField.ShowInEditForm    = false;
                            oField.ShowInNewForm     = false;
                            oField.Update();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogMessage("\t", "Adding TempDept field: " + ex.Message, 3);
                    }

                    oResourcePool.Update();

                    #endregion

                    #region Process Role and Departments

                    bool bProcessRole = false;
                    bool bProcessDept = false;

                    try
                    {
                        if (oResourcePool.Fields.GetFieldByInternalName("Role").Type == SPFieldType.Choice)
                        {
                            bProcessRole = true;
                        }
                    }
                    catch
                    {
                    }
                    try
                    {
                        if (oResourcePool.Fields.GetFieldByInternalName("Department").Type == SPFieldType.Choice)
                        {
                            bProcessDept = true;
                        }
                    }
                    catch
                    {
                    }

                    SPField oFieldRole;
                    SPField oFieldDept;

                    try
                    {
                        oFieldRole = oResourcePool.Fields.GetFieldByInternalName("Role");
                    }
                    catch
                    {
                        SPField newField = oResourcePool.Fields.CreateNewField(SPFieldType.Choice.ToString(), "Role");
                        oResourcePool.Fields.Add(newField);
                        oResourcePool.Update();

                        oFieldRole = oResourcePool.Fields.GetFieldByInternalName("Role");
                    }

                    try
                    {
                        oFieldDept = oResourcePool.Fields.GetFieldByInternalName("Department");
                    }
                    catch
                    {
                        SPField newField = oResourcePool.Fields.CreateNewField(SPFieldType.Choice.ToString(),
                                                                               "Department");
                        oResourcePool.Fields.Add(newField);
                        oResourcePool.Update();

                        oFieldDept = oResourcePool.Fields.GetFieldByInternalName("Department");
                    }

                    if (bProcessRole || bProcessDept)
                    {
                        LogMessage("\tCopying Temporary Data");

                        foreach (SPListItem li in oResourcePool.Items)
                        {
                            try
                            {
                                if (bProcessDept && li[oFieldDept.Id] != null && oFieldDept.Type == SPFieldType.Choice)
                                {
                                    li["TempDept"] = li[oFieldDept.Id].ToString();
                                }

                                if (bProcessDept && li[oFieldRole.Id] != null && oFieldRole.Type == SPFieldType.Choice)
                                {
                                    li["TempRole"] = li[oFieldRole.Id].ToString();
                                }

                                li.Update();
                            }
                            catch (Exception ex)
                            {
                                LogMessage("\t", "Error (" + li.Title + "): " + ex.Message, 3);
                            }
                        }
                    }

                    Thread.Sleep(5000);

                    #endregion

                    ProcessFields(ref oResourcePool);

                    oFieldRole = oResourcePool.Fields.GetFieldByInternalName("Role");
                    oFieldDept = oResourcePool.Fields.GetFieldByInternalName("Department");

                    LogMessage("\tUpdating Role, Department, Holiday Schedule and Work Hours");

                    EnumerableRowCollection <DataRow> resourceHSWS     = null;
                    EnumerableRowCollection <DataRow> holidaySchedules = null;
                    EnumerableRowCollection <DataRow> workHours        = null;

                    try
                    {
                        var dtResourceHSWS = new DataTable();

                        string connectionString = GetConnectionString();

                        if (string.IsNullOrEmpty(connectionString))
                        {
                            throw new Exception("PFE DB connection string is empty.");
                        }

                        using (var sqlConnection = new SqlConnection(connectionString))
                        {
                            using (var sqlCommand = new SqlCommand(SQL, sqlConnection))
                            {
                                sqlConnection.Open();
                                using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
                                {
                                    dtResourceHSWS.Load(sqlDataReader);
                                }
                            }
                        }

                        resourceHSWS = dtResourceHSWS.AsEnumerable();

                        if (resourceHSWS.Any())
                        {
                            holidaySchedules = oHolidaySchedule.Items.GetDataTable().AsEnumerable();
                            workHours        = oWorkHours.Items.GetDataTable().AsEnumerable();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogMessage("\t", "(Get PFE DB ConnectionString): " + ex.Message, 3);
                    }

                    foreach (SPListItem li in oResourcePool.Items)
                    {
                        try
                        {
                            #region Copy Department and Roles

                            if (li["TempDept"] != null && !li["TempDept"].ToString().Contains(";#") &&
                                oFieldDept.Type == SPFieldType.Lookup)
                            {
                                DataRow[] dr = dtDepartments.Select("DisplayName='" + li["TempDept"] + "'");
                                if (dr.Length > 0)
                                {
                                    var lv = new SPFieldLookupValue(int.Parse(dr[0]["ID"].ToString()),
                                                                    li["TempDept"].ToString());
                                    li[oFieldDept.Id] = lv;
                                }
                            }

                            if (li["TempRole"] != null && !li["TempRole"].ToString().Contains(";#") &&
                                oFieldRole.Type == SPFieldType.Lookup)
                            {
                                DataRow[] dr = dtRoles.Select("Title='" + li["TempRole"] + "'");
                                if (dr.Length > 0)
                                {
                                    var lv = new SPFieldLookupValue(int.Parse(dr[0]["ID"].ToString()),
                                                                    li["TempRole"].ToString());
                                    li[oFieldRole.Id] = lv;
                                }
                            }

                            #endregion

                            string spAccount = string.Empty;
                            var    resAcct   = li["SharePointAccount"] as string;
                            if (!string.IsNullOrEmpty(resAcct))
                            {
                                var uv = new SPFieldUserValue(SPWeb, resAcct);
                                if (uv.User != null)
                                {
                                    spAccount = uv.User.LoginName.ToLower();
                                }
                            }

                            string extId = (li["EXTID"] ?? string.Empty).ToString();

                            if (resourceHSWS != null && resourceHSWS.Any() && !string.IsNullOrEmpty(spAccount))
                            {
                                try
                                {
                                    if (string.IsNullOrEmpty(extId))
                                    {
                                        foreach (DataRow row in resourceHSWS)
                                        {
                                            object acct = row["Account"];
                                            if (acct != null && acct != DBNull.Value)
                                            {
                                                if (acct.ToString().ToLower().Equals(spAccount))
                                                {
                                                    li["EXTID"] = (row["ResourceId"] ?? string.Empty).ToString();
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LogMessage("\t", "(" + li.Title + "): Not setting EXTID. " + ex.Message, 3);
                                }

                                try
                                {
                                    foreach (object schedule in from hs in resourceHSWS
                                             let account = hs["Account"]
                                                           where account != null && account != DBNull.Value
                                                           where account.ToString().ToLower().Equals(spAccount)
                                                           select hs["HolidaySchedule"]
                                                           into schedule
                                                           where schedule != null && schedule != DBNull.Value
                                                           select schedule)
                                    {
                                        foreach (DataRow s in holidaySchedules)
                                        {
                                            object sch = s["Title"];
                                            if (sch == null || sch == DBNull.Value)
                                            {
                                                continue;
                                            }

                                            string hsch = sch.ToString();
                                            if (!hsch.ToLower().Equals(schedule.ToString().ToLower()))
                                            {
                                                continue;
                                            }

                                            li["HolidaySchedule"] =
                                                new SPFieldLookupValue(Convert.ToInt32(s["ID"].ToString()), hsch);
                                            break;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LogMessage("\t", "(" + li.Title + "): Not setting Holiday Schedule. " + ex.Message,
                                               3);
                                }

                                try
                                {
                                    foreach (object hours in from wh in resourceHSWS
                                             let account = wh["Account"]
                                                           where account != null && account != DBNull.Value
                                                           where account.ToString().ToLower().Equals(spAccount)
                                                           select wh["WorkHours"]
                                                           into hours
                                                           where hours != null && hours != DBNull.Value
                                                           select hours)
                                    {
                                        foreach (DataRow h in workHours)
                                        {
                                            object hr = h["Title"];
                                            if (hr == null || hr == DBNull.Value)
                                            {
                                                continue;
                                            }

                                            string whr = hr.ToString();
                                            if (!whr.ToLower().Equals(hours.ToString().ToLower()))
                                            {
                                                continue;
                                            }

                                            li["WorkHours"] = new SPFieldLookupValue(
                                                Convert.ToInt32(h["ID"].ToString()), whr);
                                            break;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LogMessage("\t", "(" + li.Title + "): Not setting Work Hours. " + ex.Message, 3);
                                }
                            }
                            else
                            {
                                LogMessage("\t",
                                           "(" + li.Title +
                                           "): Not setting Holiday Schedule and Work Hours. Cannot load from PFE.", 3);
                            }

                            li.Update();

                            LogMessage("\t\t" + li.Title);
                        }
                        catch (Exception ex)
                        {
                            LogMessage("\t", "(" + li.Title + "): " + ex.Message, 3);
                        }
                    }

                    if (bIsPfe)
                    {
                        using (var workEngineAPI = new WorkEngineAPI())
                        {
                            LogMessage("Installing PfE Resource Events");

                            WorkEngineAPI.AddRemoveFeatureEvents(
                                @"<AddRemoveFeatureEvents><Data><Feature Name=""pferesourcemanagement"" Operation=""ADD""/></Data></AddRemoveFeatureEvents>",
                                SPWeb);
                        }
                    }

                    LogMessage("Enabling New Button");

                    using (var spSite = new SPSite(oResourcePool.ParentWeb.Site.ID))
                    {
                        using (SPWeb spWeb = spSite.OpenWeb(oResourcePool.ParentWeb.ID))
                        {
                            SPList resourcePool = spWeb.Lists.GetList(oResourcePool.ID, false);

                            var gSettings = new GridGanttSettings(resourcePool)
                            {
                                HideNewButton = false
                            };
                            gSettings.SaveSettings(resourcePool);
                        }
                    }

                    LogMessage("Processing Editable Fields");
                    UpdateField("Generic", true, false, true, ref oResourcePool);
                    UpdateField("FirstName", true, true, true, ref oResourcePool);
                    UpdateField("LastName", true, true, true, ref oResourcePool);
                    UpdateField("Email", true, false, true, ref oResourcePool);
                    UpdateField("ResourceLevel", true, true, true, ref oResourcePool);
                    UpdateField("Permissions", true, true, true, ref oResourcePool);
                    UpdateField("StandardRate", true, true, true, ref oResourcePool);
                    UpdateField("Department", true, true, true, ref oResourcePool);
                    UpdateField("Role", true, true, true, ref oResourcePool);
                    UpdateField("HolidaySchedule", true, true, true, ref oResourcePool);
                    UpdateField("WorkHours", true, true, true, ref oResourcePool);
                    UpdateField("AvailableFrom", true, true, true, ref oResourcePool);
                    UpdateField("AvailableTo", true, true, true, ref oResourcePool);
                    UpdateField("Disabled", false, true, true, ref oResourcePool);
                }
                catch (Exception ex)
                {
                    LogMessage("", "General: " + ex.Message, 3);
                }
            }

            return(true);
        }
Пример #15
0
        private string KiemtraCamchidinhchungphieu(int id_thuoc, string ten_chitiet)
        {
            string _reval = "";
            string _tempt = "";
            var    lstKey = new List <string>();
            string _key   = "";

            //Kiểm tra dịch vụ đang thêm có phải là dạng Single-Service hay không?
            DataRow[] _arrSingle =
                m_dtDanhmucthuoc.Select(DmucThuoc.Columns.SingleService + "=1 AND " + DmucThuoc.Columns.IdThuoc + "=" +
                                        id_thuoc);
            if (_arrSingle.Length > 0 &&
                m_dtDonthuocChitiet.Select(KcbDonthuocChitiet.Columns.IdThuoc + "<>" + id_thuoc).Length > 0)
            {
                return(string.Format("Single-Service: {0}", ten_chitiet));
            }
            //Kiểm tra các dịch vụ đã thêm có cái nào là Single-Service hay không?
            List <int> lstID =
                m_dtDonthuocChitiet.AsEnumerable()
                .Select(c => Utility.Int32Dbnull(c[KcbDonthuocChitiet.Columns.IdThuoc], 0))
                .Distinct()
                .ToList();
            EnumerableRowCollection <DataRow> q = from p in m_dtDanhmucthuoc.AsEnumerable()
                                                  where Utility.ByteDbnull(p[DmucThuoc.Columns.SingleService], 0) == 1 &&
                                                  lstID.Contains(Utility.Int32Dbnull(p[DmucThuoc.Columns.IdThuoc], 0))
                                                  select p;

            if (q.Any())
            {
                return(string.Format("Single-Service: {0}",
                                     Utility.sDbnull(q.FirstOrDefault()[DmucThuoc.Columns.TenThuoc], "")));
            }
            //Lấy các cặp cấm chỉ định chung cùng nhau
            DataRow[] arrDr =
                m_dtqheCamchidinhChungphieu.Select(QheCamchidinhChungphieu.Columns.IdDichvu + "=" + id_thuoc);
            DataRow[] arrDr1 =
                m_dtqheCamchidinhChungphieu.Select(QheCamchidinhChungphieu.Columns.IdDichvuCamchidinhchung + "=" +
                                                   id_thuoc);
            foreach (DataRow dr in arrDr)
            {
                DataRow[] arrtemp =
                    m_dtDonthuocChitiet.Select(KcbDonthuocChitiet.Columns.IdThuoc + "=" +
                                               Utility.sDbnull(
                                                   dr[QheCamchidinhChungphieu.Columns.IdDichvuCamchidinhchung]));
                if (arrtemp.Length > 0)
                {
                    foreach (DataRow dr1 in arrtemp)
                    {
                        _tempt = string.Empty;
                        _key   = id_thuoc + "-" + Utility.sDbnull(dr1[KcbDonthuocChitiet.Columns.IdThuoc], "");
                        if (!lstKey.Contains(_key))
                        {
                            lstKey.Add(_key);
                            _tempt = string.Format("{0} - {1}", ten_chitiet,
                                                   Utility.sDbnull(dr1[DmucThuoc.Columns.IdThuoc], ""));
                        }
                        if (_tempt != string.Empty)
                        {
                            _reval += _tempt + "\n";
                        }
                    }
                }
            }
            foreach (DataRow dr in arrDr1)
            {
                DataRow[] arrtemp =
                    m_dtDonthuocChitiet.Select(KcbDonthuocChitiet.Columns.IdThuoc + "=" +
                                               Utility.sDbnull(dr[QheCamchidinhChungphieu.Columns.IdDichvu]));
                if (arrtemp.Length > 0)
                {
                    foreach (DataRow dr1 in arrtemp)
                    {
                        _tempt = string.Empty;
                        _key   = id_thuoc + "-" + Utility.sDbnull(dr1[KcbDonthuocChitiet.Columns.IdThuoc], "");
                        if (!lstKey.Contains(_key))
                        {
                            lstKey.Add(_key);
                            _tempt = string.Format("{0} - {1}", ten_chitiet,
                                                   Utility.sDbnull(dr1[DmucThuoc.Columns.TenThuoc], ""));
                        }
                        if (_tempt != string.Empty)
                        {
                            _reval += _tempt + "\n";
                        }
                    }
                }
            }
            return(_reval);
        }
Пример #16
0
        private static HtmlBuilder LinkTable(
            this HtmlBuilder hb,
            Context context,
            SiteSettings ss,
            View view,
            EnumerableRowCollection <DataRow> dataRows,
            string direction,
            string dataTableName)
        {
            return(hb.Table(
                       id: dataTableName,
                       css: "grid",
                       attributes: new HtmlAttributes()
                       .DataId(ss.SiteId.ToString())
                       .DataName(direction)
                       .DataValue("back")
                       .DataAction("LinkTable")
                       .DataMethod("post"),
                       action: () =>
            {
                var siteMenu = SiteInfo.TenantCaches.Get(context.TenantId)?.SiteMenu;
                if (dataRows != null && dataRows.Any())
                {
                    ss.SetColumnAccessControls(context: context);
                    var columns = ss.GetLinkTableColumns(
                        context: context,
                        view: view,
                        checkPermission: true);
                    switch (ss.ReferenceType)
                    {
                    case "Issues":
                        var issueCollection = new IssueCollection(
                            context: context,
                            ss: ss,
                            dataRows: dataRows);
                        issueCollection.SetLinks(context: context, ss: ss);
                        hb
                        .Caption(caption: "{0} : {1} - {2} {3}".Params(
                                     Caption(
                                         context: context,
                                         direction: direction),
                                     siteMenu.Breadcrumb(context: context, siteId: ss.SiteId)
                                     .Select(o => o.Title)
                                     .Join(" > "),
                                     Displays.Quantity(context: context),
                                     dataRows.Count()))
                        .THead(action: () => hb
                               .GridHeader(
                                   context: context,
                                   columns: columns,
                                   view: view,
                                   sort: true,
                                   checkRow: false,
                                   action: "LinkTable"))
                        .TBody(action: () => issueCollection
                               .ForEach(issueModel =>
                        {
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: issueModel.Mine(context: context));
                            hb.Tr(
                                attributes: new HtmlAttributes()
                                .Class("grid-row")
                                .DataId(issueModel.IssueId.ToString()),
                                action: () => columns
                                .ForEach(column => hb
                                         .TdValue(
                                             context: context,
                                             ss: ss,
                                             column: column,
                                             issueModel: issueModel)));
                        }));
                        break;

                    case "Results":
                        var resultCollection = new ResultCollection(
                            context: context,
                            ss: ss,
                            dataRows: dataRows);
                        resultCollection.SetLinks(context: context, ss: ss);
                        hb
                        .Caption(caption: "{0} : {1} - {2} {3}".Params(
                                     Caption(
                                         context: context,
                                         direction: direction),
                                     siteMenu.Breadcrumb(context: context, siteId: ss.SiteId)
                                     .Select(o => o.Title)
                                     .Join(" > "),
                                     Displays.Quantity(context: context),
                                     dataRows.Count()))
                        .THead(action: () => hb
                               .GridHeader(
                                   context: context,
                                   columns: columns,
                                   view: view,
                                   sort: true,
                                   checkRow: false,
                                   action: "LinkTable"))
                        .TBody(action: () => resultCollection
                               .ForEach(resultModel =>
                        {
                            ss.SetColumnAccessControls(
                                context: context,
                                mine: resultModel.Mine(context: context));
                            hb.Tr(
                                attributes: new HtmlAttributes()
                                .Class("grid-row")
                                .DataId(resultModel.ResultId.ToString()),
                                action: () => columns
                                .ForEach(column => hb
                                         .TdValue(
                                             context: context,
                                             ss: ss,
                                             column: column,
                                             resultModel: resultModel)));
                        }));
                        break;
                    }
                }
            }));
        }
Пример #17
0
        private static DataSet ResultContents(
            Context context, EnumerableRowCollection <DataRow> dataRows)
        {
            var statements = new List <SqlStatement>();

            if (dataRows.Any(o => o.String("ReferenceType") == "Sites"))
            {
                statements.Add(Rds.SelectSites(
                                   dataTableName: "Sites",
                                   column: Rds.SitesColumn()
                                   .ParentId(_as: "SiteId")
                                   .SiteId(_as: "Id")
                                   .Body()
                                   .Items_Title(),
                                   join: new SqlJoinCollection(
                                       new SqlJoin(
                                           tableBracket: "\"Items\"",
                                           joinType: SqlJoin.JoinTypes.Inner,
                                           joinExpression: "\"Items\".\"ReferenceId\"=\"Sites\".\"SiteId\"")),
                                   where : Rds.SitesWhere()
                                   .TenantId(context.TenantId)
                                   .SiteId_In(dataRows
                                              .Where(o => o.String("ReferenceType") == "Sites")
                                              .Select(o => o.Long("ReferenceId")))));
            }
            if (dataRows.Any(o => o.String("ReferenceType") == "Issues"))
            {
                statements.Add(Rds.SelectIssues(
                                   dataTableName: "Issues",
                                   column: Rds.IssuesColumn()
                                   .SiteId()
                                   .IssueId(_as: "Id")
                                   .Body()
                                   .Items_Title(),
                                   join: new SqlJoinCollection(
                                       new SqlJoin(
                                           tableBracket: "\"Items\"",
                                           joinType: SqlJoin.JoinTypes.Inner,
                                           joinExpression: "\"Items\".\"ReferenceId\"=\"Issues\".\"IssueId\"")),
                                   where : Rds.IssuesWhere()
                                   .IssueId_In(dataRows
                                               .Where(o => o.String("ReferenceType") == "Issues")
                                               .Select(o => o.Long("ReferenceId")))));
            }
            if (dataRows.Any(o => o.String("ReferenceType") == "Results"))
            {
                statements.Add(Rds.SelectResults(
                                   dataTableName: "Results",
                                   column: Rds.ResultsColumn()
                                   .SiteId()
                                   .ResultId(_as: "Id")
                                   .Body()
                                   .Items_Title(),
                                   join: new SqlJoinCollection(
                                       new SqlJoin(
                                           tableBracket: "\"Items\"",
                                           joinType: SqlJoin.JoinTypes.Inner,
                                           joinExpression: "\"Items\".\"ReferenceId\"=\"Results\".\"ResultId\"")),
                                   where : Rds.ResultsWhere()
                                   .ResultId_In(dataRows
                                                .Where(o => o.String("ReferenceType") == "Results")
                                                .Select(o => o.Long("ReferenceId")))));
            }
            if (dataRows.Any(o => o.String("ReferenceType") == "Wikis"))
            {
                statements.Add(Rds.SelectWikis(
                                   dataTableName: "Wikis",
                                   column: Rds.WikisColumn()
                                   .SiteId()
                                   .WikiId(_as: "Id")
                                   .Body()
                                   .Items_Title(),
                                   join: new SqlJoinCollection(
                                       new SqlJoin(
                                           tableBracket: "\"Items\"",
                                           joinType: SqlJoin.JoinTypes.Inner,
                                           joinExpression: "\"Items\".\"ReferenceId\"=\"Wikis\".\"WikiId\"")),
                                   where : Rds.WikisWhere()
                                   .WikiId_In(dataRows
                                              .Where(o => o.String("ReferenceType") == "Wikis")
                                              .Select(o => o.Long("ReferenceId")))));
            }
            return(Repository.ExecuteDataSet(
                       context: context,
                       statements: statements.ToArray()));
        }
Пример #18
0
        /// <summary>
        ///     hàm thực hiện việc chuyên thông tin sang bên phải
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdChuyenSang_Click(object sender, EventArgs e)
        {
            if (grdPres.GetCheckedRows().Length <= 0)
            {
                Utility.ShowMsg("Bạn chọn bản ghi cần chuyển sang", "Thông báo", MessageBoxIcon.Error);
                return;
            }
            foreach (GridEXRow gridExRow in grdPres.GetCheckedRows())
            {
                int pres_id = Utility.Int32Dbnull(gridExRow.Cells["Pres_ID"].Value, -1);
                EnumerableRowCollection <DataRow> query = from thuoc in m_dtDonThuoc.AsEnumerable()
                                                          where
                                                          Utility.Int32Dbnull(thuoc[KcbDonthuoc.Columns.PresId]) == pres_id
                                                          select thuoc;
                if (query.Any())
                {
                    DataRow firstrow = query.FirstOrDefault();
                    if (firstrow != null)
                    {
                        firstrow["IsChon"] = 1;
                    }
                    firstrow.AcceptChanges();
                }

                EnumerableRowCollection <DataRow> query1 = from thuoc in m_dtPhieuLinh.AsEnumerable()
                                                           where Utility.Int32Dbnull(thuoc[KcbDonthuoc.Columns.PresId]) == pres_id
                                                           select thuoc;
                if (!query1.Any())
                {
                    DataRow firstrow1 = query.FirstOrDefault();
                    if (firstrow1 != null)
                    {
                        DataRow dr = m_dtPhieuLinh.NewRow();
                        dr["IsChon"]  = 1;
                        dr["Pres_ID"] = Utility.Int32Dbnull(firstrow1["Pres_ID"]);
                        if (m_dtPhieuLinh.Columns.Contains("ID_DTRI"))
                        {
                            dr["ID_DTRI"] = Utility.Int32Dbnull(firstrow1["Treat_ID"]);
                        }
                        if (m_dtPhieuLinh.Columns.Contains("Treat_ID"))
                        {
                            dr["Treat_ID"] = Utility.Int32Dbnull(firstrow1["Treat_ID"]);
                        }
                        dr["Patient_Name"]  = Utility.sDbnull(firstrow1["Patient_Name"]);
                        dr["Year_Of_Birth"] = Utility.Int32Dbnull(firstrow1["Year_Of_Birth"]);
                        dr["Patient_Code"]  = Utility.sDbnull(firstrow1["Patient_Code"]);
                        dr["Patient_Addr"]  = Utility.sDbnull(firstrow1["Patient_Addr"]);
                        dr["Patient_ID"]    = Utility.Int32Dbnull(firstrow1["Patient_ID"]);
                        if (m_dtPhieuLinh.Columns.Contains("Pres_Date"))
                        {
                            dr["Pres_Date"] = Convert.ToDateTime(firstrow1["Pres_Date"]);
                        }
                        if (m_dtPhieuLinh.Columns.Contains("Pres_Name"))
                        {
                            dr["Pres_Name"] = Utility.sDbnull(firstrow1["Pres_Name"]);
                        }
                        m_dtPhieuLinh.Rows.Add(dr);
                    }
                }
                else
                {
                    DataRow firstrow = query1.FirstOrDefault();
                    if (firstrow != null)
                    {
                        firstrow["IsChon"] = 1;
                    }
                    firstrow.AcceptChanges();
                }
            }

            Modifycommand();
        }
Пример #19
0
        // Returns a datatable of VWAPs for a stock with the given epic
        public DataTable GetFilteredVWAP(string epic)
        {
            // Get an enumerable table for LINQ
            EnumerableRowCollection <DataRow> enumTable = Table.AsEnumerable();

            if (!enumTable.Any(row => epic == row.Field <string>("epic")))
            {
                return(null);
            }

            var query = from stock in enumTable
                        // filter stocks by epic
                        where stock.Field <string>("epic") == epic
                        // group stocks by epic, isin and tradetype
                        group stock by(
                epic : stock.Field <string>("epic"),
                isin : stock.Field <string>("isin"),
                tradeType : stock.Field <string>("trade type")
                )
                        into g
                        select(
                g.Key.isin,
                g.Key.tradeType,
                // sales is the sum of the quantity of sales * price per sale
                sales : g.Sum(x => x.Field <long>("quantity") * x.Field <double>("price")),
                // quantity is the sum of the quantities
                quantity : g.Sum(x => x.Field <long>("quantity"))
                ) into h
                        select(
                h.isin,
                h.tradeType,
                VWAP : h.sales / h.quantity
                );

            var query2 = from stock in enumTable
                         // filter stocks by epic
                         where stock.Field <string>("epic") == epic
                         // group stocks by epic and isin
                         group stock by(
                epic : stock.Field <string>("epic"),
                isin : stock.Field <string>("isin")
                )
                         into g
                         select(
                g.Key.isin,
                // sales is the sum of the quantity of sales * price per sale
                sales : g.Sum(x => x.Field <long>("quantity") * x.Field <double>("price")),
                // quantity is the sum of the quantities
                quantity : g.Sum(x => x.Field <long>("quantity"))
                ) into h
                         select(
                h.isin,
                VWAP : h.sales / h.quantity
                );

            // Create a new datatable
            DataTable dataTable = new DataTable();

            // Add the columns
            _ = dataTable.Columns.Add("epic", typeof(string));
            _ = dataTable.Columns.Add("isin", typeof(string));
            _ = dataTable.Columns.Add("trade type", typeof(string));
            _ = dataTable.Columns.Add("VWAP", typeof(double));

            // Iterate through the query results
            foreach ((string isin, double VWAP) in query2)
            {
                // Add a row with the corresponding values
                _ = dataTable.Rows.Add(epic, isin, "Overall", VWAP);
            }

            // Iterate through the query results
            foreach ((string isin, string tradeType, double VWAP) in query)
            {
                // Add a row with the corresponding values
                dataTable.Rows.Add(epic, isin, tradeType, VWAP);
            }

            // Return the results
            return(dataTable);
        }
Пример #20
0
        public void Top(string data)
        {
            if (!isAuthorized)
            {
                SendBuffer("-ERR Not Authorized.");
                return;
            }

            string[] parts = data.Split(" ");

            if (parts.Length != 2)
            {
                SendBuffer("-ERR invalid parameter");
                return;
            }

            Int64 msgNum = -1;

            Int64.TryParse(parts[0], out msgNum);

            Int64 len = -1;

            Int64.TryParse(parts[1], out len);

            if (len == -1)
            {
                SendBuffer("-ERR invalid length");
                return;
            }

            if (msgNum == -1)
            {
                SendBuffer("-ERR no such message");
                return;
            }

            EnumerableRowCollection <DataRow> results = from messages in mailBox.Tables["messages"].AsEnumerable() where messages.Field <Int64>("index") == msgNum select messages;

            if (!results.Any())
            {
                SendBuffer("-ERR no such message");
                return;
            }

            DataRow dataRow  = results.First <DataRow>();
            string  filename = dataRow.Field <string>("filename");

            string[] lines = File.ReadAllLines(filename);

            string headers = "";
            string body    = "";
            bool   isBody  = false;
            int    counter = 0;

            foreach (string line in lines)
            {
                if (isBody)
                {
                    if (counter == len)
                    {
                        break;
                    }
                    body += line + "\r\n";
                    counter++;
                }
                else
                {
                    if (line.Length == 0)
                    {
                        isBody = true;
                    }

                    headers += line + "\r\n";
                }
            }
            SendBuffer("+OK");
            SendBuffer(headers + body + "\r\n.");
        }