public ProtocolFeatureSwitch()
        {
            InitializeComponent();

            // Get a local reference to the protocol model.
            theProtocolModel = ProtocolModel.GetInstance();
        }
示例#2
0
 private void session_ProtocolModelCompleted(ISession session, ProtocolModel protocolModel)
 {
     if (protocolModel != null && protocolModel != PlaceholderProtocolModel && this.SessionProtocolModelCompleted != null)
     {
         this.SessionProtocolModelCompleted(session, protocolModel);
     }
 }
示例#3
0
        public JsonResult CreateProtocol(string data)
        {
            dynamic model  = JsonConvert.DeserializeObject(data);
            string  date   = model.date.ToString();
            int     days   = DateTime.Parse(date).Subtract(new DateTime(2020, 1, 1)).Days;
            int     specid = int.Parse(model.specialty.ToString());

            using (UserContext db = new UserContext())
            {
                SpecialtyModel sp           = db.Specialties.Find(specid);
                string         protocolname = $"{days:D3}";
                ProtocolModel  pr           = db.Protocols.Find(protocolname);
                if (pr != null)
                {
                    int index = 0;
                    while (pr != null)
                    {
                        index++;
                        protocolname = $"{days:D3}.{index:D2}";
                        pr           = db.Protocols.Find(protocolname);
                    }
                }
                db.Protocols.Add(new ProtocolModel {
                    ProtocolName = protocolname
                });
                db.SaveChanges();
                return(Json(protocolname + $"-{sp.Prefix}", JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        public ProtocolMultipleSamples()
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            // Get a local reference to the protocol model.
            theProtocolModel = ProtocolModel.GetInstance();
        }
示例#5
0
        public TCPConnectionManager(PresenterModel model)
        {
            this.m_Model    = model;
            this.m_Protocol = new ProtocolModel(this, "TCP");

            this.m_Classroom = new TCPClassroomManager(this.m_Model, this, Strings.InstructorStartTCPServer);

            using (Synchronizer.Lock(this.m_Protocol.SyncRoot)) {
                this.m_Protocol.Classrooms.Add(this.m_Classroom.Classroom);
            }
        }
示例#6
0
                private void HandleHumanNameChanged(object sender_, PropertyEventArgs args)
                {
                    ProtocolModel sender = sender_ as ProtocolModel;

                    if (sender != null)
                    {
                        using (Synchronizer.Lock(sender.SyncRoot)) {
                            this.Text = sender.HumanName;
                        }
                    }
                }
        public ProtocolResultVialSelection()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            theProtocolModel = ProtocolModel.GetInstance();

            results = new resultVialChecks();
        }
        public ProtocolReagentBarcodes()
        {
            InitializeComponent();

            // Get a local reference to the protocol model.
            theProtocolModel = ProtocolModel.GetInstance();

            tipDefaultName.SetToolTip(this.lbDefaultNames, "Select the vial name to add/edit barcode.");
            tipNewName.SetToolTip(this.txtCustomName, "Type the barcode desired for selected vial.");

            myUsedReagentVialList = new List <AbsoluteResourceLocation>();
        }
示例#9
0
        /// <summary>
        /// 编辑协议
        /// </summary>
        /// <param name="_model"></param>
        /// <returns></returns>
        public static bool UpdateProtocol(ProtocolModel _model)
        {
            string sql = $@"UPDATE [Protocol]
	SET [CName] = '{_model.CName}'
		,[EName] = '{_model.EName}'
		,[PCID] = '{_model.PCID}'
		,[Code] = {_model.Code}
		,[Desc] = '{_model.Desc}'
	WHERE [PID] = '{_model.PID}'"    ;

            return(helper.ExecuteNonQuery(sql) > 0);
        }
        public ProtocolCustomize()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Get a local reference to the protocol model.
            theProtocolModel = ProtocolModel.GetInstance();

            tipDefaultName.SetToolTip(this.lbDefaultNames, "Select the default vial name to change.");
            tipNewName.SetToolTip(this.txtCustomName, "Type the custom name desired for selected default name.");
        }
示例#11
0
        /// <summary>
        /// Get barcode traceability manager.
        /// </summary>
        /// <param name="protocol">The Protocol Model</param>
        /// <param name="consumableBarcodeManager">The Consumable Barcode Manager</param>
        /// <returns>The barcode traceability manager.</returns>
        public virtual IBarcodeTraceabilityManager GetBarcodeTraceabilityManager(ProtocolModel protocol, IConsumableBarcodeManager consumableBarcodeManager)
        {
            if (barcodeTraceabilityManager == null)
            {
                barcodeTraceabilityManager = new BarcodeTraceabilityManager(DataStorage.Factory.Instance.CreateUnitOfWork(UseCaseNames.WorkflowExecution).BarcodeRepository, protocol, consumableBarcodeManager);
            }
            else
            {
                barcodeTraceabilityManager.Protocol = protocol;
                barcodeTraceabilityManager.ConsumableBarcodeManager = consumableBarcodeManager;
            }

            return(barcodeTraceabilityManager);
        }
示例#12
0
 public bool DeleteProtocol(string protocolname)
 {
     int[] docs;
     using (UserContext db = new UserContext())
     {
         ProtocolModel d = db.Protocols.Find(protocolname);
         if (d != null)
         {
             db.DocumentModels.RemoveRange(d.DocumentModels);
             db.Protocols.Remove(d);
             db.SaveChanges();
         }
         return(true);
     }
 }
示例#13
0
        private void session_SessionClosed(TcpSession session, ProtocolModel protocolModel)
        {
            //first remove the session from the list
            if (this.upcomingSessionsList.ContainsKey(session.Identifier))
            {
                this.upcomingSessionsList.Remove(session.Identifier);
            }
            else if (this.establishedSessionsList.ContainsKey(session.Identifier))
            {
                this.establishedSessionsList.Remove(session.Identifier);
            }

            if (protocolModel != null && protocolModel != PlaceholderProtocolModel && this.SessionProtocolModelCompleted != null)
            {
                this.SessionProtocolModelCompleted(session, protocolModel);
            }
        }
        public AboutThisProtocolWindow()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            theProtocolModel = ProtocolModel.GetInstance();

            // set data in textboxes
            txtCreationDate.Text = "" + theProtocolModel.ProtocolCreationDate;

            if (theProtocolModel.ProtocolModificationDateIsSpecified)
            {
                txtModificationDate.Text = "" + theProtocolModel.ProtocolModificationDate;
            }
            else
            {
                txtModificationDate.Text = string.Empty;
            }
            txtProtocolVersion.Text = "" + theProtocolModel.ProtocolVersion;

            txtProtocolAuthor.Text = "" + theProtocolModel.ProtocolAuthor;
            ProtocolNum1.Text      = "" + theProtocolModel.ProtocolNumber1;
            ProtocolNum2.Text      = "" + theProtocolModel.ProtocolNumber2;

            VersionManager VerMgr = VersionManager.GetInstance();

            /*
             * if ((VerMgr.InputVersions[0] == 0)||(VerMgr.InputVersions[1] == 0))
             * {
             *      lblRoboSep.Text = "RoboSep Protocol Editor Ver: N/A";
             *
             * }
             * else
             * {
             * lblRoboSep.Text = "RoboSep Protocol Editor Ver: " +
             *              VerMgr.InputVersions[0].ToString() + "." +
             *              VerMgr.InputVersions[1].ToString() + "." +
             *              VerMgr.InputVersions[2].ToString() + "." +
             *              VerMgr.InputVersions[3].ToString();
             * }
             */
        }
        private ProtocolModel GetBestProtocolMatch(ProtocolModel observationModel, SortedList <String, ProtocolModel> protocolModels)
        {
            ProtocolModel bestProtocolMatch           = null;
            var           bestProtocolMatchDivergence = this.config.DivergenceThreshold; //the highest allowed distance for a valid protocol model match

            foreach (var protocolModel in this._protocolModels.Values)
            {
                var divergence = observationModel.GetAverageKullbackLeiblerDivergenceFrom(protocolModel);
                if (divergence < bestProtocolMatchDivergence)
                {
                    bestProtocolMatch           = protocolModel;
                    bestProtocolMatchDivergence = divergence;
                }
            }

            //just for test
            //ShowProtocolModelDivergences(observationModel, bestProtocolMatch);
            return(bestProtocolMatch);
        }
