Esempio n. 1
0
 public DPE_PublicationData(string PublicationName, string dataname, CustomSortedList data)
 {
     this._publicationName = PublicationName;
     this._dataname        = dataname.ToUpper();
     this._data            = data;
     this._dataType        = DPE_ServerDefs.PublicationVariableDataType.DPE_DT_CFSortedList;
 }
Esempio n. 2
0
 public DPE_PublicationData(string PublicationName, string dataname, DataSet data)
 {
     this._publicationName = PublicationName;
     this._dataname        = dataname.ToUpper();
     this._data            = data;
     this._dataType        = DPE_ServerDefs.PublicationVariableDataType.DPE_DT_DataSet;
 }
        public void Button8_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                IEnumerator enumm       = default(IEnumerator);
                string      listElement = "";


                if (this.lstPostedPublicationVariables.Items.Count >= 0)
                {
                    enumm = this.lstPostedPublicationVariables.Items.GetEnumerator();

                    while (enumm.MoveNext())
                    {
                        listElement = System.Convert.ToString(enumm.Current);

                        string VariableName = this.GetSelectedPublicationVariableName(listElement);
                        DPE_ServerDefs.PublicationVariableDataType varType = this.GetSelectedPublicationVariableDataType(listElement);

                        //modifies the handler data for the
                        publicationsPosting.PublicationVariableDefinitionData varDef = this._ClientHandlerData.GetPublicationPostDefinition(this._publicationName).GetVariableDefinition(VariableName);
                        this._variablesHandlerContainer.AddVariableHandler(this._publicationName, ref varDef);
                    }


                    ClientHandlersDataContainer.GetInstance().SaveData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void AddVaribleToPublication(string variableName, DPE_ServerDefs.PublicationVariableDataType dataType)
 {
     variableName = variableName.ToUpper();
     if (!this._variablesToPublish.ContainsKey(variableName))
     {
         this._variablesToPublish.Add(variableName, dataType);
     }
 }
Esempio n. 5
0
 private void ValidateDataPublication(DPE_PublicationData data)
 {
     DPE_ServerDefs.PublicationVariableDataType type = default(DPE_ServerDefs.PublicationVariableDataType);
     type = this._variablesPublishedRegistry.GetDataVariablePublicationDataType(data.VariableName);
     if (type != data.DataType)
     {
         throw (new Exception("The data published as \'" + data.VariableName + "\' was declared to be of type \'" + type.ToString() + "\' and was received as \'" + data.DataType.ToString() + "\'"));
     }
 }
            internal void PostPublicationOnServer(DPE_ClientPublicationDefinition PublicationDefinition)
            {
                //crates the publication definition into a P2PData to send to the server
                CustomHashTable varsToPublish = new CustomHashTable();
                string          variableName  = "";

                DPE_ServerDefs.PublicationVariableDataType variableDataType = default(DPE_ServerDefs.PublicationVariableDataType);
                string variableDataTypeAsString = "";

                IEnumerator enumm = PublicationDefinition.VariablesToPublishTable.GetEnumerator();

                while (enumm.MoveNext())
                {
                    variableName             = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key);
                    variableDataType         = (DPE_ServerDefs.PublicationVariableDataType)(((DictionaryEntry)enumm.Current).Value);
                    variableDataTypeAsString = DPE_ServerDefs.Get_String_FromPublicationVariableDataType(variableDataType);
                    varsToPublish.Add(variableName, variableDataTypeAsString);
                }

                P2PData data = new P2PData(DPE_ServerDefs.DPE_CMD_CREATE_PUBLICATION, varsToPublish);

                data.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_PUBLICATIONS_GROUP, PublicationDefinition.PublicationsGroup);
                data.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_CLIENT_ID, this._STXDataSocketClient.ClientID);
                data.DataAttributesTable.AddAttribute(DPE_PublicationsDefinitions.DPE_PUBLICATION_NAME, PublicationDefinition.PublicationName);

                Services.P2PCommunicationsScheme.P2PPortClient p2pclient = default(Services.P2PCommunicationsScheme.P2PPortClient);
                try
                {
                    p2pclient = new Services.P2PCommunicationsScheme.P2PPortClient(this._STXDataSocketClient.DSSServerHostName, this._STXDataSocketClient.PublicationsPost_PortNumber);
                    p2pclient.Connect();

                    //sends the information to the server in order to create it
                    p2pclient.SendData(P2PDataSendMode.SyncrhonicalSend, data);

                    p2pclient.Dispose();

                    //it the publication was created in the server then ists definition is saved in the publications posted manager
                    //in order to allow it to re create ii if needed
                    this.AddPublicationDefinitionAfterCreation(PublicationDefinition);

                    string msg = "Publication \'" + PublicationDefinition.PublicationName + "\'    ->    POSTED succesfully.";
                    CustomEventLog.WriteEntry(EventLogEntryType.SuccessAudit, msg);
                }
                catch (Exception ex)
                {
                    try
                    {
                        this.RemovePublicationDefinition(PublicationDefinition);
                    }
                    catch (Exception)
                    {
                    }
                    string errMSg = "";
                    errMSg = "Error creating the publication \'" + PublicationDefinition.PublicationName + "\' : " + ex.Message;
                    throw (new Exception(errMSg));
                }
            }
