Пример #1
0
        public override string PushDown()
        {
            if (!IsPredicateSet)
            {
                return(String.Empty);
            }

            IsPushedDown = true;
            string result = ColumnName.ToString();

            result += " " + FilterPredicate.ComparisonOperatorAsString(ComparisonOperator) + " N'" + EscapeFilter(PredicateValue) + "'";
            return(result);
        }
        public override string PushDown()
        {
            if (!IsPredicateSet)
            {
                return(String.Empty);
            }

            IsPushedDown = true;
            string result = "(";

            bool hasPositives = false;
            bool hasNegatives = false;

            for (int i = 0; i < ComparisonOperator.Length; i++)
            {
                if (ComparisonOperator[i] == FilterComparisonOperator.Not_Equal)
                {
                    hasNegatives = true;
                }
                else
                {
                    hasPositives = true;
                }
            }

            for (int i = 0; i < PredicateValue.Length; i++)
            {
                if (hasNegatives && hasPositives && ComparisonOperator[i] == FilterComparisonOperator.Not_Equal)
                {
                    // In this case I only care for the positives
                    continue;
                }

                if (i > 0)
                {
                    if (hasNegatives && !hasPositives)
                    {
                        result += " AND ";
                    }
                    else
                    {
                        result += " OR ";
                    }
                }

                result += ColumnName.ToString();
                result += " " + FilterPredicate.ComparisonOperatorAsString(ComparisonOperator[i]) + " '" + EscapeFilter(PredicateValue[i]) + "'";
            }
            result += ")";
            return(result);
        }
Пример #3
0
        public void Execute(Boolean ReplaceAndExecute, string tagevent, TagHandler Tags)
        {
            string     finalWhere;
            string     value;
            string     cmdSend;
            Logging    log          = new Logging("[" + tagevent + "]" + Command + ":" + ColumnName + " ");
            SQLHandler sqlGenerator = new SQLHandler();

            string cmd = Command.ToLower();

            if (cmd.Substring(0, 6) == "insert" || cmd.Substring(0, 6) == "update" || cmd.Substring(0, 6) == "select")
            {
                if (Where != "")
                {
                    finalWhere = Tags.SolveWhere(Where);
                }
                else
                {
                    finalWhere = Where;
                }

                sqlGenerator.InitCommand(cmd.ToString(), ColumnName.ToString(), finalWhere);
                if (Columns != null)
                {
                    for (int index = 0; index < Columns.Count; index++)
                    {
                        ColumnsCommand column = Columns[index];
                        log.Command += column.TagAddress + column.name + column.KeepInTag + "=" + column.Formula + "\t";
                        if (column.Enabled)
                        {
                            if (ReplaceAndExecute)
                            {
                                string tmpExp = column.Formula;
                                value = Tags.SolveFormula(tmpExp);
                                if (column.Format != "")
                                {
                                    value = String.Format(column.Formula, column.Format);
                                }
                            }
                            else
                            {
                                value = column.Formula;
                            }
                            column.Value = value.ToString().Trim();
                            sqlGenerator.SetColumn(column.name, value);

                            if (column.KeepInTag != "")
                            {
                                Tags.UpdateTagsValue(column.KeepInTag, Convert.ToInt32(value));
                                IntData.SaveRecordsetFlag = true;
                            }
                        }
                        Columns[index] = column;
                    }

                    if (ReplaceAndExecute)
                    {
                        cmdSend = sqlGenerator.Command;
                        if (Command.ToString().ToUpper() == "UPDATE")
                        {
                            if (AutoInsert(ColumnName.ToString()))
                            {
                                cmdSend += IntData.AUTO_INSERT_STR;
                            }
                        }
                        if (Command.ToString().ToUpper() != "SELECT" && ColumnName.ToString() != "" && ColumnName.IndexOf("_Internal") == -1)
                        {
                            MQHandler queue = new MQHandler();
                            queue.SendMsg(cmdSend);
                        }
                        if (Command.ToString().ToUpper() == "SELECT")
                        {
                            WriteOPC(cmdSend, Tags);
                        }
                    }
                }
            }
            log.Success();
        }