示例#16
0
            protected override object SetUpMember(int index, object member)
            {
                ProtocolModel protocol = member as ProtocolModel;

                if (protocol == null)
                {
                    return(null);
                }

                TCPConnectionManager connection = protocol.ConnectionManager as TCPConnectionManager;

                if (connection == null)
                {
                    return(null);
                }

                this.m_Parent.AddClassroom(connection.ClassroomManager);

                return(connection.ClassroomManager);
            }
示例#17
0
        /// <summary>
        /// 添加协议
        /// </summary>
        /// <param name="_model"></param>
        /// <returns></returns>
        public static bool AddProtocol(ProtocolModel _model)
        {
            string sql = $@"INSERT INTO [Protocol]
		([PID]
		,[CName]
		,[EName]
		,[PCID]
		,[Code]
		,[Desc]
,[CreateTime])
	VALUES
		('{_model.PID}'
		,'{_model.CName}'
		,'{_model.EName}'
		,'{_model.PCID}'
		,{_model.Code}
		,'{_model.Desc}'
,'{_model.CreateTime}')";

            return(helper.ExecuteNonQuery(sql) > 0);
        }
示例#18
0
        private static List <ProtocolModel> DT2ProtocolModel(DataTable _dt)
        {
            List <ProtocolModel> list = new List <ProtocolModel>();

            if (_dt != null && _dt.Rows.Count > 0)
            {
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    ProtocolModel model = new ProtocolModel();
                    model.CName      = _dt.Rows[i]["CName"].ToString();
                    model.Code       = Convert.ToInt32(_dt.Rows[i]["Code"]);
                    model.Desc       = _dt.Rows[i]["Desc"].ToString();
                    model.EName      = _dt.Rows[i]["EName"].ToString();
                    model.PCID       = _dt.Rows[i]["PCID"].ToString();
                    model.PID        = _dt.Rows[i]["PID"].ToString();
                    model.CreateTime = _dt.Rows[i]["CreateTime"].ToString();
                    list.Add(model);
                }
            }
            return(list);
        }
示例#19
0
        /// <summary>
        /// 显示数据
        /// </summary>
        /// <param name="_proModel"></param>
        private void ShowProtoInfo(ProtocolModel _proModel)
        {
            if (_proModel == null)
            {
                return;
            }
            groupProtoInfo.Enabled = true;

            //协议基本信息
            this.txtProtoCode.Text   = _proModel.Code.ToString();
            this.txtProtoEnName.Text = _proModel.EName;
            this.txtProtoCnName.Text = _proModel.CName;
            this.txtProtoDesc.Text   = _proModel.Desc;

            var attrsList = ProtocolDB.GetAttributes(_proModel.PID);

            dvGrid.Rows.Clear();
            if (attrsList != null && attrsList.Count > 0)
            {
                for (int i = 0; i < attrsList.Count; i++)
                {
                    DataGridViewRow dataGridViewRow = dvGrid.Rows[0].Clone() as DataGridViewRow;

                    dataGridViewRow.Cells[0].Value  = attrsList[i].AType;
                    dataGridViewRow.Cells[1].Value  = attrsList[i].EName;
                    dataGridViewRow.Cells[2].Value  = attrsList[i].CName;
                    dataGridViewRow.Cells[3].Value  = attrsList[i].IsLoop;
                    dataGridViewRow.Cells[4].Value  = attrsList[i].A2LoopEName;
                    dataGridViewRow.Cells[5].Value  = attrsList[i].A2BoolEName;
                    dataGridViewRow.Cells[6].Value  = attrsList[i].A2Bool;
                    dataGridViewRow.Cells[7].Value  = attrsList[i].A2StrEName;
                    dataGridViewRow.Cells[8].Value  = attrsList[i].A2Str;
                    dataGridViewRow.Cells[9].Value  = attrsList[i].PAID;
                    dataGridViewRow.Cells[10].Value = attrsList[i].PID;

                    dvGrid.Rows.Add(dataGridViewRow);
                }
            }
        }
