private task[] GetTasks(sdsdocument[] documentInSds, List <ContactInfo> recipients, SigningInfo signingInfo)
        {
            try
            {
                var  callbackOnTaskCompleteUrl = "https://prosesspilotenesignicatwebapi-preprod.azurewebsites.net:443/api/Callback/Landingpage?lcid=" + signingInfo.LCID;
                var  signatures      = new SignatureHandler().GetSignatures(signingInfo);
                var  authSignatures  = new SignatureHandler().GetAuthSignatures(signingInfo);
                var  documentactions = GetDocumentActions(documentInSds, recipients);
                var  randomnr        = new Random();
                int  nr     = randomnr.Next(10000);
                bool bundle = signingInfo.signingMetodText == "nbid";

                var tasks = new task[recipients.Count];
                for (int i = 0; i < recipients.Count; i++)
                {
                    var notifications = new NotificationHandler().AddNotifications(recipients[i], signingInfo, i);

                    tasks[i] = new task
                    {
                        id              = "task_" + i + "_" + nr, // Any identifier you'd like
                        subjectref      = "sub_" + i,             // Any identifier you'd like
                        bundle          = true,
                        bundleSpecified = bundle,
                        daystolive      = signingInfo.daysToLive,
                        documentaction  = documentactions,
                        signature       = signatures,
                        authenticationbasedsignature = authSignatures,
                        ontaskcomplete = callbackOnTaskCompleteUrl,
                        subject        = new subject
                        {
                            id     = "sub_" + i,
                            email  = recipients[i].email,
                            mobile = !string.IsNullOrWhiteSpace(recipients[i].mobile) ? recipients[i].mobile : "22222222"
                                     //nationalid = recipients[i].ssn //National id mustbe inserted
                        },
                        notification = notifications
                    };
                }
                return(tasks);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 2
0
        public string CreateSignRequest(sdsdocument uploadedDocument, string customerorg, string language, int method)
        {
            var lang = "en";

            if (language == "1044")
            {
                lang = "nb";
            }

            var signmethodText = new SignatureHandler().GetMethod(method);
            var signInfo       = new SigningInfo();

            signInfo.signingMetodText = signmethodText;
            signInfo.isInk            = true;

            var  authMethod = new SignatureHandler().GetAuthSignatures(signInfo);
            var  signatures = new SignatureHandler().GetSignatures(signInfo);
            bool bundle     = signInfo.signingMetodText == "nbid";


            var request = new createrequestrequest
            {
                password = "******",
                service  = "prosesspilotene",
                request  = new request[]
                {
                    new request
                    {
                        clientreference = "cliref1",
                        language        = lang,
                        profile         = "default",
                        document        = new document[]
                        {
                            new sdsdocument
                            {
                                id          = uploadedDocument.id,
                                refsdsid    = uploadedDocument.refsdsid,
                                description = uploadedDocument.description
                            }
                        },
                        subject = new subject[]
                        {
                            new subject
                            {
                                id     = "subj_1",
                                mobile = "99999999"
                                         //nationalid = "1909740939"
                            }
                        },
                        task = new task[]
                        {
                            new task
                            {
                                id              = "task_1",
                                subjectref      = "subj_1",
                                bundle          = true,
                                bundleSpecified = bundle,
                                documentaction  = new documentaction[]
                                {
                                    new documentaction
                                    {
                                        type        = documentactiontype.sign,
                                        documentref = uploadedDocument.id
                                    }
                                },
                                authenticationbasedsignature = authMethod,
                                signature = signatures
                            }
                        }
                    }
                }
            };

            for (int i = 0; i < request.request[0].task.Length; i++)
            {
                var callbackOnTaskCompleteUrl = "https://prosesspilotenesignicatwebapi-preprod.azurewebsites.net:443/api/Callback/Landingpage?lcid=" + Convert.ToString(language);
                var callbackNotificationUrl   = "https://prosesspilotenesignicatwebapi-preprod.azurewebsites.net:443/api/Callback/GetSigning?orgname=" + customerorg;
                request.request[0].task[i].ontaskcomplete = callbackOnTaskCompleteUrl;

                request.request[0].task[i].notification = new[]
                {
                    new notification
                    {
                        notificationid = "req_callback_" + i,
                        type           = notificationtype.URL,
                        recipient      = callbackNotificationUrl,
                        message        = "callbackurl",
                        schedule       = new []
                        {
                            new schedule
                            {
                                stateis = taskstatus.completed
                            }
                        }
                    }
                };
            }

            createrequestresponse response;

            using (var client = new DocumentEndPointClient())
            {
                response = client.createRequest(request);
            }
            return
                (String.Format("https://preprod.signicat.com/std/docaction/prosesspilotene?request_id={0}&task_id={1}",
                               response.requestid[0], request.request[0].task[0].id));
        }