public IEnumerable <string> GetErrors()
        {
            var errors = new List <string>();

            if (ErrorMessage.IsVisible)
            {
                errors.Add(ErrorMessage.Get());
            }

            if (EmailError.IsVisible)
            {
                errors.Add(EmailError.Get());
            }

            if (FullNameError.IsVisible)
            {
                errors.Add(FullNameError.Get());
            }

            if (PasswordError.IsVisible)
            {
                errors.Add(PasswordError.Get());
            }

            if (ConfirmPasswordError.IsVisible)
            {
                errors.Add(ConfirmPasswordError.Get());
            }

            return(errors);
        }
Example #2
0
        internal static Exception GetException(int err)
        {
            EmailError error = (EmailError)err;

            if (error == EmailError.OutOfMemory)
            {
                return(new OutOfMemoryException("Out of memory"));
            }
            else if (error == EmailError.InvalidParameter)
            {
                return(new ArgumentException("Invalid parameter"));
            }
            else if (error == EmailError.ServerNotReady)
            {
                return(new IOException("Server not ready yet"));;
            }
            else if (error == EmailError.NoData)
            {
                return(new InvalidDataException("No data found"));
            }
            else if (error == EmailError.CommunicationWithServerFailed)
            {
                return(new TimeoutException("timed out"));
            }
            else if (error == EmailError.PermissionDenied)
            {
                return(new UnauthorizedAccessException("Permission denied"));
            }
            else if (error == EmailError.NotSupported)
            {
                return(new NotSupportedException("Not supported"));
            }
            else if (error == EmailError.OutOfRange)
            {
                return(new IndexOutOfRangeException("Out of range"));
            }
            else if (error == EmailError.SendingFailed)
            {
                return(new Exception("Sending failed"));
            }
            else if (error == EmailError.OperationFailed)
            {
                return(new InvalidOperationException("operation failed"));
            }
            else if (error == EmailError.NoSimCard)
            {
                return(new Exception("No sim card found"));
            }
            else
            {
                return(new Exception("System operation"));
            }
        }
Example #3
0
        public object Any(EmailRequest req)
        {
            EmailResponse resp = new EmailResponse();

            string FromAddress     = "*****@*****.**";
            string FromAdressTitle = req.FromAdressTitle;
            //To Address
            string ToAddress     = req.ToAddress;
            string ToAdressTitle = req.ToAdressTitle;
            string Subject       = req.Subject;
            string BodyContent   = req.BodyContent;

            string SmtpServer = "smtp.zoho.com";
            //Smtp Port Number
            int SmtpPortNumber = 465;

            try
            {
                var mimeMessage = new MimeMessage();
                mimeMessage.From.Add(new MailboxAddress(FromAdressTitle, FromAddress));
                mimeMessage.To.Add(new MailboxAddress(ToAdressTitle, ToAddress));
                mimeMessage.Subject = Subject;
                mimeMessage.Body    = new TextPart("plain")
                {
                    Text = BodyContent
                };
                using (var client = new SmtpClient())
                {
                    client.Connect(SmtpServer, SmtpPortNumber, true);
                    // Note: only needed if the SMTP server requires authentication
                    // Error 5.5.1 Authentication
                    client.Authenticate("*****@*****.**", "1.Pappaamma");
                    client.Send(mimeMessage);
                    client.Disconnect(true);
                }
                Console.WriteLine("The mail has been sent successfully !!");
                resp.Result = "Success By Unni";
                return(resp);
            }
            catch (Exception E)
            {
                EmailError res = new EmailError();
                res.Result = E.ToJson();
                Console.WriteLine(res.Result);
                return(res);
            }
        }
Example #4
0
        void OnPlayfabRegistrationSuccess(RegisterPlayFabUserResult result)
        {
            if (SuperSatoshiChanger != null)
            {
                SuperSatoshiChanger.IncreaseStat(refererUsername, SatoshiStatField, 4.ToString());
            }

            AddOrUpdateContactEmailRequest addOrUpdateContactEmail = new AddOrUpdateContactEmailRequest {
                EmailAddress = email
            };

            PlayFabClientAPI.AddOrUpdateContactEmail(addOrUpdateContactEmail, EmailResult => { Debug.Log("Email adjusted"); }, EmailError => { Debug.Log(EmailError.GenerateErrorReport()); });
            PlayerPrefs.SetString("Password", password);

            onRegistrationSuccess();

            PlayerPrefs.SetString("Skin", "Classic");

            PlayerPrefs.DeleteKey("Day");
            PlayerPrefs.DeleteKey("Month");

            Debug.Log("Success");
        }