示例#20
0
        public RTPConnectionManager(PresenterModel model)
        {
            this.m_Model    = model;
            this.m_Protocol = new ProtocolModel(this, "RTP");

            this.m_Classrooms = new List <RTPClassroomManager>();

            List <Venue> venueList = RTPVenueManager.GetVenues();

            foreach (Venue v in venueList)
            {
                this.m_Classrooms.Add(new RTPClassroomManager(this.m_Model, this, v.VenueName, v.VenueEndPoint, false));
                //Note that the UI connection dialog only shows 5 classrooms, regardless of how many we add here
            }

            using (Synchronizer.Lock(this.m_Protocol.SyncRoot)) {
                foreach (RTPClassroomManager manager in this.m_Classrooms)
                {
                    this.m_Protocol.Classrooms.Add(manager.Classroom);
                }
            }
        }
示例#21
0
        /// <summary>
        /// Gets standard protocol from database.
        /// </summary>
        /// <returns>Protocol Model</returns>
        ProtocolModel GetProtocolFromDB()
        {
            TreeToolOrebrollEntities ent = new TreeToolOrebrollEntities();

            var protocol         = new ProtocolModel();
            var observationTypes = new ObservationTypeCollection();

            protocol.TreeSpecies = (ent.TreeSpecies.Select(t => new TreeSpeciesModel {
                ID = t.TreeSpeciesID, Name = t.SwedishName
            }));
            observationTypes.ActionNeedsTimeType = (ent.ActionNeedsTimeType.Select(t => new ObservationTypeModel {
                ID = t.ActionNeedsTimeID, Value = t.Value
            }));
            observationTypes.ActionNeedsType     = (ent.ActionNeedsType.Select(t => new ActionNeedsTypeModel {
                ID = t.ActionNeedsID, Value = t.Value
            }));
            observationTypes.DamageClassType     = (ent.DamageClassType.Select(t => new ObservationTypeModel {
                ID = t.DamageClassID, Value = t.Value
            }));
            observationTypes.DiseasesType        = (ent.DiseasesType.Select(t => new ObservationTypeModel {
                ID = t.DiseasesID, Value = t.Value
            }));
            observationTypes.FungusType          = (ent.FungusType.Select(t => new ObservationTypeModel {
                ID = t.FungusID, Value = t.Value
            }));
            observationTypes.SafetyType          = (ent.SafetyType.Select(t => new ObservationTypeModel {
                ID = t.SafetyID, Value = t.Value
            }));
            observationTypes.VitalityType        = (ent.VitalityType.Select(t => new ObservationTypeModel {
                ID = t.VitalityID, Value = t.Value
            }));
            observationTypes.AgeType             = (ent.AgeType.Select(t => new AgeTypeModel {
                ID = t.AgeID, Value = t.Value
            }));

            protocol.ObservationTypes = observationTypes;
            return(protocol);
        }
        private ProtocolModel GetBestProtocolMatch(ProtocolModel observationModel, SortedList <String, ProtocolModel> protocolModels)
        {
            ProtocolModel bestProtocolMatch           = null;
            var           bestProtocolMatchDivergence = this.config.DivergenceThreshold; //the highest allowed distance for a valid protocol model match

            foreach (var protocolModel in this._protocolModels.Values)
            {
                var divergence = observationModel.GetAverageKullbackLeiblerDivergenceFrom(protocolModel);
                if (divergence < bestProtocolMatchDivergence)
                {
                    bestProtocolMatch           = protocolModel;
                    bestProtocolMatchDivergence = divergence;
                }
            }

            //TODO I have no idea why this is not working...
            //var _protocolModelsDivergences = new double[_protocolModels.Values.Count];
            //var _protocolModelsResulting = new ProtocolModel[_protocolModels.Values.Count];
            //Parallel.ForEach(_protocolModels.Values, (i, state, index) =>
            //{
            //    _protocolModelsDivergences[index] = observationModel.GetAverageKullbackLeiblerDivergenceFrom(i);
            //    _protocolModelsResulting[index] = i;
            //});

            //for (int index = 0; index < _protocolModelsDivergences.Length; index++)
            //{
            //    double divergence = _protocolModelsDivergences[index];
            //    if (bestProtocolMatchDivergence > divergence)
            //    {
            //        bestProtocolMatchDivergence = divergence;
            //        bestProtocolMatch = _protocolModelsResulting[index];
            //    }
            //}

            return(bestProtocolMatch);
        }
