/// <summary>
        ///     The hook callback.
        /// </summary>
        /// <param name="nCode">
        ///     The n code.
        /// </param>
        /// <param name="wParam">
        ///     The w param.
        /// </param>
        /// <param name="lParam">
        ///     The l param.
        /// </param>
        /// <returns>
        ///     The <see cref="IntPtr" />.
        /// </returns>
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (wParam == (IntPtr)WM_KEYDOWN)
            {
                var notepads = Process.GetProcessesByName("notepad");
                if (notepads.Length > 0)
                {
                    if (notepads[0] != null && notepads[0].MainWindowTitle.ToUpper() == "CHAT.TXT - NOTEPAD")
                    {
                        var virtualkCode = Marshal.ReadInt32(lParam);
                        if (virtualkCode != 13)
                        {
                            LineChat.Append((char)virtualkCode);
                        }

                        if (virtualkCode == 13)
                        {
                            trigger.DataContext =
                                EncodingDecoding.EncodingString2Bytes(
                                    string.Concat("[", ConfigurationBag.Configuration.PointName, "]: ",
                                                  LineChat.ToString()));
                            LineChat.Clear();
                            InternalActionTrigger(trigger, InternalContext);
                        }
                    }
                }
            }

            return(CallNextHookEx(hookId, nCode, wParam, lParam));
        }