Example #5
0
    public void cameraInit(string cameraType)
    {
        //Initiates camera to run in 12 bit mode with continuous acquisition.
        int  i           = 0;
        uint NUM_BUFFERS = 10;

        if (cameraType == "basler")
        {
            Pylon.Initialize();
            numDevices = Pylon.EnumerateDevices();
            if (ConfigurationManager.AppSettings.Get("ipAddress").Length > 0)
            {
                while (ip != ConfigurationManager.AppSettings.Get("ipAddress"))
                {
                    hDev = Pylon.CreateDeviceByIndex(j);
                    prop = Pylon.DeviceGetDeviceInfoHandle(hDev);
                    ip   = Pylon.DeviceInfoGetPropertyValueByIndex(prop, 8);
                    j++;
                    if (j > numDevices)
                    {
                        break;
                    }
                }
            }
            else
            {
                numDevices = Pylon.EnumerateDevices();
                hDev       = Pylon.CreateDeviceByIndex(0);
            }
            try
            {
                Pylon.DeviceOpen(hDev, Pylon.cPylonAccessModeControl | Pylon.cPylonAccessModeStream);
            }
            catch (System.Threading.ThreadAbortException) { }
            catch (Exception ex)
            {
                EmailError.emailAlert(ex);
                throw (ex);
            }

            isAvail = Pylon.DeviceFeatureIsAvailable(hDev, "EnumEntry_PixelFormat_Mono12");
            Pylon.DeviceFeatureFromString(hDev, "PixelFormat", "Mono12");
            Pylon.DeviceFeatureFromString(hDev, "AcquisitionMode", "Continuous");
            Pylon.DeviceSetIntegerFeature(hDev, "Height", 1);
            Pylon.DeviceSetFloatFeature(hDev, "ExposureTimeAbs", exp); //Exposure time is in microseconds and rounded to the closest 100 ns.
            isAvail = Pylon.DeviceFeatureIsWritable(hDev, "GevSCPSPacketSize");
            if (isAvail)
            {
                Pylon.DeviceSetIntegerFeature(hDev, "GevSCPSPacketSize", 1500);
            }
            payloadSize = checked ((uint)Pylon.DeviceGetIntegerFeature(hDev, "PayloadSize"));
            nStreams    = Pylon.DeviceGetNumStreamGrabberChannels(hDev);
            hGrabber    = Pylon.DeviceGetStreamGrabber(hDev, 0);
            Pylon.StreamGrabberOpen(hGrabber);
            hWait = Pylon.StreamGrabberGetWaitObject(hGrabber);
            Pylon.StreamGrabberSetMaxNumBuffer(hGrabber, NUM_BUFFERS);
            Pylon.StreamGrabberSetMaxBufferSize(hGrabber, payloadSize);
            Pylon.StreamGrabberPrepareGrab(hGrabber);
            buffers = new Dictionary <PYLON_STREAMBUFFER_HANDLE, PylonBuffer <Byte> >();
            for (i = 0; i < NUM_BUFFERS; ++i)
            {
                PylonBuffer <Byte>        buffer = new PylonBuffer <byte>(payloadSize, true);
                PYLON_STREAMBUFFER_HANDLE handle = Pylon.StreamGrabberRegisterBuffer(hGrabber, ref buffer);
                buffers.Add(handle, buffer);
            }
            i = 0;
            foreach (KeyValuePair <PYLON_STREAMBUFFER_HANDLE, PylonBuffer <Byte> > pair in buffers)
            {
                Pylon.StreamGrabberQueueBuffer(hGrabber, pair.Key, i++);
            }
            Pylon.DeviceExecuteCommandFeature(hDev, "AcquisitionStart");
        }
    }