示例#23
0
        private void  除当前协议ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selectedNode == null || selectedNode.TagType != NodeSelectTag.TAGTYPE.Protocol)
            {
                MessageBox.Show("请正确选择协议");
                return;
            }

            ProtocolModel protocolModel = selectedNode.Model as ProtocolModel;

            if (protocolModel == null || string.IsNullOrEmpty(protocolModel.PID))
            {
                MessageBox.Show("请正确选择协议");
                return;
            }

            if (MessageBox.Show($"您确定要删除[{protocolModel.CName}]模块吗?谨慎操作", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                //DATA
                if (ProtocolDB.DeleteProtocol(protocolModel.PID))
                {
                    //UI
                    selectedNode.Target.Parent.Nodes.Remove(selectedNode.Target);
                    protocolModels.Remove(protocolModel);
                    myTree.Refresh();
                    selectedNode = null;

                    MessageBox.Show("删除成功");
                }
                else
                {
                    MessageBox.Show("协议删除失败,请联系管理员检查数据");
                    return;
                }
            }
        }
示例#24
0
 /// <summary>
 /// 导出c#代码
 /// </summary>
 /// <param name="_saveFolder"></param>
 public ExportCSharpCodes(string _saveFolder, ProtocolModel _model)
 {
     saveFolder = _saveFolder;
     ExportAsync(_model);
 }
