Commits

Afriza N. Arief committed a85226f

Added "Fix Zohor" Prayer Time functionality and default to x86 Processor Architecture

Comments (0)

Files changed (6)

Form1.Designer.cs

             this.label1 = new System.Windows.Forms.Label();
             this.txtboxXmlUri = new System.Windows.Forms.TextBox();
             this.progressBar1 = new System.Windows.Forms.ProgressBar();
+            this.btnFixZohor = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // listView
             this.progressBar1.Size = new System.Drawing.Size(285, 24);
             this.progressBar1.TabIndex = 7;
             // 
+            // btnFixZohor
+            // 
+            this.btnFixZohor.Location = new System.Drawing.Point(326, 382);
+            this.btnFixZohor.Name = "btnFixZohor";
+            this.btnFixZohor.Size = new System.Drawing.Size(164, 36);
+            this.btnFixZohor.TabIndex = 8;
+            this.btnFixZohor.Text = "Fix Zohor";
+            this.btnFixZohor.UseVisualStyleBackColor = true;
+            this.btnFixZohor.Click += new System.EventHandler(this.btnFixZohor_Click);
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(519, 434);
+            this.Controls.Add(this.btnFixZohor);
             this.Controls.Add(this.progressBar1);
             this.Controls.Add(this.txtboxXmlUri);
             this.Controls.Add(this.label1);
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.TextBox txtboxXmlUri;
         private System.Windows.Forms.ProgressBar progressBar1;
+        private System.Windows.Forms.Button btnFixZohor;
     }
 }
 
 
             if (this.googleAuthToken == null)
             {
-                GoogleClientLogin loginDialog = new GoogleClientLogin(this.calendarService, "youremailhere@gmail.com");
+                GoogleClientLogin loginDialog = new GoogleClientLogin(this.calendarService, "user@gmail.com");
                 loginDialog.ShowDialog();
 
                 this.googleAuthToken = loginDialog.AuthenticationToken;
                         }
                     }
                 }
-                catch (Exception ex)
+                catch (Exception )
                 {
                 }
 
             this.progressBar1.Value = processedRecords;
             Application.DoEvents();
         }
+
+        private void btnFixZohor_Click(object sender, EventArgs e)
+        {
+            if (//txtboxInputFilePath.Text.Length == 0 ||
+                txtboxXmlUri.Text.Length == 0)
+                return;
+            Console.WriteLine("Started..");
+            try
+            {
+                /*
+                Stream stream = openFileDialog1.OpenFile();
+                if (stream != null)
+                {
+                    StreamReader sr = new StreamReader(stream);
+                    string line = null;
+                    while ((line = sr.ReadLine()) != null)
+                    {
+                        ProcessOneTxtLinePrayers(line);
+                    }
+                    if (FlushBatch())
+                    {
+                        processedRecords += batchCounter;
+                        UpdateProgressBar();
+                        batchCounter = 0;
+                    }
+                }
+                */
+                EventQuery evtQuery = new EventQuery(txtboxXmlUri.Text);
+                evtQuery.NumberToRetrieve = 100;
+                evtQuery.FutureEvents = true;
+                evtQuery.StartTime = new DateTime(2011, 01, 01);
+                evtQuery.EndTime = new DateTime(2012, 01, 01);
+                evtQuery.Query = "Zohor";
+
+                EventFeed feedResult = calendarService.Query(evtQuery);
+                AtomFeed batchFeed = new AtomFeed(feedResult);
+
+                do
+                {
+                    foreach (EventEntry evtEntry in feedResult.Entries)
+                    {
+                        bool needFix = false;
+                        foreach (When when in evtEntry.Times)
+                        {
+                            if (when.StartTime.Hour == 00)
+                            {
+                                needFix = true;
+                                when.StartTime = when.StartTime.Subtract(new TimeSpan(12, 0, 0));
+                            }
+                            if (when.EndTime.Hour == 00)
+                            {
+                                needFix = true;
+                                when.EndTime = when.EndTime.Subtract(new TimeSpan(12, 0, 0));
+                            }
+                        }
+                        if (needFix)
+                        {
+                            evtEntry.BatchData = new GDataBatchEntryData(GDataBatchOperationType.update);
+                            batchFeed.Entries.Add(evtEntry);
+                            if (batchFeed.Entries.Count >= 50)
+                            {
+                                AtomFeed batchResultFeed = calendarService.Batch(batchFeed, new Uri(feedResult.Batch));
+                                bool succeed = true;
+                                foreach (var entry in batchResultFeed.Entries)
+                                {
+                                    if (entry.BatchData.Status.Code != 200)
+                                    {
+                                        succeed = false;
+                                        Console.WriteLine("Failed to update: " + entry);
+                                    }
+                                }
+
+                                if (succeed)
+                                   Console.WriteLine("Succeeded updating " + batchFeed.Entries.Count + " entries.");
+
+                                batchFeed = new AtomFeed(feedResult);
+                            }
+                        }
+                    }
+                    if (batchFeed.Entries.Count > 0)
+                    {
+                        AtomFeed batchResultFeed = calendarService.Batch(batchFeed, new Uri(feedResult.Batch));
+                        bool succeed = true;
+                        foreach (var entry in batchResultFeed.Entries)
+                        {
+                            if (entry.BatchData.Status.Code != 200)
+                            {
+                                succeed = false;
+                                Console.WriteLine("Failed to update: " + entry);
+                            }
+                        }
+
+                        if (succeed)
+                            Console.WriteLine("Succeeded updating " + batchFeed.Entries.Count + " entries.");
+
+                        batchFeed = new AtomFeed(feedResult);
+                    }
+                    if (feedResult.NextChunk == null)
+                        break;
+                    feedResult = calendarService.Query(new EventQuery(feedResult.NextChunk));
+                } while (feedResult.Entries.Count > 0);
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex);
+            }
+            Console.WriteLine("Finished..");
+        }
     }
 }

GoogleClientLogin.cs

         private void Login_Click(object sender, System.EventArgs e)
         {
             this.service.setUserCredentials(this.Username.Text, this.Password.Text);
-            this.authToken = this.service.QueryAuthenticationToken();
+            //this.authToken = this.service.QueryAuthenticationToken();
+            this.authToken = this.service.QueryClientLoginToken();
             this.Close();
         }
     }

Import_MUIS_PrayerTimes.csproj

   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}</ProjectGuid>
     <OutputType>WinExe</OutputType>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>x86</PlatformTarget>
+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Google.GData.AccessControl, Version=1.1.3.31163, Culture=neutral, PublicKeyToken=b4b8eb9a7afc8328, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>

Import_MUIS_PrayerTimes.sln

 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
+		Debug|x86 = Debug|x86
 		Release|Any CPU = Release|Any CPU
+		Release|x86 = Release|x86
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Debug|x86.ActiveCfg = Debug|x86
+		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Debug|x86.Build.0 = Debug|x86
 		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Release|x86.ActiveCfg = Release|x86
+		{F8AA5A27-4DD4-4635-8E9A-DD97AC7AA017}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

Import_MUIS_PrayerTimes.suo

Binary file modified.