Example #6
0
    public void startFrameGrab(int nr, int trigmode, dataDelegate dd, string cameraType)
    {
        //Start frame grabbing loop and pushes data into the data delegate as a ushort array.
        int bufferIndex;

        masterDataDelegate = dd;

        try
        {
            while (true)
            {
                if (cameraType == "basler")
                {
                    PylonBuffer <Byte> buffer;
                    Pylon.WaitObjectWait(hWait, 100);

                    Pylon.StreamGrabberRetrieveResult(hGrabber, out grabResult);

                    bufferIndex = (int)grabResult.Context;
                    while (buffers.TryGetValue(grabResult.hBuffer, out buffer) != true)
                    {
                        ;
                    }
                    Buffer.BlockCopy(buffer.Array, 0, data, 0, buffer.Array.Length);
                    if (frameReverse)
                    {
                        Array.Reverse(data);
                    }
                    frameAveraging(data);
                    Pylon.StreamGrabberQueueBuffer(hGrabber, grabResult.hBuffer, bufferIndex);
                }
                else if (cameraType == "none")
                {
                    data = new ushort[camWidth];
                    Random   random = new Random();
                    TimeSpan ts     = DateTime.Now.Subtract(new DateTime(2011, 2, 1));
                    double   offset = 300 * Math.Sin(2 * Math.PI * 0.01 * ts.TotalSeconds) - 500;
                    for (int i = 0; i < data.Length; i++)
                    {
                        if (i < 40)
                        {
                            data[i] = (ushort)(data[i] + random.Next(0, 5));
                        }
                        if (i > 40 && i < 1540)
                        {
                            data[i] = (ushort)(data[i] + Math.Pow(2, 11) * Math.Abs(Math.Sin(2 * Math.PI * i / 300.0)) + random.Next(0, 5));
                        }
                        if (i > 1540 && i < 1940 + offset)
                        {
                            data[i] = (ushort)(data[i] + random.Next(0, 5));
                        }
                        if (i > 1940 + offset && i < 3440 + offset)
                        {
                            data[i] = (ushort)(data[i] + Math.Pow(2, 11) * Math.Abs(Math.Sin(2 * Math.PI * (i - offset) / 300.0)) + random.Next(0, 5));
                        }
                        if (i > 3440 + offset)
                        {
                            data[i] = (ushort)(data[i] + random.Next(0, 5));
                        }
                    }
                    Thread.Sleep(int.Parse(ConfigurationManager.AppSettings.Get("cameraExposureTime")) / 1000);
                    frameAveraging(data);
                }
            }
        }
        catch (System.Threading.ThreadAbortException) { }
        catch (Exception ex)
        {
            EmailError.emailAlert(ex);
            throw (ex);
        }
    }
        public override void Execute()
        {
            base.Execute();
            log.Debug("Begin Execute");
            try
            {
                var api   = new ApiClient();
                var count = 0;

                foreach (var item in (List <tblAttachmentsTemp>)State.Data)
                {
                    log.Debug($"Checking reports for {item.FileName}");
                    count++;
                    if (count == Config.Instance.VirusScanTaskScanReportCountLimit)
                    {
                        log.Debug("Scan Report Count Limit reached.");
                        return;
                    }

                    var boundary = "-----" + Guid.NewGuid().ToString().Replace("-", "");
                    var request  = new ApiClient.Request
                    {
                        Url     = Config.Instance.VirusScanTaskScanReportUrl,
                        Method  = "POST",
                        Headers = new NameValueCollection
                        {
                            { "content-type", $"multipart/form-data; boundary={boundary}" },
                        },
                        Body = ApiClient.BuildMultipartForm(
                            boundary,
                            new List <KeyValuePair <string, string> >
                        {
                            new KeyValuePair <string, string>("apikey", Config.Instance.VirusScanTaskApiKey),
                            new KeyValuePair <string, string>("resource", item.ScanId)
                        },
                            null
                            ),
                        ResponseAsString = true
                    };
                    var response = api.ClientRequest(request);
                    var json     = JsonConvert.DeserializeObject <VirusTotalScanReportResult>(response.ToString());
                    if (json.ResponseCode == 1)
                    {
                        var isOk   = json.Positives == 0 ? "returned OK, " : "";
                        var result = $"Report {isOk} found  {json.Positives} positives out of {json.Total} scans";
                        log.Info(result);
                        item.ScanResult = json.Positives == 0 ? "OK" : result + "\n" + response;
                        if (item.ScanResult != "OK")
                        {
                            UpdateAttachmentTemp(item);
                            Results.Add(new Result(item.ScanId, response.StatusCode.ToString(), response.StatusDescription, null));
                            var email = new EmailError();
                            email.GenerateErrorMessageEmail($"{result}<br/> Filename: {item.FileName}<br/> ScanId: {item.ScanId}<br/> Returned JSON:<br/>{response.ToString()}");
                        }
                        else
                        {
                            var isSaved = AllowAttachment(item);
                            if (isSaved)
                            {
                                CloseAttachmentTemp(item);
                                Results.Add(new Result(item.ScanId, response.StatusCode.ToString(), response.StatusDescription, null));
                            }
                            else
                            {
                                throw new Exception($"Could not save create attachment for Id: {item.Id}");
                            }
                        }
                    }
                    else
                    {
                        var warning = $"Report not completed, JSON returned: {response}";
                        log.Error(warning);
                        Results.Add(new Result(null, response.StatusCode.ToString(), response.StatusDescription, warning));
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e);
                Results.Add(new Result(null, null, null, e.Message));
            }
            finally
            {
                log.Debug("End Execute");
            }
        }
 public ConfigurationEmail(Boolean active_, Alert_Mail.Classes.Configuration.Connexion connexion_, EmailLists emailLists_, EmailError emailError_, EmailSummary emailSummary_, EmailPendingFiles emailPendingFiles_)
 {
     this.active            = active_;
     this.connexion         = connexion_;
     this.emailLists        = emailLists_;
     this.emailError        = emailError_;
     this.emailSummary      = emailSummary_;
     this.emailPendingFiles = emailPendingFiles_;
 }