示例#25
0
        public ActionResult ProtocolForm(Guid?id)
        {
            var user         = UserHelper.GetCurrentEmployee();
            var ppRepository = new PriceProjectRepository();

            PP_Protocols protocol;

            if (id.HasValue)
            {
                protocol = db.PP_Protocols.FirstOrDefault(x => x.Id == id.Value);
                if (protocol == null)
                {
                    LogHelper.Log.ErrorFormat("Не удалось найти протокол по идентификатору {0}", id.Value);
                    return(null);
                }
            }
            else
            {
                protocol = new PP_Protocols {
                    ProtocolDate = DateTime.Now,
                    Type         = (int)ProtocolType.Protocol1,
                    Status       = (int)ProtocolStatus.Draft,
                    Number       = ppRepository.GenerateProtocolNumber(),
                    IsImn        = false
                };
            }

            var model = new ProtocolModel {
                Guid     = Guid.NewGuid(),
                Protocol = protocol
            };

            if (protocol.Status == (int)ProtocolStatus.Draft)
            {
                ViewBag.Leadership = ppRepository.GetLeadership().ToList().Select(e => new SelectListItem
                {
                    Value = e.Id.ToString(),
                    Text  = e.FullName
                }).ToList();

                var list = new List <SelectListItem>();
                list.AddRange(EnumHelper.GetDisplayNameEnumList <ProtocolType>().ToList().Select(x => new SelectListItem
                {
                    Value = x.Key.ToString(),
                    Text  = x.Value
                }));
                ViewBag.ProtocolTypes = list;

                ViewBag.Requesters = ppRepository.GetRequesters().ToList().Select(e => new SelectListItem
                {
                    Value = e.Id.ToString(),
                    Text  = e.DisplayName
                }).ToList();
                return(PartialView(model));
            }
            else
            {
                ViewBag.HasEdit = model.Protocol.OwnerId == user.Id;

                var file = FileHelper.GetProtocolAttachFile(db, protocol.Id);
                if (file != null)
                {
                    ViewBag.AttFileName      = file.Name;
                    ViewBag.AttFileExtension = file.Extension;
                    ViewBag.AttFileSize      = file.Length;
                }

                var employee = ppRepository.GetEmployeeById(protocol.RequesterId.Value);
                ViewBag.RequesterDisplayName = employee != null ? employee.DisplayName : "";
                employee = ppRepository.GetEmployeeById(protocol.ChiefId.Value);
                ViewBag.ChiefDisplayName = employee != null ? employee.DisplayName : "";

                ViewBag.ComissionMembers = string.Join("<br/>", protocol.PP_ProtocolComissionMembers.Select(x => x.Employee.FullName).ToArray());

                return(PartialView("ProtocolFormView", model));
            }
        }
        public ProtocolInitializer GetProtocolInitializer(IReadOnlyCollection <TenantModel> tenantModels, ProtocolModel protocolModel,
                                                          Collaboration collaboration, WorkflowProperty dsw_p_CollaborationSignSummaryTemplateId, WorkflowProperty dsw_a_Collaboration_GenerateSignSummary,
                                                          WorkflowProperty dsw_p_ProposerRole, UDSDto udsDto)
        {
            ProtocolInitializer protInitializer = new ProtocolInitializer();

            // Oggetto
            protInitializer.Subject = protocolModel.Object;
            // Protocol Type
            protInitializer.ProtocolType = protocolModel.ProtocolType.EntityShortId;
            //Note
            protInitializer.Notes = protocolModel.Note;
            //Protocollo
            protInitializer.DocumentProtocol = protocolModel.DocumentProtocol;
            //Date
            protInitializer.DocumentDate = protocolModel.DocumentDate;
            // Classificazione
            if (protocolModel.Category != null && protocolModel.Category.IdCategory.HasValue)
            {
                protInitializer.Category = FacadeFactory.Instance.CategoryFacade.GetById(protocolModel.Category.IdCategory.Value);
            }
            if (protocolModel.Container != null && protocolModel.Container.IdContainer.HasValue)
            {
                protInitializer.Containers = new List <Data.Container> {
                    FacadeFactory.Instance.ContainerFacade.GetById(Convert.ToInt32(protocolModel.Container.IdContainer))
                };
            }
            if (protocolModel.DocumentTypeCode != null)
            {
                protInitializer.DocumentTypeLabel = FacadeFactory.Instance.TableDocTypeFacade.GetByCode(protocolModel.DocumentTypeCode).Description;
            }

            string owner = DocSuiteContext.Current.User.UserName;

            // Gestione documenti
            if (protocolModel.MainDocument != null && !string.IsNullOrEmpty(protocolModel.MainDocument.FileName) &&
                (protocolModel.MainDocument.ContentStream != null || protocolModel.MainDocument.DocumentId.HasValue))
            {
                protInitializer.MainDocument = SaveStream(owner, protocolModel.MainDocument);
            }

            // Allegati
            IEnumerable <DocumentModel> results = null;

            if (protocolModel.Attachments != null && (results = protocolModel.Attachments.Where(f => !string.IsNullOrEmpty(f.FileName) && (f.ContentStream != null || f.DocumentId.HasValue))).Any())
            {
                protInitializer.Attachments = SaveStream(owner, results);
            }

            if (collaboration != null && dsw_p_CollaborationSignSummaryTemplateId != null && dsw_a_Collaboration_GenerateSignSummary != null &&
                dsw_a_Collaboration_GenerateSignSummary.ValueBoolean.HasValue && dsw_a_Collaboration_GenerateSignSummary.ValueBoolean.Value &&
                dsw_p_CollaborationSignSummaryTemplateId.ValueGuid.HasValue && dsw_p_CollaborationSignSummaryTemplateId.ValueGuid.Value != Guid.Empty)
            {
                TemplateDocumentRepository templateDocumentRepository = WebAPIImpersonatorFacade.ImpersonateFinder(new TemplateDocumentRepositoryFinder(tenantModels),
                                                                                                                   (impersonationType, finder) =>
                {
                    finder.UniqueId     = dsw_p_CollaborationSignSummaryTemplateId.ValueGuid.Value;
                    finder.EnablePaging = false;
                    return(finder.DoSearch().SingleOrDefault()?.Entity);
                });

                if (templateDocumentRepository != null)
                {
                    BiblosChainInfo        biblosChainInfo    = new BiblosChainInfo(templateDocumentRepository.IdArchiveChain);
                    DocumentInfo           biblosDocumentInfo = biblosChainInfo.Documents.Single(f => !f.IsRemoved);
                    List <BuildValueModel> buildValueModels   = new List <BuildValueModel>();
                    buildValueModels.Add(new BuildValueModel()
                    {
                        IsHTML = false,
                        Name   = "oggetto",
                        Value  = protInitializer.Subject,
                    });
                    DateTime signDate;
                    string   token;
                    foreach (CollaborationSign item in collaboration.CollaborationSigns)
                    {
                        signDate = item.SignDate ?? item.LastChangedDate.Value.DateTime;
                        token    = signDate.DayOfWeek == DayOfWeek.Sunday ? "la" : "il";
                        buildValueModels.Add(new BuildValueModel()
                        {
                            IsHTML = false,
                            Name   = $"signer_info_{item.Incremental}",
                            Value  = $"{item.SignName} {token} {signDate.ToLongDateString()}",
                        });
                    }
                    buildValueModels = BuildValueProposerRole(dsw_p_ProposerRole, buildValueModels);
                    buildValueModels = BuildValueUDS(udsDto, buildValueModels);
                    byte[] pdf = Services.StampaConforme.Service.BuildPDF(biblosDocumentInfo.Stream, buildValueModels.ToArray(), string.Empty);
                    if (protInitializer.Attachments == null)
                    {
                        protInitializer.Attachments = new List <DocumentInfo>();
                    }
                    protInitializer.Attachments.Add(SaveStream(owner, pdf, "riepilogo_firmatari.pdf"));
                }
            }
            // Annessi
            results = null;
            if (protocolModel.Annexes != null && (results = protocolModel.Annexes.Where(f => !string.IsNullOrEmpty(f.FileName) && (f.ContentStream != null || f.DocumentId.HasValue))).Any())
            {
                protInitializer.Annexed = SaveStream(owner, results);
            }

            // Contatti
            protInitializer.Senders    = new List <Data.ContactDTO>();
            protInitializer.Recipients = new List <Data.ContactDTO>();
            if (protocolModel.ContactManuals != null && protocolModel.ContactManuals.Any())
            {
                foreach (ProtocolContactManualModel protocolContactManualModel in protocolModel.ContactManuals)
                {
                    Data.Contact contact = new Data.Contact();
                    contact.ContactType   = new Data.ContactType(Data.ContactType.Aoo);
                    contact.Description   = protocolContactManualModel.Description;
                    contact.CertifiedMail = protocolContactManualModel.CertifiedEmail;
                    contact.EmailAddress  = protocolContactManualModel.EMail;
                    if (!string.IsNullOrEmpty(protocolContactManualModel.Address))
                    {
                        contact.Address         = new Data.Address();
                        contact.Address.Address = protocolContactManualModel.Address;
                    }

                    if (protocolContactManualModel.ComunicationType == ComunicationType.Sender)
                    {
                        protInitializer.Senders.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Manual));
                    }
                    else
                    {
                        protInitializer.Recipients.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Manual));
                    }
                }
            }
            if (protocolModel.Contacts != null && protocolModel.Contacts.Any())
            {
                foreach (ProtocolContactModel protocolContactModel in protocolModel.Contacts)
                {
                    Data.Contact contact = FacadeFactory.Instance.ContactFacade.GetById(protocolContactModel.IdContact);
                    if (protocolContactModel.ComunicationType == ComunicationType.Sender)
                    {
                        protInitializer.Senders.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Address));
                    }
                    else
                    {
                        protInitializer.Recipients.Add(new Data.ContactDTO(contact, Data.ContactDTO.ContactType.Address));
                    }
                }
            }
            return(protInitializer);
        }