Esempio n. 7
0
        public void btnOK_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtPublicationName.Text.Length <= 0)
                {
                    this.txtPublicationName.Focus();
                    throw (new Exception("No Publication Name specified"));
                }

                if (this.lstBoxPublicationVariables.Items.Count <= 0)
                {
                    throw (new Exception("No variables specified for the publication"));
                }

                DPE_ClientPublicationDefinition publication = default(DPE_ClientPublicationDefinition);

                if (this.txtPublicationsGroup.Text.Length > 0)
                {
                    publication = new DPE_ClientPublicationDefinition(this.txtPublicationsGroup.Text, this.txtPublicationName.Text);
                }
                else
                {
                    publication = new DPE_ClientPublicationDefinition(this.txtPublicationName.Text);
                }

                string varName = "";
                DPE_ServerDefs.PublicationVariableDataType varType = default(DPE_ServerDefs.PublicationVariableDataType);
                IEnumerator enumm = this._publicationVariables.GetEnumerator();
                while (enumm.MoveNext())
                {
                    varName = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key);
                    varType = (DPE_ServerDefs.PublicationVariableDataType)(((DictionaryEntry)enumm.Current).Value);
                    publication.AddVaribleToPublication(varName, varType);
                }

                this._client.CreateDataPublication(publication);

                //creation of support object to serialize publicatio creation data
                this._publicationsPostingData = new publicationsPosting.PostedPublicationDefinitionData(publication.PublicationName);
                enumm = this._publicationVariables.GetEnumerator();
                while (enumm.MoveNext())
                {
                    varName = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key);
                    varType = (DPE_ServerDefs.PublicationVariableDataType)(((DictionaryEntry)enumm.Current).Value);
                    publicationsPosting.PublicationVariableDefinitionData def = new publicationsPosting.PublicationVariableDefinitionData(varName, varType);
                    this._publicationsPostingData.AddVariableDefinition(def);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
 internal void AddDataVariablePublication(string dataName, DPE_ServerDefs.PublicationVariableDataType dataType)
 {
     dataName = dataName.ToUpper();
     lock (this._variablesTable)
     {
         if (!this._variablesTable.ContainsKey(dataName))
         {
             this._variablesTable.Add(dataName, dataType);
             this.AddVariableToDataTableRegistry(dataName, dataType);
         }
     }
 }
        private DPE_ServerDefs.PublicationVariableDataType GetSelectedPublicationVariableDataType(string listElement)
        {
            string element = listElement;

            string[] keys         = element.Split(new char[] { ',' });
            string   VariableName = keys[0];
            string   varTypeStr   = keys[1];

            varTypeStr = varTypeStr.TrimEnd(' ');
            varTypeStr = varTypeStr.TrimStart(' ');
            DPE_ServerDefs.PublicationVariableDataType varType = DPE_ServerDefs.Get_PublicationVariableDataType_FromString(varTypeStr);
            return(varType);
        }