Пример #4
0
    protected void ImgExpExcel_Click(object sender, EventArgs e)
    {
        DataTable dt = BLL_QMS_RestHours.Get_RestHours_Report(UDFLib.ConvertDateToNull(txtFrom.Text), UDFLib.ConvertDateToNull(txtTo.Text), UDFLib.ConvertToInteger(ddlCrewList.SelectedValue), UDFLib.ConvertToInteger(ddlVesselList.SelectedValue));



        string[] HeaderCaptions = { "Date",       "Ship's Clocked Hours",
                                    "0",          "0",                   "1",                           "0",         "2",
                                    "0",          "3",                   "0",                           "4",
                                    "0",          "5",                   "0",                           "6",
                                    "0",          "7",                   "0",                           "8",
                                    "0",          "9",                   "1",                           "0",
                                    "1",          "1",                   "1",                           "2",
                                    "1",          "3",                   "1",                           "4",
                                    "1",          "5",                   "1",                           "6",
                                    "1",          "7",                   "1",                           "8",
                                    "1",          "9",                   "2",                           "0",
                                    "2",          "1",                   "2",                           "2",
                                    "2",          "3",                   "",
                                    "Work Hours", "Rest Hours",          "Rest Hours in Any 24 Hours",  "Over Time", "Rest Hour In 7-Day Period","Seafarer's Remark", "Verifier's Remark" };
        string[] DataColumnsName = { "REST_HOURS_DATE", "SHIPS_CLOCKED_HOURS",
                                     "WH_0000_0030",    "WH_0030_0100",       "WH_0100_0130",      "WH_0130_0200",
                                     "WH_0200_0230",    "WH_0230_0300",       "WH_0300_0330",      "WH_0330_0400",
                                     "WH_0400_0430",    "WH_0430_0500",       "WH_0500_0530",      "WH_0530_0600",
                                     "WH_0600_0630",    "WH_0630_0700",       "WH_0700_0730",      "WH_0730_0800",
                                     "WH_0800_0830",    "WH_0830_0900",       "WH_0900_0930",      "WH_0930_1000",
                                     "WH_1000_1030",    "WH_1030_1100",       "WH_1100_1130",      "WH_1130_1200",
                                     "WH_1200_1230",    "WH_1230_1300",       "WH_1300_1330",      "WH_1330_1400",
                                     "WH_1400_1430",    "WH_1430_1500",       "WH_1500_1530",      "WH_1530_1600",
                                     "WH_1600_1630",    "WH_1630_1700",       "WH_1700_1730",      "WH_1730_1800",
                                     "WH_1800_1830",    "WH_1830_1900",       "WH_1900_1930",      "WH_1930_2000",
                                     "WH_2000_2030",    "WH_2030_2100",       "WH_2100_2130",      "WH_2130_2200",
                                     "WH_2200_2230",    "WH_2230_2300",       "WH_2300_2330",      "WH_2330_2400",

                                     "WORKING_HOURS",   "REST_HOURS",         "REST_HOURS_ANY24",  "OverTime_HOURS","RestHrs7Day","Seafarer_Remarks", "Verifier_Remarks" };



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

        for (int i = 0; i < dt.Columns.Count; i++)
        {
            string lCoumnName = dt.Columns[i].ToString();
            if (lCoumnName.StartsWith("WH_"))
            {
                lColName.Add(lCoumnName);
            }
        }

        foreach (string itemc in lColName)
        {
            ChangeColumnDataType(dt, itemc, typeof(string));
        }

        foreach (DataRow item in dt.Rows)
        {
            foreach (DataColumn ColumnName in dt.Columns)
            {
                if (ColumnName.ToString().StartsWith("WH_"))
                {
                    if (item[ColumnName.ToString()].ToString() == "0")
                    {
                        item[ColumnName.ToString()] = DBNull.Value;
                    }
                    else
                    {
                        item[ColumnName.ToString()] = "&#10003;";
                    }
                }
            }
        }



        //GridViewExportUtil.ExportToExcel(dt, HeaderCaptions, DataColumnsName, "CrewHandOver.xls", "Crew Handover");
        if (dt.Rows.Count > 0)
        {
            GridViewExportUtil.ShowExcel(dt, HeaderCaptions, DataColumnsName, "CrewRestHoursReport.xls", "Rest/Work Hour Report for " + dt.Rows[0]["Staff_rank_Code"] + "-" + dt.Rows[0]["Staff_Code"] + "-" + dt.Rows[0]["Staff_Name"]);
        }
        else
        {
            string msg = String.Format("alert('Records not found!');");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg, true);
        }
    }
Пример #5
0
 public void ReturnCorrectToStringValue()
 {
     Assert.Equal(_name, _columnName.ToString());
 }