示例#27
0
        private string GetSavedDocsJson(string data)
        {
            dynamic              arr          = JsonConvert.DeserializeObject(data);
            List <int>           document     = new List <int>();
            List <string>        protocolname = new List <string>();
            List <DocumentModel> docs         = new List <DocumentModel>();

            using (UserContext db = new UserContext())
            {
                foreach (var el in arr)
                {
                    DocumentModel doc;

                    if (el.protocolname.ToString().Contains("000.0"))
                    {
                        doc = new DocumentModel
                        {
                            Date            = DateTime.Parse(el.date.ToString()),
                            StartDate       = DateTime.Parse(el.datestart.ToString()),
                            UserId          = int.Parse(el.uid.ToString()),
                            PatternId       = int.Parse(el.template.ToString()),
                            OrganizationId  = int.Parse(el.organization.ToString()),
                            SpecialtyId     = int.Parse(el.specialty.ToString()),
                            EducationTime   = el.educationtime.ToString(),
                            ProtocolName    = el.protocolname.ToString().Split('-')[0],
                            HandWriteFields = el.fields.ToString()
                        };
                        doc = db.DocumentModels.Add(doc);
                        PictureModel pic = db.PicturesModels.Find(doc.PatternId);
                        doc.BlankNumber = pic.BlankNumber;
                        pic.BlankNumber++;
                        db.Entry(pic).State = EntityState.Modified;
                        db.SaveChanges();
                        document.Add(doc.DocumentId);
                        return(JsonConvert.SerializeObject(document));
                    }
                    ProtocolModel pr = db.Protocols.Find(el.protocolname.ToString().Split('-')[0]);
                    if (pr == null)
                    {
                        pr = db.Protocols.Add(new ProtocolModel {
                            ProtocolName = el.protocolname.ToString().Split('-')[0]
                        });
                    }

                    if (pr != null && pr.DocumentModels.Any())
                    {
                        if (!protocolname.Contains(el.protocolname.ToString().Split('-')[0]))
                        {
                            protocolname.Add(el.protocolname.ToString().Split('-')[0]);
                        }

                        doc = pr.DocumentModels.FirstOrDefault(t => t.PatternId == int.Parse(el.template.ToString()) &&
                                                               t.UserId == int.Parse(el.uid.ToString()));
                        if (doc != null)
                        {
                            doc.Date            = DateTime.Parse(el.date.ToString());
                            doc.StartDate       = DateTime.Parse(el.datestart.ToString());
                            doc.UserId          = int.Parse(el.uid.ToString());
                            doc.PatternId       = int.Parse(el.template.ToString());
                            doc.OrganizationId  = int.Parse(el.organization.ToString());
                            doc.SpecialtyId     = int.Parse(el.specialty.ToString());
                            doc.EducationTime   = el.educationtime.ToString();
                            doc.ProtocolName    = el.protocolname.ToString().Split('-')[0];
                            doc.HandWriteFields = el.fields.ToString();
                            db.Entry(doc).State = EntityState.Modified;
                        }
                        else
                        {
                            doc = new DocumentModel
                            {
                                Date            = DateTime.Parse(el.date.ToString()),
                                StartDate       = DateTime.Parse(el.datestart.ToString()),
                                UserId          = int.Parse(el.uid.ToString()),
                                PatternId       = int.Parse(el.template.ToString()),
                                OrganizationId  = int.Parse(el.organization.ToString()),
                                SpecialtyId     = int.Parse(el.specialty.ToString()),
                                EducationTime   = el.educationtime.ToString(),
                                ProtocolName    = el.protocolname.ToString().Split('-')[0],
                                HandWriteFields = el.fields.ToString()
                            };
                            doc = db.DocumentModels.Add(doc);
                            PictureModel pic = db.PicturesModels.Find(doc.PatternId);
                            doc.BlankNumber = pic.BlankNumber;
                            pic.BlankNumber++;
                            db.Entry(pic).State = EntityState.Modified;
                        }
                    }
                    else
                    {
                        doc = new DocumentModel
                        {
                            Date            = DateTime.Parse(el.date.ToString()),
                            StartDate       = DateTime.Parse(el.datestart.ToString()),
                            UserId          = int.Parse(el.uid.ToString()),
                            PatternId       = int.Parse(el.template.ToString()),
                            OrganizationId  = int.Parse(el.organization.ToString()),
                            SpecialtyId     = int.Parse(el.specialty.ToString()),
                            EducationTime   = el.educationtime.ToString(),
                            ProtocolName    = el.protocolname.ToString().Split('-')[0],
                            HandWriteFields = el.fields.ToString()
                        };
                        doc = db.DocumentModels.Add(doc);
                        PictureModel pic = db.PicturesModels.Find(doc.PatternId);
                        doc.BlankNumber = pic.BlankNumber;
                        pic.BlankNumber++;
                        db.Entry(pic).State = EntityState.Modified;
                    }
                    docs.Add(doc);
                }
                foreach (string n in protocolname)
                {
                    ProtocolModel protocol = db.Protocols.Find(n);
                    if (protocol != null && db.Entry(protocol).State != EntityState.Added)
                    {
                        foreach (DocumentModel model in protocol.DocumentModels.ToArray())
                        {
                            if (db.Entry(model).State == EntityState.Unchanged)
                            {
                                db.DocumentModels.Remove(model);
                            }
                        }
                    }
                }
                db.SaveChanges();
                foreach (DocumentModel doc in docs)
                {
                    document.Add(doc.DocumentId);
                }
            }
            return(JsonConvert.SerializeObject(document));
        }
 private void sessionHandler_SessionProtocolModelCompleted(ISession session, ProtocolModel protocolModel)
 {
     //this.completedProtocolModels.Add(session, protocolModel);
     lock (this._completedProtocolModelsQueue) { this._completedProtocolModelsQueue.Enqueue(new KeyValuePair <ISession, ProtocolModel>(session, protocolModel)); }
 }
示例#29
0
 public ClassroomCollectionHelper(PresentationsListView parent, ProtocolModel protocol) : base(parent.m_EventQueue, protocol, "Classrooms")
 {
     this.m_Parent = parent;
     base.Initialize();
 }
