Exemplo n.º 1
0
 public static List<IntelWebField> List(IntelWebField p1, IntelWebField p2)
 {
     List<IntelWebField> templist = new List<IntelWebField>();
     templist.Add(p1);
     templist.Add(p2);
     return templist;
 }
Exemplo n.º 2
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            CurrentUser cuser = new CurrentUser();
            cuser.userName = "******";
            cuser.Load();

            string tiercode = Request.QueryString["tiercode"];
            string deptcode = Request.QueryString["deptcode"];
            string sitecode = Request.QueryString["sitecode"];
            string panelcode = Request.QueryString["panelcode"];
            string devicecode = Request.QueryString["devicecode"];
            string fromdate = Request.QueryString["fdate"];
            string todate = Request.QueryString["tdate"];

            tbl_alarm_time_details alarmDet = new tbl_alarm_time_details(cuser);
            IntelWebField tierFld = alarmDet.Field("tier_code");
            tierFld.fieldValue = tiercode;
            IntelWebField deptFld = alarmDet.Field("department_code");
            deptFld.fieldValue = deptcode;
            IntelWebField siteFld = alarmDet.Field("site_code");
            siteFld.fieldValue = sitecode;
            IntelWebField panelFld = alarmDet.Field("panel_code");
            panelFld.fieldValue = panelcode;
            IntelWebField deviceFld = alarmDet.Field("alarm_device_code");
            deviceFld.fieldValue = devicecode;
            IntelWebField fdateFld = new IntelWebField("todate", OleDbType.DBDate, 10, 10, 0, DataRowVersion.Current, false, fromdate);
            IntelWebField tdateFld = new IntelWebField("todate", OleDbType.DBDate, 10, 10, 0, DataRowVersion.Current, false, todate);
            List<IntelWebField> bparam = new List<IntelWebField>();
            bparam.Add(tierFld);
            bparam.Add(deptFld);
            bparam.Add(siteFld);
            bparam.Add(panelFld);
            bparam.Add(deviceFld);
            bparam.Add(fdateFld);
            bparam.Add(tdateFld);
            List<IntelWebObject> alarmDets = alarmDet.Load("tier_code=? and department_code=? and site_code=? and panel_code=? and alarm_device_code=? and alarm_date between ? and ?", "alarm_date,alarm_time", bparam);
            if (alarmDets.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<table style=\"width:100%;\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"webgrid\"><thead class=\"titlegrid\"><tr><th>Device</th><th>Alarm Date</th><th>Alarm Hour</th><th>Alaram Time</th><th>Alarm Details</th><th>Alarm Comment</th></tr>");
                int rowCnt = 0;
                foreach (tbl_alarm_time_details alarm in alarmDets)
                {
                    string trclass = (rowCnt % 2 == 0 ? "" : " class=\"gridodd\" ");
                    sb.Append("<tr" + trclass + "><td>" + HttpUtility.HtmlEncode(alarm.alarm_device_code) + "</td><td>" + HttpUtility.HtmlEncode(alarm.alarm_date.ToString("MM/dd/yyyy")) + "</td><td>" + HttpUtility.HtmlEncode(alarm.alarm_hour) + "</td><td>" + HttpUtility.HtmlEncode(alarm.alarm_time) + "</td><td>" + HttpUtility.HtmlEncode(alarm.alarm_details) + "</td><td>" + HttpUtility.HtmlEncode(alarm.alarm_comment) + "</td></tr>");
                    rowCnt++;
                }
                sb.Append("</table>");

                Response.Write(sb.ToString());
            }
            else
            {
                Response.Write("There are no details found.");
            }
        }
