Thursday, February 1, 2018

My freelancing journey

Hey everyone! It's been a while since I last used this. I've done several things since I last wrote here. I am now working in UPRM with NEXT. Aside from that I am also working on my own freelance projects, which is what I intend to talk about here.

On 2016 I got an opportunity to create a web page for a local company. The company sells medical equipment to different hospitals around Puerto Rico. The page was mostly promotional, just some text, images and descriptions of the different equipments sold by the company. I finished this web page around January 2017, mostly because my contacts with the company were extremely busy and they couldn't meet with me to discuss the details. On the beginning of January 2017 they payed me and all was well. My contact with that company, who is also a personal friend and ex-coworker, recommended me to someone who needed an application. And this is the beginning of my journey with my current client.

My new client and I met in January 2017. He explained his needs and we agreed on a web application. Though I am not allowed to disclose too much details, the functionality of the application was simple: it was mostly input data and save in db. I began this project mid January 2017. I made the web application using Python Flask and MySQL, and Dreamhost Hosting. By early February I already had a working application which my client would begin testing. My client's goal was to sell this application as a service to other big clients. So the testing process began and, obviously, along the way changes were made and new features were added.

My client was able to convince a big client of his to buy the application as a service. There was to be a pilot program to test out the app, and if everything went well they would begin a contract. There was a "pre pilot" where one of the bigger issues was that the web application was dependent on internet, and most of the areas where the application was being used had no internet access. My client and I discussed the possibility of developing a mobile application. The idea was that the mobile application would save data locally on the device, and then at the end of the day the users would synchronize their data to the already existing database in the hosting.

By September, my client was convinced that the mobile application was absolutely necessary. We talked about starting the application and the process began. Unfortunately, during that time, hurricane Maria hit. Everyone knows the great tragedy it brought. Fortunately for me I was not as deeply affected by Maria as most people were, and STILL ARE. I was out of electricity for 16 days and my water service was never out. 2 weeks after I got electricity back, I got my internet service back. During this time I was in contact with my client and, fortunately, he still wanted the application. So as soon as I got my electric service back I started working (it was a bit tough without internet at first). By January 2018, the application was finished. I used Ionic Framework and Python Flask for the API that handles the synchronization process. It was very tough to learn Ionic, but with perseverance and will power I pulled through.

In January my client and I began testing the application, every aspect of it. He also got other people to test it out. In the process bugs were fixed and features were added, like before. Today is the first day of the pilot program for the big client of my client. The application was installed in iOS and Android devices, and now we will know for sure if the application is working as intended. I'm not gonna lie, I'm a little bit nervous. We'll see how everything goes, but hopefully it will be a success.

I have to say, I have learned a lot during this time. My goal is to go completely freelance, and be able to live working under my terms. I have ways to go to reach my goal but I will work hard for it. At the moment, I am working simultaneously on a project with two friends. My intention in returning to this blog is to document my coding process again. It will not only help me (and others) on future references, but it will also help with the documenting process related to the project. I will blog about any project I'm currently working on. I hope that through these entries I am able to help anyone reading this.

Tuesday, September 15, 2015

Using DevExpress to create a mobile responsive page

Well the page is already made, what I need to do is change some of the elements inside the page to be more mobile friendly. It is quite the task, since the web page is using DevExpress and is already made in a way that might be difficult to change. In this case, I'm trying to make the login page mobile friendly. I think I might end up making a new one, should it prove too difficult to change the existing one.

EDIT 1: I'm checking out this website:

http://www.formget.com/how-to-make-simple-responsive-form-for-a-website/#

It seems to do what I want, even though it is not DevExpress. I don't like DevExpress. It simplifies some things and complicates others. Maybe I can just use this for the parts that should be mobile responsive like the login.

EDIT 2: Decided not to use the resource above. It is a couple of CSS files, but the whole project is in DevExpress. I should figure out how to do it in DevExpress. It won't be easy, since I've read as much as I could on mobile response in DevExpress and there's not a lot to go on.

EDIT 3: Again changed my mind and went with bootstrap. I followed through the simple login I made not too long ago and it's turning out pretty good. I just need to test it in mobile to make sure it works as intended.

EDIT 4: Login is looking good, I just need to test it on mobile.

EDIT 5: My problem now is publishing the project, which is not letting me. I am using my local IIS to enter through my phone so I can see the result. To achieve that I had to set my IIS to a port and then open that port in the Windows Firewall. But the problem now is the project won't publish. The error I'm getting says  Error : Copying file Inventory\Attachments\13_634703859621110000_Linchpin.htm

I'll see what I can get from that.

EDIT 6: I was able to fix the error. The problem was that even though in the folder that file didn't exist, in the Solution Explorer it did, along with many other "ghost" files. Thanks to this stackoverflow answer I was able to figure it out:

http://stackoverflow.com/questions/7969531/vs2010-wants-to-publish-a-non-existant-file-how-do-i-change-it

Now I'm getting an error related to the config file, but I'll figure it out eventually. If it becomes too much trouble I'll blog about it.

Web page won't show Bootstrap style

For some reason the web page I am publishing is not showing the Bootstrap style. The style is shown in the mobile browser and when I'm debugging, but when I try to access the page where I published it in ANY browser on my laptop, the Bootstrap style isn't shown. I intend to get to the bottom of this today. But I have no idea what could this be. If the style is shown in debugging and in the mobile browser, why isn't it shown in the normal PC browsers?
EDIT 1: SyntaxError: expected expression, got '==='