示例#30
0
        private async void ExportAsync(ProtocolModel _model)
        {
            //获取协议的所有属性
            List <ProtocolAttributeModel> attributes = ProtocolDB.GetAttributes(_model.PID);

            StringBuilder sbr = await Task.Run(() =>
            {
                //代码结果集
                StringBuilder sb = new StringBuilder();

                sb.Append("//===================================================\r\n");
                sb.Append($"//创建时间:{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}\r\n");
                sb.Append("//备    注:\r\n");
                sb.Append("//===================================================\r\n");
                sb.Append("using System.Collections;\r\n");
                sb.Append("using System.Collections.Generic;\r\n");
                sb.Append("using System;\r\n");
                sb.Append("\r\n");
                sb.Append("/// <summary>\r\n");
                sb.Append($"/// {_model.CName}\r\n");
                sb.Append("/// </summary>\r\n");


                if (ProtocolDB.settingModel.UseNamespace)
                {
                    sb.AppendFormat($"namespace {ProtocolDB.settingModel.NamespaceContent}\r\n");
                    sb.AppendFormat("{{\r\n");//namespace Start
                }

                sb.Append($"public struct {_model.EName}Protocol\r\n");
                sb.AppendFormat("{{\r\n");//class Start
                sb.Append($"    public ushort Code {{ get {{ return {_model.Code}; }} }}\r\n");
                sb.Append("\r\n");

                #region 字段

                for (int i = 0; i < attributes.Count; i++)
                {
                    var att = attributes[i];

                    if (!string.IsNullOrEmpty(att.A2LoopEName))
                    {
                        //如果是从属某项循环的 不理会
                        continue;
                    }

                    //不从属循环的
                    if (att.IsLoop)
                    {
                        //如果当前是循环项
                        var loopAtts = attributes.Where(c => c.A2LoopEName == att.EName).OrderBy(c => c.Index).ToList();
                        for (int l = 0; l < loopAtts.Count; l++)
                        {
                            sb.Append($"    public List<{loopAtts[l].AType}> {loopAtts[l].EName}List; //{loopAtts[l].CName}\r\n");
                        }
                    }
                    else
                    {
                        //正常
                        sb.Append($"    public {att.AType} {att.EName}; //{att.CName}\r\n");
                    }
                }

                sb.Append("\r\n");

                #endregion

                #region ToArray

                sb.AppendFormat("    public byte[] ToArray()\r\n");
                sb.AppendFormat("    {{\r\n");//ToArray Start

                sb.AppendFormat("        using (JZ_MemoryStream ms = new JZ_MemoryStream())\r\n");
                sb.AppendFormat("        {{\r\n");//JZ_MemoryStream Start
                sb.AppendFormat("                ms.WriteUShort(Code);\r\n");

                for (int i = 0; i < attributes.Count; i++)
                {
                    var att = attributes[i];
                    if (!string.IsNullOrEmpty(att.A2LoopEName) || !string.IsNullOrEmpty(att.A2BoolEName) || !string.IsNullOrEmpty(att.A2StrEName))
                    {
                        //附属于其它属性的值 不处理 后面一起处理
                        continue;
                    }

                    if (att.IsLoop)
                    {
                        //本身是循环项
                        //查找依附于当前循环项的子项
                        var loopAtts = attributes.Where(c => c.A2LoopEName == att.EName).OrderBy(c => c.Index).ToList();
                        //输出子项数量
                        sb.AppendFormat($"            ms.WriteInt({loopAtts.Count});\r\n");
                        if (loopAtts != null && loopAtts.Count > 0)
                        {
                            for (int l = 0; l < loopAtts.Count; l++)
                            {
                                sb.Append($"for(int i=0;i<{loopAtts[l].EName}List.Count;i++)");
                                sb.AppendFormat("        {{\r\n");
                                sb.Append($"    ms.Write{ChangeTypeName(loopAtts[l].AType).Replace("()", "")} {loopAtts[l].EName}List[i]; //{loopAtts[l].CName}\r\n");
                                sb.AppendFormat("        }}\r\n");
                            }
                        }
                    }
                    else if (att.AType.ToLower() == "bool")
                    {
                        //正常
                        sb.AppendFormat($"            ms.Write{ChangeTypeName(att.AType).Replace("()", "")}({att.EName});\r\n");

                        //查看是否有关联项
                        var boolAtts = attributes.Where(c => c.A2BoolEName == att.EName).OrderBy(c => c.Index).ToList();
                        if (boolAtts != null && boolAtts.Count > 0)
                        {
                            //有bool关联
                            for (int b = 0; b < boolAtts.Count; b++)
                            {
                                string torf = att.A2Bool ? "" : "!";
                                sb.Append($"if({torf}{att.EName})");
                                sb.AppendFormat("        {{\r\n");
                                sb.Append($"    ms.Write{ChangeTypeName(boolAtts[b].AType).Replace("()", "")}({boolAtts[b].EName}); //{boolAtts[b].CName}\r\n");
                                sb.AppendFormat("        }}\r\n");
                            }
                        }
                    }
                    else if (att.AType.ToLower() == "string")
                    {
                        //本身是string项
                        //正常输出string内容
                        sb.AppendFormat($"            ms.Write{ChangeTypeName(att.AType).Replace("()", "")}({att.EName});\r\n");
                        //查找string附属
                        var stringAtts = attributes.Where(c => c.A2StrEName == att.EName).OrderBy(c => c.Index).ToList();
                        if (stringAtts != null && stringAtts.Count > 0)
                        {
                            for (int s = 0; s < stringAtts.Count; s++)
                            {
                                sb.Append($"if({att.EName}=={stringAtts[s].A2Str})");
                                sb.AppendFormat("        {{\r\n");
                                sb.Append($"    ms.Write{ChangeTypeName(stringAtts[s].AType).Replace("()", "")}({stringAtts[s].EName}); //{stringAtts[s].CName}\r\n");
                                sb.AppendFormat("        }}\r\n");
                            }
                        }
                    }
                    else
                    {
                        //其它项 正常处理
                        sb.AppendFormat("            ms.Write{0}({1});\r\n", ChangeTypeName(att.AType).Replace("()", ""), att.EName);
                    }
                }

                sb.AppendFormat("        }}\r\n"); //JZ_MemoryStream End
                sb.AppendFormat(" return ms.ToArray();\r\n");
                sb.AppendFormat("        }}\r\n"); //ToArray End

                #endregion

                #region ToProtocol


                sb.AppendFormat($"    public {_model.EName}Protocol ToProtocol(byte[] _buffer)\r\n");
                sb.AppendFormat("    {{\r\n");//ToProtocol Start
                sb.AppendFormat($"        {_model.EName}Protocol pro = new {_model.EName}Protocol();\r\n");
                sb.AppendFormat("        using (JZ_MemoryStream ms = new JZ_MemoryStream(_buffer))\r\n");
                sb.AppendFormat("        {{\r\n");//JZ_MemoryStream Start

                for (int i = 0; i < attributes.Count; i++)
                {
                    var att = attributes[i];
                    if (!string.IsNullOrEmpty(att.A2LoopEName) || !string.IsNullOrEmpty(att.A2BoolEName) || !string.IsNullOrEmpty(att.A2StrEName))
                    {
                        //附属于其它属性的值 不处理 后面一起处理
                        continue;
                    }

                    if (att.IsLoop)
                    {
                        //本身是循环项
                        //查找依附于当前循环项的子项
                        var loopAtts = attributes.Where(c => c.A2LoopEName == att.EName).OrderBy(c => c.Index).ToList();
                        //输出子项数量
                        sb.AppendFormat($"           int count= ms.ReadInt();\r\n");
                        if (loopAtts != null && loopAtts.Count > 0)
                        {
                            //字段初始化
                            for (int l = 0; l < loopAtts.Count; l++)
                            {
                                sb.Append($"    pro.{loopAtts[l].EName}List=new List<{loopAtts[l].AType}>();//{loopAtts[l].CName}\r\n");
                            }
                            //字段赋值
                            for (int l = 0; l < loopAtts.Count; l++)
                            {
                                sb.Append($"for(int i=0;i<count;i++)");
                                sb.AppendFormat("        {{\r\n");
                                sb.Append($"    pro.{loopAtts[l].EName}List.Add(ms.Read{ChangeTypeName(loopAtts[l].AType).Replace("()", "")}()); //{loopAtts[l].CName}\r\n");
                                sb.AppendFormat("        }}\r\n");
                            }
                        }
                    }
                    else if (att.AType.ToLower() == "bool")
                    {
                        //正常
                        sb.AppendFormat($"           pro.{att.EName}= ms.Read{ChangeTypeName(att.AType).Replace("()", "")}();\r\n");

                        //查看是否有关联项
                        var boolAtts = attributes.Where(c => c.A2BoolEName == att.EName).OrderBy(c => c.Index).ToList();
                        if (boolAtts != null && boolAtts.Count > 0)
                        {
                            //有bool关联
                            for (int b = 0; b < boolAtts.Count; b++)
                            {
                                string torf = att.A2Bool ? "" : "!";
                                sb.Append($"if({torf}{att.EName})");
                                sb.AppendFormat("        {{\r\n");
                                sb.Append($"   pro.{boolAtts[b].EName}= ms.Read{ChangeTypeName(boolAtts[b].AType).Replace("()", "")}(); //{boolAtts[b].CName}\r\n");
                                sb.AppendFormat("        }}\r\n");
                            }
                        }
                    }
                    else if (att.AType.ToLower() == "string")
                    {
                        //本身是string项
                        //正常输出string内容
                        sb.AppendFormat($"           pro.{att.EName}= ms.Read{ChangeTypeName(att.AType).Replace("()", "")}();\r\n");
                        //查找string附属
                        var stringAtts = attributes.Where(c => c.A2StrEName == att.EName).OrderBy(c => c.Index).ToList();
                        if (stringAtts != null && stringAtts.Count > 0)
                        {
                            for (int s = 0; s < stringAtts.Count; s++)
                            {
                                sb.Append($"if({att.EName}=={stringAtts[s].A2Str})");
                                sb.AppendFormat("        {{\r\n");
                                sb.Append($"   pro.{stringAtts[s].EName}= ms.Read{ChangeTypeName(stringAtts[s].AType).Replace("()", "")}(); //{stringAtts[s].CName}\r\n");
                                sb.AppendFormat("        }}\r\n");
                            }
                        }
                    }
                    else
                    {
                        //其它项 正常处理
                        sb.AppendFormat("           pro.{1}= ms.Read{0}();\r\n", ChangeTypeName(att.AType).Replace("()", ""), att.EName);
                    }
                }

                sb.AppendFormat("        return pro;\r\n");
                sb.AppendFormat("        }}\r\n"); //JZ_MemoryStream End
                sb.AppendFormat("        }}\r\n"); //ToProtocol End

                #endregion

                sb.AppendFormat("        }}\r\n");//class End


                if (ProtocolDB.settingModel.UseNamespace)
                {
                    sb.AppendFormat("}}\r\n");//namespace End
                }

                return(sb);
            });

            using (FileStream fs = new FileStream(string.Format("{0}/{1}Protocol.cs", saveFolder, _model.EName), FileMode.Create))
            {
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.Write(sbr.ToString());
                }
            }
        }