)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » FieldTnmdSupplier (Ia.Ftn.Wa.Models.Maintenance)

Public general use code classes and xml files that we've compiled and used over the years:

    1: using Microsoft.AspNetCore.Identity;
    2: using Microsoft.AspNetCore.Mvc;
    3: using Microsoft.AspNetCore.Mvc.Rendering;
    4: using Microsoft.EntityFrameworkCore;
    5: using System.Data;
    6: using System.Diagnostics.Eventing.Reader;
    7: using System.Net;
    8: using System.Security.Policy;
    9: using System.Text.RegularExpressions;
   10:  
   11: namespace Ia.Ftn.Wa.Models.Maintenance
   12: {
   13:     ////////////////////////////////////////////////////////////////////////////
   14:  
   15:     /// <summary publish="true">
   16:     ///
   17:     /// </summary>
   18:     /// 
   19:     /// <remarks> 
   20:     /// Copyright © 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   21:     ///
   22:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   23:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   24:     ///
   25:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   26:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   27:     /// 
   28:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   29:     /// 
   30:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   31:     /// </remarks> 
   32:     public static class FieldTnmdSupplier
   33:     {
   34:         private static bool selectAllCheckBoxListItems;
   35:         private static Ia.Ftn.Cl.Models.StaffIdentityUser staffIdentityUser;
   36:         private static List<string> actionCheckBoxSelectedItemValueList;
   37:  
   38:         ////////////////////////////////////////////////////////////////////////////
   39:  
   40:         /// <summary>
   41:         ///
   42:         /// </summary>
   43:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplierViewModel fieldTnmdSupplierViewModel)
   44:         {
   45:             /*
   46:             staff = Ia.Ftn.Cl.Models.Data.Staff.MembershipUser;
   47: 
   48:             if (Session["actionCheckBoxSelectedItemValueList"] != null)
   49:             {
   50:                 actionCheckBoxSelectedItemValueList = (List<string>)Session["actionCheckBoxSelectedItemValueList"];
   51: 
   52:                 selectAllCheckBoxListItems = false;
   53:             }
   54:             else
   55:             {
   56:                 actionCheckBoxSelectedItemValueList = new List<string>();
   57:                 Session["actionCheckBoxSelectedItemValueList"] = actionCheckBoxSelectedItemValueList;
   58: 
   59:                 selectAllCheckBoxListItems = true;
   60:             }
   61: 
   62:                 FrameworkSelectList_ViewModel();
   63:                 ReportGridView_DataBind();
   64: 
   65: 
   66:             sendEmailButton.Enabled = Ia.Ftn.Cl.Models.Business.Authority.StaffCanSendFieldTnmdSupplierWorkorderEmail(staff);
   67:             */
   68:  
   69:             var list = (from f in Ia.Ftn.Cl.Models.Data.Administration.FrameworkList
   70:                         where f.Type == "division" && (f.Parent.Parent.ArabicName == "قطاع خدمات المشتركين" && f.Sites.Count > 0 || f.Parent.ArabicName == "إدارة صيانة الشبكة الهاتفية")
   71:                         select f).ToList();
   72:  
   73:             var list1 = new List<SelectListItem>();
   74:             list1.Add(new SelectListItem("All divisions (كل المراقبات)", "0"));
   75:  
   76:             foreach (var l in list)
   77:             {
   78:                 list1.Add(new SelectListItem(l.ArabicName, l.Id));
   79:             }
   80:  
   81:             fieldTnmdSupplierViewModel.FrameworkSelectList = new SelectList(list, "Id", "ArabicName");
   82:         }
   83:  
   84:         /*
   85:         ////////////////////////////////////////////////////////////////////////////
   86: 
   87:         /// <summary>
   88:         ///
   89:         /// </summary>
   90:         protected void FrameworkDropDownList_SelectedIndexChanged()
   91:         {
   92:             ReportGridView_DataBind();
   93:         }
   94:         */
   95:  
   96:         ////////////////////////////////////////////////////////////////////////////
   97:  
   98:         /// <summary>
   99:         ///
  100:         /// </summary>
  101:         private static void ActionCheckBoxList_SelectedIndexChanged()
  102:         {
  103:             /*
  104:             actionCheckBoxSelectedItemValueList = new List<string>();
  105: 
  106:             foreach (ListItem listItem in actionCheckBoxList.Items)
  107:             {
  108:                 if (listItem.Selected) actionCheckBoxSelectedItemValueList.Add(listItem.Value);
  109:             }
  110: 
  111:             Session["actionCheckBoxSelectedItemValueList"] = actionCheckBoxSelectedItemValueList;
  112: 
  113:             ReportGridView_DataBind();
  114:             */
  115:         }
  116:  
  117:         ////////////////////////////////////////////////////////////////////////////
  118:  
  119:         /// <summary>
  120:         ///
  121:         /// </summary>
  122:         private static List<string> FrameworkAndStaffIdList(string frameworkId)
  123:         {
  124:             List<string> list;
  125:  
  126:             if (string.IsNullOrEmpty(frameworkId)) list = Ia.Ftn.Cl.Models.Business.Administration.Framework.FrameworkAndStaffIdList();
  127:             else list = Ia.Ftn.Cl.Models.Business.Administration.Framework.FrameworkAndStaffIdList(frameworkId);
  128:  
  129:             return list;
  130:         }
  131:  
  132:         ////////////////////////////////////////////////////////////////////////////
  133:  
  134:         /// <summary>
  135:         ///
  136:         /// </summary>
  137:         public static string Post(ref Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplierViewModel fieldTnmdSupplierViewModel, string commandName)
  138:         {
  139:             string url;
  140:  
  141:             fieldTnmdSupplierViewModel.Result = new Ia.Cl.Models.Result();
  142:  
  143:             /*
  144:             var processId = fieldTnmdSupplierViewModel.FromSelectedValue;
  145: 
  146:             var result = new Ia.Cl.Models.Result();
  147: 
  148:             if (int.TryParse(performanceViewModel.FromSelectedValue, out int daysAgo)) { }
  149:             else daysAgo = 0;
  150: 
  151:             var list0 = Ia.Ftn.Cl.Models.Data.Administration.StaffAndFrameworkPerformanceReport(daysAgo);
  152: 
  153:             var list = list0.Where(u => u.FirstAndMiddleName != "غير معرف");
  154: 
  155:             performanceViewModel.PerformanceList = list.OrderByDescending(u => u.Attempted).ThenByDescending(u => u.Resolved).ToList();
  156:             */
  157:  
  158:             var frameworkId = fieldTnmdSupplierViewModel.FrameworkSelectedValue;
  159:             var frameworkAndStaffIdList = FrameworkAndStaffIdList(frameworkId);
  160:  
  161:             if (frameworkAndStaffIdList.Count > 0)
  162:             {
  163:                 var list = Ia.Ftn.Cl.Models.Ui.Report.ReportWithReportOpenStatusByUserIdListAndFrameworkIdList(frameworkAndStaffIdList, frameworkId);
  164:  
  165:                 ActionCheckBoxList_DataBind(list);
  166:  
  167:                 list = (from l in list
  168:                         where actionCheckBoxSelectedItemValueList.Contains(l.Report.LastReportHistory.Action.ToString())
  169:                         select l).ToList();
  170:  
  171:                 fieldTnmdSupplierViewModel.FieldTnmdSupplierReportAccessServiceRequestList = list;
  172:  
  173:                 fieldTnmdSupplierViewModel.Result.AddSuccess(""); // Note: this will display reports that are OPEN, and CLOSED reports within the last " + closed_display_ddl.SelectedItem.Text + " only"; // hour only";
  174:             }
  175:             else
  176:             {
  177:             }
  178:  
  179:  
  180:             if (commandName == "producePrintForm")
  181:             {
  182:                url = ProducePrintForm_Command(frameworkId, frameworkAndStaffIdList);
  183:             }
  184:             else if (commandName == "sendEmail")
  185:             {
  186:                 url = SendEmail_Command(frameworkId, frameworkAndStaffIdList);
  187:             }
  188:             else
  189:             {
  190:                 url = string.Empty;
  191:             }
  192:  
  193:             return url;
  194:         }
  195:  
  196:         ////////////////////////////////////////////////////////////////////////////
  197:  
  198:         /// <summary>
  199:         ///
  200:         /// </summary>
  201:         private static void ActionCheckBoxList_DataBind(List<Ia.Ftn.Cl.Models.Ui.ReportAccessServiceRequest> list)
  202:         {
  203:             /*
  204:             int id;
  205:             var actionCheckBoxListItemList = new List<ListItem>();
  206: 
  207:             var actionColoredDictionary = Ia.Ftn.Cl.Models.Data.Report.ActionColoredDictionary;
  208:             var list0 = new List<int>();
  209: 
  210:             foreach (var rasr in list)
  211:             {
  212:                 id = rasr.Report.LastReportHistory.Action;
  213: 
  214:                 if (!list0.Contains(id))
  215:                 {
  216:                     list0.Add(id);
  217: 
  218:                     actionCheckBoxListItemList.Add(new ListItem { Text = actionColoredDictionary[id], Value = id.ToString(), Selected = false });
  219:                 }
  220:             }
  221: 
  222:             actionCheckBoxList.DataSource = actionCheckBoxListItemList;
  223:             actionCheckBoxList.DataTextField = "Text";
  224:             actionCheckBoxList.DataValueField = "Value";
  225:             actionCheckBoxList.DataBind();
  226: 
  227:             if (selectAllCheckBoxListItems)
  228:             {
  229:                 foreach (var listItem in actionCheckBoxListItemList)
  230:                 {
  231:                     actionCheckBoxList.Items.FindByValue(listItem.Value).Selected = true;
  232:                     actionCheckBoxSelectedItemValueList.Add(listItem.Value);
  233:                 }
  234: 
  235:                 Session["actionCheckBoxSelectedItemValueList"] = actionCheckBoxSelectedItemValueList;
  236:             }
  237:             else
  238:             {
  239:                 foreach (var listItem in actionCheckBoxListItemList)
  240:                 {
  241:                     actionCheckBoxList.Items.FindByValue(listItem.Value).Selected = actionCheckBoxSelectedItemValueList.Contains(listItem.Value) ? true : false;
  242:                 }
  243:             }
  244:             */
  245:         }
  246:  
  247:         ////////////////////////////////////////////////////////////////////////////
  248:         ////////////////////////////////////////////////////////////////////////////
  249:  
  250:         /// <summary>
  251:         /// 
  252:         /// </summary>
  253:         private static string ProducePrintForm_Command(string frameworkId, List<string> frameworkAndStaffIdList)
  254:         {
  255:             string url;
  256:  
  257:             if (frameworkAndStaffIdList.Count > 0)
  258:             {
  259:                 url = "/contact/print?formName=field-tnmd-supplier-workorder-form&userId="
  260:                     + WebUtility.UrlEncode(string.Join("+", frameworkAndStaffIdList))
  261:                     + "&frameworkId=" + WebUtility.UrlEncode(frameworkId);
  262:                     //+ "&actionCheckBoxSelectedItemValueList=" + WebUtility.UrlEncode(string.Join("+", actionCheckBoxSelectedItemValueList));
  263:             }
  264:             else url = string.Empty;
  265:  
  266:             return url;
  267:         }
  268:  
  269:         ////////////////////////////////////////////////////////////////////////////
  270:  
  271:         /// <summary>
  272:         /// 
  273:         /// </summary>
  274:         private static string SendEmail_Command(string frameworkId, List<string> frameworkAndStaffIdList)
  275:         {
  276:             string url;
  277:  
  278:             if (frameworkAndStaffIdList.Count > 0)
  279:             {
  280:                 url = "/contact/email?formName=field-tnmd-supplier-workorder-email-form&userId="
  281:                     + WebUtility.UrlEncode(string.Join("+", frameworkAndStaffIdList))
  282:                     + "&frameworkId=" + WebUtility.UrlEncode(frameworkId);
  283:                     //+ "&actionCheckBoxSelectedItemValueList=" + WebUtility.UrlEncode(string.Join("+", actionCheckBoxSelectedItemValueList));
  284:             }
  285:             else url = string.Empty;
  286:  
  287:             return url;
  288:         }
  289:  
  290:         /*
  291:         ////////////////////////////////////////////////////////////////////////////
  292: 
  293:         /// <summary>
  294:         ///
  295:         /// </summary>
  296:         private void QrCode_DataBind()
  297:         {
  298:             int frameworkId;
  299:             Ia.Cl.Models.QrCode qrCode;
  300:             List<Guid> userIdList;
  301: 
  302:             frameworkId = int.Parse(frameworkDropDownList.SelectedItem.Value);
  303: 
  304:             if (radioButtonList.SelectedItem.Value == "division") userIdList = Ia.Ftn.Cl.Models.Business.Authority.FieldFrameworkAndStaffGuidList;
  305:             else if (radioButtonList.SelectedItem.Value == "tnmd") userIdList = Ia.Ftn.Cl.Models.Business.Authority.TnmdFrameworkAndStaffGuidList;
  306:             else if (radioButtonList.SelectedItem.Value == "nokia") userIdList = Ia.Ftn.Cl.Models.Business.Authority.NokiaFrameworkAndStaffGuidList;
  307:             else if (radioButtonList.SelectedItem.Value == "huawei") userIdList = Ia.Ftn.Cl.Models.Business.Authority.HuaweiFrameworkAndStaffGuidList;
  308:             else userIdList = new List<Guid>();
  309: 
  310:             var text = Ia.Ftn.Wa.Model.Business.Administration.PrepareFieldTnmdSupplierWorkorderQrCodeTextForm(userIdList, frameworkId);
  311: 
  312:             var chat = (from c in Ia.Ftn.Cl.Models.Telegram.Chat.List
  313:                         where c.Framework != null && c.Framework.Sites.Any(u => u.Id == frameworkId)
  314:                         select c).FirstOrDefault();
  315: 
  316:             if (chat != null)
  317:             {
  318:                 qrCode = new Ia.Cl.Models.QrCode(text, "SlateGray", "White", chat.LogoImageAbsolutePathUrl);
  319:             }
  320:             else
  321:             {
  322:                 qrCode = new Ia.Cl.Models.QrCode(text, "SlateGray", "White", Ia.Ftn.Cl.Models.Business.Administration.LogoImageAbsolutePathUrl);
  323:             }
  324: 
  325:             qrCodeImage.AlternateText = text;
  326:             qrCodeImage.ImageUrl = qrCode.ImageUrlDataFormat;
  327:         }
  328:         */
  329:  
  330:         ////////////////////////////////////////////////////////////////////////////
  331:         ////////////////////////////////////////////////////////////////////////////
  332:     }
  333:  
  334:     ////////////////////////////////////////////////////////////////////////////
  335:     ////////////////////////////////////////////////////////////////////////////
  336: }