예제 #1
0
        public ActionResult Edit(LetterModel model)
        {
            using (ncelsEntities db = new ncelsEntities())
            {
                OBK_LetterPortalEdo dataFromDB = db.OBK_LetterPortalEdo.Where(x => x.ID == model.ID).FirstOrDefault();
                if (dataFromDB != null)
                {
                    dataFromDB.LetterContent = model.LetterContent;
                    dataFromDB.ContractId    = model.ContractId;
                    dataFromDB.OBK_LetterRegistration.LetterRegName = model.RegName;
                    dataFromDB.OBK_LetterRegistration.LetterRegDate = model.LetterRegDate;
                    db.SaveChanges();


                    foreach (HttpPostedFileBase file in model.files)
                    {
                        //Checking file is available to save.
                        if (file != null)
                        {
                            string InputFileName         = Path.GetFileName(file.FileName);
                            OBK_LetterAttachments attach = new OBK_LetterAttachments();
                            attach.AttachmentName = InputFileName;
                            attach.ContentFile    = StreamToByteArray(file.InputStream);
                            attach.LetterId       = dataFromDB.ID;
                            db.OBK_LetterAttachments.Add(attach);
                            db.SaveChanges();
                        }
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult EditGet(long id)
        {
            LetterModel model = new LetterModel();

            using (ncelsEntities db = new ncelsEntities())
            {
                OBK_LetterPortalEdo dataFromDB = db.OBK_LetterPortalEdo.Where(x => x.ID == id).FirstOrDefault();
                if (dataFromDB != null)
                {
                    model.ID             = dataFromDB.ID;
                    model.LetterContent  = dataFromDB.LetterContent;
                    model.ContractId     = dataFromDB.ContractId;
                    model.RegName        = dataFromDB.OBK_LetterRegistration.LetterRegName;
                    model.LetterRegDate  = dataFromDB.OBK_LetterRegistration.LetterRegDate;
                    model.AuthorID       = dataFromDB.AuthorID;
                    model.LetterStatusId = dataFromDB.LetterStatusId;
                    ViewData["Contract"] = new SelectList(db.OBK_Contract.Where(x => x.EmployeeId == dataFromDB.AuthorID).ToList(), "Id", "Number", dataFromDB.ContractId);
                    var dataDocs = db.OBK_LetterAttachments.Where(x => x.LetterId == model.ID).Select(x => new AttachDoc
                    {
                        AttachmentName = x.AttachmentName,
                        ID             = x.ID,
                        isSigned       = string.IsNullOrEmpty(x.SignXmlBigData) ? false : true,
                    }).ToList();
                    model.listDoc = dataDocs;
                }
            }
            return(View(model));
        }
예제 #3
0
 public ActionResult DeleteOutgoing(LetterModel model)
 {
     using (ncelsEntities db = new ncelsEntities())
     {
         OBK_LetterPortalEdo edo = db.OBK_LetterPortalEdo.Where(x => x.ID == model.ID).FirstOrDefault();
         if (edo != null)
         {
             db.OBK_LetterPortalEdo.Remove(edo);
             db.SaveChanges();
             db.Database.ExecuteSqlCommand(String.Format("delete from OBK_LetterAttachments where LetterId={0}", model.ID));
             //     db.OBK_LetterRegistration.Remove(db.OBK_LetterRegistration.Where(x=>x.ID==edo.OBKLetterRegID).FirstOrDefault());
             db.SaveChanges();
         }
     }
     return(RedirectToAction("Index"));
 }
예제 #4
0
        public bool saveRegNomerFromEdo(long letterEdoID, string regNomer, DateTime regDate)
        {
            bool result = false;

            try
            {
                OBK_LetterPortalEdo edo = AppContext.OBK_LetterPortalEdo.Where(x => x.ID == letterEdoID).FirstOrDefault();
                edo.EdoRegDate  = regDate;
                edo.EdoRegNomer = regNomer;
                AppContext.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                return(false);
            }
            return(result);
        }
예제 #5
0
        public ActionResult AddLetter(LetterModel model)
        {
            if (model != null)
            {
                using (ncelsEntities db = new ncelsEntities())
                {
                    OBK_LetterRegistration letterRegistartin = new OBK_LetterRegistration();
                    letterRegistartin.LetterRegDate = model.LetterRegDate;
                    letterRegistartin.LetterRegName = model.RegName;
                    db.OBK_LetterRegistration.Add(letterRegistartin);
                    db.SaveChanges();


                    OBK_LetterPortalEdo data = new OBK_LetterPortalEdo();
                    data.LetterContent  = model.LetterContent;
                    data.CreatedDate    = DateTime.Now;
                    data.ContractId     = model.ContractId;
                    data.AuthorID       = model.AuthorID;
                    data.LetterContent  = model.LetterContent;
                    data.OBKLetterRegID = letterRegistartin.ID;
                    data.LetterStatusId = model.LetterStatusId;//Pismo prosto sohranen na base
                    db.OBK_LetterPortalEdo.Add(data);
                    db.SaveChanges();

                    foreach (HttpPostedFileBase file in model.files)
                    {
                        //Checking file is available to save.
                        if (file != null)
                        {
                            string InputFileName         = Path.GetFileName(file.FileName);
                            OBK_LetterAttachments attach = new OBK_LetterAttachments();
                            attach.AttachmentName = InputFileName;
                            attach.ContentFile    = StreamToByteArray(file.InputStream);
                            attach.LetterId       = data.ID;
                            db.OBK_LetterAttachments.Add(attach);
                        }
                    }
                    model.ID = data.ID;
                    db.SaveChanges();
                    if (model.LetterStatusId == 2)
                    {
                        var dataDocs = db.OBK_LetterAttachments.Where(x => x.LetterId == model.ID).Select(x => new AttachDoc
                        {
                            AttachmentName = x.AttachmentName,
                            ID             = x.ID,
                            isSigned       = string.IsNullOrEmpty(x.SignXmlBigData) ? false : true,
                        }).ToList();
                        model.listDoc = dataDocs;
                    }
                    db.SaveChanges();
                }
            }
            if (model.LetterStatusId == 2)
            {
                if (model.listDoc.Count != 0)
                {
                    return(View("SignViewStart", model));
                }
                else
                {
                    //WebSerice
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
예제 #6
0
        public ActionResult SignForm(long id, string xmlAuditForm)
        {
            bool success = true;
            var  counter = 0;

            using (ncelsEntities db = new ncelsEntities())
            {
                try
                {
                    OBK_LetterAttachments attach = db.OBK_LetterAttachments.Where(x => x.ID == id).FirstOrDefault();
                    attach.SignXmlBigData = xmlAuditForm;
                    db.SaveChanges();
                    var countSigned = db.OBK_LetterAttachments.Count((x => (x.SignXmlBigData == null || x.SignXmlBigData == "") && x.LetterId == attach.LetterId));
                    counter = countSigned;
                    if (counter == 0)
                    {
                        OBK_LetterPortalEdo    partal    = db.OBK_LetterPortalEdo.Where(x => x.ID == attach.LetterId).FirstOrDefault();
                        OBK_LetterRegistration regPartal = db.OBK_LetterRegistration.Where(x => x.ID == partal.OBKLetterRegID).FirstOrDefault();
                        partal.LetterStatusId = 2;
                        db.SaveChanges();
                        //CallWebServiceWithEDO
                        var          employee   = db.Employees.FirstOrDefault(x => x.Login == User.Identity.Name);
                        ActionClient client     = new ActionClient();
                        InParameters parameters = new InParameters();
                        parameters.date_letter      = partal.CreatedDate.ToString("dd.MM.yyyy");
                        parameters.id_contact       = partal.ID.ToString();
                        parameters.id_edo           = "";
                        parameters.id_letter_obk    = regPartal.ID.ToString();
                        parameters.id_letter_user   = regPartal.LetterRegName;
                        parameters.date_letter_user = regPartal.LetterRegDate.Value.ToString("dd.MM.yyyy");

                        parameters.letter_text = partal.LetterContent;
                        parameters.user_obk    = employee.LastName;



                        List <OBK_LetterAttachments> listAttach = db.OBK_LetterAttachments.Where(x => x.LetterId == partal.ID).ToList();
                        List <Attachment>            lists      = new List <Attachment>();
                        foreach (OBK_LetterAttachments attachFile in listAttach)
                        {
                            Attachment attachs = new Attachment();
                            sbyte[]    signed  = Array.ConvertAll(attachFile.ContentFile, b => unchecked ((sbyte)b));
                            attachs.content = Convert.ToBase64String(attachFile.ContentFile);
                            attachs.name    = attachFile.AttachmentName;
                            attachs.sign    = attachFile.SignXmlBigData;
                            lists.Add(attachs);
                        }
                        parameters.attachments = lists.ToArray();
                        var datasend = client.sendINDocument(parameters);
                        if (datasend)
                        {
                        }
                    }
                }
                catch (Exception e)
                {
                    success = false;
                }
            }
            return(Json(new { success, counter }, JsonRequestBehavior.AllowGet));
        }