public ActionResult Edit([Bind(Exclude = "Image")] ServiceHeader serviceHeader, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        serviceHeader.Image = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);


                        db.Entry(serviceHeader).State = EntityState.Modified;
                        db.SaveChanges();

                        return(RedirectToAction("Index", "ServiceHeader"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }
            return(View());
        }
Пример #2
0
 public void SaveServiceHeader(ServiceHeader serviceheader)
 {
     if (serviceheader.HeaderId == 0)
     {
         context.ServiceHeaders.Add(serviceheader);
     }
     else
     {
         ServiceHeader dbentry = context.ServiceHeaders.Find(serviceheader.HeaderId);
         if (dbentry != null)
         {
             dbentry.Category          = serviceheader.Category;
             dbentry.CategoryLabel     = serviceheader.CategoryLabel;
             dbentry.Description       = serviceheader.Description;
             dbentry.HomeCategory      = serviceheader.HomeCategory;
             dbentry.HomeCategoryLabel = serviceheader.HomeCategoryLabel;
             dbentry.ImageUrl          = serviceheader.ImageUrl;
             dbentry.IsActive          = serviceheader.IsActive;
             dbentry.MenuCategory      = serviceheader.MenuCategory;
             dbentry.MenuCategoryLabel = serviceheader.MenuCategoryLabel;
             dbentry.ProductCode       = serviceheader.ProductCode;
             dbentry.ProductName       = serviceheader.ProductName;
             dbentry.ServiceName       = serviceheader.ServiceName;
             dbentry.ServiceLabel      = serviceheader.ServiceLabel;
             dbentry.ServiceUrl        = serviceheader.ServiceUrl;
             dbentry.ServiceParams     = serviceheader.ServiceParams;
             dbentry.ParamsType        = serviceheader.ParamsType;
             dbentry.TimeFormat        = serviceheader.TimeFormat;
         }
     }
     context.SaveChanges();
 }
Пример #3
0
        public string ServiceUrlFill(ServiceHeader s, ServiceRequest r)
        {
            string val = s.ServiceUrl;

            switch ((ServiceUrlFiller)s.ParamsType)
            {
            default:
                val += ServiceUrlFill(s.ServiceParams.Trim(), r.MSISDN.Trim(), s.ProductCode.Trim());
                break;

            case ServiceUrlFiller.standard:
                val += ServiceUrlFill(s.ServiceParams.Trim(), r.MSISDN.Trim(), s.ProductCode.Trim(), r.TransactionId.ToString().Replace("-", "").Trim(), s.Description.Trim());
                break;

            case ServiceUrlFiller.multiplex:
                val += ServiceUrlFill(s.ServiceParams, r.MSISDN.Trim(), s.ProductCode.Trim(), r.TransactionId.ToString().Replace("-", "").Trim(), DateTime.Now, s.TimeFormat);
                break;

            case ServiceUrlFiller.nil:
                val += ServiceUrlFill(s.ServiceParams);
                break;

            case ServiceUrlFiller.lone:
                val += ServiceUrlFill(s.ServiceParams, s.ProductCode);
                break;
            }
            LogFileWrite(val);
            return(val);
        }
Пример #4
0
        public ServiceHeader DeleteServiceHeader(int headerId)
        {
            ServiceHeader dbentry = context.ServiceHeaders.Find(headerId);

            if (dbentry != null)
            {
                context.ServiceHeaders.Remove(dbentry);
                context.SaveChanges();
            }
            return(dbentry);
        }
Пример #5
0
        public async Task OnGet(int carId)
        {
            ServiceHeaderList = await _db.ServiceHeader
                                .Include(c => c.Car)
                                .Include(c => c.Car.ApplicationUser)
                                .Where(c => c.CarId == carId)
                                .ToListAsync();

            UserId = _db.Car.Where(car => car.Id == carId).ToList().FirstOrDefault()?.UserId;

            ServiceHeader = ServiceHeaderList.FirstOrDefault();
        }
Пример #6
0
        protected ServiceHeader BuildServiceHeader()
        {
            var serviceHeader = new ServiceHeader
            {
                functionIdentification     = FunctionIdentifier,
                organisationIdentification = GetOrganisationIdentification(),
                createDateTime             = DateTime.Now,
                endToEndMessageId          = CreateMessageId(),
                erpInformation             = CreateErpInformation(),
                format = "xml"
            };

            return(serviceHeader);
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound("ID is missing"));
            }

            ServiceHeader serviceHeader = db.ServiceHeaders.Find(id);

            if (serviceHeader == null)
            {
                return(HttpNotFound("ID was not found"));
            }

            return(View(serviceHeader));
        }