Exemplo n.º 3
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            CurrentUser cuser = new CurrentUser();
            cuser.userName = "******";
            cuser.Load();

            string tiercode = Request.QueryString["tiercode"];
            string deptcode = Request.QueryString["deptcode"];
            string sitecode = Request.QueryString["sitecode"];
            string fromdate = Request.QueryString["fdate"];
            string todate = Request.QueryString["tdate"];

            tbl_alarm_time_details alarmDet = new tbl_alarm_time_details(cuser);
            IntelWebField tierFld = alarmDet.Field("tier_code");
            tierFld.fieldValue = tiercode;
            IntelWebField deptFld = alarmDet.Field("department_code");
            deptFld.fieldValue = deptcode;
            IntelWebField siteFld = alarmDet.Field("site_code");
            siteFld.fieldValue = sitecode;
            IntelWebField fdateFld = new IntelWebField("todate", OleDbType.DBDate, 10, 10, 0, DataRowVersion.Current, false, fromdate);
            IntelWebField tdateFld = new IntelWebField("todate", OleDbType.DBDate, 10, 10, 0, DataRowVersion.Current, false, todate);
            List<IntelWebField> bparam = new List<IntelWebField>();
            bparam.Add(tierFld);
            bparam.Add(deptFld);
            bparam.Add(siteFld);
            bparam.Add(fdateFld);
            bparam.Add(tdateFld);
            List<IntelWebObject> alarmDets = alarmDet.Load("tier_code=? and department_code=? and site_code=? and alarm_date between ? and ?", "panel_code", bparam);
            if (alarmDets.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                /* Panels Table */
                sb.Append("<table><tr>");
                var distPanels = alarmDets.Select(x => x.Field("panel_code").fieldValue ?? "").Distinct();
                foreach (string panel in distPanels)
                {
                    sb.Append("<td>" + AlaramDeviceHTML(sitecode, panel, alarmDets) + "</td>");
                }

                sb.Append("</tr></table>");

                Response.Write(sb.ToString());
            }
            else
            {
                Response.Write("There are no details found.");
            }
        }
Exemplo n.º 4
0
        public DisplayField(WebGrid myGrid, string fieldName, string myDisplayName, string myJSFormatFunction, bool myIsHeaderField, string myFormFieldName)
        {
            if (myGrid.controls != null)
            {
                var control = GridDefUtil.getControl(myGrid.controls, myFormFieldName);
                if (control == null)
                {
                    _formFieldName = myFormFieldName;
                }
                else
                {
                    _formFieldName = control.ClientID;
                }
            }
            else
            {
                _formFieldName = myFormFieldName;
            }
            _jsFormatFunction = myJSFormatFunction;
            _displayName = myDisplayName;
            var myField = myGrid.protoObject.Field(fieldName);
            if (myField == null)
            {
                throw new ApplicationException("The field [" + fieldName + "] does not exist as a field in the prototype for [" + myGrid.protoObject.GetType().Name + "]");
            }
            _fieldName = fieldName;

            _allowNull = myField.nullable;
            if (myField.type == System.Data.OleDb.OleDbType.VarChar || myField.type == System.Data.OleDb.OleDbType.VarWChar || myField.type == System.Data.OleDb.OleDbType.Char || myField.type == System.Data.OleDb.OleDbType.LongVarChar || myField.type == System.Data.OleDb.OleDbType.LongVarWChar)
            {
                _maxLength = myField.parameter.Size;
            }
            else
            {
                _maxLength = 0;
            }
            _isHeaderField = myIsHeaderField;
            if (myField.version == System.Data.DataRowVersion.Default)
            {
                _defaultField = myField;

            }
        }