Esempio n. 10
0
 internal void AddVariableToDataPublication(string dataName, DPE_ServerDefs.PublicationVariableDataType dataType)
 {
     this._variablesPublishedRegistry.AddDataVariablePublication(dataName, dataType);
     try
     {
         if (VariableAddedEvent != null)
         {
             VariableAddedEvent(this, dataName, dataType);
         }
     }
     catch (Exception)
     {
     }
 }
 private void AddVariableToDataTableRegistry(string dataname, DPE_ServerDefs.PublicationVariableDataType datataype)
 {
     try
     {
         dataname = dataname.ToUpper();
         DataRow newrow = this._publicationVariablesDataTable.NewRow();
         newrow["Variable Name"] = dataname;
         newrow["Data Type"]     = DPE_ServerDefs.Get_String_FromPublicationVariableDataType(datataype);
         this._publicationVariablesDataTable.Rows.Add(newrow);
     }
     catch (Exception)
     {
     }
 }
 internal DPE_ServerDefs.PublicationVariableDataType GetDataVariablePublicationDataType(string dataname)
 {
     dataname = dataname.ToUpper();
     if (this._variablesTable.ContainsKey(dataname))
     {
         DPE_ServerDefs.PublicationVariableDataType type = default(DPE_ServerDefs.PublicationVariableDataType);
         type = (DPE_ServerDefs.PublicationVariableDataType)(this._variablesTable[dataname]);
         return(type);
     }
     else
     {
         throw (new Exception("No variable named \'" + dataname + "\' registered in the container"));
     }
 }
 public DPE_ServerDefs.PublicationVariableDataType GetVariableDataType(string variableName)
 {
     variableName = variableName.ToUpper();
     if (this._tableAsHashTable.ContainsKey(variableName))
     {
         DPE_ServerDefs.PublicationVariableDataType type = default(DPE_ServerDefs.PublicationVariableDataType);
         type = (DPE_ServerDefs.PublicationVariableDataType) this._tableAsHashTable[variableName];
         return(type);
     }
     else
     {
         return(DPE_ServerDefs.PublicationVariableDataType.DPE_DT_Undefined);
     }
 }