Пример #8
0
        private void HandleServiceHeader(SoapHttpClientProtocol ws, MsnServiceType st, MsnServiceState ss)
        {
            ServiceHeader sh = (st == MsnServiceType.AB) ?
                               ((ABServiceBinding)ws).ServiceHeaderValue :
                               ((SharingServiceBinding)ws).ServiceHeaderValue;

            if (null != sh &&
                NSMessageHandler.ContactService != null &&
                NSMessageHandler.ContactService.Deltas != null)
            {
                if (sh.CacheKeyChanged)
                {
                    NSMessageHandler.ContactService.Deltas.CacheKeys[CacheKeyType.OmegaContactServiceCacheKey] = sh.CacheKey;
                }

                lock (NSMessageHandler.ContactService.Deltas.SyncObject)
                {
                    /*
                     * // The implementation here is incorrect, we should only believe in the Location header
                     * // from the http response.
                     * if (!String.IsNullOrEmpty(sh.PreferredHostName))
                     * {
                     *  string methodKey = ws.ToString() + "." + ss.MethodName;
                     *  string preferredHost = FetchHost(sh.PreferredHostName);
                     *  if (NSMessageHandler.ContactService.Deltas.PreferredHosts[methodKey] == preferredHost)
                     *      return;
                     *
                     *  Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "Update redirect URL by response succeed, method " + ss.MethodName + ":\r\n " +
                     *                  "Original: " + FetchHost(ws.Url) + "\r\n " +
                     *                  "Redirect: " + preferredHost + "\r\n");
                     *
                     *  NSMessageHandler.ContactService.Deltas.PreferredHosts[methodKey] = preferredHost;
                     * }
                     */

                    NSMessageHandler.ContactService.Deltas.Save();
                }
            }
        }
Пример #9
0
 private void detach_ServiceHeaders(ServiceHeader entity)
 {
     this.SendPropertyChanging("ServiceHeaders");
     entity.Customer = null;
 }
Пример #10
0
        //Chat(code, phone)
        //mns(pid, phone, tid, descr)
        //Voice(msisdn, packid, requestimestamp(timeformat),trasactionid)

        public void Subscribe(int headerId, string ipAddress, string msisdn, bool IsHeaderEnabled = true, string sourceChannel = "Standard")
        {
            ServiceHeader serv = context.ServiceHeaders.FirstOrDefault(f => f.HeaderId == headerId);

            if (serv != null)
            {
                ServiceRequest req = new ServiceRequest();
                req.HeaderEnabled   = IsHeaderEnabled; //else number was obtained manually -false
                req.MSISDN          = msisdn;
                req.ClientIp        = ipAddress;
                req.ServiceHeaderId = serv.HeaderId;
                req.SourceChannel   = sourceChannel; //Opera
                req.Timestamped     = DateTime.Now;
                req.TransactionId   = Guid.NewGuid();

                SaveServiceRequest(req);


                if (req.RequestId > 0)
                {
                    var reply = "";// new WebClient().DownloadString(ServiceUrlFill(serv, req));/////Need to follow up with return data

                    if (serv.ParamsType == 3 | serv.ParamsType == 4)
                    {
                        //request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                        //request.Method = "POST"; // Doesn't work with "GET"
                        //ASCIIEncoding encoding = new ASCIIEncoding();
                        //byte[] data = encoding.GetBytes(serv.ServiceParams.TrimStart('?'));
                        //request.ContentLength = data.Length;

                        Pop(ServiceUrlFill(serv, req));
                        HttpContext.Current.Session["Param3"] = ServiceUrlFill(serv, req);
                        //request.GetRequestStream().Write(data, 0, data.Length);
                        reply = "OK";
                    }
                    else
                    {
                        HttpContext.Current.Session["Param3"] = null;
                        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ServiceUrlFill(serv, req));

                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();


                        using (Stream stream = response.GetResponseStream())
                        {
                            StreamReader reader         = new StreamReader(stream, Encoding.UTF8);
                            String       responseString = reader.ReadToEnd();
                            reply = responseString;
                        }
                    }

                    ServiceResponseRepository repo = new ServiceResponseRepository();
                    ServiceResponse           rep  = new ServiceResponse();
                    LogFileWrite(reply);
                    rep.Description = reply;
                    //LogFileWrite("Description: "+ reply.ToString());
                    rep.RequestId = req.RequestId;
                    var statCode = string.Concat(reply.Take(50));
                    rep.StatusCode = statCode;
                    //LogFileWrite("StatusCode: " + string.Concat(reply.Take(50)));

                    rep.Timestamped = DateTime.Now;

                    repo.SaveServiceResponse(rep);
                }
            }
        }