That's the error I'm getting. I don't know where those '===' are coming from, I check the line that's throwing the error and those equal signs are not there. The text is the same except for those equal signs.

EDIT 2: Well I forgot I didn't publish this, but I did solve it. The thing is, there was no problem at all. And I did refresh everything in the browsers, but what solved it was changing Internet connections. Weird as it sounds, but that's what did it.

Monday, August 31, 2015

Javascript function executing before jQuery finished loading data

It's been a while. Mostly because I haven't done anything serious that has taken me too much work to figure out. So here is the situation:

I'm bringing data to my web page from a Web Service and I store it in local storage, so I can use it offline. The problem? Some of that data is used to load dropdowns. But when I execute the dropdown loading function some of the data is not yet in the local storage. I assume the jQuery is executing asynchronous to the dropdown loading function, or any other Javascript function for that matter. I will have to find some way to confirm all the data is in the local storage, then execute the load dropdown.

EDIT 1: Well I solved THAT quickly! I had a function which parsed all the data then that function called three more functions which loaded the respective dropdown with their data as parameters. What I did was eliminate that function and only kept the three which were being called. The data I was loading there I loaded directly in the respective function. And, the most important, used a function in the .ajax jQuery called "complete", which executes after the success and failure. In each complete, I executed the dropdown loading function respective to each one.

Friday, June 26, 2015

Deserialize JSON Object in C#

As soon as I'm done with this the project is basically done. I mean, the important part is sending and receiving data through the Web Service using JSON. I can already receive it, but I still need to send it. In my past entry, I explained how I communicated with C# by Javascript. Now, I receive a big string which is a "stringified" JSON array. What I need to do deserialize that data so that I can correctly separate the data and then INSERT it to the database. This is the code I have right now:

    [WebMethod]
    public void SyncToServer(string D)
    {
        Console.Write(D);
        var jobs = JsonConvert.DeserializeObject<Job[]>(D);
        Console.WriteLine();
    }

The string D is the JSON I'm receiving. D has a string which is the JSON array. The class Job has the exact same fields that the JSON has, so it shouldn't be a problem. And that is the exact solution I've read in every place I've searched. But it's not working. The error I'm getting is the following:

An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code
Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Job' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
I will continue to try and deserialize it.

UPDATE: I now copied the JSON array string to a variable and tried executing the same code, but no change. I suspect it has to be the way I'm doing it is incorrect. I still have to keep investigating.

UPDATE 2: I tried making the JSON in the variable a JSON object with the whole array as a parameter, but it's still not working.

UPDATE 3: Wow... The problem was the JSON. It was incorrectly formatted, it had a couple of extra brackets that didn't go there. That's why it wasn't recognizing the format. Now that I've managed to figure out where the flaw was, time to go back to the Javascript and find out where exactly is it going wrong in creating the JSON.

UPDATE 4: GOT IT! In the Javascript I changed the way I was writing the JSON in the localstorage. If the localstorage was empty, I pushed the object into an array then placed it on the localstorage. The problem was that it was inserting the whole object as an array, and I needed to insert just the object. Success!

Thursday, June 25, 2015

Sending JSON to C#

I'm trying to POST a JSON from Javascript to a C# asmx. Apparently there is an error trying to deserialize the JSON. I've already tried creating a class with the same parameters, but somehow it didn't work. I also tried deserializing the JSON to a string List, but to no avail. The JSON is an array, and it comes in string format. I'm trying to get into it. We'll see how it goes.

UPDATE: So the error I was getting has changed. Originally I had this:

Type 'System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is not supported for deserialization of an array

Now, I'm getting this:

  1. Invalid web service call, missing value for parameter: 'job'."
  2. StackTrace" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters) ↵ at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters) ↵ at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) ↵ at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)"

I would like to thank the following link for providing some light to my problem: http://blog.dj-djl.com/2013/05/type-systemcollectionsgenericidictionar.html

Now, according to that link, one of the problems I had was placing the JSON Array in a simple JSON object. So what I'm assuming is that you can't send it as an array, but you can send it as JSON Object and make the array a parameter. I'm not sure if that makes sense as I wrote it.

As I wrote this, I realize that the class I'm using to get the JSON is not declared as an array. This could be why I'm getting that error. I will verify and update.

UPDATE 2: Changed it to array but it didn't work. I'm going to keep verifying some things but I might just try to use a string list instead of the object I created for the JSON to get the data. Be back in a few.

UPDATE 3: Changed the name of the object to match the name of the parameter in the JSON and to no avail. BUT

  1. Message"Cannot convert object of type 'System.String' to type 'Job[]'"
  2. StackTrace" at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) ↵ at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) ↵ at System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary`2 rawParams) ↵ at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters) ↵ at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) ↵ at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)"

The error message changed. It can't be converted to the type of object I defined. Why? I'm not completely sure, but I have a feeling it's because the array of data that I need is inside a parameter.

UPDATE 4: Changed the object to a string array and I still get an error.

UPDATE 5: FUCKING GOT IT!!!!! Ok so what happened was that when I placed the JSON Array inside a JSON parameter, I no longer needed to get a string array, but rather one string which is all of the array. Now I get all of the array in string format. What follows is parsing that string to get the information I need. For now I'm ending it here.