Ejemplo n.º 1
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.");
            }
        }
Ejemplo 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 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.");
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int counter = 0;
            string objectType = Request.Form.Get("grid" + counter.ToString() + "_objectId");
            List<string> saveErrors = new List<string>();
            var GridReturnRecordInfo = new StringBuilder();
            if (!String.IsNullOrEmpty(objectType))
            {
                CurrentUser cuser = new CurrentUser();
                cuser.userName = "******";
                cuser.Load();

                WebGridController gridController = WebGridController.ControllerFromName(objectType, Request.Form, null, cuser);
                var myGrid = gridController.grid;
                string submittedName = Request.Form.Get("grid" + counter.ToString() + "_objectName");
                myGrid.gridName = submittedName; //change grid name to the value submitted - this supports multiple aliased gris - such as in Onboarding New Hire
                GridReturnRecordInfo.Append("{name:'" + JSUtil.EnquoteJS(myGrid.gridName) + "',records:");
                myGrid.LoadData();
                if (myGrid.loadErrors != null && myGrid.loadErrors.Count != 0)
                {
                    foreach (ApplicationException ae in myGrid.loadErrors)
                    {
                        saveErrors.Add(ae.Message);
                    }
                }

                myGrid.UpdateData();
                if (!string.IsNullOrEmpty(myGrid.updateDataErrors))
                {
                    Response.Write("{ok:false,errorMessage:'The save operation was cancelled because there were problems with the data that you submitted. " + JSUtil.EnquoteJS("\n" + myGrid.updateDataErrors) + "'}");
                    Response.End();
                }
                var myData = myGrid.data;
                var removeObjs = new List<IntelWebObject>();
                if (myData != null)
                {
                    foreach (IntelWebObject obj in myData)
                    {
                        if (obj.isDirty)
                        {
                            if (!myGrid.deleteQueue.Contains(obj))
                            { //don't save items marked for deletion
                                if (!obj.save())
                                {
                                    saveErrors.Add(obj.saveErrorText);
                                    if (obj.isNew)
                                    {
                                        removeObjs.Add(obj);

                                    }
                                    else
                                    {
                                        obj.revertChanges();
                                    }
                                }
                            }
                        }
                    }
                    foreach (IntelWebObject removeIt in removeObjs)
                    {
                        myGrid.data.Remove(removeIt);
                    }
                }
                GridReturnRecordInfo.Append(myGrid.dataJS());
                GridReturnRecordInfo.Append(",deletedKeys:[");
                var deleteBuilder = new StringBuilder();
                foreach (IntelWebObject apObj in myGrid.deleteQueue)
                {
                    var dKey = JSUtil.SerializeJSProperty(apObj.primaryKey);

                    if (!apObj.delete())
                    {
                        saveErrors.Add(apObj.saveErrorText);
                    }
                    else
                    {
                        deleteBuilder.Append(dKey);
                        deleteBuilder.Append(",");
                    }
                }
                if (deleteBuilder.Length > 0)
                {
                    deleteBuilder.Remove(deleteBuilder.Length - 1, 1);
                }
                GridReturnRecordInfo.Append(deleteBuilder.ToString());
                GridReturnRecordInfo.Append("]}");
                GridReturnRecordInfo.Append(",");
                counter++;
                objectType = Request.Form.Get("grid" + counter.ToString() + "_objectId");
            }
            else
            {
                saveErrors.Add("Object Id is null");
            }
            if (GridReturnRecordInfo.Length > 0) { GridReturnRecordInfo.Remove(GridReturnRecordInfo.Length - 1, 1); }
            string output = "{ok:[paramOK],errorMessage:'[paramErrorMessage]'"; //action:[paramAction] - is implemented in the gridBase.js 7/22/2010
            if (saveErrors.Count.Equals(0))
            {
                output = output.Replace("[paramOK]", "true");
                output = output.Replace("[paramErrorMessage]", "");

            }
            else
            {
                output = output.Replace("[paramOK]", "false");
                var sb = new StringBuilder();
                foreach (string em in saveErrors)
                {
                    sb.Append(JSUtil.EnquoteJS(em + "\n"));

                }
                output = output.Replace("[paramErrorMessage]", sb.ToString());
            }
            output += ",gridInfos:[" + GridReturnRecordInfo.ToString() + "]";
            output += "}";
            Response.Write(output);
        }
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            string SaveFile="";
            cuser = new CurrentUser();
            cuser.userName = "******";
            cuser.Load();
            lkup_tier tier = new lkup_tier(cuser);
            List<IntelWebObject> Tiers = tier.Load();
            this.ltrTiers.Text = string.Join("", Tiers.Cast<lkup_tier>().Select(x => "<option value=\"" + HttpUtility.HtmlEncode(x.tier_code) + "\">" + HttpUtility.HtmlEncode(x.tier_code) + "</option>").ToArray());

            if (IsPostBack)
            {
                bool createJob = false;
                if (Request.Files.Count > 0)
                {
                    HttpPostedFile File1 = Request.Files[0];
                    if (File1.ContentLength > 0)
                    {
                        SaveFile = System.IO.Path.GetFileName(File1.FileName);
                        if (System.IO.Path.GetExtension(SaveFile).Equals(".xls", StringComparison.InvariantCultureIgnoreCase))
                        {
                            string SaveLocation = Server.MapPath("Data") + "\\" + SaveFile;
                            try
                            {
                                File1.SaveAs(SaveLocation);
                                createJob = true;
                            }
                            catch (Exception ex)
                            {
                                ltrMessage.Text = "<div style=\"border:1px solid #FF0000;\">Error: " + HttpUtility.HtmlEncode(ex.Message) + "</div>";
                            }
                        }
                        else
                        {
                            ltrMessage.Text = "<div style=\"border:1px solid #FFFF00;\">Impoter support's only Excel files.</div>";
                        }
                    }
                    else
                    {
                        string xlsText = Request.Form["xlsTextArea"];
                        if (!string.IsNullOrEmpty(xlsText))
                        {
                            SaveFile = randomFile() + ".txt";
                            StreamWriter outfile = new StreamWriter(Server.MapPath("Data") + "\\" + SaveFile);
                            outfile.Write(xlsText);
                            outfile.Close();
                            createJob = true;
                        }
                    }
                }
                if (createJob)
                {
                    JobQ job = new JobQ(cuser);
                    job.jobType = "Import";
                    job.jobStatus = "active";
                    job.tiername = Request.Form["tiername"];
                    job.filename = SaveFile;
                    if (job.save())
                    {
                        ltrMessage.Text = "<div style=\"border:1px solid #00FF00;\">The file has been uploaded.</div>";
                    }
                    else
                    {
                        ltrMessage.Text = "<div style=\"border:1px solid #FF0000;\">Error: " + HttpUtility.HtmlEncode(job.saveErrorText) + "</div>";
                    }
                }
            }

            ltrJobStatus.Text = JobStatusHTML();
        }