Exemplo n.º 5
0
        public bool LoadData()
        {
            int myCount = this.submittedRecordCount;
            List<IntelWebField> primaryKeys = new List<IntelWebField>();
            StringBuilder sb = new StringBuilder();
            int recCnt = this.submittedRecordCount;
            for (int counter = 0; counter < recCnt; counter++)
            {
                string isNewString = this.form.Get(this._gridName + "_isNew_" + counter.ToString());
                if (String.IsNullOrEmpty(isNewString) || isNewString != "true")
                {

                    sb.Append("?,");

                    string keyvalue = this.form.Get(this._gridName + "_pk_" + counter.ToString());
                    object convertedKey;
                    switch (this.primaryKey.type)
                    {
                        case System.Data.OleDb.OleDbType.Guid:
                            convertedKey = new Guid(keyvalue);
                            break;
                        case System.Data.OleDb.OleDbType.Integer:
                            convertedKey = int.Parse(keyvalue);
                            break;
                        default:
                            convertedKey = keyvalue;
                            break;
                    }
                    IntelWebField paramFld = new IntelWebField(this._gridName + "_pk_" + counter.ToString(), this.primaryKey.type, this.primaryKey.size, 0, 0, System.Data.DataRowVersion.Current, false, convertedKey);
                    primaryKeys.Add(paramFld);
                }
            }

            try
            {
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                    IntelWebObject tobj = this.User.protoObject(objectType);

                    _data = tobj.Load(this.primaryKey.name + " in (" + sb.ToString() + ")", "", primaryKeys);
                }
            }
            catch (ApplicationException ex)
            {
                this.loadErrors.Add(ex);
                return false;
            }
            return true;
        }
Exemplo n.º 6
0
 public WebGrid(string type, CurrentUser myUser, string myGridName)
 {
     this.User = myUser;
     this.objectType = type;
     _protoObject = this.User.protoObject(this.objectType);
     _pkfield = _protoObject.primaryKey;
     _gridName = myGridName;
 }