Esempio n. 14
0
        public void btnOK_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtPublicationName.Text.Length <= 0)
                {
                    this.txtPublicationName.Focus();
                    throw (new Exception("No Publication Name specified"));
                }


                this.ValidateSelectedType();

                DPE_ClientPublicationDefinition publication = default(DPE_ClientPublicationDefinition);

                if (this.txtPublicationsGroup.Text.Length > 0)
                {
                    publication = new DPE_ClientPublicationDefinition(this.txtPublicationsGroup.Text, this.txtPublicationName.Text);
                }
                else
                {
                    publication = new DPE_ClientPublicationDefinition(this.txtPublicationName.Text);
                }



                this._publicationsPostingData = new publicationsPosting.PostedPublicationDefinitionData(publication.PublicationName);


                string variableName = "";
                DPE_ServerDefs.PublicationVariableDataType varType = default(DPE_ServerDefs.PublicationVariableDataType);

                for (this._variablesCount = 1; this._variablesCount <= this.nudNumberOfVariables.Value; this._variablesCount++)
                {
                    varType      = this.GetRandomDataType();
                    variableName = this.txtPublicationName.Text + "_VAR_" + System.Convert.ToString(this._variablesCount);
                    publication.AddVaribleToPublication(variableName, varType);

                    publicationsPosting.PublicationVariableDefinitionData def = new publicationsPosting.PublicationVariableDefinitionData(variableName, varType);
                    this._publicationsPostingData.AddVariableDefinition(def);
                }

                this._client.CreateDataPublication(publication);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.DialogResult = System.Windows.Forms.DialogResult.None;
            }
        }
 public DPE_ServerDefs.PublicationVariableDataType GetVariableDataTypeDefined(string variableName)
 {
     variableName = variableName.ToUpper();
     if (this._variablesToPublish.ContainsKey(variableName))
     {
         DPE_ServerDefs.PublicationVariableDataType type = default(DPE_ServerDefs.PublicationVariableDataType);
         type = (DPE_ServerDefs.PublicationVariableDataType) this._variablesToPublish[variableName];
         return(type);
     }
     else
     {
         throw (new Exception("The variable \'" + variableName + "\' is not contained in the publication \'" + this._publicationName + "\'"));
     }
 }
 public void AddVariable(string variableName, DPE_ServerDefs.PublicationVariableDataType dataType)
 {
     variableName = variableName.ToUpper();
     if (!this.ContainsVariableName(variableName))
     {
         //addition to the datatable
         DataRow row = default(DataRow);
         row = this._table.NewRow();
         row[DPE_ServerDefs.VARIBLE_NAME_TABLE_COLUMN_NAME] = variableName;
         row[DPE_ServerDefs.DATATYPE_TABLE_COLUMN_NAME]     = dataType.ToString();
         this._table.Rows.Add(row);
         //addition to the hash table
         this._tableAsHashTable.Add(variableName, dataType);
     }
 }
 private DPE_ServerDefs.PublicationVariableDataType GetSelectedPublicationVariableDataType()
 {
     if (this.lstPostedPublicationVariables.SelectedIndex >= 0)
     {
         string   element      = System.Convert.ToString(this.lstPostedPublicationVariables.SelectedItem);
         string[] keys         = element.Split(new char[] { ',' });
         string   VariableName = keys[0];
         string   varTypeStr   = keys[1];
         varTypeStr = varTypeStr.TrimEnd(' ');
         varTypeStr = varTypeStr.TrimStart(' ');
         DPE_ServerDefs.PublicationVariableDataType varType = DPE_ServerDefs.Get_PublicationVariableDataType_FromString(varTypeStr);
         return(varType);
     }
     else
     {
         throw new Exception("No selected element");
     }
 }
        public void Button7_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (this.lstPostedPublicationVariables.SelectedIndex >= 0)
                {
                    string VariableName = this.GetSelectedPublicationVariableName();
                    DPE_ServerDefs.PublicationVariableDataType varType = this.GetSelectedPublicationVariableDataType();

                    //modifies the handler data for the
                    publicationsPosting.PublicationVariableDefinitionData varDef = this._ClientHandlerData.GetPublicationPostDefinition(this._publicationName).GetVariableDefinition(VariableName);
                    this._variablesHandlerContainer.AddVariableHandler(this._publicationName, ref varDef);

                    ClientHandlersDataContainer.GetInstance().SaveData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 19
0
        private DPE_ServerDefs.PublicationVariableDataType GetRandomDataType()
        {
            DPE_ServerDefs.PublicationVariableDataType varType = default(DPE_ServerDefs.PublicationVariableDataType);

            int  typeByIndex = 0;
            bool typeFound   = false;

            while ((typeByIndex < 1 & typeByIndex > 5) || !typeFound)
            {
                Random random = new Random();
                typeByIndex = random.Next(1, 5);

                switch (typeByIndex)
                {
                case 1:
                    if (this.chkInteger.Checked)
                    {
                        varType   = DPE_ServerDefs.PublicationVariableDataType.DPE_DT_Integer;
                        typeFound = true;
                    }
                    break;

                case 2:
                    if (this.chkDEcimal.Checked)
                    {
                        varType   = DPE_ServerDefs.PublicationVariableDataType.DPE_DT_Decimal;
                        typeFound = true;
                    }
                    break;

                case 3:
                    if (this.chkBoolean.Checked)
                    {
                        varType   = DPE_ServerDefs.PublicationVariableDataType.DPE_DT_Boolean;
                        typeFound = true;
                    }
                    break;

                case 4:
                    if (this.chkString.Checked)
                    {
                        varType   = DPE_ServerDefs.PublicationVariableDataType.DPE_DT_String;
                        typeFound = true;
                    }
                    break;

                case 5:
                    if (this.chkDataTable.Checked)
                    {
                        varType   = DPE_ServerDefs.PublicationVariableDataType.DPE_DT_DataTable;
                        typeFound = true;
                    }
                    break;

                default:
                    typeFound = false;
                    break;
                }
            }

            return(varType);
        }
 public PublicationVariableDefinitionData(string variableName, CommunicationsLibrary.DataPublicationsEnvironment.Definitions.DPE_ServerDefs.PublicationVariableDataType dataType)
 {
     this._variableName = variableName;
     this._publicationVariableDAtaType = dataType;
 }
 private void VariableAddedToPublication_EventHandlerFcn(DPE_Publication publication, string variableName, DPE_ServerDefs.PublicationVariableDataType variableType)
 {
     try
     {
         this.SetPublishedVariablesCountOfPublication(publication);
     }
     catch (Exception)
     {
     }
 }