Exemplo n.º 2
0
        private static void SetEventOnRampMessageReceivedMessage(byte[] message)
        {
            string stringValue = EncodingDecoding.EncodingBytes2String(message);

            Console.WriteLine("---------------EVENT RECEIVED IN GRABCASTER LIBRARY---------------");
            Console.WriteLine(stringValue);
        }
        public byte[] Execute(ActionEvent actionEvent, ActionContext context)
        {
            try
            {
                var script = string.Empty;
                if (!string.IsNullOrEmpty(ScriptFileEvent))
                {
                    script = File.ReadAllText(ScriptFileEvent);
                }
                else
                {
                    script = ScriptEvent;
                }

                var powerShellScript = PowerShell.Create();
                powerShellScript.AddScript(script);

                // TODO 1020
                powerShellScript.AddParameter("DataContext", DataContext);
                powerShellScript.Invoke();
                var outVar = powerShellScript.Runspace.SessionStateProxy.PSVariable.GetValue("DataContext");
                if (outVar != null)
                {
                    DataContext = EncodingDecoding.EncodingString2Bytes(outVar.ToString());
                    actionEvent(this, context);
                }
                return(null);
                // TODO 1030
            }
            catch (Exception)
            {
                // ignored
                return(null);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     The event received from embedded.
        /// </summary>
        /// <param name="eventType">
        ///     The event type.
        /// </param>
        /// <param name="context">
        ///     The context.
        /// </param>
        private static void EventReceivedFromEmbedded(IEventType eventType, ActionContext context)
        {
            string stringValue = EncodingDecoding.EncodingBytes2String(eventType.DataContext);

            Console.WriteLine("---------------EVENT RECEIVED FROM EMBEDDED LIBRARY---------------");
            Console.WriteLine(stringValue);
        }
Exemplo n.º 5
0
        public byte[] Execute(ActionTrigger actionTrigger, ActionContext context)
        {
            try
            {
                //Start Service
                // Start Web API interface

                engineHost = new PageOneMessageTriggerWebServiceHost(typeof(PageOneMessageTrigger),
                                                                     new Uri(WebApiEndPoint));
                engineHost.AddServiceEndpoint(typeof(IPageOneMessage), new WebHttpBinding(), ConfigurationBag.EngineName);
                var stp = engineHost.Description.Behaviors.Find <ServiceDebugBehavior>();
                stp.HttpHelpPageEnabled = false;

                input                    = "/auth";
                engineHost.This          = this;
                engineHost.Context       = context;
                engineHost.ActionTrigger = actionTrigger;
                engineHost.Open();
                Thread.Sleep(Timeout.Infinite);
                return(null);
            }
            catch (Exception ex)
            {
                DataContext = EncodingDecoding.EncodingString2Bytes(ex.Message);
                actionTrigger(this, context);
                ActionTrigger = actionTrigger;
                Context       = context;
                return(EncodingDecoding.EncodingString2Bytes(ex.Message));
            }
        }
Exemplo n.º 6
0
 public string SendMessage(iPageOneMessage pageOneMessage)
 {
     ActionTrigger(this, Context);
     //Wait for sync
     waitHandle.WaitOne();
     return(EncodingDecoding.EncodingBytes2String(DataContext));
 }
Exemplo n.º 7
0
    protected void ChatButton_Click(object sender, EventArgs e)
    {
        string query = EncodingDecoding.EncodeMd5(ResultsGridView.SelectedDataKey.Value.ToString());

        Session["ChatID"] = query;
        Response.Redirect("chat.aspx");
    }
        public void SyncAsyncActionReceived(byte[] content)
        {
            string guidBack = EncodingDecoding.EncodingBytes2String(content);

            Console.WriteLine($"EVTE {guidBack} - {DateTime.UtcNow.Second + ":" + DateTime.UtcNow.Millisecond}");

            WaitHandle.Set();
        }
Exemplo n.º 9
0
        public string Auth()
        {
            object s = engineHost;

            engineHost.ActionTrigger(engineHost.This, engineHost.Context);
            //Wait for sync
            waitHandle.WaitOne();
            return(EncodingDecoding.EncodingBytes2String(engineHost.DataContext));
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Print the tag code of the scanned tag
        /// </summary>
        /// <param name="sender">
        ///     The sender.
        /// </param>
        /// <param name="e">
        ///     The e.
        /// </param>
        private void RfidTag(object sender, TagEventArgs e)
        {
            var rfidTag = new RfidTag {
                TagId = e.Tag, BankId = "4433EB52-240A-44CC-8A3B-B6673E1E0B31"
            };

            var tagString = JsonConvert.SerializeObject(rfidTag);

            DataContext = EncodingDecoding.EncodingString2Bytes(tagString);
            ActionTrigger(this, Context);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     The my on entry written.
        /// </summary>
        /// <param name="source">
        ///     The source.
        /// </param>
        /// <param name="e">
        ///     The e.
        /// </param>
        public void MyOnEntryWritten(object source, EntryWrittenEventArgs e)
        {
            var eventViewerMessage = new EventViewerMessage
            {
                EntryType   = e.Entry.EntryType,
                MachineName = e.Entry.MachineName,
                Message     = e.Entry.Message,
                Source      = e.Entry.Source,
                TimeWritten = e.Entry.TimeWritten
            };
            var serializedMessage = JsonConvert.SerializeObject(eventViewerMessage);

            DataContext = EncodingDecoding.EncodingString2Bytes(serializedMessage);
            ActionTrigger(this, Context);
        }
Exemplo n.º 12
0
        private void buttonTry_Click(object sender, EventArgs e)
        {
            prpassemblyfile =
                @"C:\Users\Nino\Documents\SnapGate\SnapGate.Framework\BizTalk.Laoratory\PipelineLaboratory\PipelineLaboratory\bin\Debug\PipelineLaboratory.dll";
            prppipetype      = "PipelineLaboratory.ReceivePipelineFlat";
            prpinputinstance =
                @"C:\Users\Nino\Documents\SnapGate\SnapGate.Framework\BizTalk.Laoratory\PipelineLaboratory\PipelineLaboratory\TestFile.txt";
            prpfilename =
                @"C:\Users\Nino\Documents\SnapGate\SnapGate.Framework\BizTalk.Laoratory\PipelineLaboratory\PipelineLaboratory\ReceivePipelineFlat.btp";
            byte[] content = BizTalkPipelines.ExecutePipeline(prpassemblyfile, prpassemblyfile, prppipetype,
                                                              prpinputinstance, prpfilename);
            string s = EncodingDecoding.EncodingBytes2String(content);

            MessageBox.Show(s);
        }
Exemplo n.º 13
0
 public byte[] Execute(ActionEvent actionEvent, ActionContext context)
 {
     try
     {
         var content = EncodingDecoding.EncodingBytes2String(DataContext);
         var twilio  = new TwilioRestClient(AccountSid, AuthToken);
         var text    = content.Replace("\"", string.Empty).Replace("\\", string.Empty);
         twilio.SendMessage(From, To, text);
         return(null);
         // SetEventActionEvent(this, context);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        /// <summary>
        ///     Serialize Array to Object
        /// </summary>
        /// <param name="arrayBytes">
        ///     Array byte to deserialize
        /// </param>
        /// <returns>
        ///     Object deserialized
        /// </returns>
        public static object ByteArrayToObject(byte[] arrayBytes)
        {
            if (arrayBytes == null)
            {
                return(EncodingDecoding.EncodingString2Bytes(string.Empty));
            }

            var memoryStream    = new MemoryStream();
            var binaryFormatter = new BinaryFormatter();

            memoryStream.Write(arrayBytes, 0, arrayBytes.Length);
            memoryStream.Seek(0, SeekOrigin.Begin);
            var obj = binaryFormatter.Deserialize(memoryStream);

            return(obj);
        }
Exemplo n.º 15
0
 public byte[] Execute(ActionEvent actionEvent, ActionContext context)
 {
     try
     {
         Debug.WriteLine("In MessageBoxEvent Event.");
         var message = EncodingDecoding.EncodingBytes2String(DataContext);
         MessageBox.Show(message);
         actionEvent(this, context);
         return(null);
     }
     catch (Exception ex)
     {
         Debug.WriteLine("MessageBoxEvent error > " + ex.Message);
         actionEvent(this, null);
         return(null);
     }
 }
 public byte[] Execute(ActionTrigger actionTrigger, ActionContext context)
 {
     try
     {
         if (input.Length != 0)
         {
             actionTrigger(this, context);
         }
         return(DataContext);
     }
     catch (Exception ex)
     {
         DataContext = EncodingDecoding.EncodingString2Bytes(ex.Message);
         actionTrigger(this, context);
         ActionTrigger = actionTrigger;
         Context       = context;
         return(EncodingDecoding.EncodingString2Bytes(ex.Message));
     }
 }
        public byte[] Execute(ActionTrigger actionTrigger, ActionContext context)
        {
            try
            {
                while (true)
                {
                    using (var myConnection = new SqlConnection(ConnectionString))
                    {
                        var selectCommand = new SqlCommand(SqlQuery, myConnection);
                        myConnection.Open();
                        XmlReader readerResult = null;
                        try
                        {
                            readerResult = selectCommand.ExecuteXmlReader();
                            readerResult.Read();
                        }
                        catch (Exception)
                        {
                        }

                        if (!readerResult.EOF)
                        {
                            var xdoc = new XmlDocument();
                            xdoc.Load(readerResult);
                            if (xdoc.OuterXml != string.Empty)
                            {
                                DataContext = EncodingDecoding.EncodingString2Bytes(xdoc.OuterXml);
                                //myConnection.Close();
                                actionTrigger(this, context);
                            }
                        }
                        Thread.Sleep(PollingTime);
                    }
                }
                return(null);
            }
            catch (Exception)
            {
                // ignored
                return(null);
            }
        }
Exemplo n.º 18
0
    /// <summary>
    /// Handles the Click event of the AcceptedButton control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void AcceptedButton_Click(object sender, EventArgs e)
    {
        int bookingId = int.Parse(ResultsGridView.SelectedDataKey.Value.ToString());

        if (DetailsView.Rows[2].Cells[1].Text == "Taxi")
        {
            string        path = Server.MapPath("~/App_Data/Logs/") + "BookingLogNo_" + bookingId.ToString() + ".xml";
            List <string> list = new List <string>();
            list = (List <string>)Application[EncodingDecoding.EncodeMd5(bookingId.ToString())];
            if (list != null)
            {
                Data.CreateLog(list, path);
            }
            Application.Clear();
        }
        string status = "ACCEPTED";

        Data.UpdateBooking(bookingId, "", status);
        Response.Redirect(Request.RawUrl);
    }
        public byte[] Execute(ActionEvent actionEvent, ActionContext context)
        {
            try
            {
                DataContext = EncodingDecoding.EncodingString2Bytes(To);
                //Console.WriteLine("In event before handle");
                //Console.WriteLine($"EVENT {context.BubblingConfiguration.MessageId} - {DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")}");

                actionEvent(this, context);

                return(null);
            }
            catch (Exception ex)
            {
                DataContext = EncodingDecoding.EncodingString2Bytes(ex.Message);
                ;
                actionEvent(this, context);
                return(null);
            }
        }
        /// <summary>
        ///     Return the complete configuration
        /// </summary>
        /// <returns>
        ///     The <see cref="Stream" />.
        /// </returns>
        /// http://localhost:8000/GrabCaster/Configuration
        public Stream Configuration()
        {
            try
            {
                return(SyncProvider.GetConfiguration());
            }
            catch (Exception ex)
            {
                var docMain       = new XmlDocument();
                var errorTemplate = docMain.CreateElement(string.Empty, "Error", string.Empty);
                var errorText     = docMain.CreateTextNode(ex.Message);
                errorTemplate.AppendChild(errorText);

                var currentWebContext = WebOperationContext.Current;
                if (currentWebContext != null)
                {
                    currentWebContext.OutgoingResponse.ContentType = "text/xml";
                }
                return(new MemoryStream(EncodingDecoding.EncodingString2Bytes(errorTemplate.OuterXml)));
            }
        }
        public byte[] Execute()
        {
            try
            {
                string content     = EncodingDecoding.EncodingBytes2String(DataContext);
                byte[] contentBack = BizTalkPipelines.ExecutePipeline(AssemblyFile, AssemblyFile, PipelineTypeName,
                                                                      content, PipelinePathFile);
                return(contentBack);
            }
            catch (Exception ex)
            {
                LogEngine.WriteLog(ConfigurationBag.EngineName,
                                   $"Error in {MethodBase.GetCurrentMethod().Name}",
                                   Constant.LogLevelError,
                                   Constant.TaskCategoriesError,
                                   ex,
                                   Constant.LogLevelError);

                return(null);
            }
        }
Exemplo n.º 22
0
        public byte[] Execute(ActionEvent actionEvent, ActionContext context)
        {
            var content  = EncodingDecoding.EncodingBytes2String(DataContext);
            var notepads = Process.GetProcessesByName("notepad");

            if (notepads.Length == 0)
            {
                return(null);
            }

            if (notepads[0] != null && notepads[0].MainWindowTitle.ToUpper() == "CHAT.TXT - NOTEPAD")
            {
                EmptyClipboard();
                var child  = FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Edit", null);
                var length = SendMessageGetTextLength(child, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);
                SendMessage(child, EM_SETSEL, length, length); // search end of file position
                content += "\r\n";
                SendMessage(child, EM_REPLACESEL, 1, content); // append new line
            }
            return(null);
        }
 /// <summary>
 ///     Execute an internal trigger
 /// </summary>
 /// <param name="triggerId">
 /// </param>
 /// <param name="configurationId"></param>
 /// <returns>
 ///     The <see cref="string" />.
 /// </returns>
 /// http://localhost:8000/GrabCaster/ExecuteTrigger?ConfigurationID={5D793BC4-B111-4BF4-BAAF-196F661E13E2}&TriggerID={9A989BD1-C8DE-4FC1-B4BA-02E7D8A4AD76}&value=text
 public string ExecuteTrigger(string configurationId, string triggerId, string value)
 {
     try
     {
         var BubblingObjects = (from trigger in EventsEngine.BubblingTriggerConfigurationsSingleInstance
                                where trigger.IdComponent == triggerId && trigger.IdConfiguration == (configurationId ?? "")
                                select trigger).ToArray();
         if (BubblingObjects.Length != 0)
         {
             byte[] content = EncodingDecoding.EncodingString2Bytes(value ?? "");
             EventsEngine.ExecuteTriggerConfiguration(BubblingObjects[0], content);
             return("Trigger executed.");
         }
         return
             ($"Trigger not found. - Looking for Trigger Id {triggerId} and configuration Id {configurationId}.");
     }
     catch (Exception ex)
     {
         return
             ($"Trigger not executed check the Windows event viewer and check the trigger Id and configuration Id are present and active in the trigger folder - Looking for Trigger Id {triggerId} and configuration Id {configurationId} - Exception {ex.Message}.");
     }
 }
        public byte[] Execute(ActionTrigger actionTrigger, ActionContext context)
        {
            try
            {
                //setGetDataTrigger = GetDataTrigger;
                //DynamicRESTService.StartService(WebApiEndPoint);
                string guid     = string.Empty;
                string guidBack = string.Empty;
                //EventBehaviour eventBehaviour = (EventBehaviour)Enum.Parse(typeof(EventBehaviour), Behaviour);
                WaitHandle = new AutoResetEvent(false);
                while (true)
                {
                    guid = Guid.NewGuid().ToString();
                    //context.EventBehaviour = eventBehaviour;
                    Console.WriteLine($"TRGT {guid} - {DateTime.UtcNow.Second + ":" + DateTime.UtcNow.Millisecond}");
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    DataContext = EncodingDecoding.EncodingString2Bytes(guid);
                    actionTrigger(this, context);
                    WaitHandle.WaitOne();
                    stopwatch.Stop();
                    guidBack = EncodingDecoding.EncodingBytes2String(DataContext);
                    Console.WriteLine($"EVTT {guidBack} - {DateTime.UtcNow.Second + ":" + DateTime.UtcNow.Millisecond}");

                    long elapsed_time = stopwatch.ElapsedMilliseconds;
                    Console.WriteLine($"Response in {elapsed_time}");
                    Console.WriteLine($"0.5 second waitining...");
                    Thread.Sleep(500);
                }
            }
            catch (Exception ex)
            {
                DataContext = EncodingDecoding.EncodingString2Bytes(ex.Message);
                actionTrigger(this, context);
                ActionTrigger = actionTrigger;
                Context       = context;
                return(EncodingDecoding.EncodingString2Bytes(ex.Message));
            }
        }
        public byte[] Execute(ActionEvent actionEvent, ActionContext context)
        {
            try
            {
                var rfidtag      = EncodingDecoding.EncodingBytes2String(DataContext);
                var dialogResult = MessageBox.Show(
                    $"Authorization for TAG code {rfidtag}.",
                    "Authorization TAG",
                    MessageBoxButtons.YesNo);
                DataContext =
                    EncodingDecoding.EncodingString2Bytes(dialogResult == DialogResult.Yes
                        ? true.ToString()
                        : false.ToString());

                actionEvent(this, context);
                return(null);
            }

            catch
            {
                // ignored
                return(null);
            }
        }
        /// <summary>
        ///     Send a EventMessage message
        /// </summary>
        public static bool SendMessage(LogMessage logMessage)
        {
            try
            {
                Debug.WriteLine("LogEventUpStream - serialize log message.");
                //Create EH data message
                var jsonSerialized    = JsonConvert.SerializeObject(logMessage);
                var serializedMessage = EncodingDecoding.EncodingString2Bytes(jsonSerialized);

                var data = new EventData(serializedMessage);
                Debug.WriteLine("LogEventUpStream - send log message.");

                //Send the metric to Event Hub
                eventHubClient.Send(data);
                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("LogEventUpStream - error->{0}", ex.Message);

                EventLog.WriteEntry("Framework.Log.EventHubs", ex.Message, EventLogEntryType.Error);
                return(false);
            }
        }
Exemplo n.º 27
0
        public static byte[] ExecutePipeline(string assemblyfile, string assdirectory, string pipetype,
                                             string inputinstance, string filename)
        {
            IBaseMessage inputMessage = MessageHelper.CreateFromStream(LoadMessage(inputinstance));
            Assembly     btAssembly;

            btAssembly = Assembly.LoadFrom(assemblyfile);
            string AssemblyName = btAssembly.FullName;

            Type t = btAssembly.GetType(pipetype);

            //set pype type
            string        pipelinetype = GetPipeTypeRecOrSend(filename);
            Type          tschema      = null;
            List <string> values       = null;

            //Get spec doc
            string specdoc = "";
            string assname = "";

            MessageCollection rppoutputMessages = null;
            IBaseMessage      sppoutputMessages = null;
            StreamReader      rdr = null;

            byte[] returnContent = null;
            try
            {
                switch (pipelinetype)
                {
                case "ReceivePipeline":
                    RWPipeline rppwrapper = MainPipelineHelper.RetReceivePipeline(t);
                    values = getspecandassnamefrompipeline(filename,
                                                           "/Document/Stages/Stage/Components/Component/Properties/Property[@Name='DocumentSpecName']/Value",
                                                           assemblyfile, assdirectory);

                    foreach (string s in values)
                    {
                        specdoc = s.Substring(0, s.IndexOf('|'));
                        assname = s.Substring(s.IndexOf('|') + 1);

                        Assembly prjAssembly = Assembly.LoadFrom(assname);
                        tschema = prjAssembly.GetType(specdoc);

                        if (tschema == null)
                        {
                            //MessageBox.Show("Cannot find schema document in " + assname);
                            returnContent = null;
                        }
                    }


                    rppwrapper.AddDocSpec(tschema);
                    rppoutputMessages = rppwrapper.Execute(inputMessage);
                    rdr = new StreamReader(rppoutputMessages[0].BodyPart.Data);
                    string contentRp = rdr.ReadToEnd();
                    returnContent = EncodingDecoding.EncodingString2Bytes(contentRp);
                    break;

                case "SendPipeline":
                    SWPipeline sppwrapper = MainPipelineHelper.RetSendPipeline(t);
                    values = getspecandassnamefrompipeline(filename,
                                                           "/Document/Stages/Stage/Components/Component/Properties/Property[@Name='DocumentSpecName']/Value",
                                                           assemblyfile, assdirectory);

                    foreach (string s in values)
                    {
                        specdoc = s.Substring(0, s.IndexOf('|'));
                        assname = s.Substring(s.IndexOf('|') + 1);

                        Assembly prjAssembly = Assembly.LoadFrom(assname);
                        tschema = prjAssembly.GetType(specdoc);

                        if (tschema == null)
                        {
                            //MessageBox.Show("Cannot find schema document in " + assname);
                            returnContent = null;
                        }
                    }

                    sppwrapper.AddDocSpec(tschema);
                    sppoutputMessages = sppwrapper.Execute(inputMessage);
                    rdr = new StreamReader(sppoutputMessages.BodyPart.Data);
                    string contentSp = rdr.ReadToEnd();
                    returnContent = EncodingDecoding.EncodingString2Bytes(contentSp);
                    break;

                default:
                    //MessageBox.Show("Select a correct pipeline.");
                    returnContent = null;
                    break;

                    //***********************************************************
                }

                return(returnContent);
            }
            catch (Exception ex)
            {
                string fileresult = assdirectory + Path.GetFileNameWithoutExtension(inputinstance) + "_" +
                                    Guid.NewGuid() + "txt";
                File.WriteAllText(fileresult, "Error: " + ex.Message + "\r\n\r\n" + ex.StackTrace);
                Process.Start("IExplore.exe", fileresult);
                return(returnContent);
            }
        }
Exemplo n.º 28
0
 /// <summary>
 ///     Loads a message from disk
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public static Stream LoadMessage(string value)
 {
     return(new MemoryStream(EncodingDecoding.EncodingString2Bytes(value ?? "")));
 }
Exemplo n.º 29
0
 /// <summary>
 ///     Saves a message to disk
 /// </summary>
 /// <param name="path"></param>
 /// <param name="data"></param>
 internal static void SaveMessage(string value, Stream data)
 {
     data = new MemoryStream(EncodingDecoding.EncodingString2Bytes(value ?? ""));
 }
Exemplo n.º 30
0
    /// <summary>
    /// Handles the Click event of the SubmitButton control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        LotusDataContext db = new LotusDataContext(Data.ConnectionManager());
        int    dataId       = (from d in db.form_datas select d.form_data_id).Max() + 1;
        string user         = Page.User.Identity.Name;
        List <form_field_definition> listControls = Data.GetControls(PageID);

        foreach (form_field_definition control in listControls)
        {
            string   sValue = null;
            bool?    bValue = null;
            DateTime?dValue = null;
            string   ctrlId = control.form_field_name.Replace(" ", "");
            switch (control.input_type)
            {
            case "txtBox":
            case "txtArea":
                sValue = ((TextBox)this.FindControl(ctrlId)).Text;
                break;

            case "ddList":
                sValue = ((DropDownList)this.FindControl(ctrlId)).SelectedValue;
                break;

            case "chkBox":
                bValue = ((CheckBox)this.FindControl(ctrlId)).Checked;
                break;

            case "chkBoxList":
                CheckBoxList chkList = (CheckBoxList)this.FindControl(ctrlId);
                foreach (ListItem item in chkList.Items)
                {
                    if (item.Selected)
                    {
                        sValue += item.Text + ", ";
                    }
                }
                break;

            case "radioBtnList":
                sValue = ((RadioButtonList)this.FindControl(ctrlId)).SelectedValue;
                break;

            case "datePicker":
                int day   = int.Parse(((DropDownList)this.FindControl("days")).SelectedValue);
                int month = int.Parse(((DropDownList)this.FindControl("months")).SelectedValue);
                int year  = int.Parse(((DropDownList)this.FindControl("years")).SelectedValue);
                dValue = new DateTime(year, month, day);
                break;

            case "timePicker":
                sValue = ((DropDownList)this.FindControl("hours")).SelectedValue + ":" + ((DropDownList)this.FindControl("minutes")).SelectedValue;
                break;

            case "addressCtrl":
                string city    = ((DropDownList)this.FindControl("city" + control.default_value)).SelectedValue;
                string region  = ((DropDownList)this.FindControl("region" + control.default_value)).SelectedValue;
                string address = ((TextBox)this.FindControl("address1" + control.default_value)).Text;
                sValue = address + ", " + region + ", " + city;
                break;
            }
            Data.InsertData(dataId, control.form_field_definition_id, PageID, control.input_type, sValue, bValue, dValue);
        }
        Data.InsertBooking(dataId, PageID, Page.User.Identity.Name);
        LogedinPanel.Visible  = true;
        SubmitPanel.Visible   = false;
        ThankYouPanel.Visible = true;
        if (ModuleData != "taxi")
        {
            Session["Service"] = ModuleData;
            SendMail();
        }
        else
        {
            string query = EncodingDecoding.EncodeMd5(dataId.ToString());
            Session["ChatID"]  = query;
            Session["Service"] = ModuleData;
            Response.Redirect("chat.aspx");
        }
    }