Exemplo n.º 7
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            CurrentUser cuser = new CurrentUser();
            cuser.userName = "******";
            cuser.Load();

            string formTier = Request.Form["tiercode"] ?? "";
            string formdept = Request.Form["deptcode"] ?? "";
            string formfdate = Request.Form["fromdate"] ?? "";
            string formtdate = Request.Form["todate"] ?? "";

            // Testing
            if (string.IsNullOrEmpty(formfdate)) formfdate = "04/01/2011";
            if (string.IsNullOrEmpty(formtdate)) formtdate = "04/30/2011";

            /*
             * if (string.IsNullOrEmpty(formfdate)) formfdate = DateTime.Today.ToString("MM/dd/yyyy");
             * if (string.IsNullOrEmpry(formtdate)) formtdate = DateTime.Today.AddMonths(1).ToString("MM/dd/yyyy");
            */

            lkup_tier tier = new lkup_tier(cuser);
            List<IntelWebObject> tiers = tier.Load();
            this.ltrTiers.Text = "<option value=\"\"></option>" + string.Join("", tiers.Cast<lkup_tier>().Select(x=>"<option value=\"" + HttpUtility.HtmlEncode(x.tier_code) + "\" " + (formTier.Equals(x.tier_code)?"selected":"") + " >" + HttpUtility.HtmlEncode(x.tier_code) + "</option>").ToArray());

            lkup_department lkupDept = new lkup_department(cuser);
            List<IntelWebObject> lkupDepts = lkupDept.Load();
            this.ltrDepts.Text = "<option value=\"\"></option>" + string.Join("", lkupDepts.Cast<lkup_department>().Select(x => "<option value=\"" + HttpUtility.HtmlEncode(x.department_code) + "\" " + (formdept.Equals(x.department_code)?"selected":"") +  " >" + HttpUtility.HtmlEncode(x.department_code + " (" + x.department_code_description + ")") + "</option>").ToArray());

            tbl_alarm_time_details alarmDet = new tbl_alarm_time_details(cuser);
            List<IntelWebField> bparams = new List<IntelWebField>();
            IntelWebField tierFld = alarmDet.Field("tier_code");
            tierFld.fieldValue = formTier;
            IntelWebField deptFld = alarmDet.Field("department_code");
            deptFld.fieldValue = formdept;
            IntelWebField fdateFld = new IntelWebField("todate", OleDbType.DBDate, 10, 10, 0, DataRowVersion.Current, false, formfdate);
            IntelWebField tdateFld = new IntelWebField("todate", OleDbType.DBDate, 10, 10, 0, DataRowVersion.Current, false, formtdate);
            bparams.Add(tierFld);
            bparams.Add(deptFld);
            bparams.Add(fdateFld);
            bparams.Add(tdateFld);

            List<IntelWebObject> alaramDets = alarmDet.Load("tier_code=? and department_code=? and alarm_date between ? and ?", "site_code,panel_code,alarm_device_code", bparams);
            if (alaramDets.Count > 0)
            {
                var distSites = alaramDets.Select(x => x.Field("site_code").fieldValue ?? "").Distinct().ToList();
                /* Distinct Sites get Address City, State, Country */
                lkup_site lkupsite = new lkup_site(cuser);
                bparams.Clear();
                string qs = "";
                foreach (string site in distSites)
                {
                    qs += ("?,");
                    IntelWebField fld = new IntelWebField("site_code", OleDbType.VarChar, 50, 50, 0, DataRowVersion.Current, false, null);
                    fld.fieldValue = site;
                    bparams.Add(fld);
                }
                bparams.Add(IntelWebParameter.GetParam("deptcode", OleDbType.VarChar, 50, formdept));
                if (qs.Length > 0) qs = qs.Substring(0, qs.Length - 1);
                List<IntelWebObject> Sites = lkupsite.Load("(site_code in (" + qs + ") or department_code=?)and city is not null ", "city", bparams);
                Dictionary<string, string> distCities = new Dictionary<string, string>();
                foreach (lkup_site site in Sites)
                {
                    string mapcity = site.city + (((site.state_code ?? "").Length > 0) ? "," + site.state_code.Trim() : "");
                    string siteDets = site.site_code + "\t" + site.address1 + "\t" + site.address2 + "\t" + site.city + "\t" + site.country_code;
                    if (distCities.ContainsKey(mapcity))
                    {
                        distCities[mapcity] = distCities[mapcity] + "\n" + siteDets;
                    }
                    else
                    {
                        distCities.Add(mapcity, siteDets);
                    }
                }

                string jsCities = "[";
                foreach (string key in distCities.Keys)
                {
                    jsCities += "{\"address\":\"" + key + "\",\"sitesHtml\":\"";
                    string[] arySites = distCities[key].Split('\n');
                    jsCities += "<table style=\\\"width:95%;\\\"><tr>";
                    foreach (string st in arySites)
                    {
                        string[] arySiteAddr = st.Split('\t');
                        jsCities += "<td>";
                        if (arySiteAddr.Length > 0)
                        {
                            jsCities += "<div><img style=\\\"cursor:pointer;\\\" onclick=\\\"showDiv(this, '" + arySiteAddr[0] + "');\\\" src=\'Images/house.png\' alt=\'site\' /> " + JSUtil.EnquoteJS(HttpUtility.HtmlEncode(arySiteAddr[0])) + " </div>";
                        }
                        if(arySiteAddr.Length > 3)
                        {
                            jsCities += "<div style=\\\"border:1px solid #999;padding:2px;white-space:nowrap;\\\"><div>" + JSUtil.EnquoteJS(HttpUtility.HtmlEncode(arySiteAddr[1])) + "</div><div>" + JSUtil.EnquoteJS(HttpUtility.HtmlEncode(arySiteAddr[2])) + "</div><div>" + JSUtil.EnquoteJS(HttpUtility.HtmlEncode(arySiteAddr[3] + " " + arySiteAddr[4])) + "</div></div>";
                        }
                        jsCities += "</td>";
                        //<br />" + st + "<br />   Peak:50 <br />Non-Peak:20</td>";
                    }
                    jsCities += "</tr></table>\"},";
                }
                if (distCities.Count > 0) jsCities = jsCities.Substring(0, jsCities.Length - 1);
                jsCities += "];";

                /* Map Script STARTS */
                ltrMapScript.Text = @"<script type=""text/javascript"">
                jsMapCities = " + jsCities + @"
                jsFromDate = '" + formfdate + @"';
                jsToDate = '" + formtdate + @"';
                function mapInit(){
                    if (GBrowserIsCompatible()) {
                        var map = new GMap2(document.getElementById('map_canvas'));
                        map.addControl(new GLargeMapControl());
                        map.addControl(new GMapTypeControl());
                        map.addControl(new GOverviewMapControl());
                        map.enableScrollWheelZoom();
                        map.setCenter(new GLatLng(39, -93), 4);
                        map.setUIToDefault();
                        var bounds = new GLatLngBounds();
                        geocoder = new GClientGeocoder();

                        function createMarker(address, thtml, cnt){
                            // Creates the  customized marker icon
                            var blueIcon = new GIcon(G_DEFAULT_ICON);
                            if(cnt % 2 == 0) {
                                blueIcon.image = ""http://iweb.vasbal.com/images/grn-pushpin.png"";
                            } else if(cnt % 3 == 0) {
                                blueIcon.image = ""http://iweb.vasbal.com/images/red-pushpin.png"";
                            } else {
                                blueIcon.image = ""http://iweb.vasbal.com/images/ylw-pushpin.png"";
                            }
                            blueIcon.iconSize = new GSize(32, 32);

                            // Set up our GMarkerOptions object
                            var markerOptions = { icon:blueIcon };

                            if(geocoder){
                                geocoder.getLatLng(address, function(point) {
                                        if (point) {
                                            var marker = new GMarker(point, markerOptions);
                                            map.addOverlay(marker);
                                            bounds.extend(marker.getPoint());
                                            var mhtml = thtml;
                                            var mklatlng = new GLatLng(marker.getPoint().lat(), marker.getPoint().lng());
                                            GEvent.addListener(marker, ""click"", function () { map.openInfoWindowHtml(mklatlng, '<div>'+mhtml+'</div>'); });
                                            GEvent.addListener(marker, ""mouseover"", function () { map.openInfoWindowHtml(mklatlng, '<div>'+mhtml+'</div>'); });

                                        }
                                });
                            }
                        }

                        map.clearOverlays();
                        var cnt = 0;
                        for(var x in jsMapCities){
                            createMarker(jsMapCities[x].address, jsMapCities[x].sitesHtml, cnt);
                            cnt++;
                        }
                    }
                }
                </script>";
                /* End Script */
            }
            else
            {
                ltrMessage.Text = @"<div class=""ui-widget"">
                <div class=""ui-state-error ui-corner-all"" style=""width:70%;margin-left:200px;margin-top: 5px; padding: 0 .7em;"">
                <p style=""height:35px;""><span class=""ui-icon ui-icon-alert"" style=""float: left; margin-right: .3em;""></span>
                <strong>Alert:</strong>There are no alarm details found between selected date period.</p></div></div>";

                ltrMapScript.Text = @"<script type=""text/javascript"">
                function mapInit(){
                    if (GBrowserIsCompatible()) {
                        var map = new GMap2(document.getElementById('map_canvas'));
                        map.addControl(new GLargeMapControl());
                        map.addControl(new GMapTypeControl());
                        map.addControl(new GOverviewMapControl());
                        map.enableScrollWheelZoom();
                        map.setCenter(new GLatLng(39, -93), 4);
                        map.setUIToDefault();
                    }
                }
                </script>";
            }
        }
Exemplo n.º 8
0
 private string fixFieldValueForOutput(object value, IntelWebField field)
 {
     if (field.parameter.DbType.Equals(System.Data.DbType.Date))
     {
         if (value == null || value.Equals(DateTime.MinValue))
         {
             return "(Null)";
         }
         DateTime m = (DateTime)value;
         return m.Month.ToString() + "/" + m.Day.ToString() + "/" + m.Year.ToString();
     }
     else
     {
         return (value ?? "").ToString();
     }
 }