Ejemplo n.º 5
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>";
            }
        }
Ejemplo n.º 6
0
        public void doImport(bool preview)
        {
            if (!File.Exists(fullFileName))
            {
                error = new ImportError();
                error.errorMessage = fullFileName + " does not exist.";
                _importproblems.Add(error);
                return;
            }
            CurrentUser cuser = new CurrentUser();
            cuser.userName = this.UserName;
            cuser.Load();
            using (StreamReader sr = File.OpenText(fullFileName))
            {
                String inputLine;
                /* Read Header */
                inputLine = sr.ReadLine();
                if (inputLine != null)
                {
                    Dictionary<string, string> headers = this.deviceHeaders;
                    string[] lineHeaders = inputLine.Split('\t');
                    int col = 0;
                    foreach (string str in lineHeaders)
                    {
                        if (headers.ContainsKey(str))
                        {
                            headers[str] = col.ToString();
                            col++;
                        }
                    }
                    Dictionary<string, string> mapFields = this.fieldsMap;
                    string deptcode="", sitecode="", panelcode="", alarmcode="", alarmtype="";
                    _line = 0;
                    while ((inputLine = sr.ReadLine()) != null)
                    {
                        /* Read File Each Line */
                        string[] lineFields = inputLine.Split('\t');
                        _line++;
                        tbl_alarm_time_details alarmDet = new tbl_alarm_time_details(cuser);
                        foreach(string fieldname in headers.Keys)
                        {

                            int idx;
                            int.TryParse(headers[fieldname], out idx);
                            object value = lineFields[idx];

                            PropertyInfo pi = alarmDet.GetType().GetProperty(mapFields[fieldname]);
                            if (pi != null)
                            {
                                value = IntelWebDataConverter.toType(lineFields[idx], pi.PropertyType, "Line: [" + _line.ToString() + "] Field: [" + fieldname + "] Value: [" + (lineFields[idx] ?? "") + "]");

                                pi.SetValue(alarmDet, value, null);

                                if (fieldname.Equals("DEPT/REG"))
                                {
                                    deptcode = value.ToString();
                                }

                                if (fieldname.Equals("SITE"))
                                {
                                    sitecode = value.ToString();
                                }

                                if (fieldname.Equals("PANEL"))
                                {
                                    panelcode = value.ToString();
                                }

                                if (fieldname.Equals("ALARM DEVICE"))
                                {
                                    alarmcode = value.ToString();
                                }
                                if (fieldname.Equals("ALARM TYPE"))
                                {
                                    alarmtype = value.ToString();
                                }
                            }
                        }
                        UpSert(deptcode, sitecode, panelcode, alarmcode, alarmtype, cuser);
                        alarmDet.tier_code = tierCode;
                        alarmDet.LoadSingle();
                        bool isnew = alarmDet.isNew;
                        string desc = alarmDet.ChangedFieldsDescription();
                        if (!alarmDet.save())
                        {
                            error = new ImportError();
                            error.errorMessage = alarmDet.saveErrorText;
                            error.fieldFQR = alarmDet.friendlySingluarName();
                            error.lineNumber = _line;
                            _importproblems.Add(error);
                        }
                        else
                        {
                            iitem = new ImportedItem(_line, isnew, alarmDet.friendlySingluarName(), desc);
                            _importeditems.Add(iitem);
                        }
                    }
                }
            }
            _enddate = DateTime.Now;
        }
