)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     /// </remarks> 
   22:     public static class FieldTnmdSupplier
   23:     {
   24:         private static bool selectAllCheckBoxListItems;
   25:         private static Ia.Ftn.Cl.Models.StaffIdentityUser staffIdentityUser;
   26:         private static List<string> actionCheckBoxSelectedItemValueList;
   27:  
   28:         ////////////////////////////////////////////////////////////////////////////
   29:  
   30:         /// <summary>
   31:         ///
   32:         /// </summary>
   33:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplierViewModel fieldTnmdSupplierViewModel)
   34:         {
   35:             /*
   36:             staff = Ia.Ftn.Cl.Models.Data.Staff.MembershipUser;
   37: 
   38:             if (Session["actionCheckBoxSelectedItemValueList"] != null)
   39:             {
   40:                 actionCheckBoxSelectedItemValueList = (List<string>)Session["actionCheckBoxSelectedItemValueList"];
   41: 
   42:                 selectAllCheckBoxListItems = false;
   43:             }
   44:             else
   45:             {
   46:                 actionCheckBoxSelectedItemValueList = new List<string>();
   47:                 Session["actionCheckBoxSelectedItemValueList"] = actionCheckBoxSelectedItemValueList;
   48: 
   49:                 selectAllCheckBoxListItems = true;
   50:             }
   51: 
   52:                 FrameworkSelectList_ViewModel();
   53:                 ReportGridView_DataBind();
   54: 
   55: 
   56:             sendEmailButton.Enabled = Ia.Ftn.Cl.Models.Business.Authority.StaffCanSendFieldTnmdSupplierWorkorderEmail(staff);
   57:             */
   58:  
   59:             var list = (from f in Ia.Ftn.Cl.Models.Data.Administration.FrameworkList
   60:                         where f.Type == "division" && (f.Parent.Parent.ArabicName == "قطاع خدمات المشتركين" && f.Sites.Count > 0 || f.Parent.ArabicName == "إدارة صيانة الشبكة الهاتفية")
   61:                         select f).ToList();
   62:  
   63:             var list1 = new List<SelectListItem>();
   64:             list1.Add(new SelectListItem("All divisions (كل المراقبات)", "0"));
   65:  
   66:             foreach (var l in list)
   67:             {
   68:                 list1.Add(new SelectListItem(l.ArabicName, l.Id));
   69:             }
   70:  
   71:             fieldTnmdSupplierViewModel.FrameworkSelectList = new SelectList(list, "Id", "ArabicName");
   72:         }
   73:  
   74:         /*
   75:         ////////////////////////////////////////////////////////////////////////////
   76: 
   77:         /// <summary>
   78:         ///
   79:         /// </summary>
   80:         protected void FrameworkDropDownList_SelectedIndexChanged()
   81:         {
   82:             ReportGridView_DataBind();
   83:         }
   84:         */
   85:  
   86:         ////////////////////////////////////////////////////////////////////////////
   87:  
   88:         /// <summary>
   89:         ///
   90:         /// </summary>
   91:         private static void ActionCheckBoxList_SelectedIndexChanged()
   92:         {
   93:             /*
   94:             actionCheckBoxSelectedItemValueList = new List<string>();
   95: 
   96:             foreach (ListItem listItem in actionCheckBoxList.Items)
   97:             {
   98:                 if (listItem.Selected) actionCheckBoxSelectedItemValueList.Add(listItem.Value);
   99:             }
  100: 
  101:             Session["actionCheckBoxSelectedItemValueList"] = actionCheckBoxSelectedItemValueList;
  102: 
  103:             ReportGridView_DataBind();
  104:             */
  105:         }
  106:  
  107:         ////////////////////////////////////////////////////////////////////////////
  108:  
  109:         /// <summary>
  110:         ///
  111:         /// </summary>
  112:         private static List<string> FrameworkAndStaffIdList(string frameworkId)
  113:         {
  114:             List<string> list;
  115:  
  116:             if (string.IsNullOrEmpty(frameworkId)) list = Ia.Ftn.Cl.Models.Business.Administration.Framework.FrameworkAndStaffIdList();
  117:             else list = Ia.Ftn.Cl.Models.Business.Administration.Framework.FrameworkAndStaffIdList(frameworkId);
  118:  
  119:             return list;
  120:         }
  121:  
  122:         ////////////////////////////////////////////////////////////////////////////
  123:  
  124:         /// <summary>
  125:         ///
  126:         /// </summary>
  127:         public static string Post(ref Ia.Ftn.Wa.Models.Maintenance.FieldTnmdSupplierViewModel fieldTnmdSupplierViewModel, string commandName)
  128:         {
  129:             string url;
  130:  
  131:             fieldTnmdSupplierViewModel.Result = new Ia.Cl.Models.Result();
  132:  
  133:             /*
  134:             var processId = fieldTnmdSupplierViewModel.FromSelectedValue;
  135: 
  136:             var result = new Ia.Cl.Models.Result();
  137: 
  138:             if (int.TryParse(performanceViewModel.FromSelectedValue, out int daysAgo)) { }
  139:             else daysAgo = 0;
  140: 
  141:             var list0 = Ia.Ftn.Cl.Models.Data.Administration.StaffAndFrameworkPerformanceReport(daysAgo);
  142: 
  143:             var list = list0.Where(u => u.FirstAndMiddleName != "غير معرف");
  144: 
  145:             performanceViewModel.PerformanceList = list.OrderByDescending(u => u.Attempted).ThenByDescending(u => u.Resolved).ToList();
  146:             */
  147:  
  148:             var frameworkId = fieldTnmdSupplierViewModel.FrameworkSelectedValue;
  149:             var frameworkAndStaffIdList = FrameworkAndStaffIdList(frameworkId);
  150:  
  151:             if (frameworkAndStaffIdList.Count > 0)
  152:             {
  153:                 var list = Ia.Ftn.Cl.Models.Ui.Report.ReportWithReportOpenStatusByUserIdListAndFrameworkIdList(frameworkAndStaffIdList, frameworkId);
  154:  
  155:                 ActionCheckBoxList_DataBind(list);
  156:  
  157:                 list = (from l in list
  158:                         where actionCheckBoxSelectedItemValueList.Contains(l.Report.LastReportHistory.Action.ToString())
  159:                         select l).ToList();
  160:  
  161:                 fieldTnmdSupplierViewModel.FieldTnmdSupplierReportAccessServiceRequestList = list;
  162:  
  163:                 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";
  164:             }
  165:             else
  166:             {
  167:             }
  168:  
  169:  
  170:             if (commandName == "producePrintForm")
  171:             {
  172:                url = ProducePrintForm_Command(frameworkId, frameworkAndStaffIdList);
  173:             }
  174:             else if (commandName == "sendEmail")
  175:             {
  176:                 url = SendEmail_Command(frameworkId, frameworkAndStaffIdList);
  177:             }
  178:             else
  179:             {
  180:                 url = string.Empty;
  181:             }
  182:  
  183:             return url;
  184:         }
  185:  
  186:         ////////////////////////////////////////////////////////////////////////////
  187:  
  188:         /// <summary>
  189:         ///
  190:         /// </summary>
  191:         private static void ActionCheckBoxList_DataBind(List<Ia.Ftn.Cl.Models.Ui.ReportAccessServiceRequest> list)
  192:         {
  193:             /*
  194:             int id;
  195:             var actionCheckBoxListItemList = new List<ListItem>();
  196: 
  197:             var actionColoredDictionary = Ia.Ftn.Cl.Models.Data.Report.ActionColoredDictionary;
  198:             var list0 = new List<int>();
  199: 
  200:             foreach (var rasr in list)
  201:             {
  202:                 id = rasr.Report.LastReportHistory.Action;
  203: 
  204:                 if (!list0.Contains(id))
  205:                 {
  206:                     list0.Add(id);
  207: 
  208:                     actionCheckBoxListItemList.Add(new ListItem { Text = actionColoredDictionary[id], Value = id.ToString(), Selected = false });
  209:                 }
  210:             }
  211: 
  212:             actionCheckBoxList.DataSource = actionCheckBoxListItemList;
  213:             actionCheckBoxList.DataTextField = "Text";
  214:             actionCheckBoxList.DataValueField = "Value";
  215:             actionCheckBoxList.DataBind();
  216: 
  217:             if (selectAllCheckBoxListItems)
  218:             {
  219:                 foreach (var listItem in actionCheckBoxListItemList)
  220:                 {
  221:                     actionCheckBoxList.Items.FindByValue(listItem.Value).Selected = true;
  222:                     actionCheckBoxSelectedItemValueList.Add(listItem.Value);
  223:                 }
  224: 
  225:                 Session["actionCheckBoxSelectedItemValueList"] = actionCheckBoxSelectedItemValueList;
  226:             }
  227:             else
  228:             {
  229:                 foreach (var listItem in actionCheckBoxListItemList)
  230:                 {
  231:                     actionCheckBoxList.Items.FindByValue(listItem.Value).Selected = actionCheckBoxSelectedItemValueList.Contains(listItem.Value) ? true : false;
  232:                 }
  233:             }
  234:             */
  235:         }
  236:  
  237:         ////////////////////////////////////////////////////////////////////////////
  238:         ////////////////////////////////////////////////////////////////////////////
  239:  
  240:         /// <summary>
  241:         /// 
  242:         /// </summary>
  243:         private static string ProducePrintForm_Command(string frameworkId, List<string> frameworkAndStaffIdList)
  244:         {
  245:             string url;
  246:  
  247:             if (frameworkAndStaffIdList.Count > 0)
  248:             {
  249:                 url = "/contact/print?formName=field-tnmd-supplier-workorder-form&userId="
  250:                     + WebUtility.UrlEncode(string.Join("+", frameworkAndStaffIdList))
  251:                     + "&frameworkId=" + WebUtility.UrlEncode(frameworkId);
  252:                     //+ "&actionCheckBoxSelectedItemValueList=" + WebUtility.UrlEncode(string.Join("+", actionCheckBoxSelectedItemValueList));
  253:             }
  254:             else url = string.Empty;
  255:  
  256:             return url;
  257:         }
  258:  
  259:         ////////////////////////////////////////////////////////////////////////////
  260:  
  261:         /// <summary>
  262:         /// 
  263:         /// </summary>
  264:         private static string SendEmail_Command(string frameworkId, List<string> frameworkAndStaffIdList)
  265:         {
  266:             string url;
  267:  
  268:             if (frameworkAndStaffIdList.Count > 0)
  269:             {
  270:                 url = "/contact/email?formName=field-tnmd-supplier-workorder-email-form&userId="
  271:                     + WebUtility.UrlEncode(string.Join("+", frameworkAndStaffIdList))
  272:                     + "&frameworkId=" + WebUtility.UrlEncode(frameworkId);
  273:                     //+ "&actionCheckBoxSelectedItemValueList=" + WebUtility.UrlEncode(string.Join("+", actionCheckBoxSelectedItemValueList));
  274:             }
  275:             else url = string.Empty;
  276:  
  277:             return url;
  278:         }
  279:  
  280:         /*
  281:         ////////////////////////////////////////////////////////////////////////////
  282: 
  283:         /// <summary>
  284:         ///
  285:         /// </summary>
  286:         private void QrCode_DataBind()
  287:         {
  288:             int frameworkId;
  289:             Ia.Cl.Models.QrCode qrCode;
  290:             List<Guid> userIdList;
  291: 
  292:             frameworkId = int.Parse(frameworkDropDownList.SelectedItem.Value);
  293: 
  294:             if (radioButtonList.SelectedItem.Value == "division") userIdList = Ia.Ftn.Cl.Models.Business.Authority.FieldFrameworkAndStaffGuidList;
  295:             else if (radioButtonList.SelectedItem.Value == "tnmd") userIdList = Ia.Ftn.Cl.Models.Business.Authority.TnmdFrameworkAndStaffGuidList;
  296:             else if (radioButtonList.SelectedItem.Value == "nokia") userIdList = Ia.Ftn.Cl.Models.Business.Authority.NokiaFrameworkAndStaffGuidList;
  297:             else if (radioButtonList.SelectedItem.Value == "huawei") userIdList = Ia.Ftn.Cl.Models.Business.Authority.HuaweiFrameworkAndStaffGuidList;
  298:             else userIdList = new List<Guid>();
  299: 
  300:             var text = Ia.Ftn.Wa.Model.Business.Administration.PrepareFieldTnmdSupplierWorkorderQrCodeTextForm(userIdList, frameworkId);
  301: 
  302:             var chat = (from c in Ia.Ftn.Cl.Models.Telegram.Chat.List
  303:                         where c.Framework != null && c.Framework.Sites.Any(u => u.Id == frameworkId)
  304:                         select c).FirstOrDefault();
  305: 
  306:             if (chat != null)
  307:             {
  308:                 qrCode = new Ia.Cl.Models.QrCode(text, "SlateGray", "White", chat.LogoImageAbsolutePathUrl);
  309:             }
  310:             else
  311:             {
  312:                 qrCode = new Ia.Cl.Models.QrCode(text, "SlateGray", "White", Ia.Ftn.Cl.Models.Business.Administration.LogoImageAbsolutePathUrl);
  313:             }
  314: 
  315:             qrCodeImage.AlternateText = text;
  316:             qrCodeImage.ImageUrl = qrCode.ImageUrlDataFormat;
  317:         }
  318:         */
  319:  
  320:         ////////////////////////////////////////////////////////////////////////////
  321:         ////////////////////////////////////////////////////////////////////////////
  322:     }
  323:  
  324:     ////////////////////////////////////////////////////////////////////////////
  325:     ////////////////////////////////////////////////////////////////////////////
  326: }