Ejemplo n.º 7
0
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            CurrentUser cuser = new CurrentUser();
            cuser.userName = "******";
            cuser.Load();
            WebGridController siteGC = WebGridController.ControllerFromName("lkup_site", Request.Form, this.Form.Controls, cuser);
            lkup_department lkupDept = new lkup_department(cuser);
            List<IntelWebObject> lkupDepts = lkupDept.Load();
            this.ltrDepts.Text = string.Join("", lkupDepts.Cast<lkup_department>().Select(x=>"<option value=\"" + HttpUtility.HtmlEncode(x.department_code) + "\">" + HttpUtility.HtmlEncode(x.department_code + " (" + x.department_code_description + ")") + "</option>").ToArray());

            lkup_site lkupSite = new lkup_site(cuser);
            List<IntelWebObject> lkupSites = lkupSite.Load("","department_code,site_code");
            siteGC.grid.data = lkupSites;

            siteGC.grid.uiFormShowJS = @"function(){
            $('#divSiteEntry').dialog({width:750,modal:true,title:'Site/Building Info',close:function(){webGrid.removeNewItems()}});$('#site_code').focus();}";
            siteGC.grid.afterSubmitJS = @"function(result,grid){
                                              if(result.ok && result.gridInfos){
                                                webGrid.mergeGridInfos(result.gridInfos);
                                                webGrid.drawFilteredRows(grid,function(record){
                                                  if((typeof record.fields.markedforremoval != undefined) && !record.fields.markedforremoval){
                                                    return true;
                                                  }
                                                return false;
                                                });
                                               	if($('#divSiteEntry').is(':visible')){
                                                    try{
                                                        $('#divSiteEntry').dialog('close');
                                                    }
                                                    catch(ex){}
                                                }
                                              }
                                            }";

            siteGC.grid.uiFormName = "theform";
            var gtable = new WebGridTable();
            gtable.UIHeaderText = "Site / Building Information";
            gtable.tableId = "tblFieldsId";
            gtable.Grid = siteGC.grid;
            var myButtonFunction = new Func<IntelWebObject, object>((obj) =>
            {
                return @"<a href=""javascript:void(0);"" title=""Edit Site"" onclick=""editSite([gridName],[recordIndex])"" ><img alt=""Edit"" title=""Edit Site"" src=""Images/table_edit.png""></a>&nbsp;<a href=""javascript:void(0);"" title=""Delete Site"" onclick=""delSite([gridName],[recordIndex])"" ><img title=""Delete Site"" src=""Images/delete.png"" alt=""delete""></a>";
            });

            gtable.extraColumns.Add(new WebGridTable.extraColumn()
            {
                fieldTemplate = new DisplayField()
                {
                    submitField = false
                    ,
                    fieldName = "EditButtons"
                    ,
                    formatFunction = myButtonFunction
                    ,
                    isHeaderField = true
                    ,
                    jsFormatFunction = @"return '<a href=""javascript:void(0);"" title=""Edit Site"" onclick=""editSite([gridName],[recordIndex])"" ><img alt=""Edit"" title=""Edit Site"" src=""Images/table_edit.png""></a>&nbsp;<a href=""javascript:void(0);"" title=""Delete Site"" onclick=""delSite([gridName],[recordIndex])"" ><img title=""Delete Site"" src=""Images/delete.png"" alt=""delete""></a> '"
                }
            });

            ltrGrid.Text = "<div class=\"centered\">" + gtable.tableUI() + "</div>";
            ltrGridScript.Text = "<script type=\"text/javascript\">" + siteGC.grid.gridScript() + "</script>\n" + gtable.tableScript();
        }